Merge branch 'feat/inout-bag-pallet'
This commit is contained in:
@@ -94,6 +94,12 @@
|
||||
- 화면 계산만 — 발주 품목 사본·발주서 화면·**발주 메일에는 넣지 않음**(사용자 지정). 값은 지금 상품 정보(`_form_page` 의 `body_per_box`, `/api/items`).
|
||||
- 007 확인 `db.boxes_ready`(groups_ready 와 같은 방식 — 연결 열기 전, 미적용 1분 기억). 그룹·색상 조회(`_PRODUCT_SELECT_006`)는 `p.*` 라 새 열이 따라온다.
|
||||
|
||||
## 봉투·백 (008, 2026-11-04)
|
||||
|
||||
- 이름에 **"미라클 봉투"·"미라클백"** 이 들어간 상품(`store.is_bag`, 저장 안 함 — 이름으로 판단) = 옵션 → 상품 정보에서 일반 상품과 **표를 나눔**(봉투·백 표가 위). 박스 칸만 다름: **박스당 수량**(`body_per_box` 재사용)·**1파렛트당 박스 수량**(`inout_products.boxes_per_pallet`). 뚜껑 없음(저장하면 `lid_per_box` 는 NULL).
|
||||
- 새 발주서 합계 줄에 봉투·백 박스·파렛트를 **통·뚜껑과 따로** 표시: 파렛트 = ⌈Σ(박스 ÷ 그 상품 1파렛트 박스)⌉, 그림 없음. 입수·1파렛트 값은 `store.box_info`(`_form_page`·`/api/items`).
|
||||
- 008 확인 `db.bags_ready`(boxes_ready 와 같은 방식). 미적용이면 모두 일반 상품으로 동작.
|
||||
|
||||
## 오른쪽 달력 (2026-10-21)
|
||||
|
||||
- 입출고 **모든 화면** 2열(`.io-split` = 왼쪽 `section.io` | 오른쪽 `_calendar.html`, 1100px 미만은 한 열 300px). 스크롤해도 위에 붙음.
|
||||
|
||||
@@ -637,7 +637,12 @@ class InoutDBStore:
|
||||
self._need_products()
|
||||
grouped = self.groups_ready() and any("group_id" in r for r in rows)
|
||||
boxed = self.boxes_ready() and any("body_per_box" in r for r in rows)
|
||||
bagged = self.bags_ready() and any("boxes_per_pallet" in r for r in rows)
|
||||
with self._pool.connection() as conn, conn.transaction():
|
||||
if bagged: # 008 — 봉투·백 1파렛트당 박스 수량
|
||||
for r in rows:
|
||||
if "boxes_per_pallet" in r:
|
||||
conn.execute("UPDATE inout_products SET boxes_per_pallet=%s WHERE item_code=%s", (r["boxes_per_pallet"], r["code"]))
|
||||
if boxed: # 007 — 통·뚜껑 박스 입수(그룹과 무관, 상품마다)
|
||||
for r in rows:
|
||||
if "body_per_box" in r:
|
||||
@@ -759,6 +764,22 @@ class InoutDBStore:
|
||||
self._boxes_checked = time.monotonic()
|
||||
return ok
|
||||
|
||||
def bags_ready(self) -> bool:
|
||||
"""008 이 적용됐나(상품 boxes_per_pallet). boxes_ready 와 같은 방식."""
|
||||
if getattr(self, "_bags_ok", False):
|
||||
return True
|
||||
if time.monotonic() - getattr(self, "_bags_checked", -1e9) < 60:
|
||||
return False
|
||||
if not self.products_ready():
|
||||
return False
|
||||
with self._pool.connection() as conn:
|
||||
ok = bool(conn.execute(
|
||||
"SELECT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'inout_products' "
|
||||
"AND column_name = 'boxes_per_pallet') AS ok").fetchone()["ok"])
|
||||
self._bags_ok = ok
|
||||
self._bags_checked = time.monotonic()
|
||||
return ok
|
||||
|
||||
def _need_groups(self) -> None:
|
||||
if not self.groups_ready():
|
||||
raise ValueError("DB 마이그레이션 inout_db 006(상품 그룹·색상)이 아직 적용되지 않았습니다.")
|
||||
|
||||
@@ -267,7 +267,7 @@ def _form_page(request: Request, user: dict[str, Any], st: Any, *, order: dict[s
|
||||
ln["price"] = float(price) if price is not None else None
|
||||
ln["price_label"] = store.fmt_num(price) if price is not None else ""
|
||||
bx = boxes.get(ln["code"]) or {} # 박스 입수(007) — 지금 상품 정보 값(발주 품목에 남기지 않음)
|
||||
ln["body_per_box"], ln["lid_per_box"] = bx.get("body_per_box"), bx.get("lid_per_box")
|
||||
ln.update(store.box_info(bx))
|
||||
reader = _items(request)
|
||||
catalog_n = st.catalog_count()
|
||||
return _render(request, "inout/order_form.html", user, {
|
||||
@@ -939,8 +939,10 @@ def _options_ctx(request: Request, st: Any) -> dict[str, Any]:
|
||||
known.add(e)
|
||||
reader = _items(request)
|
||||
products = st.list_products()
|
||||
bags_ready = st.bags_ready()
|
||||
for pr in products:
|
||||
pr["silver_g"] = store.silver_g(pr.get("weight_g"), pr.get("silver_pct"))
|
||||
pr["is_bag"] = bags_ready and store.is_bag(pr.get("item_name"))
|
||||
return {"products": products, "excluded": st.list_excluded(), "products_ready": st.products_ready(),
|
||||
"groups": st.list_groups(), "groups_ready": st.groups_ready(), "colors": store.COLORS,
|
||||
"boxes_ready": st.boxes_ready(),
|
||||
@@ -1099,7 +1101,9 @@ def settings_products_save(request: Request, payload: dict[str, Any] = Body(...)
|
||||
code = str((r or {}).get("code") or "").strip().upper()
|
||||
try:
|
||||
row = {"code": code, **store.validate_product_values(r)}
|
||||
if "body_per_box" in (r or {}): # 007 — 통·뚜껑 박스 입수(빈칸 = 없음)
|
||||
if "boxes_per_pallet" in (r or {}): # 008 — 봉투·백(박스당 수량·1파렛트당 박스 수량)
|
||||
row.update(store.validate_bag_values(r))
|
||||
elif "body_per_box" in (r or {}): # 007 — 통·뚜껑 박스 입수(빈칸 = 없음)
|
||||
row.update(store.validate_box_values(r))
|
||||
if "group_id" in (r or {}): # 006 — 그룹(빈칸 = 그룹 없음)·상품 자기 색상
|
||||
gid = str(r.get("group_id") or "").strip()
|
||||
@@ -1198,7 +1202,7 @@ def api_items(request: Request, q: str = "") -> JSONResponse:
|
||||
"weight_g": store.fmt_num(r["weight_g"]) if r["weight_g"] is not None else "",
|
||||
"silver_pct": store.fmt_num(r["silver_pct"], 4) if r["silver_pct"] is not None else "",
|
||||
"color": r.get("color") or "none",
|
||||
"body_per_box": r.get("body_per_box"), "lid_per_box": r.get("lid_per_box")} for r in rows]})
|
||||
**store.box_info(r)} for r in rows]})
|
||||
reader = _items(request)
|
||||
if reader is None or not reader.enabled:
|
||||
return JSONResponse({"items": [], "enabled": False,
|
||||
|
||||
@@ -586,7 +586,8 @@ def validate_product_values(values: dict[str, Any]) -> dict[str, Decimal | None]
|
||||
def has_values(p: dict[str, Any]) -> bool:
|
||||
"""단가·무게·은 함유량(·그룹·색상 006·박스 입수 007) 중 하나라도 넣었나 — 넣은 상품은 다시 불러와도 그대로 둔다."""
|
||||
return (any(p.get(k) is not None for k in PRODUCT_LIMITS) or p.get("group_id") is not None
|
||||
or (p.get("color") or "none") != "none" or any(p.get(k) is not None for k in BOX_FIELDS))
|
||||
or (p.get("color") or "none") != "none" or any(p.get(k) is not None for k in BOX_FIELDS)
|
||||
or p.get("boxes_per_pallet") is not None)
|
||||
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
@@ -598,9 +599,9 @@ MAX_PER_BOX = 1_000_000
|
||||
PALLET_BOXES = 30
|
||||
|
||||
|
||||
def parse_per_box(raw: Any, *, key: str) -> int | None:
|
||||
def parse_per_box(raw: Any, *, key: str = "", label: str = "") -> int | None:
|
||||
"""박스 입수 칸 하나 — 빈칸은 None(없음·미입력), 1 이상 정수(쉼표 허용)."""
|
||||
label = BOX_FIELDS[key]
|
||||
label = label or BOX_FIELDS[key]
|
||||
s = str(raw if raw is not None else "").replace(",", "").strip()
|
||||
if not s:
|
||||
return None
|
||||
@@ -608,7 +609,7 @@ def parse_per_box(raw: Any, *, key: str) -> int | None:
|
||||
raise ValueError(f"{label}은(는) 1 이상 정수로 입력하세요.")
|
||||
n = int(s)
|
||||
if n < 1:
|
||||
raise ValueError(f"{label}은(는) 1 이상이어야 합니다(뚜껑이 없으면 빈칸).")
|
||||
raise ValueError(f"{label}은(는) 1 이상이어야 합니다(없으면 빈칸).")
|
||||
if n > MAX_PER_BOX:
|
||||
raise ValueError(f"{label}이(가) 너무 큽니다.")
|
||||
return n
|
||||
@@ -618,6 +619,26 @@ def validate_box_values(values: dict[str, Any]) -> dict[str, int | None]:
|
||||
return {k: parse_per_box(values.get(k), key=k) for k in BOX_FIELDS}
|
||||
|
||||
|
||||
# 봉투·백(2026-11-04, 마이그레이션 008) — 이름으로 판단(저장 안 함). 뚜껑 없음, 박스당 수량 = body_per_box, 1파렛트 박스 수는 상품마다.
|
||||
BAG_NAME_WORDS = ("미라클 봉투", "미라클백")
|
||||
|
||||
|
||||
def is_bag(name: Any) -> bool:
|
||||
return any(word in str(name or "") for word in BAG_NAME_WORDS)
|
||||
|
||||
|
||||
def validate_bag_values(values: dict[str, Any]) -> dict[str, int | None]:
|
||||
return {"body_per_box": parse_per_box(values.get("body_per_box"), label="박스당 수량"), "lid_per_box": None,
|
||||
"boxes_per_pallet": parse_per_box(values.get("boxes_per_pallet"), label="1파렛트당 박스 수량")}
|
||||
|
||||
|
||||
def box_info(row: dict[str, Any]) -> dict[str, Any]:
|
||||
"""발주서 화면 박스 계산 값 — 008 미적용(열 없음)이면 모두 일반 상품으로."""
|
||||
bag = "boxes_per_pallet" in row and is_bag(row.get("item_name"))
|
||||
return {"body_per_box": row.get("body_per_box"), "lid_per_box": None if bag else row.get("lid_per_box"),
|
||||
"is_bag": bag, "boxes_per_pallet": row.get("boxes_per_pallet") if bag else None}
|
||||
|
||||
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# 상품 그룹·색상(2026-10-21, 마이그레이션 006)
|
||||
# 그룹에 은 함유량·색상을 한 번만 — 그룹 상품은 그룹 값, 그룹 없는 상품은 자기 값(effective_product).
|
||||
|
||||
@@ -141,6 +141,7 @@
|
||||
값을 넣은 상품은 다시 불러와도 그대로이고, 지운 단품은 다음 불러오기에서 빠집니다. 발주서 제품은 이 목록에서 고르며, 발주할 때의 값이 발주서에 남습니다.
|
||||
{% if groups_ready %}<b>그룹</b>을 고른 상품은 은 함유량·<b>색상</b>을 그룹 값으로 씁니다(<b>상품 그룹</b> 탭에서 한 번만 설정).{% endif %}
|
||||
{% if boxes_ready %}<b>통 수량(박스)</b>·<b>뚜껑 수량(박스)</b> = 통·뚜껑이 한 박스에 몇 개씩 들어가는지(뚜껑이 없으면 빈칸) — 새 발주서에서 박스 수·파렛트 수를 계산합니다.{% endif %}
|
||||
이름에 "미라클 봉투"·"미라클백"이 들어간 상품은 <b>봉투·백</b> 표에서 <b>박스당 수량</b>·<b>1파렛트당 박스 수량</b>을 넣습니다.
|
||||
</p>
|
||||
<div class="io-prod-bar">
|
||||
<button type="button" class="erp-btn erp-btn-outline erp-btn-sm" id="io-prod-import">단품 불러오기</button>
|
||||
@@ -151,11 +152,16 @@
|
||||
</div>
|
||||
{% if products %}
|
||||
<div class="io-prod-scroll">
|
||||
{# 봉투·백(008) = 일반 상품과 표를 나눔, 짧은 목록이라 위에. 박스 칸 두 개만 다르고 나머지 칸은 같다 #}
|
||||
{% set bags = products|selectattr('is_bag')|list %}
|
||||
{% for bag_table, rows in [(true, bags), (false, products|rejectattr('is_bag')|list)] if rows %}
|
||||
<div class="io-prod-part">
|
||||
{% if bags %}<div class="io-prod-part-title">{{ '봉투·백' if bag_table else '일반 상품' }} <span class="io-sub">{{ rows|length }}개</span></div>{% endif %}
|
||||
<table class="io-dlg-table io-prod-table{% if groups_ready %} has-groups{% endif %}">
|
||||
<colgroup><col class="w-code" /><col />{% if groups_ready %}<col class="w-group" />{% endif %}<col class="w-num" /><col class="w-num" /><col class="w-num" /><col class="w-ag" />{% if boxes_ready %}<col class="w-box" /><col class="w-box" />{% endif %}{% if groups_ready %}<col class="w-color" />{% endif %}<col class="w-del" /></colgroup>
|
||||
<thead><tr><th>코드</th><th>제품명</th>{% if groups_ready %}<th>그룹</th>{% endif %}<th class="io-r">단가(원)</th><th class="io-r">무게·PP(g/개)</th><th class="io-r">은 함유량(%)</th><th class="io-r">은(g/개)</th>{% if boxes_ready %}<th title="통이 한 박스에 몇 개">통 수량(박스)</th><th title="뚜껑이 한 박스에 몇 개 — 뚜껑이 없으면 빈칸">뚜껑 수량(박스)</th>{% endif %}{% if groups_ready %}<th>색상</th>{% endif %}<th></th></tr></thead>
|
||||
<thead><tr><th>코드</th><th>제품명</th>{% if groups_ready %}<th>그룹</th>{% endif %}<th class="io-r">단가(원)</th><th class="io-r">무게·PP(g/개)</th><th class="io-r">은 함유량(%)</th><th class="io-r">은(g/개)</th>{% if bag_table %}<th title="한 박스에 몇 개">박스당 수량</th><th title="한 파렛트에 몇 박스">1파렛트당 박스 수량</th>{% elif boxes_ready %}<th title="통이 한 박스에 몇 개">통 수량(박스)</th><th title="뚜껑이 한 박스에 몇 개 — 뚜껑이 없으면 빈칸">뚜껑 수량(박스)</th>{% endif %}{% if groups_ready %}<th>색상</th>{% endif %}<th></th></tr></thead>
|
||||
<tbody>
|
||||
{% for p in products %}
|
||||
{% for p in rows %}
|
||||
{% set own_pct = p.own_silver_pct if groups_ready else p.silver_pct %}
|
||||
<tr data-code="{{ p.item_code }}" data-search="{{ (p.item_code ~ ' ' ~ p.item_name ~ ' ' ~ (p.group_name or ''))|lower }}"{% if groups_ready and p.group_id %} class="is-grouped"{% endif %}>
|
||||
<td class="io-code">{{ p.item_code }}</td>
|
||||
@@ -171,7 +177,10 @@
|
||||
<td><input class="io-in io-in-num io-own" data-key="silver_pct" value="{{ fmt_num(own_pct, 4) if own_pct is not none else '' }}" inputmode="decimal" aria-label="{{ p.item_code }} 은 함유량" />
|
||||
{% if groups_ready %}<span class="io-group-val io-r" title="그룹 값 — 그룹에서 바꿉니다">{{ fmt_num(p.silver_pct, 4) if p.silver_pct is not none else '-' }}</span>{% endif %}</td>
|
||||
<td class="io-r io-ag" title="무게 × 은 함유량 ÷ 100">{{ fmt_num(p.silver_g, 4) if p.silver_g is not none else '-' }}</td>
|
||||
{% if boxes_ready %}
|
||||
{% if bag_table %}
|
||||
<td><input class="io-in io-in-num" data-key="body_per_box" value="{{ '{:,}'.format(p.body_per_box) if p.body_per_box else '' }}" inputmode="numeric" aria-label="{{ p.item_code }} 박스당 수량" /></td>
|
||||
<td><input class="io-in io-in-num" data-key="boxes_per_pallet" value="{{ '{:,}'.format(p.boxes_per_pallet) if p.boxes_per_pallet else '' }}" inputmode="numeric" aria-label="{{ p.item_code }} 1파렛트당 박스 수량" /></td>
|
||||
{% elif boxes_ready %}
|
||||
<td><input class="io-in io-in-num" data-key="body_per_box" value="{{ '{:,}'.format(p.body_per_box) if p.body_per_box else '' }}" inputmode="numeric" aria-label="{{ p.item_code }} 통 수량(박스)" /></td>
|
||||
<td><input class="io-in io-in-num" data-key="lid_per_box" value="{{ '{:,}'.format(p.lid_per_box) if p.lid_per_box else '' }}" inputmode="numeric" placeholder="없음" aria-label="{{ p.item_code }} 뚜껑 수량(박스)" /></td>
|
||||
{% endif %}
|
||||
@@ -186,6 +195,8 @@
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="io-empty">아직 불러온 단품이 없습니다 — [단품 불러오기]를 누르세요. (그 전에는 발주서에서 코드표 단품을 바로 고릅니다)</p>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "erp_base.html" %}
|
||||
{% from "inout/_macros.html" import order_badge, progress, due, n, ymd %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261102a" />{% endblock %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261104a" />{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="io-split">{# 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21) #}
|
||||
@@ -71,4 +71,4 @@
|
||||
{% include "inout/_calendar.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261102a" defer></script>{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261104a" defer></script>{% endblock %}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</footer>
|
||||
</dialog>
|
||||
{%- endmacro -%}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261102a" />{% endblock %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261104a" />{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% set active = order.status in ('open', 'partial') %}
|
||||
@@ -262,4 +262,4 @@
|
||||
{% include "inout/_calendar.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261102a" defer></script>{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261104a" defer></script>{% endblock %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "erp_base.html" %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261102a" />{% endblock %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261104a" />{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="io-split">{# 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21) #}
|
||||
@@ -34,7 +34,7 @@
|
||||
<tbody>
|
||||
{% for ln in lines %}
|
||||
{% set received = (order.lines | selectattr('item_code', 'equalto', ln.code) | map(attribute='received') | first) if order else 0 %}
|
||||
<tr class="io-line" data-price="{{ ln.price if ln.price is not none else '' }}"{% if boxes_ready %} data-body-box="{{ ln.body_per_box or '' }}" data-lid-box="{{ ln.lid_per_box or '' }}"{% endif %}>
|
||||
<tr class="io-line" data-price="{{ ln.price if ln.price is not none else '' }}"{% if boxes_ready %} data-body-box="{{ ln.body_per_box or '' }}" data-lid-box="{{ ln.lid_per_box or '' }}" data-bag="{{ '1' if ln.is_bag else '' }}" data-pallet-box="{{ ln.boxes_per_pallet or '' }}"{% endif %}>
|
||||
<td class="io-col-no"></td>
|
||||
<td class="io-item-cell">
|
||||
<input type="hidden" name="item_code" value="{{ ln.code }}" />
|
||||
@@ -64,13 +64,19 @@
|
||||
<span class="io-pallet-vis" data-k="vis"></span>
|
||||
<span class="erp-muted" data-k="note">1파렛트 = {{ pallet_boxes }}박스</span>
|
||||
</div>
|
||||
{# 봉투·백(008) — 상품마다 1파렛트 박스 수가 달라 통·뚜껑 파렛트와 따로 셈 #}
|
||||
<div class="io-pallet" id="io-pallet-bag" aria-live="polite" hidden>
|
||||
<span>봉투·백 <b data-k="boxes">0</b>박스</span>
|
||||
<span class="io-pallet-main">→ <b data-k="pallets">0</b>파렛트</span>
|
||||
<span class="erp-muted" data-k="note"></span>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td></tr></tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<template id="io-line-tpl">
|
||||
<tr class="io-line"{% if boxes_ready %} data-body-box="" data-lid-box=""{% endif %}>
|
||||
<tr class="io-line"{% if boxes_ready %} data-body-box="" data-lid-box="" data-bag="" data-pallet-box=""{% endif %}>
|
||||
<td class="io-col-no"></td>
|
||||
<td class="io-item-cell">
|
||||
<input type="hidden" name="item_code" value="" />
|
||||
@@ -95,4 +101,4 @@
|
||||
{% include "inout/_calendar.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261102a" defer></script>{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261104a" defer></script>{% endblock %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "erp_base.html" %}
|
||||
{% from "inout/_macros.html" import due, n, ymd %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261102a" />{% endblock %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261104a" />{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="io-split">{# 2열 — 왼쪽 화면 | 오른쪽 달력(2026-10-21) #}
|
||||
@@ -91,4 +91,4 @@
|
||||
{% include "inout/_calendar.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261102a" defer></script>{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261104a" defer></script>{% endblock %}
|
||||
|
||||
@@ -275,6 +275,7 @@
|
||||
.io-prod-search { width: 220px; }
|
||||
.io-prod-scroll { max-height: min(440px, calc(100vh - 340px)); overflow-y: auto; border: 1px solid var(--color-subtle-ash); border-radius: 8px; }
|
||||
.io-prod-table thead th { position: sticky; top: 0; z-index: 1; background: #fafbfc; }
|
||||
.io-prod-part-title { padding: 10px 12px 6px; font-size: 13.2px; font-weight: 700; }
|
||||
.io-prod-table col.w-code { width: 128px; }
|
||||
.io-prod-table col.w-num { width: 120px; }
|
||||
.io-prod-table col.w-ag { width: 92px; }
|
||||
@@ -462,6 +463,7 @@
|
||||
.io-box-pick { border: 1px solid #cfe0fb; background: #f0f6ff; color: #1d4f91; border-radius: 6px; padding: 0 6px; height: 20px; font-size: 11.5px; cursor: pointer; }
|
||||
.io-box-pick:hover { background: #dce9ff; }
|
||||
.io-pallet { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; font-size: 13px; }
|
||||
.io-pallet[hidden] { display: none; }
|
||||
.io-pallet b { font-variant-numeric: tabular-nums; }
|
||||
.io-pallet-main { font-size: 14px; font-weight: 600; }
|
||||
.io-pallet-main b { font-size: 16px; color: #1d4f91; }
|
||||
|
||||
+32
-7
@@ -56,6 +56,7 @@
|
||||
// 힌트 = 통·뚜껑 입수의 최소공배수(둘 다 박스가 꽉 차는 수량 단위)와 지금 수량에 가까운 그 배수(누르면 수량 칸에 넣음).
|
||||
const palletBoxes = parseInt(form.dataset.palletBoxes || "0", 10);
|
||||
const pallet = document.getElementById("io-pallet");
|
||||
const bagPallet = document.getElementById("io-pallet-bag");
|
||||
const gcd = function (a, b) { while (b) { const t = a % b; a = b; b = t; } return a; };
|
||||
const lcm = function (a, b) { return a / gcd(a, b) * b; };
|
||||
function boxCell(tr, n, has) {
|
||||
@@ -64,13 +65,14 @@
|
||||
const out = { body: 0, lid: 0, unset: has && !body };
|
||||
if (!cell) return out;
|
||||
if (!has) { cell.innerHTML = "-"; return out; }
|
||||
if (!body) { cell.innerHTML = '<span class="erp-muted" title="옵션 → 상품 정보에서 통 수량(박스)을 넣으면 계산합니다">박스 입수 미설정</span>'; return out; }
|
||||
const bag = tr.dataset.bag === "1"; // 봉투·백 — 통·뚜껑 구분 없음
|
||||
if (!body) { cell.innerHTML = '<span class="erp-muted" title="옵션 → 상품 정보에서 ' + (bag ? "박스당 수량" : "통 수량(박스)") + '을 넣으면 계산합니다">박스 입수 미설정</span>'; return out; }
|
||||
out.body = n ? Math.ceil(n / body) : 0;
|
||||
out.lid = n && lid ? Math.ceil(n / lid) : 0;
|
||||
const unit = lid ? lcm(body, lid) : body; // 통·뚜껑이 모두 꽉 차는 수량 단위
|
||||
let html = '<div class="io-box-main">통 <b>' + fmt(out.body) + "</b>박스" +
|
||||
(lid ? ' · 뚜껑 <b>' + fmt(out.lid) + "</b>박스" : ' · <span class="erp-muted">뚜껑 없음</span>') + "</div>";
|
||||
const per = "통 " + fmt(body) + "개/박스" + (lid ? " · 뚜껑 " + fmt(lid) + "개/박스" : "");
|
||||
let html = '<div class="io-box-main">' + (bag ? "" : "통 ") + "<b>" + fmt(out.body) + "</b>박스" +
|
||||
(bag ? "" : lid ? ' · 뚜껑 <b>' + fmt(out.lid) + "</b>박스" : ' · <span class="erp-muted">뚜껑 없음</span>') + "</div>";
|
||||
const per = (bag ? "" : "통 ") + fmt(body) + "개/박스" + (lid ? " · 뚜껑 " + fmt(lid) + "개/박스" : "");
|
||||
let hint;
|
||||
if (n && n % unit === 0) {
|
||||
hint = '<span class="io-box-ok">✓ ' + (lid ? "통·뚜껑 박스가 모두 꽉 찹니다" : "박스가 꽉 찹니다") + "</span>";
|
||||
@@ -129,6 +131,7 @@
|
||||
function renumber() {
|
||||
let q = 0, k = 0, amount = 0, missing = 0;
|
||||
let bodyBoxes = 0, lidBoxes = 0, unset = 0;
|
||||
let bagLines = 0, bagBoxes = 0, bagShare = 0, bagUnset = 0;
|
||||
body.querySelectorAll(".io-line").forEach(function (tr, i) {
|
||||
tr.querySelector(".io-col-no").textContent = String(i + 1);
|
||||
const n = num(tr.querySelector(".io-qty").value);
|
||||
@@ -139,7 +142,15 @@
|
||||
if (cell) cell.textContent = has && price !== null && n ? (Math.round(price * n * 100) / 100).toLocaleString("ko-KR") : "-";
|
||||
if (has) { k++; q += n; if (price === null) missing++; else amount += price * n; }
|
||||
const bx = boxCell(tr, n, has);
|
||||
bodyBoxes += bx.body; lidBoxes += bx.lid; if (bx.unset) unset++;
|
||||
if (has && tr.dataset.bag === "1") {
|
||||
const cap = parseInt(tr.dataset.palletBox || "0", 10) || 0;
|
||||
bagLines++;
|
||||
bagBoxes += bx.body;
|
||||
if (cap) bagShare += bx.body / cap; // 1파렛트 박스 수가 다른 봉투·백은 차지하는 비율로 더함
|
||||
if (bx.unset || !cap) bagUnset++;
|
||||
} else {
|
||||
bodyBoxes += bx.body; lidBoxes += bx.lid; if (bx.unset) unset++;
|
||||
}
|
||||
const unit = unitOf(tr); // ◀ ▶ = 공배수만큼(입수가 없으면 누를 수 없음)
|
||||
tr.querySelectorAll(".io-step").forEach(function (b) {
|
||||
b.disabled = !unit || (b.dataset.step === "-1" && !n);
|
||||
@@ -153,6 +164,13 @@
|
||||
pallet.querySelector('[data-k="vis"]').innerHTML = palletVis(all);
|
||||
set("note", "1파렛트 = " + palletBoxes + "박스" + (unset ? " · 박스 입수 미설정 " + unset + "종 제외" : ""));
|
||||
}
|
||||
if (bagPallet) {
|
||||
bagPallet.hidden = !bagLines;
|
||||
const setBag = function (key, v) { bagPallet.querySelector('[data-k="' + key + '"]').textContent = v; };
|
||||
setBag("boxes", fmt(bagBoxes));
|
||||
setBag("pallets", fmt(Math.ceil(Math.round(bagShare * 1e6) / 1e6))); // 소수 오차로 한 파렛트 더 나오지 않게
|
||||
setBag("note", "통·뚜껑과 따로 셈" + (bagUnset ? " · 박스당 수량·1파렛트당 박스 수량 미설정 " + bagUnset + "종 제외" : ""));
|
||||
}
|
||||
totalQty.textContent = fmt(q);
|
||||
totalLines.textContent = fmt(k);
|
||||
if (totalAmount) totalAmount.textContent = (Math.round(amount * 100) / 100).toLocaleString("ko-KR");
|
||||
@@ -284,7 +302,10 @@
|
||||
const row = input.closest("tr");
|
||||
if (row) { // 단가(상품 정보) — 금액 계산용, 박스 입수(007) — 박스·파렛트 계산용
|
||||
row.dataset.price = it.price === null || it.price === undefined ? "" : String(it.price);
|
||||
if ("bodyBox" in row.dataset) { row.dataset.bodyBox = it.body_per_box || ""; row.dataset.lidBox = it.lid_per_box || ""; }
|
||||
if ("bodyBox" in row.dataset) {
|
||||
row.dataset.bodyBox = it.body_per_box || ""; row.dataset.lidBox = it.lid_per_box || "";
|
||||
row.dataset.bag = it.is_bag ? "1" : ""; row.dataset.palletBox = it.boxes_per_pallet || "";
|
||||
}
|
||||
const pc = row.querySelector(".io-price");
|
||||
if (pc) pc.textContent = it.unit_price || "-";
|
||||
}
|
||||
@@ -531,6 +552,9 @@
|
||||
tr.hidden = !hit;
|
||||
if (hit) shown++;
|
||||
});
|
||||
body.querySelectorAll(".io-prod-part").forEach(function (part) { // 찾은 줄이 없는 표는 제목째 숨김
|
||||
part.hidden = !part.querySelector("tbody tr:not([hidden])");
|
||||
});
|
||||
const cnt = body.querySelector("#io-prod-count");
|
||||
if (cnt) cnt.dataset.base = cnt.dataset.base || cnt.textContent;
|
||||
if (cnt) cnt.textContent = q ? shown + "개 찾음" : cnt.dataset.base;
|
||||
@@ -561,7 +585,8 @@
|
||||
const v = function (k) { return tr.querySelector('[data-key="' + k + '"]').value.trim(); };
|
||||
const row = { code: tr.dataset.code, unit_price: v("unit_price"), weight_g: v("weight_g"), silver_pct: v("silver_pct") };
|
||||
if (tr.querySelector('[data-key="group_id"]')) { row.group_id = v("group_id"); row.color = v("color"); } // 006
|
||||
if (tr.querySelector('[data-key="body_per_box"]')) { row.body_per_box = v("body_per_box"); row.lid_per_box = v("lid_per_box"); } // 007
|
||||
if (tr.querySelector('[data-key="boxes_per_pallet"]')) { row.body_per_box = v("body_per_box"); row.boxes_per_pallet = v("boxes_per_pallet"); } // 008 봉투·백
|
||||
else if (tr.querySelector('[data-key="body_per_box"]')) { row.body_per_box = v("body_per_box"); row.lid_per_box = v("lid_per_box"); } // 007
|
||||
return row;
|
||||
});
|
||||
if (rows.length) await act("/inout/settings/products/save", { rows: rows });
|
||||
|
||||
@@ -203,6 +203,13 @@ cupang·malaysia 와 같은 DSN). 화면에서 코드·이름으로 검색(`GET
|
||||
- 옵션 상품 정보 표 제목 행 = 가운데·굵게·12px × 110%. 그룹 표는 같은 날 **상품 그룹** 탭으로 분리, 옵션 창 폭 1440px 까지.
|
||||
- **달력 다시 그리기 줄이기**(같은 날): 화면을 옮겨도 마지막 달력을 sessionStorage 에서 바로 붙이고, 서버 값이 바뀐 때만 다시 그린다(보던 달 유지, [오늘]로 돌아옴).
|
||||
|
||||
## 6-3-3. 봉투·백 박스·파렛트(2026-11-04, 마이그레이션 008)
|
||||
|
||||
- 사용자 요청: 상품 정보에서 이름에 **"미라클 봉투"·"미라클백"** 이 들어간 상품은 **박스당 수량**·**1파렛트당 박스 수량**을 넣도록 일반 상품과 분리.
|
||||
- 구분은 이름으로(`store.is_bag`, 저장 안 함). 옵션 → 상품 정보에 봉투·백 표를 따로 두고(위), 나머지 칸(단가·무게·은·그룹·색상)은 일반 상품과 같다.
|
||||
- 저장: 박스당 수량 = 기존 `body_per_box`, 1파렛트당 박스 수량 = 새 열 `boxes_per_pallet`. 봉투·백을 저장하면 `lid_per_box` 는 NULL.
|
||||
- 계산(새 발주서 합계 줄, `inout.js`, 요청에 명시되지 않아 구현 때 정함): 봉투·백은 통·뚜껑 파렛트(1파렛트 30박스)와 **따로** — 박스 = ⌈수량 ÷ 박스당 수량⌉, 파렛트 = ⌈Σ(박스 ÷ 그 상품의 1파렛트당 박스 수량)⌉. 값이 빠진 상품은 몇 종 빠졌는지 표시. 발주 메일에는 넣지 않음.
|
||||
|
||||
## 6-4. 입고 요청 메일 — 물류센터 전산 등록 부탁(2026-10-19, 마이그레이션 005)
|
||||
|
||||
- **왜**(사용자 요청): 물류에 들어온 입고를 물류센터 입고 담당자가 전산에 등록하도록, 입고 담당이 입고를 저장하면 메일로 알린다.
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
-- =====================================================================
|
||||
-- inout_db 마이그레이션 008 — 봉투·백 1파렛트당 박스 수량(2026-11-04)
|
||||
-- =====================================================================
|
||||
-- 멱등(idempotent). 열 하나만 추가(기존 값 그대로). 007 다음에 적용. 운영: /opt/www/main 에서 기존 inout_db 에 적용(백업 먼저).
|
||||
-- docker exec -i postgres-db psql -v ON_ERROR_STOP=1 -U postgres -d inout_db < scripts/sql/inout_db_008_bag_pallet.sql
|
||||
--
|
||||
-- 왜(사용자 요청): 이름에 "미라클 봉투"·"미라클백"이 들어간 상품은 옵션 → 상품 정보에서 일반 상품과 따로,
|
||||
-- 박스당 수량(기존 body_per_box 를 그대로 씀)과 1파렛트당 박스 수량(이 열)을 넣는다. 봉투·백 여부는 저장하지 않고 이름으로 판단.
|
||||
-- 되돌리기: ALTER TABLE inout_products DROP COLUMN boxes_per_pallet; (1파렛트당 박스 수량만 사라짐 — 실행 전 백업)
|
||||
-- =====================================================================
|
||||
\set ON_ERROR_STOP on
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE inout_products ADD COLUMN IF NOT EXISTS boxes_per_pallet INT NULL CHECK (boxes_per_pallet IS NULL OR boxes_per_pallet > 0);
|
||||
COMMENT ON COLUMN inout_products.boxes_per_pallet IS '1파렛트당 박스 수량(봉투·백만) — NULL = 미입력';
|
||||
|
||||
COMMIT;
|
||||
SELECT 'inout_db 008 bag pallet ready' AS status;
|
||||
@@ -349,6 +349,41 @@ class InoutDbTests(unittest.TestCase):
|
||||
pass
|
||||
self.assertEqual(self.st.catalog_count(), before)
|
||||
|
||||
def test_bag_pallet(self):
|
||||
"""008 — 봉투·백: 이름으로 구분, 박스당 수량·1파렛트당 박스 저장, 뚜껑 값은 지움, 일반 상품 값은 그대로."""
|
||||
from app.modules.inout import store
|
||||
|
||||
if not self.st.bags_ready():
|
||||
self.skipTest("inout_db 008 미적용")
|
||||
self.assertTrue(store.is_bag("미라클 봉투 대") and store.is_bag("새 미라클백 20L"))
|
||||
self.assertFalse(store.is_bag("미라클 통") or store.is_bag(None))
|
||||
self.assertEqual(store.validate_bag_values({"body_per_box": "1,000", "boxes_per_pallet": "40"}),
|
||||
{"body_per_box": 1000, "lid_per_box": None, "boxes_per_pallet": 40})
|
||||
for bad in ("0", "1.5", "abc"):
|
||||
with self.assertRaises(ValueError):
|
||||
store.validate_bag_values({"boxes_per_pallet": bad})
|
||||
T = self.tag.upper()
|
||||
A, B = f"ZP-{T}-A", f"ZP-{T}-B"
|
||||
before = self.st.catalog_count()
|
||||
try:
|
||||
self.st.import_products([{"code": A, "name": "미라클 봉투 대"}, {"code": B, "name": "일반 통"}], by="b@x")
|
||||
empty = {"unit_price": None, "weight_g": None, "silver_pct": None}
|
||||
self.st.save_products([{"code": A, **empty, "body_per_box": 100, "lid_per_box": 50},
|
||||
{"code": B, **empty, "body_per_box": 120, "lid_per_box": 500}], by="b@x")
|
||||
self.st.save_products([{"code": A, **empty, **store.validate_bag_values({"body_per_box": "1,000", "boxes_per_pallet": "40"})}], by="b@x")
|
||||
got = self.st.catalog_lookup([A, B])
|
||||
self.assertEqual((got[A]["body_per_box"], got[A]["lid_per_box"], got[A]["boxes_per_pallet"]), (1000, None, 40))
|
||||
self.assertEqual(store.box_info(got[A]), {"body_per_box": 1000, "lid_per_box": None, "is_bag": True, "boxes_per_pallet": 40})
|
||||
self.assertEqual(store.box_info(got[B]), {"body_per_box": 120, "lid_per_box": 500, "is_bag": False, "boxes_per_pallet": None})
|
||||
self.assertFalse(store.box_info({"item_name": "미라클백", "body_per_box": 10})["is_bag"]) # 008 미적용(열 없음) = 일반 상품
|
||||
finally:
|
||||
for code in (A, B):
|
||||
try:
|
||||
self.st.exclude_product(code, by="cleanup@x")
|
||||
except ValueError:
|
||||
pass
|
||||
self.assertEqual(self.st.catalog_count(), before)
|
||||
|
||||
def test_box_quantities(self):
|
||||
"""007 — 통·뚜껑 박스 입수(뚜껑 없음 = 빈칸), 검사, 목록·검색·조회에 나오고, 넣은 상품은 다시 불러와도 그대로."""
|
||||
from app.modules.inout import store
|
||||
|
||||
@@ -412,6 +412,54 @@ run(body)
|
||||
self.assertIn("OK", res.stdout)
|
||||
|
||||
|
||||
@unittest.skipUnless(DB_ENABLED, "INOUT_TEST_DB_URL(localhost) not set")
|
||||
def test_bag_products_separated(self):
|
||||
"""008 — 옵션: 봉투·백 표가 따로(칸 다름), 저장·발주서 제품 검색·발주서 화면에 값이 나온다."""
|
||||
res = _run('''
|
||||
import 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)
|
||||
BAG, BOX = "ZG-%s-A" % tag, "ZG-%s-B" % tag
|
||||
|
||||
def body(c):
|
||||
who["u"] = admin
|
||||
st.import_products([{"code": BAG, "name": "미라클백 " + tag}, {"code": BOX, "name": "통 " + tag}], by=admin["email"])
|
||||
try:
|
||||
panel = c.get("/inout/settings?panel=1").text
|
||||
assert panel.count('class="io-prod-part"') == 2 and "1파렛트당 박스 수량</th>" in panel
|
||||
bag_row = panel[panel.index('data-code="%s"' % BAG):]
|
||||
bag_row = bag_row[:bag_row.index("</tr>")]
|
||||
box_row = panel[panel.index('data-code="%s"' % BOX):]
|
||||
box_row = box_row[:box_row.index("</tr>")]
|
||||
assert 'data-key="boxes_per_pallet"' in bag_row and 'data-key="lid_per_box"' not in bag_row
|
||||
assert 'data-key="boxes_per_pallet"' not in box_row and 'data-key="lid_per_box"' in box_row
|
||||
assert panel.index('data-code="%s"' % BAG) < panel.index("일반 상품") < panel.index('data-code="%s"' % BOX)
|
||||
r = c.post("/inout/settings/products/save", headers={"X-Inout-Options": "1"}, json={"rows": [
|
||||
{"code": BAG, "unit_price": "", "weight_g": "", "silver_pct": "", "body_per_box": "1,000", "boxes_per_pallet": "40"}]})
|
||||
assert r.status_code == 200 and r.json()["ok"], r.text
|
||||
item = c.get("/inout/api/items?q=" + BAG).json()["items"][0]
|
||||
assert (item["is_bag"], item["body_per_box"], item["lid_per_box"], item["boxes_per_pallet"]) == (True, 1000, None, 40)
|
||||
r = c.post("/inout/settings/products/save", headers={"X-Inout-Options": "1"}, json={"rows": [
|
||||
{"code": BAG, "unit_price": "", "weight_g": "", "silver_pct": "", "body_per_box": "1", "boxes_per_pallet": "0"}]})
|
||||
assert r.json()["ok"] is False and "1파렛트당 박스 수량" in r.json()["message"], r.text
|
||||
form = c.post("/inout/orders/new", data={"factory_id": "", "order_date": "2026-11-04", "item_code": [BAG],
|
||||
"item_name": [""], "qty": ["500"], "line_memo": [""]}).text
|
||||
assert 'data-body-box="1000" data-lid-box="" data-bag="1" data-pallet-box="40"' in form, form[:300]
|
||||
assert 'id="io-pallet-bag"' in form
|
||||
finally:
|
||||
for code in (BAG, BOX):
|
||||
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_list_status_remembered_per_user(self):
|
||||
"""발주 목록 상태 보기 — 사람마다 따로 기억, 처음은 진행 중, 틀린 값은 저장 안 함."""
|
||||
|
||||
Reference in New Issue
Block a user