public static void ReleaseARDocument(IBqlTable aTable) { AR.ARRegister toProc = (AR.ARRegister)aTable; using (PXTimeStampScope scope = new PXTimeStampScope(null)) { if (!(toProc.Released ?? false)) { List <AR.ARRegister> list = new List <AR.ARRegister>(1); list.Add(toProc); ARDocumentRelease.ReleaseDoc(list, false); } } }
protected virtual bool HasUnreleasedDetails(GLVoucherBatch batch) { foreach (PXResult <GLVoucher, AP.APRegister, AR.ARRegister, CAAdj, Batch> it in this.Details.Select(batch.WorkBookID, batch.VoucherBatchNbr)) { GLVoucher iVoucher = it; AP.APRegister iAPR = it; AR.ARRegister iARR = it; CAAdj iCAR = it; Batch iGL = it; switch (iVoucher.Module) { case GL.BatchModule.AP: if (iAPR == null || string.IsNullOrEmpty(iAPR.RefNbr)) { throw new PXException(GL.Messages.DocumentIsInvalidForVoucher, iVoucher.RefNbr, iVoucher.VoucherBatchNbr); } return(iAPR.Released != true); case GL.BatchModule.AR: if (iARR == null || string.IsNullOrEmpty(iARR.RefNbr)) { throw new PXException(GL.Messages.DocumentIsInvalidForVoucher, iVoucher.RefNbr, iVoucher.VoucherBatchNbr); } return(iARR.Released != true); case GL.BatchModule.CA: if (iCAR == null || string.IsNullOrEmpty(iCAR.AdjRefNbr)) { throw new PXException(GL.Messages.DocumentIsInvalidForVoucher, iVoucher.RefNbr, iVoucher.VoucherBatchNbr); } return(iCAR.Released != true); case GL.BatchModule.GL: if (iGL == null || string.IsNullOrEmpty(iGL.BatchNbr)) { throw new PXException(GL.Messages.DocumentIsInvalidForVoucher, iVoucher.RefNbr, iVoucher.VoucherBatchNbr); } return(iGL.Released != true); default: throw new PXException(GL.Messages.ModuleIsNotSupported, iVoucher.Module); } } return(false); }
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); } } } }
protected virtual void ReleaseBatchDetailsProc(GLVoucherBatch aBatch, List <Batch> toPost, Dictionary <Guid, CAMessage> errors) { int toProcessCount = 0; List <Guid> failed = new List <Guid>(); Dictionary <string, IList> processQueue = new Dictionary <string, IList>(); foreach (PXResult <GLVoucher, AP.APRegister, AR.ARRegister, CAAdj, Batch> it in this.Details.Select(aBatch.WorkBookID, aBatch.VoucherBatchNbr)) { GLVoucher iVoucher = it; Guid key = iVoucher.RefNoteID.Value; try { switch (iVoucher.Module) { case GL.BatchModule.AP: AP.APRegister iAPR = it; if (iAPR == null || String.IsNullOrEmpty(iAPR.RefNbr)) { throw new PXException(GL.Messages.DocumentIsInvalidForVoucher, iVoucher.RefNbr, iVoucher.VoucherBatchNbr); } if (iAPR.Released != true) { toProcessCount++; List <AP.APRegister> list = new List <AP.APRegister>(1); list.Add(iAPR); if (iAPR.Scheduled == true) { throw new PXException(Messages.CannotReleaseScheduled); } AP.APDocumentRelease.ReleaseDoc(list, false, false, toPost); } break; case GL.BatchModule.AR: AR.ARRegister iARR = it; if (iARR == null || String.IsNullOrEmpty(iARR.RefNbr)) { throw new PXException(GL.Messages.DocumentIsInvalidForVoucher, iVoucher.RefNbr, iVoucher.VoucherBatchNbr); } if (iARR.Released != true) { toProcessCount++; List <AR.ARRegister> list = new List <AR.ARRegister>(1); list.Add(iARR); if (iARR.Scheduled == true) { throw new PXException(Messages.CannotReleaseScheduled); } AR.ARDocumentRelease.ReleaseDoc(list, false, toPost, null); } break; case GL.BatchModule.CA: CAAdj iCAR = it; if (iCAR == null || String.IsNullOrEmpty(iCAR.AdjRefNbr)) { throw new PXException(GL.Messages.DocumentIsInvalidForVoucher, iVoucher.RefNbr, iVoucher.VoucherBatchNbr); } if (iCAR.Released != true) { toProcessCount++; CATrxRelease.ReleaseDoc <CAAdj>(iCAR, 0, toPost); } break; case GL.BatchModule.GL: Batch iGL = it; if (iGL == null || String.IsNullOrEmpty(iGL.BatchNbr)) { throw new PXException(GL.Messages.DocumentIsInvalidForVoucher, iVoucher.RefNbr, iVoucher.VoucherBatchNbr); } if (iGL.Released != true) { toProcessCount++; List <Batch> list = new List <Batch>(1); list.Add(iGL); if (iGL.Scheduled == true) { throw new PXException(Messages.CannotReleaseScheduled); } JournalEntry.ReleaseBatch(list, toPost); } break; default: throw new PXException(GL.Messages.ModuleIsNotSupported, iVoucher.Module); } } catch (Exception ex) { failed.Add(key); //prevent process from stoping on first error errors.Add(key, FormatError(ex)); } } if (failed.Count > 0) { throw new PXException(Messages.ReleasingOfSomeOfTheIncludedDocumentsFailed, failed.Count, toProcessCount); } }