# `Sp_Apply_Flow_Cahreceipt` (procedure)

> 流程启动前调用-收款单舍入金额，比如说超过100元的，
					二级部门、一级部门，财务审核，
					超过2000的总经理审核


- **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_Cahreceipt`'`._

## Narrative

**Business context:** 收款单 (Cash Receipt) workflow-apply data builder — header says "流程启动前调用-收款单舍入金额，比如说超过100元的, 二级部门、一级部门，财务审核, 超过2000的总经理审核". One of the per-form `Sp_Apply_Flow_<Form>` procs in the `Sp_Apply_Flow_*` family that the workflow engine invokes before kicking off an approval chain to populate the approval card's display labels, value JSON, and candidate-approver lists.

**What it does:** Resolves the four approver tiers (二级部门 / 一级部门 / 财务 / 总经理) from `eleemployee` joined through `sisdepart` for the 制单人 plus `iPosition`-filtered managers (`iPosition=11` for finance, `iPosition=1` for GM). Builds `p_sProductName` by aggregating `cahreceiptslave` rows where `dRoundingMoney > 0` into a `产品名称➜开票金额➜舍入金额` summary. Emits two outputs: `sTableParams` = JSON of column-label translations; `sTableParamsValue` = JSON containing the resolved field values + the four approver name lists (`OneFlow`/`TwoFlow`/`ThreeFlow`/`FourFlow`) joined from `cahreceiptmaster` + `elecustomer`. The `sSrcReportData` JSON output is fully commented out (defaults flow through `Sp_Add_Flow`).

**Invocation:** Dispatched dynamically by Java `CheckExamineFlowDataServiceImpl.doSendCheckFolwData()` via `doProByNameFlow(..., sApplyProName, ...)` where `sApplyProName` is read from `gdsmoduleflow.sApplyProName` on the 收款单 workflow config row (`gdsmoduleflow` is empty in this database — workflow configs are tenant-provisioned per deployment). See [`Sp_Add_Flow`](./Sp_Add_Flow.md) for the surrounding flow-insert entry point.
