# `Sp_share_sPay` (procedure) > 付款单(汇总)分摊 - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sDropTableSql` | `longtext` | | 2 | IN | `sCreateTableSql` | `longtext` | | 3 | IN | `insertSql` | `longtext` | | 4 | IN | `selectSql` | `longtext` | | 5 | IN | `sFormGuid` | `varchar(100)` | | 6 | IN | `sLoginId` | `varchar(100)` | | 7 | IN | `sBrId` | `varchar(100)` | | 8 | IN | `sSuId` | `varchar(100)` | | 9 | OUT | `sCode` | `int` | | 10 | OUT | `sReturn` | `longtext` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_share_sPay`'`._ ## Narrative **Business context:** 财务管理 → 付款单(汇总) — 付款单(汇总)分摊 (`COMMENT '付款单(汇总)分摊'`). Allocates a summary payment header (`cahpaymentmaster` / `cahpaymentslave` / `cahpaymentsumslave`) across its detail rows so each slave and sum-slave line carries its share of the paid money / foreign money / rounding. Used on the 付款汇总 form variant where multiple sub-bills are aggregated under one header. Per-payment-row variant: `Sp_share_sPay_One`. **What it does:** Executes the four dynamic-SQL strings handed in by the Java side (`sDropTableSql`, `sCreateTableSql`, `insertSql`, `selectSql`) to build `cahpaymentmaster_calc_tmp`, `cahpaymentslave_calc_tmp` and `cahpaymentsumslave_calc_tmp` temp tables seeded from the form's current data. Then it UPDATEs the slave / sum-slave temps with the per-row share computations (currency rate, rounding, totals from `INFORMATION_SCHEMA` column metadata) and SELECTs them back for the front-end to refresh. **Invocation:** Dispatched dynamically by `CalcProcedureServiceImpl.calc()` (POST `/calcprocedure/calc`) — the 汇总分摊 button on the 付款单(汇总) form has `sProName='Sp_share_sPay'` configured; Java builds the four temp-table SQLs from the form's current row data and forwards the call. No DB caller; no xly-src install script for this proc — DB-only.