# `Sp_beforeSaveReturn_sWXKK` (procedure)

> 外协扣款前反写数量


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 委外管理 / 外协扣款 — parallel-fork variant of the outsource-deduction save-hook. Comment header: `外协扣款前反写数量`. The active before-save chain for 外协扣款 is `Sp_beforeSave_sWXKK` → `Sp_saveReturn_sWXKK` (the suffix `WXKK` = 外协扣款 / outsource deduction).

**What it does:** Parses CSV `sGuid` into `p_t_sId`, joins `opsoutsideinstorededslave` ↔ -`master` and the related `MftWorkOrderSlave` source, computes `p_MftworkOrderSlave_tmp`, then in each `iTag` branch updates `mftqualityaccidentmaster` (linking the deduction to a quality-incident), `salsalesorderslave`, and `developorderslave` so deduction status flows back to the originating order.

**Invocation:** Status: appears orphaned. No caller found in any channel. Candidate for maintainer audit.
