{% for b in box_list %}
@@ -94,11 +95,21 @@
| {{ it.product_name }} |
{{ it.product_code }} |
{{ it.quantity }} |
+ {% if box_weight and loop.first %}
+ {# 상자 무게 합계 — 상자번호처럼 상자 단위로 한 칸. 무게 없는 제품이 있으면 표시 #}
+ {% set miss = b.weight_missing or [] %}
+
+ {%- if b.weight_g is not none -%}
+ {{ "{:,}".format(b.weight_g) }}g{% if miss %}일부 미입력{% endif %}
+ {%- else -%}—{%- endif -%}
+ |
+ {% endif %}
{% endfor %}
{% endfor %}
{% if not box_list %}
- | 상자 정보가 없습니다. |
+ | 상자 정보가 없습니다. |
{% endif %}
diff --git a/app/static/cupang.css b/app/static/cupang.css
index 790da41..83800eb 100644
--- a/app/static/cupang.css
+++ b/app/static/cupang.css
@@ -1345,6 +1345,16 @@ a.cpg-boxno-dl:hover { background: #1a5c38; border-color: #1a5c38; font-weight:
.cpg-boxno-c-name { width: auto; }
.cpg-boxno-c-code { width: 100px; }
.cpg-boxno-c-qty { width: 62px; }
+.cpg-boxno-c-weight { width: 92px; }
+/* 상자 무게 합계(g) — 상자 단위 한 칸(rowspan), 오른쪽 정렬 숫자. 무게 없는 제품이 있으면 작은 표시 */
+.cpg-boxno-weight {
+ text-align: right; vertical-align: middle; font-variant-numeric: tabular-nums; font-weight: 600;
+ border-left: 1px solid var(--color-cloud-gray);
+}
+.cpg-boxno-weight .cpg-weight-unit { font-weight: 400; }
+.cpg-boxno-wmiss {
+ display: block; margin-top: 1px; font-size: 10.5px; font-weight: 600; color: #b45309; white-space: nowrap;
+}
.cpg-boxno-cell {
text-align: center; font-weight: 700;
font-family: var(--font-geist-mono);
diff --git a/docs/DATABASES.md b/docs/DATABASES.md
index 9922e2a..c29c512 100644
--- a/docs/DATABASES.md
+++ b/docs/DATABASES.md
@@ -208,7 +208,7 @@ DDL: `scripts/sql/cupang_db_init.sql` (멱등). DB·역할(`cupang_app`)·테이
박스 계산은 서버(`store.compute_boxes`)에서 재계산: `required_boxes = ceil(quantity / units_per_box)`. 클라이언트 계산은 미리보기용.
-제품 카탈로그 `cupang_products`(제품코드 UNIQUE·제품명·쿠팡상품코드·활성) — **포장무게 `weight_g`**(INTEGER g, NULL = 미입력, 0~1,000,000 CHECK)는 마이그레이션 `scripts/sql/cupang_db_007_product_weight.sql`, 초기 값 시드 `scripts/sql/cupang_products_weight_seed.sql`(무게가 비어 있는 행만 채움, 실행 전 값은 `_cpg_weight_seed_backup` 에 남김). 007 미적용이면 화면은 무게 칸을 숨기고 그대로 동작.
+제품 카탈로그 `cupang_products`(제품코드 UNIQUE·제품명·쿠팡상품코드·활성) — **포장무게 `weight_g`**(INTEGER g, NULL = 미입력, 0~1,000,000 CHECK)는 마이그레이션 `scripts/sql/cupang_db_007_product_weight.sql`, 초기 값 시드 `scripts/sql/cupang_products_weight_seed.sql`(무게가 비어 있는 행만 채움, 실행 전 값은 `_cpg_weight_seed_backup` 에 남김). 007 미적용이면 화면은 무게 칸을 숨기고 그대로 동작. 출고 상세의 상자별 무게 합계는 저장하지 않고 화면·엑셀을 만들 때 지금 무게로 계산한다.
임시 저장(`cupang_box_calc_drafts`)은 화면 상태 스냅샷만 담는다. 불러올 때 박스 수는 저장값을 쓰지 않고 서버에서 다시 계산하고, 그 위에 분배 내역을 얹는다(사라진 항목은 제외). 마이그레이션: `scripts/sql/cupang_db_003_box_calc_drafts.sql`.
diff --git a/tests/test_cupang_weight.py b/tests/test_cupang_weight.py
index a1fe79d..f3b613f 100644
--- a/tests/test_cupang_weight.py
+++ b/tests/test_cupang_weight.py
@@ -121,3 +121,49 @@ def test_update_without_column_ignores_weight():
st.update_product(product_id=7, product_name="미라클통", product_code="MS-9809", weight_g=950)
sql, params = _main_sql(pool, "UPDATE cupang_products")
assert "weight_g" not in sql and sql.count("%s") == len(params) == 4
+
+
+# ── 상자 목록 무게 합계(상자별) ──────────────────────────────────────
+class _WStore:
+ def __init__(self, enabled: bool, weights: dict[str, int | None]):
+ self.enabled, self.weights = enabled, weights
+
+ def weight_enabled(self) -> bool:
+ return self.enabled
+
+ def list_products(self, include_inactive: bool = False):
+ return [{"product_code": c, "weight_g": w} for c, w in self.weights.items()]
+
+
+def _boxes():
+ mt = {"product_name": "멀티 5,000ml x4", "product_code": "MT-5000_4", "quantity": 2}
+ mix = [{"product_name": "미라클 통 점보 x2", "product_code": "MT-7000_2", "quantity": 6},
+ {"product_name": "무게 없음", "product_code": "XX-0001", "quantity": 1}]
+ return [{"no": 1, "kind": "product", "items": [mt]},
+ {"no": 2, "kind": "mix", "items": mix},
+ {"no": 3, "kind": "product", "items": [{"product_name": "없음", "product_code": "XX-0001", "quantity": 3}]}]
+
+
+def test_box_weights():
+ from app.modules.cupang.router import _attach_box_weights
+ boxes = _boxes()
+ assert _attach_box_weights(_WStore(True, {"MT-5000_4": 1800, "MT-7000_2": 1060, "XX-0001": None}), boxes) is True
+ assert boxes[0]["weight_g"] == 3600 and boxes[0]["weight_missing"] == [] # 2 × 1,800
+ assert boxes[1]["weight_g"] == 6360 and boxes[1]["weight_missing"] == ["XX-0001"] # 6 × 1,060, 무게 없는 제품은 빼고
+ assert boxes[2]["weight_g"] is None and boxes[2]["weight_missing"] == ["XX-0001"] # 하나도 모르면 None
+ plain = _boxes()
+ assert _attach_box_weights(_WStore(False, {}), plain) is False and "weight_g" not in plain[0]
+
+
+def test_box_list_workbook_weight_column():
+ from app.modules.cupang.export import build_box_list_workbook
+ from app.modules.cupang.router import _attach_box_weights
+ boxes = _boxes()
+ _attach_box_weights(_WStore(True, {"MT-5000_4": 1800, "MT-7000_2": 1060}), boxes)
+ ws = build_box_list_workbook({"ship_date": "2026-10-02", "center_name_snapshot": "대구3"}, boxes, with_weight=True).active
+ assert [ws.cell(row=2, column=c).value for c in range(1, 6)] == ["상자번호", "제품명", "제품코드", "수량", "무게(g)"]
+ assert ws.cell(row=3, column=5).value == 3600 and ws.cell(row=4, column=5).value == 6360
+ assert any(str(r) == "E4:E5" for r in ws.merged_cells.ranges) # 혼합 상자 무게 칸 세로 병합
+ assert ws.cell(row=6, column=5).value is None
+ ws2 = build_box_list_workbook({"ship_date": "2026-10-02"}, _boxes()).active # 예전처럼 4열
+ assert ws2.cell(row=2, column=5).value is None and ws2.cell(row=2, column=4).value == "수량"