fix(momo orders): 택배/용차 추가 버튼 — 같은 종류 라인 있으면 수량 +1 (중복 생성 방지)
Deploy momo-erp / deploy (push) Successful in 50s
Deploy momo-erp / deploy (push) Successful in 50s
증상: + 택배 추가 / + 용차 추가 버튼을 누를 때마다 같은 종류 라인이 새로 생성됨. 변경: 같은 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) <noreply@anthropic.com>
This commit is contained in:
@@ -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: "용차" };
|
||||
|
||||
@@ -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)));
|
||||
|
||||
Reference in New Issue
Block a user