From 83bfaf53ddbc66f4f0a3aa3c2b7238fc31499eaa Mon Sep 17 00:00:00 2001 From: Falkvinge Date: Sat, 28 Oct 2017 13:23:35 +0200 Subject: [PATCH] Added footer to VAT report data --- .../Pages.Ledgers.designer.cs | 18 ++++++++++++++++++ Site/App_GlobalResources/Pages.Ledgers.resx | 8 ++++++++ .../v5/Ledgers/Json-VatReportData.aspx.cs | 13 ++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Site/App_GlobalResources/Pages.Ledgers.designer.cs b/Site/App_GlobalResources/Pages.Ledgers.designer.cs index 25581aa4..c2052f5c 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.designer.cs +++ b/Site/App_GlobalResources/Pages.Ledgers.designer.cs @@ -2032,6 +2032,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to -- nothing to report --. + /// + internal static string ViewVatReports_EmptyReport { + get { + return ResourceManager.GetString("ViewVatReports_EmptyReport", resourceCulture); + } + } + /// /// Looks up a localized string similar to Report Totals. /// @@ -2113,6 +2122,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to Totals for this report. + /// + internal static string ViewVatReports_ReportTotals { + get { + return ResourceManager.GetString("ViewVatReports_ReportTotals", resourceCulture); + } + } + /// /// Looks up a localized string similar to View. /// diff --git a/Site/App_GlobalResources/Pages.Ledgers.resx b/Site/App_GlobalResources/Pages.Ledgers.resx index f8d73f70..43ba5708 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.resx +++ b/Site/App_GlobalResources/Pages.Ledgers.resx @@ -906,4 +906,12 @@ View This is the word or words before the name of the displayed VAT report. + + -- nothing to report -- + This is displayed when there are no items at all in a VAT report. + + + Totals for this report + Displayed as description of footer + \ No newline at end of file diff --git a/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.cs b/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.cs index 97103305..5451d225 100644 --- a/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.cs +++ b/Site/Pages/v5/Ledgers/Json-VatReportData.aspx.cs @@ -81,7 +81,18 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers lines.Add("{" + element + "}"); } - Response.Write("[" + String.Join(",", lines.ToArray()) + "]"); + if (lines.Count == 0) // add empty report line + { + lines.Add(String.Format("\"id\":\"0\",\"description\":\"{0}\"", + JsonSanitize(Resources.Pages.Ledgers.ViewVatReports_EmptyReport))); + } + + Response.Write("{\"rows\":[" + String.Join(",", lines.ToArray()) + "],"); + + Response.Write(String.Format("\"footer\":[\"id\":\"0\",\"description\":\"{0}\",\"turnover\":\"{1:N2}\",\"inbound\":\"{2:N2}\",\"outbound\":\"{3:N2}\"]", + JsonSanitize(Resources.Pages.Ledgers.ViewVatReports_Footer_Total.ToUpperInvariant()), turnoverCentsTotal / 100.0, inboundCentsTotal / 100.0, outboundCentsTotal / 100.0)); + + Response.Write("}"); // needs to be separate to not trigger String.Format warning // TODO: FOOTER