# `Sp_saveReturn_sRcts` (procedure)

> 估价单保存前反写状态


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 财务管理 → 收款单(汇总) — back-write helper for the consolidated 收款单 (`CahReceiptMaster` summarised across multiple customers/orders). Mirrors `Sp_saveReturn_sRct` but for the summary variant: re-syncs the received amounts back onto the matched sales-side lines and ledger rows when a 汇总 receipt is saved or cancelled.

**What it does:** Same shape as `Sp_saveReturn_sRct` — splits `sGuid` into `p_t_sId`, builds `t_data_temp`, then UPDATEs `SalSalesOrderMaster/Slave`, `SalDeliverGoodsMaster/Slave`, `SalSalesCheckingSlave`, `SalSalesInvoiceSlave`, `MftWorkOrderMaster/Slave`, `CahCustomerInit`, `CahPaymentMaster`, `CahReceiptMaster`, `CahFinancialAdjust`, `SalQualityAbnormalSlave`. `iTag=1` excludes current 收款 doc; `iTag=2` includes it.

**Invocation:** Wrapped by `Sp_afterSave_sRcts` (iTag=2) and `Sp_beforeSave_sRcts` (iTag=1). 收款单(汇总) binds those wrappers via `gdsmodule.sSaveProName/sSaveProNameBefore`. Note `Sp_afterSave_sRcts`/`Sp_beforeSave_sRcts` actually call the non-汇总 `Sp_saveReturn_sRct` first then this one — both procs run together for 汇总 docs. Page front-matter mis-labels as "估价单保存前反写状态".
