# `Sp_chart_TodayProfit` (procedure)

> 本月毛利


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sLoginId` | `varchar(100)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | IN | `bFilter` | `varchar(5000)` |
| 5 | OUT | `sCode` | `int` |
| 6 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 财务图表分析 → 图表分析 → 决策支持 — the dashboard card 本月毛利 breaks down this month's gross profit (sales – standard cost) by product classification so finance can see which categories drove margin.

**What it does:** Joins `mftworkorderslave` to a `mftworkordermaster` aggregate filtered by `bCheck = 1` and `date_format(tCreateDate,'%Y-%m')` = current month, computes per-row gross profit as `dProductMoney − dCostMoney × (dProductMoney / dTotalMoney)`, then joins `eleproduct`→`sisproductclassify`, groups by classification, scales by 0.001 (千元), and emits a JSON pie payload `{data, hasLegend, subTitle:'单位:千元'}`.

**Invocation:** Bound via `gdsconfigcharmaster.sProcedureName` on chart card `15934048800005818183366101872000` under 财务图表分析.
