# `Sp_Calc_sCps` (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(5000)` | | 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_sCps`'`._ ## Narrative **Business context:** 费用录入 (department-expense entry) — check / uncheck on `accexpenseentrydepartmentmaster`. Approves a department-expense ledger entry; on approval, refreshes the `sFrameType` lookup from `elecostframe` so the row is correctly bucketed for cost-rollup. Used both as an interactive audit and as a server-side helper invoked by the cost-closing / material-confirm workflows. **What it does:** Validates `sGuid`. Reads master `bInvalid`; refuses if invalid. With `iFlag=1`: refuses if already checked; runs `UPDATE accexpenseentrydepartmentmaster A INNER JOIN elecostframe B ON A.sExpenseeId=B.sId SET A.sFrameType=B.sFrameType`, then sets `bCheck=1`, `sCheckPerson=sLoginId`, `tCheckDate=tCheckTime`. With `iFlag=0`: refuses if already unchecked, then clears the same fields. **Invocation:** Called by other stored procedures during the cost-closing / 生产领料确认 pipeline (verified via routine-definition grep): - `Sp_BtnEventProductionmaterialSure_New` — fires this audit when 生产领料确认 (production-material-issue confirm) detects new expense rows. - `Sp_financialClosing_BtnEventCalcCost_New` — invoked from the cost-checking pass before month-end close. - `Sp_financialClosing_BtnEventExpense` — invoked from the expense-closing pass. All three callers pass `iFlag='1', iTmpCheck='0', sFormGuid='101801153119616595200652250'` and `sMakePerson` in {`'系统插入'`, `'检查插入'`}. No direct `gdsmodule` button binding — this audit is a back-end utility, not a user-clicked one. Customer-override file `script/标版/20250616/Sp_Calc_sCps_ftfydr.sql` exists alongside the standard `optimize/Sp_Calc_sCps.sql` — verify which is deployed.