# `Sp_Sales_NotDeliverGoodMaterialsList` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sCustomer_id` | `varchar(100)` |
| 2 | IN | `iCopeEvent` | `int` |
| 3 | IN | `sLoginId` | `varchar(100)` |
| 4 | IN | `sState` | `varchar(10)` |
| 5 | IN | `sBrId` | `varchar(100)` |
| 6 | IN | `sSuId` | `varchar(100)` |
| 7 | IN | `bFilter` | `longtext` |
| 8 | IN | `sUnTaskFormId` | `varchar(100)` |
| 9 | IN | `pageNum` | `int` |
| 10 | IN | `pageSize` | `int` |
| 11 | OUT | `totalCount` | `int` |
| 12 | IN | `countCloumn` | `varchar(5000)` |
| 13 | OUT | `countMapJson` | `longtext` |
| 14 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 15 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 16 | 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_NotDeliverGoodMaterialsList`'`._

## Narrative

**Business context:** 材料销售管理 → 材料未送货任务列表 — paged worklist of material-side 销售订单 lines still owing delivery (companion to the product-side `Sp_Sales_NotDeliverGoodList`). Used by the materials-sales clerk to plan which 材料送货单 to ship next.

**What it does:** Builds temp `NotDeliverGoodList`, sources base rows from `Viw_SalSalesOrder`/`SalSalesOrderSlave` joined against `elecustomer`, `elematerials`, `siswarehouse`, `sissalesman`, `sispayment`, `sisdeliver`, `sistax`; folds in stock (`eleproductstock`, `pitproductstorevirtual`, `PitProductInStoreSlave`), 工单 status (`Viw_MftWorkOrder`/`mftworkorderslave`), 委外入库 (`Viw_OpsOutSideInStore`), 送货 history (`SalDeliverGoodsSlave`) and reject deductions (`SalRejectGoodsSlave`). Filters by `iCopeEvent`, `sState`, `bFilter`, `Fun_GetLookCustomer(sLoginId)` and `sUnTaskFormId`. Paging via `Sp_Do_UpdateByPageSizeBefore`.

**Invocation:** Bound to `gdsconfigformmaster.sSqlStr` on form `101251240115016140462211080` (材料未送货任务列表) under 材料销售管理 → 销售管理. Install scripts at `script/标版/30100101/` and `script/标版/20210323/optimizeprocedure.sql`, plus customer override `script/客户/福雅/optimizeprocedure.sql`.
