# `Sp_System_AutoProductPriceSingle` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `tStartDate` | `datetime` |
| 2 | IN | `tEndDate` | `datetime` |
| 3 | IN | `iType` | `int` |
| 4 | IN | `sLoginId` | `varchar(100)` |
| 5 | IN | `sBrId` | `varchar(100)` |
| 6 | IN | `sSuId` | `varchar(100)` |
| 7 | OUT | `sReturn` | `varchar(4000)` |
| 8 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 库存管理 / 成本核算 → 成品价格自动结转 — product-side counterpart of `Sp_System_AutoMaterialsPriceSingle`. Period-scoped (no per-document `sGuid`) pass that resolves each in-period product's effective price from the latest sales / customer-price / product-master / reconciliation source, populates a temp `Sp_EleProductStockSum`/`Sp_EleProductStock` snapshot, and back-writes the unit price to the period's成品 stock-check rows.

**What it does:** Initialises temp tables `Sp_EleProductStockSum` (per-product roll-up across the period) and `Sp_EleProductStock` (per-warehouse/location detail). For each product touched between `tStartDate`/`tEndDate`, looks up `dProductPrice` in priority order — most recent sales-order in the period, then `eleproductcustomer`/`eleproduct` defaults, then nearest 销售对账. Settings `NetPrice`/`NetMoney` from `SysSystemSettings` set decimals. `iType` switches between in-period stock-view computation and downstream propagation; results refresh the成品 stock-check tables for the period. Mirrors the dual-mode in the base materials proc (`bUpdate=1` 月末结帐, `bUpdate=0` UI preview).

**Invocation:** Status: appears orphaned at this snapshot. No `gdsmodule.sProcName` hook, no form-master binding, no other-routine caller, no MyBatis XML reference. Install copies live at `script/标版/30100101/Sp_System_AutoProductPriceSingle.sql` and `script/客户/千彩/Sp_System_AutoProductPriceSingle.sql` (customer override). Verify whether a 成品价值 button or batch job currently invokes it before relying on it; the wiring may be customer-specific.
