如何在图形扩展中覆盖 PXFilteredProcessingJoin 而不改变基本图形的行为? [英] How do I override PXFilteredProcessingJoin in a graph extension without altering behavior of the base graph?

查看:31
本文介绍了如何在图形扩展中覆盖 PXFilteredProcessingJoin 而不改变基本图形的行为?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:

在 APPayBills(应付帐款 - 准备付款)中,屏幕功能旨在累积现金帐户的所有付款.有一个 Branch 选项,但它实际上并不限制支付给分行,而是限制为分行定义的现金账户.

In APPayBills (Payables - Prepare Payments) the screen functionality is designed to accumulate all payments for a cash account. There is a selection for Branch, but it doesn't actually limit payments to the branch, but rather the cash accounts defined for the branch.

我们的用例是我们有多个分支机构",它们在日常业务(库存、发货材料、采购收据等)中有些独立运作.但是,所有应付款项都通过一个银行账户处理,因此单一现金账户.付款由分行根据某些业务规则处理.在标准 Acumatica 下处理此问题的显而易见的方法是使用不同的银行账户,以便我们可以在 Acumatica 内部操作单独的现金账户.我们的用户群更喜欢单一银行账户,因此我们的任务是创建解决方案.我们也有一些变通方法,但需要对其进行简化以减轻员工的负担并减少错误.使用 Acumatica 开立了一个案例,得到的回应是这需要我们进行定制.

Our use case is that we have multiple "branches" that operate somewhat independently for day to day business (inventory, issuing material, purchase receipts, etc.) However, all the payables are handled via a single bank account, hence a single cash account. Payments are processed by branch according to certain business rules. The obvious way to handle this under standard Acumatica would be to use different bank accounts so that we can operate separate cash accounts inside of Acumatica. Our user base prefers the single bank account, so we are tasked with creating a solution. We have some work arounds also, but this needs to be streamlined to ease the burden on staff and reduce errors. A case was opened with Acumatica, and the response was that this requires a customization on our part.

问题:

APPayBill 利用 2 个视图(APDocuemntList 和 APExceptionsList)在 2 个选项卡上填充网格.标准行为是网格保持空白,直到用户输入分行、付款方式和现金帐户.此时,结果将根据使用指定现金帐户的所有付款显示在网格中.

APPayBill utilizes 2 views (APDocuemntList and APExceptionsList) to populate grids on 2 tabs. Standard behavior is that the grid remains empty until the Branch, Payment Method, and Cash Account are entered by the user. At that point, the results are displayed in the grids according to all payments using the specified cash account.

我的理解是,您可以在图形扩展中重新定义视图以覆盖它.但是,当我这样做时,网格甚至在进行任何选择之前就会填充.网格数据根据我的需要进行过滤,但不希望更改何时填充网格的用户界面行为.

My understanding is that you can redefine a view in a graph extension to overrides it. However, when I do, the grids fill in even before any selections are made. The grid data is filtered as I want them, but change in user interface behavior for when to populate the grids is undesirable.

代码前:

[PXFilterable]
public PXFilteredProcessingJoin<APAdjust, PayBillsFilter,
    InnerJoin<APInvoice, On<APInvoice.docType, Equal<APAdjust.adjdDocType>, And<APInvoice.refNbr, Equal<APAdjust.adjdRefNbr>>>,
    LeftJoin<APTran, On<APInvoice.paymentsByLinesAllowed, Equal<True>,
        And<APTran.tranType, Equal<APAdjust.adjdDocType>,
        And<APTran.refNbr, Equal<APAdjust.adjdRefNbr>,
        And<APTran.lineNbr, Equal<APAdjust.adjdLineNbr>>>>>>>
    > APDocumentList;

public PXSelectJoin<APAdjust,
    InnerJoin<APInvoice, On<APInvoice.docType, Equal<APAdjust.adjdDocType>, And<APInvoice.refNbr, Equal<APAdjust.adjdRefNbr>>>,
        LeftJoin<APTran, On<APInvoice.paymentsByLinesAllowed, Equal<True>,
            And<APTran.tranType, Equal<APAdjust.adjdDocType>,
            And<APTran.refNbr, Equal<APAdjust.adjdRefNbr>,
            And<APTran.lineNbr, Equal<APAdjust.adjdLineNbr>>>>>>>
    > APExceptionsList;

代码后:

[PXFilterable]
public PXFilteredProcessingJoin<APAdjust, PayBillsFilter,
    InnerJoin<APInvoice, On<APInvoice.docType, Equal<APAdjust.adjdDocType>, And<APInvoice.refNbr, Equal<APAdjust.adjdRefNbr>>>,
    LeftJoin<APTran, On<APInvoice.paymentsByLinesAllowed, Equal<True>,
        And<APTran.tranType, Equal<APAdjust.adjdDocType>,
        And<APTran.refNbr, Equal<APAdjust.adjdRefNbr>,
        And<APTran.lineNbr, Equal<APAdjust.adjdLineNbr>>>>>>>

    // BEG - Add branch filter
    ,Where<APAdjust.adjdBranchID, Equal<Current<PayBillsFilter.branchID>>>
    // END - Add branch filter

    > APDocumentList;

public PXSelectJoin<APAdjust,
    InnerJoin<APInvoice, On<APInvoice.docType, Equal<APAdjust.adjdDocType>, And<APInvoice.refNbr, Equal<APAdjust.adjdRefNbr>>>,
        LeftJoin<APTran, On<APInvoice.paymentsByLinesAllowed, Equal<True>,
            And<APTran.tranType, Equal<APAdjust.adjdDocType>,
            And<APTran.refNbr, Equal<APAdjust.adjdRefNbr>,
            And<APTran.lineNbr, Equal<APAdjust.adjdLineNbr>>>>>>>

    // BEG - Add branch filter
    ,Where<APAdjust.adjdBranchID, Equal<Current<PayBillsFilter.branchID>>>
    // END - Add branch filter

    > APExceptionsList;

为了确保 where 子句的添加不是罪魁祸首,我从字面上复制并粘贴了基本代码中的确切视图到图形扩展中,这样绝对不会有任何变化.令人惊讶的是(对我而言)带有替换视图的图形扩展表现出与添加 Where 子句时相同的预填充行为.

To be sure that the addition of the where clause was not the culprit, I literally copied and pasted the exact views from the base code into the graph extension so that there would be absolutely no change. Surprisingly (to me) the graph extension with the replacement views exhibited the same pre-populating behavior that was seen with the Where clauses added.

显然,以这种方式覆盖视图有一些特别之处.我尝试使用和不使用 [PXOverride] 装饰视图,行为没有差异.

Clearly there is something special to overriding views in this way. I tried with and without [PXOverride] decorating the views with no difference in behavior.

是什么导致处理屏幕预填充网格,以及如何正确地将我的覆盖应用于 2 个视图?

What is causing the processing screen to pre-populate the grid, and how do I apply my overrides to the 2 views properly?

推荐答案

在图 APPayBills 中,数据视图 APDocumentList 是这样定义的:

In the graph APPayBills, the data view APDocumentList is defined like this:

    [PXFilterable]
    public PXFilteredProcessingJoin<APAdjust, PayBillsFilter, 
        InnerJoin<APInvoice, On<APInvoice.docType, Equal<APAdjust.adjdDocType>, And<APInvoice.refNbr, Equal<APAdjust.adjdRefNbr>>>>> APDocumentList;

然而,视图也有一个委托:

However, the view also has a delegate:

protected virtual IEnumerable apdocumentlist()
        {
            PayBillsFilter filter = Filter.Current;

            if (filter?.PayDate == null || filter.PayTypeID == null || filter.PayAccountID == null)
                yield break;

            foreach (APAdjust adj in APDocumentList.Cache.Inserted)
            {
                APInvoice doc = PXSelect<APInvoice, Where<APInvoice.docType, Equal<Required<APInvoice.docType>>, And<APInvoice.refNbr, Equal<Required<APInvoice.refNbr>>>>>.Select(this, adj.AdjdDocType, adj.AdjdRefNbr);
                adj.SeparateCheck = (adj.SeparateCheck ?? doc.SeparateCheck);
                yield return new PXResult<APAdjust, APInvoice>(adj, doc);
                if (_copies.ContainsKey(adj))
                {
                    _copies.Remove(adj);
                }
                _copies.Add(adj, PXCache<APAdjust>.CreateCopy(adj));
            }

            PXSelectBase<APInvoice> cmd = ComposeBQLCommandForAPDocumentListSelect();

            int startRow = PXView.StartRow;
            int totalRows = 0;

            APDocumentListViewExecuteParamsBuilder.ViewExecutingParams viewExecutingParams =
                new APDocumentListViewExecuteParamsBuilder()
                    .BuildViewExecutingParams(APDocumentList.View);

            foreach (PXResult<APInvoice, CurrencyInfo> res in
                cmd.View.Select(new[] { filter },
                                ComposeParametersForAPDocumentListSelect(),
                                PXView.Searches,
                                viewExecutingParams.Sorts.ToArray(),
                                viewExecutingParams.Descendings.ToArray(),
                                viewExecutingParams.FilterRows.ToArray(),
                                ref startRow,
                                PXView.MaximumRows,
                                ref totalRows))
            {
                APInvoice doc = res;
                APAdjust adj = new APAdjust();
                adj.VendorID = doc.VendorID;
                adj.AdjdDocType = doc.DocType;
                adj.AdjdRefNbr = doc.RefNbr;
                adj.AdjgDocType = APDocType.Check;
                adj.AdjgRefNbr = AutoNumberAttribute.GetNewNumberSymbol<APPayment.refNbr>(Caches[typeof(APPayment)], new APPayment { DocType = APDocType.Check });
                adj.SeparateCheck = doc.SeparateCheck;

                if (APDocumentList.Locate(adj) == null)
                {
                    PXSelectJoin<APInvoice, InnerJoin<CurrencyInfo, On<CurrencyInfo.curyInfoID, Equal<APInvoice.curyInfoID>>>, Where<APInvoice.docType, Equal<Required<APInvoice.docType>>, And<APInvoice.refNbr, Equal<Required<APInvoice.refNbr>>>>>.StoreCached(this, new PXCommandKey(new object[] { adj.AdjdDocType, adj.AdjdRefNbr }), new List<object> { res });
                    PXSelectorAttribute.StoreCached<APAdjust.adjdRefNbr>(APDocumentList.Cache, adj, doc);
                    yield return new PXResult<APAdjust, APInvoice>(APDocumentList.Insert(adj), doc);

                    _copies.Add(adj, PXCache<APAdjust>.CreateCopy(adj));
                }
            }

            APDocumentList.Cache.IsDirty = false;
            APDocumentList.View.RequestRefresh();
        }

当显式定义委托时(例如本例),屏幕中填充的信息就是委托中定义的信息.

When a delegate is explicitly defined (such as this case), the information populated in the screen is the one defined in the delegate.

在这种情况下,此条件是在输入过滤器参数之前不会填充网格的条件:

In this case, this condition is the one that does not populate the grid until the filter parameters are entered:

if (filter?.PayDate == null || filter.PayTypeID == null || filter.PayAccountID == null)
                    yield break;

在您的情况下,您还需要覆盖委托.

In your case, you need to override the delegate as well.

注意:这是 2018R2 的视图和委托定义.其他版本可能有所不同.请确保使用适用于您的版本的那个.

Note: this is the view and delegate definition for 2018R2. Other versions may differ. Make sure you use the one that applies for your version.

这篇关于如何在图形扩展中覆盖 PXFilteredProcessingJoin 而不改变基本图形的行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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