# `Sp_financial_OrderGrossProfit` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sType` | `int` |
| 2 | IN | `tStartDate` | `datetime` |
| 3 | IN | `tEndDate` | `datetime` |
| 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 | OUT | `sCode` | `longtext` |
| 16 | OUT | `sReturn` | `longtext` |

## Body

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

## Narrative

**Business context:** Order-axis gross-profit report — for a date window aggregates per-订单 总金额 vs 直接材料 / 生产补料 / 发外加工 / 报工分摊 costs, producing the gross-profit table for finance review. Root of the `Sp_financial_OrderGrossProfit_*` variant family (`_new`, `_new1`, `_Classify`, `_Customer`, `_Customernew`, `_sSrCustomer`, `_bf2`).

**What it does:** Resolves the active 会计期 via `sysaccountperiod`, computes shared 分摊 totals (`p_dShareMakeMoney`, `p_dReportMoneySum`), then assembles temp tables and dynamic SQL honoring caller `bFilter`/`sFilterOrderBy`/`sGroupby_select_sql`. Branches on `sType`. Returns paginated rows plus `totalCount`, `countMapJson`, and finally `sCode`/`sReturn` status fields.

**Invocation:** Status: appears orphaned. No `gdsmodule.sProcName`, no `gdsconfigformmaster` data-source binding, no other-routine caller, and no xly-src reference beyond the install scripts at `script/标版/30100101/Sp_financial_OrderGrossProfit.sql` and `script/标版/optimize/Sp_financial_OrderGrossProfit.sql` — candidate for maintainer audit (canonical report-data-source signature but the form binding is gone in the surveyed DB; either the customer site rebinds it locally or the feature was retired).
