/// <summary> /// Ported from changed_value_posts::output_revaluation /// </summary> public void OutputRevaluation(Post post, Date date) { if (date.IsValid()) { post.XData.Date = date; } try { BindScope boundScope = new BindScope(Report, post); RepricedTotal = TotalExpr.Calc(boundScope); } finally { post.XData.Date = default(Date); } if (!Value.IsNullOrEmpty(LastTotal)) { Value diff = RepricedTotal - LastTotal; if (!Value.IsNullOrEmptyOrFalse(diff)) { Xact xact = Temps.CreateXact(); xact.Payee = "Commodities revalued"; xact.Date = date.IsValid() ? date : post.ValueDate; if (!ForAccountsReports) { FiltersCommon.HandleValue( /* value= */ diff, /* account= */ RevaluedAccount, /* xact= */ xact, /* temps= */ Temps, /* handler= */ (PostHandler)Handler, /* date= */ xact.Date.Value, /* act_date_p= */ true, /* total= */ RepricedTotal); } else if (ShowUnrealized) { FiltersCommon.HandleValue( /* value= */ diff.Negated(), /* account= */ (diff.IsLessThan(Value.Zero) ? LossesEquityAccount : GainsEquityAccount), /* xact= */ xact, /* temps= */ Temps, /* handler= */ (PostHandler)Handler, /* date= */ xact.Date.Value, /* act_date_p= */ true, /* total= */ new Value(), /* direct_amount= */ false, /* mark_visited= */ true); } } } }
public override void Clear() { TotalExpr.MarkUncomplited(); DisplayTotalExpr.MarkUncomplited(); LastPost = null; LastTotal = new Value(); Temps.Clear(); base.Clear(); CreateAccounts(); }
/// <summary> /// Ported from void changed_value_posts::operator()(post_t& post) /// </summary> public override void Handle(Post post) { if (LastPost != null) { if (!ForAccountsReports && !HistoricalPricesOnly) { OutputIntermediatePrices(LastPost, post.ValueDate); } OutputRevaluation(LastPost, post.ValueDate); } if (ChangedValuesOnly) { post.XData.Displayed = true; } base.Handle(post); BindScope boundScope = new BindScope(Report, post); LastTotal = TotalExpr.Calc(boundScope); LastPost = post; }
/// <summary> /// Ported from changed_value_posts::output_revaluation /// </summary> public void OutputRevaluation(Post post, Date date) { if (date.IsValid()) { post.XData.Date = date; } try { BindScope boundScope = new BindScope(Report, post); RepricedTotal = TotalExpr.Calc(boundScope); } finally { post.XData.Date = default(Date); } Logger.Current.Debug("filters.changed_value", () => String.Format("output_revaluation(last_total) = {0}", LastTotal)); Logger.Current.Debug("filters.changed_value", () => String.Format("output_revaluation(repriced_total) = {0}", RepricedTotal)); if (!Value.IsNullOrEmpty(LastTotal)) { Value diff = RepricedTotal - LastTotal; if (!Value.IsNullOrEmptyOrFalse(diff)) { Logger.Current.Debug("filters.changed_value", () => String.Format("output_revaluation(strip(diff)) = {0}", diff.StripAnnotations(Report.WhatToKeep()))); Xact xact = Temps.CreateXact(); xact.Payee = "Commodities revalued"; xact.Date = date.IsValid() ? date : post.ValueDate; if (!ForAccountsReports) { FiltersCommon.HandleValue( /* value= */ diff, /* account= */ RevaluedAccount, /* xact= */ xact, /* temps= */ Temps, /* handler= */ (PostHandler)Handler, /* date= */ xact.Date.Value, /* act_date_p= */ true, /* total= */ RepricedTotal); } else if (ShowUnrealized) { FiltersCommon.HandleValue( /* value= */ diff.Negated(), /* account= */ (diff.IsLessThan(Value.Zero) ? LossesEquityAccount : GainsEquityAccount), /* xact= */ xact, /* temps= */ Temps, /* handler= */ (PostHandler)Handler, /* date= */ xact.Date.Value, /* act_date_p= */ true, /* total= */ new Value(), /* direct_amount= */ false, /* mark_visited= */ true); } } } }