Fun_GetMaterialsQtyUnit.md 1.99 KB

Fun_GetMaterialsQtyUnit (function)

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

Parameters

# Mode Name Type
1 IN sMaterialsGuid varchar(100)
2 IN sMaterialsStyle varchar(100)
3 IN dAuxiliaryQty decimal(18,6)
4 IN iType int
5 IN sBrId varchar(100)
6 IN sSuId varchar(100)

Body

Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTIONFunGetMaterialsQtyUnit'._

Narrative

Business context: Material-quantity / unit conversion core — given an auxiliary qty in sheets (张/PCS), the material spec (size WxH or WxHxThickness and EleMaterials row), returns either the converted material qty in the storage unit (iType=0) or the resolved auxiliary unit name (iType=1). Drives every quotation, work-order, inventory, and check procedure that needs to translate between purchase units (吨/Ton/KG/M2/M3/M) and counting units (张/PCS).

What it does: Reads EleMaterials.dGramWeight, sMaterialsUnit, sAuxiliaryUnit, bReel, dCoefficient, bInverse; parses the *-delimited style; branches on (dimension count, reel flag, material unit) and applies the appropriate area×gram-weight formula scaled by the global CbxMaterialsUnit system setting (MM/CM/INCH) — INCH uses NetConversionRate to convert to metric.

Invocation: Called dynamically by Java service code — CalculationStdServiceImpl builds Select Fun_GetMaterialsQtyUnit(...) SQL during quotation/work-order standard-cost calculation, and ReplaceFieldServiceImpl substitutes the function name as sFunName when resolving derived columns. Also called from many Sp_Calc_s* / Sp_Check_s* / Sp_Quotation_Calc* / Sp_WorkOrder_Calc* / SP_Inventory_InOutWarehouse* procedures (52 stored-routine callers). Sibling: Fun_GetMaterialsQtyUnitSupple (board-with-thickness variant).