# `Sp_beforeSave_tice` (procedure)

> 回厂通知单保存前


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 回厂通知单 (Return-to-factory notice — equipment / fixed-asset family) — before-save dispatcher for the return-to-factory notice document. Wraps `sGuid` and delegates to `Sp_saveReturn_tice`, which back-writes `dAuxiliaryFXQty` (returned-back auxiliary qty) onto the upstream `eptmachinefixedorderslave` (machine-fixing order) row by aggregating sibling `eptmachinefixednoticeslave` lines that share the same source. Header comment: `回厂通知单保存前`.

**What it does:** Skips the `sGuid` quoting wrapper that other beforeSave siblings use; calls `Sp_saveReturn_tice(sGuid, sBrId, sSuId, 1, @sCode, @sReturn)` directly. The historical inline `Update eptmachinefixedorderslave` block joining `eptmachinefixednoticeslave` / `eptmachinefixednoticemaster` remains commented-out.

**Invocation:** Not bound to a module as a save-hook in this DB. Called only by `Sp_delete_backwriting` when `sFormGuid = '1691254111217313133811620'` (回厂通知单, hard-coded in the dispatcher). `Sp_Invalid_backwriting` has no matching branch, so cancel-invalidate does not replay this writeback.

Flag: asymmetric dispatcher coverage — delete branch exists but cancel-invalidate does not. Likely an oversight.
