# `Sp_beforeSave_sRcts` (procedure)

> 收款单保存前反写数量(汇总)


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sGuid` | `varchar(2000)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | OUT | `sCode` | `int` |
| 5 | OUT | `sReturn` | `varchar(4000)` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_beforeSave_sRcts`'`._

## Narrative

**Business context:** 财务收付款 / 收款单（汇总） — before-save dispatcher for the consolidated-receipt document. Sibling of `Sp_beforeSave_sRct` but operating on the summary/汇总 variant. Wraps `sGuid` and delegates to `Sp_saveReturn_sRcts` to backwrite received-money onto upstream advance-money fields before the master save commits.

**What it does:** Declares unused `iReceivablesType`, `CbxAdvanceType` locals, then `CALL Sp_saveReturn_sRcts(sGuid, sBrId, sSuId, 1, @sCode, @sReturn)` (always — no `IF sGuid IS NOT EMPTY` guard; the `SET sGuid = IF(INSTR(sGuid,'"')>0...)` normalisation has been moved inside the commented-out legacy block, so the active path passes `sGuid` raw). The body retains 20K chars of commented-out legacy fallback SQL — same branched updates against `SalSalesOrderMaster` / `MftWorkOrderMaster` as `Sp_beforeSave_sRct`, now superseded by the saveReturn sibling. A `-- leave top;` debug comment remains.

**Invocation:** **Not** hooked on any `gdsmodule` row directly. Reached only via dispatcher procs `Sp_Invalid_backwriting` and `Sp_delete_backwriting`, which branch to this proc when `sFormGuid = '101251240115017022732698090'` (收款单（汇总） — sId is not in `gdsmodule`, presumably configured at the form-master / customer-override layer).
