Sp_MaterialsPurchaseStoreVirtual.md 1.68 KB

Sp_MaterialsPurchaseStoreVirtual (procedure)

  • Type: PROCEDURE
  • Deterministic: NO
  • SQL data access: CONTAINS SQL

Parameters

# Mode Name Type
1 IN sGuid varchar(4000)
2 IN sBrId varchar(100)
3 IN sSuId varchar(100)

Body

Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURESpMaterialsPurchaseStoreVirtual'._

Narrative

Business context: 采购管理 → 采购订单 / 仓库管理 → 虚拟库存 — refreshes the on-order (虚拟入库) projection that mitmaterialsstorevirtual maintains for a purchase order. The virtual store tracks "已下单未入库" quantities so MRP/stock checks can reserve against the still-open purchase commitment.

What it does: Takes a comma-delimited sGuid of PurPurchaseOrderMaster.sId values, materialises them into temp table p_t_sId, deletes the existing mitmaterialsstorevirtual rows for those bill ids (scoped by sBrId/sSuId), then re-inserts one row per purpurchaseorderslave where bInStoreComplete=0, carrying the outstanding dAuxiliaryQty - dInStoreAuxiliaryQty and dMaterialsQty - dInStoreQty from the slave plus master metadata (sBillNo, sFormId). Effectively a "delete + rebuild" for one purchase order.

Invocation: Chained from Sp_Calc_sPod (采购订单 审核/反审核), Sp_Calc_sPis (采购入库 calc), Sp_Bill_Force_Complete (强制完结), and Sp_Bill_Force_Complete_copy1. xly-src ships script/标版/30100101/Sp_MaterialsPurchaseStoreVirtual.sql as the install script. No direct UI button — always invoked as a side-effect of upstream PO/入库 lifecycle events.