Sp_Calc_sPiv (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 PROCEDURESpCalc_sPiv'._
Narrative
Business context: 采购管理 → 对账与结算 → 采购发票明细 (also 物料采购流程 → 采购发票) — purchase-invoice audit on PurPurchaseInvoiceMaster. The check posts the invoice into accounts-payable and back-stamps the linked checking master with the invoice number; the uncheck rolls back the payable row and KPI entries.
What it does: Guards on bInvalid/SysLocking. Aggregates dMaterialsMoney+dMaterialsTaxMoney from purpurchaseinvoiceslave. On iFlag=1: when SysSystemSettings.CkxDefineCheck=1 and iTmpCheck<>1 iterates each slave through Sp_System_CheckFlow (multi-step approval workflow keyed on PurPurchaseInvoiceMaster/Slave/EleSupply/EleMaterials); deletes any prior CahPaymentables for sBillId=sGuid and inserts a fresh payable row with dBillMoney=dTotalMoney, dCheckingMoney=dTaxMoney; opens a cursor over each slave to write a kpidetail row (with operator from sftlogininfo) when the line carries sSrcId/sSrcNo/tSrcDate/sUnTaskFormId; stamps sInvoiceNo back into purpurchasecheckingmaster via the checking-slave→invoice-slave join; flips bCheck=1, sStatus=1 on the master. iFlag=0 symmetrically deletes CahPaymentables + kpidetail and clears the back-stamped sInvoiceNo to NULL.
Invocation: Bound to gdsmodule.sProcName on 采购发票明细 (sId 19211681019715780440296680, parent 对账与结算) and 采购发票 (sId 19211681019715782883617940, parent 物料采购流程) — dispatched by BusinessBaseServiceImpl.getPrcName(sFormGuid, …) on the audit/un-audit button. xly-src ships script/标版/30100101/Sp_Calc_sPiv.sql (install) and script/标版/upgrade/20220104审核去除结账校验/Sp_Calc_sPiv.sql (patch removing closing-period validation) — verify which is deployed.