refactor: Update logistics and inspection pages for improved field labels and validation

- Changed field labels for clarity in logistics info page, updating "유형" to "업체유형" and enhancing placeholders for better user guidance.
- Added required validation for fields in both logistics and inspection forms, ensuring essential data is captured before submission.
- Introduced dynamic generation of route names based on departure and destination inputs in the logistics info page.
- Enhanced inspection management page with additional user options and improved handling of inspection types and criteria.

These changes aim to enhance user experience and data integrity across logistics and inspection functionalities.
This commit is contained in:
kjs
2026-04-03 16:02:14 +09:00
parent 64e26f2c3f
commit eee20c6581
7 changed files with 1513 additions and 253 deletions

View File

@@ -201,13 +201,32 @@ export async function create(req: AuthenticatedRequest, res: Response) {
// 재고 레코드가 없으면 0으로 생성 (마이너스 방지)
await client.query(
`INSERT INTO inventory_stock (
company_code, item_code, warehouse_code, location_code,
id, company_code, item_code, warehouse_code, location_code,
current_qty, safety_qty, last_out_date,
created_date, updated_date, writer
) VALUES ($1, $2, $3, $4, '0', '0', NOW(), NOW(), NOW(), $5)`,
) VALUES (gen_random_uuid()::text, $1, $2, $3, $4, '0', '0', NOW(), NOW(), NOW(), $5)`,
[companyCode, itemCode, whCode, locCode, userId]
);
}
// 재고 이력 기록 (inventory_history)
const afterStockRes = await client.query(
`SELECT current_qty FROM inventory_stock
WHERE company_code = $1 AND item_code = $2
AND COALESCE(warehouse_code, '') = COALESCE($3, '')
AND COALESCE(location_code, '') = COALESCE($4, '')
LIMIT 1`,
[companyCode, itemCode, whCode || '', locCode || '']
);
const afterQty = afterStockRes.rows[0]?.current_qty || '0';
await client.query(
`INSERT INTO inventory_history (
id, company_code, item_number, warehouse_code, location_code,
history_type, history_date, change_qty, after_qty, reason,
created_by, created_date
) VALUES (gen_random_uuid()::text, $1, $2, $3, $4, '출고', NOW()::date, $5, $6, $7, $8, NOW())`,
[companyCode, itemCode, whCode, locCode, String(-outQty), afterQty, item.outbound_type || '출고', userId]
);
}
// 판매출고인 경우 출하지시의 ship_qty 업데이트

View File

@@ -253,6 +253,25 @@ export async function create(req: AuthenticatedRequest, res: Response) {
[companyCode, itemCode, whCode, locCode, String(inQty), userId]
);
}
// 2b-2. 재고 이력 기록 (inventory_history)
const afterStockRes = await client.query(
`SELECT current_qty FROM inventory_stock
WHERE company_code = $1 AND item_code = $2
AND COALESCE(warehouse_code, '') = COALESCE($3, '')
AND COALESCE(location_code, '') = COALESCE($4, '')
LIMIT 1`,
[companyCode, itemCode, whCode || '', locCode || '']
);
const afterQty = afterStockRes.rows[0]?.current_qty || String(inQty);
await client.query(
`INSERT INTO inventory_history (
id, company_code, item_number, warehouse_code, location_code,
history_type, history_date, change_qty, after_qty, reason,
created_by, created_date
) VALUES (gen_random_uuid()::text, $1, $2, $3, $4, '입고', NOW()::date, $5, $6, $7, $8, NOW())`,
[companyCode, itemCode, whCode, locCode, String(inQty), afterQty, item.inbound_type || '입고', userId]
);
}
// 2c. 구매입고인 경우 발주의 received_qty 업데이트 — 기존 로직 유지
@@ -516,6 +535,25 @@ export async function deleteReceiving(req: AuthenticatedRequest, res: Response)
AND COALESCE(location_code, '') = COALESCE($5, '')`,
[inQty, companyCode, itemCode, whCode || '', locCode || '']
);
// 입고취소 이력 기록
const afterStockRes = await client.query(
`SELECT current_qty FROM inventory_stock
WHERE company_code = $1 AND item_code = $2
AND COALESCE(warehouse_code, '') = COALESCE($3, '')
AND COALESCE(location_code, '') = COALESCE($4, '')
LIMIT 1`,
[companyCode, itemCode, whCode || '', locCode || '']
);
const afterQty = afterStockRes.rows[0]?.current_qty || '0';
await client.query(
`INSERT INTO inventory_history (
id, company_code, item_number, warehouse_code, location_code,
history_type, history_date, change_qty, after_qty, reason,
created_by, created_date
) VALUES (gen_random_uuid()::text, $1, $2, $3, $4, '입고취소', NOW()::date, $5, $6, '입고 삭제에 의한 롤백', $7, NOW())`,
[companyCode, itemCode, whCode, locCode, String(-inQty), afterQty, userId]
);
}
// 구매입고 발주 롤백: purchase_order_mng 기반