feat(backend/receiving): normalize type via category resolver, rollback source on qty edit, aggregate production received_qty
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
import type { Response } from "express";
|
||||
import { getPool } from "../database/db";
|
||||
import type { AuthenticatedRequest } from "../types/auth";
|
||||
import { resolveCategoryCode } from "../utils/categoryUtils";
|
||||
import { adjustInventory } from "../utils/inventoryUtils";
|
||||
import { logger } from "../utils/logger";
|
||||
|
||||
@@ -127,6 +128,14 @@ export async function create(req: AuthenticatedRequest, res: Response) {
|
||||
const insertedRows: any[] = [];
|
||||
|
||||
for (const item of items) {
|
||||
// 저장용 value_code (조건 분기는 원본 item.outbound_type 유지)
|
||||
const resolvedItemOutboundType = await resolveCategoryCode(
|
||||
client,
|
||||
"outbound_mng",
|
||||
"outbound_type",
|
||||
item.outbound_type,
|
||||
);
|
||||
|
||||
const result = await client.query(
|
||||
`INSERT INTO outbound_mng (
|
||||
id, company_code, outbound_number, outbound_type, outbound_date,
|
||||
@@ -152,7 +161,7 @@ export async function create(req: AuthenticatedRequest, res: Response) {
|
||||
[
|
||||
companyCode,
|
||||
outbound_number || item.outbound_number,
|
||||
item.outbound_type,
|
||||
resolvedItemOutboundType,
|
||||
outbound_date || item.outbound_date,
|
||||
item.reference_number || null,
|
||||
item.customer_code || null,
|
||||
@@ -260,7 +269,7 @@ export async function create(req: AuthenticatedRequest, res: Response) {
|
||||
locCode,
|
||||
String(-outQty),
|
||||
afterQty,
|
||||
item.outbound_type || "출고",
|
||||
resolvedItemOutboundType || "출고",
|
||||
userId,
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user