From 8e1bbb9f48c375771718a6f8df185c7cf26684cc Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 31 Dec 2018 14:28:13 +0100 Subject: [PATCH] EOM work --- Common/Enums/DocumentType.cs | 7 ++++++- Logic/Support/Document.cs | 4 ++++ Site/Pages/v5/Ledgers/EndOfMonth.aspx | 20 +++++++++++++------- Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 6 ++++++ Site/Site.csproj | 2 +- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Common/Enums/DocumentType.cs b/Common/Enums/DocumentType.cs index e844d989..544d3b18 100644 --- a/Common/Enums/DocumentType.cs +++ b/Common/Enums/DocumentType.cs @@ -77,6 +77,11 @@ namespace Swarmops.Common.Enums /// /// Nor this /// - Salary + Salary, + + /// + /// Documentation related to a financial account, usually an external one + /// + FinancialAccountDocument } } \ No newline at end of file diff --git a/Logic/Support/Document.cs b/Logic/Support/Document.cs index b209adf6..190cf730 100644 --- a/Logic/Support/Document.cs +++ b/Logic/Support/Document.cs @@ -249,6 +249,10 @@ namespace Swarmops.Logic.Support { return DocumentType.Salary; } + else if (foreignObject is FinancialAccountDocument) + { + return DocumentType.FinancialAccountDocument; + } else { throw new ArgumentException ("Unrecognized foreign object type:" + foreignObject.GetType().ToString()); diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 863e9284..87af5aaa 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -277,15 +277,21 @@ } var itemType = activeUpload.substring(0, activeUpload.indexOf('-')); - console.log(itemType); - console.log("Upload" + itemType); - /* + // Note that the function to call is selected dynamically! + SwarmopsJS.ajaxCall( - "EndOfMonth.aspx/Upload" + , - {guid: uploadGuid, itemId: activeUpload}, - ) - // TODO: AJAX CALL TO STORE UPLOAD*/ + "EndOfMonth.aspx/Upload" + itemType, + { guid: uploadGuid, itemId: activeUpload }, + function(result) { + if (result.Success) { + + } else { + // Todo: add more error handling later, maybe + clientFailedUpload(); + } + }); + markItemCompleted(activeUpload); diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index d7d8fbb6..7b2294f6 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -277,6 +277,7 @@ namespace Swarmops.Frontend.Pages.Ledgers string[] parts = itemId.Split('-'); FinancialAccount account = FinancialAccount.FromIdentity(Int32.Parse(parts[1])); int yearMonth = Int32.Parse(parts[2]); + DateTime statementStart = new DateTime(yearMonth/100, yearMonth%100, 1); if (account.OrganizationId != authData.CurrentOrganization.Identity) { @@ -285,6 +286,11 @@ namespace Swarmops.Frontend.Pages.Ledgers Documents documents = Documents.RecentFromDescription(guid); + FinancialAccountDocument accountDoc = FinancialAccountDocument.Create(account, FinancialAccountDocumentType.BankStatement, authData.CurrentUser, + statementStart, statementStart.AddMonths(1), string.Empty); + + documents.SetForeignObjectForAll(accountDoc); + return new AjaxCallResult {Success = true}; } diff --git a/Site/Site.csproj b/Site/Site.csproj index 2522207c..b34a47e9 100644 --- a/Site/Site.csproj +++ b/Site/Site.csproj @@ -5311,7 +5311,7 @@ - + 10.0