Sp_System_CheckSaveFlowCps (procedure)
费用录入保存调用
- Type: PROCEDURE
- Deterministic: NO
- SQL data access: CONTAINS SQL
Parameters
| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | sFormGuid |
varchar(100) |
| 2 | IN | sGuid |
varchar(100) |
| 3 | IN | sTableName |
varchar(100) |
| 4 | IN | sLoginId |
varchar(100) |
| 5 | OUT | sReturn |
varchar(4000) |
| 6 | IN | sBrId |
varchar(100) |
| 7 | IN | sSuId |
varchar(100) |
| 8 | OUT | sCode |
int |
Body
Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURESpSystem_CheckSaveFlowCps'._
Narrative
Business context: 费用录入保存调用 — post-save cost-allocation engine for the 费用录入(部门) master form accexpenseentrydepartmentmaster (sFormId 101801153119616595200652250). Whenever a 费用录入 row is saved, this routine reapportions the expense across the department-slave / work-center-slave hierarchy and fills the differential / transfer columns so the cost ledger stays balanced. Lives on the 成本核算 path of the 财务结账 module.
What it does: Reads accexpenseentrydepartmentmaster.dExpenseeMoney − SUM(slave.dEnterMoney WHERE bDepartInsert=0) and refuses save with sSystemCostUnderDepartSum if the residual goes negative. Resets dTotalMoney/dApportionMoney/dTransferMoney on accexpenseentrydepartmentslave and accexpenseentryworkcenterslave, then reads iAssignStandardName2/3 to drive the apportionment standard, and over many cursor passes recomputes per-department and per-work-center totals, posts the rounding residual to the last row, and updates sTransferDepartName / sTransferWorkCenterMemo. Touches accexpenseentrydepartmentmaster_dif, accexpenseentrydepartmentslave, accexpenseentryworkcenterslave, sysaccountperiod.
Invocation: Called from Sp_BtnEventProductionmaterialSure_New (per-cost-frame loop that auto-inserts 系统插入 master rows), Sp_financialClosing_BtnEventCalcCost_New, and Sp_financialClosing_BtnEventExpense. No direct sSaveProName binding in gdsmodule for this DB instance — the cost-flow procs CALL it after they assemble each accexpenseentrydepartmentmaster row, then CALL Sp_Calc_sCps to audit. Install scripts at script/标版/30100101/cost/Sp_System_CheckSaveFlowCps.sql and a ftfydr upgrade variant in script/标版/20250616/.