# `sp_update_billmaterials_MoneyToPrice` (procedure)

> 修改物料价格


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sTbSlaveName` | `varchar(40)` |
| 2 | IN | `sTbMasterName` | `varchar(40)` |
| 3 | IN | `sGuid` | `varchar(100)` |
| 4 | IN | `sFormGuid` | `varchar(100)` |
| 5 | IN | `iType` | `int` |
| 6 | IN | `sBrId` | `varchar(40)` |
| 7 | IN | `sSuId` | `varchar(40)` |
| 8 | OUT | `sCode` | `int` |
| 9 | OUT | `sReturn` | `longtext` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `sp_update_billmaterials_MoneyToPrice`'`._

## Narrative

**Business context:** 单据价格刷新 (修改物料价格) — generic material-line price/tax recalculation helper used after bulk money-side edits on any 物料 slave table. Reverses the usual money-from-price flow: given an updated `dMaterialsForeignMoney`, it derives `dMaterialsTaxForeignMoney`, taxable price, and per-unit price using `sistax.dRate` and the configured decimal precision.

**What it does:** Reads `NetMoney`/`NetPrice` from `SysSystemSettings` for `(sBrId, sSuId)` to control rounding. Builds and executes a dynamic `UPDATE sTbSlaveName A JOIN sistax B ON A.sTaxId=B.sId` that sets `dMaterialsTaxForeignMoney = ROUND(ROUND(dMaterialsForeignMoney/(1+dRate/100), NetMoney)*(dRate/100), NetMoney)` and downstream price columns. `iType=0` recomputes price from money; other modes branch through alternate formulas. Validates `sTbSlaveName` (refuses empty) and returns `sCode/sReturn`.

**Invocation:** Status: appears orphaned. No caller found in form-master, gdsmodule hooks, other routines, or xly-src grep — the only xly-src hits are this proc's own install script `script/标版/刷新价格过程/sp_update_billmaterials_price.sql` and an unrelated 客户/万昌 file. Candidate for maintainer audit; appears to be a maintenance/repair helper invoked ad-hoc by DBAs.
