# `Sp_Inventory_ProductInventoryV56` (procedure)


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProductGuid` | `varchar(100)` |
| 2 | IN | `sLoginId` | `varchar(100)` |
| 3 | IN | `sProductClassifyGuid` | `varchar(100)` |
| 4 | IN | `sWarehouseGuid` | `varchar(100)` |
| 5 | IN | `sLocationGuid` | `varchar(100)` |
| 6 | IN | `sWarehouseLocationGuid` | `varchar(100)` |
| 7 | IN | `sCustomerGuid` | `varchar(100)` |
| 8 | IN | `iHasZero` | `int` |
| 9 | IN | `iGetQty` | `int` |
| 10 | OUT | `dProductQty` | `decimal(18,6)` |
| 11 | IN | `sDefineNoS` | `varchar(100)` |
| 12 | IN | `sDefineNoS2` | `varchar(100)` |
| 13 | IN | `iSumQty` | `int` |
| 14 | OUT | `dProductPrice` | `decimal(18,6)` |
| 15 | IN | `tStartDate` | `datetime` |
| 16 | IN | `tEndDate` | `datetime` |
| 17 | IN | `iDetailStock` | `int` |
| 18 | IN | `iGetAvailableQty` | `int` |
| 19 | IN | `sBrId` | `varchar(100)` |
| 20 | IN | `sSuId` | `varchar(100)` |
| 21 | IN | `bFilter` | `varchar(5000)` |
| 22 | IN | `pageNum` | `int` |
| 23 | IN | `pageSize` | `int` |
| 24 | OUT | `totalCount` | `int` |
| 25 | IN | `countCloumn` | `varchar(5000)` |
| 26 | OUT | `countMapJson` | `longtext` |
| 27 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 28 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 29 | IN | `sGroupby_group_sql` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 成品库存 → 库存查询 → 成品可用库存查询 / 移动端管理 → 工作台 → 常用报表 → 成品库存 — finished-product available-stock query. Shows current on-hand qty net of reservations, sliced by warehouse / location / 自定义项, used on both the desktop available-stock screen and the mobile workbench finished-stock card.

**What it does:** Builds a temp ledger from `pitproductstore` plus `eleproductstock` aggregated per product / 自定义项 / warehouse / location, subtracting outstanding 送货 reservations and frozen-stock flags, then joins `eleproduct` / `elecustomer` / `elewarehouse` for display columns. Returns paginated rowset and count-aggregation JSON through `Sp_Outstanding_Query`. Switches: `iHasZero` keep/drop zero rows, `iGetQty` qty-only mode, `iSumQty` collapse to aggregates, `iDetailStock` detail mode, `iGetAvailableQty` toggle reservation netting.

**Invocation:** Bound as the data source on form-masters `19211681015115285140931300` (成品可用库存查询 — 库存查询) and `101251240115015897741046460` (成品库存 — 移动端 → 工作台 → 常用报表). Function `Fun_getInitColumnByProName` references it for column metadata. xly-src ships `script/标版/30100101/Sp_Inventory_ProductInventoryV56.sql` and `script/标版/optimize/Sp_Inventory_ProductInventoryV56.sql`; `script/客户/千彩/Sp_Inventory_ProductInventoryV56_qc.sql` is the 千彩 override.
