Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
455 views
in Technique[技术] by (71.8m points)

acumatica - Overriding PXFilteredProcessingJoin and delegate for APPrintChecks

I have the same issue as the below link but with a different graph (APPrintChecks)

how-do-i-override-pxfilteredprocessingjoin-in-a-graph-extension-without-altering

I am overriding the main view to pull in the remittance name from APContact to show in the grid.

[PXFilterable]
public PXFilteredProcessingJoin<APPayment, PrintChecksFilter,
  InnerJoin<Vendor, On<Vendor.bAccountID, Equal<APPayment.vendorID>>,
  InnerJoin<APContact, On<APContact.contactID, Equal<APPayment.remitContactID>>>>,
  Where<boolTrue, Equal<boolTrue>>,
  OrderBy<Asc<Vendor.acctName, Asc<APPayment.refNbr>>>> APPaymentList;

However, I do not know how to override the delegate so I won't have the same problem as the other poster (no filter being applied).

protected virtual IEnumerable appaymentlist()
    {
        if (cleared)
        {
            foreach (APPayment doc in APPaymentList.Cache.Updated)
            {
                doc.Passed = false;
            }
        }

        foreach (PXResult<APPayment, Vendor, PaymentMethod, CABatchDetail> doc in PXSelectJoin<APPayment,
            InnerJoinSingleTable<Vendor, On<Vendor.bAccountID, Equal<APPayment.vendorID>>,
            InnerJoin<PaymentMethod, On<PaymentMethod.paymentMethodID, Equal<APPayment.paymentMethodID>>,
            LeftJoin<CABatchDetail, On<CABatchDetail.origModule, Equal<BatchModule.moduleAP>,
                    And<CABatchDetail.origDocType, Equal<APPayment.docType>,
                    And<CABatchDetail.origRefNbr, Equal<APPayment.refNbr>>>>>>>,
            Where2<Where<APPayment.status, Equal<APDocStatus.pendingPrint>,
                And<CABatchDetail.batchNbr, IsNull,
                And<APPayment.cashAccountID, Equal<Current<PrintChecksFilter.payAccountID>>,
                And<APPayment.paymentMethodID, Equal<Current<PrintChecksFilter.payTypeID>>,
                And<Match<Vendor, Current<AccessInfo.userName>>>>>>>,
                And<APPayment.docType, In3<APDocType.check, APDocType.prepayment, APDocType.quickCheck>>>>.Select(this))
        {
            yield return new PXResult<APPayment, Vendor>(doc, doc);
            if (_copies.ContainsKey((APPayment)doc))
            {
                _copies.Remove((APPayment)doc);
            }
            _copies.Add((APPayment)doc, PXCache<APPayment>.CreateCopy(doc));
        }
    }

There are other private variables that are referenced in this. Any help appreciated.

Also, if there's a simpler way to pull in a related value on a grid like this (virtual field in DAC?) I'm not stuck on doing it with a graph extension.

question from:https://stackoverflow.com/questions/65945798/overriding-pxfilteredprocessingjoin-and-delegate-for-apprintchecks

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So this appears to work but it seems messy and duplicates a lot of code and private variables. Appreciate any feedback if there's a better way to do this:

 public class APPrintChecks_Extension : PXGraphExtension<APPrintChecks> {

[PXFilterable]
public PXFilteredProcessingJoin<APPayment, PrintChecksFilter,
  InnerJoin<Vendor, On<Vendor.bAccountID, Equal<APPayment.vendorID>>,
  InnerJoin<APContact, On<APContact.contactID, Equal<APPayment.remitContactID>>>>,
  Where<boolTrue, Equal<boolTrue>>,
  OrderBy<Asc<Vendor.acctName, Asc<APPayment.refNbr>>>> APPaymentList;


    public IEnumerable appaymentlist()
    {
      
      if (cleared)
      {
        foreach (APPayment doc in APPaymentList.Cache.Updated)
        {
          doc.Passed = false;
        }
      }

      foreach (PXResult<APPayment, Vendor, APContact, PaymentMethod, CABatchDetail> doc in PXSelectJoin<APPayment,
        InnerJoinSingleTable<Vendor, On<Vendor.bAccountID, Equal<APPayment.vendorID>>,
        InnerJoin<APContact, On<APContact.contactID, Equal<APPayment.remitContactID>>,
        InnerJoin<PaymentMethod, On<PaymentMethod.paymentMethodID, Equal<APPayment.paymentMethodID>>,
         LeftJoin<CABatchDetail, On<CABatchDetail.origModule, Equal<BatchModule.moduleAP>,
            And<CABatchDetail.origDocType, Equal<APPayment.docType>,
            And<CABatchDetail.origRefNbr, Equal<APPayment.refNbr>>>>>>>>,
        Where2<Where<APPayment.status, Equal<APDocStatus.pendingPrint>,
          And<CABatchDetail.batchNbr, IsNull,
          And<APPayment.cashAccountID, Equal<Current<PrintChecksFilter.payAccountID>>,
          And<APPayment.paymentMethodID, Equal<Current<PrintChecksFilter.payTypeID>>,
          And<Match<Vendor, Current<AccessInfo.userName>>>>>>>,
          And<APPayment.docType, In3<APDocType.check, APDocType.prepayment, APDocType.quickCheck>>>>.Select(Base))
      {
        yield return new PXResult<APPayment, Vendor, APContact>(doc, doc, doc);
        if (_copies.ContainsKey((APPayment)doc))
        {
          _copies.Remove((APPayment)doc);
        }
        _copies.Add((APPayment)doc, PXCache<APPayment>.CreateCopy(doc));
      }
    }
    
    private bool cleared;
    public void Clear()
    {
      Base.Filter.Current.CurySelTotal = 0m;
      Base.Filter.Current.SelTotal = 0m;
      Base.Filter.Current.SelCount = 0;
      cleared = true;
      Base.Clear();
    }

    private readonly Dictionary<object, object> _copies = new Dictionary<object, object>();

}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...