# `GetMaterialsAuxiliaryQty` (function) - **Type:** FUNCTION - **Returns:** `decimal(18,6)` - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `iType` | `int` | | 2 | IN | `p_sMaterialsId` | `varchar(100)` | | 3 | IN | `p_sMaterialsStyle` | `varchar(100)` | | 4 | IN | `p_sDefineNo` | `varchar(255)` | | 5 | IN | `p_sDefineNo2` | `varchar(255)` | | 6 | IN | `p_sWareHouseId` | `varchar(100)` | | 7 | IN | `p_sLocationId` | `varchar(100)` | | 8 | IN | `p_sWareHouseLocationId` | `varchar(100)` | | 9 | IN | `p_sBrId` | `varchar(100)` | | 10 | IN | `p_sSuId` | `varchar(100)` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTION `GetMaterialsAuxiliaryQty`'`._ ## Narrative **Business context:** Materials auxiliary-unit stock query. Returns either a single location's on-hand auxiliary quantity (`iType=0`) or the available auxiliary stock for the whole tenant after netting in-transit virtual moves (`iType≠0`). **What it does:** When `iType=0`, looks up `elematerialsstock.dAuxiliaryQty` matching the eight key columns. When `iType≠0`, sums `dAuxiliaryQty` from `elematerialsstock` across all warehouses, then adjusts: subtracts the `MitMaterialsStoreVirtual` rows tagged with purchase-form `sFormId='192116810113315217757747140'` and adds back work-order-form rows (`'19211681019715469179247390'` and `'19211681019715329305562620'`). **Invocation:** Status: appears orphaned. No form-master, gdsmodule, other-routine, or xly-src caller (the matching `xly-src/script/标版/30000101/GetMaterialsAuxiliaryQty.sql` is the definition itself). Sibling of the substantive `Fun_GetMaterialsQtyUnit` family — appears to be an earlier capitalized name retained but unwired. Hardcodes tenant-specific `sFormId` GUIDs. Candidate for maintainer audit.