public override void Handle(Post post) { if (!post.HasXData || !post.XData.Displayed) { StringBuilder sb = new StringBuilder(); BindScope boundScope = new BindScope(Report, post); if (!String.IsNullOrEmpty(ReportTitle)) { if (FirstReportTitle) { FirstReportTitle = false; } else { sb.AppendLine(); } ValueScope valScope = new ValueScope(boundScope, Value.StringValue(ReportTitle)); Format groupTitleFormat = new Format(Report.GroupTitleFormatHandler.Str()); sb.Append(groupTitleFormat.Calc(valScope)); ReportTitle = string.Empty; } if (PrependFormat != null) { sb.AppendFormat(StringExtensions.GetWidthAlignFormatString(PrependWidth), PrependFormat.Calc(boundScope)); } if (LastXact != post.Xact) { if (LastXact != null) { BindScope xactScope = new BindScope(Report, LastXact); if (BetweenFormat != null) // DM - in the original code, between_format is called w/o instantiating and returns nothing { sb.Append(BetweenFormat.Calc(xactScope)); } } sb.Append(FirstLineFormat.Calc(boundScope)); LastXact = post.Xact; } else if (LastPost != null && LastPost.GetDate() != post.GetDate()) { sb.Append(FirstLineFormat.Calc(boundScope)); } else { sb.Append(NextLineFormat.Calc(boundScope)); } post.XData.Displayed = true; LastPost = post; Report.OutputStream.Write(sb.ToString()); } }
public void RegisterMetadata(string key, Value value, Item context) { if (CheckingStyle == JournalCheckingStyleEnum.CHECK_WARNING || CheckingStyle == JournalCheckingStyleEnum.CHECK_ERROR) { if (!KnownTags.Contains(key)) { if (context == null) { if (ForceChecking) { FixedMetadata = true; } KnownTags.Add(key); } else if (!FixedMetadata && context != null && context.State != ItemStateEnum.Uncleared) { KnownTags.Add(key); } else if (CheckingStyle == JournalCheckingStyleEnum.CHECK_WARNING) { CurrentContext.Warning(String.Format("Unknown metadata tag '{0}'", key)); } else if (CheckingStyle == JournalCheckingStyleEnum.CHECK_ERROR) { throw new ParseError(String.Format("Unknown metadata tag '{0}'", key)); } } } if (!Value.IsNullOrEmpty(value)) { foreach (CheckExprPair pair in TagCheckExprsMap.GetValues(key)) { BindScope boundScope = new BindScope(CurrentContext.Scope, context); ValueScope valScope = new ValueScope(boundScope, value); if (!pair.Expr.Calc(valScope).AsBoolean) { if (pair.CheckExprKind == CheckExprKindEnum.EXPR_ASSERTION) { throw new ParseError(String.Format(ParseError.ParseError_MetadataAssertionFailedFor, key, value, pair.Expr)); } else { CurrentContext.Warning(String.Format(ParseError.ParseError_MetadataCheckFailedFor, key, value, pair.Expr)); } } } } }
public virtual int PostAccount(Account account, bool flat) { if (!flat && account.Parent != null) { PostAccount(account.Parent, flat); } if (account.XData.ToDisplay && !account.XData.Displayed) { StringBuilder sb = new StringBuilder(); Logger.Current.Debug("account.display", () => String.Format("Displaying account: {0}", account.FullName)); account.XData.Displayed = true; BindScope boundScope = new BindScope(Report, account); if (!String.IsNullOrEmpty(ReportTitle)) { if (FirstReportTitle) { FirstReportTitle = false; } else { sb.AppendLine(); } ValueScope valScope = new ValueScope(boundScope, Value.StringValue(ReportTitle)); Format groupTitleFormat = new Format(Report.GroupTitleFormatHandler.Str()); sb.Append(groupTitleFormat.Calc(valScope)); ReportTitle = string.Empty; } if (PrependFormat != null) { sb.AppendFormat(StringExtensions.GetWidthAlignFormatString(PrependWidth), PrependFormat.Calc(boundScope)); } sb.Append(AccountLineFormat.Calc(boundScope)); Report.OutputStream.Write(sb.ToString()); return(1); } return(0); }
public ValueNameSelectAttribute(ValueScope scope) { _valueScope = scope; }
/// <summary> /// Ported from void posts_to_org_table::operator()(post_t& post) /// </summary> public override void Handle(Post post) { if (!post.HasXData || !post.XData.Displayed) { StringBuilder sb = new StringBuilder(); BindScope boundScope = new BindScope(Report, post); if (!HeaderPrinted) { sb.AppendLine("|Date|Code|Payee|X|Account|Amount|Total|Note|"); sb.AppendLine("|-|"); sb.AppendLine("|||<20>|||<r>|<r>|<20>|"); HeaderPrinted = true; } if (!String.IsNullOrEmpty(ReportTitle)) { if (FirstReportTitle) { FirstReportTitle = false; } else { sb.AppendLine(); } ValueScope valScope = new ValueScope(boundScope, Value.StringValue(ReportTitle)); Format groupTitleFormat = new Format(Report.GroupTitleFormatHandler.Str()); sb.AppendLine("|-|"); sb.Append("|" + groupTitleFormat.Calc(valScope)); sb.AppendLine("|-|"); ReportTitle = String.Empty; } if (PrependFormat != null) { sb.Append("|" + PrependFormat.Calc(boundScope)); } if (LastXact != post.Xact) { sb.Append(FirstLineFormat.Calc(boundScope)); LastXact = post.Xact; } else if (LastPost != null && LastPost.GetDate() != post.GetDate()) { sb.Append(FirstLineFormat.Calc(boundScope)); } else { sb.Append(NextLineFormat.Calc(boundScope)); } Value amt = new Expr("display_amount").Calc(boundScope).Simplified(); Value tot = new Expr("display_total").Calc(boundScope).Simplified(); if (amt.Type == ValueTypeEnum.Balance || tot.Type == ValueTypeEnum.Balance) { Balance amtBal = amt.AsBalance; Balance totBal = tot.AsBalance; var i = amtBal.Amounts.GetIterator(); var j = totBal.Amounts.GetIterator(); bool first = true; while (!i.IsEnd || !j.IsEnd) { if (first) { first = false; if (!i.IsEnd) { i.MoveNext(); } if (!j.IsEnd) { j.MoveNext(); } } else { SymbolScope callScope = new SymbolScope(boundScope); bool assigned = false; if (!i.IsEnd) { if (i.Current.Value != null) { Logger.Current.Debug(DebugOrgNextAmount, () => String.Format("next_amount = {0}", i.Current.Value)); callScope.Define(SymbolKindEnum.FUNCTION, "next_amount", ExprOp.WrapValue(Value.Get(i.Current.Value))); i.MoveNext(); assigned = true; } else { callScope.Define(SymbolKindEnum.FUNCTION, "next_amount", ExprOp.WrapValue(Value.StringValue(String.Empty))); i.MoveNext(); } } else { callScope.Define(SymbolKindEnum.FUNCTION, "next_amount", ExprOp.WrapValue(Value.StringValue(String.Empty))); } if (!j.IsEnd) { if (j.Current.Value != null) { Logger.Current.Debug(DebugOrgNextTotal, () => String.Format("next_total = {0}", j.Current.Value)); callScope.Define(SymbolKindEnum.FUNCTION, "next_total", ExprOp.WrapValue(Value.Get(j.Current.Value))); j.MoveNext(); Logger.Current.Debug(DebugOrgNextTotal, () => String.Format("2.next_total = {0}", callScope.Lookup(SymbolKindEnum.FUNCTION, "next_total").AsValue)); assigned = true; } else { callScope.Define(SymbolKindEnum.FUNCTION, "next_total", ExprOp.WrapValue(Value.StringValue(String.Empty))); j.MoveNext(); } } else { callScope.Define(SymbolKindEnum.FUNCTION, "next_total", ExprOp.WrapValue(Value.StringValue(String.Empty))); } if (assigned) { AmountLinesFormat.MarkUncomplited(); sb.Append(AmountLinesFormat.Calc(callScope)); } } } } post.XData.Displayed = true; LastPost = post; Report.OutputStream.Write(sb.ToString()); } }
public ValueKeyReferenceAttribute(string keyRefernce, ValueScope scope) { _keyRef = keyRefernce; _scope = scope; }