# `Sp_beforeSaveReturn_sSod` (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_beforeSaveReturn_sSod`'`._

## Narrative

**Business context:** 销售管理 / 销售订单 — parallel-fork variant of the sales-order save-hook that would backwrite ordered quantities onto upstream quotations and return notices. Comment header: `销售订单保存前反写报价数量`. The active before-save chain for 销售订单 is `Sp_beforeSave_sSod` → `Sp_saveReturn_sSod`.

**What it does:** Parses CSV `sGuid` into `p_t_sId`, joins `salsalesorderslave` ↔ `salsalesordermaster` to gather source-slave IDs, builds `p_MftworkOrderSlave_tmp` of ordered quantities, then in each `iTag` branch updates `quoquotationslave.dorderQty` (quotation already-ordered total) and `returnnoticeslave` quantities so upstream documents reflect the sales-order commit.

**Invocation:** Status: appears orphaned. No caller found in any channel. Candidate for maintainer audit — superseded by `Sp_saveReturn_sSod`.
