Acumatica中的覆盖二级图扩展方法 [英] Overriding second level graph extension method in Acumatica

查看:25
本文介绍了Acumatica中的覆盖二级图扩展方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用可重复使用的业务对象来获取营业税,折扣等,并且需要覆盖这些图形扩展中的某些方法。例如,我从机会图开始。我有一组订单总计需要计算到产品总金额中,过去我们只是覆盖了(我认为)税收类别的税收属性。无论如何,我看不出如何在第二级图扩展中的方法上使用 PXOverrideAttribute

I need to work with the reusable business objects for Sales tax, discounts, etc. and need to override some of the methods in these graph extensions. For example I am starting with the Opportunities graph. I have a set of order totals that need to calculate into the overall products amount and in the past we just overrode the tax attribute on (I think) tax category. Anyhow I don't see how its possible to use the PXOverrideAttribute on a method from a second level graph extension.

这里是我的示例:

public class OpportunityMaintExtOne : PXGraphExtension<PX.Objects.CR.OpportunityMaint.SalesTax, PX.Objects.CR.OpportunityMaint>
{ 
    [PXOverride]
    public virtual void CalcDocTotals(object row, decimal CuryTaxTotal, decimal CuryInclTaxTotal, decimal CuryWhTaxTotal,
        Action<object, decimal, decimal, decimal> del)
    {
        del?.Invoke(row, CuryTaxTotal, CuryInclTaxTotal, CuryWhTaxTotal);

        var someOtherTotal = Base1.Documents.Cache.GetValueAsDecimal<CROpportunityExtension.aMCurySomeOtherTotal>(row);
        if (someOtherTotal == 0)
        {
            return;
        }

        var curyDocTotal = someOtherTotal + Base1.Documents.Cache.GetValueAsDecimal<CROpportunity.curyProductsAmount>(row);
        Base1.Documents.Cache.SetValue<CROpportunity.curyProductsAmount>(row, curyDocTotal);
    }
}

CalcDocTotals内部发生了什么在我的图形扩展中不是焦点。事实是,如果该方法位于第一级(基本)图中,则无法覆盖 OpportunityMaint.SalesTax CalcDocTotals 方法。 SalesTax图扩展将方法设为受保护的方法,但是如果您将方法调用设为公开,则可以使用PXOverrideAttribute重写受保护的方法(如果它在基础图中)。我还尝试使用声明的委托代替Action,但结果相同(如我预期,但想确认)。

What is going on inside of CalcDocTotals in my graph extension is not the focus. It is the fact that I cannot override the OpportunityMaint.SalesTax CalcDocTotals method as I could if the method was in the first level (Base) graph. The SalesTax graph extension has the method as protected but protected methods (if it was in the base graph) are overrideable using the PXOverrideAttribute if you make your method call public which is what I have done. I also tried using a declared delegate in place of the Action but same results (as I expected but wanted to confirm).

我的问题:是否有可能使用PXOverrideAttribute覆盖第二,第三等级别的图形扩展方法?

当我编译上面的代码并加载页面时,出现此错误:

When I compile the code above and the page loads I get this error:


方法无效CalcDocTotals(System.Object,System.Decimal,
System.Decimal,System.Decimal,
图扩展中的System.Action`4 [System.Object,System.Decimal,System.Decimal,System.Decimal])
被标记为[PXOverride],但是具有该名称的原始方法
却没有已在PXGraph中找到

Method Void CalcDocTotals(System.Object, System.Decimal, System.Decimal, System.Decimal, System.Action`4[System.Object,System.Decimal,System.Decimal,System.Decimal]) in graph extension is marked as [PXOverride], but the original method with such name has not been found in PXGraph


推荐答案

已在2018R1 Update 4(18.104.0023)中添加。这样可以解决我的问题/问题,并允许我的问题中张贴的代码按原样运行。

The ability to override extension methods from a higher level extension has been added in 2018R1 Update 4 (18.104.0023). This resolves my question/issue and allows for the code posted in my question to function as is.

这篇关于Acumatica中的覆盖二级图扩展方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆