protected virtual void Account_CuryID_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e) { Account acct = cache.Locate(e.Row) as Account; string newCuryID = (string)e.NewValue; if (acct != null && string.IsNullOrEmpty(acct.CuryID) && !string.IsNullOrEmpty(newCuryID)) { if (!PostedTransInOtherCuryExists(acct, newCuryID)) { return; } } if (acct != null && acct.CuryID != newCuryID) { if (newCuryID != null || acct.IsCashAccount == true) { bool hasHistory = GLUtility.IsAccountHistoryExist(this, acct.AccountID); if (hasHistory) { throw new PXSetPropertyException(Messages.CannotChangeAccountCurrencyTransactionsExist); } } } if (acct != null && acct.IsCashAccount == true && string.IsNullOrEmpty(newCuryID)) { throw new PXSetPropertyException(Messages.CannotClearCurrencyInCashAccount); } }
protected virtual void Account_Type_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e) { Account acct = e.Row as Account; if (acct.Active != null && acct.Type != (string)e.NewValue && acct.AccountID != null) { bool hasHistory = GLUtility.IsAccountHistoryExist(this, acct.AccountID); if (hasHistory) { throw new PXSetPropertyException(Messages.AccountExistsType); } if (acct.AccountID == GLSetup.Current?.YtdNetIncAccountID && (string)e.NewValue != AccountType.Liability) { throw new PXSetPropertyException(Messages.AccountTypeCannotBeChangedGLYTD, acct.AccountCD); } if (acct.AccountGroupID != null) { var group = (PM.PMAccountGroup)PXSelectorAttribute.Select <Account.accountGroupID>(cache, acct); throw new PXSetPropertyException(Messages.AccountHasGroup, group.GroupCD); } } }
protected virtual void Account_CuryID_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e) { Account acct = cache.Locate(e.Row) as Account; string newCuryID = (string)e.NewValue; if (acct != null && string.IsNullOrEmpty(acct.CuryID) && !string.IsNullOrEmpty(newCuryID)) { if (PXSelect <CuryGLHistory, Where <CuryGLHistory.accountID, Equal <Current <Account.accountID> >, And <CuryGLHistory.curyID, NotEqual <Required <CuryGLHistory.curyID> >, And <CuryGLHistory.balanceType, NotEqual <LedgerBalanceType.report> > > > > .SelectSingleBound(this, new object[] { acct }, newCuryID).Count == 0) { return; } } if (acct != null && acct.CuryID != newCuryID) { bool hasHistory = GLUtility.IsAccountHistoryExist(this, acct.AccountID); if (hasHistory) { throw new PXSetPropertyException(Messages.AccountExistsCurrencyID); } } if (acct != null && acct.IsCashAccount == true && string.IsNullOrEmpty(newCuryID)) { throw new PXSetPropertyException(Messages.CannotClearCurrencyInCashAccount); } }
protected virtual void GLSetup_YtdNetIncAccountID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { GLSetup row = (GLSetup)e.Row; if (row == null) { return; } if (e.NewValue != null) { Account YtdAccNew = PXSelect <Account, Where <Account.accountID, Equal <Required <GLSetup.ytdNetIncAccountID> > > > .Select(this, e.NewValue); if ((int?)e.NewValue == row.RetEarnAccountID) { Account YtdAcc = PXSelect <Account, Where <Account.accountID, Equal <Current <GLSetup.ytdNetIncAccountID> > > > .SelectSingleBound(this, new object[] { row }); Account REAcc = PXSelect <Account, Where <Account.accountID, Equal <Current <GLSetup.retEarnAccountID> > > > .SelectSingleBound(this, new object[] { row }); e.NewValue = YtdAcc == null ? null : YtdAcc.AccountCD; throw new PXSetPropertyException(CS.Messages.Entry_NE, REAcc.AccountCD); } if (YtdAccNew.GLConsolAccountCD != null) { throw new PXSetPropertyException(Messages.AccountCannotBeSpecifiedAsTheYTDNetIncome); } if (GLUtility.IsAccountHistoryExist(this, (int?)e.NewValue)) { e.NewValue = YtdAccNew == null ? null : YtdAccNew.AccountCD; throw new PXSetPropertyException(Messages.AccountExistsHistory2); } } }
protected virtual void GLSetup_RowSelected(PXCache cache, PXRowSelectedEventArgs e) { if (e.Row == null) { return; } GLSetup setup = e.Row as GLSetup; bool hasHistory = GLUtility.IsAccountHistoryExist(this, setup.YtdNetIncAccountID); PXUIFieldAttribute.SetEnabled <GLSetup.ytdNetIncAccountID>(GLSetupRecord.Cache, setup, !hasHistory); PXUIFieldAttribute.SetEnabled <GLSetup.retEarnAccountID>(GLSetupRecord.Cache, setup, true); }
protected virtual void Account_Type_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e) { Account acct = e.Row as Account; if (acct.Active != null && acct.Type != (string)e.NewValue) { bool hasHistory = acct.AccountID != null && GLUtility.IsAccountHistoryExist(this, acct.AccountID); if (hasHistory) { throw new PXSetPropertyException(Messages.AccountExistsType); } } }
protected virtual void GLSetup_RetEarnAccountID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { GLSetup row = (GLSetup)e.Row; if (row == null) { return; } if (e.NewValue != null && (int?)e.NewValue == row.YtdNetIncAccountID) { Account YtdAcc = PXSelect <Account, Where <Account.accountID, Equal <Current <GLSetup.ytdNetIncAccountID> > > > .SelectSingleBound(this, new object[] { row }); Account REAcc = PXSelect <Account, Where <Account.accountID, Equal <Current <GLSetup.retEarnAccountID> > > > .SelectSingleBound(this, new object[] { row }); e.NewValue = REAcc == null ? null : REAcc.AccountCD; throw new PXSetPropertyException(CS.Messages.Entry_NE, YtdAcc.AccountCD); } if (e.NewValue != null && GLUtility.IsAccountHistoryExist(this, (int?)e.NewValue)) { sender.RaiseExceptionHandling <GLSetup.retEarnAccountID>(e.Row, null, new PXSetPropertyException(Messages.AccountExistsHistory2, PXErrorLevel.Warning)); } }