# `Sp_InsertVoucher_Cahpayment` (procedure) - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sProInParam` | `varchar(10000)` | | 2 | IN | `sMakePerson_s` | `varchar(100)` | | 3 | IN | `sBrId` | `varchar(100)` | | 4 | IN | `sSuId` | `varchar(100)` | | 5 | OUT | `sReturn` | `varchar(1000)` | | 6 | OUT | `sCode` | `int` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_InsertVoucher_Cahpayment`'`._ ## Narrative **Business context:** 财务 / 自动凭证 — generates accounting vouchers (`udfvouchermaster` + `udfvoucherslave`) for bank 付款单 (cash-payment) bills `cahpaymentmaster` of `sSettlementId='bank'` over a chosen date range. Per-supplier × bank-account × currency-rate aggregation; flips each consumed row's `iVouchermark=1` so it won't re-post. **What it does:** Reads the date range from `$.changeValue[0].pChooseDate` of `sProInParam`. Cursors over `cahpaymentmaster GROUP BY sSupplyId, sBankId, dCurrencyRate WHERE bCheck=1 AND tCreateDate IN [start,end) AND sSettlementId='bank' AND iVouchermark=0`. For the first row per group, allocates a new voucher number via `SP_Sis_GetMaxNo('udfvouchermaster',…,'1012512401150…')` and inserts the voucher master with `sVoucherType='记'`. Then inserts voucher-slave debit/credit entries summing the payment-detail money by accounting subject and stamps each consumed `cahpaymentmaster` with `iVouchermark=1`. **Invocation:** Status: appears orphaned. Signature is the standard `GenericProcedureCallServiceImpl.doGenericProcedureCall()` voucher-button shape, but no form-master/`gdsmodule`/workflow/other-routine reference and no xly-src match besides the install script `script/标版/30100101/Sp_InsertVoucher_Cahpayment.sql`. Sibling of `Sp_InsertVoucher_Cahreceipt` (收款单 counterpart); superseded by the template-driven `Sp_InsertVoucher_Universal`/`Sp_InsertVoucher_Universals_All`. Candidate for maintainer audit — may be dead code retained for the legacy workbench.