# `Sp_financialClosing_BtnEventReCheckout` (procedure) > @author:杨恒林 @date:20210523 封存 @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_financialClosing_BtnEventReCheckout`'`._ ## Narrative **Business context:** 系统设置 → 系统参数 → 财务结账 — inverse of `Sp_financialClosing_BtnEventCheckout`. Author note: "反结帐时 清除 材料月结,成品月结,成本月结". Unfreezes the chosen `sysaccountperiod` and rolls back the per-bill `dCostPrice`/`dCostMoney` figures that the close pipeline had stamped. **What it does:** Parses the period sId from `sProInParam` (`INSTR(sProInParam, sId) > 0`). Reads `sysaccountperiod` for `sPeriodId, tStartDate, tEndDate, bCalMaterials`; the end-date is bumped by 1 day to make BETWEEN inclusive. Refuses if the next period is already frozen (`NextSettleAccounts`) and refuses if material costing has already finalised (`sMaterialAccounted`). Then `DELETE FROM EleMaterialsStockSumMonth/EleMaterialsStockMonth/eleproductstocksummonth/eleproductstockmonth` for the period, and (if `CotOrderCostAnalysis` exists) deletes its rows too. UPDATE-sweeps `dCostPrice=0, dCostMoney=0` across `pitproductstore`, `pitproductinstoreslave/master`, `sgdsemigoodsmatchbillslave/master`, `saldelivergoodsslave/master`, `salrejectgoodsslave/master`, `salsalescheckingslave/master`, `PitProductRejectSlave/Master`, `pitproductstoreadjustmentslave/master`, `pitproductadjustslave/master`, `pitproductcheckslave/master` for every checked, non-invalid bill in the period. Finally sets `sysaccountperiod.bFrozen=0, tForzenDate=NULL`. **Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` from the 财务结帐 form's 反结帐 toolbar button. xly-src ships both `script/标版/30100101/cost/Sp_financialClosing_BtnEventReCheckout.sql` and an optimised `script/标版/optimize/Sp_financialClosing_BtnEventReCheckout.sql` — verify which is deployed before changing behaviour.