获取核算组织的本位币示例原创
金蝶云社区-邱育华
邱育华
14人赞赏了该文章 100次浏览 未经作者许可,禁止转载编辑于2022年11月25日 13:54:57

一、【业务需求】

单据扩展本位币的字段,新增单据时,如何让这个字段自动赋值为账套的本位币种?


二、【分析实现】

1、根据组织取到默认会计政策下面默认的本位币和汇率类型

两种方式:

  • 调用财务领域的服务

Kingdee.K3.BD.Contracts.FIN.IFINServiceForCommon service = Kingdee.K3.BD.Contracts.ServiceFactory.GetService<Kingdee.K3.BD.Contracts.FIN.IFINServiceForCommon>(ctx);
return service.GetDefCurrencyAndExchangeTypeByBizOrgID(ctx, subOrgId);


  • 调用供应链领域CommonServiceHelper,引用组件(Kingdee.K3.SCM.ServiceHelper.dll)

CommonServiceHelper.GetDefCurrencyAndExchangeTypeByBizOrgID(this.View.Context, orgId)


image.png


返回JSONObject类型,其中

  • FRateType:汇率类型   

  • FCyForID:本位币内码

  • FCyForCode: 本位币编码


2、调拨申请单扩展本位币字段,二开表单插件

public override void AfterCreateModelData(EventArgs e)
{
            if (this.View.OpenParameter.Status == OperationStatus.ADDNEW)
            {
                if (this.View.OpenParameter.CreateFrom != CreateFrom.Push)
                { 

                    DynamicObject apporg = this.Model.GetValue("FAPPORGID") as DynamicObject;
                    long orgId = apporg == null ? 0 : Convert.ToInt64(apporg["Id"]);
                    JSONObject objk = CommonServiceHelper.GetDefCurrencyAndExchangeTypeByBizOrgID(this.View.Context, orgId);
                    this.View.Model.SetValue("FBaseCurrId", objk["FCyForID"]);
                }
            }
}


Python: 

import clr
clr.AddReference("System")
clr.AddReference("System.Core")
clr.AddReference("Kingdee.BOS")
clr.AddReference("Kingdee.BOS.Core")
clr.AddReference('Kingdee.K3.SCM.ServiceHelper')

from System import *
from Kingdee.BOS.Core import *
from Kingdee.K3.SCM.ServiceHelper import *

def AfterCreateModelData(e):
    if this.View.OpenParameter.Status == OperationStatus.ADDNEW and this.View.OpenParameter.CreateFrom != CreateFrom.Push:
        apporg = this.Model.GetValue("FAPPORGID")
        if apporg != None:
            orgId = Convert.ToInt64(apporg["Id"])
            objk = CommonServiceHelper.GetDefCurrencyAndExchangeTypeByBizOrgID(this.View.Context, orgId)
            this.View.Model.SetValue("FBaseCurrId", objk["FCyForID"])


image.png

赞 14