# `Sp_beforeSave_sRct` (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_sRct`'`._

## Narrative

**Business context:** 财务收付款 / 收款单 — before-save dispatcher for the receipt document. Wraps `sGuid` and delegates to `Sp_saveReturn_sRct` to backwrite received-money onto upstream sales-order / work-order advance-money fields before the master save commits.

**What it does:** Declares unused `iReceivablesType`, `CbxAdvanceType` locals, normalises `sGuid` to a quoted-CSV form, then `CALL Sp_saveReturn_sRct(sGuid, sBrId, sSuId, 1, @sCode, @sReturn)`. The body retains 18K chars of commented-out legacy fallback SQL that selected `CbxAdvanceType` from `SysSystemSettings` and ran branched updates against `SalSalesOrderMaster` / `MftWorkOrderMaster` directly — superseded by the saveReturn sibling.

**Invocation:** Hooked as `gdsmodule.sSaveProNameBefore` on `收款单` (sId `192116810113315231731646200`). Also called by dispatcher procs `Sp_Invalid_backwriting` and `Sp_delete_backwriting`.
