Sp_Check_dOraQtyTs.md 1.97 KB

Sp_Check_dOraQtyTs (procedure)

校验是否超过源单数量

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

Parameters

# Mode Name Type
1 IN sTableName varchar(50)
2 IN sCloumnQtyName varchar(255)
3 IN sSrcTableName varchar(50)
4 IN sSrcCloumnName varchar(50)
5 IN sSrcCloumnQtyName varchar(255)
6 IN sTsCloumnName varchar(50)
7 IN sTsCloumnNameCon varchar(50)
8 IN sTsTableName varchar(50)
9 IN sGuid varchar(50)
10 IN sBrId varchar(50)
11 IN sSuId varchar(50)
12 OUT sCode int
13 OUT sReturn longtext

Body

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

Narrative

Business context: Reusable generic check 校验是否超过源单数量 — prevents a downstream document from issuing more quantity than its upstream source authorizes, with an extra layer of specification-attribute (Ts) grouping for fabric/colour-spec scenarios.

What it does: Given the slave table, its quantity columns, the source table/column, and an optional Ts specification table/column, builds temp tables p_sSrcSlaveId and p_sSlaveId_qty via dynamic SQL, sums the current document's quantities per source-slave, joins back to source quantities and the spec table, and returns sCode = -1 with a 已开数量 / 源单据数量 diff message (formatted via Sp_Sis_GetConst('sDoraQtyUpQty', …)) when any current quantity exceeds the source. The non-Ts sibling is Sp_Check_dOraQty.

Invocation: Called from save-quantity checks in upstream/downstream document procedures, including Sp_Check_sRgd (新增销售退货 / 销售送货流程) — the Sp_Check_* family is invoked by Sp_Calc_* save procedures via the dispatcher pattern. Also called by Sp_Check_sDgda.