PXFormula属性无法正确计算 [英] PXFormula attribute isn't calculating correctly

查看:88
本文介绍了PXFormula属性无法正确计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对SalesOrder(SO301000)屏幕进行了自定义,如下所示:

I have a customization to the SalesOrder (SO301000) screen as follows:


  • 我在标题部分创建了一个User字段(SOOrder)称为总收入(SOOrderExt.UsrTotalRevenue):


  • 我向Ext添加了PXFormula属性。网格(SOLine.CuryLineAmt)中的价格字段如下:

此计算正确,直到尝试复制订单以创建另一订单为止。发生这种情况时,该值会加倍-就像是将原始订单加复制的订单相加。此时,即使您按照复制的顺序删除了订单项,它也会在标题中保留汇总值。我不知道它将在哪里获得这一价值。我错过了一步吗?

This calculates correctly, until one tries to copy an order to create another order. When this happens, the value is doubled - as if it's summing the original order PLUS the copied order. At that point, even if you delete the line item(s) in the copied order, it maintains the summary value in the header. I have no idea where it would be getting this value. Have I missed a step? Is there some type of refresh that I need to add somewhere?

推荐答案

根据我们今天早些时候与Peter的讨论,最初有2种刷新类型导致自定义聚合字段值加倍的单独方案:

Per our discussion with Peter earlier today, originally there were 2 separate scenarios causing custom aggregate field value to double:


  1. 使用剪贴板菜单中的复制粘贴按钮时(在答案:

  1. When Copy-Paste buttons are used from the Clipboard menu (addressed in the answer above):

动作下拉按钮中的复制订单动作:

The Copy Order action form the Actions drop-down button:

通过探索SOOrderentry的源代码.CopyOrderProc方法,您应该在复制顺序函数中注意到一堆分配了 0 值的字段(其中所有字段都是聚合的最初在销售订单屏幕上找到的ed字段):

By exploring source code of the SOOrderentry.CopyOrderProc method, you should notice a bunch of fields with assigned 0 value during the Copy Order function (among those are all aggregated fields originally found on the Sales Orders screen):

    public class SOOrderEntry : PXGraph<SOOrderEntry, SOOrder>, PXImportAttribute.IPXPrepareItems
    {
        ...

        public virtual void CopyOrderProc(SOOrder order, CopyParamFilter copyFilter)
        {
            ...
            foreach (PXResult<SOOrder, CurrencyInfo> res in PXSelectJoin<SOOrder, InnerJoin<CurrencyInfo, On<CurrencyInfo.curyInfoID, Equal<SOOrder.curyInfoID>>>, Where<SOOrder.orderType, Equal<Required<SOOrder.orderType>>, And<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>>>>.Select(this, order.OrderType, order.OrderNbr))
            {
                ...
                SOOrder copyorder = PXCache<SOOrder>.CreateCopy(quoteorder);
                ...
                copyorder.ShipmentCntr = 0;
                copyorder.OpenShipmentCntr = 0;
                copyorder.OpenLineCntr = 0;
                copyorder.ReleasedCntr = 0;
                copyorder.BilledCntr = 0;
                copyorder.OrderQty = 0m;
                copyorder.OrderWeight = 0m;
                copyorder.OrderVolume = 0m;
                copyorder.OpenOrderQty = 0m;
                copyorder.UnbilledOrderQty = 0m;
                copyorder.CuryInfoID = neworder.CuryInfoID;
                copyorder.Status = neworder.Status;
                copyorder.Hold = neworder.Hold;
                copyorder.Completed = neworder.Completed;
                copyorder.Cancelled = neworder.Cancelled;
                copyorder.InclCustOpenOrders = neworder.InclCustOpenOrders;
                copyorder.OrderDate = neworder.OrderDate;
                copyorder.RequestDate = neworder.RequestDate;
                copyorder.ShipDate = neworder.ShipDate;
                copyorder.CuryMiscTot = 0m;
                copyorder.CuryUnbilledMiscTot = 0m;
                copyorder.CuryLineTotal = 0m;
                copyorder.CuryOpenLineTotal = 0m;
                copyorder.CuryUnbilledLineTotal = 0m;
                copyorder.CuryVatExemptTotal = 0m;
                copyorder.CuryVatTaxableTotal = 0m;
                copyorder.CuryTaxTotal = 0m;
                copyorder.CuryOrderTotal = 0m;
                copyorder.CuryOpenOrderTotal = 0m;
                copyorder.CuryOpenTaxTotal = 0m;
                copyorder.CuryUnbilledOrderTotal = 0m;
                copyorder.CuryUnbilledTaxTotal = 0m;
                ...
            }
            ...
        }
        ...
    }

要解决复制顺序操作中自定义聚合字段值加倍的问题,您应该简单地覆盖SOOrderEntry BLC扩展中的CopyOrderProc方法,并在该方法内部订阅RowSelecting处理程序,根据基本产品流向自定义聚合字段分配 0 值:

To resolve the issue with doubled custom aggregated field value in the Copy Order action, you should simply override the CopyOrderProc method in the SOOrderEntry BLC extension and inside the method subscribe to RowSelecting handler to assign 0 value to custom aggregated fields following the base product flow:

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
    public delegate void CopyOrderProcDel(SOOrder order, CopyParamFilter copyFilter);

    [PXOverride]
    public void CopyOrderProc(SOOrder order, CopyParamFilter copyFilter, CopyOrderProcDel del)
    {
        Base.RowSelecting.AddHandler<SOOrder>((sender, e) =>
        {
            if (e.Row == null) return;

            SOOrderExt orderExt = sender.GetExtension<SOOrderExt>(e.Row);
            orderExt.UsrTotalRevenue = 0m;
        });
        del(order, copyFilter);
    }
}

这篇关于PXFormula属性无法正确计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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