public IncomingCalculationParameters(PXGraph graph, FABookBalance bookBalance) { Graph = graph; BookBalance = bookBalance; FixedAsset = SelectFrom <FixedAsset> .Where <FixedAsset.assetID.IsEqual <@P.AsInt> > .View .Select(Graph, AssetID); Details = SelectFrom <FADetails> .Where <FADetails.assetID.IsEqual <@P.AsInt> > .View .Select(Graph, AssetID); Method = SelectFrom <FADepreciationMethod> .Where <FADepreciationMethod.methodID.IsEqual <@P.AsInt> > .View .Select(Graph, BookBalance.DepreciationMethodID); Precision = (int)SelectFrom <Currency> .InnerJoin <Company> .On <Company.baseCuryID.IsEqual <Currency.curyID> > .View .Select(Graph) .RowCast <Currency>() .FirstOrDefault() .DecimalPlaces; // TODO: CollectAdditions() must be invoked after AC-156072 implementation Additions = CollectAdditionsFromHistory(); }
public void MarkOriginal(FABookBalance bookBalance) { IsOriginal = true; BusinessUse = bookBalance.BusinessUse * 0.01m ?? 1m; SalvageAmount = bookBalance.SalvageAmount ?? 0m; Section179Amount = bookBalance.Tax179Amount ?? 0m; BonusAmount = bookBalance.BonusAmount ?? 0m; }
private SLMethodAdditionParameters CalculateAdditionParameters( CalculationParameters calculationData, FAAddition addition) { FABookBalance bookBalance = calculationData.BookBalance; #region Parameters Contracts if (bookBalance == null) { throw new ArgumentNullException(nameof(calculationData.BookBalance)); } if (bookBalance.DeprFromDate == null) { throw new ArgumentNullException(nameof(bookBalance.DeprFromDate)); } if (bookBalance.UsefulLife == null) { throw new ArgumentNullException(nameof(bookBalance.UsefulLife)); } #endregion int assetID = calculationData.AssetID; int bookID = calculationData.BookID; SLMethodAdditionParameters parameters = new SLMethodAdditionParameters { DepreciationBasis = addition.DepreciationBasis, PlacedInServiceDate = (DateTime)bookBalance.DeprFromDate }; addition.CalculatedAdditionParameters = parameters; FABookPeriod additionPeriod = IncomingParameters.RepositoryHelper.FindFABookPeriodOfDate( addition.IsOriginal ? parameters.PlacedInServiceDate : addition.Date, bookID, assetID); parameters.DepreciateFromDate = (DateTime)additionPeriod?.StartDate.Value; parameters.DepreciateFromPeriodID = additionPeriod.FinPeriodID; DateTime depreciateToDate = AddUsefulLifeToDate(parameters.DepreciateFromDate, bookBalance.UsefulLife.Value); parameters.DepreciateToPeriodID = IncomingParameters.RepositoryHelper.GetFABookPeriodIDOfDate(depreciateToDate, bookID, assetID); // Consider the suspended periods parameters.SuspendedPeriodIDs = SelectFrom <FABookHistory> .Where <FABookHistory.assetID.IsEqual <@P.AsInt> .And <FABookHistory.bookID.IsEqual <@P.AsInt> > .And <FABookHistory.finPeriodID.IsGreaterEqual <@P.AsString> > .And <FABookHistory.finPeriodID.IsLessEqual <@P.AsString> > .And <FABookHistory.suspended.IsEqual <True> > > .OrderBy <FABookHistory.finPeriodID.Desc> .View .Select( IncomingParameters.Graph, calculationData.AssetID, calculationData.BookID, parameters.DepreciateFromPeriodID, parameters.DepreciateToPeriodID) .RowCast <FABookHistory>() .Select(history => history.FinPeriodID) .ToHashSet(); parameters.DepreciateToPeriodID = IncomingParameters.UtilsHelper.PeriodPlusPeriodsCount( parameters.DepreciateToPeriodID, parameters.SuspendedPeriodIDs.Count, bookID, assetID); return(parameters); }