feat(입출고): 대성화학·인천공장 발주 메일 표를 간단하게

공장 이름에 대성화학·인천공장이 들어가면 품목 표를 번호·제품 코드·
제품명·수량·박스당 수량·박스 수·비고로 만들고, 요약 표와 글 본문에서도
금액·무게·PP·은을 뺀다. 박스 값은 메일을 만들 때의 상품 정보로 계산한다.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-04 15:43:19 +09:00
parent dd5010019d
commit 0ba6192e95
6 changed files with 154 additions and 21 deletions
+41
View File
@@ -461,6 +461,47 @@ def body(c):
st.exclude_product(code, by=admin["email"])
print("OK")
run(body)
''', {"INOUT_TEST_DB_URL": DSN})
self.assertEqual(res.returncode, 0, res.stdout + res.stderr)
self.assertIn("OK", res.stdout)
@unittest.skipUnless(DB_ENABLED, "INOUT_TEST_DB_URL(localhost) not set")
def test_simple_factory_mail_shows_boxes(self):
"""대성화학 메일 미리보기 — 상품 정보의 박스 입수로 박스 칸이 차고 단가는 없음. 다른 공장은 예전 표."""
res = _run('''
import re, uuid
from app.modules.inout.db import InoutDBStore
st = InoutDBStore(__import__("os").environ["INOUT_TEST_DB_URL"])
main.app.state.inout_store = st
main.app.state.inout_items = Items()
tag = uuid.uuid4().hex[:6].upper()
admin = U("admin-%s@t.local" % tag.lower(), role="admin")
users.append(admin)
CODE = "ZS-%s-A" % tag
def order_for(c, factory):
c.post("/inout/settings/factories", data={"name": factory, "is_active": "1"}, headers={"X-Inout-Options": "1"})
fid = next(f["id"] for f in st.list_factories() if f["name"] == factory)
r = c.post("/inout/orders/new", data={"factory_id": fid, "order_date": "2026-11-04", "item_code": [CODE],
"item_name": [""], "qty": ["100"], "line_memo": [""]}, follow_redirects=False)
return int(re.search(r"/inout/orders/(\\d+)", r.headers["location"]).group(1))
def body(c):
who["u"] = admin
st.import_products([{"code": CODE, "name": "통 " + tag}], by=admin["email"])
try:
r = c.post("/inout/settings/products/save", headers={"X-Inout-Options": "1"}, json={"rows": [
{"code": CODE, "unit_price": "7777", "weight_g": "", "silver_pct": "", "body_per_box": "30", "lid_per_box": ""}]})
assert r.json()["ok"], r.text
html = c.get("/inout/orders/%d/mail" % order_for(c, "대성화학-" + tag)).json()["html"]
assert "박스당 수량" in html and ">30개</td>" in html and ">4박스</td>" in html, html
assert "단가" not in html and "7,777" not in html
html = c.get("/inout/orders/%d/mail" % order_for(c, "보통공장-" + tag)).json()["html"]
assert "박스당 수량" not in html and "7,777" in html
finally:
st.exclude_product(CODE, by=admin["email"])
print("OK")
run(body)
''', {"INOUT_TEST_DB_URL": DSN})
self.assertEqual(res.returncode, 0, res.stdout + res.stderr)
self.assertIn("OK", res.stdout)