diff --git a/app/modules/cupang/db.py b/app/modules/cupang/db.py index 824cb25..aaaa605 100644 --- a/app/modules/cupang/db.py +++ b/app/modules/cupang/db.py @@ -679,9 +679,10 @@ class CupangDBStore: center_name: str = "", keyword: str = "", po_type: str = "", + week_label: str = "", limit: int = 5000, ) -> list[dict[str, Any]]: - """출고일 기준 조회. 기간·센터·발주유형·검색어(품목/SKU/발주번호/바코드).""" + """출고일 기준 조회. 기간·센터·발주유형·주차·검색어(품목/SKU/발주번호/바코드).""" where: list[str] = [] params: list[Any] = [] if date_from: @@ -696,6 +697,9 @@ class CupangDBStore: if po_type: where.append("po_type = %s") params.append(po_type) + if week_label: + where.append("week_label = %s") + params.append(week_label) if keyword: where.append( "(item_name ILIKE %s OR sku_id ILIKE %s OR po_no ILIKE %s OR barcode ILIKE %s)" @@ -728,6 +732,15 @@ class CupangDBStore: ).fetchall() return [r["center_name"] for r in rows] + def sales_weeks(self) -> list[str]: + """필터용 — 매출 자료의 주차 목록(최근 주차부터).""" + with self._pool.connection() as conn: + rows = conn.execute( + "SELECT week_label, MIN(ship_date) AS d FROM cupang_sales " + "WHERE week_label <> '' GROUP BY week_label ORDER BY d DESC NULLS LAST" + ).fetchall() + return [r["week_label"] for r in rows] + def create_sale(self, *, data: dict[str, Any]) -> dict[str, Any]: row = self._normalize_sale(data) cols = ", ".join(self.SALES_FIELDS) diff --git a/app/modules/cupang/router.py b/app/modules/cupang/router.py index bbbf712..095608d 100644 --- a/app/modules/cupang/router.py +++ b/app/modules/cupang/router.py @@ -590,6 +590,7 @@ def _sales_filters(request: Request) -> dict[str, str]: "center_name": (q.get("center") or "").strip(), "keyword": (q.get("q") or "").strip(), "po_type": (q.get("type") or "").strip(), + "week_label": (q.get("week") or "").strip(), } @@ -641,6 +642,7 @@ async def sales_page(request: Request) -> HTMLResponse: "totals": totals, "filters": filters, "centers": store.sales_centers(), + "weeks": store.sales_weeks(), "po_types": ["일반", "벤더플렉스"], "weekly": sorted(weekly.values(), key=lambda w: w.get("week_from") or ""), }, diff --git a/app/modules/cupang/templates/cupang/box_calc.html b/app/modules/cupang/templates/cupang/box_calc.html index fa69df7..7e8a555 100644 --- a/app/modules/cupang/templates/cupang/box_calc.html +++ b/app/modules/cupang/templates/cupang/box_calc.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
diff --git a/app/modules/cupang/templates/cupang/box_rules.html b/app/modules/cupang/templates/cupang/box_rules.html index 205f72e..b7a69b5 100644 --- a/app/modules/cupang/templates/cupang/box_rules.html +++ b/app/modules/cupang/templates/cupang/box_rules.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
diff --git a/app/modules/cupang/templates/cupang/index.html b/app/modules/cupang/templates/cupang/index.html index 99ec541..4057669 100644 --- a/app/modules/cupang/templates/cupang/index.html +++ b/app/modules/cupang/templates/cupang/index.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
diff --git a/app/modules/cupang/templates/cupang/products.html b/app/modules/cupang/templates/cupang/products.html index 4be3e42..d1772c2 100644 --- a/app/modules/cupang/templates/cupang/products.html +++ b/app/modules/cupang/templates/cupang/products.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
diff --git a/app/modules/cupang/templates/cupang/sales.html b/app/modules/cupang/templates/cupang/sales.html index e835948..a32ae32 100644 --- a/app/modules/cupang/templates/cupang/sales.html +++ b/app/modules/cupang/templates/cupang/sales.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %} {# 쿠팡 로켓 매출 — 발주 라인별 공급가·원가·물류비·마진 #} @@ -29,6 +29,13 @@ {% endfor %} +