protected virtual void PaymentMethodAccount_RowSelected(PXCache cache, PXRowSelectedEventArgs e) { PaymentMethodAccount row = (PaymentMethodAccount)e.Row; if (row == null) { return; } if (string.IsNullOrEmpty(row.PaymentMethodID) == false) { PaymentMethod pt = PXSelect <PaymentMethod, Where <PaymentMethod.paymentMethodID, Equal <Required <PaymentMethod.paymentMethodID> > > > .Select(this, row.PaymentMethodID); bool enabled = (pt != null) && pt.APCreateBatchPayment == true; PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aPBatchLastRefNbr>(cache, row, enabled); } if (row.CashAccountID.HasValue) { CashAccount c = PXSelectReadonly <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(this, row.CashAccountID); PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.useForAP>(cache, row, (c != null)); } bool enableAP = row.UseForAP ?? false; bool enableAR = row.UseForAR ?? false; PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aPIsDefault>(cache, e.Row, enableAP); PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aPAutoNextNbr>(cache, e.Row, enableAP); PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aPLastRefNbr>(cache, e.Row, enableAP); PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aRIsDefault>(cache, e.Row, enableAR); PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aRIsDefaultForRefund>(cache, e.Row, enableAR); PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aRAutoNextNbr>(cache, e.Row, enableAR); PXUIFieldAttribute.SetEnabled <PaymentMethodAccount.aRLastRefNbr>(cache, e.Row, enableAR); }
protected virtual void PaymentMethodAccount_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { PaymentMethodAccount row = (PaymentMethodAccount)e.Row; PXDefaultAttribute.SetPersistingCheck <PaymentMethodAccount.aPLastRefNbr>(sender, e.Row, row.APAutoNextNbr == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing); if (row.APAutoNextNbr == true && row.APLastRefNbr == null) { sender.RaiseExceptionHandling <PaymentMethodAccount.aPAutoNextNbr>(row, row.APAutoNextNbr, new PXSetPropertyException(Messages.SpecifyLastRefNbr, GL.Messages.ModuleAP)); } if (row.ARAutoNextNbr == true && row.ARLastRefNbr == null) { sender.RaiseExceptionHandling <PaymentMethodAccount.aRAutoNextNbr>(row, row.ARAutoNextNbr, new PXSetPropertyException(Messages.SpecifyLastRefNbr, GL.Messages.ModuleAR)); } CashAccount cashAccount = PXSelectReadonly <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(this, row.CashAccountID); if (cashAccount != null && cashAccount.Active != true) { string errorMsg = string.Format(CA.Messages.CashAccountInactive, cashAccount.CashAccountCD.Trim()); sender.RaiseExceptionHandling <PaymentMethodAccount.cashAccountID>(e.Row, cashAccount.CashAccountCD, new PXSetPropertyException(errorMsg, PXErrorLevel.Error)); } }
protected virtual void PaymentMethodAccount_UseForAR_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e) { PaymentMethodAccount row = (PaymentMethodAccount)e.Row; CA.PaymentMethod pm = this.PaymentMethod.Current; e.NewValue = (pm != null) && pm.UseForAR == true; e.Cancel = true; }
protected virtual void PaymentMethodAccount_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { PaymentMethodAccount row = (PaymentMethodAccount)e.Row; if (row.APAutoNextNbr == true && row.APLastRefNbr == null) { sender.RaiseExceptionHandling <PaymentMethodAccount.aPAutoNextNbr>(row, row.APAutoNextNbr, new PXSetPropertyException(Messages.SpecifyLastRefNbr, GL.Messages.ModuleAP)); } if (row.ARAutoNextNbr == true && row.ARLastRefNbr == null) { sender.RaiseExceptionHandling <PaymentMethodAccount.aRAutoNextNbr>(row, row.ARAutoNextNbr, new PXSetPropertyException(Messages.SpecifyLastRefNbr, GL.Messages.ModuleAR)); } }
protected virtual void PaymentMethodAccount_RowDeleting(PXCache cache, PXRowDeletingEventArgs e) { PaymentMethodAccount row = (PaymentMethodAccount)e.Row; PXEntryStatus status = cache.GetStatus(e.Row); if (row.CashAccountID != null && status != PXEntryStatus.Inserted && status != PXEntryStatus.InsertedDeleted) { CustomerPaymentMethod cpm = PXSelect <CustomerPaymentMethod, Where <CustomerPaymentMethod.paymentMethodID, Equal <Required <CustomerPaymentMethod.paymentMethodID> >, And <CustomerPaymentMethod.cashAccountID, Equal <Required <CustomerPaymentMethod.cashAccountID> > > > > .SelectWindowed(this, 0, 1, row.PaymentMethodID, row.CashAccountID); if (cpm != null) { throw new PXException(Messages.PaymentMethodAccountIsInUseAndCantBeDeleted); } } }
protected virtual void PaymentMethodAccount_RowUpdating(PXCache cache, PXRowUpdatingEventArgs e) { PaymentMethodAccount row = (PaymentMethodAccount)e.NewRow; if (row != null) { PaymentMethodAccount oldrow = (PaymentMethodAccount)e.Row; if ((row.UseForAP != oldrow.UseForAP) && !row.UseForAP.GetValueOrDefault(false)) { row.APIsDefault = false; } if ((row.UseForAR != oldrow.UseForAR) && !row.UseForAR.GetValueOrDefault(false)) { row.ARIsDefault = false; } } }
protected virtual void PaymentMethodAccount_UseForAP_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e) { PaymentMethodAccount row = (PaymentMethodAccount)e.Row; CA.PaymentMethod pm = this.PaymentMethod.Current; if (row != null && pm != null) { e.NewValue = (pm.UseForAP == true); if (pm.UseForAP == true && row.CashAccountID.HasValue) { CashAccount c = PXSelectReadonly <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(this, row.CashAccountID); e.NewValue = (c != null); } e.Cancel = true; } }
protected virtual void PaymentMethodAccount_RowInserting(PXCache cache, PXRowInsertingEventArgs e) { PaymentMethodAccount row = (PaymentMethodAccount)e.Row; if (row == null) { return; } if (String.IsNullOrEmpty(row.PaymentMethodID) == false && row.CashAccountID.HasValue) { foreach (PXResult <PaymentMethodAccount, CashAccount> iRes in this.CashAccounts.Select()) { PaymentMethodAccount it = iRes; if (!object.ReferenceEquals(row, it) && it.PaymentMethodID == row.PaymentMethodID && row.CashAccountID == it.CashAccountID) { CashAccount acct = iRes; throw new PXSetPropertyException(Messages.DuplicatedCashAccountForPaymentMethod, acct.CashAccountCD); } } } }
protected virtual void PaymentMethodAccount_CashAccountID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e) { PaymentMethodAccount row = (PaymentMethodAccount)e.Row; cache.SetDefaultExt <PaymentMethodAccount.useForAP>(row); }
protected virtual void CAEntryType_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { CAEntryType row = (CAEntryType)e.Row; if (row != null) { if (row.Module == GL.BatchModule.CA) { PXUIFieldAttribute.SetEnabled <CAEntryType.referenceID>(this.EntryType.Cache, row, false); PXUIFieldAttribute.SetEnabled <CAEntryType.accountID>(sender, row, true); PXUIFieldAttribute.SetEnabled <CAEntryType.subID>(sender, row, true); } else { PXUIFieldAttribute.SetEnabled <CAEntryType.referenceID>(this.EntryType.Cache, row, true); PXUIFieldAttribute.SetEnabled <CAEntryType.accountID>(sender, row, false); PXUIFieldAttribute.SetEnabled <CAEntryType.subID>(sender, row, false); } PXUIFieldAttribute.SetEnabled <CAEntryType.useToReclassifyPayments>(sender, row, row.Module == GL.BatchModule.CA); bool isInserted = sender.GetStatus(e.Row) == PXEntryStatus.Inserted; PXUIFieldAttribute.SetEnabled <CAEntryType.entryTypeId>(sender, row, isInserted); bool usesCashAccount = false; GL.Account acct = null; CashAccount cashAcct = null; if (row.AccountID != null && row.SubID != null) { cashAcct = PXSelectReadonly <CashAccount, Where <CashAccount.accountID, Equal <Required <CashAccount.accountID> >, And <CashAccount.subID, Equal <Required <CashAccount.subID> > > > > .Select(this, row.AccountID, row.SubID); acct = PXSelectReadonly <GL.Account, Where <GL.Account.accountID, Equal <Required <GL.Account.accountID> > > > .Select(this, row.AccountID); usesCashAccount = (cashAcct != null); } PXUIFieldAttribute.SetEnabled <CAEntryType.accountID>(sender, row, row.UseToReclassifyPayments != true); PXUIFieldAttribute.SetEnabled <CAEntryType.subID>(sender, row, row.UseToReclassifyPayments != true); PXUIFieldAttribute.SetEnabled <CAEntryType.branchID>(sender, row, row.UseToReclassifyPayments != true && usesCashAccount); PXUIFieldAttribute.SetEnabled <CAEntryType.cashAccountID>(sender, row, row.UseToReclassifyPayments == true); if (row.UseToReclassifyPayments == true && acct != null && acct.AccountID.HasValue) { if (!usesCashAccount) { sender.RaiseExceptionHandling <CAEntryType.accountID>(e.Row, acct.AccountCD, new PXSetPropertyException(Messages.CAEntryTypeUsedForPaymentReclassificationMustHaveCashAccount, PXErrorLevel.Error)); } else { PaymentMethodAccount pmAccount = PXSelectReadonly2 <PaymentMethodAccount, InnerJoin <PaymentMethod, On <PaymentMethod.paymentMethodID, Equal <PaymentMethodAccount.paymentMethodID>, And <PaymentMethod.isActive, Equal <True> > > >, Where <PaymentMethodAccount.cashAccountID, Equal <Required <PaymentMethodAccount.cashAccountID> >, And <Where <PaymentMethodAccount.useForAP, Equal <True>, Or <PaymentMethodAccount.useForAR, Equal <True> > > > > > .Select(this, row.CashAccountID); if (pmAccount == null || pmAccount.CashAccountID.HasValue == false) { sender.RaiseExceptionHandling <CAEntryType.cashAccountID>(e.Row, cashAcct.CashAccountCD, new PXSetPropertyException(Messages.EntryTypeCashAccountIsNotConfiguredToUseWithAnyPaymentMethod, PXErrorLevel.Warning)); } else { sender.RaiseExceptionHandling <CAEntryType.accountID>(e.Row, null, null); } } } else { row.CashAccountID = null; sender.RaiseExceptionHandling <CAEntryType.accountID>(e.Row, null, null); } } }
protected virtual void PaymentMethodAccount_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e) { PaymentMethodAccount row = (PaymentMethodAccount)e.Row; bool needRefresh = false; if (row != null) { PaymentMethodAccount oldrow = (PaymentMethodAccount)e.OldRow; if ((row.ARIsDefault != oldrow.ARIsDefault) && row.ARIsDefault.GetValueOrDefault(false)) { CashAccount rowc = PXSelectReadonly <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(this, row.CashAccountID); foreach (PXResult <PaymentMethodAccount, CashAccount> rr in this.CashAccounts.Select()) { PaymentMethodAccount it = rr; CashAccount ic = rr; if (row.ARIsDefault == true && rowc.BranchID == ic.BranchID && !(row.PaymentMethodID == it.PaymentMethodID && row.CashAccountID == it.CashAccountID)) { it.ARIsDefault = false; this.CashAccounts.Update(it); } } needRefresh = true; } if ((row.ARIsDefaultForRefund != oldrow.ARIsDefaultForRefund) && row.ARIsDefaultForRefund.GetValueOrDefault(false)) { CashAccount rowc = PXSelectReadonly <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(this, row.CashAccountID); foreach (PXResult <PaymentMethodAccount, CashAccount> rr in this.CashAccounts.Select()) { PaymentMethodAccount it = rr; CashAccount ic = rr; if (row.ARIsDefaultForRefund == true && rowc.BranchID == ic.BranchID && !(row.PaymentMethodID == it.PaymentMethodID && row.CashAccountID == it.CashAccountID)) { it.ARIsDefaultForRefund = false; this.CashAccounts.Update(it); } } needRefresh = true; } if ((row.APIsDefault != oldrow.APIsDefault) && row.APIsDefault.GetValueOrDefault(false)) { CashAccount rowc = PXSelectReadonly <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(this, row.CashAccountID); foreach (PXResult <PaymentMethodAccount, CashAccount> rr in this.CashAccounts.Select()) { PaymentMethodAccount it = rr; CashAccount ic = rr; if (it.APIsDefault == true && rowc.BranchID == ic.BranchID && !(row.PaymentMethodID == it.PaymentMethodID && row.CashAccountID == it.CashAccountID)) { it.APIsDefault = false; this.CashAccounts.Update(it); } } needRefresh = true; } if (needRefresh) { this.CashAccounts.View.RequestRefresh(); } } }