From 90af8a848681c6e00785c5aabcaf98014e5a0aa1 Mon Sep 17 00:00:00 2001 From: king Date: Mon, 19 Oct 2026 14:03:54 +0900 Subject: [PATCH] =?UTF-8?q?feat(inout):=20=EC=A0=84=EC=B2=B4=20=EC=9E=85?= =?UTF-8?q?=EA=B3=A0=20=EC=99=84=EB=A3=8C=EB=A9=B4=20=EC=9E=85=EA=B3=A0=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5=20=EB=A7=89=EA=B8=B0=20=C2=B7=20=EC=82=AC?= =?UTF-8?q?=EB=B0=A9=EB=84=B7=20=EC=9E=85=EA=B3=A0=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EC=97=91=EC=85=80=20=EC=B4=88=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 모든 품목 입고 완료·초과면 입고 칸·[입고 저장] 등 흐리게 disabled, 서버도 잠근 뒤 거절 - 사방넷 입고 파일 버튼 #217346 Co-Authored-By: Claude Opus 5.5 --- app/modules/inout/CLAUDE.md | 3 ++- app/modules/inout/db.py | 3 +++ app/modules/inout/templates/inout/index.html | 2 +- .../inout/templates/inout/order_detail.html | 24 +++++++++++-------- .../inout/templates/inout/order_form.html | 2 +- .../inout/templates/inout/pending.html | 2 +- app/static/inout.css | 10 ++++++++ docs/INOUT_MODULE.md | 6 ++++- tests/test_inout_db.py | 4 ++++ 9 files changed, 41 insertions(+), 15 deletions(-) diff --git a/app/modules/inout/CLAUDE.md b/app/modules/inout/CLAUDE.md index 12f5b77..0fe1d16 100644 --- a/app/modules/inout/CLAUDE.md +++ b/app/modules/inout/CLAUDE.md @@ -11,6 +11,7 @@ - 물류 입고를 여러 번 나눠 입력, 품목별 발주·입고·미입고. - 미입고 현황(제품별 합계·발주별·지연). - 초과 입고는 확인 화면 후 허용(트랜잭션 안에서 발주서 잠그고 판단, `confirm_over`). +- **전체 입고 완료(모든 품목 입고 ≥ 발주, 상태 done·over)면 더 입고 못 함**(2026-10-19) — 화면은 입고 칸·[입고 저장]·사진·[남은 수량 채우기]를 흐리게 disabled, 서버 `_add_receipt` 도 잠근 뒤 거절. 입고 기록을 지우면 다시 열림. - 잔량 종결·취소(취소는 입고 없을 때만). - 상태는 저장하지 않고 누적 입고로 계산(`store.order_status`). - 모든 품목 입고완료·초과입고 = "✓ 전체 입고 완료"(초과면 "초과 포함", `order_badge`). @@ -38,7 +39,7 @@ ## 사방넷 입고 파일 (2026-10-19, 마이그레이션 없음) -- 입고 기록 줄 [사방넷 입고 파일] → `GET /inout/orders/{id}/receipts/{rid}/sabangnet.xlsx`(발주·입고 담당). 1행 제목 **A 상품코드 · B 가용수량 · C 불용수량**, +- 입고 기록 줄 [사방넷 입고 파일](엑셀 초록 `#217346`) → `GET /inout/orders/{id}/receipts/{rid}/sabangnet.xlsx`(발주·입고 담당). 1행 제목 **A 상품코드 · B 가용수량 · C 불용수량**, A = 코드표 `single_items.sabangnet_code`(`itemcode.sabangnet_codes`), B = 입고 수량, **C = 수량이 아니라 상품 이름**(사용자 지정). A·C 는 글자 칸(앞자리 0 보존). - 사방넷 코드가 빈 품목이 있거나 코드표를 못 읽으면 파일을 만들지 않고 발주서로 돌아가 품목을 알려 준다(빈 칸 업로드 방지). 파일 이름 `사방넷_입고_{입고일}_{발주번호}.xlsx`. diff --git a/app/modules/inout/db.py b/app/modules/inout/db.py index 96d6d8c..0951be6 100644 --- a/app/modules/inout/db.py +++ b/app/modules/inout/db.py @@ -354,6 +354,9 @@ class InoutDBStore: "SELECT l.id, l.item_code, l.item_name, l.qty, COALESCE(sum(rl.qty), 0)::int AS received " "FROM inout_order_lines l LEFT JOIN inout_receipt_lines rl ON rl.order_line_id = l.id " "WHERE l.order_id=%s GROUP BY l.id", (order_id,)).fetchall() + # 전체 입고 완료(모든 품목 입고 ≥ 발주)면 더 받지 않는다(2026-10-19) — 화면은 버튼을 막고, 서버도 거절(잠근 뒤 판단) + if lines and all(int(x["received"]) >= int(x["qty"]) for x in lines): + raise ValueError("전체 입고가 완료된 발주서입니다 — 더 입고할 수 없습니다(잘못 넣은 입고는 입고 기록에서 지운 뒤 다시 넣으세요).") data = store.validate_receipt(lines, quantities, receipt_date=receipt_date, memo=memo) if data["over"] and not confirm_over: raise OverReceipt(data["over"]) diff --git a/app/modules/inout/templates/inout/index.html b/app/modules/inout/templates/inout/index.html index d7e94b5..2470ac4 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 %}
diff --git a/app/modules/inout/templates/inout/order_detail.html b/app/modules/inout/templates/inout/order_detail.html index 2b6db2e..243f39a 100644 --- a/app/modules/inout/templates/inout/order_detail.html +++ b/app/modules/inout/templates/inout/order_detail.html @@ -20,11 +20,14 @@ {%- endmacro -%} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %} {% set active = order.status in ('open', 'partial') %} {% set receiving = perms.can_receive and can_receive_now %} +{# 전체 입고 완료(모든 품목 입고완료·초과) — 입고 칸·[입고 저장]을 흐리게 막는다(서버도 거절, 2026-10-19). 입고 기록을 지우면 다시 열림 #} +{% set recv_done = order.status in ('done', 'over') %} +{% set dis = ' disabled' if recv_done else '' %} {% set photo_admin = perms.can_receive and not order.cancelled_at %}
{% include "inout/_nav.html" %} @@ -79,11 +82,12 @@
{# Enter 키 = 이 버튼(일반 저장). 없으면 폼의 첫 제출 버튼인 [초과 입고로 저장]이 눌려 확인 없이 초과가 저장된다 #} - {% if receiving %}{% endif %} + {% if receiving %}{% endif %}

품목

- {% if receiving %}물류에 들어온 수량을 [이번 입고]에 넣고 저장 — 여러 번 나눠 넣어도 됩니다 + {% if receiving and recv_done %}✓ 전체 입고 완료 — 더 입고할 수 없습니다(잘못 넣은 입고는 아래 입고 기록에서 지운 뒤 다시 넣으세요) + {% elif receiving %}물류에 들어온 수량을 [이번 입고]에 넣고 저장 — 여러 번 나눠 넣어도 됩니다 {% elif perms.can_receive and order.closed_at %}종결된 발주서 — 입고하려면 발주 담당이 종결을 풀어야 합니다{% endif %}
@@ -128,7 +132,7 @@ {% if receiving %}{% endif %} + aria-label="{{ ln.item_name }} 이번 입고 수량"{{ dis }} />{% endif %} {% endfor %} @@ -147,19 +151,19 @@ {% if receiving %} -
- - +
+ +
입고증 사진 (최대 {{ max_photos }}장)
- - + +
{% endif %} diff --git a/app/modules/inout/templates/inout/order_form.html b/app/modules/inout/templates/inout/order_form.html index ccacfb1..278d6bd 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 %}
diff --git a/app/modules/inout/templates/inout/pending.html b/app/modules/inout/templates/inout/pending.html index 70e5cea..6789dd9 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 %}
diff --git a/app/static/inout.css b/app/static/inout.css index c081803..35521df 100644 --- a/app/static/inout.css +++ b/app/static/inout.css @@ -295,3 +295,13 @@ .io-logi-field > span { font-weight: 600; } .io-logi-field small { font-weight: 400; color: var(--color-midtone-gray, #777); } .io-rmail-cell .io-sabang-btn { margin-top: 4px; display: inline-flex; } + +/* 사방넷 입고 파일 버튼 — 엑셀 초록(2026-10-19) */ +.io .erp-btn.io-sabang-btn { background: #217346; border-color: #217346; color: #fff; } +.io .erp-btn.io-sabang-btn:hover, .io .erp-btn.io-sabang-btn:focus-visible { background: #185c37; border-color: #185c37; color: #fff; } + +/* 전체 입고 완료 — 입고 칸·버튼 흐리게, 누를 수 없게 */ +.io-receipt-bar.is-locked { opacity: .5; } +.io-receipt-bar.is-locked .erp-btn, .io-receipt-bar.is-locked .io-photo-pick, .io-receipt-bar.is-locked input { cursor: not-allowed; pointer-events: none; } +.io-table .io-recv:disabled { opacity: .5; cursor: not-allowed; background: #f3f4f6; } +.io-recv-done-note { color: #1e7a34; font-weight: 600; } diff --git a/docs/INOUT_MODULE.md b/docs/INOUT_MODULE.md index 69058e6..c7944a6 100644 --- a/docs/INOUT_MODULE.md +++ b/docs/INOUT_MODULE.md @@ -31,6 +31,10 @@ - **초과 입고**: 입고 저장 때 발주를 넘는 품목이 있으면 저장하지 않고 확인 화면(409, 넣은 숫자 유지) → [초과 입고로 저장](`confirm_over=1`). 판단은 DB 트랜잭션 안에서 발주서 행을 잠그고(`FOR UPDATE`) 누적 입고를 다시 읽어 한다 — 동시에 입고해도 확인을 건너뛰지 않음. Enter 키는 숨은 기본 버튼(일반 저장)으로 가게 해 확인 없이 초과가 저장되지 않게 했다. +- **전체 입고 완료 뒤 입고 막기**(2026-10-19 요청): 모든 품목이 입고완료·초과(발주서 done·over)면 품목 머리에 "✓ 전체 입고 완료 — 더 입고할 수 없습니다", + 이번 입고 칸·입고일·메모·사진·[남은 수량 모두 채우기]·[입고 저장]·숨은 기본 버튼을 `disabled` + 흐리게(`.io-receipt-bar.is-locked`). + 서버도 `_add_receipt` 에서 발주서를 잠근 뒤 모든 품목 누적 입고 ≥ 발주면 ValueError(초과 확인을 해도) — 두 창에서 동시에 넣어도 막힘. + 잘못 넣은 입고는 입고 기록에서 지우면 다시 입고할 수 있다. 입고 기록의 사진 더하기·입고 요청 메일·사방넷 파일은 그대로. - 발주서 고치기: 입고된 품목은 **뺄 수 없다**(입고 기록이 사라지므로) — 수량은 바꿀 수 있다(입고보다 줄이면 초과로 보임). - 입고 기록 지우기(입고 담당): 잘못 넣은 1건을 지우면 그만큼 다시 미입고. - 발주번호: `PO-YYMMDD-NN`(발주일 기준 그날 순번, advisory lock 으로 동시 생성해도 겹치지 않음). 순번은 숫자로 비교한다 — 100번째부터 세 자리(`-100`). @@ -184,7 +188,7 @@ cupang·malaysia 와 같은 DSN). 화면에서 코드·이름으로 검색(`GET ## 6-5. 사방넷 입고 파일(2026-10-19, 마이그레이션 없음) -- 입고 기록 표 **입고 요청 메일 · 사방넷** 칸의 **[사방넷 입고 파일]**(발주 담당·입고 담당) → 그 입고 1건의 엑셀(`GET …/receipts/{rid}/sabangnet.xlsx`). +- 입고 기록 표 **입고 요청 메일 · 사방넷** 칸의 **[사방넷 입고 파일]**(엑셀 초록 버튼, 발주 담당·입고 담당) → 그 입고 1건의 엑셀(`GET …/receipts/{rid}/sabangnet.xlsx`). - 시트 1행 = 제목 **상품코드 · 가용수량 · 불용수량**(굵게·회색 바탕), 2행부터 입고 품목마다 A = 코드표(itemcode_db `single_items.sabangnet_code`, `itemcode.SingleItemReader.sabangnet_codes`) 사방넷 코드, B = 입고 수량, **C = 상품 이름**(사용자 요청 — 불용수량 칸이지만 수량이 아니라 이름). A·C 는 글자 서식(`@`, 앞자리 0 보존), 열 너비는 내용 길이로. diff --git a/tests/test_inout_db.py b/tests/test_inout_db.py index 5a523bd..cff9408 100644 --- a/tests/test_inout_db.py +++ b/tests/test_inout_db.py @@ -57,6 +57,10 @@ class InoutDbTests(unittest.TestCase): confirm_over=False, by="w@x") got = self.st.get_order(o["id"]) self.assertEqual((got["status"], got["summary"]["remaining"], len(got["receipts"])), ("done", 0, 2)) + # 전체 입고 완료 뒤엔 더 받지 않는다(2026-10-19) — 초과 확인을 해도 + with self.assertRaisesRegex(ValueError, "전체 입고가 완료"): + self.st.add_receipt(o["id"], {ids["MT-A"]: "1"}, receipt_date="2026-10-23", memo="", confirm_over=True, by="w@x") + self.assertEqual(len(self.st.get_order(o["id"])["receipts"]), 2) self.assertEqual([r["total"] for r in got["receipts"]], [60, 90]) # 진행 중 목록에서 빠지고 완료 목록에 self.assertNotIn(o["id"], [x["id"] for x in self.st.list_orders(status="active", factory_id=self.fid)])