# `Sp_Calc_sExp` (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(5000)` |
| 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_sExp`'`._

## Narrative

**Business context:** 成本管理 → 成本单据 → 费用分摊单据 — cost-allocation check / uncheck on `CosExpenseShare`. Approves a 费用分摊 (overhead/expense allocation across cost centers or orders) so the allocated amounts feed the cost-rollup queries.

**What it does:** Tiny stub. Validates `sGuid` (no `bInvalid` check, no account-period guard, no slave loop). With `iFlag=1`: `Update CosExpenseShare Set bCheck=1, sCheckPerson, tCheckDate=NOW() Where sId=sGuid`. With `iFlag<>1`: same `UPDATE` with `bCheck=0`. Unlike most `Sp_Calc_s*` siblings it never refuses an already-checked/unchecked bill — both branches are idempotent overwrites.

**Invocation:** Bound to `gdsmodule.sProcName` on `费用分摊单据` (sId `15848534690001174150034350979800`), parent `成本单据` → 成本管理. Dispatched by Java `BusinessBaseServiceImpl.getPrcName(...)` on the audit/un-audit button. xly-src ships `script/标版/30100101/Sp_Calc_sExp.sql` (install) and `script/标版/optimize/Sp_Calc_sExp.sql` (patch).

Note: COMMENT `'销售订单'` is a copy-paste artefact, ignore. Flag for audit: missing `sStatus`-flip and missing already-checked guard versus family norm.
