public void SplitFilter_SplitDate_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            SplitFilter filter = (SplitFilter)e.Row;

            if (filter == null)
            {
                return;
            }

            FABookBalance bal = PXSelect <FABookBalance, Where <FABookBalance.assetID, Equal <Current <SplitFilter.assetID> > >, OrderBy <Desc <FABookBalance.updateGL> > > .SelectSingleBound(this, new object[] { filter });

            if (bal != null)
            {
                if (string.IsNullOrEmpty(bal.CurrDeprPeriod) && !string.IsNullOrEmpty(bal.LastDeprPeriod))
                {
                    e.NewValue = FABookPeriodIDAttribute.PeriodStartDate(this, FABookPeriodIDAttribute.PeriodPlusPeriod(this, bal.LastDeprPeriod, 1, bal.BookID), bal.BookID);
                }
                else
                {
                    FABookPeriod todayPeriod = FABookPeriodIDAttribute.FABookPeriodFromDate(this, Accessinfo.BusinessDate, bal.BookID);
                    e.NewValue = string.CompareOrdinal(bal.CurrDeprPeriod, todayPeriod.FinPeriodID) > 0 ? FABookPeriodIDAttribute.PeriodStartDate(this, bal.CurrDeprPeriod, bal.BookID) : Accessinfo.BusinessDate;
                }
            }
            else
            {
                e.NewValue = Accessinfo.BusinessDate;
            }
        }
Exemple #2
0
        protected override void TYearSetupOnRowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            base.TYearSetupOnRowSelected(cache, e);
            FABookYearSetup yearSetup = (FABookYearSetup)e.Row;
            FABookBalance   bal       = PXSelect <FABookBalance, Where <FABookBalance.bookID, Equal <Current <FABookYearSetup.bookID> > > > .SelectSingleBound(this, new object[] { yearSetup });

            FABookYear year = null;

            if (bal == null)
            {
                year = PXSelect <FABookYear, Where <FABookYear.bookID, Equal <Current <FABookYearSetup.bookID> > > > .SelectSingleBound(this, new object[] { yearSetup });
            }
            DeleteGeneratedPeriods.SetEnabled(bal == null && year != null);
        }
        protected virtual void FATran_FinPeriodID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            FATran tran = (FATran)e.Row;

            if (tran?.AssetID == null || tran.BookID == null || tran.TranDate == null)
            {
                return;
            }

            try
            {
                // TODO: AC-106141
                // Use BranchID of the fixed asset referenced by local FATran
                FABookPeriod period = PXSelect <
                    FABookPeriod,
                    Where <FABookPeriod.bookID, Equal <Required <FABookPeriod.bookID> >,
                           And <FABookPeriod.finPeriodID, Equal <Required <FABookPeriod.finPeriodID> > > > >
                                      .Select(this, tran.BookID, (string)e.NewValue);

                if (period == null)
                {
                    throw new PXSetPropertyException(Messages.NoPeriodsDefined);
                }

                FABookBalance bal = bookbalances.SelectSingle(tran.AssetID, tran.BookID);


                if ((tran.TranType == FATran.tranType.DepreciationPlus || tran.TranType == FATran.tranType.DepreciationMinus) && tran.Origin == FARegister.origin.Adjustment)
                {
                    if (!string.IsNullOrEmpty(bal.CurrDeprPeriod) && string.CompareOrdinal((string)e.NewValue, bal.CurrDeprPeriod) >= 0)
                    {
                        throw new PXSetPropertyException(CS.Messages.Entry_LT, FinPeriodIDFormattingAttribute.FormatForError(bal.CurrDeprPeriod));
                    }
                    if (!string.IsNullOrEmpty(bal.LastDeprPeriod) && string.CompareOrdinal((string)e.NewValue, bal.LastDeprPeriod) > 0)
                    {
                        throw new PXSetPropertyException(CS.Messages.Entry_LE, FinPeriodIDFormattingAttribute.FormatForError(bal.LastDeprPeriod));
                    }
                    if (!string.IsNullOrEmpty(bal.DeprFromPeriod) && string.CompareOrdinal((string)e.NewValue, bal.DeprFromPeriod) < 0)
                    {
                        throw new PXSetPropertyException(CS.Messages.Entry_GE, FinPeriodIDFormattingAttribute.FormatForError(bal.DeprFromPeriod));
                    }
                }
            }
            catch (PXSetPropertyException)
            {
                e.NewValue = FinPeriodIDAttribute.FormatForDisplay((string)e.NewValue);
                throw;
            }
        }
Exemple #4
0
        protected virtual void FADepreciationMethod_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            FADepreciationMethod meth = (FADepreciationMethod)e.Row;

            if (meth == null)
            {
                return;
            }

            FABookSettings sett = PXSelect <FABookSettings, Where <FABookSettings.depreciationMethodID, Equal <Required <FADepreciationMethod.methodID> > > > .Select(this, meth.MethodID);

            FABookBalance bal = PXSelect <FABookBalance, Where <FABookBalance.depreciationMethodID, Equal <Required <FADepreciationMethod.methodID> > > > .Select(this, meth.MethodID);

            if (sett != null || bal != null)
            {
                throw new PXSetPropertyException(Messages.FADeprMethodUsedInAssets);
            }
        }
Exemple #5
0
        protected virtual void FATran_FinPeriodID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            FATran tran = (FATran)e.Row;

            if (tran == null || tran.AssetID == null || tran.BookID == null)
            {
                return;
            }

            try
            {
                FABookPeriod p = PXSelect <FABookPeriod,
                                           Where <FABookPeriod.bookID, Equal <Required <FABookPeriod.bookID> >,
                                                  And <FABookPeriod.finPeriodID, Equal <Required <FABookPeriod.finPeriodID> > > > > .Select(this, tran.BookID, (string)e.NewValue);

                if (p == null)
                {
                    throw new PXSetPropertyException(Messages.NoPeriodsDefined);
                }

                FABookBalance bal = PXSelect <FABookBalance,
                                              Where <FABookBalance.assetID, Equal <Required <FABookBalance.assetID> >,
                                                     And <FABookBalance.bookID, Equal <Required <FABookBalance.bookID> > > > > .Select(this, tran.AssetID, tran.BookID);


                if ((tran.TranType == FATran.tranType.DepreciationPlus || tran.TranType == FATran.tranType.DepreciationMinus) && tran.Origin == FARegister.origin.Adjustment)
                {
                    if (!string.IsNullOrEmpty(bal.CurrDeprPeriod) && String.Compare((string)e.NewValue, bal.CurrDeprPeriod) >= 0)
                    {
                        throw new PXSetPropertyException(CS.Messages.Entry_LT, FinPeriodIDFormattingAttribute.FormatForError(bal.CurrDeprPeriod));
                    }
                    if (!string.IsNullOrEmpty(bal.LastDeprPeriod) && String.Compare((string)e.NewValue, bal.LastDeprPeriod) > 0)
                    {
                        throw new PXSetPropertyException(CS.Messages.Entry_LE, FinPeriodIDFormattingAttribute.FormatForError(bal.LastDeprPeriod));
                    }
                }
            }
            catch (PXSetPropertyException)
            {
                e.NewValue = FinPeriodSelectorAttribute.FormatForDisplay((string)e.NewValue);
                throw;
            }
        }
        protected virtual void FABookBalance_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            FABookBalance bal = (FABookBalance)e.Row;

            if (bal == null || PXLongOperation.Exists(UID))
            {
                return;
            }

            try
            {
                AssetProcess.CheckUnreleasedTransactions(this, bal);
            }
            catch (PXException exc)
            {
                PXUIFieldAttribute.SetEnabled <FABookBalance.selected>(sender, bal, false);
                sender.RaiseExceptionHandling <FABookBalance.selected>(bal, null, new PXSetPropertyException(exc.MessageNoNumber, PXErrorLevel.RowWarning));
            }
        }
 public int GetFABookPeriodOrganizationID(FABookBalance balance, bool check = true)
 {
     return(GetFABookPeriodOrganizationID(balance.BookID, balance.AssetID, check));
 }