# `Sp_Calc_sPod` (procedure) > 采购订单 - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `iFlag` | `int` | | 2 | IN | `iTmpCheck` | `int` | | 3 | IN | `sFormGuid` | `varchar(100)` | | 4 | IN | `sGuid` | `varchar(100)` | | 5 | IN | `sLoginId` | `varchar(100)` | | 6 | OUT | `sReturn` | `varchar(4000)` | | 7 | IN | `sBrId` | `varchar(100)` | | 8 | IN | `sSuId` | `varchar(100)` | | 9 | OUT | `sCode` | `int` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Calc_sPod`'`._ ## Narrative **Business context:** KPI流程操作菜单 → 物料采购流程 → 采购订单 — purchase-order audit on `PurPurchaseOrderMaster`/`Slave`. Also serves 采购订单(单据) under 功能操作 (mobile). On check the PO is opened to receiving, the latest negotiated price is rolled into supplier records, and quantities are propagated into upstream demand documents (sales-order materials, work-order materials, semi-goods match-bill); on uncheck the same legs are reversed. **What it does:** Aggregates slave rows by `sMaterialsId+sMaterialsStyle` via cursor; recomputes total/tax money. On `iFlag=1` runs `Sp_System_CheckFlow` per slave when `CkxDefineCheck=1` & `iTmpCheck<>1`; calls `Sp_MaterialsPurchaseStoreVirtual` to update the virtual-stock projection; pushes the negotiated `dLastPrice` into `EleMaterials` and `EleMaterialsSupply`; back-stamps `dPurchasedQty`/`dPurchasedAuxiliaryQty` into `MftWorkOrderMaterials`, `mftworkorderslave`, `PurPurchaseApplySlave`, `salsalesordermaterials`, `sgdsemigoodsmatchbillmaterials`; updates `purpurchaseorderdetail` rollup; flips `bCheck=1, sStatus=1`. `iFlag=0` calls `Sp_Bill_Used` first to refuse when downstream rows exist, then reverses. **Invocation:** Bound to `gdsmodule.sProcName` on 采购订单 (sId `192116810113315217757747140`, parent 物料采购流程) and 采购订单(单据) (sId `101251240115015989270450430`, parent 功能操作). Also called server-side from `Sp_Calc_pruOrderBgd` (采购变更) with `iFlag=0` to un-audit the chased PO before the change document is itself audited. Dispatched primarily by `BusinessBaseServiceImpl.getPrcName(sFormGuid, …)` on the audit/un-audit button. Body size 54K. xly-src ships `script/标版/30100101/Sp_Calc_sPod.sql` (install) and `script/标版/upgrade/20220104审核去除结账校验/Sp_Calc_sPod.sql` (period-validation removal patch).