From d86e0a6aab9890a274fdb72fdb5b57bce802bff7 Mon Sep 17 00:00:00 2001 From: Falkvinge Date: Sat, 28 Oct 2017 12:42:10 +0200 Subject: [PATCH] More work on VAT report data --- .../v5/Ledgers/Json-VatReportData.aspx.cs | 29 +++++++++++++++---- Site/Pages/v5/Ledgers/ViewVatReports.aspx | 9 +++--- Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs | 1 + 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.cs b/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.cs index 61538f80..5f8d8196 100644 --- a/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.cs +++ b/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.cs @@ -41,9 +41,9 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers Response.ContentType = "application/json"; - Int64 turnoverTotal; - Int64 inboundTotal; - Int64 outboundTotal; + Int64 turnoverCentsTotal = 0; + Int64 inboundCentsTotal = 0; + Int64 outboundCentsTotal = 0; StringBuilder response = new StringBuilder(16384); @@ -54,18 +54,37 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers { FinancialTransaction transaction = item.Transaction; - string element = string.Format("\"id\":\"{0}\",\"txid\":\"{1}\",\"datetime\":\"{2}\",\"description\":\"{3}\"", + string element = string.Format("\"id\":\"{0}\",\"txid\":\"{1}\",\"datetime\":\"{2: MMM dd}\",\"description\":\"{3}\"", transaction.Identity, transaction.OrganizationSequenceId, - "date time", + transaction.DateTime, JsonSanitize(transaction.Description)); + if (item.TurnoverCents > 0) + { + element += String.Format("\"turnover\":\"{0:N2}\"", item.TurnoverCents / 100.0); + turnoverCentsTotal += item.TurnoverCents; + } + + if (item.VatInboundCents > 0) + { + element += String.Format("\"inbound\":\"{0:N2}\"", item.VatInboundCents/ 100.0); + inboundCentsTotal += item.VatInboundCents; + } + + if (item.VatOutboundCents > 0) + { + element += String.Format("\"outbound\":\"{0:N2}\"", item.VatOutboundCents/ 100.0); + outboundCentsTotal += item.VatOutboundCents; + } lines.Add("{" + element + "}"); } Response.Write("[" + String.Join(",", lines.ToArray()) + "]"); + // TODO: FOOTER + Response.End(); } diff --git a/Site/Pages/v5/Ledgers/ViewVatReports.aspx b/Site/Pages/v5/Ledgers/ViewVatReports.aspx index 27733a9d..420e5459 100644 --- a/Site/Pages/v5/Ledgers/ViewVatReports.aspx +++ b/Site/Pages/v5/Ledgers/ViewVatReports.aspx @@ -18,6 +18,7 @@ $('#<%=DropReports.ClientID %>').change(function () { var selectedReportId = $('#<%=DropReports.ClientID %>').val(); + console.log("Selected Report Id: " + selectedReportId); $('#tableVatReport').treegrid({ url: 'Json-VatReportData.aspx?ReportId=' + selectedReportId }); $('#imageLoadIndicator').show(); @@ -65,16 +66,16 @@ rownumbers="false" animate="true" fitColumns="true" showFooter="true" - idField="id" treeField="txid"> + idField="id"> - - + + - + diff --git a/Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs b/Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs index bece001d..1a94cfa9 100644 --- a/Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs +++ b/Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs @@ -51,6 +51,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers } this.InitialReportId = reports.Last().Identity; + this.DropReports.SelectedValue = this.InitialReportId.ToString(CultureInfo.InvariantCulture); Localize(); }