# `Sp_OpsOutsideprocess_CheckUpdate_ZF` (procedure)

> 工序发外单据其它费用保存


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sGuid` | `varchar(100)` |
| 2 | IN | `sFormGuid` | `varchar(100)` |
| 3 | IN | `sLoginId` | `varchar(100)` |
| 4 | IN | `sBrId` | `varchar(100)` |
| 5 | IN | `sSuId` | `varchar(100)` |
| 6 | OUT | `sCode` | `int` |
| 7 | OUT | `sReturn` | `varchar(4000)` |

## Body

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

## Narrative

**Business context:** 外协管理 / 工序发外 — "工序发外单据其它费用保存" variant. Recomputes 工序发外 (`opsoutsideprocessslave`) prices after the user enters 其它费用 (`dOtherMoney`), folding the surcharge into 单价/金额 and refreshing the tax-decomposition columns. The `_ZF` suffix marks the 转发/拆分 variant of the cost-update routine.

**What it does:** Within the master `sGuid` scope: backs up `dMaterialsPrice → dOldMaterialsPrice`, recomputes `dOldMaterialsMoney = ROUND(dOldMaterialsPrice*dMaterialsQty,2)`; if any slave has `dOtherMoney<>0`, distributes it to `dMaterialsPrice = ROUND((dOldMaterialsMoney+dOtherMoney)/dMaterialsQty,3)` and refreshes tax-decomposed columns (`dMaterialsNoTaxPrice`, `dMaterialsNoTaxMoney`, `dMaterialsTaxMoney`) joined to `sistax`. Refuses with `sCode=-1` and `'该订单存在相同产品，单价不一致数据，请检查修改后重新保存！'` when the same `sProductId` ends up with multiple `dMaterialsPrice` values. Resets the `dOld*` backup columns to zero when the master hasn't been audited yet (`iCheckCount=0`).

**Invocation:** Pre-save validator. Called from `Sp_Check_sOpc` (the gdsmodule `sSaveProName` hook for the 工序发外 form) — i.e. dispatched by `BusinessBaseServiceImpl` during the save chain (`Sp_Check_s*` family). No xly-src refs.
