# `Sp_beforeSave_sWXKK` (procedure)

> 外协扣款前反写数量


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 外协商扣款 (Outsourcing-vendor deduction) — before-save dispatcher for the deduction document. Wraps `sGuid` and delegates to `Sp_saveReturn_sWXKK`, which back-writes `dBackDeductionSupplyMoney` (deduction amount) onto the upstream `mftqualityaccidentmaster` (quality-accident master) row, joining through `opsoutsideinstorededslave` / `opsoutsideinstorededmaster`. Header comment: `外协扣款前反写数量`.

**What it does:** Normalises `sGuid` to a quoted-CSV form, then `CALL Sp_saveReturn_sWXKK(sGuid, sBrId, sSuId, 1, @sCode, @sReturn)`. The historical inline `Update mftqualityaccidentmaster` block remains commented-out in the body.

**Invocation:** Not bound to a module as a save-hook in this DB. Called only by `Sp_delete_backwriting` when `sFormGuid = '1691254111217013458193680'` (外协商扣款) — note the delete path runs but `Sp_Invalid_backwriting` has no matching branch, so cancel-invalidate of an 外协商扣款 record will not replay this writeback.

Flag: asymmetric dispatcher coverage — delete replays the backwrite but cancel-invalidate does not. Likely an oversight.
