private void processAccount(GncAccount acct, int depth) { var balsnaps = acct.EnumSplits(false).Where(spl => spl.IsBalsnap).ToArray(); if (!balsnaps.Any()) { _report.SetValue(acct, Tr.PgLastBalsnap.ColLast, Tr.PgLastBalsnap.LastNever, "lastbalsnap_never"); } else { var lastsnap = balsnaps.OrderBy(spl => spl.Transaction.DatePosted).Last(); var lastsplit = acct.EnumSplits(false).Last(); if (lastsnap.Balsnap == 0 && object.ReferenceEquals(lastsplit, lastsnap) && lastsnap.AccountBalanceAfter == 0) { _report.SetValue(acct, Tr.PgLastBalsnap.ColLast, Tr.PgLastBalsnap.LastZero, "lastbalsnap_zero"); } else { int days = (int)(DateTime.Today - lastsnap.Transaction.DatePosted).TotalDays; _report.SetValue(acct, Tr.PgLastBalsnap.ColLast, Tr.PgLastBalsnap.LastNDaysAgo.Fmt(Tr.Language.GetNumberSystem(), days), makeCss(days)); } } foreach (var acctChild in acct.EnumChildren()) { processAccount(acctChild, depth + 1); } }
protected override void ProcessAccount(GncAccount acct, int depth) { var intervalTotal = new GncMultiAmount(); int intervalDays = 0, intervalCount = 0; var earliest = acct.Book.EarliestDate; var latest = acct.Book.LatestDate; foreach (var interval in EnumIntervals()) { var tot = ConvertTo == null ? acct.GetTotalWithSubaccounts(interval) : acct.GetTotalConverted(interval, true, ConvertTo); if (Negate) tot.NegateInplace(); // Count only the full months for the purpose of averaging if (interval.Start >= earliest && interval.End <= latest) { intervalTotal.AddInplace(tot); intervalCount++; intervalDays += (int) (interval.End - interval.Start).TotalDays + 1; } SetReportAmount(Report, acct, interval, tot, ConvertTo != null, "/Trns?Acct={0}&Fr={1}&To={2}{3}".Fmt( acct.Path(":").UrlEscape(), interval.Start.Date.ToIsoStringOptimal(), interval.End.Date.ToIsoStringOptimal(), acct.EnumChildren().Any() ? "&SubAccts=true" : "")); } if (intervalCount > 1) { if (!Report.ContainsCol("average")) Report.AddCol("average", Tr.PgMonthlyTotals.ColAverage, "aw-col-average"); intervalTotal.MultiplyInplace(30.43m / intervalDays); // daily average * days in month SetReportAmount(Report, acct, "average", intervalTotal, ConvertTo != null); } }
private void doAccount(GncAccount account, int depth) { ProcessAccount(account, depth); if (depth < MaxDepth || MaxDepth == -1) { foreach (var acctChild in account.EnumChildren()) { doAccount(acctChild, depth + 1); } } }
private IEnumerable <object> listAccount(GncAccount acct, int depth) { yield return(new P("\u2003\u2003".Repeat(depth), new A(acct.Name) { href = Request.Url.WithQuery("Acct", acct.Path(":")).ToHref() })); foreach (var subacct in acct.EnumChildren()) { yield return(listAccount(subacct, depth + 1)); } }
protected override AccountValueInfo GetAccountValue(GncAccount account, int depth) { var interval = new DateInterval(_dateFr, _dateTo); return(new AccountValueInfo { Amount = ConvertTo == null?account.GetTotalWithSubaccounts(interval) : account.GetTotalConverted(interval, true, ConvertTo), Url = "/Trns?Acct={0}&Fr={1}&To={2}{3}".Fmt( account.Path(":").UrlEscape(), _dateFr.ToIsoStringOptimal(), _dateTo.ToIsoStringOptimal(), account.EnumChildren().Any() ? "&SubAccts=true" : ""), }); }
private void doAccount(GncAccount account, int depth) { var value = GetAccountValue(account, depth); SetReportAmount(Report, account, GetColumnCaption(), value.Amount, ConvertTo != null, value.Url); if (depth < MaxDepth || MaxDepth == -1) { foreach (var acctChild in account.EnumChildren()) { doAccount(acctChild, depth + 1); } } }
public void AddAcct(GncAccount acct) { var row = Table.AddRow(); _rowMap.Add(acct, row); row.Depth = acct.Depth - _baseAcct.Depth; string indent = "\u2003\u2003".Repeat(acct.Depth - _baseAcct.Depth - 1); string name = (acct == _baseAcct) ? (Program.Tr.ReportTable_GrandTotal.Fmt(acct.Name)) : acct.Name; if (acct.EnumChildren().Any()) { row.SetValue(_colAcctName, new object[] { indent, new A(name) { class_ = "nocolor", href = _request.Url.WithQuery("Acct", acct.Path(":")).ToHref() } }); } else { row.SetValue(_colAcctName, indent + name); } }
public override object GetContent() { var minDate = DateTime.MinValue; var maxDate = DateTime.MaxValue - TimeSpan.FromDays(1); var frDate = Request.GetValidated("Fr", minDate); var toDate = Request.GetValidated("To", maxDate, dt => dt >= frDate, Tr.PgTrns.Validation_NotBeforeFr); var amtFmt = Request.GetValidated("AmtFmt", "#,0"); _interval = new DateInterval(frDate.Date, toDate.Date + TimeSpan.FromDays(1) - TimeSpan.FromTicks(1)); _account = GetAccount("Acct"); var subAccts = _subaccts = Request.GetValidated("SubAccts", false); var showBalance = Request.GetValidated("ShowBal", false, val => !(val && _subaccts), Tr.PgTrns.Validation_ShowBalVsSubAccts); _subaccts &= _account.EnumChildren().Any(); ReportTable table = new ReportTable(); var colDate = table.AddCol(Tr.PgTrns.ColDate); var colDesc = table.AddCol(Tr.PgTrns.ColDescription); var colQty = table.AddCol(Tr.PgTrns.ColQuantity); var colCcy = table.AddCol(Tr.PgTrns.ColCurrency); var colBal = table.AddCol(Tr.PgTrns.ColBalance); var colAcct = table.AddCol(Tr.PgTrns.ColAccount); var colInBase = table.AddCol(Tr.PgTrns.ColInBaseCcy.Fmt(Program.CurFile.Book.BaseCurrencyId)); if (!_subaccts) { table.Cols.Remove(colAcct); } if (showBalance) { table.Cols.Remove(colInBase); } else { table.Cols.Remove(colBal); } var splits = _account.EnumSplits(_subaccts); splits = splits.Where(split => split.Transaction.DatePosted >= frDate && split.Transaction.DatePosted <= toDate); splits = splits.OrderBy(split => split.Transaction); foreach (var split in splits) { var trn = split.Transaction; var row = table.AddRow(); row.SetValue(colDate, trn.DatePosted.ToShortDateString()); row.SetValue(colDesc, (split.Memo == null || split.Memo == "" || split.Memo == trn.Description) ? trn.Description : (trn.Description + " [" + split.Memo + "]")); row.SetValue(colQty, split.Quantity.ToString(amtFmt), ReportTable.CssClassNumber(split.Quantity)); row.SetValue(colCcy, split.Account.Commodity.Identifier, "ccy_name ccy_" + split.Account.Commodity.Identifier.Replace(":", "_")); if (!showBalance) { row.SetValue(colInBase, split.AmountConverted(Program.CurFile.Book.BaseCurrency).Quantity.ToString(amtFmt), ReportTable.CssClassNumber(split.Quantity)); } if (showBalance) { row.SetValue(colBal, split.AccountBalanceAfter.ToString(amtFmt), ReportTable.CssClassNumber(split.AccountBalanceAfter)); } if (_subaccts) { row.SetValue(colAcct, generateAcctPath(split.Account)); } if (split.IsBalsnap) { try { row.CssClass = split.AccountBalanceAfter == split.Balsnap ? "balsnap_ok" : "balsnap_wrong"; } catch (GncBalsnapParseException) { row.CssClass = "balsnap_error"; } } } return(Ut.NewArray( new P(Tr.PgMonthly.CurAccount, GetAccountBreadcrumbs("Acct", _account)), new P(Tr.PgTrns.ModeCaption, showBalance && !subAccts ? (object)new SPAN(Tr.PgTrns.ModeWithBalance) { class_ = "aw-current" } : new A(Tr.PgTrns.ModeWithBalance) { href = Request.Url.WithQuery("ShowBal", "true").WithoutQuery("SubAccts").ToHref() }, " · ", !showBalance && subAccts ? (object)new SPAN(Tr.PgTrns.ModeWithSubaccts) { class_ = "aw-current" } : new A(Tr.PgTrns.ModeWithSubaccts) { href = Request.Url.WithoutQuery("ShowBal").WithQuery("SubAccts", "true").ToHref() } ), new P(Tr.PgTrns.RoundingCaption, amtFmt == "#,0" ? (object)new SPAN(Tr.PgTrns.RoundingWhole) { class_ = "aw-current" } : new A(Tr.PgTrns.RoundingWhole) { href = Request.Url.WithoutQuery("AmtFmt").ToHref() }, " · ", amtFmt == "#,0.00" ? (object)new SPAN(Tr.PgTrns.RoundingDecimals) { class_ = "aw-current" } : new A(Tr.PgTrns.RoundingDecimals) { href = Request.Url.WithQuery("AmtFmt", "#,0.00").ToHref() } ), new P(Tr.PgTrns.DateCaption, (frDate == minDate && toDate == maxDate) ? (object)Tr.PgTrns.ShowingAll : (frDate == minDate) ? Tr.PgTrns.ShowingOnOrBefore.FmtEnumerable( (object)Ut.NewArray <object>(new SPAN(toDate.ToShortDateString()) { class_ = "filter_hilite" }, " (", new A(Tr.PgTrns.DateRemove) { href = Request.Url.WithoutQuery("To").ToHref() }, ")") ) : (toDate == maxDate) ? Tr.PgTrns.ShowingOnOrAfter.FmtEnumerable( (object)Ut.NewArray <object>(new SPAN(frDate.ToShortDateString()) { class_ = "filter_hilite" }, " (", new A(Tr.PgTrns.DateRemove) { href = Request.Url.WithoutQuery("Fr").ToHref() }, ")") ) : Tr.PgTrns.ShowingBetween.FmtEnumerable( Ut.NewArray <object>(new SPAN(frDate.ToShortDateString()) { class_ = "filter_hilite" }, " (", new A(Tr.PgTrns.DateRemove) { href = Request.Url.WithoutQuery("Fr").ToHref() }, ")"), Ut.NewArray <object>(new SPAN(toDate.ToShortDateString()) { class_ = "filter_hilite" }, " (", new A(Tr.PgTrns.DateRemove) { href = Request.Url.WithoutQuery("To").ToHref() }, ")") ) ), table.GetHtml() )); }