# `Sp_Calc_sRcts` (procedure)

> 收款单(汇总)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `iFlag` | `int` |
| 2 | IN | `iTmpCheck` | `int` |
| 3 | IN | `sFormGuid` | `varchar(100)` |
| 4 | IN | `sGuid` | `varchar(100)` |
| 5 | IN | `sLoginId` | `varchar(100)` |
| 6 | OUT | `sReturn` | `varchar(100)` |
| 7 | IN | `sBrId` | `varchar(100)` |
| 8 | IN | `sSuId` | `varchar(100)` |
| 9 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** Sister proc of [`Sp_Calc_sRct`](Sp_Calc_sRct.md), suffix `s` likely for "汇总" / "summary" — its header reads `收款单(汇总)`. Audit / un-audit of a consolidated 收款单 that aggregates multiple source bills under one master. The body re-emits one row into `cahreceiptnewmaster` per source-bill type and chains `Sp_Calc_sDgd`/`Sp_Calc_sSod`/`Sp_Calc_sWod` so the underlying delivery / sales-order / work-order auto-audit through the same flow.

**What it does:** Skeleton matches `Sp_Calc_sRct` (validate + lock + cursor slave + flip master), but on the back-write side it: `Insert Into cahreceiptnewmaster` rows for the consolidated receipt, `Insert Into CahWasteBook`, `Update CahReceiptMaster`/`CahFinancialAdjust`, back-writes `SalSalesOrderMaster`/`SalDeliverGoodsMaster`/`MftWorkOrderMaster`, posts `kpidetail`, and calls `Sp_Calc_sDgd`/`Sp_Calc_sSod`/`Sp_Calc_sWod` per consolidated source slave. `iFlag=0` `delete from cahreceiptnewmaster`/`cahwastebook` and reverses.

**Invocation:** No `gdsmodule.sProcName='Sp_Calc_sRcts'` binding in this snapshot — only `Sp_Calc_sRct` is wired up. xly-src ships `script/标版/30100101/Sp_Calc_sRcts.sql` (install script) but no live form points at it. **Status: appears orphaned.** Likely a tenant-specific consolidated-receipt audit that gets activated by overwriting `gdsmodule.sProcName` on a 收款单(汇总) module row during customer install — candidate for maintainer audit before relying on it.
