Sp_InsertVoucher_Universal (procedure)
- Type: PROCEDURE
- Deterministic: NO
- SQL data access: CONTAINS SQL
Parameters
| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | sProInParam |
varchar(10000) |
| 2 | IN | sMakePerson |
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 PROCEDURESpInsertVoucher_Universal'._
Narrative
Business context: 财务 / 凭证模板 / 自动凭证 (通用) — template-driven generic voucher generator. Replaces the per-source Sp_InsertVoucher_<Module> family with one parametric proc that takes a sVoucherId (pointing at udfvouchertemplatemaster) and assembles a voucher from whichever source table the template names. The companion Sp_InsertVoucher_Universals_All is the bulk version (no sVoucherId — picks the default template per sFormId).
What it does: Extracts sTemplateGuid from $.changeValue.sVoucherId (returns '未选择凭证模板,请选择后操作' with sCode=-1 if empty). Looks up template metadata (sVoucherFormId, sSumType, sVoucherOrder) from udfvouchertemplatemaster and the source-table name + label from gdsconfigformmaster. Derives p_sVoucherTableName by stripping master/slave suffix and prepending viw_ so it always reads the view. Reads already-posted sSrcSlaveId from viw_udfvoucher to skip already-posted source rows; then for the remaining source rows uses sSumType (sCustomerId / sSupplyId / sBillNo / sFormId) as the grouping key and sVoucherOrder to drive the debit/credit ordering. Allocates voucher numbers via SP_Sis_GetMaxNo and inserts udfvouchermaster + udfvoucherslave. Also tracks per-column flags (b_sWareHouseId, b_sMaterialsId, b_sCustomerId, b_sSupplyId, b_sProductId) so the template can opt-in to auxiliary-accounting dimensions.
Invocation: Status: appears orphaned. Signature matches the GenericProcedureCallServiceImpl.doGenericProcedureCall() voucher-button shape; no form-master/gdsmodule/workflow reference and no xly-src match besides install scripts (script/标版/30100101/Sp_InsertVoucher_Universals.sql and script/标版/upgrade/20211115生成凭证/Sp_InsertVoucher_Universal_month.sql). Likely the "single-bill" entry point for the template engine, invoked from a 生成凭证 button on the 凭证模板 module that didn't survive into the current form-master definitions. Candidate for maintainer audit.