背景

费用报销单分录的报销未付款金额,客户需要打印出来一个汇总,不显示单据体。

 

1,拖一个金额字段冗余在单据头。

2,套打里面吧这个字段设置到对应的打印位置。

3,挂插件

#-*- coding: utf-8 -*-
import clr
clr.AddReference("System")
clr.AddReference("System.Core")
clr.AddReference("Kingdee.BOS")
clr.AddReference("Kingdee.BOS.Core")
clr.AddReference("Kingdee.BOS.DataEntity")
clr.AddReference("Kingdee.BOS.ServiceHelper")
import sys
from System import *
from System.Collections.Generic import *
from System.Threading import *
from Kingdee.BOS.Log import *
from Kingdee.BOS.Core.Log import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.DynamicForm import *
from Kingdee.BOS.KDThread import *
from Kingdee.BOS.DataEntity import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.ServiceHelper import * 
from Kingdee.BOS.Core.Metadata import SelectorItemInfo ##字段选择实体类
from Kingdee.BOS.Core.SqlBuilder import QueryBuilderParemeter ##查询参数实体类
#修改默认编码为utf8
reload(sys)
sys.setdefaultencoding(\'utf-8\') 

def OnPrepareNotePrintData(e):
    if e.DataSourceId == "FBillHead":
        # 获取到单据头的数据包
        qureyObjs = e.DataObjects
        # 获取数据包行数
        _count =  e.DataObjects.Count
        # 获取到单据头的数据包类型
        DevDynamicTypy = qureyObjs[0].DynamicObjectType
        # 是否需要注册字段
        IsNeedReg = True
        for p in DevDynamicTypy.Properties:
            if str(p.Name).lower() == "F_Dev_ReimbNotPaySum".lower():
                IsNeedReg = False
        # 如果需要注册字段就注册字段
        if IsNeedReg:
            #注册一个F_PAEZ_Amount字段
            DevDynamicTypy.RegisterSimpleProperty("F_Dev_ReimbNotPaySum", str,None,False,[])
        # 循环把数据包的数据赋值回去。
        for i in range(0,_count):
            # 创建一个新的数据包
            obj = DynamicObject(DevDynamicTypy)
            # 把旧数据包的值全部给新数据包
            for p in qureyObjs[0].DynamicObjectType.Properties:
                obj[p] = e.DataObjects[0][p]
            # 查询出未付款金额
            sql = "/*dialect*/select CAST(SUM(FREIMBNOTPAYAMOUNT) AS DECIMAL(18,2)) as FREIMBNOTPAYAMOUNT from t_ER_ExpenseReimbEntry where fid = " + str(qureyObjs[0][0])
            dyc = DBServiceHelper.ExecuteDynamicObject(this.Context, sql)
            if dyc != None:
                Amount = dyc[0][0]
                # 把未付款金额的数据给OBJ数据包
                obj["F_Dev_ReimbNotPaySum"] = Amount;
            # 最后用新的数据包来替换旧的数据包
            e.DataObjects[i] = obj

  

4,套打使用GetValue("F_PAEZ_Amount") 

5,完成