From 70736bd8f68034b3045a3e7d401d2f1219514ca4 Mon Sep 17 00:00:00 2001 From: chpark Date: Thu, 7 May 2026 20:09:16 +0900 Subject: [PATCH] =?UTF-8?q?fix(momo=20orders):=20=ED=83=9D=EB=B0=B0/?= =?UTF-8?q?=EC=9A=A9=EC=B0=A8=20=EC=B6=94=EA=B0=80=20=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?=E2=80=94=20=EA=B0=99=EC=9D=80=20=EC=A2=85=EB=A5=98=20=EB=9D=BC?= =?UTF-8?q?=EC=9D=B8=20=EC=9E=88=EC=9C=BC=EB=A9=B4=20=EC=88=98=EB=9F=89=20?= =?UTF-8?q?+1=20(=EC=A4=91=EB=B3=B5=20=EC=83=9D=EC=84=B1=20=EB=B0=A9?= =?UTF-8?q?=EC=A7=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 증상: + 택배 추가 / + 용차 추가 버튼을 누를 때마다 같은 종류 라인이 새로 생성됨. 변경: 같은 kind 의 라인이 이미 있으면 그 라인의 qty 를 +1, 없으면 신규 추가. - /m/admin/orders (관리자 거래명세표): 기존 라인 찾아 lines/save 로 qty+1 업데이트 - /m/orders/new (거래처 발주 작성): extras 배열에서 같은 kind 라인의 qty +1 Co-Authored-By: Claude Opus 4.7 (1M context) --- src/app/(main)/m/admin/orders/page.tsx | 12 ++++++++++++ src/app/(main)/m/orders/new/page.tsx | 19 +++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/app/(main)/m/admin/orders/page.tsx b/src/app/(main)/m/admin/orders/page.tsx index 0f7f9ec..7477d79 100644 --- a/src/app/(main)/m/admin/orders/page.tsx +++ b/src/app/(main)/m/admin/orders/page.tsx @@ -357,6 +357,18 @@ function StatementPreview({ else Swal.fire({ icon: "error", title: "삭제 실패", text: j.message }); }; const addNewExtra = (kind: "DELIVERY" | "CHARTER") => { + // 같은 종류 라인이 이미 있으면 새로 만들지 않고 수량 +1 + const existing = items.find((it) => it.KIND === kind); + if (existing) { + upsertExtra({ + objid: existing.OBJID, + kind, + label: existing.EXTRA_LABEL || existing.ITEM_NAME, + unitPrice: Number(existing.UNIT_PRICE), + qty: Number(existing.QTY) + 1, + }); + return; + } const defaults = kind === "DELIVERY" ? { unitPrice: 4000, qty: 1, label: "택배비" } : { unitPrice: 5000, qty: 1, label: "용차" }; diff --git a/src/app/(main)/m/orders/new/page.tsx b/src/app/(main)/m/orders/new/page.tsx index a598414..6b66aac 100644 --- a/src/app/(main)/m/orders/new/page.tsx +++ b/src/app/(main)/m/orders/new/page.tsx @@ -127,12 +127,19 @@ export default function ItemsBrowse() { const removeLine = (objid: string) => setCart((c) => c.filter((x) => x.item.OBJID !== objid)); const addExtra = (kind: "DELIVERY" | "CHARTER") => { - const defaultPrice = kind === "DELIVERY" ? DEFAULT_DELIVERY_PRICE : DEFAULT_CHARTER_PRICE; - setExtras((p) => [...p, { - id: newKey(), kind, - unitPrice: defaultPrice, qty: 1, - label: kind === "DELIVERY" ? "택배비" : "용차비", - }]); + // 같은 종류 라인이 이미 있으면 새로 만들지 않고 수량 +1 + setExtras((p) => { + const existing = p.find((e) => e.kind === kind); + if (existing) { + return p.map((e) => e.id === existing.id ? { ...e, qty: e.qty + 1 } : e); + } + const defaultPrice = kind === "DELIVERY" ? DEFAULT_DELIVERY_PRICE : DEFAULT_CHARTER_PRICE; + return [...p, { + id: newKey(), kind, + unitPrice: defaultPrice, qty: 1, + label: kind === "DELIVERY" ? "택배비" : "용차비", + }]; + }); }; const updateExtra = (id: string, field: keyof ExtraLine, value: string | number) => { setExtras((p) => p.map((e) => (e.id === id ? { ...e, [field]: value } as ExtraLine : e)));