扩展中的数据视图委托未执行

发布于 2025-01-12 19:13:27 字数 1680 浏览 1 评论 0 原文

我正在尝试向 PRCalculationEngine.cs 中的 UnionDeductions 视图提供 Dataview 委托覆盖,

我注意到该视图在基本图中没有定义的 dataview 委托 - 并且声明有点“不同”,因为它使用了 BQL Fluent班级。

是否有可能在扩展中引入数据视图委托 如果是这样,是否有不同的方式来声明委托?

业务案例是,客户需要根据某些员工属性(工龄等)修改工会扣除金额,并且需要动态修改金额。

由于 GetBenefits 和CalcularBenefitNominalAmount 方法的私有且受保护的访问权限,我认为执行此操作的唯一方法是覆盖数据视图委托并在计算福利/扣除金额之前更改扣除/福利金额...

公共部分类 PRCalculationEngine : PXGraph

{.....

public UnionDeductionQuery UnionDeductions;

...}

当我尝试在扩展中为此视图定义数据视图委托时 - 我无法让数据视图委托“触发” 即代码始终只在基本视图上运行 .Select 但不执行委托。

这是扩展的核心代码 公共类 PRCalculationEngine_Ext1ESP : PXGraphExtension

{ 公共静态 bool IsActive() { return PXAccess.FeatureInstalled(); }

    #region Select Overrides 

    public PRCE.UnionDeductionQuery UnionDeductions;

    protected System.Collections.IEnumerable unionDeductions()
    {
        foreach (PXResult<PREarningDetail, PRDeductionAndBenefitUnionPackage, PRDeductCode, EPEarningType> result in
            UnionDeductions.Select())

        {
            

// 在这里修改包裹数量...

yield return result;

        }


    }

    #endregion

}

中调用视图的方式

这就是在 Base Graph foreach (IGrouping> resultGroup in UnionDeductions.Select(deductionCode.CodeID) .Select(x => (PXResult)x) .GroupBy(x => ((PREarningDetail)x).RecordID)) {

任何建议或意见将不胜感激。

I am attempting to provide a Dataview delegate overide to the UnionDeductions view in PRCalculationEngine.cs

I note that this View does NOT have a defined dataview delegate in the Base graph - and the declaration is a bit 'different' in that is uses a BQL Fluent class.

Is this even possible to introduce a data view delegate in an extension
If so, Is there a different way of declaring the delegate ?

The business case is that the client needs to modify the Amount of the union deduction based on certain Employee attributes (length of service etc) and needs to dynamically modify the amount.

Due to the private and protected access of the GetBenefits and CalculateRegularBenefitNominalAmount methods, the only way I see to do this is to over-ride the dataview delegate and alter the Deduction/Benefit amounts prior to the calculation of the Benefit/Deduction amount...

public partial class PRCalculationEngine : PXGraph

{.....

public UnionDeductionQuery UnionDeductions;

...}

When I attempt to define a dataview delegate for this view in an Extension - I cannot get the dataview delegate to 'fire'
ie The code always just runs the .Select on the Base view but does not execute the delegate.

This is the core of the extension code
public class PRCalculationEngine_Ext1ESP : PXGraphExtension

{
public static bool IsActive() { return PXAccess.FeatureInstalled<FeaturesSet.payrollModule>(); }

    #region Select Overrides 

    public PRCE.UnionDeductionQuery UnionDeductions;

    protected System.Collections.IEnumerable unionDeductions()
    {
        foreach (PXResult<PREarningDetail, PRDeductionAndBenefitUnionPackage, PRDeductCode, EPEarningType> result in
            UnionDeductions.Select())

        {
            

// modify the package amount here...

yield return result;

        }


    }

    #endregion

}

This is how the view is being called in the Base Graph

foreach (IGrouping<int?, PXResult<PREarningDetail, PRDeductionAndBenefitUnionPackage, PRDeductCode, EPEarningType>> resultGroup in UnionDeductions.Select(deductionCode.CodeID)
.Select(x => (PXResult<PREarningDetail, PRDeductionAndBenefitUnionPackage, PRDeductCode, EPEarningType>)x)
.GroupBy(x => ((PREarningDetail)x).RecordID))
{

Any advice or observations would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↙厌世 2025-01-19 19:13:27

如果需要覆盖还引用其他受保护方法的基本数据视图委托的逻辑,请尝试以下操作是否有帮助:

首先使用 PXProtectedAccess 属性和要覆盖的方法创建基类的扩展,如下所示:

[PXProtectedAccess]
    public abstract class PRCalculationEngine_FirstExt : PXGraphExtension<PRCalculationEngine>
    {
        [PXProtectedAccess]
        public abstract DedBenAmount CalculateRegularBenefitNominalAmount(
            PRDeductCode deductCode,
            PREmployeeDeduct employeeDeduct,
            PRPaymentDeduct paymentDeduct);
        
    }

然后创建第二个扩展(您的实际图形扩展)继承自基类和您上面创建的第一个扩展。

public class PRCalculationEngine_Extension : PXGraphExtension<PRCalculationEngine_FirstExt, PRCalculationEngine>
{

// Here declare the view, write the PXOverride method, and access the protected methods of the base graph by referencing those as Base1.CalculateRegularBenefitNominalAmount()

}

请注意,上面的片段只是为了提供指示。我没有真正研究过 PRCalculationEngine 或测试过该代码,但在不同的图表上做了类似的更改以覆盖数据视图委托。如果有帮助请告诉我。谢谢。

If the requirement is to overwrite the logic of the base dataview delegate which also references other protected methods, try if this helps:

First create an extension of the base class as follows with the PXProtectedAccess attribute and the methods that you want to override:

[PXProtectedAccess]
    public abstract class PRCalculationEngine_FirstExt : PXGraphExtension<PRCalculationEngine>
    {
        [PXProtectedAccess]
        public abstract DedBenAmount CalculateRegularBenefitNominalAmount(
            PRDeductCode deductCode,
            PREmployeeDeduct employeeDeduct,
            PRPaymentDeduct paymentDeduct);
        
    }

Then create a second extension (your actual graph extension) inheriting from both the base class and the first extension you created above.

public class PRCalculationEngine_Extension : PXGraphExtension<PRCalculationEngine_FirstExt, PRCalculationEngine>
{

// Here declare the view, write the PXOverride method, and access the protected methods of the base graph by referencing those as Base1.CalculateRegularBenefitNominalAmount()

}

Note that the above snippets are just to give an indication. I have not really worked on the PRCalculationEngine or tested that code but had done similar changes on a different graph to override the dataview delegate. Let me know if it helps. Thank you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文