Improve production plan operations
This commit is contained in:
@@ -900,9 +900,9 @@ const updateProductionPlanStatus = async (id, status) => {
|
||||
try {
|
||||
await client.query('BEGIN');
|
||||
const planResult = await client.query(`
|
||||
UPDATE production_plans
|
||||
SET status = $1,
|
||||
completed_at = CASE WHEN $1 = 'finished' THEN COALESCE(completed_at, CURRENT_TIMESTAMP) ELSE NULL END,
|
||||
UPDATE production_plans
|
||||
SET status = $1::text,
|
||||
completed_at = CASE WHEN $1::text = 'finished' THEN COALESCE(completed_at, CURRENT_TIMESTAMP) ELSE NULL END,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = $2
|
||||
RETURNING id;
|
||||
@@ -913,9 +913,9 @@ const updateProductionPlanStatus = async (id, status) => {
|
||||
throw error;
|
||||
}
|
||||
await client.query(`
|
||||
UPDATE production_orders
|
||||
SET status = $1,
|
||||
completed_date = CASE WHEN $1 = 'finished' THEN COALESCE(completed_date, CURRENT_DATE) ELSE completed_date END,
|
||||
UPDATE production_orders
|
||||
SET status = $1::text,
|
||||
completed_date = CASE WHEN $1::text = 'finished' THEN COALESCE(completed_date, CURRENT_DATE) ELSE completed_date END,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE production_plan_id = $2
|
||||
AND status NOT IN ('finished', 'canceled');
|
||||
|
||||
Reference in New Issue
Block a user