# `Sp_Quotation_CalcDataBookStd` (procedure)


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

## Parameters

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

## Body

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

## Narrative

**Business context:** 销售管理 → 报价&估计管理 → 书刊产品报价 / 书刊产品报价单据 — top-level quote-cost calculator dedicated to the 书刊 (book/journal) product family. Standard entry-point for the book-style quote (signature wider/longer formats, parts split between cover / inner / insert) that the user invokes from the quote edit screen.

**What it does:** Walks the master quote `quoquotationmaster_tmp` and its slaves `quoquotationslave_tmp`/`QuoQuotationcontrol_tmp`/`QuoQuotationmaterials_tmp`/`QuoQuotationprocess_tmp`/`QuoQuotationControlCombine_tmp`. Per slave it derives `dSumProductQty`, `dSumGiveQty`, sample/standard-page flags, then opens cursors over Control, Materials, PrintProcess, Slave, and update-Slave temps. For each control it computes process in/out quantities, accumulates rate adjustments, applies the customer's book-quote paper formula (`sQuotationPaperFormulaId`) and capacity formula (`sCapacityFormulaId`), and writes back into the same `_tmp` set. `Sp_System_ReplaceField` localises the merged messages; `Sp_Sis_GetConst` fetches localized constants. Reads `gdsmodule`, `SysSystemSettings`, `sysformsetting` for branch/feature flags.

**Invocation:** Bound to two production modules via `gdsmodule.sCalcProName`:
- `书刊产品报价` (sId `101251240115016197744846010`) under 报价&估计管理
- `书刊产品报价单据` (sId `101251240115016197744514350`) under 销售单据

Also enumerated in `CaclProNameEnum.SP_QUOTATION_CALCDATABOOKSTD` (java `xlyBusinessService/contant/enumeration/CaclProNameEnum.java`); the proc name is passed to `ManyQuoServiceImpl.addQuotationsheetManyThread(params, userInfo, sProName)` for multi-quantity calculation paths, and `QuoquotationServiceImpl.isQuoquotationMany()` reads `gdsmodule.sCalcProName` to decide the calc strategy. xly-src ships `script/标版/30100101/Sp_Quotation_CalcDataBookStd.sql` (install).
