# `Sp_Calc_scusded` (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_scusded`'`._

## Narrative

**Business context:** 客户索赔 — customer-deduction / customer-claim check / uncheck on `saldelivergoodsdedmaster`. Approves a deduction the customer has applied against a delivery (price chargeback, claim, short-pay) so the receivable totals update; locks in the currency-rate snapshot at audit time.

**What it does:** Validates `sGuid`. Reads master `bInvalid`; refuses if invalid. With `iFlag=1`: sets `saldelivergoodsdedmaster.bCheck=1`, `sStatus=1`, `sCheckPerson=sLoginId`, `tCheckDate=tCheckTime`, then refreshes `dCurrencyRate` by joining `elecustomer C ON M.sCustomerId=C.sId` and `siscurrency S ON C.sCurrency=S.sCurrency`. With `iFlag=0`: clears master flags (currency-rate snapshot stays).

**Invocation:** Status: appears orphaned. No `gdsmodule.sProcName/sSaveProName/sDeleteProName/sSaveProNameBefore` binding, no `gdsconfigformmaster` reference, no other procedure or function calls it, no xly-src hit. The 客户索赔 table exists in the schema but the audit handler is unwired in this DB instance. Candidate for maintainer audit.
