# `Sp_financialClosing_BtnEventOutSideEstimation` (procedure) - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sProInParam` | `longtext` | | 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_BtnEventOutSideEstimation`'`._ ## Narrative **Business context:** 系统设置 → 系统参数 → 财务结账 — 发外暂估 (outside-processing estimate) generator for month-end close. Same shape as `Sp_financialClosing_BtnEventEstimation` but operates on the 发外加工 cost ledger `accordercostanalysis` (with `iType=7` for this-period estimate, `iType=5` prior estimate, `iType=3` invoice) and the parallel finished-goods inventory ledger `accoutsideproductstore`. **What it does:** Parses `sCostPeriod` from `sProInParam`. Reads `sysaccountperiod` for window dates and `bCost`; refuses (`sBtnDepartFinished`) if the period is already cost-finalised. Refuses if prior-period 发外暂估 (`iType=5`) or this-period 发外发票 (`iType=3`) rows are still `bConfirm=0` (`sClosingConfirmLastFwData` / `sSystemProductionFwfpConfirm`). Deletes the period's existing `iType=7` `accordercostanalysis` rows and `accoutsideproductstore` rows. Rebuilds via temp tables `Sp_instore` / `Sp_instoreSum` populated from outsource-process checking and invoice views, resolves estimate prices, and re-inserts the summed rows into `accordercostanalysis` (`iType=7`) plus the matching `accoutsideproductstore` records. **Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` from the 财务结帐 form's 发外暂估 toolbar button. Sibling variants `Sp_financialClosing_BtnEventOutSideEstimation_new` and `_test` exist as in-progress / test rewrites — verify which is wired in production before changing behaviour. xly-src ships `script/标版/30100101/cost/Sp_financialClosing_BtnEventOutSideEstimation.sql`.