单据保存校验业务日期大于库存的关账日期实现案例
【业务需求】
单据保存操作的校验规则中如何设置:
1、新增单据的单据日期大于库存的关账日期
库存类单据标准插件中已预置关账日期的校验,对于非库存单据或者二开单据,系统关账日期在校验规则中无法直接使用,这个需求要写插件实现,组织最大关账日期数据可以调用Kingdee.K3.SCM.App.Core.CommonService服务的GetMaxCloseDateByOrgId方法获得,或者直接从T_STK_CLOSEPROFILE表中读取
select max(FCLOSEDATE) FCLOSEDATE FROM T_STK_CLOSEPROFILE WHERE FCATEGORY = 'STK' and FORGID = xxx
T_STK_CLOSEPROFILE 关账记录表
FCATEGORY = 'HS': 存货关账
FCATEGORY = 'STK':库存关账
以处理申请单为例,保存操作配置插件脚本:
import clr clr.AddReference('System') clr.AddReference('Kingdee.BOS') clr.AddReference('Kingdee.BOS.Core') clr.AddReference('Kingdee.BOS.ServiceHelper') from System import * from System import StringComparison from Kingdee.BOS.Core import * from Kingdee.BOS.Core.Metadata.EntityElement import * from Kingdee.BOS.Core.Validation import * from Kingdee.BOS.Log import Logger from Kingdee.BOS.ServiceHelper import * def OnAddValidators(e): validator = StockOrgCloseDateValidator() validator.AlwaysValidate = True validator.EntityKey = "FBillHead" e.Validators.Add(validator) class StockOrgCloseDateValidator(AbstractValidator): def Validate(self, dataEntities, validateContext, ctx): if len(dataEntities) == 0: return for bill in dataEntities: targetOrgId = bill["StockOrgId_Id"] # 单据库存组织 sqlText = "select max(FCLOSEDATE) FCLOSEDATE FROM T_STK_CLOSEPROFILE WHERE FCATEGORY = 'STK' and FORGID = " + str(targetOrgId); dyObjs = DBServiceHelper.ExecuteDynamicObject(this.Context, sqlText) if dyObjs.Count == 0: continue date = Convert.ToDateTime(bill["Date"]) # 单据业务日期 closeDate = Convert.ToDateTime(dyObjs[0]["FCLOSEDATE"]) if date < closeDate: errorMsg = "单据日期{0}必须大于库存组织最后关账日期{1}" info = ValidationErrorInfo("",str(bill["Id"]), bill.DataEntityIndex, bill.RowIndex, "关账日期校验", errorMsg.format(str(date), str(closeDate)), str(bill["BillNo"]), ErrorLevel.Error) validateContext.AddError(None,info)
单据保存校验业务日期大于库存的关账日期实现案例
【业务需求】单据保存操作的校验规则中如何设置:1、新增单据的单据日期大于库存的关账日期库存类单据标准插件中已预置关账日期的校验,对...
点击下载文档
本文2024-09-23 02:54:42发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-155485.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章