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; } }
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()); }
public override object Evaluate(PXCache cache, object item, Dictionary<Type, object> pars) { object val = base.Evaluate(cache, item, pars); if (val == null) { return null; } DateTime? recoveryEndDate = (DateTime?)val; int? bookID = (int?)pars[typeof(BookID)]; return FABookPeriodIDAttribute.FormatPeriod(FABookPeriodIDAttribute.PeriodFromDate(cache.Graph, recoveryEndDate, bookID, false)); }
public override object Evaluate(PXCache cache, object item, Dictionary <Type, object> pars) { object val = base.Evaluate(cache, item, pars); if (val == null) { return(null); } DateTime?recoveryEndDate = (DateTime?)val; int? bookID = (int?)pars[typeof(BookID)]; int? assetID = (int?)pars[typeof(AssetID)]; return(FABookPeriodIDAttribute.FormatForDisplay(cache.Graph.GetService <IFABookPeriodRepository>().GetFABookPeriodIDOfDate(recoveryEndDate, bookID, assetID, false))); }
public override object Evaluate(PXCache cache, object item, Dictionary<Type, object> pars) { try { return FABookPeriodIDAttribute.FormatPeriod(DeprCalcParameters.GetRecoveryStartPeriod(cache.Graph, (FABookBalance)item)); } catch (PXException ex) { throw new PXSetPropertyException(ex.Message, PXErrorLevel.Error); } catch { return null; } }
public override void Verify(PXCache cache, object item, List <object> pars, ref bool?result, ref object value) { int? bookID = (int?)Calculate <BookID>(cache, item); decimal?usefulLife = (decimal?)Calculate <UsefulLife>(cache, item); if (bookID == null || usefulLife == null) { value = null; return; } int depreciationPeriodsInYear = FABookPeriodIDAttribute.GetBookPeriodsInYear(cache.Graph, bookID); value = (int)Decimal.Ceiling((decimal)usefulLife * depreciationPeriodsInYear); }
public override void Verify(PXCache cache, object item, List <object> pars, ref bool?result, ref object value) { base.Verify(cache, item, pars, ref result, ref value); if (value == null) { return; } DateTime?recoveryEndDate = (DateTime?)value; int?bookID = (int?)Calculate <BookID>(cache, item); string recoveryEndPeriod = FABookPeriodIDAttribute.PeriodFromDate(cache.Graph, recoveryEndDate, bookID); value = FABookPeriodIDAttribute.FormatPeriod(recoveryEndPeriod); }
public override void Verify(PXCache cache, object item, List <object> pars, ref bool?result, ref object value) { int?bookID = (int?)Calculate <BookID>(cache, item); try { string recoveryStartPeriod = DepreciationCalc.GetRecoveryStartPeriod(cache.Graph, (FABookBalance)item); value = FABookPeriodIDAttribute.FormatPeriod(recoveryStartPeriod); } catch (PXException ex) { throw new PXSetPropertyException(ex.Message, PXErrorLevel.Error); } catch { value = null; } }