Sp_Check_sPpa.md 2.54 KB

Sp_Check_sPpa (procedure)

采购申请单据保存之前数据校验

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

Parameters

# Mode Name Type
1 IN sTableName varchar(100)
2 IN sGuid varchar(100)
3 IN sFormGuid varchar(100)
4 IN sLoginId varchar(100)
5 IN sBrId varchar(100)
6 IN sSuId varchar(100)
7 IN iFlag int
8 OUT sCode int
9 OUT sReturn varchar(4000)

Body

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

Narrative

Business context: 采购管理 → 采购明细 → 采购申请单据 — post-save validator on purpurchaseapplymaster/purpurchaseapplyslave/purpurchaseapplydetail. Same shape as Sp_Check_sPod but for the upstream purchase-requisition: re-runs 正算/反算 quantity formulas, enforces 反算公式物料 and 烟包类型 rules, and caps the requested qty against the originating sales-order need.

What it does: Sets sCode=1, iFlag=0, clears sReturn. Reads NetMoney/NetPrice precisions. Barriers up front: iHandIn=1 rows whose eleproduct.bInverse=0 abort with sMaterialNotFsgsSq ("物料不是反算公式物料,请输入申请数量进行计算"); 客服-channel requests with no 烟包类 selected abort with sTypeSelectCiggrate. Opens nested cursors over purpurchaseapplyslave × purpurchaseapplydetail joined to the upstream sales-order / forecast row, dispatches to Sp_System_ReplaceField forward formula or the reverse-formula branch (eleformula.sComputeId/sReComputeId), recomputes dMaterialsQty/dAuxiliaryQty and the money columns, updates the slave/detail rows. On overruns raises sPpaSqQtyUpNeed/sPpaHsQtyUpNeed/sPpaHsSqQtyUpNeed/sHsQtyUpSaleOrder/sHsSqQtyUpSaleOrder/sSqQtyUpSaleOrder/sPcaMaterialInOrder/sPcaMaterialInCgOrder. Finally calls Sp_afterSave_sPpa.

Invocation: Status: appears orphaned. The module 采购申请单据 (192116810113315217105813660, 采购管理 → 采购明细) binds Sp_Calc_sPpa on sProcName and the newer 采购申请(新) (192116811110216195779824320) binds Sp_Calc_sPpa1, but Sp_Check_sPpa itself is not wired as sSaveProName/sSaveProNameBefore on any module. No other routine references it. xly-src ships script/标版/30100101/Sp_Check_sPpa.sql as the install body — the script is in the codebase but the hook is unbound — candidate for maintainer audit.