public virtual IEnumerable release(PXAdapter adapter) { CASetup setup = casetup.Current; CAEnqFilter filter = Filter.Current; List <CATran> tranList = new List <CATran>(); foreach (CATran transToRelease in PXSelect <CATran, Where2 <Where <Required <CAEnqFilter.includeUnreleased>, Equal <boolTrue>, Or <CATran.released, Equal <boolTrue> > >, And <CATran.cashAccountID, Equal <Required <CAEnqFilter.accountID> >, And <CATran.tranDate, Between <Required <CAEnqFilter.startDate>, Required <CAEnqFilter.endDate> > > > >, OrderBy <Asc <CATran.tranDate, Asc <CATran.extRefNbr, Asc <CATran.tranID> > > > > .Select(this, filter.IncludeUnreleased, filter.AccountID, filter.StartDate, filter.EndDate)) { if (transToRelease.Selected == true) { tranList.Add(transToRelease); } } Save.Press(); if (tranList.Count == 0) { throw new PXException(Messages.NoDocumentSelected); } else { PXLongOperation.StartOperation(this, delegate() { CATrxRelease.GroupReleaseTransaction(tranList, setup.ReleaseAP == true, setup.ReleaseAR == true, true); }); } return(adapter.Get()); }
public virtual IEnumerable release(PXAdapter adapter) { PXCache cache = Caches[typeof(CATransfer)]; CATransfer transfer = Transfer.Current; if (PXLongOperation.Exists(UID)) { throw new ApplicationException(GL.Messages.PrevOperationNotCompleteYet); } bool holdExpenses = false; foreach (PXResult <CATran, CAAdj> expense in TransferTran.Select()) { CAAdj expenseAdj = (CAAdj)expense; CATran expenseTran = (CATran)expense; if (expenseAdj != null && (expenseAdj.Hold == true || expenseAdj.Approved == false)) { holdExpenses = true; TransferTran.Cache.RaiseExceptionHandling <CATran.extRefNbr>(expenseTran, expenseTran.ExtRefNbr, new PXSetPropertyException(Messages.HoldExpense, PXErrorLevel.RowError)); } } if (holdExpenses) { throw new PXException(Messages.HoldExpenses, transfer.RefNbr); } Save.Press(); List <CARegister> list = new List <CARegister>(); CATran tran = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CATransfer.tranIDIn> > > > .Select(this, transfer.TranIDIn); if (tran != null) { list.Add(CATrxRelease.CARegister(transfer, tran)); } else { throw new PXException(Messages.TransactionNotFound); } tran = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CATransfer.tranIDOut> > > > .Select(this, transfer.TranIDOut); if (tran == null) { throw new PXException(Messages.TransactionNotFound); } PXLongOperation.StartOperation(this, delegate() { CATrxRelease.GroupRelease(list, false); }); List <CATransfer> ret = new List <CATransfer>(); ret.Add(transfer); return(ret); }
public virtual IEnumerable release(PXAdapter adapter) { PXCache cache = Caches[typeof(CATransfer)]; CATransfer transfer = Transfer.Current; if (PXLongOperation.Exists(UID)) { throw new ApplicationException(GL.Messages.PrevOperationNotCompleteYet); } Save.Press(); CheckExpensesOnHold(); List <CARegister> list = new List <CARegister>(); CATran tran = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CATransfer.tranIDIn> > > > .Select(this, transfer.TranIDIn); if (tran != null) { list.Add(CATrxRelease.CARegister(transfer, tran)); } else { throw new PXException(Messages.TransactionNotFound); } tran = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CATransfer.tranIDOut> > > > .Select(this, transfer.TranIDOut); if (tran == null) { throw new PXException(Messages.TransactionNotFound); } PXLongOperation.StartOperation(this, delegate() { CATrxRelease.GroupRelease(list, false); }); List <CATransfer> ret = new List <CATransfer>(); ret.Add(transfer); return(ret); }
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); } }