# `Sp_Calc_sInded` (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_sInded`'`._

## Narrative

**Business context:** 销售管理 → 销售送货流程 — internal-deduction check / uncheck on `saldelivergoodsdedInmaster` (COMMENT `'内部扣款单'`). Approves a 内部扣款单 (internal deduction note — typically a 质量事故 / 客户扣款 back-charged to the responsible internal team) and flips the linked 质量事故 slave so the deduction shows as settled.

**What it does:** Validates `sGuid`. With `iFlag=1`: guards on `bCheck=1`, `Update saldelivergoodsdedInmaster` to set the audit flags, then `Update mftqualityaccidentSlave` to flip the matching 质量事故 slave's settlement flag (linking the deduction back to the originating quality-incident). Uncheck reverses both. References `elecustomer` and `siscurrency` for label lookups during validation.

**Invocation:** Status: appears orphaned. No live `gdsmodule.sProcName` binding, no `sSaveProName` hook, no other-routine CALLs, no xly-src reference — candidate for maintainer audit. The 内部扣款单 form may be customer-specific or wired only via override scripts; verify whether the form is enabled per tenant.
