# `Sp_Check_sRct` (procedure)

> 收款单保存之前数据校验


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 财务管理 → 财务收付款 → 收款单 — post-save validator on `cahreceiptmaster`. Carries one inline fix-up (rounding the foreign-currency product total) before delegating to the after-save peer for the real write-back into upstream receivables.

**What it does:** Sets `sCode=1`, defaults `iFlag` to 0, clears `sReturn`. Short-circuits to `sCode=-1` if `sReturn` is already populated. Then `UPDATE cahreceiptmaster SET dProductForeignMoney = ROUND(ROUND(dTotalMoney/dCurrencyRate, 3), 2) WHERE sId=sGuid` keeps the foreign-currency product money in sync with the converted total. Finally calls `Sp_afterSave_sRct(sGuid, sBrId, sSuId, sCode, sReturn)` and flips `sCode=-1` if that returns a message.

**Invocation:** Bound to `gdsmodule.sSaveProName` on `收款单` (`192116810113315231731646200`) — 财务管理 → 财务收付款 (KPI流程操作菜单). Dispatched by `BusinessBaseServiceImpl.checkUpdate(..., "sSaveProName")` after the save batch commits. Pre-save peer is `Sp_beforeSave_sRct`. xly-src ships `script/标版/30100101/Sp_Check_sRct.sql` as the install body.
