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 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 ensureAcct(GncAccount acct) { if (_rowMap.ContainsKey(acct)) { return; } if (_autoAddAcct) { AddAcct(acct); } else { throw new RTException("ReportAccounts: account \"{0}\" not yet defined and AutoAdd is disabled.".Fmt(acct.Path(":"))); } }
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); } }