diff --git a/Logic/Financial/VatReport.cs b/Logic/Financial/VatReport.cs index 1ea4633d..e8cf71b1 100644 --- a/Logic/Financial/VatReport.cs +++ b/Logic/Financial/VatReport.cs @@ -62,7 +62,7 @@ namespace Swarmops.Logic.Financial return FromIdentityAggressive(vatReportId); } - public static ReportRequirement IsRequired(Organization organization, int year, int month) + public static ReportRequirement IsRequired(Organization organization) { // If org isn't VAT enabled, the report is never required @@ -73,6 +73,7 @@ namespace Swarmops.Logic.Financial DateTime nowUtc = DateTime.UtcNow; int reportMonthInterval = organization.VatReportFrequencyMonths; + DateTime nextReportDue = NextReportDue(organization); // Get the list of previous VAT reports @@ -125,6 +126,37 @@ namespace Swarmops.Logic.Financial } + public static DateTime NextReportDue(Organization organization) + { + int reportMonthInterval = organization.VatReportFrequencyMonths; + + // Get the list of previous VAT reports + + VatReports reports = VatReports.ForOrganization(organization, true); + + if (reports.Count == 0) + { + DateTime firstReportGenerationTime = + new DateTime(organization.FirstFiscalYear, 1, 1).AddMonths(reportMonthInterval); + // construct VAT report on the first day of the new month + + return firstReportGenerationTime; + } + else // if reports.Count > 0 + { + reports.Sort(VatReports.VatReportSorterByDate); + + DateTime lastReport = new DateTime(reports.Last().YearMonthStart/100, reports.Last().YearMonthStart%100, + 1); + + DateTime nextReport = lastReport.AddMonths(reportMonthInterval); + DateTime nextReportGenerationTime = nextReport.AddMonths(reportMonthInterval); + + return nextReportGenerationTime; + } + } + + public static VatReport Create(Organization organization, int year, int startMonth, int monthCount) { VatReport newReport = CreateDbRecord(organization, year, startMonth, monthCount); @@ -351,6 +383,31 @@ namespace Swarmops.Logic.Financial } } + + public static string NextReportDescription(Organization organization) + { + DateTime nextReportDue = NextReportDue(organization); + int monthInterval = organization.VatReportFrequencyMonths; + + switch (monthInterval) + { + case 1: + return String.Format(Resources.Logic_Financial_VatReport.Description_SingleMonth, + new DateTime(nextReportDue.Year, nextReportDue.Month, 2)); // the 2 is to prevent timezone errors + + case 12: + return String.Format(Resources.Logic_Financial_VatReport.Description_FullYear, + nextReportDue.Year); + + default: + return String.Format(Resources.Logic_Financial_VatReport.Description_Months, + nextReportDue, nextReportDue.AddMonths(monthInterval - 1)); + + } + + } + + public string DescriptionShort { get diff --git a/Site/App_GlobalResources/Global.designer.cs b/Site/App_GlobalResources/Global.designer.cs index 7bd05c36..a6526f08 100644 --- a/Site/App_GlobalResources/Global.designer.cs +++ b/Site/App_GlobalResources/Global.designer.cs @@ -1212,6 +1212,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to {0} to {1}. + /// + internal static string Global_MonthXtoY { + get { + return ResourceManager.GetString("Global_MonthXtoY", resourceCulture); + } + } + /// /// Looks up a localized string similar to - multiple -. /// diff --git a/Site/App_GlobalResources/Global.resx b/Site/App_GlobalResources/Global.resx index 97e9a40a..e6acc786 100644 --- a/Site/App_GlobalResources/Global.resx +++ b/Site/App_GlobalResources/Global.resx @@ -988,4 +988,8 @@ You are entering the <strong>Sandbox</strong> organization.<br/><br/>This is a safe environment where you can play around with Swarmops without risking any damage to production data. Have fun all you want, and return to your production environment when you're done experimenting. + + {0} to {1} + For example, "January to March". The initial "from" is implied. + \ No newline at end of file diff --git a/Site/App_GlobalResources/Pages.Ledgers.designer.cs b/Site/App_GlobalResources/Pages.Ledgers.designer.cs index 48de4865..471c1e09 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.designer.cs +++ b/Site/App_GlobalResources/Pages.Ledgers.designer.cs @@ -1068,6 +1068,96 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to Close Financial Ledgers for Year {0}. + /// + internal static string EndOfMonth_CloseLedgersFor { + get { + return ResourceManager.GetString("EndOfMonth_CloseLedgersFor", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Create {0}. + /// + internal static string EndOfMonth_CreateVatReport { + get { + return ResourceManager.GetString("EndOfMonth_CreateVatReport", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Autofetch Transaction Data for {0}. + /// + internal static string EndOfMonth_FetchTransactionDataFor { + get { + return ResourceManager.GetString("EndOfMonth_FetchTransactionDataFor", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Annual Reports. + /// + internal static string EndOfMonth_Header_AnnualReports { + get { + return ResourceManager.GetString("EndOfMonth_Header_AnnualReports", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to External Account Data and Match Accounts. + /// + internal static string EndOfMonth_Header_ExternalData { + get { + return ResourceManager.GetString("EndOfMonth_Header_ExternalData", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Payroll And Taxes. + /// + internal static string EndOfMonth_Header_PayrollTaxes { + get { + return ResourceManager.GetString("EndOfMonth_Header_PayrollTaxes", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Send Reports to Accountants, Shareholders, etc.. + /// + internal static string EndOfMonth_Header_SendReports { + get { + return ResourceManager.GetString("EndOfMonth_Header_SendReports", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Resolve all unmatched accounts. + /// + internal static string EndOfMonth_MatchAccounts { + get { + return ResourceManager.GetString("EndOfMonth_MatchAccounts", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Upload Bank Statement ({1}) for {0} for {2}. + /// + internal static string EndOfMonth_UploadBankStatementFor { + get { + return ResourceManager.GetString("EndOfMonth_UploadBankStatementFor", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Upload Transaction Data ({1}) for {0}. + /// + internal static string EndOfMonth_UploadTransactionDataFor { + get { + return ResourceManager.GetString("EndOfMonth_UploadTransactionDataFor", resourceCulture); + } + } + /// /// Looks up a localized string similar to Account name. /// diff --git a/Site/App_GlobalResources/Pages.Ledgers.resx b/Site/App_GlobalResources/Pages.Ledgers.resx index 7027da19..a0d0a7a8 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.resx +++ b/Site/App_GlobalResources/Pages.Ledgers.resx @@ -978,4 +978,44 @@ (which was accounted for with <strong>{0} {1:N2}</strong> in the ledger operating currency) {0} {1:N2} is a currency and amount, which is how an initial bank balance in a foreign currency was entered into the ledgers after converting to the organization's accounting currency + + Close Financial Ledgers for Year {0} + Parameter zero is the year as four digits. This EOM option is only presented once per year. + + + Create {0} + Parameter zero is the name of the VAT report as created localized in the logic layer + + + Autofetch Transaction Data for {0} + Parameter zero is the account name as given by the user + + + Annual Reports + This is the header for closing of ledgers and generation of annual reports at the end-of-month routine + + + External Account Data and Match Accounts + This is the header for uploading bank statements and resolving unmatched transactions at end-of-month. + + + Payroll And Taxes + This is the header for all tax reports and payroll processing for the end-of-month (start-of-next-month) routine. + + + Send Reports to Accountants, Shareholders, etc. + This is the header for all items that send reports to external people at the end-of-month routine. + + + Resolve all unmatched accounts + This means to match bank transactions with incoming/outgoing expected payments (invoices, expense reports, etc) where it couldn't be done automatically + + + Upload Bank Statement ({1}) for {0} for {2} + Parameter zero is the account name, parameter one the format (e.g. PDF), parameter two is the month (e.g. October 2018) + + + Upload Transaction Data ({1}) for {0} + Parameter zero is the account name, parameter one is the format (e.g. XML or CSV) + \ No newline at end of file diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 4b2da551..17ae8213 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -103,7 +103,7 @@ $('#TableEomItems').datagrid('appendRow', { - itemGroupName: 'Send to Accountants, Shareholders, etc.', + itemGroupName: 'Send to Accountants, Shareholders, etc.', itemId: 'SendReports' }); diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index 0840415e..a66b999e 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -4,6 +4,8 @@ using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; +using Swarmops.Basic.Types.Common; +using Swarmops.Logic.Financial; using Swarmops.Logic.Security; namespace Swarmops.Frontend.Pages.Ledgers @@ -13,6 +15,30 @@ namespace Swarmops.Frontend.Pages.Ledgers protected void Page_Load(object sender, EventArgs e) { this.PageAccessRequired = new Access(this.CurrentOrganization, AccessAspect.BookkeepingDetails); + DateTime utcMo + + // Check which reports are required + + // Group I: External data & accounts + + EomItemGroup group1 = new EomItemGroup(); + group1.Header = Resources.Pages.Ledgers.EndOfMonth_Header_ExternalData; + + // TODO: Iterate over all Balance account and check for automation; + // if so, add it to an upload sequence + + ReportRequirement vatRequired = VatReport.IsRequired(this.CurrentOrganization); + + if (vatRequired != ReportRequirement.NotRequired) // it's either Required or Completed + { + EomItem vatReport = new EomItem(); + vatReport.Id = "VatReport"; + vatReport.Name = String.Format(Resources.Pages.Ledgers.EndOfMonth_CreateVatReport, VatReport.NextReportDescription (this.CurrentOrganization)); + vatReport.Completed = (vatRequired == ReportRequirement.Completed ? true : false); + + group1.Items.Add(vatReport); + } + } @@ -24,5 +50,23 @@ namespace Swarmops.Frontend.Pages.Ledgers } } + + private class EomItem + { + public string Id { get; set; } + public string Name { get; set; } + public bool Completed { get; set; } + } + + private class EomItemGroup + { + public EomItemGroup() + { + Items = new List(); + } + + public string Header { get; set; } + public List Items { get; } + } } } \ No newline at end of file