# `Sp_Sales_PurchaseAnalysiseOfSupply` (procedure)

> 现金日记帐


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `tStartDate` | `datetime` |
| 2 | IN | `tEndDate` | `datetime` |
| 3 | IN | `sBrId` | `varchar(100)` |
| 4 | IN | `sSuId` | `varchar(100)` |
| 5 | IN | `sLoginId` | `varchar(100)` |
| 6 | IN | `bFilter` | `varchar(5000)` |
| 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_Sales_PurchaseAnalysiseOfSupply`'`._

## Narrative

**Business context:** 采购管理 → 采购分析报表 → 采购分析-按供应商 — paged report that aggregates purchase qty, money and payment status by 供应商 across the period. Lets procurement compare supplier-level spend and outstanding payment.

**What it does:** Builds temp `SAS`/`tempSAS`, `INSERT INTO SAS` from `viw_purpurchaseorder` joined against `elesupply` and `cahpaymentmaster` for per-supplier payment totals. `UPDATE SAS` folds in extra aggregates. Final paging via `Sp_Do_UpdateByPageSizeBefore` with `pageNum/pageSize` and `countMapJson` from `countCloumn`; `bFilter`/`sFilterOrderBy`/`sGroupby_*` spliced in.

**Invocation:** Bound to `gdsconfigformmaster.sSqlStr` on form `19211681019715708433570790` (采购分析-按供应商) under 采购分析报表 → 采购管理. Install scripts at `script/标版/30100101/Sp_Sales_PurchaseAnalysiseOfSupply.sql`, optimised at `script/标版/20210323/optimizeprocedure.sql`, customer override at `script/客户/福雅/`.

Note: the page's heading `现金日记帐` is a stale `gdsmodule.sChinese` artefact — the live business identity is 采购分析-按供应商.
