public virtual void AssignNumbers(ARPaymentEntryExt pe, ARPayment doc, ref string NextCheckNbr) { pe.RowPersisting.RemoveHandler <ARAdjust>(pe.ARAdjust_RowPersisting); pe.Clear(PXClearOption.PreserveTimeStamp); doc = pe.Document.Current = pe.Document.Search <ARPayment.refNbr>(doc.RefNbr, doc.DocType); PaymentMethodAccount det = pe.cashaccountdetail.Select(); var payExt = PXCache <ARPayment> .GetExtension <ARPaymentExt>(pe.Document.Current); if (!string.IsNullOrEmpty(NextCheckNbr)) { if (String.IsNullOrEmpty(pe.Document.Current.ExtRefNbr)) { payExt.StubCntr = 1; payExt.BillCntr = 0; pe.Document.Current.ExtRefNbr = NextCheckNbr; if (String.IsNullOrEmpty(NextCheckNbr)) { throw new PXException(AP.Messages.NextCheckNumberIsRequiredForProcessing); } pe.cashaccountdetail.Update(det); // det.APLastRefNumber was modified in StoreStubNumber method NextCheckNbr = AutoNumberAttribute.NextNumber(NextCheckNbr); payExt.Printed = true; pe.Document.Current.Hold = false; pe.Document.Current.UpdateNextNumber = true; pe.Document.Update(pe.Document.Current); } else { if (payExt.Printed != true || pe.Document.Current.Hold != false) { payExt.Printed = true; pe.Document.Current.Hold = false; pe.Document.Update(pe.Document.Current); } } } }
public virtual void GenerateProc(Schedule schedule, short times, DateTime runDate) { string lastBatchNbr = "0000000000"; long lastInfoID = -1; IEnumerable <ScheduleDet> occurrences = new Scheduler(this).MakeSchedule(schedule, times, runDate); using (PXTransactionScope ts = new PXTransactionScope()) { foreach (ScheduleDet occurrence in occurrences) { foreach (BatchNew scheduledBatch in PXSelect < BatchNew, Where < BatchNew.scheduleID, Equal <Optional <Schedule.scheduleID> >, And <BatchNew.scheduled, Equal <boolTrue> > > > .Select(this, schedule.ScheduleID)) { BatchNew copy = PXCache <BatchNew> .CreateCopy(scheduledBatch); copy.OrigBatchNbr = copy.BatchNbr; copy.OrigModule = copy.Module; copy.CuryInfoID = null; copy.NumberCode = "GLREC"; copy.NoteID = null; CurrencyInfo info = (CurrencyInfo)PXSelect < CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Required <CurrencyInfo.curyInfoID> > > > .Select(this, scheduledBatch.CuryInfoID); if (info != null) { CurrencyInfo infocopy = PXCache <CurrencyInfo> .CreateCopy(info); infocopy.CuryInfoID = lastInfoID; copy.CuryInfoID = lastInfoID; CuryInfo_Created.Cache.Insert(infocopy); } copy.Posted = false; copy.Released = false; copy.Status = BatchStatus.Balanced; copy.Scheduled = false; copy.AutoReverseCopy = false; copy.DateEntered = occurrence.ScheduledDate; FinPeriod finPeriod = FinPeriodRepository.GetFinPeriodByMasterPeriodID(PXAccess.GetParentOrganizationID(copy.BranchID), occurrence.ScheduledPeriod) .GetValueOrRaiseError(); copy.FinPeriodID = finPeriod.FinPeriodID; copy.TranPeriodID = null; copy.BatchNbr = lastBatchNbr; copy.RefBatchNbr = lastBatchNbr; lastBatchNbr = AutoNumberAttribute.NextNumber(lastBatchNbr); lastInfoID--; copy = (BatchNew)Batch_Created.Cache.Insert(copy); CurrencyInfoAttribute.SetEffectiveDate <Batch.dateEntered>(Batch_Created.Cache, new PXFieldUpdatedEventArgs(copy, null, false)); PXNoteAttribute.CopyNoteAndFiles(Caches[typeof(BatchNew)], scheduledBatch, Batch_Created.Cache, copy); foreach (GLTranNew scheduledBatchTransaction in PXSelect < GLTranNew, Where < GLTranNew.module, Equal <Required <GLTranNew.module> >, And <GLTranNew.batchNbr, Equal <Required <GLTranNew.batchNbr> > > > > .Select(this, scheduledBatch.Module, scheduledBatch.BatchNbr)) { GLTranNew transactionCopy = PXCache <GLTranNew> .CreateCopy(scheduledBatchTransaction); transactionCopy.OrigBatchNbr = transactionCopy.BatchNbr; transactionCopy.OrigModule = transactionCopy.Module; transactionCopy.BatchNbr = copy.BatchNbr; transactionCopy.RefBatchNbr = copy.RefBatchNbr; transactionCopy.CuryInfoID = copy.CuryInfoID; transactionCopy.CATranID = null; transactionCopy.NoteID = null; transactionCopy.TranDate = occurrence.ScheduledDate; FinPeriodIDAttribute.SetPeriodsByMaster <GLTranNew.finPeriodID>(Tran_Created.Cache, transactionCopy, occurrence.ScheduledPeriod); transactionCopy = Tran_Created.Cache.Insert(transactionCopy) as GLTranNew; PXNoteAttribute.CopyNoteAndFiles(Tran_Created.Cache, scheduledBatchTransaction, Tran_Created.Cache, transactionCopy); } } schedule.LastRunDate = occurrence.ScheduledDate; Running_Schedule.Cache.Update(schedule); } Running_Schedule.Cache.Persist(PXDBOperation.Update); Batch_Created.Cache.Persist(PXDBOperation.Insert); Batch_Created.Cache.Persist(PXDBOperation.Update); foreach (GLTranNew createdTransaction in Tran_Created.Cache.Inserted) { foreach (BatchNew createdBatch in Batch_Created.Cache.Cached) { if (object.Equals(createdBatch.RefBatchNbr, createdTransaction.RefBatchNbr)) { createdTransaction.BatchNbr = createdBatch.BatchNbr; createdTransaction.CuryInfoID = createdBatch.CuryInfoID; if (!string.IsNullOrEmpty(createdBatch.RefNbr)) { createdTransaction.RefNbr = createdBatch.RefNbr; } break; } } } Tran_Created.Cache.Normalize(); Tran_Created.Cache.Persist(PXDBOperation.Insert); Tran_Created.Cache.Persist(PXDBOperation.Update); Caches[typeof(CA.CADailySummary)].Persist(PXDBOperation.Insert); ts.Complete(this); } Running_Schedule.Cache.Persisted(false); Batch_Created.Cache.Persisted(false); Tran_Created.Cache.Persisted(false); Caches[typeof(CA.CADailySummary)].Persisted(false); }
public virtual void GenerateProc(Schedule s, short Times, DateTime runDate) { string LastBatchNbr = "0000000000"; Int64 LastInfoID = -1; List <ScheduleDet> sd = MakeSchedule(s, Times, runDate); using (PXTransactionScope ts = new PXTransactionScope()) { foreach (ScheduleDet d in sd) { foreach (BatchNew b in PXSelect <BatchNew, Where <BatchNew.scheduleID, Equal <Optional <Schedule.scheduleID> >, And <BatchNew.scheduled, Equal <boolTrue> > > > .Select(this, s.ScheduleID)) { BatchNew copy = PXCache <BatchNew> .CreateCopy(b); copy.OrigBatchNbr = copy.BatchNbr; copy.OrigModule = copy.Module; copy.CuryInfoID = null; copy.NumberCode = "GLREC"; copy.NoteID = null; CurrencyInfo info = (CurrencyInfo)PXSelect <CurrencyInfo, Where <CurrencyInfo.curyInfoID, Equal <Required <CurrencyInfo.curyInfoID> > > > .Select(this, b.CuryInfoID); if (info != null) { CurrencyInfo infocopy = PXCache <CurrencyInfo> .CreateCopy(info); infocopy.CuryInfoID = LastInfoID; copy.CuryInfoID = LastInfoID; CuryInfo_Created.Cache.Insert(infocopy); } copy.Posted = false; copy.Released = false; copy.Status = "B"; copy.Scheduled = false; copy.DateEntered = d.ScheduledDate; copy.FinPeriodID = d.ScheduledPeriod; copy.TranPeriodID = null; copy.BatchNbr = LastBatchNbr; copy.RefBatchNbr = LastBatchNbr; LastBatchNbr = AutoNumberAttribute.NextNumber(LastBatchNbr); LastInfoID--; copy = (BatchNew)Batch_Created.Cache.Insert(copy); CurrencyInfoAttribute.SetEffectiveDate <Batch.dateEntered>(Batch_Created.Cache, new PXFieldUpdatedEventArgs(copy, null, false)); PXNoteAttribute.SetNote(Batch_Created.Cache, copy, PXNoteAttribute.GetNote(Caches[typeof(BatchNew)], b)); PXNoteAttribute.SetFileNotes(Batch_Created.Cache, copy, PXNoteAttribute.GetFileNotes(Caches[typeof(BatchNew)], b)); foreach (GLTranNew tran in PXSelect <GLTranNew, Where <GLTranNew.module, Equal <Required <GLTranNew.module> >, And <GLTranNew.batchNbr, Equal <Required <GLTranNew.batchNbr> > > > > .Select(this, b.Module, b.BatchNbr)) { GLTranNew trancopy = PXCache <GLTranNew> .CreateCopy(tran); trancopy.OrigBatchNbr = trancopy.BatchNbr; trancopy.OrigModule = trancopy.Module; trancopy.BatchNbr = copy.BatchNbr; trancopy.RefBatchNbr = copy.RefBatchNbr; trancopy.CuryInfoID = copy.CuryInfoID; trancopy.CATranID = null; trancopy.TranDate = d.ScheduledDate; trancopy.FinPeriodID = d.ScheduledPeriod; trancopy.TranPeriodID = d.ScheduledPeriod; Tran_Created.Cache.Insert(trancopy); } } s.LastRunDate = d.ScheduledDate; Running_Schedule.Cache.Update(s); } Running_Schedule.Cache.Persist(PXDBOperation.Update); Batch_Created.Cache.Persist(PXDBOperation.Insert); Batch_Created.Cache.Persist(PXDBOperation.Update); foreach (GLTranNew tran in Tran_Created.Cache.Inserted) { foreach (BatchNew batch in Batch_Created.Cache.Cached) { if (object.Equals(batch.RefBatchNbr, tran.RefBatchNbr)) { tran.BatchNbr = batch.BatchNbr; tran.CuryInfoID = batch.CuryInfoID; if (!string.IsNullOrEmpty(batch.RefNbr)) { tran.RefNbr = batch.RefNbr; } break; } } } Tran_Created.Cache.Normalize(); Tran_Created.Cache.Persist(PXDBOperation.Insert); Tran_Created.Cache.Persist(PXDBOperation.Update); Caches[typeof(CA.CADailySummary)].Persist(PXDBOperation.Insert); ts.Complete(this); } Running_Schedule.Cache.Persisted(false); Batch_Created.Cache.Persisted(false); Tran_Created.Cache.Persisted(false); Caches[typeof(CA.CADailySummary)].Persisted(false); }
protected virtual void PrintPayments(List <APPayment> list, PrintChecksFilter filter, PaymentMethod paymentMethod) { if (list.Count == 0) { return; } if (paymentMethod.UseForAP == true) { if (paymentMethod.APPrintChecks == true && string.IsNullOrEmpty(paymentMethod.APCheckReportID)) { throw new PXException(Messages.FieldNotSetInPaymentMethod, PXUIFieldAttribute.GetDisplayName <PaymentMethod.aPCheckReportID>(paymenttype.Cache), paymentMethod.PaymentMethodID); } if (paymentMethod.APPrintChecks == true && paymentMethod.APPrintRemittance == true && string.IsNullOrEmpty(paymentMethod.APRemittanceReportID)) { throw new PXException(Messages.FieldNotSetInPaymentMethod, PXUIFieldAttribute.GetDisplayName <PaymentMethod.aPRemittanceReportID>(paymenttype.Cache), paymentMethod.PaymentMethodID); } } bool printAdditionRemit = false; if (paymentMethod.APCreateBatchPayment == true) { CABatch batch = CreateBatchPayment(list, filter); if (batch != null) { bool failed = false; APPaymentEntry pe = CreateInstance <APPaymentEntry>(); string NextCheckNbr = filter.NextCheckNbr; foreach (APPayment pmt in list) { APPayment payment = pmt; PXProcessing <APPayment> .SetCurrentItem(payment); try { payment = pe.Document.Search <APPayment.refNbr>(payment.RefNbr, payment.DocType); if (payment.PrintCheck != true) { throw new PXException(Messages.CantPrintNonprintableCheck); } if ((payment.DocType == APDocType.Check || payment.DocType == APDocType.QuickCheck) && payment.Status != APDocStatus.PendingPrint) { throw new PXException(Messages.ChecksMayBePrintedInPendingPrintStatus); } AssignNumbers(pe, payment, ref NextCheckNbr, true); if (payment.Passed == true) { pe.TimeStamp = payment.tstamp; } pe.Save.Press(); payment.tstamp = pe.TimeStamp; pe.Clear(); } catch (PXException e) { PXProcessing <APPayment> .SetError(e); failed = true; } } if (failed) { throw new PXOperationCompletedWithErrorException(Messages.APPaymentsAreAddedToTheBatchButWasNotUpdatedCorrectly, batch.BatchNbr); } RedirectToResultWithCreateBatch(batch); } } else { APReleaseChecks pp = CreateInstance <APReleaseChecks>(); ReleaseChecksFilter filter_copy = PXCache <ReleaseChecksFilter> .CreateCopy(pp.Filter.Current); filter_copy.PayAccountID = filter.PayAccountID; filter_copy.PayTypeID = filter.PayTypeID; filter_copy.CuryID = filter.CuryID; pp.Filter.Cache.Update(filter_copy); APPaymentEntry pe = CreateInstance <APPaymentEntry>(); bool failed = false; Dictionary <string, string> d = new Dictionary <string, string>(); string nextCheckNbr = filter.NextCheckNbr; string prevCheckNbr = nextCheckNbr; int idxReportFilter = 0; foreach (APPayment pmt in list) { APPayment payment = pmt; PXProcessing <APPayment> .SetCurrentItem(payment); try { prevCheckNbr = nextCheckNbr; if (filter.IsNextNumberDuplicated(this, nextCheckNbr)) { string duplicate = nextCheckNbr; nextCheckNbr = AutoNumberAttribute.NextNumber(nextCheckNbr); throw new PXException(Messages.ConflictWithExistingCheckNumber, duplicate); } payment = pe.Document.Search <APPayment.refNbr>(payment.RefNbr, payment.DocType); if (payment.PrintCheck != true) { throw new PXException(Messages.CantPrintNonprintableCheck); } if ((payment.DocType == APDocType.Check || payment.DocType == APDocType.QuickCheck) && payment.Status != APDocStatus.PendingPrint) { throw new PXException(Messages.ChecksMayBePrintedInPendingPrintStatus); } AssignNumbers(pe, payment, ref nextCheckNbr); if (payment.Passed == true) { pe.TimeStamp = payment.tstamp; } pe.Save.Press(); payment.tstamp = pe.TimeStamp; pe.Clear(); APPayment seldoc = pe.Document.Search <APPayment.refNbr>(payment.RefNbr, payment.DocType); seldoc.Selected = true; seldoc.Passed = true; seldoc.tstamp = payment.tstamp; pp.APPaymentList.Cache.Update(seldoc); pp.APPaymentList.Cache.SetStatus(seldoc, PXEntryStatus.Updated); printAdditionRemit |= seldoc.BillCntr > paymentMethod.APStubLines; StringBuilder sbDocType = new StringBuilder("APPayment.DocType"); sbDocType.Append(Convert.ToString(idxReportFilter)); StringBuilder sbRefNbr = new StringBuilder("APPayment.RefNbr"); sbRefNbr.Append(Convert.ToString(idxReportFilter)); idxReportFilter++; d[sbDocType.ToString()] = payment.DocType == APDocType.QuickCheck ? APDocType.QuickCheck : APDocType.Check; d[sbRefNbr.ToString()] = payment.RefNbr; PXProcessing <APPayment> .SetProcessed(); } catch (PXException e) { PXProcessing <APPayment> .SetError(e); failed = true; nextCheckNbr = prevCheckNbr; } } if (failed) { PXReportRequiredException report = null; if (d.Count > 0) { d[ReportMessages.CheckReportFlag] = ReportMessages.CheckReportFlagValue; report = new PXReportRequiredException(d, paymentMethod.APCheckReportID, PXBaseRedirectException.WindowMode.New, "Check"); } throw new PXOperationCompletedWithErrorException(GL.Messages.DocumentsNotReleased, report); } else { if (d.Count > 0) { RedirectToResultNoBatch(pp, d, paymentMethod, printAdditionRemit, nextCheckNbr); } } } }
public virtual void AssignNumbers(APPaymentEntry pe, APPayment doc, ref string NextCheckNbr, bool skipStubs = false) { pe.RowPersisting.RemoveHandler <APAdjust>(pe.APAdjust_RowPersisting); pe.Clear(); doc = pe.Document.Current = pe.Document.Search <APPayment.refNbr>(doc.RefNbr, doc.DocType); PaymentMethodAccount det = pe.cashaccountdetail.Select(); doc.IsPrintingProcess = true; // indicates that the payment under printing process (to prevent update by PaymentRefAttribute) if (string.IsNullOrEmpty(NextCheckNbr)) { throw new PXException(Messages.NextCheckNumberIsRequiredForProcessing); } if (string.IsNullOrEmpty(pe.Document.Current.ExtRefNbr)) { pe.Document.Current.StubCntr = 1; pe.Document.Current.BillCntr = 0; pe.Document.Current.ExtRefNbr = NextCheckNbr; if (pe.Document.Current.DocType == APDocType.QuickCheck && pe.Document.Current.CuryOrigDocAmt <= 0m) { throw new PXException(Messages.ZeroCheck_CannotPrint); } if (!skipStubs) // print check { APAdjust[] adjustments = pe.Adjustments_print.Select().RowCast <APAdjust>().ToArray(); PaymentMethod pt = pe.paymenttype.Select(); int stubCount = (int)Math.Ceiling(adjustments.Length / (decimal)(pt.APStubLines ?? 1)); if (stubCount > 1 && pt.APPrintRemittance != true) { string endNumber = AutoNumberAttribute.NextNumber(NextCheckNbr, stubCount - 1); string[] duplicates = PXSelect <CashAccountCheck, Where <CashAccountCheck.accountID, Equal <Required <PrintChecksFilter.payAccountID> >, And <CashAccountCheck.paymentMethodID, Equal <Required <PrintChecksFilter.payTypeID> >, And <CashAccountCheck.checkNbr, GreaterEqual <Required <PrintChecksFilter.nextCheckNbr> >, And <CashAccountCheck.checkNbr, LessEqual <Required <PrintChecksFilter.nextCheckNbr> > > > > > > .Select(this, det.CashAccountID, det.PaymentMethodID, NextCheckNbr, endNumber) .RowCast <CashAccountCheck>() .Select(check => check.CheckNbr) .ToArray(); if (duplicates.Any()) { throw new PXException( Messages.TooSmallCheckNumbersGap, stubCount, NextCheckNbr, endNumber, string.Join(",", duplicates)); } } short ordinalInStub = 0; int stubOrdinal = 0; foreach (APAdjust adj in adjustments) { pe.Document.Current.BillCntr++; if (ordinalInStub > pt.APStubLines - 1) { //AssignCheckNumber only for first StubLines in check, other/all lines will be printed on remittance report if (pt.APPrintRemittance == true) { adj.StubNbr = null; pe.Adjustments.Cache.Update(adj); continue; } NextCheckNbr = AutoNumberAttribute.NextNumber(NextCheckNbr); pe.Document.Current.StubCntr++; ordinalInStub = 0; stubOrdinal++; } SetAdjustmentStubNumber(pe, doc, adj, NextCheckNbr); StoreStubNumber(pe, doc, det, NextCheckNbr, stubOrdinal); ordinalInStub++; } } else // create batch payment { //Update last number det.APLastRefNbr = NextCheckNbr; } pe.cashaccountdetail.Update(det); // det.APLastRefNumber was modified in StoreStubNumber method NextCheckNbr = AutoNumberAttribute.NextNumber(NextCheckNbr); pe.Document.Current.Printed = true; pe.Document.Current.Hold = false; pe.Document.Update(pe.Document.Current); } else { if (pe.Document.Current.Printed != true || pe.Document.Current.Hold == true) { pe.Document.Current.Printed = true; pe.Document.Current.Hold = false; pe.Document.Update(pe.Document.Current); } } }
public static void ReleasePayments(List <APPayment> list, string Action) { APReleaseChecks graph = PXGraph.CreateInstance <APReleaseChecks>(); APPaymentEntry pe = PXGraph.CreateInstance <APPaymentEntry>(); bool failed = false; bool successed = false; string NextCheckNbr = null; List <APRegister> docs = new List <APRegister>(list.Count); List <string> numbers = new List <string>(); Dictionary <string, int> stubs = new Dictionary <string, int>(); for (int i = 0; i < list.Count; i++) { if (list[i].Passed == true) { graph.TimeStamp = pe.TimeStamp = list[i].tstamp; } switch (Action) { case "R": list[i].Printed = true; break; case "D": PaymentMethodAccount det = PXSelect <PaymentMethodAccount, Where <PaymentMethodAccount.cashAccountID, Equal <Required <PaymentMethodAccount.cashAccountID> >, And <PaymentMethodAccount.paymentMethodID, Equal <Required <PaymentMethodAccount.paymentMethodID> > > > > .Select(graph, list[i].CashAccountID, list[i].PaymentMethodID); if (det == null || det.APAutoNextNbr == false) { numbers.Add(list[i].ExtRefNbr); stubs[list[i].ExtRefNbr] = (int)list[i].StubCntr; //null out Check Number and delete used check number if StubCounter == 1 list[i].ExtRefNbr = null; } list[i].Printed = false; break; case "V": //null out Check Number but do not delete it list[i].StubCntr = -1; list[i].ExtRefNbr = null; list[i].Printed = false; break; default: continue; } if ((bool)list[i].Printed) { try { APPrintChecks.AssignNumbers(pe, list[i], ref NextCheckNbr); pe.Save.Press(); object[] persisted = PXTimeStampScope.GetPersisted(pe.Document.Cache, pe.Document.Current); if (persisted == null || persisted.Length == 0) { //preserve timestamp which will be @@dbts after last record committed to db on previous Persist(). //otherwise another process updated APAdjust. docs.Add(list[i]); } else { if (list[i].Passed == true) { pe.Document.Current.Passed = true; } docs.Add(pe.Document.Current); } successed = true; } catch (Exception e) { PXProcessing <APPayment> .SetError(i, e); docs.Add(null); failed = true; } } else { try { list[i].Hold = true; graph.APPaymentList.Cache.PersistUpdated(list[i]); graph.APPaymentList.Cache.Persisted(false); graph.TimeStamp = PXDatabase.SelectTimeStamp(); if (string.IsNullOrEmpty(list[i].ExtRefNbr)) { //try to get next number graph.APPaymentList.Cache.SetDefaultExt <APPayment.extRefNbr>(list[i]); if (string.IsNullOrEmpty(list[i].ExtRefNbr) == false) { list[i].StubCntr = 1; graph.APPaymentList.Cache.PersistUpdated(list[i]); graph.APPaymentList.Cache.Persisted(false); } } } catch (Exception e) { PXProcessing <APPayment> .SetError(i, e); } docs.Add(null); } } if (successed) { APDocumentRelease.ReleaseDoc(docs, true); } numbers.Sort(); for (int i = numbers.Count - 1; i >= 0; i--) { PaymentMethodAccount det = PXSelect <PaymentMethodAccount, Where <PaymentMethodAccount.cashAccountID, Equal <Required <PaymentMethodAccount.cashAccountID> >, And <PaymentMethodAccount.paymentMethodID, Equal <Required <PaymentMethodAccount.paymentMethodID> > > > > .Select(graph, list[0].CashAccountID, list[0].PaymentMethodID); string lastnumber = AutoNumberAttribute.NextNumber(numbers[i], stubs[numbers[i]] - 1); if (string.Equals(lastnumber, det.APLastRefNbr)) { det.APLastRefNbr = AutoNumberAttribute.NextNumber(det.APLastRefNbr, -stubs[numbers[i]]); graph.cashaccountdetail.Cache.PersistUpdated(det); graph.cashaccountdetail.Cache.Persisted(false); } } if (failed) { throw new PXException(GL.Messages.DocumentsNotReleased); } }
protected virtual void ProcessPaymentFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { bool SuggestNextNumber = false; ProcessPaymentFilter row = (ProcessPaymentFilter)e.Row; PXUIFieldAttribute.SetVisible <ProcessPaymentFilter.curyID>(sender, null, PXAccess.FeatureInstalled <FeaturesSet.multicurrency>()); if (e.Row != null && cashaccountdetail.Current != null && (!Equals(cashaccountdetail.Current.CashAccountID, row.PayAccountID) || !Equals(cashaccountdetail.Current.PaymentMethodID, row.PayTypeID))) { cashaccountdetail.Current = null; SuggestNextNumber = true; } if (e.Row != null && paymenttype.Current != null && (!Equals(paymenttype.Current.PaymentMethodID, row.PayTypeID))) { paymenttype.Current = null; } if (e.Row != null && string.IsNullOrEmpty(row.NextCheckNbr)) { SuggestNextNumber = true; } PXUIFieldAttribute.SetVisible <ProcessPaymentFilter.nextCheckNbr>(sender, null, true); if (e.Row == null) { return; } if (cashaccountdetail.Current != null && true == cashaccountdetail.Current.ARAutoNextNbr && SuggestNextNumber) { row.NextCheckNbr = string.IsNullOrEmpty(cashaccountdetail.Current.ARLastRefNbr) == false?AutoNumberAttribute.NextNumber(cashaccountdetail.Current.ARLastRefNbr) : string.Empty; } sender.RaiseExceptionHandling <ProcessPaymentFilter.payTypeID>(e.Row, row.PayTypeID, paymenttype.Current != null && true != PXCache <PaymentMethod> .GetExtension <PaymentMethodExt>(paymenttype.Current).ARCreateBatchPayment ? new PXSetPropertyException(AP.Messages.PaymentTypeNoPrintCheck, PXErrorLevel.Warning) : null); sender.RaiseExceptionHandling <ProcessPaymentFilter.nextCheckNbr>(e.Row, row.NextCheckNbr, paymenttype.Current != null && paymenttype.Current.PrintOrExport == true && String.IsNullOrEmpty(row.NextCheckNbr) ? new PXSetPropertyException(AP.Messages.NextCheckNumberIsRequiredForProcessing, PXErrorLevel.Warning) : !string.IsNullOrEmpty(row.NextCheckNbr) && !AutoNumberAttribute.CanNextNumber(row.NextCheckNbr) ? new PXSetPropertyException(AP.Messages.NextCheckNumberCanNotBeInc, PXErrorLevel.Warning) : null); if (/*HttpContext.Current != null && */ Filter.Current.BranchID != PXAccess.GetBranchID()) { Filter.Current.BranchID = PXAccess.GetBranchID(); } ProcessPaymentFilter filter = Filter.Current; PaymentMethod pt = paymenttype.Current; ARPaymentList.SetProcessTooltip(Messages.Process); ARPaymentList.SetProcessAllTooltip(Messages.ProcessAll); ARPaymentList.SetProcessDelegate( delegate(List <ARPayment> list) { var graph = CreateInstance <ARProcessPayment>(); graph.ProcessPayments(list, filter, pt); } ); }
protected virtual void PrintChecksFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { bool SuggestNextNumber = false; PrintChecksFilter row = (PrintChecksFilter)e.Row; PXUIFieldAttribute.SetVisible <PrintChecksFilter.curyID>(sender, null, (bool)CMSetup.Current.MCActivated); if (e.Row != null && cashaccountdetail.Current != null && (object.Equals(cashaccountdetail.Current.CashAccountID, row.PayAccountID) == false || object.Equals(cashaccountdetail.Current.PaymentMethodID, row.PayTypeID) == false)) { cashaccountdetail.Current = null; SuggestNextNumber = true; } if (e.Row != null && paymenttype.Current != null && (object.Equals(paymenttype.Current.PaymentMethodID, row.PayTypeID) == false)) { paymenttype.Current = null; } if (e.Row != null && string.IsNullOrEmpty(row.NextCheckNbr)) { SuggestNextNumber = true; } PXUIFieldAttribute.SetVisible <PrintChecksFilter.nextCheckNbr>(sender, null, true); if (e.Row == null) { return; } if (cashaccountdetail.Current != null && (bool)cashaccountdetail.Current.APAutoNextNbr == true) { //PXUIFieldAttribute.SetVisible<PrintChecksFilter.nextCheckNbr>(sender, null, true); if (SuggestNextNumber) { if (string.IsNullOrEmpty(cashaccountdetail.Current.APLastRefNbr) == false) { row.NextCheckNbr = AutoNumberAttribute.NextNumber(cashaccountdetail.Current.APLastRefNbr); } else { row.NextCheckNbr = string.Empty; } } } else { //PXUIFieldAttribute.SetVisible<PrintChecksFilter.nextCheckNbr>(sender, null, false); //row.NextCheckNbr = null; } if (paymenttype.Current != null && ((bool)paymenttype.Current.APPrintChecks == false && (bool)paymenttype.Current.APCreateBatchPayment == false)) { sender.RaiseExceptionHandling <PrintChecksFilter.payTypeID>(e.Row, row.PayTypeID, new PXSetPropertyException(Messages.PaymentTypeNoPrintCheck, PXErrorLevel.Warning)); } else { sender.RaiseExceptionHandling <PrintChecksFilter.payTypeID>(e.Row, row.PayTypeID, null); } if (paymenttype.Current != null && paymenttype.Current.PrintOrExport == true && String.IsNullOrEmpty(row.NextCheckNbr)) { sender.RaiseExceptionHandling <PrintChecksFilter.nextCheckNbr>(e.Row, row.NextCheckNbr, new PXSetPropertyException(Messages.NextCheckNumberIsRequiredForProcessing, PXErrorLevel.Warning)); } else { if (!String.IsNullOrEmpty(row.NextCheckNbr) && !AutoNumberAttribute.CanNextNumber(row.NextCheckNbr)) { sender.RaiseExceptionHandling <PrintChecksFilter.nextCheckNbr>(e.Row, row.NextCheckNbr, new PXSetPropertyException(Messages.NextCheckNumberCanNotBeInc, PXErrorLevel.Warning)); } else { sender.RaiseExceptionHandling <PrintChecksFilter.nextCheckNbr>(e.Row, row.NextCheckNbr, null); } } PrintChecksFilter filter = Filter.Current; PaymentMethod pt = paymenttype.Current; APPaymentList.SetProcessTooltip(Messages.ProcessSelectedRecordsTooltip); APPaymentList.SetProcessAllTooltip(Messages.ProcessAllRecordsTooltip); APPaymentList.SetProcessDelegate( delegate(List <APPayment> list) { var graph = PXGraph.CreateInstance <APPrintChecks>(); graph.PrintPayments(list, filter, pt); //CreateBatchPayment(list, filter); } ); }
public static void AssignNumbers(APPaymentEntry pe, APPayment doc, ref string NextCheckNbr, bool skipStubs) { pe.RowPersisting.RemoveHandler <APAdjust>(pe.APAdjust_RowPersisting); pe.Clear(PXClearOption.PreserveTimeStamp); pe.Document.Current = (APPayment)pe.Document.Search <APPayment.refNbr>(doc.RefNbr, doc.DocType); if (String.IsNullOrEmpty(NextCheckNbr) == false) { if (String.IsNullOrEmpty(pe.Document.Current.ExtRefNbr)) { pe.Document.Current.StubCntr = 1; pe.Document.Current.BillCntr = 0; pe.Document.Current.ExtRefNbr = NextCheckNbr; if (String.IsNullOrEmpty(NextCheckNbr)) { throw new PXException(Messages.NextCheckNumberIsRequiredForProcessing); } if (pe.Document.Current.DocType == APDocType.QuickCheck && pe.Document.Current.CuryOrigDocAmt <= 0m) { throw new PXException(Messages.ZeroCheck_CannotPrint); } if (!skipStubs) { short j = 0; foreach (PXResult <APAdjust> res in pe.Adjustments_print.Select()) { pe.Document.Current.BillCntr++; APAdjust adj = (APAdjust)res; PaymentMethod pt = pe.paymenttype.Select(); PaymentMethodAccount det = pe.cashaccountdetail.Select(); if (j > pt.APStubLines - 1) { //AssignCheckNumber only for first StubLines in check, other/all lines will be printed on remittance report if (pt.APPrintRemittance == true) { adj.StubNbr = null; pe.Adjustments.Cache.Update(adj); continue; } NextCheckNbr = AutoNumberAttribute.NextNumber(NextCheckNbr); pe.Document.Current.StubCntr++; j = 0; } adj.StubNbr = NextCheckNbr; pe.Adjustments.Cache.Update(adj); det.APLastRefNbr = NextCheckNbr; pe.cashaccountdetail.Update(det); j++; } } NextCheckNbr = AutoNumberAttribute.NextNumber(NextCheckNbr); pe.Document.Current.Printed = true; pe.Document.Current.Hold = false; pe.Document.Current.UpdateNextNumber = true; pe.Document.Update(pe.Document.Current); } else { if (pe.Document.Current.Printed != true || pe.Document.Current.Hold != false) { pe.Document.Current.Printed = true; pe.Document.Current.Hold = false; pe.Document.Update(pe.Document.Current); } } } else { PaymentMethod method = pe.paymenttype.Select(); PaymentMethodAccount det = pe.cashaccountdetail.Select(); //if (method != null && (method.PrintOrExport == false || det.APAutoNextNbr == true)) { if (pe.Document.Current.DocType == APDocType.QuickCheck && pe.Document.Current.CuryOrigDocAmt <= 0m) { throw new PXException(Messages.ZeroCheck_CannotPrint); } pe.Document.Current.StubCntr = 1; pe.Document.Current.BillCntr = 0; pe.Document.Current.ExtRefNbr = doc.ExtRefNbr; if (!skipStubs) { foreach (PXResult <APAdjust> res in pe.Adjustments_print.Select()) { pe.Document.Current.BillCntr++; APAdjust adj = (APAdjust)res; adj.StubNbr = doc.ExtRefNbr; pe.Adjustments.Cache.Update(adj); } } pe.Document.Current.Printed = true; pe.Document.Current.Hold = false; pe.Document.Update(pe.Document.Current); } } }