# `Sp_Calc_sMmm` (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_sMmm`'`._

## Narrative

**Business context:** 财务管理 → 财务单据 → 材料存货调整单据 — material **value** adjustment audit / un-audit on `MitMaterialsStoreAdjustmoneyMaster`. Sister to `Sp_Calc_sMma` (qty side); this variant is the finance-driven version that re-prices existing on-hand without changing quantities — e.g., supplier price revisions, period-end revaluation.

**What it does:** Defaults the IN params, branches on `iFlag`. On `iFlag=1` flips `MitMaterialsStoreAdjustmoneyMaster.bCheck=1`, writes the re-valuation rows into `MitMaterialsStore`, and `INSERT INTO EleMaterialsStock` to refresh the on-hand snapshot's value columns. `iFlag=0` runs `Delete From MitMaterialsStore` for the doc's value-adjust rows and `UPDATE EleMaterialsStock` to restore prior valuation.

**Invocation:** Bound to `gdsmodule.sProcName` on `材料存货调整单据` (sId `101251240115015990257724500`) under 财务管理 → 财务单据. Dispatched by Java `BusinessBaseServiceImpl.getPrcName(sFormGuid, …)` on the 审核/反审核 button. xly-src ships `script/标版/30100101/Sp_Calc_sMmm.sql` and `script/标版/optimize/Sp_Calc_sMmm.sql`.
