# `Sp_Calc_sLos` (procedure)

> @author:zhucx
							@date:2021.11.29
							@describe: 	物流管理-物流单 审核


- **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_sLos`'`._

## Narrative

**Business context:** 物流管理 → 10.物流单据 → 物流单单据 — logistics-order check / uncheck on `logisticsordermaster`. Approves a 物流单 (outbound logistics ticket — carrier picking up a 送货单 batch) so the listed deliveries become flagged as shipped-via-this-carrier, ready for downstream 物流对账 reconciliation.

**What it does:** Validates `sGuid`, refuses when `bInvalid=1`, checks `sysaccountperiod.bFrozen` per the system settings, and `SysLocking` against the carrier supplier. With `iFlag=1`: calls `Sp_Check_sLosTest` for pre-flight validation, `Update logisticsordermaster` to set the audit flags, `Update logisticsorderdetails` (slave detail lines) to flag them as shipped, `UPDATE saldelivergoodsslave` to write back the carrier/物流单 reference into each linked 送货单 row, and `CALL Sp_Bill_Used` to mark the bill consumed. Uncheck reverses the master/detail flags and clears the back-write on `saldelivergoodsslave`.

**Invocation:** Bound to `gdsmodule.sProcName` on `物流单单据` (sId `101251240115016270322291050`), parent `10.物流单据` → 物流管理. Dispatched by Java `BusinessBaseServiceImpl.getPrcName(...)` on the audit/un-audit button. xly-src ships `script/标版/30100101/Sp_Calc_sLos.sql` (install) and `script/标版/optimize/Sp_Calc_sLos.sql` (patch). Authored 2021-11-29 by `zhucx` per the body header.
