GetMaterialsPrice.md 1.91 KB

GetMaterialsPrice (function)

  • Type: FUNCTION
  • Returns: varchar(8000)
  • Deterministic: NO
  • SQL data access: CONTAINS SQL

Parameters

# Mode Name Type
1 IN sMaterialsGuid varchar(100)
2 IN sMaterialsStyle 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 FUNCTIONGetMaterialsPrice'.

Narrative

Business context: Canonical materials-price lookup — returns the price for a EleMaterials.sId according to the per-tenant CbxOfferMaterials setting (which of four price columns to use). Used wherever a routine needs "the price of this material right now" for 报价/工单/采购 cost calculations.

What it does: reads SysSystemSettings.CbxOfferMaterials into iType, then SELECTs one of four price columns from EleMaterials keyed by (sId, sBrandsId, sSubsidiaryId): 0dPurchasePrice (采购价), 1dRecentPurchasePrice (最近采购价), 2dDesignateSalesPrice (指定销售价), 3dSalesPrice (销售价). Returns 0 for empty input or missing rows. Ignores the declared sMaterialsStyle parameter — pricing is keyed only on sId.

Invocation: referenced by 17+ stored routines including the entire Sp_Quotation_CalcData* and Sp_WorkOrder_CalcData* cost-build family (Std/Flex/Book/Pack/Set/LastStd/zr variants), Sp_Inventory_MaterialsInventoryV56Price and Sp_Manufacture_sWodPurchareMaterials_copy1. Wrapped by Fun_Cashier_GetMaterialsPrice_Quo. Form-side: embedded in the 采购申请→采购订单 conversion form (sId 192116810113315263819752160) and the OEE 待入库客来料任务列表 (sId 101251240115016347243410860). Also referenced in xly-src Sp_financial_OrderGrossProfit/CustomerGrossProfit/SaleManGrossProfit (margin reports).