private static PXGraph PrepareDestinationGraphForCA(string origDocType, string origRefNbr) { switch (origDocType) { case CATranType.CAAdjustment: case CATranType.CAAdjustmentRGOL: CATranEntry caTranGraph = PXGraph.CreateInstance <CATranEntry>(); caTranGraph.CAAdjRecords.Current = origDocType == CATranType.CATransferExp ? GetOriginalDocument <CAAdj, CAAdj.adjTranType, CAAdj.transferNbr>(caTranGraph, origDocType, origRefNbr) : GetOriginalDocument <CAAdj, CAAdj.adjTranType, CAAdj.adjRefNbr>(caTranGraph, origDocType, origRefNbr); return(caTranGraph); case CATranType.CADeposit: case CATranType.CAVoidDeposit: return(MakeDestinationGraph <CADepositEntry, CADeposit, CADeposit.tranType, CADeposit.refNbr>(origDocType, origRefNbr)); case CATranType.CATransferIn: case CATranType.CATransferOut: case CATranType.CATransferExp: case CATranType.CATransferRGOL: CashTransferEntry cashTransferGraph = PXGraph.CreateInstance <CashTransferEntry>(); cashTransferGraph.Transfer.Current = PXSelect <CATransfer, Where <CATransfer.transferNbr, Equal <Required <CATransfer.transferNbr> > > > .Select(cashTransferGraph, origRefNbr); return(cashTransferGraph); default: return(null); } }
public static List <CAAdj> Process(List <CAAdj> list, bool isMassProcess) { List <CAAdj> listWithTax = new List <CAAdj>(list.Count); CATranEntry rg = PXGraph.CreateInstance <CATranEntry>(); for (int i = 0; i < list.Count; i++) { try { rg.Clear(); rg.CAAdjRecords.Current = PXSelect <CAAdj, Where <CAAdj.adjRefNbr, Equal <Required <CAAdj.adjRefNbr> > > > .Select(rg, list[i].AdjRefNbr); listWithTax.Add(rg.CalculateAvalaraTax(rg.CAAdjRecords.Current)); PXProcessing <CAAdj> .SetInfo(i, ActionsMessages.RecordProcessed); } catch (Exception e) { if (isMassProcess) { PXProcessing <CAAdj> .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); }
public virtual IEnumerable ViewDocument(PXAdapter adapter) { Document doc = Items.Current; if (doc != null && !String.IsNullOrEmpty(doc.Module) && !String.IsNullOrEmpty(doc.DocType) && !String.IsNullOrEmpty(doc.RefNbr)) { switch (doc.Module) { case GL.BatchModule.AR: ARInvoiceEntry argraph = PXGraph.CreateInstance <ARInvoiceEntry>(); argraph.Document.Current = argraph.Document.Search <ARInvoice.refNbr>(doc.RefNbr, doc.DocType); if (argraph.Document.Current != null) { throw new PXRedirectRequiredException(argraph, true, "View Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } break; case GL.BatchModule.AP: APInvoiceEntry apgraph = PXGraph.CreateInstance <APInvoiceEntry>(); apgraph.Document.Current = apgraph.Document.Search <APInvoice.refNbr>(doc.RefNbr, doc.DocType); if (apgraph.Document.Current != null) { throw new PXRedirectRequiredException(apgraph, true, "View Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } break; case GL.BatchModule.CA: CATranEntry cagraph = PXGraph.CreateInstance <CATranEntry>(); cagraph.CAAdjRecords.Current = cagraph.CAAdjRecords.Search <CAAdj.adjRefNbr>(doc.RefNbr, doc.DocType); if (cagraph.CAAdjRecords.Current != null) { throw new PXRedirectRequiredException(cagraph, true, "View Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } break; } } return(adapter.Get()); }
public override void Persist() { using (new PXConnectionScope()) { using (PXTransactionScope ts = new PXTransactionScope()) { List <CATran> deleted = new List <CATran>(); RowPersisting.AddHandler <CATran>((sender, e) => { if (deleted.Contains((CATran)e.Row)) { e.Cancel = true; } }); CATranEntry graph = null; foreach (CATran catran in TransferTran.Cache.Deleted) { if (graph == null) { graph = PXGraph.CreateInstance <CATranEntry>(); } CAAdj adj = PXSelect <CAAdj, Where <CAAdj.tranID, Equal <Required <CAAdj.tranID> > > > .Select(graph, catran.TranID); if (adj != null) { graph.TimeStamp = TimeStamp; graph.CAAdjRecords.Delete(adj); graph.Save.Press(); graph.Clear(); deleted.Add(catran); } } base.Persist(); ts.Complete(); foreach (CATran catran in deleted) { TransferTran.Cache.Remove(catran); } deleted.Clear(); } } //Current should be the only one inserted PXCache currencycache = Caches[typeof(CM.CurrencyInfo)]; currencycache.SetStatus(currencycache.Current, PXEntryStatus.Inserted); }
public virtual IEnumerable viewDoc(PXAdapter adapter) { if (Expenses.Current.AdjRefNbr != null) { CATranEntry graph = PXGraph.CreateInstance <CATranEntry>(); graph.Clear(); Transfer.Cache.IsDirty = false; CAAdj adj = PXSelect <CAAdj, Where <CAAdj.adjRefNbr, Equal <Required <CAExpense.adjRefNbr> > > > .Select(this, Expenses.Current.AdjRefNbr); graph.CAAdjRecords.Current = adj; throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } return(adapter.Get()); }
public virtual IEnumerable viewDoc(PXAdapter adapter) { CATran catran = (CATran)(TransferTran.Current); if (catran != null) { CATranEntry graph = PXGraph.CreateInstance <CATranEntry>(); graph.Clear(); Transfer.Cache.IsDirty = false; graph.CAAdjRecords.Current = PXSelect <CAAdj, Where <CAAdj.tranID, Equal <Required <CATran.tranID> > > > .Select(this, catran.TranID); throw new PXRedirectRequiredException(graph, true, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } return(adapter.Get()); }
public override void Persist() { using (PXTransactionScope ts = new PXTransactionScope()) { List <CATran> deleted = new List <CATran>(); RowPersisting.AddHandler <CATran>((sender, e) => { if (deleted.Contains((CATran)e.Row)) { e.Cancel = true; } }); CATranEntry graph = null; foreach (CATran catran in TransferTran.Cache.Deleted) { if (graph == null) { graph = PXGraph.CreateInstance <CATranEntry>(); } CAAdj adj = PXSelect <CAAdj, Where <CAAdj.tranID, Equal <Required <CAAdj.tranID> > > > .Select(graph, catran.TranID); if (adj != null) { graph.TimeStamp = TimeStamp; graph.CAAdjRecords.Delete(adj); graph.Save.Press(); graph.Clear(); deleted.Add(catran); } } base.Persist(); ts.Complete(); foreach (CATran catran in deleted) { TransferTran.Cache.Remove(catran); } deleted.Clear(); } }
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 }; } } }
public static void InitBackwardEditorHandlers(CATranEntry graph) { graph.RowPersisting.AddHandler <CAAdj>(CAExpenseHelper.CAAdj_RowPersisting); graph.RowPersisting.AddHandler <CASplit>(CAExpenseHelper.CASplit_RowPersisting); }
private static void Validate(CATranEntry te, CashAccount tlist) { if (tlist.Reconcile != true) { te.Clear(); using (new PXConnectionScope()) { using (PXTransactionScope ts = new PXTransactionScope()) { PXCache adjcache = te.Caches[typeof(CATran)]; foreach (CATran catran in PXSelect <CATran, Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> > > > .Select(te, tlist.CashAccountID)) { if (tlist.Reconcile != true && (catran.Cleared != true || catran.TranDate == null)) { catran.Cleared = true; catran.ClearDate = catran.TranDate; } te.catrancache.Update(catran); } te.catrancache.Persist(PXDBOperation.Update); ts.Complete(te); } te.catrancache.Persisted(false); } } te.Clear(); using (new PXConnectionScope()) { PXCache adjcache = te.Caches[typeof(CAAdj)]; using (PXTransactionScope ts = new PXTransactionScope()) { foreach (PXResult <CAAdj, CATran> res in PXSelectJoin <CAAdj, LeftJoin <CATran, On <CATran.tranID, Equal <CAAdj.tranID> > >, Where <CAAdj.cashAccountID, Equal <Required <CAAdj.cashAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID)) { CAAdj caadj = (CAAdj)res; adjcache.SetValue <CAAdj.tranID>(caadj, null); adjcache.SetValue <CAAdj.cleared>(caadj, false); CATran catran = AdjCashTranIDAttribute.DefaultValues <CAAdj.tranID>(adjcache, caadj); if (catran != null) { catran = (CATran)te.catrancache.Insert(catran); te.catrancache.PersistInserted(catran); long id = Convert.ToInt64(PXDatabase.SelectIdentity()); adjcache.SetValue <CAAdj.tranID>(caadj, id); adjcache.Update(caadj); } } adjcache.Persist(PXDBOperation.Update); ts.Complete(te); } adjcache.Persisted(false); te.catrancache.Persisted(false); } te.Clear(); using (new PXConnectionScope()) { PXCache transfercache = te.Caches[typeof(CATransfer)]; using (PXTransactionScope ts = new PXTransactionScope()) { foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDIn> > >, Where <CATransfer.inAccountID, Equal <Required <CATransfer.inAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID)) { CATransfer catransfer = (CATransfer)res; transfercache.SetValue <CATransfer.tranIDIn>(catransfer, null); transfercache.SetValue <CATransfer.clearedIn>(catransfer, false); if (transfercache.GetValue <CATransfer.clearedOut>(catransfer) == null) { transfercache.SetValue <CATransfer.clearedOut>(catransfer, false); } CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDIn>(transfercache, catransfer); if (catran != null) { catran = (CATran)te.catrancache.Insert(catran); te.catrancache.PersistInserted(catran); long id = Convert.ToInt64(PXDatabase.SelectIdentity()); transfercache.SetValue <CATransfer.tranIDIn>(catransfer, id); transfercache.Update(catransfer); } } foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDOut> > >, Where <CATransfer.outAccountID, Equal <Required <CATransfer.outAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID)) { CATransfer catransfer = (CATransfer)res; transfercache.SetValue <CATransfer.tranIDOut>(catransfer, null); transfercache.SetValue <CATransfer.clearedOut>(catransfer, false); if (transfercache.GetValue <CATransfer.clearedIn>(catransfer) == null) { transfercache.SetValue <CATransfer.clearedIn>(catransfer, false); } CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDOut>(transfercache, catransfer); if (catran != null) { catran = (CATran)te.catrancache.Insert(catran); te.catrancache.PersistInserted(catran); long id = Convert.ToInt64(PXDatabase.SelectIdentity()); transfercache.SetValue <CATransfer.tranIDOut>(catransfer, id); transfercache.Update(catransfer); } } transfercache.Persist(PXDBOperation.Update); ts.Complete(te); } transfercache.Persisted(false); te.catrancache.Persisted(false); } te.Clear(); PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.module>(te.Caches[typeof(GLTran)], null, false); PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.batchNbr>(te.Caches[typeof(GLTran)], null, false); PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.ledgerID>(te.Caches[typeof(GLTran)], null, false); PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.finPeriodID>(te.Caches[typeof(GLTran)], null, false); using (new PXConnectionScope()) { using (PXTransactionScope ts = new PXTransactionScope()) { foreach (PXResult <GLTran, Ledger, Batch> res in PXSelectJoin <GLTran, InnerJoin <Ledger, On <Ledger.ledgerID, Equal <GLTran.ledgerID> >, InnerJoin <Batch, On <Batch.module, Equal <GLTran.module>, And <Batch.batchNbr, Equal <GLTran.batchNbr>, And <Batch.scheduled, Equal <False> > > > > >, Where <GLTran.accountID, Equal <Required <GLTran.accountID> >, And <GLTran.subID, Equal <Required <GLTran.subID> >, And <Ledger.balanceType, Equal <LedgerBalanceType.actual>, And <GLTran.cATranID, IsNull> > > > > .Select(te, tlist.AccountID, tlist.SubID)) { GLTran gltran = (GLTran)res; CATran catran = GLCashTranIDAttribute.DefaultValues <GLTran.cATranID>(te.gltrancache, gltran); if (catran != null) { catran = (CATran)te.catrancache.Insert(catran); te.catrancache.PersistInserted(catran); long id = Convert.ToInt64(PXDatabase.SelectIdentity()); gltran.CATranID = id; te.gltrancache.Update(gltran); } } te.gltrancache.Persist(PXDBOperation.Update); te.dailycache.Clear(); PXDatabase.Delete <CADailySummary>( new PXDataFieldRestrict("CashAccountID", PXDbType.Int, 4, tlist.CashAccountID, PXComp.EQ) ); foreach (CATran tran in PXSelect <CATran, Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> > > > .Select(te, tlist.CashAccountID)) { CADailyAccumulatorAttribute.RowInserted <CATran.tranDate>(te.catrancache, tran); } te.dailycache.Persist(PXDBOperation.Insert); te.dailycache.Persist(PXDBOperation.Update); ts.Complete(te); } te.gltrancache.Persisted(false); te.catrancache.Persisted(false); te.dailycache.Persisted(false); } }