# `Sp_Cashier_OrderMoneyWarning` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `iState` | `int` |
| 2 | IN | `sBrId` | `varchar(255)` |
| 3 | IN | `sSuId` | `varchar(255)` |
| 4 | IN | `bFilter` | `varchar(5000)` |
| 5 | IN | `sUnTaskFormId` | `varchar(100)` |
| 6 | IN | `pageNum` | `int` |
| 7 | IN | `pageSize` | `int` |
| 8 | OUT | `totalCount` | `int` |
| 9 | IN | `countCloumn` | `varchar(5000)` |
| 10 | OUT | `countMapJson` | `longtext` |
| 11 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 12 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 13 | IN | `sGroupby_group_sql` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 财务管理 → 应收账款 → 订金->收款 — outstanding-prepayment warning list. Lists sales orders (or work orders) whose 预收订金 has not yet been fully received, so cashiers can chase the customer or know that an unfulfilled prepayment is still pending.

**What it does:** Reads `SysAccountPeriod.tARDate` as the AR cutoff and `SysSystemSettings.CbxAdvanceType` to pick the source — `salesorder` reads checked `SalSalesOrderMaster` rows where `dAdvanceMoney - dRealAdvanceMoney > 0` and `bAdvanceComplete = iState`; `workorder` reads `Viw_MftWorkOrder` joined to `cahreceiptmaster` (excluding rows already receipted) with the analogous `bSlaveAdvanceComplete` flag. Stages results in `p_tmp_OrderMoneyWarning`, then enriches customer/salesman/payment labels from `elecustomer`/`sissalesman`/`sispayment`, computes a credit-limit indicator and `tLimitDate = Fun_GetLimitDate(...)`, and finally pages via `Sp_Outstanding_Query`.

**Invocation:** Bound as the data-source of the 订金->收款 form (sId `192116810113315273126649110`, 财务管理 → 应收账款) and the 选择预收订金 picker (sId `192116810113315312149519830`) via `gdsconfigformmaster.sSqlStr`. Output column-metadata is computed by `Fun_getInitColumnByProName` (which special-cases this proc name).
