# `Sp_Receivables_AR_new` (procedure)

> 应收账款-优化搜索条件


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `iType` | `int` |
| 2 | IN | `sSalesManNameParam` | `varchar(100)` |
| 3 | IN | `sCustomerClassifyNameParam` | `varchar(100)` |
| 4 | IN | `sStatistics` | `varchar(100)` |
| 5 | IN | `tStartDate` | `datetime` |
| 6 | IN | `tEndDate` | `datetime` |
| 7 | IN | `sZero` | `varchar(100)` |
| 8 | IN | `sLoginId` | `varchar(100)` |
| 9 | INOUT | `dNoReceiptMoney` | `decimal(18,6)` |
| 10 | INOUT | `dDueReceiptMoney` | `decimal(18,6)` |
| 11 | IN | `sBrId` | `varchar(100)` |
| 12 | IN | `sSuId` | `varchar(100)` |
| 13 | IN | `bFilter` | `longtext` |
| 14 | IN | `pageNum` | `int` |
| 15 | IN | `pageSize` | `int` |
| 16 | OUT | `totalCount` | `int` |
| 17 | IN | `countCloumn` | `varchar(5000)` |
| 18 | OUT | `countMapJson` | `longtext` |
| 19 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 20 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 21 | IN | `sGroupby_group_sql` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 财务管理 → 应收账款 — 应收账款-优化搜索条件 customer/branch variant of `Sp_Receivables_AR`. Adds first-class filter params `sSalesManNameParam` / `sCustomerClassifyNameParam` so the legacy free-form `bFilter` doesn't have to encode 销售员 and 客户分类 splits. Body otherwise mirrors the base AR roll-up: opening balance + period sales + receipts + invoices + payments/adjustments per customer.

**What it does:** Same `TmpAll` UNION pipeline as `Sp_Receivables_AR`, but pre-builds `p_sWhere` from the two extra params before splicing into the dynamic SQL. Hands the final `SELECT` to `Sp_Outstanding_Query` for paging/`countMapJson`. Returns `dNoReceiptMoney`/`dDueReceiptMoney` as totals.

**Invocation:** No bindings found. Not referenced by any `gdsconfigformmaster.sSqlStr`, no `gdsmodule` hook, no other routine calls it, no xly-src match. Status: appears orphaned — likely a staging snapshot of the optimised AR report that never got promoted into the live form binding. Candidate for maintainer audit.
