diff --git a/inventory_sync/specs.py b/inventory_sync/specs.py index cc52e92..83eb077 100644 --- a/inventory_sync/specs.py +++ b/inventory_sync/specs.py @@ -44,7 +44,7 @@ FIELD_SPECS = [ FieldSpec("零售价", "零售价", 2, "0.00", 2), FieldSpec("店铺名称", "店铺名称", 1), FieldSpec("店铺可用库存", "店铺挂单量", 2, "0", 0), - FieldSpec("总库存", "总库存", 2, "0", 0), + FieldSpec("全渠道总库存", "总库存", 2, "0", 0), FieldSpec(month_sales_field_name(0), "本月销售数量", 2, "0", 0), FieldSpec(month_sales_field_name(1), "上月销售数量", 2, "0", 0), FieldSpec(month_sales_field_name(2), "上上月销售数量", 2, "0", 0), diff --git a/inventory_sync/sql.py b/inventory_sync/sql.py index fd8415e..6bec581 100644 --- a/inventory_sync/sql.py +++ b/inventory_sync/sql.py @@ -83,6 +83,7 @@ shop_stock_latest AS ( ) t WHERE t.rn = 1 AND t."状态" <> '已失效' + AND t."可发库存" <> 0 GROUP BY t."统一规格编码", t."店铺主键" @@ -158,7 +159,7 @@ LEFT JOIN analytics_layer.dim_shop ds ON sl."店铺主键" = ds."店铺主键" LEFT JOIN sales_summary ss ON sl."统一规格编码" = ss."统一规格编码" - AND sl."店铺主键" = ss."店铺主键" + AND sl."店铺主键" = ss."店铺主键" LEFT JOIN product_dim pd ON sl."统一规格编码" = pd."统一规格编码" WHERE pd."品牌名称" = {brand_filter} diff --git a/scripts/generate_batch_inventory_report.py b/scripts/generate_batch_inventory_report.py index 79f7b69..0c2e19a 100644 --- a/scripts/generate_batch_inventory_report.py +++ b/scripts/generate_batch_inventory_report.py @@ -1,5 +1,18 @@ #!/usr/bin/env python3 +from pathlib import Path +import sys + + +def _bootstrap_project_root() -> None: + project_root = Path(__file__).resolve().parents[1] + project_root_text = str(project_root) + if project_root_text not in sys.path: + sys.path.insert(0, project_root_text) + + +_bootstrap_project_root() + from inventory_analytics.batch_inventory_report.cli import main diff --git a/scripts/sync_channel_inventory.py b/scripts/sync_channel_inventory.py index 03b797c..0049088 100644 --- a/scripts/sync_channel_inventory.py +++ b/scripts/sync_channel_inventory.py @@ -1,11 +1,24 @@ #!/usr/bin/env python3 +from pathlib import Path import sys + +def _bootstrap_project_root() -> None: + project_root = Path(__file__).resolve().parents[1] + project_root_text = str(project_root) + if project_root_text not in sys.path: + sys.path.insert(0, project_root_text) + + +_bootstrap_project_root() + from inventory_analytics.channel_inventory_sync.entrypoint import main def _ensure_default_action() -> None: + if any(arg in {"-h", "--help"} for arg in sys.argv[1:]): + return if any(arg == "--action" or arg.startswith("--action=") for arg in sys.argv[1:]): return sys.argv.extend(["--action", "all"]) diff --git a/scripts/upload_batch_inventory.py b/scripts/upload_batch_inventory.py index 5e0ab63..bf91b0e 100644 --- a/scripts/upload_batch_inventory.py +++ b/scripts/upload_batch_inventory.py @@ -1,5 +1,18 @@ #!/usr/bin/env python3 +from pathlib import Path +import sys + + +def _bootstrap_project_root() -> None: + project_root = Path(__file__).resolve().parents[1] + project_root_text = str(project_root) + if project_root_text not in sys.path: + sys.path.insert(0, project_root_text) + + +_bootstrap_project_root() + from inventory_analytics.batch_upload.web import main