public override void Persist() { foreach (FABookSettings set in DepreciationSettings.Cache.Inserted.Cast <FABookSettings>().Concat <FABookSettings>(DepreciationSettings.Cache.Updated.Cast <FABookSettings>())) { FABook book = PXSelect <FABook, Where <FABook.bookID, Equal <Required <FABook.bookID> > > > .SelectWindowed(this, 0, 1, set.BookID); IYearSetup yearSetup = FABookPeriodIDAttribute.GetBookCalendar(this, book); if (yearSetup == null || !yearSetup.IsFixedLengthPeriod) { FABookPeriodSetup period = PXSelect <FABookPeriodSetup, Where <FABookPeriodSetup.bookID, Equal <Required <FABookPeriodSetup.bookID> > > > .SelectWindowed(this, 0, 1, set.BookID); if (period == null && set.UpdateGL == false && book != null) { DepreciationSettings.Cache.RaiseExceptionHandling <FABookSettings.bookID>(set, book.BookCode, new PXSetPropertyException <FABookSettings.bookID>(Messages.NoCalendarDefined)); } } FADepreciationMethod method = PXSelect <FADepreciationMethod, Where <FADepreciationMethod.methodID, Equal <Required <FABookSettings.depreciationMethodID> > > > .SelectWindowed(this, 0, 1, set.DepreciationMethodID); if (method != null && method.IsTableMethod == true && method.UsefulLife != set.UsefulLife) { DepreciationSettings.Cache.RaiseExceptionHandling <FABookSettings.usefulLife>(set, set.UsefulLife, new PXSetPropertyException <FABookSettings.usefulLife>(Messages.UsefulLifeNotMatchDeprMethod)); } } base.Persist(); }
protected virtual void FABookSettings_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { FABookSettings set = (FABookSettings)e.Row; if (set == null) { return; } PXUIFieldAttribute.SetEnabled <FABookSettings.bookID>(sender, set, set.BookID == null); IYearSetup yearSetup = FABookPeriodIDAttribute.GetBookCalendar(this, set.BookID); FADepreciationMethod method = PXSelect <FADepreciationMethod, Where <FADepreciationMethod.methodID, Equal <Current <FABookSettings.depreciationMethodID> > > > .SelectSingleBound(this, new object[] { set }); List <KeyValuePair <object, Dictionary <object, string[]> > > parsList = new List <KeyValuePair <object, Dictionary <object, string[]> > >(); if (method != null) { parsList.Add(method.IsTableMethod == true ? new KeyValuePair <object, Dictionary <object, string[]> >(method.RecordType, FAAveragingConvention.RecordTypeDisabledValues) : new KeyValuePair <object, Dictionary <object, string[]> >(method.DepreciationMethod, FAAveragingConvention.DeprMethodDisabledValues)); } if (yearSetup != null) { parsList.Add(new KeyValuePair <object, Dictionary <object, string[]> >(yearSetup.IsFixedLengthPeriod, FAAveragingConvention.FixedLengthPeriodDisabledValues)); } FAAveragingConvention.SetAveragingConventionsList <FADepreciationMethod.averagingConvention>(sender, set, parsList.ToArray()); }