# `Sp_Calc_sPmt` (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(100)` | | 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_sPmt`'`._ ## Narrative **Business context:** KPI流程操作菜单 → 财务收付款 → 付款单 — supplier payment audit on `CahPaymentMaster`. The check posts the payment into the cashbook (`CahWasteBook`), settles the matched payable rows (`CahPaymentables` / `CahFinancialAdjust` / `cahsupplyinit` / `accmaterialsinitslave`), back-stamps the linked purchase-checking and outsourced-checking documents, and writes a KPI row; the uncheck rolls every leg back. **What it does:** Guards on `bInvalid`/`SysLocking` against `CahPaymentMaster`. Aggregates `dTotalMoney`/`dMinusMoney`/`dRoundingMoney` from `CahPaymentSlave`. On `iFlag=1`: when `CkxDefineCheck=1` & `iTmpCheck<>1` iterates each slave through `Sp_System_CheckFlow`; deletes any stale `CahPaymentNewMaster` rows for this bill and reinserts a fresh consolidated row; writes a `CahWasteBook` entry tagged with the `CbxPayablesType` setting; updates `CahPaymentables`/`CahFinancialAdjust`/`cahsupplyinit` so the matched payables show `dPayMoney`/`dCheckingMoney` consumed; propagates `sCheckPerson`/`tCheckDate` into upstream `PurPurchaseCheckingMaster`/`PurPurchaseInStoreMaster`/`PurPurchaseInvoiceSlave`/`OpsOutsideProcessMaster`/`opsoutsidecheckingslave`/`opsoutsideinvoiceslave`; writes `kpidetail` per slave; flips `bCheck=1, sStatus=1` on the master. `iFlag=0` symmetrically reverses. **Invocation:** Bound to `gdsmodule.sProcName` on 付款单 (sId `192116810113315233387186220`, parent 财务收付款) — dispatched by `BusinessBaseServiceImpl.getPrcName(sFormGuid, …)` on the audit/un-audit button. xly-src ships `script/标版/30100101/Sp_Calc_sPmt.sql` (install) and `script/标版/upgrade/20220104审核去除结账校验/Sp_Calc_sPmt.sql` (period-validation removal patch). Body size 75K — the largest in the `Sp_Calc_s*` family.