Example #1
0
        protected virtual void CAEntryType_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            CAEntryType row = e.Row as CAEntryType;

            PXDefaultAttribute.SetPersistingCheck <CAEntryType.referenceID>(sender, e.Row, PXPersistingCheck.Nothing);

            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Update)
            {
                CAAdj foundCAAdj = PXSelectReadonly <CAAdj,
                                                     Where <CAAdj.entryTypeID, Equal <Required <CAAdj.entryTypeID> > > > .
                                   Select(this, row.EntryTypeId);

                if (foundCAAdj != null)
                {
                    CAEntryType foundCAEntryType = PXSelectReadonly <CAEntryType,
                                                                     Where <CAEntryType.entryTypeId, Equal <Required <CAEntryType.entryTypeId> > > > .
                                                   Select(this, row.EntryTypeId);

                    if (foundCAEntryType != null)
                    {
                        if (row.DrCr != foundCAEntryType.DrCr)
                        {
                            if (sender.RaiseExceptionHandling <CAEntryType.drCr>(e.Row, row.DrCr, new PXSetPropertyException(Messages.CantEditDisbReceipt, PXErrorLevel.RowError, typeof(CAEntryType.drCr).Name)))
                            {
                                throw new PXRowPersistingException(typeof(CAEntryType.drCr).Name, row.DrCr, Messages.CantEditDisbReceipt, typeof(CAEntryType.drCr).Name);
                            }
                        }
                        if (row.Module != foundCAEntryType.Module)
                        {
                            if (sender.RaiseExceptionHandling <CAEntryType.module>(e.Row, row.Module, new PXSetPropertyException(Messages.CantEditModule, PXErrorLevel.RowError, typeof(CAEntryType.module).Name)))
                            {
                                throw new PXRowPersistingException(typeof(CAEntryType.module).Name, row.Module, Messages.CantEditModule, typeof(CAEntryType.module).Name);
                            }
                        }
                    }
                }
            }
            if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete)
            {
                if (row.UseToReclassifyPayments == true && row.AccountID.HasValue)
                {
                    CashAccount cashAcct = PXSelectReadonly <CashAccount,
                                                             Where <CashAccount.accountID, Equal <Required <CashAccount.accountID> >,
                                                                    And <CashAccount.subID, Equal <Required <CashAccount.subID> > > > > .Select(this, row.AccountID, row.SubID);

                    GL.Account acct = PXSelectReadonly <Account,
                                                        Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(this, row.AccountID);

                    if (cashAcct == null || !cashAcct.AccountID.HasValue)
                    {
                        if (sender.RaiseExceptionHandling <CAEntryType.accountID>(e.Row, acct.AccountCD, new PXSetPropertyException(Messages.CAEntryTypeUsedForPaymentReclassificationMustHaveCashAccount, PXErrorLevel.Error)))
                        {
                            throw new PXRowPersistingException(typeof(CAEntryType.accountID).Name, acct.AccountCD, Messages.CAEntryTypeUsedForPaymentReclassificationMustHaveCashAccount);
                        }
                    }
                }
            }
        }
        protected virtual void EnsureWildcards()
        {
            if (acctWildcard == null)
            {
                Dimension dim = PXSelect <Dimension,
                                          Where <Dimension.dimensionID, Equal <Required <Dimension.dimensionID> > > >
                                .Select(this.Base, GL.AccountAttribute.DimensionName);

                if (dim != null && dim.Length != null)
                {
                    acctWildcard = new String('_', (int)dim.Length);
                }
                else
                {
                    acctWildcard = "";
                }
                dim = PXSelect <Dimension,
                                Where <Dimension.dimensionID, Equal <Required <Dimension.dimensionID> > > >
                      .Select(this.Base, GL.SubAccountAttribute.DimensionName);

                if (dim != null && dim.Length != null)
                {
                    subWildcard = new String('_', (int)dim.Length);
                }
                else
                {
                    subWildcard = "";
                }
                GL.FinYearSetup fysetup = PXSelect <GL.FinYearSetup> .Select(this.Base);

                if (fysetup != null && fysetup.FinPeriods != null)
                {
                    finPeriods = (short)fysetup.FinPeriods;
                }
                GL.Account niacct = PXSelect <GL.Account,
                                              Where <GL.Account.accountID, Equal <Required <GL.GLSetup.ytdNetIncAccountID> > > >
                                    .Select(this.Base, setup.Current.YtdNetIncAccountID);

                if (niacct != null)
                {
                    ytdNetIncomeCD = niacct.AccountCD;
                }
            }
        }
Example #3
0
        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);
                }
            }
        }