# `Sp_Apply_Flow_QualityaccidentMaterials` (procedure)

> 流程启动前调用-供应商扣款单


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sFormGuid` | `varchar(100)` |
| 2 | IN | `sGuid` | `varchar(100)` |
| 3 | IN | `sSrcNo` | `varchar(100)` |
| 4 | IN | `sLoginId` | `varchar(100)` |
| 5 | OUT | `sTableParams` | `longtext` |
| 6 | OUT | `sSrcReportData` | `longtext` |
| 7 | OUT | `sTableParamsValue` | `longtext` |
| 8 | OUT | `sReturn` | `varchar(4000)` |
| 9 | IN | `sBrId` | `varchar(100)` |
| 10 | IN | `sSuId` | `varchar(100)` |
| 11 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 供应商扣款单 (流程启动前调用-供应商扣款单) — workflow-apply data builder for the supplier-deduction approval flow on `purpurchaseinstorededmaster` (negative-incoming / deduction header). Builds a nine-tier roster and per-line summary.

**What it does:** Resolves tiers from `eleemployee.iPosition`: 18=品管部, 6=物控部, 8=生产部, 26=应付会计, 1=总经理, 38=副董执行董事, 34=国内事业副总, 11=财务总鉴, 39=董事长. Emits per-line memo CONCAT-ing `物料名称➜辅助数量+单位➜扣款金额` from `purpurchaseinstorededslave`. Computes `p_dTotalMoney` as `0-SUM(dMaterialsMoney)`. Final payload includes `iCigPack` (烟包 indicator) read straight from master.

**Invocation:** Dispatched dynamically by Java `CheckExamineFlowDataServiceImpl.doSendCheckFolwData()` via `doProByNameFlow(..., sApplyProName, ...)` from `gdsmoduleflow.sApplyProName` (empty in this DB — workflow configs tenant-provisioned per deployment).

Note: companion in-flow updater `Sp_Apply_Flow_QualityaccidentMaterials_Proc1` writes back the user-decided `dOKMaterialsMoney` into the master after the relevant approval step.
