# `Sp_Cashier_GetCostMaterialsPrice` (procedure) - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sMaterialsGuid` | `varchar(100)` | | 2 | OUT | `dPrice` | `decimal(18,6)` | | 3 | IN | `sMaterialsStyleS` | `varchar(100)` | | 4 | IN | `sDefineNoS` | `varchar(100)` | | 5 | IN | `sDefineNoS2` | `varchar(100)` | | 6 | IN | `sWarehouseGuid` | `varchar(100)` | | 7 | IN | `sLocationGuid` | `varchar(100)` | | 8 | IN | `sWarehouseLocationGuid` | `varchar(100)` | | 9 | IN | `sBrId` | `varchar(100)` | | 10 | IN | `sSuId` | `varchar(100)` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Cashier_GetCostMaterialsPrice`'`._ ## Narrative **Business context:** 财务管理 / 库存 — material cost-price resolver. Returns the unit cost for a given material (and optional style / define-no / warehouse-location) following whichever costing model the tenant has selected in `SysSystemSettings.CbxMaterialsCostMode`. **What it does:** Reads the `CbxMaterialsCostMode` setting (0/1/2 = `EleMaterials.dPurchasePrice` / `dRecentPurchasePrice` / `dPurchasePrice`; 3 = weighted-average from `elematerialsstock.dMaterialsMoney / dMaterialsQty` keyed by style+defineNo and optionally warehouse-location; 4 = recent purchase). For modes 3/4 it honours `CkxMaterialsTax` — if tax is excluded, divides the purchase price by 1.16. Falls back through dRecentPurchasePrice → dPurchasePrice when the chosen channel yields 0. Output `dPrice` is the resolved cost. **Invocation:** Inlined from sibling pricers — `Sp_Cashier_GetMaterialsPrice` calls it when `CbxOfferMaterials='recentcost'`; the function wrapper family (`Fun_Cashier_GetMaterialsPrice*`) covers the same path for scalar contexts. No direct form/Java caller — only reached transitively through those wrappers used by quotation/work-order/gross-profit calculators.