feat(pl): post brand-level inventory on plan archive
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
32533948e3
commit
cc2edfc61f
5 files changed
+293
No files matched your search
@@ -85,10 +85,12 @@ def set_warning_threshold(
|
||||
) -> dict:
|
||||
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
|
||||
|
||||
brand_id = payload.brand_id or ""
|
||||
inventory = (
|
||||
db.query(PlInventory)
|
||||
.filter(
|
||||
PlInventory.product_id == payload.product_id,
|
||||
PlInventory.brand_id == brand_id,
|
||||
PlInventory.tenant_no == tenant_no,
|
||||
PlInventory.del_flag == 0,
|
||||
)
|
||||
@@ -99,12 +101,16 @@ def set_warning_threshold(
|
||||
assert_pl_row_in_scope(db, inventory, PlInventory, user, tenant_no)
|
||||
inventory.low_stock_warning = payload.low_stock_warning
|
||||
inventory.high_stock_warning = payload.high_stock_warning
|
||||
if payload.brand_name is not None:
|
||||
inventory.brand_name = payload.brand_name
|
||||
else:
|
||||
# 创建库存记录
|
||||
inventory = PlInventory(
|
||||
id=generate_uuid(),
|
||||
tenant_no=tenant_no,
|
||||
product_id=payload.product_id,
|
||||
brand_id=brand_id,
|
||||
brand_name=payload.brand_name,
|
||||
product_no="",
|
||||
product_name="",
|
||||
unit="吨",
|
||||
|
||||
@@ -58,6 +58,7 @@ from app.services.pl_inventory_link_read import build_transport_inventory_link_r
|
||||
from app.services.pl_io_order_service import get_active_io_order_for_plan, void_io_orders_for_plan
|
||||
from app.services.pl_site_link_read import build_transport_site_link_read_from_row
|
||||
from app.services.pl_transport_site_service import revoke_site_links_for_transport
|
||||
from app.services.pl_inventory_service import apply_archive_inventory_for_plan
|
||||
from app.services.pl_plan_service import (
|
||||
apply_archive_freight,
|
||||
apply_archive_product_quantities,
|
||||
@@ -1177,6 +1178,13 @@ def archive_plan(
|
||||
apply_archive_product_quantities(
|
||||
db, tenant_no=tenant_no, plan=plan, items=payload.products, user_id=user.id
|
||||
)
|
||||
apply_archive_inventory_for_plan(
|
||||
db,
|
||||
tenant_no=tenant_no,
|
||||
plan=plan,
|
||||
user_id=user.id,
|
||||
dept_id=user.dept_id or "",
|
||||
)
|
||||
if payload.freight is not None:
|
||||
apply_archive_freight(
|
||||
db, tenant_no=tenant_no, plan=plan, freight=payload.freight, user_id=user.id
|
||||
|
||||
Reference in new issue
Block a user