# `Sp_Calc_sopsded` (procedure)

> 外协商扣款


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

## Parameters

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

## Body

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

## Narrative

**Business context:** Audit handler for 外协商扣款 (outsource-vendor chargeback) on `opsoutsideinstorededmaster` — the "ded" (deduction) variant of 发外入库. After QC rejects part of an outsourced delivery, this doc records a chargeback against the vendor; on approval the master/slave rows are frozen and the approval workflow is engaged.

**What it does:** Validates `sGuid`/`bInvalid`, requires `sFlowDeptId` to be set before audit (returns the localised `sChooseReviewDepart` error otherwise), then `Update`s `opsoutsideinstorededmaster` + `opsoutsideinstorededslave` to set `bCheck=1, sStatus=1, sCheckPerson, tCheckDate=NOW()`. The reverse branch (`iFlag=0`) clears the same flags.

**Invocation:** Status: appears orphaned. No `gdsmodule.sProcName/sSaveProName`, `gdsconfigformmaster` form-master, sibling-routine, or xly-src reference targets `Sp_Calc_sopsded` (note lower-case `s` in `sopsded` — distinct identifier). Candidate for maintainer audit; confirm whether the 外协商扣款 module is exposed in this tenant's menu before adopting.
