fixed wrong date inserting
This commit is contained in:
		@@ -5,7 +5,7 @@ import responseCodes from '../response/responseCodes.js';
 | 
			
		||||
 | 
			
		||||
class ProductService {
 | 
			
		||||
    async create(groupid, localid, abstract_product_id, amount, date_of_production, expiry_date) {
 | 
			
		||||
        await db.query("INSERT INTO products (group_id, local_id, abstract_product_id, amount, date_of_production, expiry_date) VALUES ($1, $2, $3, $4, $5, $6)", [groupid, localid, abstract_product_id, amount, date_of_production, expiry_date])
 | 
			
		||||
        await db.query("INSERT INTO products (group_id, local_id, abstract_product_id, amount, date_of_production, expiry_date) VALUES ($1, $2, $3, $4, to_timestamp($5)::date, to_timestamp($6)::date)", [groupid, localid, abstract_product_id, amount, date_of_production, expiry_date])
 | 
			
		||||
            .catch((e) => {
 | 
			
		||||
                errorHandler(e, "product")
 | 
			
		||||
            });
 | 
			
		||||
@@ -27,14 +27,14 @@ class ProductService {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async updateDateOfProduction(groupId, localId, date_of_production) {
 | 
			
		||||
        await db.query("UPDATE products SET date_of_production = $1 WHERE group_id = $2 AND local_id = $3", [date_of_production, groupId, localId])
 | 
			
		||||
        await db.query("UPDATE products SET date_of_production = to_timestamp($1)::date WHERE group_id = $2 AND local_id = $3", [date_of_production, groupId, localId])
 | 
			
		||||
            .catch((e) => {
 | 
			
		||||
                errorHandler(e, "dateofproduction")
 | 
			
		||||
            });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async updateExpiryDate(groupId, localId, expiry_date) {
 | 
			
		||||
        await db.query("UPDATE products SET expiry_date = $1 WHERE group_id = $2 AND local_id = $3", [expiry_date, groupId, localId])
 | 
			
		||||
        await db.query("UPDATE products SET expiry_date = to_timestamp($1)::date WHERE group_id = $2 AND local_id = $3", [expiry_date, groupId, localId])
 | 
			
		||||
            .catch((e) => {
 | 
			
		||||
                errorHandler(e, "expirydate")
 | 
			
		||||
            });
 | 
			
		||||
@@ -59,4 +59,4 @@ class ProductService {
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default new ProductService();
 | 
			
		||||
export default new ProductService();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user