# `Sp_financial_OrderGrossProfit_Customernew` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `tStartDate` | `datetime` |
| 2 | IN | `tEndDate` | `datetime` |
| 3 | IN | `sSrcCustomerId` | `varchar(100)` |
| 4 | IN | `iType` | `int` |
| 5 | IN | `sBrId` | `varchar(100)` |
| 6 | IN | `sSuId` | `varchar(100)` |
| 7 | IN | `sLoginId` | `varchar(100)` |
| 8 | IN | `bFilter` | `longtext` |
| 9 | IN | `pageNum` | `int` |
| 10 | IN | `pageSize` | `int` |
| 11 | OUT | `totalCount` | `int` |
| 12 | IN | `countCloumn` | `longtext` |
| 13 | OUT | `countMapJson` | `longtext` |
| 14 | IN | `sFilterOrderBy` | `longtext` |
| 15 | IN | `sGroupby_select_sql` | `longtext` |
| 16 | IN | `sGroupby_group_sql` | `longtext` |

## Body

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

## Narrative

**Business context:** Newer iteration of `Sp_financial_OrderGrossProfit_Customer` adding an `sSrcCustomerId` filter — intended to drive a 按客户 gross-profit report scoped to a specific 源客户 (originating customer) within a date window.

**What it does:** Builds `p_TmpWorkOrder` / `p_TmpTb` temp tables aggregating per-order costs (订单总金额, 直接材料, 生产补料, 发外加工), filters by `sSrcCustomerId` when supplied, branches on `iType`, then assembles dynamic SQL honoring caller-supplied `bFilter`, `sFilterOrderBy`, `sGroupby_*` clauses. Returns paginated rows plus `totalCount` and `countMapJson`.

**Invocation:** Status: appears orphaned. No `gdsmodule.sProcName`, no `gdsconfigformmaster` binding, no other-routine caller, and no xly-src reference — candidate for maintainer audit (sister proc `Sp_financial_OrderGrossProfit_sSrCustomer` covers the same `sSrcCustomerId` idea; both appear unwired).
