# `Fun_GetCalcMaterialsKs` (function) - **Type:** FUNCTION - **Returns:** `int` - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `dMatLength` | `decimal(18,6)` | | 2 | IN | `dMatWidth` | `decimal(18,6)` | | 3 | IN | `dLength` | `decimal(18,6)` | | 4 | IN | `dWidth` | `decimal(18,6)` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTION `Fun_GetCalcMaterialsKs`'`._ ## Narrative **Business context:** Sheets-per-stock estimator (`Ks` = 开数, the printing trade's "ups count"): given a parent sheet `dMatLength × dMatWidth` and a finished piece `dLength × dWidth`, returns how many finished pieces can be cut from one parent sheet. Used by the quotation and work-order calculation procs to derive material consumption. **What it does:** simple axis-aligned packing — returns `(dMatLength div dLength) * (dMatWidth div dWidth)`. The full mixed-orientation packing logic (vertical + horizontal arrangements) is commented out in the body, leaving only the straight tile. `Fun_GetCalcMaterialsKs1` is the kept-alive richer variant that the commented branches would have called. **Invocation:** invoked by the quotation calc family (`Sp_Quotation_CalcDataBookStd`, `_CalcDataFlex`, `_CalcDataPackStd`, `_CalcDataSetStd`, `_CalcDataStd`, `_CalcDataPackLastStd`, `_CalcDataPackLastStd_zr`, `_CalcDataPackPartsStd`) and the work-order calc family (`Sp_WorkOrder_CalcDataBookStd`, `_CalcDataFlex`, `_CalcDataPackLastStd`, `_CalcDataPackPartsStd_child`, `_CalcDataPackStd`, `_CalcDataSetStd`, `_CalcDataStd`, `_CalcDataStdBeforeAfter`, `_CalcDataStdCenterProcess`, `_CalcDataStdCenterPrsAfter`) — all of which sit on the `报价&估计管理` quotation modules and the `轮转工单`/`合版工单` work-order modules.