# `Sp_InsertVoucher_mitproductionmaterialsBF` (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_mitproductionmaterialsBF`'`._

## Narrative

**Business context:** 财务 / 自动凭证 — 报废出库 (scrap-out, "BF" = 报废) branch of the production-materials voucher generator. Counterpart to `Sp_InsertVoucher_mitproductionmaterials`: this proc handles only the rows of `mitproductionmaterialsmaster` with `sFormId='192116810113315268872698730'` (the dedicated scrap-out form), generating the `营业外支出-财产损失` style voucher for material write-offs.

**What it does:** Parses date range from `$.changeValue[0].pChooseDate`. Builds `p_sInvoiceNo = CONCAT('报废出库+', group_concat(sBillNo))` from `mitproductionmaterialsmaster WHERE bCheck=1 AND sFormId='<scrap-out>' AND iVouchermark=0 AND tCreateDate IN (start,end)`. If any rows exist, allocates a voucher number via `SP_Sis_GetMaxNo`, inserts `udfvouchermaster` (`sVoucherType='记'`) and `udfvoucherslave` debit/credit lines summing the scrapped-cost amounts, then flips `iVouchermark=1`.

**Invocation:** Status: appears orphaned. No form-master/`gdsmodule`/workflow/other-routine reference and no xly-src match besides install script `script/标版/30100101/Sp_InsertVoucher_mitproductionmaterialsBF.sql`. Signature matches the `GenericProcedureCallServiceImpl.doGenericProcedureCall()` voucher-button shape; likely superseded by `Sp_InsertVoucher_Universal*` template-driven generator. Candidate for maintainer audit.
