public override void Flush() { StringBuilder sb = new StringBuilder(); if (Report.DisplayHandler.Handled) { Logger.Current.Debug("account.display", () => String.Format("Account display predicate: {0}", Report.DisplayHandler.Str())); DispPred.Parse(Report.DisplayHandler.Str()); } MarkAccounts(Report.Session.Journal.Master, Report.FlatHandler.Handled); int displayed = PostedAccounts.Sum(account => PostAccount(account, Report.FlatHandler.Handled)); if (displayed > 1 && !Report.NoTotalHandler.Handled && !Report.PercentHandler.Handled) { BindScope boundScope = new BindScope(Report, Report.Session.Journal.Master); sb.Append(SeparatorFormat?.Calc(boundScope)); if (PrependFormat != null) { sb.AppendFormat(StringExtensions.GetWidthAlignFormatString(PrependWidth), PrependFormat.Calc(boundScope)); } sb.Append(TotalLineFormat.Calc(boundScope)); } Report.OutputStream.Write(sb.ToString()); }
public override void Clear() { DispPred.MarkUncomplited(); PostedAccounts.Clear(); ReportTitle = string.Empty; base.Clear(); }
public Tuple <int, int> MarkAccounts(Account account, bool flat) { int visited = 0; int toDisplay = 0; foreach (Account acc in account.Accounts.Values) { Tuple <int, int> i = MarkAccounts(acc, flat); visited += i.Item1; toDisplay += i.Item2; } if (Logger.Current.ShowDebug(DebugAccountDisplay)) { Logger.Current.Debug(DebugAccountDisplay, () => "Considering account: " + account.FullName); if (account.HasXFlags(d => d.Visited)) { Logger.Current.Debug(DebugAccountDisplay, () => " it was visited itself"); } Logger.Current.Debug(DebugAccountDisplay, () => " it has " + visited + " visited children"); Logger.Current.Debug(DebugAccountDisplay, () => " it has " + toDisplay + " children to display"); } if (account.Parent != null && (account.HasXFlags(d => d.Visited) || (!flat && visited > 0))) { BindScope boundScope = new BindScope(Report, account); CallScope callScope = new CallScope(boundScope); if ((!flat && toDisplay > 1) || ((flat || toDisplay != 1 || account.HasXFlags(d => d.Visited)) && (Report.EmptyHandler.Handled || !Value.IsNullOrEmptyOrFalse(Report.DisplayValue(Report.FnDisplayTotal(callScope)))) && !Value.IsNullOrEmptyOrFalse(DispPred.Calc(boundScope)))) { account.XData.ToDisplay = true; Logger.Current.Debug(DebugAccountDisplay, () => "Marking account as TO_DISPLAY"); toDisplay = 1; } visited = 1; } return(new Tuple <int, int>(visited, toDisplay)); }