# `Sp_Bill_Force_Complete` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sIds` | `longtext` |
| 2 | IN | `sTableParam` | `longtext` |
| 3 | IN | `sSize` | `int` |
| 4 | IN | `sLoginId` | `varchar(255)` |
| 5 | IN | `sReason` | `varchar(4000)` |
| 6 | IN | `sClientType` | `longtext` |
| 7 | IN | `sComputeName` | `longtext` |
| 8 | IN | `sIpAddress` | `varchar(255)` |
| 9 | IN | `sFormId` | `varchar(255)` |
| 10 | IN | `sBrId` | `varchar(255)` |
| 11 | IN | `sSuId` | `varchar(255)` |
| 12 | IN | `sType` | `varchar(255)` |
| 13 | OUT | `sCode` | `int` |
| 14 | OUT | `sReturn` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** Cross-module / 单据强制完成 — generic "force-complete a document" action that closes out a still-open bill (purchase order, work order, production plan, etc.) without going through normal-flow completion. Drives the 强制完成 button on virtually every transactional list view.

**What it does:** Accepts a CSV of bill IDs, a per-form `sTableParam` describing which tables to mark, plus reason/audit fields (`sReason`, `sClientType`, `sComputeName`, `sIpAddress`, `sLoginId`, `sFormId`). Inserts an audit row into `syscomplete` and `syslog`, then iterates the parsed table list to set completion flags on the bill's slave/process rows: `mftworkorderslave`, `mftworkorderprocess`, `mftworkordermaterials`, `mftproductionplanslave`, `purpurchasearriveslave`, `purpurchaseorderslave`, `salsalesorderslave`, `salsalesorderprocess`, `qlycomematerialstestmaster`, `mftqualityaccidentMaster`, etc. `sType` ("force" or other) tweaks behaviour.

**Invocation:** Called by `BillServiceImpl.billForceCompleteSingle()` (xly's `xlyBusinessService`), exposed via `BillService` interface — the front-end 强制完成 toolbar action sends the form's `queryParam` map and the proc closes every configured slave row.
