public IEnumerable Release(PXAdapter adapter) { if (RUTROTHelper.IsNeedBalancing(Base, Base.Document.Current, RUTROTBalanceOn.Release)) { Base.Save.Press(); ARInvoice doc = Base.Document.Current; PXLongOperation.StartOperation(Base, delegate() { RUTROT rutrot = PXSelect <RUTROT, Where <RUTROT.refNbr, Equal <Required <ARInvoice.refNbr> >, And <RUTROT.docType, Equal <Required <ARInvoice.docType> > > > > .Select(Base, doc.RefNbr, doc.DocType); ARInvoiceEntry invoiceEntryGraph = PXGraph.CreateInstance <ARInvoiceEntry>(); RUTROTHelper.BalanceARInvoiceRUTROT(invoiceEntryGraph, doc, OnRelease: true, rutrot: rutrot); RUTROTHelper.CreateAdjustment(Base, doc, rutrot); Base.ReleaseProcess(new List <ARRegister> { doc }); }); return(new List <ARInvoice> { Base.Document.Current }); } return(Base.Release(adapter)); }
public override void Initialize() { base.Initialize(); Base.ARDocumentList.SetProcessDelegate( delegate(List <BalancedARDocument> list) { List <ARRegister> newlist = new List <ARRegister>(list.Count); foreach (BalancedARDocument doc in list) { newlist.Add(doc); } foreach (ARRegister doc in newlist) { using (PXTransactionScope ts = new PXTransactionScope()) { ARInvoiceEntry graph = PXGraph.CreateInstance <ARInvoiceEntry>(); if (RUTROTHelper.IsNeedBalancing(graph, RUTROTBalanceOn.Release)) { BalanceProc(graph, doc); } ARDocumentRelease.ReleaseDoc(new List <ARRegister> { doc }, true); ts.Complete(); } } } ); }
private void BalanceProc(ARInvoiceEntry graph, ARRegister register) { ARInvoice invoice = PXSelect <ARInvoice, Where <ARInvoice.docType, Equal <Required <ARRegister.docType> >, And <ARInvoice.refNbr, Equal <Required <ARRegister.refNbr> > > > > .Select(graph, register.DocType, register.RefNbr); if (RUTROTHelper.IsNeedBalancing(graph, invoice, RUTROTBalanceOn.Release)) { RUTROT rutrot = PXSelect <RUTROT, Where <RUTROT.refNbr, Equal <Required <ARInvoice.refNbr> >, And <RUTROT.docType, Equal <Required <ARInvoice.docType> > > > > .Select(graph, invoice.RefNbr, invoice.DocType); RUTROTHelper.BalanceARInvoiceRUTROT(graph, invoice, OnRelease: true, rutrot: rutrot); RUTROTHelper.CreateAdjustment(graph, invoice, rutrot); } }
public void BalanceDocuments(IEnumerable <DocumentDetails> documents) { ARInvoiceEntry graph = PXGraph.CreateInstance <ARInvoiceEntry>(); if (RUTROTHelper.IsNeedBalancing(graph, RUTROTBalanceOn.Claim)) { foreach (DocumentDetails details in documents) { var invoice = (ARInvoice)graph.Document.Cache.CreateCopy(details.Document); using (PXTransactionScope ts = new PXTransactionScope()) { RUTROTHelper.BalanceARInvoiceRUTROT(graph, invoice, rutrot: details.Rutrot); ts.Complete(); } } } }
public void ClaimDocuments(IEnumerable <RUTROT> documents) { var extDocuments = documents.Select(GetExtendedDoc); ValidateExported(extDocuments); string filename = CreateFilename(); if (RUTROTHelper.IsNeedBalancing(this, RUTROTBalanceOn.Claim)) { BalanceDocuments(extDocuments); } foreach (var d in extDocuments) { ClaimDocument(d.Rutrot, filename); } this.Save.Press(); var file = ExportDocuments(extDocuments, filename); throw new PXRedirectToFileException(file, true); }