# `Sp_InsertVoucher_Universals_ByMounth` (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_ByMounth`'`._

## Narrative

**Business context:** 财务管理 → 财务凭证 — month-end voucher batch generator for the 财务凭证 (`udfvouchermaster`/`udfvoucherslave`) feed. Variant of `Sp_InsertVoucher_Universals` / `Sp_InsertVoucher_Universals_Pro` that aggregates an entire month's source bills (sales/purchase deliveries, cash receipt/payment, outsourcing in-store, production materials, etc.) into one voucher per template rather than per source bill.

**What it does:** Reads the default `udfvouchertemplatemaster` row (`bDefault=1`) for `sVoucherFormId=sFormId` to obtain `sSumType`, `sVoucherOrder`, `bMinus`. Builds temp table `p_voucherUniversal` and copies the month's qualifying source rows from `accopsoutsideinstoremaster`, `accpurchaseinstoremaster`, `cahpaymentmaster`, `cahreceiptmaster`, `opsoutsideinstoremaster`, `purpurchaseinstoremaster`, `saldelivergoodsslave`, `mitproductionmaterialsslave` according to the template's mapping rules. `CALL SP_Sis_GetMaxNo` to issue a `sVoucherNo`, then `Insert Into udfVoucherMaster`/`udfVoucherSlave` and back-write `sVoucherId` onto the source rows so they aren't re-billed next run.

**Invocation:** Dispatched dynamically via `GenericProcedureCallServiceImpl.doGenericProcedureCall()` — the toolbar button on the 财务凭证模板 / 财务凭证 grid that produces the month's vouchers names this proc as the action. Status: appears orphaned in xly-src — no install script under `script/标版/30100101/`, no Java reference, and the per-bill `Sp_InsertVoucher_Universals_Pro` is the path actually shipped today. Verify before relying on the by-month variant.
