python 校验入库数量不允许上游单据领料数量原创
83人赞赏了该文章
333次浏览
未经作者许可,禁止转载编辑于2024年07月23日 15:17:22
根据源单单号校验本次入库数量不允许超过领料数量 import clr clr.AddReference('System') clr.AddReference('Kingdee.BOS') clr.AddReference('Kingdee.BOS.Core') clr.AddReference('Kingdee.BOS.Contracts') clr.AddReference('Kingdee.BOS.DataEntity') clr.AddReference('Kingdee.BOS.ServiceHelper') from Kingdee.BOS import * from Kingdee.BOS.Core import * from Kingdee.BOS.Core.Bill import * from Kingdee.BOS.Core.DynamicForm.PlugIn import * from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import * import System from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import EndOperationTransactionArgs from Kingdee.BOS.Orm.DataEntity import * from Kingdee.BOS.Core.Metadata import * from Kingdee.BOS.Contracts import * from Kingdee.BOS.ServiceHelper import * def BarItemClick(e): if (e.BarItemKey=="tbSplitSave" or e.BarItemKey=="tbSplitSubmit"): row = this.Model.GetEntryRowCount("FEntity"); i=0; merged_data = {};##定义数组 rows_data={}; srcNoP = this.Model.GetValue("FSRCBILLNO",0); if srcNoP== None or srcNoP=='': msg ='MSG:'; else: for i in range(0,row): comb = this.Model.GetValue("F_ora_Text",i); srcNo = this.Model.GetValue("FSRCBILLNO",i); if comb==None or comb=='': comb=' '; if srcNo==None or srcNo=='': srcNo=' '; curQTY = this.Model.GetValue("FQTY",i); spec = comb +'$'+ srcNo;##查找每行的源单编号与文本字段COMB后使用$组合 if spec in merged_data: merged_data[spec] += curQTY else: merged_data[spec] = curQTY separator="$"; msg ='MSG:'; for i in merged_data: comb = i.split(separator)[0];##拆分数组的comb字段与源单编号字段 srcNo =i.split(separator)[1];##拆分数组的comb字段与源单编号字段 if comb==None or comb=='': comb=' '; if srcNo==None or srcNo=='': srcNo=' '; pdQTY = sqlReturn_PDQTY(str(srcNo),str(comb)); inQTY = sqlReturn_QTY(str(srcNo),str(comb)); if inQTY == None: inQTY=0; if pdQTY == None: pdQTY=0; curQTY = merged_data[i]; if inQTY == None: inQTY=0; if pdQTY == None: pdQTY=0; if curQTY+ inQTY > pdQTY: '''this.View.ShowMessage("行号:"+str(i)+"," +"辅助资料组合"+ str(comb)+ "累计入库数量大于原料单加工原料出库数量." + "当前数量:" + str(curQTY)+".加工单原料出库数量:"+str(pdQTY) + ".累计入库数量:" + str(inQTY));''' msg = msg + " 辅助资料组合"+ str(comb)+ "累计入库数量大于原料单加工原料出库数量." + "当前数量:" + str(round(curQTY,3))+".加工单原料出库数量:"+str(round(pdQTY,3)) + ".累计入库数量:" + str(round(inQTY,3))+";"; this.Model.SetValue("F_ORA_MSG",msg); '''查询其他入库单数量''' def sqlReturn_QTY(srcNo,comb): sql ="select sum(FQTY) from T_STK_MISCELLANEOUSENTRY t,T_STK_MISCELLANEOUSENTRY_R s,T_STK_MISCELLANEOUS n where t.F_ORA_TEXT1='"+comb +"' and s.FSRCBILLNO='"+srcNo +"' and t.FENTRYID=s.FENTRYID and n.FID=t.FID and n.FDOCUMENTSTATUS='C'; "; qty = DBServiceHelper.ExecuteScalar(this.Context,sql,None); return qty; '''查询上游单据原料出库数量''' def sqlReturn_PDQTY(srcNo,comb): sql ="select sum(FLLCKQTY) from ora_t_Cust_Entry100005 t ,ora_t_Cust100002 s where t.F_ORA_TEXT='"+ comb+"' and t.FID=s.FID and s.FBILLNO='"+srcNo +"';" qty = DBServiceHelper.ExecuteScalar(this.Context,sql,None); return qty;
推荐阅读