# `Sp_beforeSave_sQtt` (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` | `varchar(4000)` |

## Body

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

## Narrative

**Business context:** 估价管理流程 / `01/04【新增】新报价单` — before-save dispatcher for the quotation document. Wraps `sGuid` and delegates to `Sp_saveReturn_sQtt` to backwrite the quotation reference onto the upstream sales-chance product rows before the master save commits.

**What it does:** Normalises `sGuid` to a quoted-CSV form, then `CALL Sp_saveReturn_sQtt(sGuid, sBrId, sSuId, 1, @sCode, @sReturn)`. The body retains ~1.5K chars of commented-out legacy code that directly cleared `salsaleschanceproduct.sQuotationId` — superseded by the saveReturn sibling.

**Invocation:** Hooked as `gdsmodule.sSaveProNameBefore` on `01/04【新增】新报价单` (sId `101251240115016076506222050`). Also called by dispatcher procs `Sp_Invalid_backwriting` and `Sp_delete_backwriting`. The dispatcher includes commented-out alternate quotation-form sIds (估价单-书刊, 估价单-标签, 估价单-软包) that would also route here if uncommented.
