feat(inout): 오른쪽 발주·입고 달력·상품 그룹·색상·담당자 아이콘
- 모든 화면 2열, 오른쪽 300x320 달력(프로젝트 달력 모양) — 날짜별 발주·입고, 누르면 목록 - 옵션 → 상품 정보: 그룹(은 함유량·색상 한 번만), 상품별 그룹·색상(마이그레이션 006) - 발주 메일 품목 표에서 색상 있는 품목 줄 배경을 그 색으로(발주 당시 색상 사본) - 옵션 → 담당자 = 아이콘 + 이름, 아래 이메일 - 006 확인을 연결 열기 전에 해 동시 발주에서 연결 풀이 바닥나지 않게 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -335,6 +335,85 @@ class InoutDbTests(unittest.TestCase):
|
||||
pass
|
||||
self.assertEqual(self.st.catalog_count(), before)
|
||||
|
||||
def test_product_groups_colors_and_calendar(self):
|
||||
"""006 — 그룹의 은 함유량·색상이 그룹 상품에 적용(그룹 없는 상품은 자기 값), 같은 이름 거절, 발주 품목 색상 사본,
|
||||
메일 품목 줄 배경, 그룹 지우면 자기 값으로, 다시 불러와도 그룹·색상만 넣은 상품은 그대로. 달력 = 발주일·입고일(취소 제외)."""
|
||||
from decimal import Decimal as D
|
||||
|
||||
from app.modules.inout import store
|
||||
|
||||
if not self.st.groups_ready():
|
||||
self.skipTest("inout_db 006 미적용")
|
||||
T = self.tag.upper()
|
||||
A, B, C = f"ZG-{T}-A", f"ZG-{T}-B", f"ZG-{T}-C"
|
||||
before = self.st.catalog_count()
|
||||
gid = None
|
||||
try:
|
||||
self.st.import_products([{"code": A, "name": "가"}, {"code": B, "name": "나"}, {"code": C, "name": "다"}], by="b@x")
|
||||
gid = self.st.save_group(group_id=None, by="b@x", **store.validate_group(
|
||||
{"name": f"은30-{T}", "silver_pct": "30", "color": "orange", "sort_order": "1"}))
|
||||
with self.assertRaisesRegex(ValueError, "같은 이름"):
|
||||
self.st.save_group(group_id=None, by="b@x", **store.validate_group({"name": f"은30-{T}", "color": "blue"}))
|
||||
with self.assertRaisesRegex(ValueError, "색상은"):
|
||||
store.validate_group({"name": "x", "color": "pink"})
|
||||
vals = store.validate_product_values({"weight_g": "50", "silver_pct": "5"})
|
||||
self.st.save_products([{"code": A, **vals, "group_id": gid, "color": "blue"}, # 그룹 → 그룹 값(30%·오렌지)
|
||||
{"code": B, **vals, "group_id": None, "color": "ivory"}], by="b@x") # 자기 값(5%·아이보리)
|
||||
with self.assertRaisesRegex(ValueError, "없는 그룹"):
|
||||
self.st.save_products([{"code": C, **vals, "group_id": 999999999, "color": "none"}], by="b@x")
|
||||
got = self.st.catalog_lookup([A, B, C])
|
||||
self.assertEqual((got[A]["silver_pct"], got[A]["color"], got[A]["own_silver_pct"], got[A]["own_color"], got[A]["group_name"]),
|
||||
(D("30.0000"), "orange", D("5.0000"), "blue", f"은30-{T}"))
|
||||
self.assertEqual((got[B]["silver_pct"], got[B]["color"], got[B]["group_id"]), (D("5.0000"), "ivory", None))
|
||||
self.assertEqual(got[C]["color"], "none")
|
||||
self.assertEqual([x["color"] for x in self.st.catalog_search(f"ZG-{T}")], ["orange", "ivory", "none"])
|
||||
g = next(x for x in self.st.list_groups() if x["id"] == gid)
|
||||
self.assertEqual((g["product_count"], g["color"]), (1, "orange"))
|
||||
# 발주 = 그룹 적용 값·색상 사본, 메일 품목 줄 배경
|
||||
data = store.validate_order(factory_id=self.fid, order_date="2026-10-21", due_date="", memo="",
|
||||
codes=[A, B, C], quantities=["10", "10", "10"])
|
||||
o = self.st.create_order(data, {A: "가", B: "나", C: "다"}, by="b@x", specs=self.st.catalog_lookup([A, B, C]))
|
||||
order = self.st.get_order(o["id"])
|
||||
lines = {x["item_code"]: x for x in order["lines"]}
|
||||
self.assertEqual((lines[A]["silver_pct"], lines[A]["color"], lines[B]["color"], lines[C]["color"]),
|
||||
(D("30.0000"), "orange", "ivory", "none"))
|
||||
html = store.order_mail(order, sender_name="", sender_email="b@x")["html"]
|
||||
self.assertEqual(html.count('<tr style="background:' + store.color_hex("orange") + '">'), 1)
|
||||
self.assertEqual(html.count('<tr style="background:' + store.color_hex("ivory") + '">'), 1)
|
||||
self.assertEqual(html.count("<tr><td"), 1) # 색없음 줄은 배경 없음
|
||||
# 그룹을 바꿔도 지난 발주서는 사본 그대로 / 그룹 지우면 상품은 자기 값으로
|
||||
self.st.save_group(group_id=gid, by="b@x", **store.validate_group({"name": f"은30-{T}", "silver_pct": "31", "color": "gray"}))
|
||||
self.assertEqual(self.st.get_order(o["id"])["lines"][0]["color"], "orange")
|
||||
self.assertEqual(self.st.catalog_lookup([A])[A]["color"], "gray")
|
||||
self.assertEqual(self.st.delete_group(gid), f"은30-{T}")
|
||||
gid = None
|
||||
got = self.st.catalog_lookup([A])[A]
|
||||
self.assertEqual((got["group_id"], got["silver_pct"], got["color"]), (None, D("5.0000"), "blue"))
|
||||
# 다시 불러와도 그룹·색상만 넣은 상품은 그대로(값 있는 상품)
|
||||
self.st.save_products([{"code": C, "unit_price": None, "weight_g": None, "silver_pct": None, "group_id": None,
|
||||
"color": "gray"}], by="b@x")
|
||||
self.assertEqual(self.st.import_products([{"code": C, "name": "다2"}], by="b@x")["kept"], 1)
|
||||
# 달력 — 발주일·입고일, 취소된 발주는 빠짐
|
||||
ids = self.line_ids(o["id"])
|
||||
self.st.add_receipt(o["id"], {ids[A]: "4"}, receipt_date="2026-10-23", memo="", confirm_over=False, by="w@x")
|
||||
cal = self.st.calendar(date(2026, 10, 1), date(2026, 10, 31))
|
||||
mine = [x for x in cal["orders"] if x["id"] == o["id"]]
|
||||
self.assertEqual((len(mine), mine[0]["qty"], mine[0]["kinds"], mine[0]["first_item"]), (1, 30, 3, "가"))
|
||||
rec = [x for x in cal["receipts"] if x["order_id"] == o["id"]]
|
||||
self.assertEqual((len(rec), rec[0]["qty"], rec[0]["receipt_date"]), (1, 4, date(2026, 10, 23)))
|
||||
o2 = self.order([("MT-X", 1)], order_date="2026-10-22")
|
||||
self.st.cancel_order(o2["id"], by="b@x")
|
||||
self.assertFalse([x for x in self.st.calendar(date(2026, 10, 22), date(2026, 10, 22))["orders"] if x["id"] == o2["id"]])
|
||||
finally:
|
||||
if gid:
|
||||
self.st.delete_group(gid)
|
||||
for code in (A, B, C):
|
||||
try:
|
||||
self.st.exclude_product(code, by="cleanup@x")
|
||||
except ValueError:
|
||||
pass
|
||||
self.assertEqual(self.st.catalog_count(), before)
|
||||
|
||||
|
||||
def test_delete_order_cascades(self):
|
||||
"""수퍼관리자 발주 삭제 — 품목·입고 기록·입고증 사진·메일 기록까지 함께 지워진다."""
|
||||
|
||||
Reference in New Issue
Block a user