public virtual IEnumerable ViewDoc(PXAdapter adapter)
        {
            CABankTranMatch match =
                PXSelect <CABankTranMatch,
                          Where <CABankTranMatch.tranID, Equal <Required <CABankTran.tranID> >,
                                 And <CABankTranMatch.tranType, Equal <Required <CABankTran.tranType> > > > >
                .Select(this, Result.Current.TranID, Result.Current.TranType);

            if (match.DocModule == BatchModule.EP)
            {
                RedirectionToOrigDoc.TryRedirect(match.DocType, match.DocRefNbr, match.DocModule);
            }
            else
            {
                CATran tran = null;
                if (match.DocModule == BatchModule.AP && match.DocType == CATranType.CABatch)
                {
                    tran = new CATran()
                    {
                        OrigTranType = CATranType.CABatch,
                        OrigModule   = BatchModule.AP,
                        OrigRefNbr   = match.DocRefNbr
                    };
                }
                else
                {
                    tran = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CABankTranMatch.cATranID> > > > .Select(this, match.CATranID);
                }


                CATran.Redirect(TranFilter.Cache, tran);
            }
            return(adapter.Get());
        }
        protected virtual IEnumerable result()
        {
            PXSelectBase <CABankTran> cmd = new PXSelectJoin <CABankTran, LeftJoin <CABankTranMatch,
                                                                                    On <CABankTranMatch.tranID, Equal <CABankTran.tranID>,
                                                                                        And <CABankTranMatch.tranType, Equal <CABankTran.tranType> > >,
                                                                                    LeftJoin <CATran, On <CATran.tranID, Equal <CABankTranMatch.cATranID> > > >,
                                                              Where <CABankTran.cashAccountID, Equal <Current <Filter.cashAccountID> >,
                                                                     And <CABankTran.tranDate, GreaterEqual <Current <Filter.startDate> >,
                                                                          And <CABankTran.tranDate, LessEqual <Current <Filter.endDate> >,
                                                                               And <CABankTran.tranType, Equal <Current <Filter.tranType> >,
                                                                                    And <CABankTran.processed, Equal <True>,
                                                                                         And <Where <CABankTran.headerRefNbr, Equal <Current <Filter.headerRefNbr> >, Or <Current <Filter.headerRefNbr>, IsNull> > > > > > > > >(this);

            foreach (PXResult <CABankTran, CABankTranMatch, CATran> res in cmd.Select())
            {
                CABankTran      tran  = (CABankTran)res;
                CABankTranMatch match = (CABankTranMatch)res;
                tran.MatchedToInvoice = CABankTranStatus.IsMatchedToInvoice(tran, match);
                CATran catran = (CATran)res;
                if (catran.OrigModule == null)
                {
                    catran.OrigModule = match.DocModule;
                }
                if (catran.OrigTranType == null)
                {
                    catran.OrigTranType = match.DocType;
                }
                if (catran.OrigRefNbr == null)
                {
                    catran.OrigRefNbr = match.DocRefNbr;
                }
                if (catran.ReferenceID == null)
                {
                    catran.ReferenceID = tran.BAccountID;
                }
                if (catran.OrigModule == null)
                {
                    catran.OrigModule = match.DocModule;
                }
                if (catran.OrigTranType == null)
                {
                    catran.OrigTranType = match.DocType;
                }
                if (catran.OrigRefNbr == null)
                {
                    catran.OrigRefNbr = match.DocRefNbr;
                }
                if (catran.ReferenceID == null)
                {
                    catran.ReferenceID = tran.BAccountID;
                }
                yield return(res);
            }
        }
        public virtual IEnumerable ViewDoc(PXAdapter adapter)
        {
            CABankTran detail = Details.Current;

            if (detail.DocumentMatched == true)
            {
                CABankTranMatch match = PXSelect <CABankTranMatch, Where <CABankTranMatch.tranID, Equal <Required <CABankTran.tranID> >, And <CABankTranMatch.tranType, Equal <Required <CABankTran.tranType> > > > > .Select(this, detail.TranID, detail.TranType);

                if (match != null)
                {
                    CABankTranMatch.Redirect(this, match);
                }
            }
            return(adapter.Get());
        }
        public static void Redirect(PXGraph graph, CABankTranMatch match)
        {
            if (match.DocModule == GL.BatchModule.AP && match.DocType == CATranType.CABatch && match.DocRefNbr != null)
            {
                CABatchEntry docGraph = PXGraph.CreateInstance <CABatchEntry>();
                docGraph.Clear();
                docGraph.Document.Current = PXSelect <CABatch, Where <CABatch.batchNbr, Equal <Required <CATran.origRefNbr> > > > .Select(docGraph, match.DocRefNbr);

                throw new PXRedirectRequiredException(docGraph, true, "Document")
                      {
                          Mode = PXBaseRedirectException.WindowMode.NewWindow
                      };
            }
            else if (match.CATranID != null)
            {
                CATran catran = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CABankTranMatch.cATranID> > > > .Select(graph, match.CATranID);

                CATran.Redirect(null, catran);
            }
            else if (match.DocModule != null && match.DocType != null && match.DocRefNbr != null)
            {
                if (match.DocModule == GL.BatchModule.AP)
                {
                    AP.APInvoiceEntry docGraph = PXGraph.CreateInstance <AP.APInvoiceEntry>();
                    docGraph.Clear();
                    AP.APInvoice invoice = PXSelect <AP.APInvoice, Where <AP.APInvoice.refNbr, Equal <Required <CABankTranMatch.docRefNbr> >, And <AP.APInvoice.docType, Equal <Required <CABankTranMatch.docType> > > > > .Select(docGraph, match.DocRefNbr, match.DocType);

                    docGraph.Document.Current = invoice;
                    throw new PXRedirectRequiredException(docGraph, true, "Document")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
                else if (match.DocModule == GL.BatchModule.AR)
                {
                    AR.ARInvoiceEntry docGraph = PXGraph.CreateInstance <AR.ARInvoiceEntry>();
                    docGraph.Clear();
                    AR.ARInvoice invoice = PXSelect <AR.ARInvoice, Where <AR.ARInvoice.refNbr, Equal <Required <CABankTranMatch.docRefNbr> >, And <AR.ARInvoice.docType, Equal <Required <CABankTranMatch.docType> > > > > .Select(docGraph, match.DocRefNbr, match.DocType);

                    docGraph.Document.Current = invoice;
                    throw new PXRedirectRequiredException(docGraph, true, "Document")
                          {
                              Mode = PXBaseRedirectException.WindowMode.NewWindow
                          };
                }
            }
        }