# `Sp_Calc_sScr` (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(4000)` |
| 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_sScr`'`._

## Narrative

**Business context:** 销售管理 → 派车单单据 (sales delivery dispatch / `SalSendCarMaster`) audit / un-audit. Auditing the 派车单 commits a vehicle and driver to a set of 送货单 lines and writes the dispatch reference back onto each 送货单 slave.

**What it does:** Validates `sGuid`, refuses when `bInvalid=1`, and on `iFlag=1` guards on `bCheck`/account period then sets `bCheck=1`, `sCheckPerson`, `tCheckDate` on `SalSendCarMaster`; iterates `salsendcarslave` to `UPDATE saldelivergoodsslave` (write the dispatch id / scheduled date onto the matching delivery line) and may call `Sp_System_CheckFlow` per slave when define-check is on. `iFlag=0` reverses the writeback and clears the flags.

**Invocation:** Bound to `gdsmodule.sProcName` on `派车单单据` (sId `15839936170002427227633635401000`) — 销售管理. Dispatched by `BusinessBaseServiceImpl.getPrcName(sFormGuid, …)` on the 审核/反审核 button. xly-src carries an `script/标版/20220104审核去除结账校验/Sp_Calc_sScr.sql` upgrade patch and a 千彩 customer override at `script/客户/千彩/Sp_Calc_sScr.sql` — verify which is deployed.
