Sp_check_MaterialsStockLimitNew.md 1.83 KB

Sp_check_MaterialsStockLimitNew (procedure)

校验材料库存是否够用

  • Type: PROCEDURE
  • Deterministic: NO
  • SQL data access: CONTAINS SQL

Parameters

# Mode Name Type
1 IN sGuid varchar(100)
2 IN sFormGuid varchar(100)
3 IN tCreateDate datetime
4 IN sBrId varchar(100)
5 IN sSuId varchar(100)
6 IN sTbName varchar(100)
7 IN iFlag int
8 OUT sCode int
9 OUT sReturn longtext

Body

Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURESpcheck_MaterialsStockLimitNew'._

Narrative

Business context: Generic reusable check 校验材料库存是否够用 — intended to prevent an outbound material movement (issue / sale / shipment) from being saved when the resulting inventory would go negative, scoped to the current accounting period.

What it does: Looks up the form's in/out direction via Sp_Sis_GetMertialsInventoryFormGuid (inferring p_iAdd ∈ {1: 入库, 2: 出库} from INSTR against the form lists); skips the check on 入库 and inverts the direction when iFlag = 0 (消审 / un-check). For outbound saves, queries sysaccountperiod for the brand's closed-period boundary, then dynamically tallies on-hand material against the document's required quantities and emits the offending material names in sReturn with sCode = -1 when stock is insufficient.

Invocation: Status: appears orphaned. No caller found in any channel — no gdsmodule hook, no gdsconfigformmaster embed, no other-routine call, no xly-src reference. Designed as a save-time check but never linked; the older Sp_check_MaterialsStockLimit (without New suffix) may be the active version. Candidate for maintainer audit.