# `Sp_Apply_Flow_QualityaccidentNB` (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_QualityaccidentNB`'`._

## Narrative

**Business context:** 内部扣款单 (流程启动前调用-内部扣款单) — workflow-apply data builder for the internal-deduction approval flow on `saldelivergoodsdedinmaster` (employee/dept-level deduction header). Builds a four-tier roster anchored to the responsible department.

**What it does:** Resolves tiers from `eleemployee.iPosition`: 18=品管部, 30=HR, 11=财务经理. `p_TwoFlow` (责任部门负责人) is resolved by joining `saldelivergoodsdedinmaster.sDeptId` → `sisdepart.sEmployeeId` → `eleemployee.sId` (the dept's named leader, not by position). Emits per-line memo CONCAT-ing `责任职员➜责任金额` from `saldelivergoodsdedinslave`. Final payload includes `dExamineMoney`, `sProductName`, `sDeptName`, `sEmpName` for the display block.

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