Work on EOM routine
This commit is contained in:
@@ -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
|
||||
|
||||
+9
@@ -1212,6 +1212,15 @@ namespace Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} to {1}.
|
||||
/// </summary>
|
||||
internal static string Global_MonthXtoY {
|
||||
get {
|
||||
return ResourceManager.GetString("Global_MonthXtoY", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to - multiple -.
|
||||
/// </summary>
|
||||
|
||||
@@ -988,4 +988,8 @@
|
||||
<data name="Global_EnteringSandbox" xml:space="preserve">
|
||||
<value>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.</value>
|
||||
</data>
|
||||
<data name="Global_MonthXtoY" xml:space="preserve">
|
||||
<value>{0} to {1}</value>
|
||||
<comment>For example, "January to March". The initial "from" is implied.</comment>
|
||||
</data>
|
||||
</root>
|
||||
+90
@@ -1068,6 +1068,96 @@ namespace Resources.Pages {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Close Financial Ledgers for Year {0}.
|
||||
/// </summary>
|
||||
internal static string EndOfMonth_CloseLedgersFor {
|
||||
get {
|
||||
return ResourceManager.GetString("EndOfMonth_CloseLedgersFor", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Create {0}.
|
||||
/// </summary>
|
||||
internal static string EndOfMonth_CreateVatReport {
|
||||
get {
|
||||
return ResourceManager.GetString("EndOfMonth_CreateVatReport", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Autofetch Transaction Data for {0}.
|
||||
/// </summary>
|
||||
internal static string EndOfMonth_FetchTransactionDataFor {
|
||||
get {
|
||||
return ResourceManager.GetString("EndOfMonth_FetchTransactionDataFor", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Annual Reports.
|
||||
/// </summary>
|
||||
internal static string EndOfMonth_Header_AnnualReports {
|
||||
get {
|
||||
return ResourceManager.GetString("EndOfMonth_Header_AnnualReports", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to External Account Data and Match Accounts.
|
||||
/// </summary>
|
||||
internal static string EndOfMonth_Header_ExternalData {
|
||||
get {
|
||||
return ResourceManager.GetString("EndOfMonth_Header_ExternalData", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Payroll And Taxes.
|
||||
/// </summary>
|
||||
internal static string EndOfMonth_Header_PayrollTaxes {
|
||||
get {
|
||||
return ResourceManager.GetString("EndOfMonth_Header_PayrollTaxes", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Send Reports to Accountants, Shareholders, etc..
|
||||
/// </summary>
|
||||
internal static string EndOfMonth_Header_SendReports {
|
||||
get {
|
||||
return ResourceManager.GetString("EndOfMonth_Header_SendReports", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Resolve all unmatched accounts.
|
||||
/// </summary>
|
||||
internal static string EndOfMonth_MatchAccounts {
|
||||
get {
|
||||
return ResourceManager.GetString("EndOfMonth_MatchAccounts", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Upload Bank Statement ({1}) for {0} for {2}.
|
||||
/// </summary>
|
||||
internal static string EndOfMonth_UploadBankStatementFor {
|
||||
get {
|
||||
return ResourceManager.GetString("EndOfMonth_UploadBankStatementFor", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Upload Transaction Data ({1}) for {0}.
|
||||
/// </summary>
|
||||
internal static string EndOfMonth_UploadTransactionDataFor {
|
||||
get {
|
||||
return ResourceManager.GetString("EndOfMonth_UploadTransactionDataFor", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Account name.
|
||||
/// </summary>
|
||||
|
||||
@@ -978,4 +978,44 @@
|
||||
<value>(which was accounted for with <strong>{0} {1:N2}</strong> in the ledger operating currency)</value>
|
||||
<comment>{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</comment>
|
||||
</data>
|
||||
<data name="EndOfMonth_CloseLedgersFor" xml:space="preserve">
|
||||
<value>Close Financial Ledgers for Year {0}</value>
|
||||
<comment>Parameter zero is the year as four digits. This EOM option is only presented once per year.</comment>
|
||||
</data>
|
||||
<data name="EndOfMonth_CreateVatReport" xml:space="preserve">
|
||||
<value>Create {0}</value>
|
||||
<comment>Parameter zero is the name of the VAT report as created localized in the logic layer</comment>
|
||||
</data>
|
||||
<data name="EndOfMonth_FetchTransactionDataFor" xml:space="preserve">
|
||||
<value>Autofetch Transaction Data for {0}</value>
|
||||
<comment>Parameter zero is the account name as given by the user</comment>
|
||||
</data>
|
||||
<data name="EndOfMonth_Header_AnnualReports" xml:space="preserve">
|
||||
<value>Annual Reports</value>
|
||||
<comment>This is the header for closing of ledgers and generation of annual reports at the end-of-month routine</comment>
|
||||
</data>
|
||||
<data name="EndOfMonth_Header_ExternalData" xml:space="preserve">
|
||||
<value>External Account Data and Match Accounts</value>
|
||||
<comment>This is the header for uploading bank statements and resolving unmatched transactions at end-of-month.</comment>
|
||||
</data>
|
||||
<data name="EndOfMonth_Header_PayrollTaxes" xml:space="preserve">
|
||||
<value>Payroll And Taxes</value>
|
||||
<comment>This is the header for all tax reports and payroll processing for the end-of-month (start-of-next-month) routine.</comment>
|
||||
</data>
|
||||
<data name="EndOfMonth_Header_SendReports" xml:space="preserve">
|
||||
<value>Send Reports to Accountants, Shareholders, etc.</value>
|
||||
<comment>This is the header for all items that send reports to external people at the end-of-month routine.</comment>
|
||||
</data>
|
||||
<data name="EndOfMonth_MatchAccounts" xml:space="preserve">
|
||||
<value>Resolve all unmatched accounts</value>
|
||||
<comment>This means to match bank transactions with incoming/outgoing expected payments (invoices, expense reports, etc) where it couldn't be done automatically</comment>
|
||||
</data>
|
||||
<data name="EndOfMonth_UploadBankStatementFor" xml:space="preserve">
|
||||
<value>Upload Bank Statement ({1}) for {0} for {2}</value>
|
||||
<comment>Parameter zero is the account name, parameter one the format (e.g. PDF), parameter two is the month (e.g. October 2018)</comment>
|
||||
</data>
|
||||
<data name="EndOfMonth_UploadTransactionDataFor" xml:space="preserve">
|
||||
<value>Upload Transaction Data ({1}) for {0}</value>
|
||||
<comment>Parameter zero is the account name, parameter one is the format (e.g. XML or CSV)</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -103,7 +103,7 @@
|
||||
|
||||
|
||||
$('#TableEomItems').datagrid('appendRow', {
|
||||
itemGroupName: '<span class="itemGroupHeader">Send to Accountants, Shareholders, etc.</span>',
|
||||
itemGroupName: '<span class="itemGroupHeader">Send to Accountants, Shareholders, etc.</span>',
|
||||
itemId: 'SendReports'
|
||||
});
|
||||
|
||||
|
||||
@@ -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<EomItem>();
|
||||
}
|
||||
|
||||
public string Header { get; set; }
|
||||
public List<EomItem> Items { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user