feat(입출고): 발주 목록에 입고일 열 추가
입고 예정일과 발주 사이에 입고일을 보여 준다. 여러 날에 나눠 입고하면 칸 안에서 줄바꿈하고, 같은 날 여러 번 입고는 한 번만, 입고 전에는 - 로 표시한다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
- 물류 입고를 여러 번 나눠 입력, 품목별 발주·입고·미입고.
|
- 물류 입고를 여러 번 나눠 입력, 품목별 발주·입고·미입고.
|
||||||
- 미입고 현황(제품별 합계·발주별·지연).
|
- 미입고 현황(제품별 합계·발주별·지연).
|
||||||
- 발주 목록 상태 보기(진행 중·완료·종결·취소·전체)는 **사람마다 기억**(2026-11-04) — `inout_settings` 키 `list_status:{이메일}`(마이그레이션 없음, 005 미적용이면 기억만 안 함). 주소에 `status` 가 있으면 저장, 없으면 저장값, 그것도 없으면 진행 중.
|
- 발주 목록 상태 보기(진행 중·완료·종결·취소·전체)는 **사람마다 기억**(2026-11-04) — `inout_settings` 키 `list_status:{이메일}`(마이그레이션 없음, 005 미적용이면 기억만 안 함). 주소에 `status` 가 있으면 저장, 없으면 저장값, 그것도 없으면 진행 중.
|
||||||
|
- 발주 목록 **입고일** 열(2026-11-05, 입고 예정일과 발주 사이, `db.list_orders` `receipt_dates`) — 여러 날에 나눠 입고하면 칸 안에서 줄바꿈(오래된 날부터), 같은 날 여러 번은 한 번만, 입고 전 `-`.
|
||||||
- [남은 수량 모두 채우기]를 한 번 더 누르면(= [채운 수량 되돌리기]) 채우기 전 값으로(2026-10-19, `inout.js`).
|
- [남은 수량 모두 채우기]를 한 번 더 누르면(= [채운 수량 되돌리기]) 채우기 전 값으로(2026-10-19, `inout.js`).
|
||||||
- 초과 입고는 확인 화면 후 허용(트랜잭션 안에서 발주서 잠그고 판단, `confirm_over`).
|
- 초과 입고는 확인 화면 후 허용(트랜잭션 안에서 발주서 잠그고 판단, `confirm_over`).
|
||||||
- **전체 입고 완료(모든 품목 입고 ≥ 발주, 상태 done·over)면 더 입고 못 함**(2026-10-19) — 화면은 입고 칸·[입고 저장]·사진·[남은 수량 채우기]를 흐리게 disabled, 서버 `_add_receipt` 도 잠근 뒤 거절. 입고 기록을 지우면 다시 열림.
|
- **전체 입고 완료(모든 품목 입고 ≥ 발주, 상태 done·over)면 더 입고 못 함**(2026-10-19) — 화면은 입고 칸·[입고 저장]·사진·[남은 수량 채우기]를 흐리게 disabled, 서버 `_add_receipt` 도 잠근 뒤 거절. 입고 기록을 지우면 다시 열림.
|
||||||
|
|||||||
@@ -339,9 +339,15 @@ class InoutDBStore:
|
|||||||
"SELECT l.order_id, l.item_code, l.item_name, l.qty, COALESCE(sum(rl.qty), 0)::int AS received "
|
"SELECT l.order_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 "
|
"FROM inout_order_lines l LEFT JOIN inout_receipt_lines rl ON rl.order_line_id = l.id "
|
||||||
"WHERE l.order_id = ANY(%s) GROUP BY l.id ORDER BY l.line_no", (ids,)).fetchall() if ids else []
|
"WHERE l.order_id = ANY(%s) GROUP BY l.id ORDER BY l.line_no", (ids,)).fetchall() if ids else []
|
||||||
|
# 입고일 열 — 같은 날 여러 번 입고해도 날짜는 하나
|
||||||
|
receipts = conn.execute("SELECT DISTINCT order_id, receipt_date FROM inout_receipts WHERE order_id = ANY(%s) "
|
||||||
|
"ORDER BY order_id, receipt_date", (ids,)).fetchall() if ids else []
|
||||||
by_order: dict[int, list[dict[str, Any]]] = {}
|
by_order: dict[int, list[dict[str, Any]]] = {}
|
||||||
for ln in lines:
|
for ln in lines:
|
||||||
by_order.setdefault(int(ln["order_id"]), []).append(ln)
|
by_order.setdefault(int(ln["order_id"]), []).append(ln)
|
||||||
|
receipt_dates: dict[int, list[date]] = {}
|
||||||
|
for r in receipts:
|
||||||
|
receipt_dates.setdefault(int(r["order_id"]), []).append(r["receipt_date"])
|
||||||
allowed = store.STATUS_FILTERS.get(status, store.STATUS_FILTERS["active"])[1]
|
allowed = store.STATUS_FILTERS.get(status, store.STATUS_FILTERS["active"])[1]
|
||||||
out = []
|
out = []
|
||||||
for h in heads:
|
for h in heads:
|
||||||
@@ -351,7 +357,7 @@ class InoutDBStore:
|
|||||||
continue
|
continue
|
||||||
names = [x["item_name"] or x["item_code"] for x in ls]
|
names = [x["item_name"] or x["item_code"] for x in ls]
|
||||||
out.append({**h, "status": st, "status_label": store.ORDER_LABELS[st], "summary": store.summarize(ls),
|
out.append({**h, "status": st, "status_label": store.ORDER_LABELS[st], "summary": store.summarize(ls),
|
||||||
"line_count": len(ls), "items_label": (names[0] + (f" 외 {len(names) - 1}종" if len(names) > 1 else "")) if names else ""})
|
"receipt_dates": receipt_dates.get(int(h["id"]), []), "line_count": len(ls), "items_label": (names[0] + (f" 외 {len(names) - 1}종" if len(names) > 1 else "")) if names else ""})
|
||||||
if len(out) >= limit:
|
if len(out) >= limit:
|
||||||
break
|
break
|
||||||
return out
|
return out
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<div class="erp-table-wrap">
|
<div class="erp-table-wrap">
|
||||||
<table class="erp-table io-table">
|
<table class="erp-table io-table">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
<th>발주번호</th><th>공장</th><th>제품</th><th>발주일</th><th>입고 예정일</th>
|
<th>발주번호</th><th>공장</th><th>제품</th><th>발주일</th><th>입고 예정일</th><th>입고일</th>
|
||||||
<th class="io-num">발주</th><th class="io-num">입고</th><th class="io-num">미입고</th><th>진행</th><th>상태</th>
|
<th class="io-num">발주</th><th class="io-num">입고</th><th class="io-num">미입고</th><th>진행</th><th>상태</th>
|
||||||
{% if perms.super %}<th class="io-col-trash"><span class="sr-only">삭제</span></th>{% endif %}
|
{% if perms.super %}<th class="io-col-trash"><span class="sr-only">삭제</span></th>{% endif %}
|
||||||
</tr></thead>
|
</tr></thead>
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
<td class="io-items">{{ o.items_label }}<div class="erp-row-sub">{{ o.line_count }}종</div></td>
|
<td class="io-items">{{ o.items_label }}<div class="erp-row-sub">{{ o.line_count }}종</div></td>
|
||||||
<td>{{ ymd(o.order_date) }}</td>
|
<td>{{ ymd(o.order_date) }}</td>
|
||||||
<td>{{ due(o.due_date, today, active) }}</td>
|
<td>{{ due(o.due_date, today, active) }}</td>
|
||||||
|
<td>{% for d in o.receipt_dates %}<div>{{ ymd(d) }}</div>{% else %}-{% endfor %}</td>
|
||||||
<td class="io-num">{{ n(o.summary.ordered) }}</td>
|
<td class="io-num">{{ n(o.summary.ordered) }}</td>
|
||||||
<td class="io-num">{{ n(o.summary.received) }}</td>
|
<td class="io-num">{{ n(o.summary.received) }}</td>
|
||||||
<td class="io-num{% if o.summary.remaining and active %} io-remaining{% endif %}">{{ n(o.summary.remaining) }}{% if o.summary.over %}<div class="io-over-sub">초과 +{{ n(o.summary.over) }}</div>{% endif %}</td>
|
<td class="io-num{% if o.summary.remaining and active %} io-remaining{% endif %}">{{ n(o.summary.remaining) }}{% if o.summary.over %}<div class="io-over-sub">초과 +{{ n(o.summary.over) }}</div>{% endif %}</td>
|
||||||
@@ -61,7 +62,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
{% else %}
|
{% else %}
|
||||||
<tr><td colspan="{{ 11 if perms.super else 10 }}" class="erp-empty">{% if filters.status == 'active' %}진행 중인 발주가 없습니다.{% else %}조건에 맞는 발주가 없습니다.{% endif %}</td></tr>
|
<tr><td colspan="{{ 12 if perms.super else 11 }}" class="erp-empty">{% if filters.status == 'active' %}진행 중인 발주가 없습니다.{% else %}조건에 맞는 발주가 없습니다.{% endif %}</td></tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -65,6 +65,18 @@ function check(name, cond, extra) {
|
|||||||
check("필터 줄 높이가 맞음", Math.abs((box.y + box.height / 2) - (search.y + search.height / 2)) < 4, { box: box, search: search });
|
check("필터 줄 높이가 맞음", Math.abs((box.y + box.height / 2) - (search.y + search.height / 2)) < 4, { box: box, search: search });
|
||||||
await p.screenshot({ path: path.join(__dirname, ".out", "inout_list.png") });
|
await p.screenshot({ path: path.join(__dirname, ".out", "inout_list.png") });
|
||||||
|
|
||||||
|
// 목록 입고일 열(2026-11-05) — 입고 예정일과 발주 사이, 여러 날은 한 칸에서 줄바꿈, 입고 전 "-"
|
||||||
|
const heads = await p.locator(".io-table thead th").allInnerTexts();
|
||||||
|
check("입고일 열 위치", heads.indexOf("입고일") === heads.indexOf("입고 예정일") + 1 && heads.indexOf("발주") === heads.indexOf("입고일") + 1, heads);
|
||||||
|
const col = heads.indexOf("입고일") + 1;
|
||||||
|
const cell = function (row) { return p.locator(".io-table tbody tr:nth-child(" + row + ") td:nth-child(" + col + ")"); };
|
||||||
|
const lines = await cell(1).locator("div").evaluateAll(function (els) {
|
||||||
|
return els.map(function (el) { return { text: el.textContent, top: el.getBoundingClientRect().top }; });
|
||||||
|
});
|
||||||
|
check("여러 날 = 줄바꿈", lines.length === 2 && lines[0].text === "2026.10.21(수)" && lines[1].text === "2026.10.23(금)" && lines[1].top > lines[0].top, lines);
|
||||||
|
check("하루 입고 = 한 줄", (await cell(2).innerText()).trim() === "2026.10.22(목)");
|
||||||
|
check("입고 전 = -", (await cell(3).innerText()).trim() === "-");
|
||||||
|
|
||||||
await p.goto("http://erp.test/inout_locked.html");
|
await p.goto("http://erp.test/inout_locked.html");
|
||||||
await p.waitForTimeout(200);
|
await p.waitForTimeout(200);
|
||||||
check("잠긴 입고일은 못 누름", await p.locator('input[name="receipt_date"] + button').isDisabled());
|
check("잠긴 입고일은 못 누름", await p.locator('input[name="receipt_date"] + button').isDisabled());
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ OUT_DIR = os.path.join(ROOT, "tests", "js", ".out")
|
|||||||
from app.modules.inout.router import _date_holidays # noqa: E402
|
from app.modules.inout.router import _date_holidays # noqa: E402
|
||||||
|
|
||||||
|
|
||||||
|
def _order(no: int, receipt_dates: list[date]) -> dict:
|
||||||
|
return {"id": no, "order_no": f"PO-26102{no}-01", "factory_name": "대성화학", "items_label": "미라클 봉투", "line_count": 1,
|
||||||
|
"order_date": date(2026, 10, 20), "due_date": None, "receipt_dates": receipt_dates, "status": "partial", "status_label": "일부 입고",
|
||||||
|
"summary": {"ordered": 100, "received": 10, "remaining": 90, "over": 0}}
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
os.makedirs(OUT_DIR, exist_ok=True)
|
os.makedirs(OUT_DIR, exist_ok=True)
|
||||||
env = jinja2.Environment(
|
env = jinja2.Environment(
|
||||||
@@ -28,7 +34,8 @@ def main() -> None:
|
|||||||
base = {"date_holidays": _date_holidays(), "today": date(2026, 10, 5), "user": {"name": "테스트", "email": "t@test.local"}, "nav_items": [], "perms": {"can_order": True, "can_receive": True}}
|
base = {"date_holidays": _date_holidays(), "today": date(2026, 10, 5), "user": {"name": "테스트", "email": "t@test.local"}, "nav_items": [], "perms": {"can_order": True, "can_receive": True}}
|
||||||
pages = {
|
pages = {
|
||||||
"inout_form.html": ("inout/order_form.html", {"vals": {"order_date": "2026-10-05", "due_date": ""}, "factories": []}),
|
"inout_form.html": ("inout/order_form.html", {"vals": {"order_date": "2026-10-05", "due_date": ""}, "factories": []}),
|
||||||
"inout_list.html": ("inout/index.html", {"filters": {"from": "2026-10-01", "to": "", "status": "open", "q": "", "factory": ""}, "factories": [], "orders": [], "status_filters": {}}),
|
"inout_list.html": ("inout/index.html", {"filters": {"from": "2026-10-01", "to": "", "status": "open", "q": "", "factory": ""}, "factories": [], "status_filters": {}, "orders": [
|
||||||
|
_order(1, [date(2026, 10, 21), date(2026, 10, 23)]), _order(2, [date(2026, 10, 22)]), _order(3, [])]}),
|
||||||
}
|
}
|
||||||
for out, (name, ctx) in pages.items():
|
for out, (name, ctx) in pages.items():
|
||||||
with open(os.path.join(OUT_DIR, out), "w", encoding="utf-8") as f:
|
with open(os.path.join(OUT_DIR, out), "w", encoding="utf-8") as f:
|
||||||
|
|||||||
@@ -15,6 +15,26 @@ DSN = os.getenv("INOUT_TEST_DB_URL", "")
|
|||||||
ENABLED = bool(DSN) and urlparse(DSN).hostname in ("localhost", "127.0.0.1")
|
ENABLED = bool(DSN) and urlparse(DSN).hostname in ("localhost", "127.0.0.1")
|
||||||
|
|
||||||
|
|
||||||
|
class ListReceiptDatesNoDbTests(unittest.TestCase):
|
||||||
|
"""DB 없이 — 발주별로 입고일을 묶어 돌려주는지(입고 없는 발주 = 빈 목록)."""
|
||||||
|
|
||||||
|
def test_groups_dates_by_order(self):
|
||||||
|
from contextlib import nullcontext
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
|
from app.modules.inout.db import InoutDBStore
|
||||||
|
|
||||||
|
heads = [{"id": i, "order_no": f"PO-{i}", "closed_at": None, "cancelled_at": None} for i in (1, 2)]
|
||||||
|
lines = [{"order_id": i, "item_code": "A", "item_name": "A", "qty": 10, "received": 1} for i in (1, 2)]
|
||||||
|
receipts = [{"order_id": 1, "receipt_date": date(2026, 10, 21)}, {"order_id": 1, "receipt_date": date(2026, 10, 23)}]
|
||||||
|
conn = MagicMock()
|
||||||
|
conn.execute.side_effect = lambda sql, *a: MagicMock(fetchall=lambda: receipts if "receipt_date" in sql else lines if "inout_order_lines l" in sql else heads)
|
||||||
|
st = InoutDBStore.__new__(InoutDBStore)
|
||||||
|
st._pool = MagicMock(connection=lambda: nullcontext(conn))
|
||||||
|
got = {o["id"]: o["receipt_dates"] for o in st.list_orders()}
|
||||||
|
self.assertEqual(got, {1: [date(2026, 10, 21), date(2026, 10, 23)], 2: []})
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(ENABLED, "INOUT_TEST_DB_URL(localhost) not set")
|
@unittest.skipUnless(ENABLED, "INOUT_TEST_DB_URL(localhost) not set")
|
||||||
class InoutDbTests(unittest.TestCase):
|
class InoutDbTests(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -66,6 +86,16 @@ class InoutDbTests(unittest.TestCase):
|
|||||||
self.assertNotIn(o["id"], [x["id"] for x in self.st.list_orders(status="active", factory_id=self.fid)])
|
self.assertNotIn(o["id"], [x["id"] for x in self.st.list_orders(status="active", factory_id=self.fid)])
|
||||||
self.assertIn(o["id"], [x["id"] for x in self.st.list_orders(status="done", factory_id=self.fid)])
|
self.assertIn(o["id"], [x["id"] for x in self.st.list_orders(status="done", factory_id=self.fid)])
|
||||||
|
|
||||||
|
def test_list_receipt_dates(self):
|
||||||
|
"""목록 입고일 — 입고 전 빈 목록, 여러 날은 오래된 날부터, 같은 날 두 번은 한 번만."""
|
||||||
|
o = self.order([("MT-D", 100)])
|
||||||
|
line = self.line_ids(o["id"])["MT-D"]
|
||||||
|
dates = lambda: next(x for x in self.st.list_orders(status="all", factory_id=self.fid) if x["id"] == o["id"])["receipt_dates"]
|
||||||
|
self.assertEqual(dates(), [])
|
||||||
|
for day in ("2026-10-23", "2026-10-21", "2026-10-23"):
|
||||||
|
self.st.add_receipt(o["id"], {line: "10"}, receipt_date=day, memo="", confirm_over=False, by="w@x")
|
||||||
|
self.assertEqual(dates(), [date(2026, 10, 21), date(2026, 10, 23)])
|
||||||
|
|
||||||
def test_over_receipt_needs_confirm(self):
|
def test_over_receipt_needs_confirm(self):
|
||||||
from app.modules.inout.db import OverReceipt
|
from app.modules.inout.db import OverReceipt
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user