feat(입출고): 발주 목록에 입고일 열 추가

입고 예정일과 발주 사이에 입고일을 보여 준다. 여러 날에 나눠 입고하면 칸 안에서
줄바꿈하고, 같은 날 여러 번 입고는 한 번만, 입고 전에는 - 로 표시한다.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-05 14:45:33 +09:00
parent 50f25a7ec7
commit b7e05f58aa
6 changed files with 61 additions and 4 deletions
+12
View File
@@ -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 });
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.waitForTimeout(200);
check("잠긴 입고일은 못 누름", await p.locator('input[name="receipt_date"] + button').isDisabled());
+8 -1
View File
@@ -20,6 +20,12 @@ OUT_DIR = os.path.join(ROOT, "tests", "js", ".out")
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:
os.makedirs(OUT_DIR, exist_ok=True)
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}}
pages = {
"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():
with open(os.path.join(OUT_DIR, out), "w", encoding="utf-8") as f:
+30
View File
@@ -15,6 +15,26 @@ DSN = os.getenv("INOUT_TEST_DB_URL", "")
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")
class InoutDbTests(unittest.TestCase):
@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.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):
from app.modules.inout.db import OverReceipt