# `Sp_ProductAgingAnalysis_YM` (procedure)

> 产品月末账龄分析


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sBrId` | `varchar(100)` |
| 2 | IN | `sSuId` | `varchar(100)` |
| 3 | IN | `sLoginId` | `varchar(100)` |
| 4 | IN | `tStartDate` | `datetime` |
| 5 | IN | `tEndDate` | `datetime` |
| 6 | IN | `bFilter` | `text` |
| 7 | IN | `pageNum` | `int` |
| 8 | IN | `pageSize` | `int` |
| 9 | OUT | `totalCount` | `int` |
| 10 | IN | `countCloumn` | `varchar(5000)` |
| 11 | OUT | `countMapJson` | `longtext` |
| 12 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 13 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 14 | IN | `sGroupby_group_sql` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 销售管理 / 库存 → 产品月末账龄分析 — month-end snapshot variant of `Sp_ProductAgingAnalysis`. Same aging logic but reads the period-closed inventory snapshot table `eleproductstockmonth` instead of the live `eleproductstock`, scoped to `(tStartDate..tEndDate)` so a user can ask "what did the aging picture look like at the end of month X".

**What it does:** `CALL Sp_Sis_GetProductInventoryFormGuid` to fill `P_Tmp_sFromId`, then `INSERT INTO P_Tmp_product_List`, `P_Tmp_product_List_Group`, `P_Tmp_product_List_return` aggregating `eleproductstockmonth` and `PitProductStore` rows joined to `salsalesordermaster`/`salsalesorderslave`, `elecustomer`, `eleproductcustomer`, `eleproduct`, `sislocation`, `siswarehouse`, `SisCurrency`, `SisSalesMan`, `sisproductclassify`. Period bounds are pushed into the predicate; paging/groupby/orderBy delegated to the standard helper.

**Invocation:** No live caller in any channel (form-master, gdsmodule hooks, other procs, xly-src grep, dynamic-dispatch search). One of the four `Sp_ProductAgingAnalysis*` siblings; the YM variant's grid binding is not registered in `xlyweberp_saas_ai` — candidate for maintainer audit.
