# `Fun_Cashier_GetMaterialsPrice` (function)

> 获取最近采购价(物料)


- **Type:** FUNCTION
- **Returns:** `varchar(100)`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sMaterialsGuid` | `varchar(100)` |
| 2 | IN | `sSupplyGuid` | `varchar(100)` |
| 3 | IN | `sBrId` | `varchar(100)` |
| 4 | IN | `sSuId` | `varchar(100)` |

## Body

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

## Narrative

**Business context:** Purchasing/quotation/work-order — "most recent purchase price" lookup for a material, optionally filtered by supplier. The cost-calculation procs use this to default a material line's unit cost when the user hasn't typed one in. Header comment is `获取最近采购价(物料)` ("get most-recent purchase price for material").

**What it does:** reads `elematerialssupply.dQuantityPrice` for the given material, tenant-scoped by `sBrId`/`sSuId`, only over `bCheck = 1` rows, taking the latest by `tCreateDate`. Tries narrowing filters in order: (supplier + style) → (supplier alone) → (style alone) → (material alone). Returns the price as a varchar; `'0'` when nothing matches.

**Invocation:** referenced from form-master `sId 192116810113315263819752160` ("1/4 采购申请->采购订单") and `101251240115016347243410860` ("待入库客来料任务列表"). Called directly by the quotation calc family (`Sp_Quotation_CalcData*`), work-order calc family (`Sp_WorkOrder_CalcData*`), `Sp_Inventory_MaterialsInventoryV56Price`, `Sp_Manufacture_sWodPurchareMaterials_copy1`, the materials check proc `Sp_Check_sMcd`, and the `_Quo` quotation variant of itself.
