# `Sp_Calc_Scrap` (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` | `longtext` |
| 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_Scrap`'`._

## Narrative

**Business context:** 固定资产报废申请单 — fixed-asset (equipment) scrapping-application check / uncheck on `eptmachinefixedscrap`. Approving the application freezes the scrap decision; the actual asset write-off happens in downstream finance procs that read `bCheck=1` rows.

**What it does:** Validates `sGuid`. Refuses if `eptmachinefixedscrap.bInvalid=b'1'`. With `iFlag=1`: refuses if already checked; sets `bCheck=1`, `sStatus=1`, `sCheckPersON=sLoginId` (sic — column name preserves the typo in the schema), `tCheckDate=NOW()`. With `iFlag=0`: refuses if already unchecked, then clears the same fields. Lightweight — no slave-row or cross-table writes from the audit itself.

**Invocation:** Status: appears orphaned. No `gdsmodule` hook, no form-master, no other procedure caller, no xly-src reference. The `eptmachinefixedscrap` table exists; the audit handler is unwired in this DB instance. Candidate for maintainer audit.
