feat(입출고): 발주 목록에 입고일 열 추가
입고 예정일과 발주 사이에 입고일을 보여 준다. 여러 날에 나눠 입고하면 칸 안에서 줄바꿈하고, 같은 날 여러 번 입고는 한 번만, 입고 전에는 - 로 표시한다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user