diff --git a/Logic/Financial/VatReport.cs b/Logic/Financial/VatReport.cs
index d1bcbc11..c9d31c30 100644
--- a/Logic/Financial/VatReport.cs
+++ b/Logic/Financial/VatReport.cs
@@ -62,6 +62,43 @@ namespace Swarmops.Logic.Financial
return FromIdentityAggressive(vatReportId);
}
+ public static void CreateNext(Organization organization)
+ {
+ // Creates all VAT reports that are required up until today.
+ // Normally this is just one, but in the case of a missed report slot, this function will
+ // catch up with all the missed ones, too.
+
+ DateTime nowUtc = DateTime.UtcNow;
+ DateTime nextReportDue = NextReportDue(organization);
+ int reportMonthInterval = organization.VatReportFrequencyMonths;
+
+ if (nextReportDue > nowUtc)
+ {
+ throw new InvalidOperationException("VAT report is not yet due or has already been generated");
+ }
+
+ DateTime thisReport = new DateTime(organization.FirstFiscalYear, 1, 1); // default to first report
+ VatReports reports = VatReports.ForOrganization(organization, true);
+
+ if (reports.Count > 0)
+ {
+ reports.Sort(VatReports.VatReportSorterByDate);
+
+ DateTime lastReport = new DateTime(reports.Last().YearMonthStart / 100, reports.Last().YearMonthStart % 100,
+ 1);
+
+ thisReport = lastReport.AddMonths(reportMonthInterval);
+ }
+
+ while (thisReport.AddMonths(reportMonthInterval) < nowUtc)
+ {
+ VatReport.Create(organization, thisReport.Year, thisReport.Month, reportMonthInterval);
+ thisReport = thisReport.AddMonths(reportMonthInterval);
+ }
+
+
+ }
+
public static ReportRequirement IsRequired(Organization organization)
{
// If org isn't VAT enabled, the report is never required
diff --git a/Site/App_GlobalResources/Pages.Ledgers.designer.cs b/Site/App_GlobalResources/Pages.Ledgers.designer.cs
index 1460125b..aa51da24 100644
--- a/Site/App_GlobalResources/Pages.Ledgers.designer.cs
+++ b/Site/App_GlobalResources/Pages.Ledgers.designer.cs
@@ -1150,7 +1150,7 @@ namespace Resources.Pages {
}
///
- /// Looks up a localized string similar to End-of-Month Routine.
+ /// Looks up a localized string similar to End-of-Month Routine: {0:MMMM yyyy}.
///
internal static string EndOfMonth_Title {
get {
diff --git a/Site/App_GlobalResources/Pages.Ledgers.resx b/Site/App_GlobalResources/Pages.Ledgers.resx
index 44042349..954ee8e2 100644
--- a/Site/App_GlobalResources/Pages.Ledgers.resx
+++ b/Site/App_GlobalResources/Pages.Ledgers.resx
@@ -1014,7 +1014,8 @@
This means to match bank transactions with incoming/outgoing expected payments (invoices, expense reports, etc) where it couldn't be done automatically
- End-of-Month Routine
+ End-of-Month Routine: {0:MMMM yyyy}
+ Parameter zero is the month that's just ended
Upload Bank Statement ({1}) for {0} for {2}
diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx
index 93b15f9a..cc7b94cf 100644
--- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx
+++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx
@@ -128,35 +128,36 @@
$('.action').click(function() {
var itemId = $(this).attr('data-item');
- var callbackName = $(this).attr('data-callback');
+ var callbackFunction = $(this).attr('data-callback');
$('img.action-icon[data-item="' + itemId + '"]').hide();
$('img.status-icon-pleasewait[data-item="' + itemId + '"]').show();
- setTimeout($.proxy(function() {
- var groupId = $(this).attr('data-group');
- var itemId = $(this).attr('data-item');
+ SwarmopsJS.ajaxCall(
+ "EndOfMonth.aspx/" + callbackFunction,
+ {},
+ $.proxy(function() {
+ var groupId = $(this).attr('data-group');
+ var itemId = $(this).attr('data-item');
- $('span.action-list-item[data-item="' + itemId + '"]').addClass('action-list-item-disabled');
- $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide();
- $('img.status-icon-completed[data-item="' + itemId + '"]').fadeIn();
+ $('span.action-list-item[data-item="' + itemId + '"]').addClass('action-list-item-disabled');
+ $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide();
+ $('img.status-icon-completed[data-item="' + itemId + '"]').fadeIn();
- $(this).attr('data-item');
- var selector = ".action-list-item:not(.action-list-item-disabled)[data-group='" + groupId + "']";
- if ($(selector).length == 0) // no further actions in this group enabled
- {
- // mark the group as completed
- $(".group-status-icon[data-group='" + groupId + "']").fadeIn();
- }
- }, this), 4000);
+ $(this).attr('data-item');
+ var selector = ".action-list-item:not(.action-list-item-disabled)[data-group='" + groupId + "']";
+ if ($(selector).length == 0) // no further actions in this group enabled
+ {
+ // mark the group as completed
+ $(".group-status-icon[data-group='" + groupId + "']").fadeIn();
+ }
+ }, this)
+ );
});
});
-
- // Function: Generate VAT report
-
// Function: Match all mismatched transactions
// Function: Upload bank statement PDF for accountId x
@@ -213,8 +214,8 @@
text-decoration: line-through;
}
- .datagrid-row-selected,.datagrid-row-over,.datagrid-row-checked{
- background:transparent;
+ .datagrid-row-selected, .datagrid-row-over, .datagrid-row-checked {
+ background:transparent !important;
}
@@ -228,7 +229,7 @@
End-of-Month routine
diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs
index 6fc72c57..dac7ea35 100644
--- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs
+++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs
@@ -3,11 +3,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
+using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using Swarmops.Basic.Types.Common;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
+using Swarmops.Logic.Structure;
namespace Swarmops.Frontend.Pages.Ledgers
{
@@ -17,11 +19,12 @@ namespace Swarmops.Frontend.Pages.Ledgers
{
this.PageAccessRequired = new Access(this.CurrentOrganization, AccessAspect.BookkeepingDetails);
- this.Title = Resources.Pages.Ledgers.EndOfMonth_Title;
this.PageTitle =
this.Title =
String.Format(Resources.Pages.Ledgers.EndOfMonth_Title, DateTime.UtcNow.AddMonths(-1));
+ this.InfoBoxLiteral = Resources.Pages.Ledgers.EndOfMonth_Info;
+
// Check which reports are required
ItemGroups = new List();
@@ -118,6 +121,22 @@ namespace Swarmops.Frontend.Pages.Ledgers
}
}
+ [WebMethod]
+ public static AjaxCallResult CreateVatReport()
+ {
+ AuthenticationData authData = GetAuthenticationDataAndCulture();
+
+ if (!authData.Authority.HasAccess(new Access(authData.CurrentOrganization, AccessAspect.BookkeepingDetails)))
+ {
+ throw new UnauthorizedAccessException();
+ }
+
+ VatReport.CreateNext(authData.CurrentOrganization);
+
+ return new AjaxCallResult {Success = true};
+ }
+
+
private class EomItem
{
public string Id { get; set; }