# `Sp_BtnEventDepartSure_New` (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_BtnEventDepartSure_New`'`._

## Narrative

**Business context:** 成本核算 / 部门核算 — toolbar handler that toggles 部门核算确认 (`accdepart.bConfirm`) for the selected costing-period rows. Period gate: rejects the operation if the chosen `sysaccountperiod.bCost=1` (period already cost-closed), preventing changes to a sealed period.

**What it does:** Parses `$.params[*].value[*]` with `sId, sCostPeriod` from `sProInParam`. For each row, reads `sysaccountperiod.bCost` for the period — if `1`, returns `sCode=-1, sBtnDepartFinished` ("该会计期间已核算完成,不能进行此操作"). Otherwise flips `accdepart.bConfirm` and stamps `sConfirmMonth=p_sPeriodId` for matching `(sId, sBrId, sSuId)`. Final `sReturn='Operation successful'`.

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` (POST `/procedureCall/doGenericProcedureCall`) — 部门核算 grid's 确认 toolbar button names this proc as its action. Siblings in the cost-confirm family: `Sp_BtnEventworkcenterSure_New`, `Sp_BtnEventMaterialsSure_New`, `Sp_BtnEventProductInStoreSure_New`, `Sp_BtnEventProductionmaterialSure_New`, `Sp_BtnEventProductSure_New`.
