public static List <ARCashSale> Process(List <ARCashSale> list, bool isMassProcess) { List <ARCashSale> listWithTax = new List <ARCashSale>(list.Count); ARCashSaleEntry rg = PXGraph.CreateInstance <ARCashSaleEntry>(); for (int i = 0; i < list.Count; i++) { try { rg.Clear(); rg.Document.Current = PXSelect <ARCashSale, Where <ARCashSale.docType, Equal <Required <ARCashSale.docType> >, And <ARCashSale.refNbr, Equal <Required <ARCashSale.refNbr> > > > > .Select(rg, list[i].DocType, list[i].RefNbr); listWithTax.Add(rg.CalculateExternalTax(rg.Document.Current)); PXProcessing <ARCashSale> .SetInfo(i, ActionsMessages.RecordProcessed); } catch (Exception e) { if (isMassProcess) { PXProcessing <ARCashSale> .SetError(i, e is PXOuterException?e.Message + "\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages) : e.Message); } else { throw new PXMassProcessException(i, e); } } } return(listWithTax); }
private static PXGraph PrepareDestinationGraphForAR(string origDocType, string origRefNbr) { switch (origDocType) { case ARDocType.Invoice: case ARDocType.DebitMemo: return(MakeDestinationGraph <ARInvoiceEntry, ARInvoice, ARInvoice.docType, ARInvoice.refNbr>(origDocType, origRefNbr)); case ARDocType.CashSale: case ARDocType.CashReturn: ARCashSaleEntry arCashSalesGraph = PXGraph.CreateInstance <ARCashSaleEntry>(); ARCashSale origCashSale = GetOriginalDocument <ARCashSale, ARCashSale.docType, ARCashSale.refNbr>(arCashSalesGraph, origDocType, origRefNbr); if (origCashSale?.OrigModule == BatchModule.SO && origCashSale.Released == false) { return(MakeDestinationGraph <SO.SOInvoiceEntry, ARInvoice, ARInvoice.docType, ARInvoice.refNbr>(origDocType, origRefNbr)); } arCashSalesGraph.Document.Current = origCashSale; return(arCashSalesGraph); case ARDocType.Payment: case ARDocType.CreditMemo: case ARDocType.Prepayment: case ARDocType.Refund: case ARDocType.VoidRefund: case ARDocType.VoidPayment: case ARDocType.SmallBalanceWO: return(MakeDestinationGraph <ARPaymentEntry, ARPayment, ARPayment.docType, ARPayment.refNbr>(origDocType, origRefNbr)); default: return(null); } }
public static ARCashSale Process(ARCashSaleEntry ie) { if (ie != null) { List <ARCashSale> list = new List <ARCashSale>(); list.Add(ie.Document.Current); List <ARCashSale> listWithTax = Process(list, false); return(listWithTax[0]); } return(null); }
protected virtual void RedirectToDoc(string aDocType, string aRefNbr) { Dictionary <string, string> alltypes = new ARDocType.ListAttribute().ValueLabelDic; if (new ARInvoiceType.ListAttribute().ValueLabelDic.ContainsKey(aDocType)) { ARInvoice doc = ARDocumentEnq.FindDoc <ARInvoice>(this, aDocType, aRefNbr); if (doc != null) { ARInvoiceEntry graph = PXGraph.CreateInstance <ARInvoiceEntry>(); graph.Document.Current = doc; throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } throw new PXException(Messages.DocumentNotFound, alltypes[aDocType], aRefNbr); } if (new ARPaymentType.ListAttribute().ValueLabelDic.ContainsKey(aDocType)) { ARPayment doc = ARDocumentEnq.FindDoc <ARPayment>(this, aDocType, aRefNbr); if (doc != null) { ARPaymentEntry graph = PXGraph.CreateInstance <ARPaymentEntry>(); graph.Document.Current = doc; throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } throw new PXException(Messages.DocumentNotFound, alltypes[aDocType], aRefNbr); } if (new ARCashSaleType.ListAttribute().ValueLabelDic.ContainsKey(aDocType)) { ARCashSale doc = ARDocumentEnq.FindDoc <ARCashSale>(this, aDocType, aRefNbr); if (doc != null) { ARCashSaleEntry graph = PXGraph.CreateInstance <ARCashSaleEntry>(); graph.Document.Current = doc; throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } throw new PXException(Messages.DocumentNotFound, alltypes[aDocType], aRefNbr); } throw new PXException(Messages.UnknownDocumentType); }
public static PXGraph FindSourceDocumentGraph(CCProcTran tran) { PXGraph target = null; if (tran != null) { if (tran.DocType == ARDocType.CashSale || tran.DocType == ARDocType.Payment) { if (tran.DocType == ARDocType.Payment) { ARPaymentEntry graph = PXGraph.CreateInstance <ARPaymentEntry>(); graph.Document.Current = graph.Document.Search <ARPayment.refNbr>(tran.RefNbr, tran.DocType); if (graph.Document.Current != null) { target = graph; } } if (tran.DocType == ARDocType.Payment) { ARCashSaleEntry graph = PXGraph.CreateInstance <ARCashSaleEntry>(); graph.Document.Current = graph.Document.Search <PX.Objects.AR.Standalone.ARCashSale.refNbr>(tran.RefNbr, tran.DocType); if (graph.Document.Current != null) { target = graph; } } } if (tran.DocType == ARDocType.Invoice) { SO.SOInvoiceEntry graph = PXGraph.CreateInstance <SO.SOInvoiceEntry>(); graph.Document.Current = graph.Document.Search <ARInvoice.refNbr>(tran.RefNbr, tran.DocType); if (graph.Document.Current != null) { target = graph; } } if (target == null && !String.IsNullOrEmpty(tran.OrigRefNbr)) { SO.SOOrderEntry graph = PXGraph.CreateInstance <SO.SOOrderEntry>(); graph.Document.Current = graph.Document.Search <SO.SOOrder.orderNbr>(tran.OrigRefNbr, tran.OrigDocType); if (graph.Document.Current != null) { target = graph; } } } return(target); }
public static PXGraph FindSourceDocumentGraph(string docType, string refNbr, string origDocType, string origRefNbr) { PXGraph target = null; if (docType == ARDocType.Payment || docType == ARDocType.VoidPayment) { ARPaymentEntry graph = PXGraph.CreateInstance <ARPaymentEntry>(); graph.Document.Current = graph.Document.Search <ARPayment.refNbr>(refNbr, docType); if (graph.Document.Current != null) { target = graph; } } if (docType == ARDocType.CashSale) { ARCashSaleEntry graph = PXGraph.CreateInstance <ARCashSaleEntry>(); graph.Document.Current = graph.Document.Search <Standalone.ARCashSale.refNbr>(refNbr, docType); if (graph.Document.Current != null) { target = graph; } } if (docType == ARDocType.Invoice) { SO.SOInvoiceEntry graph = PXGraph.CreateInstance <SO.SOInvoiceEntry>(); graph.Document.Current = graph.Document.Search <ARInvoice.refNbr>(refNbr, docType); if (graph.Document.Current != null) { target = graph; } } if (target == null && !string.IsNullOrEmpty(origRefNbr)) { SO.SOOrderEntry graph = PXGraph.CreateInstance <SO.SOOrderEntry>(); graph.Document.Current = graph.Document.Search <SO.SOOrder.orderNbr>(origRefNbr, origDocType); if (graph.Document.Current != null) { target = graph; } } return(target); }
public static void ReleaseARDocument(IBqlTable aTable, CCTranType procTran, bool success) { AR.ARRegister doc = aTable as AR.ARRegister; if (doc != null && success) { ExternalTransaction tran = null; PXGraph graph = null; if (doc.DocType == ARDocType.CashSale || doc.DocType == ARDocType.CashReturn) { ARCashSaleEntry cashSaleGraph = PXGraph.CreateInstance <ARCashSaleEntry>(); cashSaleGraph.Document.Current = PXSelect <ARCashSale, Where <ARCashSale.docType, Equal <Required <ARCashSale.docType> >, And <ARCashSale.refNbr, Equal <Required <ARCashSale.refNbr> > > > > .SelectWindowed(cashSaleGraph, 0, 1, doc.DocType, doc.RefNbr); tran = cashSaleGraph.ExternalTran.SelectSingle(doc.DocType, doc.RefNbr); graph = cashSaleGraph; } else { ARPaymentEntry paymentGraph = PXGraph.CreateInstance <ARPaymentEntry>(); paymentGraph.Document.Current = PXSelect <AR.ARPayment, Where <AR.ARPayment.docType, Equal <Required <AR.ARPayment.docType> >, And <AR.ARPayment.refNbr, Equal <Required <AR.ARPayment.refNbr> > > > > .SelectWindowed(paymentGraph, 0, 1, doc.DocType, doc.RefNbr); tran = paymentGraph.ExternalTran.SelectSingle(doc.DocType, doc.RefNbr); graph = paymentGraph; } if (tran != null) { ExternalTransactionState state = ExternalTranHelper.GetTransactionState(graph, tran); if (!state.IsDeclined && !state.IsOpenForReview) { ReleaseARDocument(aTable); } } } }
public static void ValidateCCPayment(PXGraph graph, List <IExternalTransaction> list, bool isMassProcess) { bool failed = false; ARCashSaleEntry arCashSaleGraph = null; ARPaymentEntry arPaymentGraph = null; SOInvoiceEntry soInvoiceGraph = null; for (int i = 0; i < list.Count; i++) { if (list[i] == null) { continue; } if ((i % 100) == 0) { if (arCashSaleGraph != null) { arCashSaleGraph.Clear(); } if (arPaymentGraph != null) { arPaymentGraph.Clear(); } if (soInvoiceGraph != null) { soInvoiceGraph.Clear(); } } IExternalTransaction tran = list[i]; var resultSet = PXSelectJoin <Standalone.ARRegister, LeftJoin <ARPayment, On <ARPayment.refNbr, Equal <Standalone.ARRegister.refNbr>, And <ARPayment.docType, Equal <Standalone.ARRegister.docType> > >, LeftJoin <ARInvoice, On <ARInvoice.refNbr, Equal <Standalone.ARRegister.refNbr>, And <ARInvoice.docType, Equal <Standalone.ARRegister.docType> > >, LeftJoin <SOInvoice, On <SOInvoice.refNbr, Equal <Standalone.ARRegister.refNbr>, And <SOInvoice.docType, Equal <Standalone.ARRegister.docType> > >, LeftJoin <Standalone.ARCashSale, On <Standalone.ARCashSale.refNbr, Equal <Standalone.ARRegister.refNbr>, And <Standalone.ARCashSale.docType, Equal <Standalone.ARRegister.docType> > > > > > >, Where <Standalone.ARRegister.refNbr, Equal <Required <Standalone.ARRegister.refNbr> >, And <Standalone.ARRegister.docType, Equal <Required <Standalone.ARRegister.docType> > > > > .SelectSingleBound(graph, null, tran.RefNbr, tran.DocType); foreach (PXResult <Standalone.ARRegister, ARPayment, ARInvoice, SOInvoice, Standalone.ARCashSale> arDoc in resultSet) { if (arDoc == null) { continue; } try { if ((ARInvoice)arDoc is ARInvoice arInvoice && arInvoice != null && arInvoice.RefNbr != null) { if ((SOInvoice)arDoc is SOInvoice soInvoice && soInvoice != null && soInvoice.RefNbr != null) { soInvoiceGraph = soInvoiceGraph != null ? soInvoiceGraph : PXGraph.CreateInstance <SOInvoiceEntry>(); SOInvoiceEntry.PaymentTransaction ext = soInvoiceGraph.GetExtension <SOInvoiceEntry.PaymentTransaction>(); soInvoiceGraph.Document.Current = arInvoice; soInvoiceGraph.SODocument.Current = soInvoice; if (ext.CanValidate(arInvoice)) { ext.validateCCPayment.Press(); } } else if ((Standalone.ARCashSale)arDoc is Standalone.ARCashSale arCashSale && arCashSale != null && arCashSale.RefNbr != null) { arCashSaleGraph = arCashSaleGraph != null ? arCashSaleGraph : PXGraph.CreateInstance <ARCashSaleEntry>(); ARCashSaleEntry.PaymentTransaction ext = arCashSaleGraph.GetExtension <ARCashSaleEntry.PaymentTransaction>(); arCashSaleGraph.Document.Current = arCashSale; if (ext.CanValidate(arCashSaleGraph.Document.Current)) { ext.validateCCPayment.Press(); } } }
public static void Redirect(PXCache sender, CATran catran) { if (catran == null) { return; } if (catran.OrigTranType == CAAPARTranType.GLEntry) { JournalEntry graph = PXGraph.CreateInstance <JournalEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.BatchModule.Current = PXSelect <Batch, Where <Batch.module, Equal <Required <Batch.module> >, And <Batch.batchNbr, Equal <Required <Batch.batchNbr> > > > > .Select(graph, catran.OrigModule, catran.OrigRefNbr); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.AP && (catran.OrigTranType == AP.APDocType.QuickCheck || catran.OrigTranType == AP.APDocType.VoidQuickCheck)) { APQuickCheckEntry graph = PXGraph.CreateInstance <APQuickCheckEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = PXSelect <APQuickCheck, Where <APQuickCheck.refNbr, Equal <Required <APQuickCheck.refNbr> >, And <APQuickCheck.docType, Equal <Required <APQuickCheck.docType> > > > > .Select(graph, catran.OrigRefNbr, catran.OrigTranType); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.AP && catran.OrigTranType == CATranType.CABatch) { CABatchEntry graph = PXGraph.CreateInstance <CABatchEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = PXSelect <CABatch, Where <CABatch.batchNbr, Equal <Required <CATran.origRefNbr> > > > .Select(graph, catran.OrigRefNbr); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.AP) { APPaymentEntry graph = PXGraph.CreateInstance <APPaymentEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = (APPayment)PXSelect <APPayment, Where <APPayment.refNbr, Equal <Required <APPayment.refNbr> >, And <APPayment.docType, Equal <Required <APPayment.docType> > > > > .Select(graph, catran.OrigRefNbr, catran.OrigTranType); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.AR && (catran.OrigTranType == ARDocType.CashSale || catran.OrigTranType == ARDocType.CashReturn)) { ARCashSale document = (ARCashSale)PXSelect <ARCashSale, Where <ARCashSale.refNbr, Equal <Required <ARCashSale.refNbr> >, And <ARCashSale.docType, Equal <Required <ARCashSale.docType> > > > > .Select(sender.Graph, catran.OrigRefNbr, catran.OrigTranType); if (document.OrigModule == BatchModule.SO && document.Released == false) { SO.SOInvoiceEntry graph = PXGraph.CreateInstance <SO.SOInvoiceEntry>(); graph.Clear(); sender.IsDirty = false; graph.Document.Current = (ARInvoice)PXSelect <ARInvoice, Where <ARInvoice.refNbr, Equal <Required <ARInvoice.refNbr> >, And <ARInvoice.docType, Equal <Required <ARInvoice.docType> > > > > .Select(sender.Graph, catran.OrigRefNbr, catran.OrigTranType); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else { ARCashSaleEntry graph = PXGraph.CreateInstance <ARCashSaleEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = document; throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } else if (catran.OrigModule == GL.BatchModule.AR) { ARPaymentEntry graph = PXGraph.CreateInstance <ARPaymentEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = (ARPayment)PXSelect <ARPayment, Where <ARPayment.refNbr, Equal <Required <ARPayment.refNbr> >, And <ARPayment.docType, Equal <Required <ARPayment.docType> > > > > .Select(graph, catran.OrigRefNbr, catran.OrigTranType); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.CA && catran.OrigTranType == CATranType.CAAdjustment) { CATranEntry graph = PXGraph.CreateInstance <CATranEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.CAAdjRecords.Current = PXSelect <CAAdj, Where <CAAdj.tranID, Equal <Required <CAAdj.tranID> > > > .Select(graph, catran.TranID); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.CA && catran.OrigTranType == CATranType.CATransferExp) { CATranEntry graph = PXGraph.CreateInstance <CATranEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.CAAdjRecords.Current = PXSelect <CAAdj, Where <CAAdj.adjTranType, Equal <CAAPARTranType.cATransferExp>, And <CAAdj.transferNbr, Equal <Required <CATran.origRefNbr> > > > > .Select(graph, catran.OrigRefNbr); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (catran.OrigModule == GL.BatchModule.CA) { if (catran.OrigTranType == CATranType.CADeposit || catran.OrigTranType == CATranType.CAVoidDeposit) { CADepositEntry graph = PXGraph.CreateInstance <CADepositEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Document.Current = PXSelect <CADeposit, Where <CADeposit.tranType, Equal <Required <CADeposit.tranType> >, And <CADeposit.refNbr, Equal <Required <CADeposit.refNbr> > > > > .Select(graph, catran.OrigTranType, catran.OrigRefNbr); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else { CashTransferEntry graph = PXGraph.CreateInstance <CashTransferEntry>(); graph.Clear(); if (sender != null) { sender.IsDirty = false; } graph.Transfer.Current = PXSelect <CATransfer, Where <CATransfer.tranIDOut, Equal <Required <CATransfer.tranIDOut> >, Or <CATransfer.tranIDIn, Equal <Required <CATransfer.tranIDIn> > > > > .Select(graph, catran.TranID, catran.TranID); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } }