diff --git a/app/modules/inout/CLAUDE.md b/app/modules/inout/CLAUDE.md index 79a902d..c48f67f 100644 --- a/app/modules/inout/CLAUDE.md +++ b/app/modules/inout/CLAUDE.md @@ -58,7 +58,9 @@ - 단가(원)·무게(개당 g = PP량)·은(Ag) 함유량(%) 수기 입력(은 g = 무게 × % 자동). - 한 번 불러오면 발주서 제품은 이 목록에서. 발주 품목에 그때 값 사본(`unit_price`·`weight_g`·`silver_pct`). - 발주서·메일에 금액(수량 × 단가)·PP·은 함유량과 합계. -- 발주서 화면 품목 표(`.io-items-table`, 2026-10-21): 제목 행 검정·굵게·가운데, 머리글 "은(Ag) 원료", 합계 줄 검정·굵게·제목 크기, "합계" = 1~3열 가운데, 은 원료 합계 kg(소수 셋째). +- 발주서 화면 품목 표(`.io-items-table`, 2026-10-21): 제목 행 검정·굵게·가운데, 합계 줄 검정·굵게·제목 크기, "합계" = 1~3열 가운데. + 열 **PP 사용량**·**은(Ag) 함유량** = 발주 수량 전체 사용량 kg(`store.line_usage` — 메일 표와 같은 값), 아래 작은 글씨 = 개당 g·%. +- **합계 줄(발주서 화면·발주 메일 표 같음)**: 금액 뒤 " 원", 무게 뒤 " kg", 무게는 소수 첫째 자리에서 반올림(정수 kg). 줄 값·메일 요약 표는 예전 자릿수 그대로. - **발주 메일 표**(2026-10-19, `store.order_mail`): 전체 무게(kg) = 개당 g × 수량 · **PP 사용량(kg)** = 전체 무게 − 은 무게(은 함유량 왼쪽 열) · 은(Ag) 함유량 = `30% (76.5kg)`(괄호 = 전체 무게 × %, kg 소수 넷째). 합계 줄·요약(전체 무게·PP 사용량·은 총량)도 kg. 첫 요약 표는 항목·값 두 쌍씩 4열(4×4), 요청 사항은 맨 아래 한 줄 전체. 발주서 화면 표는 예전 그대로(PP g/개). ## 상품 그룹·색상 (006, 2026-10-21) diff --git a/app/modules/inout/router.py b/app/modules/inout/router.py index 1695d49..2965b3f 100644 --- a/app/modules/inout/router.py +++ b/app/modules/inout/router.py @@ -352,7 +352,7 @@ def _detail(request: Request, user: dict[str, Any], st: Any, order: dict[str, An # 입고 담당(발주 담당 아님)은 품목을 이름·발주 수량(+ 이번 입고 칸)만 — 2026-10-16 사용자 요청 "items_limited": perms["can_receive"] and not perms["can_order"], "show_prices": perms["can_order"], "totals": store.order_totals(order["lines"]), - "fmt_num": store.fmt_num, "line_amount": store.line_amount, "silver_g": store.silver_g, + "fmt_num": store.fmt_num, "line_amount": store.line_amount, "silver_g": store.silver_g, "line_usage": store.line_usage, "max_photos": store.MAX_PHOTOS, "receipt_form": receipt_form or {"receipt_date": today_kst().isoformat(), "memo": "", "qty": {}}, "can_receive_now": order["status"] in (store.ST_OPEN, store.ST_PARTIAL, store.ST_DONE, store.ST_OVER), diff --git a/app/modules/inout/store.py b/app/modules/inout/store.py index de12d59..030d389 100644 --- a/app/modules/inout/store.py +++ b/app/modules/inout/store.py @@ -276,11 +276,10 @@ def order_mail(order: dict[str, Any], *, sender_name: str, sender_email: str) -> facts.append(("요청 사항", order["memo"])) def cells(x: dict[str, Any]) -> dict[str, str]: - price, w, pct = to_dec(x.get("unit_price")), to_dec(x.get("weight_g")), to_dec(x.get("silver_pct")) - q = int(x["qty"]) - amt = line_amount(q, price) - total_kg = w * q / Decimal(1000) if w is not None else None # 전체 무게 = 개당 g × 수량 - ag_kg = total_kg * pct / Decimal(100) if total_kg is not None and pct is not None else None + price, pct = to_dec(x.get("unit_price")), to_dec(x.get("silver_pct")) + amt = line_amount(int(x["qty"]), price) + use = line_usage(x) + total_kg, ag_kg = use["total_kg"], use["ag_kg"] return {"price": fmt_num(price) if price is not None else "-", "amount": fmt_num(amt) if amt is not None else "-", "weight": fmt_num(total_kg, 3) if total_kg is not None else "-", "pp_use": fmt_num(total_kg - ag_kg, 3) if ag_kg is not None else "-", @@ -330,10 +329,11 @@ def order_mail(order: dict[str, Any], *, sender_name: str, sender_email: str) -> f'{e(c["price"])}{e(c["amount"])}' f'{e(c["weight"])}{e(c["pp_use"])}{e(c["ag"])}' f'{e(x.get("memo") or "")}') - foot_amount = fmt_num(money["amount"]) if money["amount"] is not None else "" - foot_pp = fmt_num(money["pp_kg"], 3) if money["pp_kg"] is not None else "" - foot_use = fmt_num(money["pp_use_kg"], 3) if money["pp_use_kg"] is not None else "" - foot_ag = f'{fmt_num(ag_kg, 4)} kg' if ag_kg is not None else "" + # 합계 줄(2026-10-21) — 금액 뒤 " 원", 무게 뒤 " kg", 무게는 소수 첫째 자리에서 반올림(정수 kg) + foot_amount = f'{fmt_num(money["amount"])} 원' if money["amount"] is not None else "" + foot_pp = f'{fmt_num(money["pp_kg"], 0)} kg' if money["pp_kg"] is not None else "" + foot_use = f'{fmt_num(money["pp_use_kg"], 0)} kg' if money["pp_use_kg"] is not None else "" + foot_ag = f'{fmt_num(ag_kg, 0)} kg' if ag_kg is not None else "" bg = "background:#f6f7f9;" html = ( '
' @@ -391,6 +391,15 @@ def silver_g(weight_g: Any, silver_pct: Any) -> Decimal | None: return (w * p / Decimal(100)).quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP) +def line_usage(x: dict[str, Any]) -> dict[str, Decimal | None]: + """발주 품목 한 줄의 발주 수량 전체 사용량(kg) — 전체 무게 = 개당 g × 수량, 은 = 전체 무게 × %, PP 사용량 = 전체 − 은 + (은 함유량이 없으면 PP 사용량도 없음 — order_totals 의 pp_use_kg 와 같은 기준). 메일 표·발주서 화면 품목 표가 같이 쓴다.""" + w, pct, q = to_dec(x.get("weight_g")), to_dec(x.get("silver_pct")), int(x["qty"]) + total_kg = w * q / Decimal(1000) if w is not None else None + ag_kg = total_kg * pct / Decimal(100) if total_kg is not None and pct is not None else None + return {"total_kg": total_kg, "ag_kg": ag_kg, "pp_use_kg": total_kg - ag_kg if ag_kg is not None else None} + + def line_amount(qty: int, unit_price: Any) -> Decimal | None: p = to_dec(unit_price) return None if p is None else (p * int(qty)).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP) diff --git a/app/modules/inout/templates/inout/order_detail.html b/app/modules/inout/templates/inout/order_detail.html index 7ee4cc0..8a3c25a 100644 --- a/app/modules/inout/templates/inout/order_detail.html +++ b/app/modules/inout/templates/inout/order_detail.html @@ -108,7 +108,7 @@ {# 입고 담당(발주 담당 아님) = 제품 이름·발주 수량(+ 이번 입고)만, 발주 담당 = 단가·금액·PP·은 함께 #} {% if not items_limited %}{% endif %} - {% if show_prices %}{% endif %} + {% if show_prices %}{% endif %} {% if not items_limited %}{% endif %} {% if receiving %}{% endif %} @@ -119,11 +119,12 @@ {% if show_prices %} - {% set amt = line_amount(ln.qty, ln.unit_price) %}{% set ag = silver_g(ln.weight_g, ln.silver_pct) %} + {% set amt = line_amount(ln.qty, ln.unit_price) %}{% set ag = silver_g(ln.weight_g, ln.silver_pct) %}{% set use = line_usage(ln) %} - - + {# 발주 수량 전체 사용량(2026-10-21) — PP 사용량·은 함유량 kg(메일 표와 같은 값), 아래 작은 글씨 = 개당 값 #} + + {% endif %} {% if not items_limited %} @@ -142,9 +143,10 @@ - - - + + {# 합계 무게 = 소수 첫째 자리에서 반올림(정수 kg) #} + + {% if not items_limited %}{% endif %} {% if receiving %}{% endif %} diff --git a/tests/test_inout_mail_photo.py b/tests/test_inout_mail_photo.py index ce1a851..6f9d347 100644 --- a/tests/test_inout_mail_photo.py +++ b/tests/test_inout_mail_photo.py @@ -172,6 +172,10 @@ class MailPriceTests(unittest.TestCase): ">122.5<", ">121.888<", "0.6125 kg"): self.assertIn(part, h) self.assertNotIn("PP(g/개)", h) + # 합계 줄(2026-10-21) — 금액 " 원", 무게 " kg"(소수 첫째 자리에서 반올림): 122.5 → 123, 121.8875 → 122, 0.6125 → 1 + foot = h.split("", 1)[1] + for part in (">427,500 원<", ">123 kg<", ">122 kg<", ">1 kg<"): + self.assertIn(part, foot) self.assertLess(h.index("PP 사용량(kg)"), h.index("은(Ag) 함유량")) # PP 사용량 열은 은 함유량 왼쪽 # 첫 요약 표 = 4열(항목·값 두 쌍씩), 8칸 → 4줄. 요청 사항은 맨 아래 한 줄 전체(colspan 3) import re diff --git a/tests/test_inout_web.py b/tests/test_inout_web.py index 6fc0d8b..6c498de 100644 --- a/tests/test_inout_web.py +++ b/tests/test_inout_web.py @@ -370,13 +370,17 @@ def body(c): c.post("/inout/settings/products/save", headers=H, json={"rows": [{"code": "MT-A", "unit_price": "2000", "weight_g": "24.5", "silver_pct": "0.5"}]}) who["u"] = buyer detail = c.get("/inout/orders/%d" % oid).text - for part in ("단가(원)", "금액(원)", "150,000", "단가 미입력 1종 제외", "2.48kg", "12.25g", "0.5%", ""): + # 품목 표(2026-10-21) — PP 사용량·은(Ag) 함유량 = 발주 수량 전체(kg), 아래 작은 글씨 = 개당 값. 합계 = " 원"·정수 " kg" + # MT-A 100개 × 24.5g = 2.45kg, 은 0.5% = 0.01225kg, PP 사용량 2.43775kg → 줄 2.438kg, 합계 2 kg(X2 는 은 함유량 없어 PP 사용량 없음) + for part in ("단가(원)", "금액(원)", "150,000 원", "단가 미입력 1종 제외", ">PP 사용량<", ">은(Ag) 함유량<", "2.438kg", "24.5g/개", + "0.012kg", "0.5% · 0.1225g/개", "2 kg<", "0 kg<", ""): assert part in detail, part + assert "PP(g/개)" not in detail assert "200,000" not in detail assert 'data-price="1500"' in c.get("/inout/orders/%d/edit" % oid).text or "1,500" in c.get("/inout/orders/%d/edit" % oid).text pv = c.get("/inout/orders/%d/mail" % oid).json() # 메일 표(2026-10-19) — 전체 무게 = 개당 g × 수량(kg), PP 사용량 = 전체 − 은, 은 괄호 = 전체 무게 × %(kg) - for part in ("150,000", "전체 무게(kg)", "PP 사용량(kg)", "은(Ag) 함유량", "0.5% (0.0123kg)", ">2.48<", ">2.438<", "0.0123 kg"): + for part in ("150,000 원", "전체 무게(kg)", "PP 사용량(kg)", "은(Ag) 함유량", "0.5% (0.0123kg)", ">2 kg<", ">2.438<", "0.0123 kg"): # 합계 2.48 → 2 kg assert part in pv["html"], part # ── 입고 담당: 품목은 제품 이름·발주 수량(+ 이번 입고)만 ──
#제품 코드제품발주단가(원)금액(원)PP(g/개)은(Ag) 원료단가(원)금액(원)PP 사용량은(Ag) 함유량입고미입고상태이번 입고
{{ ln.item_name }}{% if ln.memo %}
{{ ln.memo }}
{% endif %}
{{ n(ln.qty) }}{{ fmt_num(ln.unit_price) if ln.unit_price is not none else '-' }} {{ fmt_num(amt) if amt is not none else '-' }}{{ fmt_num(ln.weight_g) if ln.weight_g is not none else '-' }}{% if ln.silver_pct is not none %}{{ fmt_num(ln.silver_pct, 4) }}%{% if ag is not none %}
{{ fmt_num(ag, 4) }}g/개
{% endif %}{% else %}-{% endif %}
{% if use.pp_use_kg is not none %}{{ fmt_num(use.pp_use_kg, 3) }}kg{% else %}-{% endif %}{% if ln.weight_g is not none %}
{{ fmt_num(ln.weight_g) }}g/개
{% endif %}
{% if use.ag_kg is not none %}{{ fmt_num(use.ag_kg, 3) }}kg{% else %}-{% endif %}{% if ln.silver_pct is not none %}
{{ fmt_num(ln.silver_pct, 4) }}%{% if ag is not none %} · {{ fmt_num(ag, 4) }}g/개{% endif %}
{% endif %}
{{ n(ln.received) }}합계 {{ n(order.summary.ordered) }} {{ fmt_num(totals.amount) if totals.amount is not none else '-' }}{% if totals.missing_price %}
단가 미입력 {{ totals.missing_price }}종 제외
{% endif %}
{% if totals.pp_kg is not none %}{{ fmt_num(totals.pp_kg, 3) }}kg{% else %}-{% endif %}{% if totals.silver_g is not none %}{{ fmt_num(totals.silver_g / 1000, 3) }}kg{% else %}-{% endif %}{{ fmt_num(totals.amount) ~ ' 원' if totals.amount is not none else '-' }}{% if totals.missing_price %}
단가 미입력 {{ totals.missing_price }}종 제외
{% endif %}
{% if totals.pp_use_kg is not none %}{{ fmt_num(totals.pp_use_kg, 0) }} kg{% else %}-{% endif %}{% if totals.silver_g is not none %}{{ fmt_num(totals.silver_g / 1000, 0) }} kg{% else %}-{% endif %}
제품 코드제품 코드