# `Sp_Check_sRcts` (procedure) > 收款单保存之前数据校验(汇总) - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sTableName` | `varchar(100)` | | 2 | IN | `sGuid` | `varchar(100)` | | 3 | IN | `sFormGuid` | `varchar(100)` | | 4 | IN | `sLoginId` | `varchar(100)` | | 5 | IN | `sBrId` | `varchar(100)` | | 6 | IN | `sSuId` | `varchar(100)` | | 7 | IN | `iFlag` | `int` | | 8 | OUT | `sCode` | `int` | | 9 | OUT | `sReturn` | `varchar(4000)` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Check_sRcts`'`._ ## Narrative **Business context:** Inferred from the name and routine comment: 财务管理 → 财务收付款 → 收款单(汇总) — would-be post-save validator on `cahreceiptmaster` with `cahreceiptslave`/`cahreceiptsumslave` allocation. Distributes the master's total receipt money and rounding money across the matched slave invoice lines (ordered by remaining `dBalanceMoney`) so each line consumes only up to its outstanding balance, then rolls the per-condition slave totals back into the summary table. **What it does:** Sets `sCode=1`, `iFlag=0`, clears `sReturn`. Reads master `dTotalMoney`/`dRoundingMoney` into running counters. Opens a cursor over `cahreceiptslave` joined to `cahreceiptsumslave` by `sSqlConditionId`, ordered ascending by `dBalanceMoney`. For each slave row: if remaining `p_dTotalMoneySum > ABS(dBalanceMoney)`, subtracts the balance from the counter (the totalMoney UPDATE is commented out — only the running balance is tracked); otherwise zeros the counter. The rounding-money branch still writes: `UPDATE cahreceiptslave SET dRoundingMoney = ` to spread the rounding to fit each slave's balance. After the cursor, rolls per-condition `SUM(dTotalMoney)`/`SUM(dRoundingMoney)` back into `cahreceiptsumslave`. Finally calls `Sp_afterSave_sRcts`. The 超额生成新单据 branch (creating a new `cahreceiptmaster` for the overflow) is fully commented out. **Invocation:** Status: appears orphaned. No `gdsmodule` row binds this proc on `sSaveProName`/`sSaveProNameBefore`; the peer `Sp_Calc_sRcts` is also unbound. No other routine references it. xly-src ships `script/标版/30100101/Sp_Check_sRcts.sql` as the install body — the script is in the codebase but no 收款单(汇总) form-master row currently wires it — candidate for maintainer audit (the family is set up but disabled).