From cfb6878beaae962ea15562303974e4ab6f128b8d Mon Sep 17 00:00:00 2001 From: king Date: Wed, 4 Nov 2026 15:29:20 +0900 Subject: [PATCH] =?UTF-8?q?feat(=EC=9E=85=EC=B6=9C=EA=B3=A0):=20=EB=B4=89?= =?UTF-8?q?=ED=88=AC=C2=B7=EB=B0=B1=20=ED=91=9C=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=8B=A8=EA=B0=80=C2=B7=EB=AC=B4=EA=B2=8C=C2=B7=EC=9D=80=20?= =?UTF-8?q?=EC=97=B4=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 봉투·백에는 단가·무게·은이 없어 표에서 네 열을 뺀다. 전에 넣은 값은 숨은 칸으로 저장 때 그대로 보내 지우지 않는다. 새 발주서·발주서 화면·발주 메일의 단가 미입력 안내에서도 봉투·백을 뺀다. 은 칸이 없는 줄에서 그룹을 바꿔도 색상 표시가 덮이지 않게 고친다. Co-Authored-By: Claude Opus 5.5 --- app/modules/inout/CLAUDE.md | 3 ++- app/modules/inout/store.py | 5 +++-- .../inout/templates/inout/_options_panel.html | 14 ++++++++++---- app/modules/inout/templates/inout/index.html | 4 ++-- .../inout/templates/inout/order_detail.html | 4 ++-- app/modules/inout/templates/inout/order_form.html | 4 ++-- app/modules/inout/templates/inout/pending.html | 4 ++-- app/static/inout.js | 10 +++++----- docs/INOUT_MODULE.md | 2 +- tests/test_inout_store.py | 4 ++++ tests/test_inout_web.py | 7 ++++++- 11 files changed, 39 insertions(+), 22 deletions(-) diff --git a/app/modules/inout/CLAUDE.md b/app/modules/inout/CLAUDE.md index 11bf26f..7a89af8 100644 --- a/app/modules/inout/CLAUDE.md +++ b/app/modules/inout/CLAUDE.md @@ -96,7 +96,8 @@ ## 봉투·백 (008, 2026-11-04) -- 이름에 **"미라클 봉투"·"미라클백"** 이 들어간 상품(`store.is_bag`, 저장 안 함 — 이름으로 판단) = 옵션 → 상품 정보에서 일반 상품과 **표를 나눔**(봉투·백 표가 위). 박스 칸만 다름: **박스당 수량**(`body_per_box` 재사용)·**1파렛트당 박스 수량**(`inout_products.boxes_per_pallet`). 뚜껑 없음(저장하면 `lid_per_box` 는 NULL). +- 이름에 **"미라클 봉투"·"미라클백"** 이 들어간 상품(`store.is_bag`, 저장 안 함 — 이름으로 판단) = 옵션 → 상품 정보에서 일반 상품과 **표를 나눔**(봉투·백 표가 위). 칸: **박스당 수량**(`body_per_box` 재사용)·**1파렛트당 박스 수량**(`inout_products.boxes_per_pallet`). 뚜껑 없음(저장하면 `lid_per_box` 는 NULL). + **단가·무게·은 칸 없음**(2026-11-04 사용자 지정) — 전에 넣은 값은 줄의 숨은 칸으로 저장 때 그대로 보내 지우지 않음. 그룹·색상 칸은 있음. 새 발주서 "단가 없는 N종"·발주서 화면과 발주 메일의 "단가 미입력 N종"(`store.order_totals`) 안내에서 봉투·백은 뺌. - 새 발주서 합계 줄에 봉투·백 박스·파렛트를 **통·뚜껑과 따로** 표시: 파렛트 = ⌈Σ(박스 ÷ 그 상품 1파렛트 박스)⌉, 그림 없음. 입수·1파렛트 값은 `store.box_info`(`_form_page`·`/api/items`). - 008 확인 `db.bags_ready`(boxes_ready 와 같은 방식). 미적용이면 모두 일반 상품으로 동작. diff --git a/app/modules/inout/store.py b/app/modules/inout/store.py index 5fd1842..07eeb99 100644 --- a/app/modules/inout/store.py +++ b/app/modules/inout/store.py @@ -547,7 +547,8 @@ def order_totals(lines: list[dict[str, Any]]) -> dict[str, Any]: q = int(x["qty"]) a = line_amount(q, x.get("unit_price")) if a is None: - missing += 1 + if not is_bag(x.get("item_name")): # 봉투·백은 단가가 원래 없음 — "단가 미입력" 안내에서 뺀다 + missing += 1 else: amount = (amount or Decimal(0)) + a w = to_dec(x.get("weight_g")) @@ -557,7 +558,7 @@ def order_totals(lines: list[dict[str, Any]]) -> dict[str, Any]: if w is not None and p is not None: # 개당 은 g 를 반올림하기 전 값으로 곱한다(합계 오차 방지) ag = (ag or Decimal(0)) + w * p / Decimal(100) * q use = (use or Decimal(0)) + w * q * (Decimal(100) - p) / Decimal(100000) - return {"amount": amount, "missing_price": missing if amount is not None else len(lines), "pp_kg": pp, "silver_g": ag, + return {"amount": amount, "missing_price": missing, "pp_kg": pp, "silver_g": ag, "pp_use_kg": use} diff --git a/app/modules/inout/templates/inout/_options_panel.html b/app/modules/inout/templates/inout/_options_panel.html index bac5eba..3dfbc85 100644 --- a/app/modules/inout/templates/inout/_options_panel.html +++ b/app/modules/inout/templates/inout/_options_panel.html @@ -141,7 +141,7 @@ 값을 넣은 상품은 다시 불러와도 그대로이고, 지운 단품은 다음 불러오기에서 빠집니다. 발주서 제품은 이 목록에서 고르며, 발주할 때의 값이 발주서에 남습니다. {% if groups_ready %}그룹을 고른 상품은 은 함유량·색상을 그룹 값으로 씁니다(상품 그룹 탭에서 한 번만 설정).{% endif %} {% if boxes_ready %}통 수량(박스)·뚜껑 수량(박스) = 통·뚜껑이 한 박스에 몇 개씩 들어가는지(뚜껑이 없으면 빈칸) — 새 발주서에서 박스 수·파렛트 수를 계산합니다.{% endif %} - 이름에 "미라클 봉투"·"미라클백"이 들어간 상품은 봉투·백 표에서 박스당 수량·1파렛트당 박스 수량을 넣습니다. + 이름에 "미라클 봉투"·"미라클백"이 들어간 상품은 봉투·백 표에서 박스당 수량·1파렛트당 박스 수량을 넣습니다(단가·무게·은 없음).

@@ -158,13 +158,17 @@
{% if bags %}
{{ '봉투·백' if bag_table else '일반 상품' }} {{ rows|length }}개
{% endif %} - {% if groups_ready %}{% endif %}{% if boxes_ready %}{% endif %}{% if groups_ready %}{% endif %} - {% if groups_ready %}{% endif %}{% if bag_table %}{% elif boxes_ready %}{% endif %}{% if groups_ready %}{% endif %} + {% if groups_ready %}{% endif %}{% if not bag_table %}{% endif %}{% if boxes_ready %}{% endif %}{% if groups_ready %}{% endif %} + {% if groups_ready %}{% endif %}{% if not bag_table %}{% endif %}{% if bag_table %}{% elif boxes_ready %}{% endif %}{% if groups_ready %}{% endif %} {% for p in rows %} {% set own_pct = p.own_silver_pct if groups_ready else p.silver_pct %} - + {% if groups_ready %} {% endif %} + {% if not bag_table %} + {% endif %} {% if bag_table %} diff --git a/app/modules/inout/templates/inout/index.html b/app/modules/inout/templates/inout/index.html index 7ad51fe..0247a73 100644 --- a/app/modules/inout/templates/inout/index.html +++ b/app/modules/inout/templates/inout/index.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {% from "inout/_macros.html" import order_badge, progress, due, n, ymd %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
{# 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21) #} @@ -71,4 +71,4 @@ {% include "inout/_calendar.html" %}
{% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/inout/templates/inout/order_detail.html b/app/modules/inout/templates/inout/order_detail.html index 18f8c81..7497d03 100644 --- a/app/modules/inout/templates/inout/order_detail.html +++ b/app/modules/inout/templates/inout/order_detail.html @@ -20,7 +20,7 @@ {%- endmacro -%} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %} {% set active = order.status in ('open', 'partial') %} @@ -262,4 +262,4 @@ {% include "inout/_calendar.html" %} {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/inout/templates/inout/order_form.html b/app/modules/inout/templates/inout/order_form.html index c414d22..5b48f76 100644 --- a/app/modules/inout/templates/inout/order_form.html +++ b/app/modules/inout/templates/inout/order_form.html @@ -1,5 +1,5 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
{# 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21) #} @@ -101,4 +101,4 @@ {% include "inout/_calendar.html" %}
{% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/inout/templates/inout/pending.html b/app/modules/inout/templates/inout/pending.html index 77cde23..f5b101c 100644 --- a/app/modules/inout/templates/inout/pending.html +++ b/app/modules/inout/templates/inout/pending.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {% from "inout/_macros.html" import due, n, ymd %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
{# 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21) #} @@ -91,4 +91,4 @@ {% include "inout/_calendar.html" %}
{% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/static/inout.js b/app/static/inout.js index 24dfc9d..3a2052f 100644 --- a/app/static/inout.js +++ b/app/static/inout.js @@ -140,7 +140,7 @@ const cell = tr.querySelector(".io-amount"); // 금액 = 수량 × 단가(상품 정보 단가, 이미 있던 품목은 발주 당시 단가) — 표시만, 저장은 서버가 단가 사본으로 if (cell) cell.textContent = has && price !== null && n ? (Math.round(price * n * 100) / 100).toLocaleString("ko-KR") : "-"; - if (has) { k++; q += n; if (price === null) missing++; else amount += price * n; } + if (has) { k++; q += n; if (price !== null) amount += price * n; else if (tr.dataset.bag !== "1") missing++; } // 봉투·백은 단가가 원래 없음 const bx = boxCell(tr, n, has); if (has && tr.dataset.bag === "1") { const cap = parseInt(tr.dataset.palletBox || "0", 10) || 0; @@ -511,13 +511,13 @@ const opt = sel.options[sel.selectedIndex]; const grouped = !!sel.value; tr.classList.toggle("is-grouped", grouped); - const vals = tr.querySelectorAll(".io-group-val"); - if (vals[0]) vals[0].textContent = (opt && opt.dataset.silver) || "-"; - if (vals[1]) { + const silverVal = tr.querySelector(".io-group-val.io-r"), colorVal = tr.querySelector(".io-color.io-group-val"); // 봉투·백 줄엔 은 칸 없음 + if (silverVal) silverVal.textContent = (opt && opt.dataset.silver) || "-"; + if (colorVal) { const key = (opt && opt.dataset.color) || "none"; const csel = tr.querySelector(".io-color-select"); const copt = csel && Array.from(csel.options).find(function (o) { return o.value === key; }); - const sw = vals[1].querySelector(".io-swatch"), nm = vals[1].querySelector(".io-color-name"); + const sw = colorVal.querySelector(".io-swatch"), nm = colorVal.querySelector(".io-color-name"); if (sw) { sw.style.background = (copt && copt.dataset.hex) || "#fff"; sw.classList.toggle("is-none", !(copt && copt.dataset.hex)); } if (nm) nm.textContent = copt ? copt.textContent : ""; } diff --git a/docs/INOUT_MODULE.md b/docs/INOUT_MODULE.md index 8a3b9a0..620a47e 100644 --- a/docs/INOUT_MODULE.md +++ b/docs/INOUT_MODULE.md @@ -206,7 +206,7 @@ cupang·malaysia 와 같은 DSN). 화면에서 코드·이름으로 검색(`GET ## 6-3-3. 봉투·백 박스·파렛트(2026-11-04, 마이그레이션 008) - 사용자 요청: 상품 정보에서 이름에 **"미라클 봉투"·"미라클백"** 이 들어간 상품은 **박스당 수량**·**1파렛트당 박스 수량**을 넣도록 일반 상품과 분리. -- 구분은 이름으로(`store.is_bag`, 저장 안 함). 옵션 → 상품 정보에 봉투·백 표를 따로 두고(위), 나머지 칸(단가·무게·은·그룹·색상)은 일반 상품과 같다. +- 구분은 이름으로(`store.is_bag`, 저장 안 함). 옵션 → 상품 정보에 봉투·백 표를 따로 두고(위), 단가·무게·은 칸은 없다(같은 날 추가 요청 — 전에 넣은 값은 숨은 칸으로 유지). 그룹·색상 칸은 일반 상품과 같다. - 저장: 박스당 수량 = 기존 `body_per_box`, 1파렛트당 박스 수량 = 새 열 `boxes_per_pallet`. 봉투·백을 저장하면 `lid_per_box` 는 NULL. - 계산(새 발주서 합계 줄, `inout.js`, 요청에 명시되지 않아 구현 때 정함): 봉투·백은 통·뚜껑 파렛트(1파렛트 30박스)와 **따로** — 박스 = ⌈수량 ÷ 박스당 수량⌉, 파렛트 = ⌈Σ(박스 ÷ 그 상품의 1파렛트당 박스 수량)⌉. 값이 빠진 상품은 몇 종 빠졌는지 표시. 발주 메일에는 넣지 않음. diff --git a/tests/test_inout_store.py b/tests/test_inout_store.py index ecbf82b..68b7c53 100644 --- a/tests/test_inout_store.py +++ b/tests/test_inout_store.py @@ -126,6 +126,10 @@ class ProductValueTests(unittest.TestCase): self.assertEqual((t["amount"], t["missing_price"], t["pp_kg"], t["silver_g"]), (D("8550.00"), 1, D("2.45"), D("12.25"))) empty = s.order_totals([{"qty": 5}]) # 004 전 발주서(값 칸 없음) self.assertEqual((empty["amount"], empty["missing_price"], empty["pp_kg"], empty["silver_g"]), (None, 1, None, None)) + # 봉투·백은 단가가 원래 없음 — "단가 미입력" 안내에 안 잡힘 + bag = {"qty": 5, "unit_price": None, "item_name": "미라클백 2.5L"} + self.assertEqual(s.order_totals([bag])["missing_price"], 0) + self.assertEqual(s.order_totals([bag, {"qty": 5, "unit_price": None, "item_name": "통"}])["missing_price"], 1) def test_parse_and_validate(self): from decimal import Decimal as D diff --git a/tests/test_inout_web.py b/tests/test_inout_web.py index 0ca5bbc..1b5aea2 100644 --- a/tests/test_inout_web.py +++ b/tests/test_inout_web.py @@ -439,9 +439,14 @@ def body(c): assert 'data-key="boxes_per_pallet"' in bag_row and 'data-key="lid_per_box"' not in bag_row assert 'data-key="boxes_per_pallet"' not in box_row and 'data-key="lid_per_box"' in box_row assert panel.index('data-code="%s"' % BAG) < panel.index("일반 상품") < panel.index('data-code="%s"' % BOX) + # 봉투·백 표엔 단가·무게·은 칸이 없다(일반 상품 표에만) — 전에 넣은 값은 숨은 칸으로 남아 저장해도 안 지워짐 + assert panel.count("단가(원)") == 1 and panel.count("은(g/개)") == 1 + assert 'class="io-ag"' not in bag_row and 'io-ag' not in bag_row and 'io-in-num" data-key="unit_price"' not in bag_row + assert 'io-in-num" data-key="unit_price"' in box_row r = c.post("/inout/settings/products/save", headers={"X-Inout-Options": "1"}, json={"rows": [ - {"code": BAG, "unit_price": "", "weight_g": "", "silver_pct": "", "body_per_box": "1,000", "boxes_per_pallet": "40"}]}) + {"code": BAG, "unit_price": "1500", "weight_g": "", "silver_pct": "", "body_per_box": "1,000", "boxes_per_pallet": "40"}]}) assert r.status_code == 200 and r.json()["ok"], r.text + assert 'type="hidden" data-key="unit_price" value="1,500"' in c.get("/inout/settings?panel=1").text item = c.get("/inout/api/items?q=" + BAG).json()["items"][0] assert (item["is_bag"], item["body_per_box"], item["lid_per_box"], item["boxes_per_pallet"]) == (True, 1000, None, 40) r = c.post("/inout/settings/products/save", headers={"X-Inout-Options": "1"}, json={"rows": [
코드제품명그룹단가(원)무게·PP(g/개)은 함유량(%)은(g/개)박스당 수량1파렛트당 박스 수량통 수량(박스)뚜껑 수량(박스)색상
코드제품명그룹단가(원)무게·PP(g/개)은 함유량(%)은(g/개)박스당 수량1파렛트당 박스 수량통 수량(박스)뚜껑 수량(박스)색상
{{ p.item_code }}{{ p.item_code }}{% if bag_table %} + {# 봉투·백엔 단가·무게·은 칸이 없다 — 전에 넣은 값이 저장 때 지워지지 않게 숨은 칸으로 그대로 보낸다 #} + + + {% endif %} {{ p.item_name }} {% if groups_ready %}{{ fmt_num(p.silver_pct, 4) if p.silver_pct is not none else '-' }}{% endif %} {{ fmt_num(p.silver_g, 4) if p.silver_g is not none else '-' }}