# `Sp_BtnEventMaterialsPost_New` (procedure) - **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_BtnEventMaterialsPost_New`'`._ ## Narrative **Business context:** 材料存货核算 / 材料盘点 — toolbar handler that re-posts an inventory-gain (盘盈) price/value onto an `accmaterialsstore` row whose source form is the 材料盘点单据 (`sFormId=192116810113315228128521360`). Used to back-fill an inventory-take adjustment with a unit price entered after the original count, recomputing total money. **What it does:** Resolves the latest frozen `sysaccountperiod` (`bFrozen=1`, ORDER BY `tStartDate` DESC LIMIT 1) into `p_sPeriodId` (read but not used in the UPDATE — only the form gate matters). Parses `$.params[*].value[*]` with `sId, dMaterialsPrice, sFormId`. For each row where `sFormId='192116810113315228128521360'` AND `dMaterialsPrice>0`, sets `accmaterialsstore.dMaterialsPrice=p_dMaterialsPrice, dMaterialsMoney=ROUND(p_dMaterialsPrice*dMaterialsQty,2)` for matching `(sId, sBrId, sSuId)`. Other form sources are silently skipped. **Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` (POST `/procedureCall/doGenericProcedureCall`) — 材料盘点 grid's 盘盈回写 toolbar button (or similar 价格补录 action) names this proc as its action.