# `Sp_saveReturn_tore` (procedure)

> 固定资产入库保存前


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 设备管理 → 固定资产入库 — quantity back-write helper for the 固定资产入库 (fixed-asset in-store, `eptmachinefixedinstoremaster` / Slave) doc. When a fixed-asset receipt is saved or invalidated this proc rolls the received qty back onto the upstream 回厂通知单 slave (`eptmachinefixednoticeslave`) so the notice shows how much has been re-stocked.

**What it does:** Parses `sGuid`, joins `eptmachinefixedinstoreslave` to collect source slave ids, aggregates per source (qty / money buckets) using `iTag` to toggle the current save-set, then `Update eptmachinefixednoticeslave` with the new totals.

**Invocation:** Called from `Sp_beforeSave_tore(iTag=1)` and `Sp_afterSave_tore(iTag=2)`. Those wrappers fire on save of the 固定资产入库 form (standard `Sp_beforeSave_<code>` / `Sp_afterSave_<code>` naming-convention dispatch in `BusinessBaseServiceImpl`) and re-fire on invalidate/delete via `Sp_Invalid_backwriting` / `Sp_delete_backwriting`.
