# `Sp_Check_sLok` (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_sLok`'`._

## Narrative

**Business context:** 销售管理 → 物流管理 → 物流对账单 (sLok = logistics-checking-order, on `opsoutsidecheckingmaster/slave`) — post-save validator and money/tax back-calculator for the 物流对账单 form. Sits between a logistics-supplier bill and the matched 物流单 records to reconcile cost.

**What it does:** Reads `NetMoney`/`NetPrice` precision from `SysSystemSettings`. Recomputes `dMaterialsNoTaxMoney` and `dMaterialsTaxMoney` on every non-manual `opsoutsidecheckingslave` row from `dMaterialsMoney` and `sistax.dRate`. Then cursors the matched slave/source-slave pairs (`sSrcSlaveId`), pulls each material's `sComputeId/sReComputeId/dRate`, and re-derives `dMaterialsMoney/dMaterialsQty/dAuxiliaryQty/dMaterialsNoTaxMoney/dMaterialsTaxMoney` per line so the totals tie back to the original 物流单 entries.

**Invocation:** Bound to `gdsmodule.sSaveProName` on `物流对账单单据` (`101251240115016270323854760`) under 销售管理 → 物流管理. Dispatched by `BusinessBaseServiceImpl.checkUpdate(..., "sSaveProName")` after the save batch commits. Pre-save peer is `Sp_beforeSave_sLok`; audit handler is `Sp_Calc_sLok`. xly-src ships `script/标版/30100101/Sp_Check_ssLok.sql` (note the double-s typo) as the install body.
