# `Sp_financial_OrderGrossProfit_new` (procedure)


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

## Parameters

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

## Narrative

**Business context:** Newer iteration of `Sp_financial_OrderGrossProfit` adding the same `iType` discriminator used by the `_Classify`/`_Customer` variants — paginated order-level gross-profit report for a date window.

**What it does:** Builds `p_TmpWorkOrder` and `p_TmpTb` temp tables summing 订单总金额, 直接材料, 生产补料, 发外加工 per order from the `mftworkorder*` family; branches on `iType`; assembles dynamic SQL honoring `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 (one of several un-bound iterations alongside `_new1`, `_Customer`, `_Customernew`, `_sSrCustomer`, `_Classify`, `_bf2`).
