# `Sp_SalSalesCheck_YM` (procedure)

> 发出商品未对账月末账龄


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 销售管理 → 销售送货流程 → 3/4 送货单->销售对帐 → 发出商品未对账月末账龄 — month-end (月末) aging report of un-reconciled 送货 stock. The `_YM` (年月) variant of `Sp_SalSalesCheck` projects every still-open 送货 line into 1-30天 / 31-60天 / 61-90天 / 91-120天 / 121-180天 / 181-360天 / 361天以上 buckets as of `tEndDate` so finance can size the AR-发出 reserve.

**What it does:** Reads `SysSystemSettings` `NetMoney/NetPrice` rounding; assembles `TmpSalSalesCheck` from `Viw_SalDeliverGoods`, `viw_saldelivergoodsded`, `Viw_SalRejectGoods` and `viw_Accproductinit`; excludes rows already linked via the `B1`/`sMinusSrcId` table; computes the aging bucket from `DATEDIFF(tEndDate, A.tCreateDate)` and writes the bucket amount into the matching `dN_M` column; applies `Fun_GetLookCustomer` scoping, splices `bFilter`, and returns paged results to the form via the standard report contract.

**Invocation:** Not bound to any `gdsconfigformmaster` row in the live DB and no other-routine caller — but the page heading (`gdsmodule.sChinese` 发出商品未对账月末账龄) is preserved on the file, so the form binding presumably exists under a customer-specific tenant or has been retired. Status: appears orphaned in this tenant — candidate for maintainer audit before removal.
