# `Sp_CalcCost_BtnEventReCalcCost` (procedure)

> @author:杨恒林
							@date:20210920 封存
							@describe: 本月未结帐成本核算, “成本核算”界面 调用


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProInParam` | `varchar(10000)` |
| 2 | IN | `sMakePerson` | `varchar(100)` |
| 3 | IN | `sBrId` | `varchar(100)` |
| 4 | IN | `sSuId` | `varchar(100)` |
| 5 | OUT | `sReturn` | `varchar(1000)` |
| 6 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 业财一体化 / 成本核算 — mid-month re-cost run for an un-closed period, exposed from the 成本核算 (cost accounting) screen for analysts who need refreshed costs before a period is formally closed. Per the COMMENT this body is marked 封存 (sealed/legacy, by 杨恒林 on 2021-09-20) — production now favours `Sp_CalcCost_BtnEventReCalcCost_new`.

**What it does:** Same JSON-param shape and `sysaccountperiod` lookups as `Sp_CalcCost_BtnEventCalcCost`. Builds dynamic SQL into temporary tables, recomputes per-cost-centre and per-expense-frame allocations against `mftworkordermaster`/`MftWorkOrderSlave`/`CotOrderCostAnalysis`, and updates the running totals — without flipping the period's `bCost` to 1 (i.e., does not finalise the close). Aimed at the case where the period is still open and the user wants to see what costs would look like with currently-checked orders.

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` — 成本核算 form's 重新核算 (本月未结帐) toolbar button. Replaced by `Sp_CalcCost_BtnEventReCalcCost_new`; verify which is wired before relying on this body.
