背景
费用报销单分录的报销未付款金额,客户需要打印出来一个汇总,不显示单据体。
1,拖一个金额字段冗余在单据头。
2,套打里面吧这个字段设置到对应的打印位置。
3,挂插件
1 #-*- coding: utf-8 -*- 2 import clr 3 clr.AddReference("System") 4 clr.AddReference("System.Core") 5 clr.AddReference("Kingdee.BOS") 6 clr.AddReference("Kingdee.BOS.Core") 7 clr.AddReference("Kingdee.BOS.DataEntity") 8 clr.AddReference("Kingdee.BOS.ServiceHelper") 9 import sys 10 from System import * 11 from System.Collections.Generic import * 12 from System.Threading import * 13 from Kingdee.BOS.Log import * 14 from Kingdee.BOS.Core.Log import * 15 from Kingdee.BOS.Core import * 16 from Kingdee.BOS.Core.DynamicForm import * 17 from Kingdee.BOS.KDThread import * 18 from Kingdee.BOS.DataEntity import * 19 from Kingdee.BOS.Orm.DataEntity import * 20 from Kingdee.BOS.ServiceHelper import * 21 from Kingdee.BOS.Core.Metadata import SelectorItemInfo ##字段选择实体类 22 from Kingdee.BOS.Core.SqlBuilder import QueryBuilderParemeter ##查询参数实体类 23 #修改默认编码为utf8 24 reload(sys) 25 sys.setdefaultencoding('utf-8') 26 27 def OnPrepareNotePrintData(e): 28 if e.DataSourceId == "FBillHead": 29 # 获取到单据头的数据包 30 qureyObjs = e.DataObjects 31 # 获取数据包行数 32 _count = e.DataObjects.Count 33 # 获取到单据头的数据包类型 34 DevDynamicTypy = qureyObjs[0].DynamicObjectType 35 # 是否需要注册字段 36 IsNeedReg = True 37 for p in DevDynamicTypy.Properties: 38 if str(p.Name).lower() == "F_Dev_ReimbNotPaySum".lower(): 39 IsNeedReg = False 40 # 如果需要注册字段就注册字段 41 if IsNeedReg: 42 #注册一个F_PAEZ_Amount字段 43 DevDynamicTypy.RegisterSimpleProperty("F_Dev_ReimbNotPaySum", str,None,False,[]) 44 # 循环把数据包的数据赋值回去。 45 for i in range(0,_count): 46 # 创建一个新的数据包 47 obj = DynamicObject(DevDynamicTypy) 48 # 把旧数据包的值全部给新数据包 49 for p in qureyObjs[0].DynamicObjectType.Properties: 50 obj[p] = e.DataObjects[0][p] 51 # 查询出未付款金额 52 sql = "/*dialect*/select CAST(SUM(FREIMBNOTPAYAMOUNT) AS DECIMAL(18,2)) as FREIMBNOTPAYAMOUNT from t_ER_ExpenseReimbEntry where fid = " + str(qureyObjs[0][0]) 53 dyc = DBServiceHelper.ExecuteDynamicObject(this.Context, sql) 54 if dyc != None: 55 Amount = dyc[0][0] 56 # 把未付款金额的数据给OBJ数据包 57 obj["F_Dev_ReimbNotPaySum"] = Amount; 58 # 最后用新的数据包来替换旧的数据包 59 e.DataObjects[i] = obj
4,套打使用GetValue("F_PAEZ_Amount")
5,完成