From eba64a6af2d688d1593414a1276cbcab5f286f9d Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 31 Oct 2017 13:11:47 +0100 Subject: [PATCH] Fixed nullref when there's no VAT reports yet --- .../Pages.Ledgers.designer.cs | 18 ++++++++++ Site/App_GlobalResources/Pages.Ledgers.resx | 6 ++++ Site/Pages/v5/Ledgers/ViewVatReports.aspx | 11 ++++-- Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs | 24 ++++++++++--- .../Ledgers/ViewVatReports.aspx.designer.cs | 36 +++++++++++++++++++ 5 files changed, 88 insertions(+), 7 deletions(-) diff --git a/Site/App_GlobalResources/Pages.Ledgers.designer.cs b/Site/App_GlobalResources/Pages.Ledgers.designer.cs index 25581aa4..cbc3f15b 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.designer.cs +++ b/Site/App_GlobalResources/Pages.Ledgers.designer.cs @@ -2077,6 +2077,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to No VAT reports for this organization. + /// + internal static string ViewVatReports_Header_NoReports { + get { + return ResourceManager.GetString("ViewVatReports_Header_NoReports", resourceCulture); + } + } + /// /// Looks up a localized string similar to Outbound VAT. /// @@ -2104,6 +2113,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to There are no VAT reports to display. This is probably due to the fact that a full VAT reporting period has not elapsed yet, so it has not been possible to create a report yet.. + /// + internal static string ViewVatReports_NoReports { + get { + return ResourceManager.GetString("ViewVatReports_NoReports", resourceCulture); + } + } + /// /// Looks up a localized string similar to VAT Reports. /// diff --git a/Site/App_GlobalResources/Pages.Ledgers.resx b/Site/App_GlobalResources/Pages.Ledgers.resx index f8d73f70..13c11f68 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.resx +++ b/Site/App_GlobalResources/Pages.Ledgers.resx @@ -906,4 +906,10 @@ View This is the word or words before the name of the displayed VAT report. + + No VAT reports for this organization + + + There are no VAT reports to display. This is probably due to the fact that a full VAT reporting period has not elapsed yet, so it has not been possible to create a report yet. + \ No newline at end of file diff --git a/Site/Pages/v5/Ledgers/ViewVatReports.aspx b/Site/Pages/v5/Ledgers/ViewVatReports.aspx index ed82060e..0ef31e1a 100644 --- a/Site/Pages/v5/Ledgers/ViewVatReports.aspx +++ b/Site/Pages/v5/Ledgers/ViewVatReports.aspx @@ -59,6 +59,7 @@ +

<%= CurrentOrganization.Currency.DisplayCode %>
  Loading

- + @@ -77,7 +78,13 @@ -
+ +
+ +

+
+
+
diff --git a/Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs b/Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs index 9a4436ef..36242318 100644 --- a/Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs +++ b/Site/Pages/v5/Ledgers/ViewVatReports.aspx.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Web; +using System.Web.DynamicData; using System.Web.UI; using System.Web.UI.WebControls; using Swarmops.Logic.Financial; @@ -42,12 +43,23 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers // TODO: Disable if viewing specific report and not open ledgers VatReports reports = VatReports.ForOrganization(CurrentOrganization, true); - reports.Sort(VatReports.VatReportSorterByDate); - foreach (VatReport report in reports) + if (reports.Count > 0) { - this.DropReports.Items.Add(new ListItem(report.Description, - report.Identity.ToString(CultureInfo.InvariantCulture))); + reports.Sort(VatReports.VatReportSorterByDate); + + foreach (VatReport report in reports) + { + this.DropReports.Items.Add(new ListItem(report.Description, + report.Identity.ToString(CultureInfo.InvariantCulture))); + } + } + else + { + // There are no VAT reports for this organization (yet?) so display an error instead + + this.PanelShowVatReports.Visible = false; + this.PanelShowNoVatReports.Visible = true; } Localize(); @@ -67,7 +79,9 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers this.LiteralHeaderVatInbound.Text = Resources.Pages.Ledgers.ViewVatReports_Header_Inbound; this.LiteralHeaderVatOutbound.Text = Resources.Pages.Ledgers.ViewVatReports_Header_Outbound; this.LiteralHeaderDox.Text = Resources.Global.Global_Dox; - // Localize all controls - todo + + this.LabelHeaderNoVatReportsToDisplay.Text = Resources.Pages.Ledgers.ViewVatReports_NoReports; + this.LabelNoVatReportsToDisplay.Text = Resources.Pages.Ledgers.ViewVatReports_NoReports; } } } \ No newline at end of file diff --git a/Site/Pages/v5/Ledgers/ViewVatReports.aspx.designer.cs b/Site/Pages/v5/Ledgers/ViewVatReports.aspx.designer.cs index 725fc26b..7e2d399f 100644 --- a/Site/Pages/v5/Ledgers/ViewVatReports.aspx.designer.cs +++ b/Site/Pages/v5/Ledgers/ViewVatReports.aspx.designer.cs @@ -12,6 +12,15 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers { public partial class ViewVatReports { + /// + /// PanelShowVatReports control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel PanelShowVatReports; + /// /// LabelContentHeader control. /// @@ -93,6 +102,33 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers { /// protected global::System.Web.UI.WebControls.Literal LiteralHeaderDox; + /// + /// PanelShowNoVatReports control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel PanelShowNoVatReports; + + /// + /// LabelHeaderNoVatReportsToDisplay control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelHeaderNoVatReportsToDisplay; + + /// + /// LabelNoVatReportsToDisplay control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelNoVatReportsToDisplay; + /// /// LabelSidebarDownload control. ///