# `Sp_InsertVoucher_Universals_All` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProInParam` | `longtext` |
| 2 | IN | `sMakePerson` | `varchar(100)` |
| 3 | IN | `sFormId` | `varchar(100)` |
| 4 | IN | `sBrId` | `varchar(100)` |
| 5 | IN | `sSuId` | `varchar(100)` |
| 6 | OUT | `sReturn` | `varchar(1000)` |
| 7 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 财务 / 凭证模板 / 自动凭证 (通用-批量) — bulk-variant of `Sp_InsertVoucher_Universal`. Drives off the default template (`udfvouchertemplatemaster.bDefault=1`) for a given source `sFormId` instead of a user-picked `sVoucherId`, and supports both 正向 (`b_bMinus=false`) and 红字 (`b_bMinus=true`) voucher generation in one call. Used for the "process every checked row" workflow on a 凭证模板 grid.

**What it does:** Looks up the default template for `sFormId` (`sSumType`, `sVoucherOrder`, `bMinus`, `sId`) from `udfvouchertemplatemaster`. Resolves the source table name + label from `gdsconfigformmaster` for the form's master child. Calls `Sp_SplicingTableSql(sFormId, sTemplateGuid, …, p_sLoginId, …)` to populate the per-session work-table `mftVoucherUniversalTmp` with all rows ready to post. Cursors that work-table `GROUP BY sSumType`; per group allocates voucher number(s) via `SP_Sis_GetMaxNo`, inserts `udfvouchermaster` (with `p_sVoucherMinusNo` for the offsetting 红字 entry when `bMinus=1`) + `udfvoucherslave` debit/credit rows aggregated from the work-table.

**Invocation:** Status: appears orphaned. Signature (note the extra `sFormId` param) matches the `GenericProcedureCallServiceImpl.doGenericProcedureCall()` voucher-button shape; no form-master/`gdsmodule`/workflow reference and no xly-src match besides install script `script/标版/30100101/Sp_InsertVoucher_Universals_All.sql`. Companion procs: `Sp_InsertVoucher_Universal` (single-template), `Sp_InsertVoucher_Universals` (legacy), `Sp_InsertVoucher_Universals_Pro` (extended), `Sp_InsertVoucher_Universals_ByMounth` (monthly). Candidate for maintainer audit — the proper end-to-end caller chain for the template engine should be verified before relying on this.
