# `Sp_Receivables_ARageDetail` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `iSelect` | `int` |
| 2 | IN | `iType` | `int` |
| 3 | IN | `sStatistics` | `varchar(100)` |
| 4 | IN | `tStartDate` | `datetime` |
| 5 | IN | `tEndDate` | `datetime` |
| 6 | IN | `sBrId` | `varchar(100)` |
| 7 | IN | `sSuId` | `varchar(100)` |
| 8 | IN | `bFilter` | `varchar(5000)` |
| 9 | IN | `pageNum` | `int` |
| 10 | IN | `pageSize` | `int` |
| 11 | OUT | `totalCount` | `int` |
| 12 | IN | `countCloumn` | `varchar(5000)` |
| 13 | OUT | `countMapJson` | `longtext` |
| 14 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 15 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 16 | 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_ARageDetail`'`._

## Narrative

**Business context:** 财务管理 → 应收账款 — 应收账款账龄明细 (AR aging-bucket detail). Companion to `Sp_Receivables_Aging`: where 账龄 (aging) buckets balances into 30/60/90/120/150+ day intervals at the customer/order level, this proc drills into each bucket to list the underlying documents (orders, invoices, deliveries) that contribute to it. The leading `iSelect` parameter picks which dimension (`0`=客户, others=order/invoice level).

**What it does:** Like the base AR procs, builds a `TmpAll` UNION over `salsalesorderslave`/`viw_salsalescheckingmaster`/`SalSalesCheckingSlave`/`CahReceiptMaster`/`SalSalesInvoiceMaster`/`CahFinancialAdjust`/`CahPaymentMaster`, with each row tagged by aging bucket (`p_dDueSalesMoney60/90/120/150` etc., computed from `tCheckDate` vs `tEndDate`). Hands the dynamic SQL to `Sp_Outstanding_Query` for paging/`countMapJson`/`bFilter` splicing.

**Invocation:** No bindings found. Not referenced by `gdsconfigformmaster.sSqlStr`, no `gdsmodule` hook, no other routine calls it, no xly-src match. Status: appears orphaned — likely a staging/replaced version of an aging-detail report whose form binding has been redirected elsewhere. Candidate for maintainer audit.
