feat: Implement duplicate inbound registration check and enhance receiving page
- Added a check in the receiving controller to prevent duplicate inbound registrations based on the inbound number, ensuring idempotency. - Updated the receiving page to maintain selected items across different inbound types, improving user experience. - Enhanced the item mapping logic to utilize inventory unit codes, ensuring accurate data representation. - Adjusted the layout to include a new column for inbound type in the receiving table, providing better visibility of item classifications.
This commit is contained in:
@@ -198,6 +198,17 @@ export async function create(req: AuthenticatedRequest, res: Response) {
|
||||
}
|
||||
const insertedDetails: any[] = [];
|
||||
|
||||
// 기존 디테일이 있으면 스킵 (멱등성 — 같은 inbound_number로 2번 호출 방지)
|
||||
const existingDetails = await client.query(
|
||||
`SELECT COUNT(*) AS cnt FROM inbound_detail WHERE company_code = $1 AND inbound_id = $2`,
|
||||
[companyCode, inboundNumber]
|
||||
);
|
||||
if (parseInt(existingDetails.rows[0].cnt, 10) > 0) {
|
||||
await client.query("COMMIT");
|
||||
client.release();
|
||||
return res.json({ success: true, data: [], message: "이미 등록된 입고입니다." });
|
||||
}
|
||||
|
||||
// 2. 디테일 INSERT (inbound_detail) + 재고/발주 업데이트
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
|
||||
Reference in New Issue
Block a user