# `Sp_afterSave_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_afterSave_sRcts`'`._

## Narrative

**Business context:** 收款单 (汇总变种) → 财务收付款 → KPI流程操作菜单 — header says 收款单保存后反写数量(汇总). Thin save-phase 反写 wrapper in the `Sp_afterSave_s<Code>` family for the aggregated-receipts (`sRcts` = "Receipt Summary") variant; delegates the actual money back-write to `Sp_saveReturn_sRcts`.

**What it does:** Declares unused locals `iReceivablesType`/`CbxAdvanceType`, wraps `sGuid` in double-quotes if not already quoted, then unconditionally calls `Sp_saveReturn_sRcts(sGuid, sBrId, sSuId, 2, @sCode, @sReturn)` (iFlag=2 = "after save" phase). The body carries a very large commented-out block that would once have set `CahReceiptMaster.dCurrencyRate=1` for RMB receipts and switched on `SysSystemSettings.CbxAdvanceType` / `CbxReceivablesType` to update `dRealAdvanceMoney` / `dReceiptMoney` across the upstream master/slave tables — inert. Does not propagate the inner `@sCode`/`@sReturn` back to its own OUT params.

**Invocation:** Reached on two paths. (1) `Sp_Check_sRcts` calls this proc near the tail of a successful save — note `gdsmodule.sSaveProName` slot for the receipts-summary form is empty, so `Sp_Check_sRcts` itself has no live binding; the form may rely on the dispatch path below. (2) `Sp_Invalid_backwriting` dispatches to this proc on 作废/取消作废 of form `101251240115017022732698090`. Caveat: that sFormGuid does not currently exist in `gdsconfigformmaster` or `gdsmodule` — likely a stale or tenant-specific id from an earlier deployment; this routine's live reachability in the current schema is limited.
