Fixed nullref when there's no VAT reports yet

This commit is contained in:
Rick Falkvinge
2017-10-31 13:11:47 +01:00
parent 172f372446
commit eba64a6af2
5 changed files with 88 additions and 7 deletions
+18
View File
@@ -2077,6 +2077,15 @@ namespace Resources.Pages {
}
}
/// <summary>
/// Looks up a localized string similar to No VAT reports for this organization.
/// </summary>
internal static string ViewVatReports_Header_NoReports {
get {
return ResourceManager.GetString("ViewVatReports_Header_NoReports", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Outbound VAT.
/// </summary>
@@ -2104,6 +2113,15 @@ namespace Resources.Pages {
}
}
/// <summary>
/// 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..
/// </summary>
internal static string ViewVatReports_NoReports {
get {
return ResourceManager.GetString("ViewVatReports_NoReports", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to VAT Reports.
/// </summary>
@@ -906,4 +906,10 @@
<value>View</value>
<comment>This is the word or words before the name of the displayed VAT report.</comment>
</data>
<data name="ViewVatReports_Header_NoReports" xml:space="preserve">
<value>No VAT reports for this organization</value>
</data>
<data name="ViewVatReports_NoReports" xml:space="preserve">
<value>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.</value>
</data>
</root>
+9 -2
View File
@@ -59,6 +59,7 @@
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
<asp:Panel runat="server" ID="PanelShowVatReports">
<h2><div class="elementFloatFar"><%= CurrentOrganization.Currency.DisplayCode %></div><asp:Label ID="LabelContentHeader" runat="server" />&nbsp;<asp:DropDownList runat="server" ID="DropReports"/>&nbsp;<img alt="Loading" src="/Images/Abstract/ajaxloader-blackcircle.gif" ID="imageLoadIndicator" /></h2>
<table id="tableVatReport" title="" class="easyui-treegrid" style="width:680px;height:600px"
url="Json-VatReportData.aspx"
@@ -68,7 +69,7 @@
idField="id" treeField="txid">
<thead>
<tr>
<th field="txid" width="40"><asp:Literal ID="LiteralHeaderTransactionId" Text="Tx#" runat="server"/></th>
<th field="txid" width="60"><asp:Literal ID="LiteralHeaderTransactionId" Text="Tx#" runat="server"/></th>
<th field="datetime" width="100"><asp:Literal ID="LiteralHeaderDateTime" runat="server" /></th>
<th field="description" width="280"><asp:Literal ID="LiteralHeaderDescription" runat="server" /></th>
<th field="turnover" width="140" align="right"><asp:Literal ID="LiteralHeaderTurnover" runat="server" /></th>
@@ -77,7 +78,13 @@
<th field="dox" width="40" align="center"><asp:Literal ID="LiteralHeaderDox" runat="server" /></th>
</tr>
</thead>
</table>
</table>
</asp:Panel>
<asp:Panel runat="server" ID="PanelShowNoVatReports" Visible="false">
<h2><asp:Label runat="server" ID="LabelHeaderNoVatReportsToDisplay"/></h2>
<div style="float: left; margin-right: 10px"><img src="/Images/Icons/iconshock-cross-96px.png"/>
</div><asp:Label runat="server" ID="LabelNoVatReportsToDisplay"/>
</asp:Panel>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderSide" Runat="Server">
+19 -5
View File
@@ -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;
}
}
}
+36
View File
@@ -12,6 +12,15 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers {
public partial class ViewVatReports {
/// <summary>
/// PanelShowVatReports control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel PanelShowVatReports;
/// <summary>
/// LabelContentHeader control.
/// </summary>
@@ -93,6 +102,33 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers {
/// </remarks>
protected global::System.Web.UI.WebControls.Literal LiteralHeaderDox;
/// <summary>
/// PanelShowNoVatReports control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Panel PanelShowNoVatReports;
/// <summary>
/// LabelHeaderNoVatReportsToDisplay control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelHeaderNoVatReportsToDisplay;
/// <summary>
/// LabelNoVatReportsToDisplay control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelNoVatReportsToDisplay;
/// <summary>
/// LabelSidebarDownload control.
/// </summary>