# `SP_Inventory_InOutWarehouseCost` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sMaterialsGuid` | `varchar(100)` |
| 2 | IN | `sMaterialsStyleS` | `varchar(100)` |
| 3 | IN | `sWareHouseGuid` | `varchar(100)` |
| 4 | IN | `tStartDate` | `datetime` |
| 5 | IN | `tEndDate` | `datetime` |
| 6 | IN | `sLocationGuid` | `varchar(100)` |
| 7 | IN | `sWarehouseLocationGuid` | `varchar(100)` |
| 8 | IN | `sLoginId` | `varchar(100)` |
| 9 | IN | `sBrId` | `varchar(100)` |
| 10 | IN | `sSuId` | `varchar(100)` |
| 11 | IN | `bFilter` | `varchar(5000)` |
| 12 | IN | `pageNum` | `int` |
| 13 | IN | `pageSize` | `int` |
| 14 | OUT | `totalCount` | `int` |
| 15 | IN | `countCloumn` | `varchar(5000)` |
| 16 | OUT | `countMapJson` | `longtext` |
| 17 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 18 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 19 | IN | `sGroupby_group_sql` | `varchar(5000)` |
| 20 | OUT | `sCode` | `int` |
| 21 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 成本核算 — cost-flavoured fork of `SP_Inventory_InOutWarehouse` that drives the cost-accounting material in/out ledger. Whereas the standard variant works against `EleMaterialsStock` / `elematerialsstockmonth`, this one reads `AccMaterialsStore` / `elematerialsstockmonthCost` / `viw_accmaterialsinit` so the report reflects costed (rather than physical) movements per the closed accounting period.

**What it does:** Resolves the cost period via `sysaccountperiod` + `SysSystemSettings`, populates `InOutWarehouse` from `AccMaterialsStore` movements and `viw_accmaterialsinit` initial balances, calls `Sp_Sis_GetMertialsInventoryFormGuid` + `Sp_Sis_GetConst` + `Sp_System_ReplaceField` for form-config and material-style normalisation, then paginates via `Sp_Outstanding_Query`.

**Invocation:** Status: appears orphaned in the live DB. No `gdsconfigformmaster` binding, no `gdsmodule` hook, no other-routine reference. xly-src ships install script `script/标版/30100101/cost/SP_Inventory_InOutWarehouseCost.sql` under the `cost/` install set (a cost-accounting add-on bundle that may not be deployed on every tenant) — candidate for maintainer audit on tenants where cost accounting is enabled.
