销售出库单保存校验关联订单物料一致性

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-23浏览:1

销售出库单保存校验关联订单物料一致性

@[TOC](目录) ### 背景 在跨组织场景,采购订单下推销售订单后,有客户会存在变更销售订单物料的情况,这样下推到出库单后,审核将不会自动生成入库单,因此需要在**出库单保存时校验销售订单与采购订单的物料是否一致**,需要在销售出库单保存操作上注册二开校验器插件实现 ### 步骤 ![5、BOS销售出库单注册保存python脚本.webp](/download/01006412d751c98d416f8765443566a328ca.webp) ### python脚本 ```python import clr clr.AddReference('mscorlib') clr.AddReference('System') clr.AddReference('Kingdee.BOS') clr.AddReference('Kingdee.BOS.App') clr.AddReference('Kingdee.BOS.Core') clr.AddReference('Kingdee.BOS.DataEntity') from System import * from Kingdee.BOS import * from Kingdee.BOS.Core import * from Kingdee.BOS.Orm import * from Kingdee.BOS.App.Data import * from Kingdee.BOS.Core.Validation import * from System.Collections.Generic import * def OnPreparePropertys(e): e.FieldKeys.Add("FPayConditionId") e.FieldKeys.Add("FPurchaseOrgId") e.FieldKeys.Add("FMATERIALSEQ") e.FieldKeys.Add("FPayMaterialId") e.FieldKeys.Add("FMaterialId") def OnAddValidators(e): outStockValidator = OutStockValidator() outStockValidator.EntityKey = "FBillHead" outStockValidator.AlwaysValidate = True e.Validators.Add(outStockValidator) class OutStockValidator(AbstractValidator): def Validate(self, dataEntities, validateContext,ctx): if dataEntities == None or dataEntities.Length == 0: return soEntryIds = List[String]() for data in dataEntities: cust = data.DataEntity["CustomerID"] if cust != None: custType = cust["CustTypeId"] if custType != None: if custType["Number"] == "KHLB003_SYS": entrys = data.DataEntity["SAL_OUTSTOCKENTRY"] if entrys != None and entrys.Count>0: for entry in entrys: soEntryId = Convert.ToString(entry["SOEntryId"]) if soEntryId >0: soEntryIds.Add(soEntryId) if soEntryIds.Count >0: sql = """ SELECT T2.FBILLNO,T1.FSEQ,MA1.FNUMBER AS SOMATNUMBER,MA2.FNUMBER AS POMATNUMBER,ISNULL(T3.FREMAINOUTQTY,0)AS SOQTY,ISNULL(T6.FREMAINSTOCKINQTY,0) AS POQTY FROM T_SAL_ORDERENTRY T1 INNER JOIN T_SAL_ORDER T2 ON T1.FID = T2.FID AND T1.FENTRYID IN ({0}) INNER JOIN T_SAL_ORDERENTRY_R T3 ON T1.FENTRYID = T3.FENTRYID INNER JOIN T_BD_MATERIAL MA1 ON T1.FMATERIALID = MA1.FMATERIALID LEFT JOIN T_SAL_ORDERENTRY_LK T4 ON T1.FENTRYID = T4.FENTRYID AND T4.FSTABLENAME = 't_PUR_POOrderEntry' LEFT JOIN T_PUR_POORDERENTRY T5 ON T4.FSID = T5.FENTRYID LEFT JOIN T_PUR_POORDERENTRY_R T6 ON T6.FENTRYID = T5.FENTRYID LEFT JOIN T_BD_MATERIAL MA2 ON T5.FMATERIALID = MA2.FMATERIALID WHERE ISNULL(T5.FENTRYID,'0') = '0' OR T6.FREMAINSTOCKINQTY < T3.FREMAINOUTQTY """.format(','.join(soEntryIds)) dyc = DBUtils.ExecuteDynamicObject(this.Context, sql) if dyc != None and dyc.Count > 0: for item in dyc: msg = "当前销售出库单关联的销售订单【{0}】的第{1}行分录物料{2}在关联的采购订单中不存在或者销售订单剩余出库数量{3}大于采购订单剩余入库数量{4},请检查!".format(item["FBILLNO"], item["FSEQ"], item["SOMATNUMBER"],item["SOQTY"], item["POQTY"]) info = ValidationErrorInfo("","", 0,0,"OutStock053", msg,"销售出库单保存校验订单物料",ErrorLevel.Error) validateContext.AddError(None,info) ``` ### 效果 1. 采购订单 ![1、采购订单.webp](/download/0100ad090cf63850434893ce494b5a4ae34d.webp) 2. 销售订单 ![2、销售订单.webp](/download/0100fad2a0d4f4ec4f2fbf20c742bf319125.webp) 3. 销售订单新变更单 ![3、销售订单新变更单关联复制行替换物料.webp](/download/01007df19f735918469f8ee362f2430e776c.webp) ![3、销售订单新变更单删除原物料替换新物料.webp](/download/0100f2d5d8a98188413abb378fed3f3bb354.webp) 4. 替换物料后的销售订单 ![4、替换物料后的销售订单.webp](/download/0100228527ed34754020aec8ca768ee961ba.webp) 5. 出库单保存校验效果 ![6、销售出库单保存校验提交.webp](/download/0100f71b02356d8c48509a5fce74a6d9f918.webp) **其他更多文章入口:**[https://vip.kingdee.com/link/s/lbRPP](https://vip.kingdee.com/link/s/lbRPP)

销售出库单保存校验关联订单物料一致性

@[TOC](目录)### 背景在跨组织场景,采购订单下推销售订单后,有客户会存在变更销售订单物料的情况,这样下推到出库单后,审核将不会自动...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息