From 547c0256b0cae2533bbd1b0346069a9056271b7d Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 12 Dec 2018 19:42:18 +0100 Subject: [PATCH 01/46] Testing if upload trigger works --- Site/Controls/v5/Base/FileUpload.ascx | 4 ++ Site/Pages/v5/Ledgers/EndOfMonth.aspx | 50 ++++++++++++------- Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 8 ++- .../v5/Ledgers/EndOfMonth.aspx.designer.cs | 9 ++++ 4 files changed, 53 insertions(+), 18 deletions(-) diff --git a/Site/Controls/v5/Base/FileUpload.ascx b/Site/Controls/v5/Base/FileUpload.ascx index 337dfc54..1e1b630f 100644 --- a/Site/Controls/v5/Base/FileUpload.ascx +++ b/Site/Controls/v5/Base/FileUpload.ascx @@ -102,6 +102,10 @@ } + function <%=this.ClientID%>_triggerUpload() { + $('#<%=this.ClientID %>_ButtonUploadHidden').click(); + } + function <%=this.ClientID%>_clear() { // Note that this only clears the UI -- the uploaded docs must be disassociated elsewhere $('#<%=this.ClientID%>_DivUploadCount').empty(); diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 6c88694b..2f635191 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -134,25 +134,34 @@ $('img.action-icon[data-item="' + itemId + '"]').hide(); $('img.status-icon-pleasewait[data-item="' + itemId + '"]').show(); - SwarmopsJS.ajaxCall( - "/Pages/v5/Ledgers/EndOfMonth.aspx/" + callbackFunction, - {}, - $.proxy(function() { - var groupId = $(this).attr('data-group'); - var itemId = $(this).attr('data-item'); + if ($(this).hasClass('is-upload')) { + // Trigger upload, then trigger ajax call on complete - $('span.action-list-item[data-item="' + itemId + '"]').addClass('action-list-item-completed'); - $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); - $('img.status-icon-completed[data-item="' + itemId + '"]').fadeIn(); + <%=this.UploadControl.ClientID%>_triggerUpload(); - var selector = ".action-list-item:not(.action-list-item-completed):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) - ); + } else { + // Ajax call right away + + SwarmopsJS.ajaxCall( + "/Pages/v5/Ledgers/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-completed'); + $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); + $('img.status-icon-completed[data-item="' + itemId + '"]').fadeIn(); + + var selector = ".action-list-item:not(.action-list-item-completed):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) + ); + } }); @@ -170,6 +179,12 @@ }); + function clientPostUpload(callbackFunction, cookie) { + + } + + var uploadGuid = '<%=this.UploadControl.GuidString%>'; + // Function: Match all mismatched transactions // Function: Upload bank statement PDF for accountId x @@ -255,6 +270,7 @@

+
0) { @@ -194,10 +195,15 @@ namespace Swarmops.Frontend.Pages.Ledgers Server.HtmlEncode(Resources.Global.Global_SkipThis) + ")"; } + if (item.Icon == "upload") + { + iconIsUploadClass = " is-upload"; + } + builder.Append(@" $('#TableEomItems').datagrid('appendRow', { itemName: """ + itemName + @""", - action: """" + action: """" }); "); } diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.designer.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.designer.cs index a7497d52..dfc5ac42 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.designer.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.designer.cs @@ -20,5 +20,14 @@ namespace Swarmops.Frontend.Pages.Ledgers { /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.Label LabelHeader; + + /// + /// UploadControl control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::Swarmops.Controls.Base.FileUpload UploadControl; } } From c0cbdf5410be9d6bd7bb604ec7f4af6eaa215c71 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Fri, 14 Dec 2018 10:41:26 +0100 Subject: [PATCH 02/46] More work on EOM --- Site/Controls/v5/Base/FileUpload.ascx | 14 +++++++ Site/Controls/v5/Base/FileUpload.ascx.cs | 1 + Site/Pages/v5/Ledgers/EndOfMonth.aspx | 52 +++++++++++++++++++++--- 3 files changed, 62 insertions(+), 5 deletions(-) diff --git a/Site/Controls/v5/Base/FileUpload.ascx b/Site/Controls/v5/Base/FileUpload.ascx index 1e1b630f..1c1ccc7c 100644 --- a/Site/Controls/v5/Base/FileUpload.ascx +++ b/Site/Controls/v5/Base/FileUpload.ascx @@ -75,8 +75,22 @@ <%= this.ClientUploadStartedCallback %>("<%= GuidString%>", "<%= Cookie%>"); + <% } %> + }, + send: function(e, data) { + // call when upload actually begins -- for notify + }, + fail: function(e, data) { + // called on upload fail or upload abort -- for notify + + <% if (!String.IsNullOrEmpty(this.ClientUploadFailedCallback)) + { %> + + <%= this.ClientUploadFailedCallback %>("<%= GuidString%>", "<%= Cookie%>"); + <% } %> } + }); diff --git a/Site/Controls/v5/Base/FileUpload.ascx.cs b/Site/Controls/v5/Base/FileUpload.ascx.cs index 4d1db30a..9506b1d1 100644 --- a/Site/Controls/v5/Base/FileUpload.ascx.cs +++ b/Site/Controls/v5/Base/FileUpload.ascx.cs @@ -36,6 +36,7 @@ namespace Swarmops.Controls.Base public bool HideTrigger { get; set; } public string ClientUploadCompleteCallback { get; set; } public string ClientUploadStartedCallback { get; set; } + public string ClientUploadFailedCallback { get; set; } public string Cookie { get; set; } public string GuidToken diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 2f635191..f7e9f9a8 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -131,17 +131,27 @@ var itemId = $(this).attr('data-item'); var callbackFunction = $(this).attr('data-callback'); - $('img.action-icon[data-item="' + itemId + '"]').hide(); - $('img.status-icon-pleasewait[data-item="' + itemId + '"]').show(); - if ($(this).hasClass('is-upload')) { + // Trigger upload, then trigger ajax call on complete + if (triggeredUpload != null) { + // upload is already in progress; don't allow two concurrent uploads since we're using one control + // todo: error message or some UX to explain this? + + return; + } + + triggeredUpload = this; <%=this.UploadControl.ClientID%>_triggerUpload(); } else { + // Ajax call right away + $('img.action-icon[data-item="' + itemId + '"]').hide(); + $('img.status-icon-pleasewait[data-item="' + itemId + '"]').show(); + SwarmopsJS.ajaxCall( "/Pages/v5/Ledgers/EndOfMonth.aspx/" + callbackFunction, {}, @@ -179,12 +189,44 @@ }); - function clientPostUpload(callbackFunction, cookie) { - + function clientStartUpload() { + if (triggeredUpload == null) { + // invalid state + return; + } + + var itemId = $(triggeredUpload).attr('data-item'); + $('img.action-icon[data-item="' + itemId + '"]').hide(); + $('img.status-icon-pleasewait[data-item="' + itemId + '"]').show(); + } + + function clientFailUpload() { + if (triggeredUpload == null) { + // invalid state + return; + } + + var itemId = $(triggeredUpload).attr('data-item'); + $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); + $('img.action-icon[data-item="' + itemId + '"]').show(); + + triggeredUpload = null; + } + + function clientFinishUpload() { + if (triggeredUpload == null) { + // invalid state + return; + } + + triggeredUpload = null; } var uploadGuid = '<%=this.UploadControl.GuidString%>'; + var triggeredUpload = null; + + // Function: Match all mismatched transactions // Function: Upload bank statement PDF for accountId x From 543dd7484f7ee9f1096ba09bfcea38f1d912e93a Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 16 Dec 2018 04:07:18 +0100 Subject: [PATCH 03/46] More work on EOM --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index f7e9f9a8..51c2ba6c 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -213,7 +213,7 @@ triggeredUpload = null; } - function clientFinishUpload() { + function clientFinishedUpload() { if (triggeredUpload == null) { // invalid state return; @@ -312,7 +312,7 @@

-
+
Date: Sun, 16 Dec 2018 04:24:23 +0100 Subject: [PATCH 04/46] Fix for event trigger sequence --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 51c2ba6c..984d1e16 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -135,7 +135,7 @@ // Trigger upload, then trigger ajax call on complete - if (triggeredUpload != null) { + if (activeUpload != null) { // upload is already in progress; don't allow two concurrent uploads since we're using one control // todo: error message or some UX to explain this? @@ -190,41 +190,49 @@ }); function clientStartUpload() { + console.log("Client started upload"); + if (triggeredUpload == null) { // invalid state return; } + activeUpload = triggeredUpload; + triggeredUpload = null; - var itemId = $(triggeredUpload).attr('data-item'); + var itemId = $(activeUpload).attr('data-item'); $('img.action-icon[data-item="' + itemId + '"]').hide(); $('img.status-icon-pleasewait[data-item="' + itemId + '"]').show(); } function clientFailUpload() { - if (triggeredUpload == null) { + console.log("Client aborted or failed upload"); + + if (activeUpload == null) { // invalid state return; } - var itemId = $(triggeredUpload).attr('data-item'); + var itemId = $(activeUpload).attr('data-item'); $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); $('img.action-icon[data-item="' + itemId + '"]').show(); - triggeredUpload = null; + activeUpload = null; } function clientFinishedUpload() { - if (triggeredUpload == null) { + console.log("Client finished upload"); + if (activeUpload == null) { // invalid state return; } - triggeredUpload = null; + activeUpload = null; } var uploadGuid = '<%=this.UploadControl.GuidString%>'; var triggeredUpload = null; + var activeUpload = null; // Function: Match all mismatched transactions From 7f9c0f1cc4bece85cb2cc9b3088c5db3df2e451b Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 16 Dec 2018 10:13:07 +0100 Subject: [PATCH 05/46] Another related fix --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 984d1e16..ff155956 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -189,7 +189,7 @@ }); - function clientStartUpload() { + function clientStartedUpload() { console.log("Client started upload"); if (triggeredUpload == null) { @@ -204,7 +204,7 @@ $('img.status-icon-pleasewait[data-item="' + itemId + '"]').show(); } - function clientFailUpload() { + function clientFailedUpload() { console.log("Client aborted or failed upload"); if (activeUpload == null) { @@ -320,7 +320,7 @@

-
+
Date: Sun, 16 Dec 2018 16:30:10 +0100 Subject: [PATCH 06/46] UX test --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index ff155956..22e95810 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -199,9 +199,13 @@ activeUpload = triggeredUpload; triggeredUpload = null; + // switch action icon upload to status icon waiting var itemId = $(activeUpload).attr('data-item'); $('img.action-icon[data-item="' + itemId + '"]').hide(); $('img.status-icon-pleasewait[data-item="' + itemId + '"]').show(); + + // If there's a skip option, disable it at this time + $('span.action-list-item[data-item="' + itemId + '"] span.action-skip').addClass('action-skip-disabled'); } function clientFailedUpload() { @@ -226,6 +230,8 @@ return; } + // TODO: AJAX CALL TO STORE UPLOAD + activeUpload = null; } @@ -284,6 +290,10 @@ transition: all 0.50s;*/ } + .action-skip .action-skip-disabled { + display: none !important; + } + .action-list-item-disabled .action-skip, .action-list-item-completed .action-skip { -webkit-transition: all 0.50s; transition: all 0.50s; From 610a0898d1f197fc796d8f5ad112d23938ae1fd6 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 16 Dec 2018 17:02:17 +0100 Subject: [PATCH 07/46] CSS fix --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 22e95810..d0b0887c 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -290,7 +290,7 @@ transition: all 0.50s;*/ } - .action-skip .action-skip-disabled { + .action-skip-disabled { display: none !important; } From 157cd3413e187ba2da6c1e9c0f6881882e293e1f Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 19 Dec 2018 19:27:30 +0100 Subject: [PATCH 08/46] Added some loc --- .../Pages.Ledgers.designer.cs | 9 +++ Site/App_GlobalResources/Pages.Ledgers.resx | 3 + Site/Pages/v5/Ledgers/EndOfMonth.aspx | 6 +- Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 75 +++++++++++++++---- 4 files changed, 76 insertions(+), 17 deletions(-) diff --git a/Site/App_GlobalResources/Pages.Ledgers.designer.cs b/Site/App_GlobalResources/Pages.Ledgers.designer.cs index e48a5512..fb205a8a 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.designer.cs +++ b/Site/App_GlobalResources/Pages.Ledgers.designer.cs @@ -1158,6 +1158,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to <strong>SKIP DOCUMENT UPLOAD?</strong><br/><br/>This document is typically needed for operation records. The only valid reason to skip a document is that it doesn't exist because the operations weren't running yet, like when an operation started in June of a year won't have documents for January of that year.<br/><br/>You won't be asked again to upload this document if you skip it now.. + /// + internal static string EndOfMonth_SkipDocumentDialogGeneric { + get { + return ResourceManager.GetString("EndOfMonth_SkipDocumentDialogGeneric", resourceCulture); + } + } + /// /// Looks up a localized string similar to End-of-Month Routine: {0:MMMM yyyy}. /// diff --git a/Site/App_GlobalResources/Pages.Ledgers.resx b/Site/App_GlobalResources/Pages.Ledgers.resx index 0343b66f..87726112 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.resx +++ b/Site/App_GlobalResources/Pages.Ledgers.resx @@ -1028,4 +1028,7 @@ <strong>SKIP BANK STATEMENT?</strong><br/><br/>Bank statements are typically needed for audit verification of the internal records. The only valid reason to skip a month's statement is that the account wasn't opened yet, in which case you skip the months before the account was opened and no statements therefore exist.<br/><br/>You won't be asked again to upload this particular statement if you skip it now. + + <strong>SKIP DOCUMENT UPLOAD?</strong><br/><br/>This document is typically needed for operation records. The only valid reason to skip a document is that it doesn't exist because the operations weren't running yet, like when an operation started in June of a year won't have documents for January of that year.<br/><br/>You won't be asked again to upload this document if you skip it now. + \ No newline at end of file diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index d0b0887c..10318bca 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -240,6 +240,10 @@ var triggeredUpload = null; var activeUpload = null; + var localized_skipNoResponse = SwarmopsJS.unescape('<%=this.Localized_SkipNo%>'); + var localized_skipYesResponse = SwarmopsJS.unescape('<%=this.Localized_SkipYes%>'); + var localized_skipPromptBankStatement = SwarmopsJS.unescape('<%=this.Localized_SkipPrompt_BankStatement%>'); + var localized_skipPromptGeneric = SwarmopsJS.unescape('<%=this.Localized_SkipPrompt_Generic%>'); // Function: Match all mismatched transactions @@ -290,7 +294,7 @@ transition: all 0.50s;*/ } - .action-skip-disabled { + .action-list-item .action-skip-disabled { display: none !important; } diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index d7c2d580..106fa6d3 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -24,8 +24,8 @@ namespace Swarmops.Frontend.Pages.Ledgers this.PageTitle = this.Title = - this.LabelHeader.Text = - String.Format(Resources.Pages.Ledgers.EndOfMonth_Title, DateTime.UtcNow.AddMonths(-1)); + this.LabelHeader.Text = + String.Format(Resources.Pages.Ledgers.EndOfMonth_Title, DateTime.UtcNow.AddMonths(-1)); this.InfoBoxLiteral = Resources.Pages.Ledgers.EndOfMonth_Info; @@ -55,13 +55,15 @@ namespace Swarmops.Frontend.Pages.Ledgers // This account has automation // If automation has Bank Account Statement enabled (assume true for now): - FinancialAccountDocument lastBankStatement = assetAccount.GetMostRecentDocument(FinancialAccountDocumentType.BankStatement); - int lastStatementMonth = (this.CurrentOrganization.FirstFiscalYear-1) *100 + 12; // December of the year before + FinancialAccountDocument lastBankStatement = + assetAccount.GetMostRecentDocument(FinancialAccountDocumentType.BankStatement); + int lastStatementMonth = (this.CurrentOrganization.FirstFiscalYear - 1)*100 + 12; + // December of the year before if (lastBankStatement != null) { lastStatementMonth = lastBankStatement.ConcernsPeriodStart.Year*100 + - lastBankStatement.ConcernsPeriodStart.Month; + lastBankStatement.ConcernsPeriodStart.Month; skippable = false; } @@ -79,9 +81,11 @@ namespace Swarmops.Frontend.Pages.Ledgers EomItem bankStatement = new EomItem(); bankStatement.DependsOn = lastId; // empty for first record bankStatement.Id = lastId = "BankStatement-" + - assetAccount.Identity.ToString(CultureInfo.InvariantCulture) + monthIterator; + assetAccount.Identity.ToString(CultureInfo.InvariantCulture) + + monthIterator; bankStatement.Name = string.Format(Resources.Pages.Ledgers.EndOfMonth_UploadBankStatementFor, - assetAccount.Name, "PDF", new DateTime(monthIterator / 100, monthIterator % 100, 15).ToString("MMMM yyyy")); + assetAccount.Name, "PDF", + new DateTime(monthIterator/100, monthIterator%100, 15).ToString("MMMM yyyy")); bankStatement.Completed = false; // TODO bankStatement.Icon = "upload"; bankStatement.Skippable = skippable; @@ -157,8 +161,12 @@ namespace Swarmops.Frontend.Pages.Ledgers builder.Append(@" $('#TableEomItems').datagrid('appendRow', { - itemGroupName: '" + group.Header.Replace(" ", " ").Replace("'", "''") + @"', - action: """", + itemGroupName: '" + + group.Header.Replace(" ", " ").Replace("'", "''") + @"', + action: """", itemId: '" + group.Id + @"' }); @@ -172,7 +180,7 @@ namespace Swarmops.Frontend.Pages.Ledgers }); "); - + foreach (EomItem item in group.Items) { if (!item.Completed) @@ -202,8 +210,19 @@ namespace Swarmops.Frontend.Pages.Ledgers builder.Append(@" $('#TableEomItems').datagrid('appendRow', { - itemName: """ + itemName + @""", - action: """" + itemName: """ + itemName + @""", + action: """" }); "); } @@ -211,19 +230,22 @@ namespace Swarmops.Frontend.Pages.Ledgers { builder.Append(@" $('#TableEomItems').datagrid('appendRow', { - itemName: """ + item.Name + @""", - action: """" + itemName: """ + item.Name + @""", + action: """" }); "); } } - previousGroupId = group.Id; // only set if group has items + previousGroupId = group.Id; // only set if group has items } } return builder.ToString(); - + } } @@ -267,5 +289,26 @@ namespace Swarmops.Frontend.Pages.Ledgers } private List ItemGroups { get; set; } + + + public string Localized_SkipPrompt_BankStatement + { + get { return CommonV5.JavascriptEscape(Resources.Pages.Ledgers.EndOfMonth_SkipBankStatementDialog); } + } + + public string Localized_SkipPrompt_Generic + { + get { return CommonV5.JavascriptEscape(Resources.Pages.Ledgers.EndOfMonth_SkipDocumentDialogGeneric); } + } + + public string Localized_SkipYes + { + get { return CommonV5.JavascriptEscape(Resources.Global.Global_SkipYes); } + } + + public string Localized_SkipNo + { + get { return CommonV5.JavascriptEscape(Resources.Global.Global_SkipNo); } + } } } \ No newline at end of file From 3b4616562cca0da0e4f4c4d4a38d299c462f4721 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 19 Dec 2018 19:48:27 +0100 Subject: [PATCH 09/46] Clarified dialog --- Site/Pages/v5/Admin/CommenceImpersonation.aspx | 2 +- Site/Pages/v5/Admin/CommenceImpersonation.aspx.cs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Site/Pages/v5/Admin/CommenceImpersonation.aspx b/Site/Pages/v5/Admin/CommenceImpersonation.aspx index 54ac871f..eb1ed37e 100644 --- a/Site/Pages/v5/Admin/CommenceImpersonation.aspx +++ b/Site/Pages/v5/Admin/CommenceImpersonation.aspx @@ -20,7 +20,7 @@ alertify.set({ labels: { - ok: SwarmopsJS.unescape('<%=this.Localized_ConfirmDialog_Proceed%>'), + ok: SwarmopsJS.unescape('<%=this.Localized_Impersonate%>'), cancel: SwarmopsJS.unescape('<%=this.Localized_ConfirmDialog_Cancel%>') }, buttonFocus: 'cancel' diff --git a/Site/Pages/v5/Admin/CommenceImpersonation.aspx.cs b/Site/Pages/v5/Admin/CommenceImpersonation.aspx.cs index 858cf85a..8f6bae8b 100644 --- a/Site/Pages/v5/Admin/CommenceImpersonation.aspx.cs +++ b/Site/Pages/v5/Admin/CommenceImpersonation.aspx.cs @@ -85,6 +85,13 @@ namespace Swarmops.Frontend.Pages.v5.Admin get { return JavascriptEscape(Resources.Pages.Admin.CommenceImpersonation_Confirm); } } + public string Localized_Impersonate + { + get { return JavascriptEscape(Resources.Pages.Admin.CommenceImpersonation_Impersonate); } + } + + + /* public string Localized_ValidationError_BankAccount { From deb90da9f115c79fc62ac271eb8d266e3edb2678 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 19 Dec 2018 19:48:35 +0100 Subject: [PATCH 10/46] Skip confirmation added --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 33 ++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 10318bca..013c091f 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -177,14 +177,35 @@ $('.action-skip > a').click(function () { var itemId = $(this).parent().parent().attr("data-item"); - var dependentItemId = $('span.action-list-item[data-dependson="' + itemId + '"]').attr("data-item"); - $('img.action-icon[data-item="' + itemId + '"]').hide(); - $('img.status-icon-completed[data-item="' + itemId + '"]').attr("src", "/Images/Icons/iconshock-red-cross-128x96px.png").fadeIn(); + var prompt = localized_skipPromptGeneric; + if (itemId.startsWith('BankStatement')) { + prompt = localized_skipPromptBankStatement; + } - $('span.action-list-item[data-item="' + itemId + '"]').addClass('action-list-item-completed'); - $('span.action-list-item[data-item="' + dependentItemId + '"]').removeClass('action-list-item-disabled'); - $('img.action-icon[data-item="' + dependentItemId + '"]').removeClass('action-icon-disabled'); + alertify.set({ + labels: { + ok: localized_skipYesResponse, + cancel: localized_skipNoResponse + }, + buttonFocus: 'cancel' + }); + + alertify.confirm(prompt, + $.proxy(function(response) { + if (response) { + var itemId = $(this).parent().parent().attr("data-item"); + + var dependentItemId = $('span.action-list-item[data-dependson="' + itemId + '"]').attr("data-item"); + + $('img.action-icon[data-item="' + itemId + '"]').hide(); + $('img.status-icon-completed[data-item="' + itemId + '"]').attr("src", "/Images/Icons/iconshock-red-cross-128x96px.png").fadeIn(); + + $('span.action-list-item[data-item="' + itemId + '"]').addClass('action-list-item-completed'); + $('span.action-list-item[data-item="' + dependentItemId + '"]').removeClass('action-list-item-disabled'); + $('img.action-icon[data-item="' + dependentItemId + '"]').removeClass('action-icon-disabled'); + } + }, this)); }); }); From dd2dc0fdc447ac7c7d3bc469103c1c3ee04557c8 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 20 Dec 2018 18:00:09 +0100 Subject: [PATCH 11/46] Testing skip disabling on upload --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 013c091f..930a90af 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -251,9 +251,25 @@ return; } + var itemId = $(activeUpload).attr('data-item'); + // TODO: AJAX CALL TO STORE UPLOAD activeUpload = null; + + // If there are items that depend on this one, + // disable their "skip" option now (because there's + // a first document in the series) + + var itemIterator = $('.action-list-item[data-dependson="' + itemId + '"]'); + + while (itemIterator.length > 0) { + // We're only supporting a 1:1 chain at this time, no 1:n dependencies + + itemId = $(itemIterator).attr('data-item'); + $('span.action-list-item[data-item="' + itemId + '"] span.action-skip').addClass('action-skip-disabled'); + itemIterator = $('.action-list-item[data-dependson="' + itemId + '"]'); + } } var uploadGuid = '<%=this.UploadControl.GuidString%>'; From 5b17e21ec228e4783e378cbe2a9e87e8f2c69530 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 20 Dec 2018 19:54:08 +0100 Subject: [PATCH 12/46] More UX testing --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 930a90af..1cb38155 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -210,6 +210,30 @@ }); + function markItemCompleted(item) { + + var groupId = $(item).attr('data-group'); + var itemId = $(item).attr('data-item'); + + $('span.action-list-item[data-item="' + itemId + '"]').addClass('action-list-item-completed'); + $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); + $('img.status-icon-completed[data-item="' + itemId + '"]').fadeIn(); + + var selector = ".action-list-item:not(.action-list-item-completed):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(); + } + + // If any items depended on this one, enable them now + + var dependentItemId = $('span.action-list-item[data-dependson="' + itemId + '"]').attr("data-item"); + $('span.action-list-item[data-item="' + dependentItemId + '"]').removeClass('action-list-item-disabled'); + $('img.action-icon[data-item="' + dependentItemId + '"]').removeClass('action-icon-disabled'); + + } + function clientStartedUpload() { console.log("Client started upload"); @@ -237,6 +261,8 @@ return; } + markItemCompleted(activeUpload); + var itemId = $(activeUpload).attr('data-item'); $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); $('img.action-icon[data-item="' + itemId + '"]').show(); From 5de9f28111f82478433e62bad2c77831b3546428 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 20 Dec 2018 20:37:18 +0100 Subject: [PATCH 13/46] More UX testing 2 --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 1cb38155..fc50d653 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -142,7 +142,7 @@ return; } - triggeredUpload = this; + triggeredUpload = $(this).attr('data-item'); <%=this.UploadControl.ClientID%>_triggerUpload(); } else { @@ -245,12 +245,11 @@ triggeredUpload = null; // switch action icon upload to status icon waiting - var itemId = $(activeUpload).attr('data-item'); - $('img.action-icon[data-item="' + itemId + '"]').hide(); - $('img.status-icon-pleasewait[data-item="' + itemId + '"]').show(); + $('img.action-icon[data-item="' + activeUpload + '"]').hide(); + $('img.status-icon-pleasewait[data-item="' + activeUpload + '"]').show(); // If there's a skip option, disable it at this time - $('span.action-list-item[data-item="' + itemId + '"] span.action-skip').addClass('action-skip-disabled'); + $('span.action-list-item[data-item="' + activeUpload + '"] span.action-skip').addClass('action-skip-disabled'); } function clientFailedUpload() { @@ -261,11 +260,8 @@ return; } - markItemCompleted(activeUpload); - - var itemId = $(activeUpload).attr('data-item'); - $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); - $('img.action-icon[data-item="' + itemId + '"]').show(); + $('img.status-icon-pleasewait[data-item="' + activeUpload + '"]').hide(); + $('img.action-icon[data-item="' + activeUpload + '"]').show(); activeUpload = null; } @@ -277,25 +273,25 @@ return; } - var itemId = $(activeUpload).attr('data-item'); - // TODO: AJAX CALL TO STORE UPLOAD - activeUpload = null; + markItemCompleted(activeUpload); // If there are items that depend on this one, // disable their "skip" option now (because there's // a first document in the series) - var itemIterator = $('.action-list-item[data-dependson="' + itemId + '"]'); + var itemIterator = $('.action-list-item[data-dependson="' + activeUpload + '"]'); while (itemIterator.length > 0) { // We're only supporting a 1:1 chain at this time, no 1:n dependencies - itemId = $(itemIterator).attr('data-item'); + var itemId = $(itemIterator).attr('data-item'); $('span.action-list-item[data-item="' + itemId + '"] span.action-skip').addClass('action-skip-disabled'); itemIterator = $('.action-list-item[data-dependson="' + itemId + '"]'); } + + activeUpload = null; } var uploadGuid = '<%=this.UploadControl.GuidString%>'; From ad9b4083e671f5cf389e3c07ffc4bcd35658cbec Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 20 Dec 2018 20:49:39 +0100 Subject: [PATCH 14/46] Inserting debug code --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index fc50d653..87b91517 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -270,12 +270,16 @@ console.log("Client finished upload"); if (activeUpload == null) { // invalid state + console.log("activeUpload is null"); return; } // TODO: AJAX CALL TO STORE UPLOAD + console.log("activeUpload is " + activeUpload); + console.log("calling MarkCompleted"); markItemCompleted(activeUpload); + console.log("called MarkCompleted"); // If there are items that depend on this one, // disable their "skip" option now (because there's From a62ea35529838358d16f648a3c210bbf0f39c4e1 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 20 Dec 2018 20:51:24 +0100 Subject: [PATCH 15/46] Obvious bugfix --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 87b91517..c5514c7b 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -210,10 +210,9 @@ }); - function markItemCompleted(item) { + function markItemCompleted(itemId) { - var groupId = $(item).attr('data-group'); - var itemId = $(item).attr('data-item'); + var groupId = $('span.action-list-item[data-item="' + itemId + '"]').attr('data-group'); $('span.action-list-item[data-item="' + itemId + '"]').addClass('action-list-item-completed'); $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); From 7e7b2c14fabdf7ce8d543bf2845e57136871d49c Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 20 Dec 2018 21:00:01 +0100 Subject: [PATCH 16/46] More debug code (2) --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 2 ++ Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index c5514c7b..af470c32 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -214,6 +214,8 @@ var groupId = $('span.action-list-item[data-item="' + itemId + '"]').attr('data-group'); + console.log("GroupId is " + groupId); + $('span.action-list-item[data-item="' + itemId + '"]').addClass('action-list-item-completed'); $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); $('img.status-icon-completed[data-item="' + itemId + '"]').fadeIn(); diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index 106fa6d3..90a6cfa4 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -37,6 +37,7 @@ namespace Swarmops.Frontend.Pages.Ledgers EomItemGroup group1 = new EomItemGroup(); group1.Header = Resources.Pages.Ledgers.EndOfMonth_Header_ExternalData; + group1.Id = "ExternalData"; // Iterate over all Balance accounts and check for automation; // if so, add it to an upload sequence @@ -81,7 +82,7 @@ namespace Swarmops.Frontend.Pages.Ledgers EomItem bankStatement = new EomItem(); bankStatement.DependsOn = lastId; // empty for first record bankStatement.Id = lastId = "BankStatement-" + - assetAccount.Identity.ToString(CultureInfo.InvariantCulture) + + assetAccount.Identity.ToString(CultureInfo.InvariantCulture) + '-' + monthIterator; bankStatement.Name = string.Format(Resources.Pages.Ledgers.EndOfMonth_UploadBankStatementFor, assetAccount.Name, "PDF", From dd36828d986658594672838cd09d0ef18ad7c07a Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 20 Dec 2018 21:08:29 +0100 Subject: [PATCH 17/46] Dumbfix --- Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index 90a6cfa4..451d577a 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -145,7 +145,7 @@ namespace Swarmops.Frontend.Pages.Ledgers string previousGroupIdData = string.Empty; if (!string.IsNullOrEmpty(previousGroupId)) { - previousGroupIdData = " data-previous-group='" + previousGroupId + "'"; + previousGroupIdData = " data-previous-group=\"" + previousGroupId + "\""; } bool groupReady = true; From ce1fe59541b72de5f024c1e7ccb46de27a41c59f Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 20 Dec 2018 21:15:21 +0100 Subject: [PATCH 18/46] Let's try this then --- Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index 451d577a..2a4a3b74 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -145,7 +145,7 @@ namespace Swarmops.Frontend.Pages.Ledgers string previousGroupIdData = string.Empty; if (!string.IsNullOrEmpty(previousGroupId)) { - previousGroupIdData = " data-previous-group=\"" + previousGroupId + "\""; + previousGroupIdData = " data-previous-group='" + previousGroupId + "'"; } bool groupReady = true; @@ -162,8 +162,8 @@ namespace Swarmops.Frontend.Pages.Ledgers builder.Append(@" $('#TableEomItems').datagrid('appendRow', { - itemGroupName: '" + - group.Header.Replace(" ", " ").Replace("'", "''") + @"', + itemGroupName: """ + + group.Header.Replace(" ", " ") + @""", action: "" Date: Sat, 22 Dec 2018 10:55:45 +0100 Subject: [PATCH 20/46] Adding some experimental Db class refactoring start --- Basic/Basic.csproj | 1 + Basic/DbColumnAwareBase.cs | 51 ++ Common/Attributes/DbColumnName.cs | 31 ++ Common/Common.csproj | 2 + Common/Enums/FinancialAccountDocumentType.cs | 3 +- Common/Interfaces/IDatabaseColumnAware.cs | 25 + .../Database-FinancialAccountDocuments.cs | 524 ++++++++++++++++++ Database/Database.csproj | 2 + Database/TableBase.cs | 56 ++ 9 files changed, 694 insertions(+), 1 deletion(-) create mode 100644 Basic/DbColumnAwareBase.cs create mode 100644 Common/Attributes/DbColumnName.cs create mode 100644 Common/Interfaces/IDatabaseColumnAware.cs create mode 100644 Database/Database-FinancialAccountDocuments.cs create mode 100644 Database/TableBase.cs diff --git a/Basic/Basic.csproj b/Basic/Basic.csproj index 27cb55bc..1b61a3b0 100644 --- a/Basic/Basic.csproj +++ b/Basic/Basic.csproj @@ -57,6 +57,7 @@ + diff --git a/Basic/DbColumnAwareBase.cs b/Basic/DbColumnAwareBase.cs new file mode 100644 index 00000000..12c28213 --- /dev/null +++ b/Basic/DbColumnAwareBase.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +/* 2018-Dec-22: This is a started refactoring of the Database namespace into separate derived classes + * from a generic that contains most of the gruntwork. It is not nearly complete and + * the code is still experimental, not taken into production yet. + */ + +namespace Swarmops.Basic +{ + public class DbColumnAwareBase + { + static DbColumnAwareBase() + { + if (_classColumnOrdinalLookup == null) + { + _classColumnOrdinalLookup = new Dictionary>(); + _classColumnSequenceLookup = new Dictionary(); + } + } + + public DbColumnAwareBase() + { + // ReSharper disable once DoNotCallOverridableMethodsInConstructor + VerifyLookupInitialized(); + } + + private static Dictionary> _classColumnOrdinalLookup; + private static Dictionary _classColumnSequenceLookup; + + + public virtual void VerifyLookupInitialized() + { + string className = this.GetType().Name; + if (_classColumnOrdinalLookup.ContainsKey(className)) + { + return; + } + + // The key of the instantiated class is not in the dictionary, so initialize dictionary + + // This is done with reflection, so is very expensive, which is why we only do it once for + // every class that derives from DbColumnAwareBase + ; + } + } +} diff --git a/Common/Attributes/DbColumnName.cs b/Common/Attributes/DbColumnName.cs new file mode 100644 index 00000000..836d054c --- /dev/null +++ b/Common/Attributes/DbColumnName.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Drawing.Text; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +/* 2018-Dec-22: This is a started refactoring of the Database namespace into separate derived classes + * from a generic that contains most of the gruntwork. It is not nearly complete and + * the code is still experimental, not taken into production yet. + */ + + +namespace Swarmops.Common.Attributes +{ + [AttributeUsage(AttributeTargets.Property)] + public class DbColumnName: Attribute + { + public DbColumnName() + { + // means the column name is the same as the property name that houses the attribute + this.ColumnName = string.Empty; + } + public DbColumnName(string columnName) + { + this.ColumnName = columnName; + } + + public string ColumnName { get; private set; } + } +} diff --git a/Common/Common.csproj b/Common/Common.csproj index 06194146..3ea2b9bc 100644 --- a/Common/Common.csproj +++ b/Common/Common.csproj @@ -41,6 +41,7 @@ + @@ -82,6 +83,7 @@ + diff --git a/Common/Enums/FinancialAccountDocumentType.cs b/Common/Enums/FinancialAccountDocumentType.cs index ba80cb98..c76f95dc 100644 --- a/Common/Enums/FinancialAccountDocumentType.cs +++ b/Common/Enums/FinancialAccountDocumentType.cs @@ -10,6 +10,7 @@ namespace Swarmops.Common.Enums { Unknown = 0, BankStatement, - BankTransactionData + BankTransactionData, + BankPaymentData } } diff --git a/Common/Interfaces/IDatabaseColumnAware.cs b/Common/Interfaces/IDatabaseColumnAware.cs new file mode 100644 index 00000000..57106c72 --- /dev/null +++ b/Common/Interfaces/IDatabaseColumnAware.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +/* 2018-Dec-22: This is a started refactoring of the Database namespace into separate derived classes + * from a generic that contains most of the gruntwork. It is not nearly complete and + * the code is still experimental, not taken into production yet. + */ + + +namespace Swarmops.Common.Interfaces +{ + [SuppressMessage("ReSharper", "TypeParameterCanBeVariant")] + public interface IDatabaseColumnAware + { + string DbTableName { get; } + string[] DbFieldSequence { get; } + string DbIdentityField { get; } + TBasic FromDataReader (IDataReader reader); // this could be static but C# doesn't allow static methods in interfaces + } +} diff --git a/Database/Database-FinancialAccountDocuments.cs b/Database/Database-FinancialAccountDocuments.cs new file mode 100644 index 00000000..cb18f7aa --- /dev/null +++ b/Database/Database-FinancialAccountDocuments.cs @@ -0,0 +1,524 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.Common; +using Swarmops.Basic.Types; +using Swarmops.Basic.Types.Financial; +using Swarmops.Common.Enums; + +namespace Swarmops.Database +{ + public partial class SwarmDb + { + #region Database field reading + + private const string financialAccountDocumentFieldSequence = + " PaymentId,PaymentGroupId,AmountCents,Reference,FromAccount," + // 0-4 + "PaymentKey,HasImage,OutboundInvoiceId " + // 5-7 + "FROM Payments "; + + private static BasicPayment ReadFinancialAccountDocumentFromDataReader(IDataRecord reader) + { + int paymentId = reader.GetInt32(0); + int paymentGroupId = reader.GetInt32(1); + Int64 amountCents = reader.GetInt64(2); + string reference = reader.GetString(3); + string fromAccount = reader.GetString(4); + string key = reader.GetString(5); + bool hasImage = reader.GetBoolean(6); + int outboundInvoiceId = reader.GetInt32(7); + + return new BasicPayment(paymentId, paymentGroupId, amountCents, reference, fromAccount, key, hasImage, + outboundInvoiceId); + } + + #endregion + + #region Database record reading -- SELECT clauses + + public BasicPayment GetFinancialAccountDocument(int financialAccountDocumentId) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = + GetDbCommand("SELECT" + paymentFieldSequence + + "WHERE FinancialAccountDocumentId=" + financialAccountDocumentId, + connection); + + using (DbDataReader reader = command.ExecuteReader()) + { + if (reader.Read()) + { + return ReadPaymentFromDataReader(reader); + } + + throw new ArgumentException("No such FinancialAccountDocumentId:" + financialAccountDocumentId); + } + } + } + + + public BasicPayment[] GetFinancialAccountDocuments(params object[] conditions) + { + List result = new List(); + + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = + GetDbCommand( + "SELECT" + paymentFieldSequence + ConstructWhereClause("Payments", conditions), connection); + + using (DbDataReader reader = command.ExecuteReader()) + { + while (reader.Read()) + { + result.Add(ReadPaymentFromDataReader(reader)); + } + + return result.ToArray(); + } + } + } + + + #endregion + + #region Creation and manipulation -- stored procedures + + public int CreateFinancialAccountDocument(int financialAccountId, FinancialAccountDocumentType type, int uploadedByPersonId, + DateTime concernsPeriodStart, DateTime concernsPeriodEnd, string rawText) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("CreateFinancialAccountDocument", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "financialAccountId", financialAccountId); + AddParameterWithName(command, "financialAccountDocumentType", type.ToString()); + AddParameterWithName(command, "uploadedDateTime", DateTime.UtcNow); + AddParameterWithName(command, "uploadedByPersonId", uploadedByPersonId); + AddParameterWithName(command, "concernsPeriodStart", concernsPeriodStart); // inclusive endpoint + AddParameterWithName(command, "concernsPeriodEnd", concernsPeriodEnd); // exclusive endpoint + AddParameterWithName(command, "outboundInvoiceId", outboundInvoiceId); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + + public int CreatePayment(int paymentGroupId, Int64 amountCents, string reference, string fromAccount, + string key, + bool hasImage, int outboundInvoiceId) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("CreatePaymentPrecise", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "paymentGroupId", paymentGroupId); + AddParameterWithName(command, "amountCents", amountCents); + AddParameterWithName(command, "reference", reference); + AddParameterWithName(command, "fromAccount", fromAccount); + AddParameterWithName(command, "paymentKey", key); + AddParameterWithName(command, "hasImage", hasImage); + AddParameterWithName(command, "outboundInvoiceId", outboundInvoiceId); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + + public int CreatePaymentInformation(int paymentId, PaymentInformationType type, string data) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("CreatePaymentInformation", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "paymentId", paymentId); + AddParameterWithName(command, "dataTypeString", type.ToString()); + AddParameterWithName(command, "data", data); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + [Obsolete("This should never be called, ever: it ruins trackability.")] + public void DeletePayment(int paymentId) + { + // This function is necessary since the Swedish bank system only allows for a dupe check AFTER all payments + // have been communicated, so they are created as data is received. If the data was a dupe, it is therefore + // deleted after the dupecheck triggers. + + // That code was later re-written to do in-memory dupechecking. This delete function should never be called. + + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("DeletePayment", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "paymentId", paymentId); + + command.ExecuteNonQuery(); + } + } + + #endregion + + #region Dead template code + + /* + public BasicExpenseClaim GetExpenseClaim(int expenseClaimId) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand( + "SELECT ExpenseClaimId,ClaimingPersonId,CreatedDateTime,Open,Attested," + + "Validated,Claimed,OrganizationId,GeographyId,BudgetId,BudgetYear," + + "ExpenseDate,Description,PreApprovedAmount,Amount,Repaid " + + "FROM ExpenseClaims WHERE ExpenseClaimId=" + expenseClaimId.ToString(), + connection); + + using (DbDataReader reader = command.ExecuteReader()) + { + if (reader.Read()) + { + return ReadExpenseFromDataReader(reader); + } + + throw new ArgumentException("Unknown ExpenseClaim Id"); + } + } + } + + public BasicExpenseClaim[] GetExpenseClaimsByClaimer(int claimingPersonId) + { + List result = new List(); + + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = + GetDbCommand("SELECT ExpenseClaimId,ClaimingPersonId,CreatedDateTime,Open,Attested," + + "Validated,Claimed,OrganizationId,GeographyId,BudgetId,BudgetYear," + + "ExpenseDate,Description,PreApprovedAmount,Amount,Repaid " + + "FROM ExpenseClaims WHERE ClaimingPersonId=" + claimingPersonId.ToString(), + connection); + + using (DbDataReader reader = command.ExecuteReader()) + { + while (reader.Read()) + { + result.Add(ReadExpenseFromDataReader(reader)); + } + + return result.ToArray(); + } + } + } + + public BasicExpenseClaim[] GetExpenseClaimsByBudgetAndYear(int budgetId, int budgetYear) + { + List result = new List(); + + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = + GetDbCommand("SELECT ExpenseClaimId,ClaimingPersonId,CreatedDateTime,Open,Attested," + + "Validated,Claimed,OrganizationId,GeographyId,BudgetId,BudgetYear," + + "ExpenseDate,Description,PreApprovedAmount,Amount,Repaid " + + "FROM ExpenseClaims WHERE BudgetId=" + budgetId.ToString() + " AND BudgetYear=" + budgetYear.ToString(), + connection); + + using (DbDataReader reader = command.ExecuteReader()) + { + while (reader.Read()) + { + result.Add(ReadExpenseFromDataReader(reader)); + } + + return result.ToArray(); + } + } + } + + public BasicExpenseClaim[] GetExpenseClaimsByOrganization(int organizationId) + { + List result = new List(); + + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = + GetDbCommand("SELECT ExpenseClaimId,ClaimingPersonId,CreatedDateTime,Open,Attested," + + "Validated,Claimed,OrganizationId,GeographyId,BudgetId,BudgetYear," + + "ExpenseDate,Description,PreApprovedAmount,Amount,Repaid " + + "FROM ExpenseClaims WHERE OrganizationId=" + organizationId.ToString(), + connection); + + using (DbDataReader reader = command.ExecuteReader()) + { + while (reader.Read()) + { + result.Add(ReadExpenseFromDataReader(reader)); + } + + return result.ToArray(); + } + } + } + + + private BasicExpenseClaim ReadExpenseFromDataReader(DbDataReader reader) + { + int expenseClaimId = reader.GetInt32(0); + int claimingPersonId = reader.GetInt32(1); + DateTime createdDateTime = reader.GetDateTime(2); + bool open = reader.GetBoolean(3); + bool attested = reader.GetBoolean(4); + bool documented = reader.GetBoolean(5); + bool claimed = reader.GetBoolean(6); + int organizationId = reader.GetInt32(7); + int geographyId = reader.GetInt32(8); // obsolete field + int budgetId = reader.GetInt32(9); + int budgetYear = reader.GetInt32(10); + DateTime expenseDate = reader.GetDateTime(11); + string description = reader.GetString(12); + double preApprovedAmount = reader.GetDouble(13); + double amount = reader.GetDouble(14); + bool repaid = reader.GetBoolean(15); + + return new BasicExpenseClaim(expenseClaimId, claimingPersonId, createdDateTime, + open, attested, documented, claimed, organizationId, geographyId, + budgetId, budgetYear, expenseDate, description, preApprovedAmount, + amount, repaid); + } + + + public int CreateExpenseClaim(int claimingPersonId, int organizationId, int budgetId, int budgetYear, + DateTime expenseDate, string description, double amount) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("CreateExpenseClaim", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "claimingPersonId", claimingPersonId); + AddParameterWithName(command, "createdDateTime", DateTime.Now); + AddParameterWithName(command, "organizationId", organizationId); + AddParameterWithName(command, "budgetId", budgetId); + AddParameterWithName(command, "budgetYear", budgetYear); + AddParameterWithName(command, "expenseDate", expenseDate); + AddParameterWithName(command, "description", description); + AddParameterWithName(command, "amount", amount); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + public int SetExpenseClaimDescription(int expenseClaimId, string description) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("SetExpenseClaimDescription", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "expenseClaimId", expenseClaimId); + AddParameterWithName(command, "description", description); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + + public int SetExpenseClaimBudget(int expenseClaimId, int budgetId) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("SetExpenseClaimBudget", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "expenseClaimId", expenseClaimId); + AddParameterWithName(command, "budgetId", budgetId); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + + public int SetExpenseClaimBudgetYear(int expenseClaimId, int budgetYear) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("SetExpenseClaimBudgetYear", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "expenseClaimId", expenseClaimId); + AddParameterWithName(command, "budgetYear", budgetYear); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + + public int SetExpenseClaimDate(int expenseClaimId, DateTime expenseDate) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("SetExpenseClaimDate", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "expenseClaimId", expenseClaimId); + AddParameterWithName(command, "expenseDate", expenseDate); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + + public int SetExpenseClaimAmount(int expenseClaimId, double amount) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("SetExpenseClaimAmount", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "expenseClaimId", expenseClaimId); + AddParameterWithName(command, "amount", amount); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + + + public int SetExpenseClaimAttested(int expenseClaimId, bool attested) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("SetExpenseClaimAttested", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "expenseClaimId", expenseClaimId); + AddParameterWithName(command, "attested", attested); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + + + public int SetExpenseClaimValidated(int expenseClaimId, bool validated) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("SetExpenseClaimValidated", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "expenseClaimId", expenseClaimId); + AddParameterWithName(command, "validated", validated); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + + + public int SetExpenseClaimOpen(int expenseClaimId, bool open) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("SetExpenseClaimOpen", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "expenseClaimId", expenseClaimId); + AddParameterWithName(command, "open", open); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + + + + public int SetExpenseClaimRepaid(int expenseClaimId, bool repaid) + { + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("SetExpenseClaimRepaid", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "expenseClaimId", expenseClaimId); + AddParameterWithName(command, "repaid", repaid); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + + + + public int CreateExpenseEvent(int expenseId, ExpenseEventType eventType, int personId) + { + // WARNING: NOT CONVERTED TO V4 YET + + using (DbConnection connection = GetSqlServerDbConnection()) + { + connection.Open(); + + DbCommand command = GetDbCommand("CreateExpenseEvent", connection); + command.CommandType = CommandType.StoredProcedure; + + AddParameterWithName(command, "expenseId", expenseId); + AddParameterWithName(command, "dateTime", DateTime.Now); + AddParameterWithName(command, "eventPersonId", personId); + AddParameterWithName(command, "eventType", eventType.ToString()); + + return Convert.ToInt32(command.ExecuteScalar()); + } + } + + + */ + + #endregion + } +} \ No newline at end of file diff --git a/Database/Database.csproj b/Database/Database.csproj index e1e0c0f1..7a981f39 100644 --- a/Database/Database.csproj +++ b/Database/Database.csproj @@ -62,6 +62,7 @@ + @@ -141,6 +142,7 @@ + Designer diff --git a/Database/TableBase.cs b/Database/TableBase.cs new file mode 100644 index 00000000..35744805 --- /dev/null +++ b/Database/TableBase.cs @@ -0,0 +1,56 @@ +using System; +using System.CodeDom; +using System.Collections.Generic; +using System.Data.Common; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Swarmops.Common.Interfaces; + + +/* 2018-Dec-22: This is a started refactoring of the Database namespace into separate derived classes + * from a generic that contains most of the gruntwork. It is not nearly complete and + * the code is still experimental, not taken into production yet. + */ + + +namespace Swarmops.Database +{ + public class TableBase where TBasic: IDatabaseColumnAware, new() + { + public TBasic GetRecordByIdentity(int identity, bool aggressive = false) + { + throw new NotImplementedException(); + /* + using (DbConnection connection = GetMySqlDbConnection()) + { + connection.Open(); + + DbCommand command = + GetDbCommand("SELECT" + paymentFieldSequence + + "WHERE PaymentId=" + paymentId, + connection); + + using (DbDataReader reader = command.ExecuteReader()) + { + if (reader.Read()) + { + return new TBasic().FromDataReader(reader); + } + + throw new ArgumentException("No such PaymentId:" + paymentId); + } + }*/ + } + + public TBasic[] GetRecordsByIdentity(int[] identities) + { + throw new NotImplementedException(); + } + + public TBasic[] GetRecords(params object[] conditions) + { + throw new NotImplementedException(); + } + } +} From ac6d25f74092c66ef3ba1b7df9151e666a95a526 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 25 Dec 2018 21:16:26 +0100 Subject: [PATCH 21/46] Work on Db refactor --- Common/Interfaces/IDatabaseColumnAware.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Common/Interfaces/IDatabaseColumnAware.cs b/Common/Interfaces/IDatabaseColumnAware.cs index 57106c72..b17a7bba 100644 --- a/Common/Interfaces/IDatabaseColumnAware.cs +++ b/Common/Interfaces/IDatabaseColumnAware.cs @@ -17,9 +17,11 @@ namespace Swarmops.Common.Interfaces [SuppressMessage("ReSharper", "TypeParameterCanBeVariant")] public interface IDatabaseColumnAware { + // these could all be static but C# doesn't allow static methods in interfaces + string DbTableName { get; } - string[] DbFieldSequence { get; } - string DbIdentityField { get; } - TBasic FromDataReader (IDataReader reader); // this could be static but C# doesn't allow static methods in interfaces + string[] DbColumnSequence { get; } + string DbIdentityColumn { get; } + TBasic FromDataReader (IDataReader reader); } } From 60f55bb88379cb7ff7a6295f09fdf1a5aaac0fc3 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 25 Dec 2018 21:16:48 +0100 Subject: [PATCH 22/46] Work on EOM checklist --- .../BasicFinancialAccountDocument.cs | 21 ++++-- .../Database-FinancialAccountDocuments.cs | 68 +------------------ Site/Pages/v5/Ledgers/EndOfMonth.aspx | 29 ++++---- Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 30 +++++++- 4 files changed, 61 insertions(+), 87 deletions(-) diff --git a/Basic/Types/Financial/BasicFinancialAccountDocument.cs b/Basic/Types/Financial/BasicFinancialAccountDocument.cs index 43191ccc..6af25bb3 100644 --- a/Basic/Types/Financial/BasicFinancialAccountDocument.cs +++ b/Basic/Types/Financial/BasicFinancialAccountDocument.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Swarmops.Common.Attributes; using Swarmops.Common.Enums; using Swarmops.Common.Interfaces; @@ -38,14 +39,20 @@ namespace Swarmops.Basic.Types.Financial // empty copy ctor } - public int FinancialAccountDocumentId { get; private set; } - public int FinancialAccountId { get; private set; } + // Name-identical dbcolumns / properties + + [DbColumnName] public int FinancialAccountDocumentId { get; private set; } + [DbColumnName] public int FinancialAccountId { get; private set; } + [DbColumnName] public DateTime UploadedDateTime { get; private set; } + [DbColumnName] public int UploadedByPersonId { get; private set; } + [DbColumnName] public DateTime ConcernsPeriodStart { get; private set; } + [DbColumnName] public DateTime ConcernsPeriodEnd { get; private set; } + [DbColumnName] public string RawDocumentText { get; private set; } + + // Complex or renamed dbcolumns / properties + public FinancialAccountDocumentType Type { get; private set; } - public DateTime UploadedDateTime { get; private set; } - public int UploadedByPersonId { get; private set; } - public DateTime ConcernsPeriodStart { get; private set; } - public DateTime ConcernsPeriodEnd { get; private set; } - public string RawDocumentText { get; private set; } + public int Identity { get { return this.FinancialAccountDocumentId; } } } diff --git a/Database/Database-FinancialAccountDocuments.cs b/Database/Database-FinancialAccountDocuments.cs index cb18f7aa..d584d2ff 100644 --- a/Database/Database-FinancialAccountDocuments.cs +++ b/Database/Database-FinancialAccountDocuments.cs @@ -43,7 +43,7 @@ namespace Swarmops.Database connection.Open(); DbCommand command = - GetDbCommand("SELECT" + paymentFieldSequence + + GetDbCommand("SELECT" + financialAccountDocumentFieldSequence + "WHERE FinancialAccountDocumentId=" + financialAccountDocumentId, connection); @@ -70,7 +70,7 @@ namespace Swarmops.Database DbCommand command = GetDbCommand( - "SELECT" + paymentFieldSequence + ConstructWhereClause("Payments", conditions), connection); + "SELECT" + financialAccountDocumentFieldSequence + ConstructWhereClause("Payments", conditions), connection); using (DbDataReader reader = command.ExecuteReader()) { @@ -105,75 +105,13 @@ namespace Swarmops.Database AddParameterWithName(command, "uploadedByPersonId", uploadedByPersonId); AddParameterWithName(command, "concernsPeriodStart", concernsPeriodStart); // inclusive endpoint AddParameterWithName(command, "concernsPeriodEnd", concernsPeriodEnd); // exclusive endpoint - AddParameterWithName(command, "outboundInvoiceId", outboundInvoiceId); + AddParameterWithName(command, "rawDocumentText", rawText); return Convert.ToInt32(command.ExecuteScalar()); } } - public int CreatePayment(int paymentGroupId, Int64 amountCents, string reference, string fromAccount, - string key, - bool hasImage, int outboundInvoiceId) - { - using (DbConnection connection = GetMySqlDbConnection()) - { - connection.Open(); - - DbCommand command = GetDbCommand("CreatePaymentPrecise", connection); - command.CommandType = CommandType.StoredProcedure; - - AddParameterWithName(command, "paymentGroupId", paymentGroupId); - AddParameterWithName(command, "amountCents", amountCents); - AddParameterWithName(command, "reference", reference); - AddParameterWithName(command, "fromAccount", fromAccount); - AddParameterWithName(command, "paymentKey", key); - AddParameterWithName(command, "hasImage", hasImage); - AddParameterWithName(command, "outboundInvoiceId", outboundInvoiceId); - - return Convert.ToInt32(command.ExecuteScalar()); - } - } - - - public int CreatePaymentInformation(int paymentId, PaymentInformationType type, string data) - { - using (DbConnection connection = GetMySqlDbConnection()) - { - connection.Open(); - - DbCommand command = GetDbCommand("CreatePaymentInformation", connection); - command.CommandType = CommandType.StoredProcedure; - - AddParameterWithName(command, "paymentId", paymentId); - AddParameterWithName(command, "dataTypeString", type.ToString()); - AddParameterWithName(command, "data", data); - - return Convert.ToInt32(command.ExecuteScalar()); - } - } - - [Obsolete("This should never be called, ever: it ruins trackability.")] - public void DeletePayment(int paymentId) - { - // This function is necessary since the Swedish bank system only allows for a dupe check AFTER all payments - // have been communicated, so they are created as data is received. If the data was a dupe, it is therefore - // deleted after the dupecheck triggers. - - // That code was later re-written to do in-memory dupechecking. This delete function should never be called. - - using (DbConnection connection = GetMySqlDbConnection()) - { - connection.Open(); - - DbCommand command = GetDbCommand("DeletePayment", connection); - command.CommandType = CommandType.StoredProcedure; - - AddParameterWithName(command, "paymentId", paymentId); - - command.ExecuteNonQuery(); - } - } #endregion diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index ce2155cb..66079c1c 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -154,21 +154,24 @@ SwarmopsJS.ajaxCall( "/Pages/v5/Ledgers/EndOfMonth.aspx/" + callbackFunction, - {}, - $.proxy(function() { - var groupId = $(this).attr('data-group'); + { itemId: itemId }, + // Success function + $.proxy(function (result) { var itemId = $(this).attr('data-item'); - - $('span.action-list-item[data-item="' + itemId + '"]').addClass('action-list-item-completed'); - $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); - $('img.status-icon-completed[data-item="' + itemId + '"]').fadeIn(); - - var selector = ".action-list-item:not(.action-list-item-completed):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(); + if (result.Success) { + markItemCompleted(itemId); + } else { + // Restore action icons. + // Todo: display DisplayMessage in dialog or error notice. + $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); + $('img.action-icon[data-item="' + itemId + '"]').show(); } + }, this), + // Failure (exception) function + $.proxy(function () { + var itemId = $(this).attr('data-item'); + $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); + $('img.action-icon[data-item="' + itemId + '"]').show(); }, this) ); } diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index 2a4a3b74..d205230d 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -251,10 +251,9 @@ namespace Swarmops.Frontend.Pages.Ledgers } [WebMethod] - public static AjaxCallResult CreateVatReport() + public static AjaxCallResult CreateVatReport(string itemId) { AuthenticationData authData = GetAuthenticationDataAndCulture(); - if (!authData.Authority.HasAccess(new Access(authData.CurrentOrganization, AccessAspect.BookkeepingDetails))) { throw new UnauthorizedAccessException(); @@ -266,6 +265,33 @@ namespace Swarmops.Frontend.Pages.Ledgers } + [WebMethod] + public static AjaxCallResult UploadBankStatement(string itemId) + { + AuthenticationData authData = GetAuthenticationDataAndCulture(); + if (!authData.Authority.HasAccess(new Access(authData.CurrentOrganization, AccessAspect.BookkeepingDetails))) + { + throw new UnauthorizedAccessException(); + } + + string[] parts = itemId.Split('-'); + FinancialAccount account = FinancialAccount.FromIdentity(Int32.Parse(parts[1])); + int yearMonth = Int32.Parse(parts[2]); + + if (account.OrganizationId != authData.CurrentOrganization.Identity) + { + throw new UnauthorizedAccessException(); + } + + + + return new AjaxCallResult {Success = true}; + } + + + + + private class EomItem { public string Id { get; set; } From bf67b0037462a297971fa0b3ff707c8ccd35d180 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 26 Dec 2018 10:41:38 +0100 Subject: [PATCH 23/46] Updated TODO --- todo.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/todo.txt b/todo.txt index 003a6c93..06b8d64f 100644 --- a/todo.txt +++ b/todo.txt @@ -14,7 +14,7 @@ PRIO 1 [ ] End-of-month routine [ ] - incl EOY [ ] - with todo field -[ ] Fix generic block explorer interfaces' +[ ] Fix generic block explorer interfaces [ ] Fix & redo bank file upload completely [ ] - with interface to Github repo of XML definitions [ ] Fix Bionic build @@ -25,20 +25,23 @@ PRIO 1 PRIO 2 ------ -[ ] Recurring expenses [ ] Todo box JSON -[ ] Expense reject malfunction +[ ] Expense reject malfunction (what's this? -RF) [ ] Backoffice.Cash SKU [ ] Submit invoice [ ] Control messages for invoice progress [ ] Pay invoice [ ] Upload bank statements [ ] External people notifications +[ ] Currency inventory tracking +[ ] Cost centers and 2-D reports +[ ] Monthly reports (not just quarterly) PRIO 3 ------ +[ ] Recurring expenses [ ] HTML/Markdown mail [ ] Org texts self-signup [ ] Load hotwallet from cold From 93f96d5f22d4ef71ea7e7fda8d0e2e0a5148fa7a Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 31 Dec 2018 05:44:28 +0100 Subject: [PATCH 24/46] update Todo --- todo.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/todo.txt b/todo.txt index 06b8d64f..2dca32e6 100644 --- a/todo.txt +++ b/todo.txt @@ -3,7 +3,7 @@ NOV2018 OVERALL: [ ] Fix basic flows -[ ] Focus on new SKU Backoffice.Cash +[ ] Focus on new SKU op.Cash [ ] Make work on Bionic and Stretch @@ -27,10 +27,11 @@ PRIO 2 [ ] Todo box JSON [ ] Expense reject malfunction (what's this? -RF) -[ ] Backoffice.Cash SKU +[ ] op.Cash SKU [ ] Submit invoice [ ] Control messages for invoice progress [ ] Pay invoice +[ ] Payment points for invoices, expense reports [ ] Upload bank statements [ ] External people notifications [ ] Currency inventory tracking @@ -47,6 +48,6 @@ PRIO 3 [ ] Load hotwallet from cold [ ] Database discrepancy [ ] Icons for Validation -[ ] Backoffice.Cash OOBE +[ ] op.Cash OOBE [ ] Assign role geolock From ac72f6bdf00291a881665fd8c341490010012cfc Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 31 Dec 2018 05:44:56 +0100 Subject: [PATCH 25/46] Continued refactoring of Db class --- Basic/DbColumnAwareBase.cs | 10 ++++++++++ Common/Attributes/DbColumnName.cs | 2 +- Common/Attributes/DbColumnTypeName.cs | 24 ++++++++++++++++++++++++ Common/Attributes/DbIdentity.cs | 14 ++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 Common/Attributes/DbColumnTypeName.cs create mode 100644 Common/Attributes/DbIdentity.cs diff --git a/Basic/DbColumnAwareBase.cs b/Basic/DbColumnAwareBase.cs index 12c28213..3d58ba96 100644 --- a/Basic/DbColumnAwareBase.cs +++ b/Basic/DbColumnAwareBase.cs @@ -47,5 +47,15 @@ namespace Swarmops.Basic // every class that derives from DbColumnAwareBase ; } + + /* + * + * sample SELECT sequence: + * private const string financialAccountDocumentFieldSequence = + " FinancialAccountDocumentId,FinancialAccountId,FinancialAccountDocumentTypes.Name,UploadedDateTime,UploadedByPersonId, " + // 0-4 + " ConcernsPeriodStart,ConcernsPeriodEnd,RawDocumentText " + // 5-7 + " FROM FinancialAccountDocuments JOIN FinancialAccountDocumentTypes USING (FinancialAccountDocumentTypeId) "; + + */ } } diff --git a/Common/Attributes/DbColumnName.cs b/Common/Attributes/DbColumnName.cs index 836d054c..5b04cb1e 100644 --- a/Common/Attributes/DbColumnName.cs +++ b/Common/Attributes/DbColumnName.cs @@ -18,7 +18,7 @@ namespace Swarmops.Common.Attributes { public DbColumnName() { - // means the column name is the same as the property name that houses the attribute + // empty attr means the column name is the same as the property name that houses the attribute this.ColumnName = string.Empty; } public DbColumnName(string columnName) diff --git a/Common/Attributes/DbColumnTypeName.cs b/Common/Attributes/DbColumnTypeName.cs new file mode 100644 index 00000000..f4897130 --- /dev/null +++ b/Common/Attributes/DbColumnTypeName.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; + +namespace Swarmops.Common.Attributes +{ + [AttributeUsage(AttributeTargets.Property)] + public class DbColumnForeignTypeName: Attribute + { + public DbColumnForeignTypeName(string foreignTableName, string commonIdColumnName, string foreignTypeColumnName) + { + this.ForeignTableName = foreignTableName; + this.CommonIdColumnName = commonIdColumnName; + this.ForeignTypeColumnName = foreignTypeColumnName; + } + + public string ForeignTableName { get; private set; } + public string CommonIdColumnName { get; private set; } + public string ForeignTypeColumnName { get; private set; } + } +} diff --git a/Common/Attributes/DbIdentity.cs b/Common/Attributes/DbIdentity.cs new file mode 100644 index 00000000..9b64aac1 --- /dev/null +++ b/Common/Attributes/DbIdentity.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Swarmops.Common.Attributes +{ + [AttributeUsage(AttributeTargets.Property)] + public class DbIdentity: Attribute + { + public DbIdentity() { } + } +} From f221ddff037dab1fb79a7c8855201907d77c893b Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 31 Dec 2018 05:45:19 +0100 Subject: [PATCH 26/46] More work on FinancialAccountDocument --- .../BasicFinancialAccountDocument.cs | 7 +++- Common/Common.csproj | 2 + .../Database-FinancialAccountDocuments.cs | 40 ++++++++++--------- Logic/Financial/FinancialAccountDocument.cs | 36 +++++++++++++++++ Site/Site.csproj | 3 ++ 5 files changed, 68 insertions(+), 20 deletions(-) diff --git a/Basic/Types/Financial/BasicFinancialAccountDocument.cs b/Basic/Types/Financial/BasicFinancialAccountDocument.cs index 6af25bb3..d0b329b8 100644 --- a/Basic/Types/Financial/BasicFinancialAccountDocument.cs +++ b/Basic/Types/Financial/BasicFinancialAccountDocument.cs @@ -39,9 +39,13 @@ namespace Swarmops.Basic.Types.Financial // empty copy ctor } + // Identity field + + [DbColumnName] [DbIdentity] + public int FinancialAccountDocumentId { get; private set; } + // Name-identical dbcolumns / properties - [DbColumnName] public int FinancialAccountDocumentId { get; private set; } [DbColumnName] public int FinancialAccountId { get; private set; } [DbColumnName] public DateTime UploadedDateTime { get; private set; } [DbColumnName] public int UploadedByPersonId { get; private set; } @@ -51,6 +55,7 @@ namespace Swarmops.Basic.Types.Financial // Complex or renamed dbcolumns / properties + [DbColumnForeignTypeName("FinancialAccountDocumentTypes", "FinancialAccountDocumentTypeId", "Name")] public FinancialAccountDocumentType Type { get; private set; } diff --git a/Common/Common.csproj b/Common/Common.csproj index 3ea2b9bc..42a06436 100644 --- a/Common/Common.csproj +++ b/Common/Common.csproj @@ -40,8 +40,10 @@ + + diff --git a/Database/Database-FinancialAccountDocuments.cs b/Database/Database-FinancialAccountDocuments.cs index d584d2ff..9f85d435 100644 --- a/Database/Database-FinancialAccountDocuments.cs +++ b/Database/Database-FinancialAccountDocuments.cs @@ -13,30 +13,32 @@ namespace Swarmops.Database #region Database field reading private const string financialAccountDocumentFieldSequence = - " PaymentId,PaymentGroupId,AmountCents,Reference,FromAccount," + // 0-4 - "PaymentKey,HasImage,OutboundInvoiceId " + // 5-7 - "FROM Payments "; + " FinancialAccountDocumentId,FinancialAccountId,FinancialAccountDocumentTypes.Name,UploadedDateTime,UploadedByPersonId, " + // 0-4 + " ConcernsPeriodStart,ConcernsPeriodEnd,RawDocumentText " + // 5-7 + " FROM FinancialAccountDocuments JOIN FinancialAccountDocumentTypes USING (FinancialAccountDocumentTypeId) "; - private static BasicPayment ReadFinancialAccountDocumentFromDataReader(IDataRecord reader) + private static BasicFinancialAccountDocument ReadFinancialAccountDocumentFromDataReader(IDataRecord reader) { - int paymentId = reader.GetInt32(0); - int paymentGroupId = reader.GetInt32(1); - Int64 amountCents = reader.GetInt64(2); - string reference = reader.GetString(3); - string fromAccount = reader.GetString(4); - string key = reader.GetString(5); - bool hasImage = reader.GetBoolean(6); - int outboundInvoiceId = reader.GetInt32(7); + int financialAccountDocumentId = reader.GetInt32(0); + int financialAccountId = reader.GetInt32(1); + string financialAccountDocumentTypeString = reader.GetString(2); + DateTime uploadedDateTime = reader.GetDateTime(3); + int uploadedByPersonId = reader.GetInt32(4); + DateTime concernsPeriodStart = reader.GetDateTime(5); + DateTime concernsPeriodEnd = reader.GetDateTime(6); + string rawText = reader.GetString(7); - return new BasicPayment(paymentId, paymentGroupId, amountCents, reference, fromAccount, key, hasImage, - outboundInvoiceId); + FinancialAccountDocumentType docType = (FinancialAccountDocumentType) Enum.Parse(typeof (FinancialAccountDocumentType), financialAccountDocumentTypeString); + + return new BasicFinancialAccountDocument(financialAccountDocumentId, financialAccountId, docType, uploadedDateTime, uploadedByPersonId, concernsPeriodStart, + concernsPeriodEnd, rawText); } #endregion #region Database record reading -- SELECT clauses - public BasicPayment GetFinancialAccountDocument(int financialAccountDocumentId) + public BasicFinancialAccountDocument GetFinancialAccountDocument(int financialAccountDocumentId) { using (DbConnection connection = GetMySqlDbConnection()) { @@ -51,7 +53,7 @@ namespace Swarmops.Database { if (reader.Read()) { - return ReadPaymentFromDataReader(reader); + return ReadFinancialAccountDocumentFromDataReader(reader); } throw new ArgumentException("No such FinancialAccountDocumentId:" + financialAccountDocumentId); @@ -60,9 +62,9 @@ namespace Swarmops.Database } - public BasicPayment[] GetFinancialAccountDocuments(params object[] conditions) + public BasicFinancialAccountDocument[] GetFinancialAccountDocuments(params object[] conditions) { - List result = new List(); + List result = new List(); using (DbConnection connection = GetMySqlDbConnection()) { @@ -76,7 +78,7 @@ namespace Swarmops.Database { while (reader.Read()) { - result.Add(ReadPaymentFromDataReader(reader)); + result.Add(ReadFinancialAccountDocumentFromDataReader(reader)); } return result.ToArray(); diff --git a/Logic/Financial/FinancialAccountDocument.cs b/Logic/Financial/FinancialAccountDocument.cs index 4e1e9bf4..5958a116 100644 --- a/Logic/Financial/FinancialAccountDocument.cs +++ b/Logic/Financial/FinancialAccountDocument.cs @@ -4,6 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Swarmops.Basic.Types.Financial; +using Swarmops.Common.Enums; +using Swarmops.Database; +using Swarmops.Logic.Swarm; namespace Swarmops.Logic.Financial { @@ -14,5 +17,38 @@ namespace Swarmops.Logic.Financial public FinancialAccountDocument() { } + + private FinancialAccountDocument(BasicFinancialAccountDocument basic) : base(basic) + { + // private ctor + } + + public static FinancialAccountDocument FromBasic(BasicFinancialAccountDocument basic) + { + return new FinancialAccountDocument(basic); + } + + public static FinancialAccountDocument FromIdentity(int financialAccountDocumentId) + { + return FromBasic(SwarmDb.GetDatabaseForReading().GetFinancialAccountDocument(financialAccountDocumentId)); + } + + internal static FinancialAccountDocument FromIdentityAggressive(int financialAccountDocumentId) + { + return FromBasic(SwarmDb.GetDatabaseForWriting().GetFinancialAccountDocument(financialAccountDocumentId)); + } + + public static FinancialAccountDocument Create(FinancialAccount account, FinancialAccountDocumentType documentType, Person uploader, DateTime concernsStart, DateTime concernsEnd, string rawText) + { + return FromIdentityAggressive( + SwarmDb.GetDatabaseForWriting().CreateFinancialAccountDocument( + account.Identity, + documentType, + uploader == null? 0: uploader.Identity, + concernsStart, + concernsEnd, + rawText + )); + } } } diff --git a/Site/Site.csproj b/Site/Site.csproj index 5c92cee9..2522207c 100644 --- a/Site/Site.csproj +++ b/Site/Site.csproj @@ -5310,6 +5310,9 @@ Pages.Swarm.yo-NG.designer.cs + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) From e2720b667c9afec32d1aa37384794144fd278af7 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 31 Dec 2018 12:42:01 +0100 Subject: [PATCH 27/46] UX test --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 13 ++++++++++++- Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 66079c1c..863e9284 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -276,7 +276,16 @@ return; } - // TODO: AJAX CALL TO STORE UPLOAD + var itemType = activeUpload.substring(0, activeUpload.indexOf('-')); + console.log(itemType); + console.log("Upload" + itemType); + + /* + SwarmopsJS.ajaxCall( + "EndOfMonth.aspx/Upload" + , + {guid: uploadGuid, itemId: activeUpload}, + ) + // TODO: AJAX CALL TO STORE UPLOAD*/ markItemCompleted(activeUpload); @@ -307,6 +316,8 @@ var localized_skipPromptBankStatement = SwarmopsJS.unescape('<%=this.Localized_SkipPrompt_BankStatement%>'); var localized_skipPromptGeneric = SwarmopsJS.unescape('<%=this.Localized_SkipPrompt_Generic%>'); + var uploadGuid = '<%=this.UploadControl.GuidString%>'; + // Function: Match all mismatched transactions // Function: Upload bank statement PDF for accountId x diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index d205230d..d7d8fbb6 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -266,7 +266,7 @@ namespace Swarmops.Frontend.Pages.Ledgers [WebMethod] - public static AjaxCallResult UploadBankStatement(string itemId) + public static AjaxCallResult UploadBankStatement(string guid, string itemId) { AuthenticationData authData = GetAuthenticationDataAndCulture(); if (!authData.Authority.HasAccess(new Access(authData.CurrentOrganization, AccessAspect.BookkeepingDetails))) @@ -283,7 +283,7 @@ namespace Swarmops.Frontend.Pages.Ledgers throw new UnauthorizedAccessException(); } - + Documents documents = Documents.RecentFromDescription(guid); return new AjaxCallResult {Success = true}; } From 8e1bbb9f48c375771718a6f8df185c7cf26684cc Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 31 Dec 2018 14:28:13 +0100 Subject: [PATCH 28/46] 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 From 3525489ca1d8539a5b5d44de831cb276da27a58f Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 31 Dec 2018 15:46:02 +0100 Subject: [PATCH 29/46] EOM work 2 --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 87af5aaa..21a29cef 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -286,30 +286,30 @@ function(result) { if (result.Success) { + markItemCompleted(activeUpload); + + // If there are items that depend on this one, + // disable their "skip" option now (because there's + // a first document in the series) + + var itemIterator = $('.action-list-item[data-dependson="' + activeUpload + '"]'); + + while (itemIterator.length > 0) { + // We're only supporting a 1:1 chain at this time, no 1:n dependencies + + var itemId = $(itemIterator).attr('data-item'); + $('span.action-list-item[data-item="' + itemId + '"] span.action-skip').addClass('action-skip-disabled'); + itemIterator = $('.action-list-item[data-dependson="' + itemId + '"]'); + } + + activeUpload = null; + } else { // Todo: add more error handling later, maybe clientFailedUpload(); } }); - - - markItemCompleted(activeUpload); - - // If there are items that depend on this one, - // disable their "skip" option now (because there's - // a first document in the series) - - var itemIterator = $('.action-list-item[data-dependson="' + activeUpload + '"]'); - - while (itemIterator.length > 0) { - // We're only supporting a 1:1 chain at this time, no 1:n dependencies - - var itemId = $(itemIterator).attr('data-item'); - $('span.action-list-item[data-item="' + itemId + '"] span.action-skip').addClass('action-skip-disabled'); - itemIterator = $('.action-list-item[data-dependson="' + itemId + '"]'); - } - - activeUpload = null; + } var uploadGuid = '<%=this.UploadControl.GuidString%>'; From 167938d2a77756048538fce9af668bebdca62365 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 31 Dec 2018 16:06:26 +0100 Subject: [PATCH 30/46] EOM work 3 --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 21a29cef..889f7288 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -281,7 +281,7 @@ // Note that the function to call is selected dynamically! SwarmopsJS.ajaxCall( - "EndOfMonth.aspx/Upload" + itemType, + "/Pages/v5/Ledgers/EndOfMonth.aspx/Upload" + itemType, { guid: uploadGuid, itemId: activeUpload }, function(result) { if (result.Success) { @@ -308,6 +308,9 @@ // Todo: add more error handling later, maybe clientFailedUpload(); } + }, + function(error) { + clientFailedUpload(); }); } From 177a9d5125f045ce8d1f9c298efc6d11d8318802 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 31 Dec 2018 21:07:18 +0100 Subject: [PATCH 31/46] EOM work 4 --- Logic/Financial/FinancialAccount.cs | 9 ++++++- Logic/Financial/FinancialAccountDocuments.cs | 28 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Logic/Financial/FinancialAccount.cs b/Logic/Financial/FinancialAccount.cs index 04db0532..b4e445da 100644 --- a/Logic/Financial/FinancialAccount.cs +++ b/Logic/Financial/FinancialAccount.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Runtime.CompilerServices; using Swarmops.Basic.Types.Financial; using Swarmops.Common; @@ -171,7 +172,13 @@ namespace Swarmops.Logic.Financial public FinancialAccountDocument GetMostRecentDocument(FinancialAccountDocumentType documentType) { - // TODO: Continue here + FinancialAccountDocuments documents = FinancialAccountDocuments.ForAccount(this, documentType); + + if (documents.Count() > 0) + { + return documents.Last(); + } + return null; } diff --git a/Logic/Financial/FinancialAccountDocuments.cs b/Logic/Financial/FinancialAccountDocuments.cs index a4d2bfeb..f0b8577d 100644 --- a/Logic/Financial/FinancialAccountDocuments.cs +++ b/Logic/Financial/FinancialAccountDocuments.cs @@ -4,11 +4,39 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Swarmops.Basic.Types.Financial; +using Swarmops.Common.Enums; +using Swarmops.Database; using Swarmops.Logic.Support; namespace Swarmops.Logic.Financial { public class FinancialAccountDocuments: PluralBase { + public static FinancialAccountDocuments ForAccount(FinancialAccount account, FinancialAccountDocumentType typeRequested = FinancialAccountDocumentType.Unknown) + { + FinancialAccountDocuments result = FromArray(SwarmDb.GetDatabaseForReading().GetFinancialAccountDocuments(account)); + result.Sort(new FinancialAccountDocumentsSorterByTypeThenDate()); + + if (typeRequested != FinancialAccountDocumentType.Unknown) + { + return (FinancialAccountDocuments) result.Where(doc => doc.Type == typeRequested); + } + + return result; + } + + } + + internal class FinancialAccountDocumentsSorterByTypeThenDate : IComparer + { + public int Compare(FinancialAccountDocument a, FinancialAccountDocument b) + { + if (a.Type != b.Type) + { + return a.Type.CompareTo(b.Type); + } + + return (a.ConcernsPeriodStart.CompareTo(b.ConcernsPeriodStart)); + } } } From 97799074ae2fd6d3402001d01880a59ce65bd3e1 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 31 Dec 2018 22:09:54 +0100 Subject: [PATCH 32/46] De-LINQed something that had a cast error --- Logic/Financial/FinancialAccountDocuments.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Logic/Financial/FinancialAccountDocuments.cs b/Logic/Financial/FinancialAccountDocuments.cs index f0b8577d..2665d78b 100644 --- a/Logic/Financial/FinancialAccountDocuments.cs +++ b/Logic/Financial/FinancialAccountDocuments.cs @@ -19,7 +19,17 @@ namespace Swarmops.Logic.Financial if (typeRequested != FinancialAccountDocumentType.Unknown) { - return (FinancialAccountDocuments) result.Where(doc => doc.Type == typeRequested); + FinancialAccountDocuments subset = new FinancialAccountDocuments(); + + foreach (FinancialAccountDocument document in result) + { + if (document.Type == typeRequested) + { + subset.Add(document); + } + } + + return subset; } return result; From 4d710d5a8a54e8de922caab12e9e1941ac3265d2 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Mon, 31 Dec 2018 22:24:30 +0100 Subject: [PATCH 33/46] EOM work 6 --- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 889f7288..4e3484bf 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -223,6 +223,14 @@ $('img.status-icon-pleasewait[data-item="' + itemId + '"]').hide(); $('img.status-icon-completed[data-item="' + itemId + '"]').fadeIn(); + // If any items depended on this one, enable them now + + var dependentItemId = $('span.action-list-item[data-dependson="' + itemId + '"]').attr("data-item"); + $('span.action-list-item[data-item="' + dependentItemId + '"]').removeClass('action-list-item-disabled'); + $('img.action-icon[data-item="' + dependentItemId + '"]').removeClass('action-icon-disabled'); + + // Check if group is complete + var selector = ".action-list-item:not(.action-list-item-completed):not(.action-list-item-disabled)[data-group='" + groupId + "']"; if ($(selector).length == 0) // no further actions in this group enabled { @@ -230,12 +238,6 @@ $(".group-status-icon[data-group='" + groupId + "']").fadeIn(); } - // If any items depended on this one, enable them now - - var dependentItemId = $('span.action-list-item[data-dependson="' + itemId + '"]').attr("data-item"); - $('span.action-list-item[data-item="' + dependentItemId + '"]').removeClass('action-list-item-disabled'); - $('img.action-icon[data-item="' + dependentItemId + '"]').removeClass('action-icon-disabled'); - } function clientStartedUpload() { From c9453205503387815e5a0ee2c523848a52e33576 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 1 Jan 2019 11:27:35 +0100 Subject: [PATCH 34/46] Nullref bugfix --- Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index 7b2294f6..c519f061 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -191,7 +191,7 @@ namespace Swarmops.Frontend.Pages.Ledgers string iconDisabledClass = string.Empty; string iconIsUploadClass = string.Empty; - if (item.DependsOn.Length > 0) + if (!string.IsNullOrEmpty(item.DependsOn)) { // add as disabled itemDisabledClass = " action-list-item-disabled"; From a85bbcf37be9c98f0b6a59bd7c70147348b5ac69 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 1 Jan 2019 11:27:51 +0100 Subject: [PATCH 35/46] Added reference for debuggability; test if it breaks staging build --- Site/Site.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Site/Site.csproj b/Site/Site.csproj index b34a47e9..4cb30e16 100644 --- a/Site/Site.csproj +++ b/Site/Site.csproj @@ -75,6 +75,9 @@ + + ..\..\..\..\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Runtime.dll + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll True From 9b49dbc50fc50fdd1f0bc113ae0372395a5abed3 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 1 Jan 2019 19:24:26 +0100 Subject: [PATCH 36/46] EOM work --- .../Pages.Ledgers.designer.cs | 9 +++++++++ Site/App_GlobalResources/Pages.Ledgers.resx | 4 ++++ Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 17 +++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/Site/App_GlobalResources/Pages.Ledgers.designer.cs b/Site/App_GlobalResources/Pages.Ledgers.designer.cs index fb205a8a..ee5ec096 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.designer.cs +++ b/Site/App_GlobalResources/Pages.Ledgers.designer.cs @@ -1149,6 +1149,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to Payroll: No payroll defined. + /// + internal static string EndOfMonth_PayrollInactive { + get { + return ResourceManager.GetString("EndOfMonth_PayrollInactive", resourceCulture); + } + } + /// /// Looks up a localized string similar to <strong>SKIP BANK STATEMENT?</strong><br/><br/>Bank statements are typically needed for audit verification of the internal records. The only valid reason to skip a month's statement is that the account wasn't opened yet, in which case you skip the months before the account was opened and no statements therefore exist.<br/><br/>You won't be asked again to upload this particular statement if you skip it now.. /// diff --git a/Site/App_GlobalResources/Pages.Ledgers.resx b/Site/App_GlobalResources/Pages.Ledgers.resx index 87726112..5cd2016c 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.resx +++ b/Site/App_GlobalResources/Pages.Ledgers.resx @@ -1031,4 +1031,8 @@ <strong>SKIP DOCUMENT UPLOAD?</strong><br/><br/>This document is typically needed for operation records. The only valid reason to skip a document is that it doesn't exist because the operations weren't running yet, like when an operation started in June of a year won't have documents for January of that year.<br/><br/>You won't be asked again to upload this document if you skip it now. + + Payroll: No payroll defined + This is shown as a disabled action item when there's no active payroll + \ No newline at end of file diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index c519f061..c31c4c31 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -123,6 +123,23 @@ namespace Swarmops.Frontend.Pages.Ledgers group2.Items.Add(vatReport); } + Payroll payroll = Payroll.ForOrganization(this.CurrentOrganization); + if (payroll.Any()) + { + // There is active payroll + + + } + else + { + EomItem payrollInactive = new EomItem(); + payrollInactive.Id = "PayrollInactive"; + payrollInactive.Completed = true; + payrollInactive.Name = Resources.Pages.Ledgers.EndOfMonth_PayrollInactive; + payrollInactive.Icon = "document"; + group2.Items.Add(payrollInactive); + } + if (group2.Items.Count > 0) { From efe28a5bcd518c19f494155f4df93076a3db3721 Mon Sep 17 00:00:00 2001 From: Falkvinge Date: Thu, 3 Jan 2019 20:49:51 +0100 Subject: [PATCH 37/46] Work on EOM --- .../Pages.Ledgers.designer.cs | 4 ++-- Site/App_GlobalResources/Pages.Ledgers.resx | 4 ++-- Site/Pages/v5/Ledgers/EndOfMonth.aspx | 1 + Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 20 +++++++++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Site/App_GlobalResources/Pages.Ledgers.designer.cs b/Site/App_GlobalResources/Pages.Ledgers.designer.cs index ee5ec096..4dcfd9c0 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.designer.cs +++ b/Site/App_GlobalResources/Pages.Ledgers.designer.cs @@ -1186,7 +1186,7 @@ namespace Resources.Pages { } /// - /// Looks up a localized string similar to Upload Bank Statement ({1}) for {0} for {2}. + /// Looks up a localized string similar to Upload Bank <strong>Statement</strong> ({1}) for {0} for {2}. /// internal static string EndOfMonth_UploadBankStatementFor { get { @@ -1195,7 +1195,7 @@ namespace Resources.Pages { } /// - /// Looks up a localized string similar to Upload Transaction Data ({1}) for {0}. + /// Looks up a localized string similar to Upload <strong>Transaction Data</strong> ({1}) for {0}. /// internal static string EndOfMonth_UploadTransactionDataFor { get { diff --git a/Site/App_GlobalResources/Pages.Ledgers.resx b/Site/App_GlobalResources/Pages.Ledgers.resx index 5cd2016c..4a752d98 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.resx +++ b/Site/App_GlobalResources/Pages.Ledgers.resx @@ -1018,11 +1018,11 @@ Parameter zero is the month that's just ended - Upload Bank Statement ({1}) for {0} for {2} + Upload Bank <strong>Statement</strong> ({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} + Upload <strong>Transaction Data</strong> ({1}) for {0} Parameter zero is the account name, parameter one is the format (e.g. XML or CSV) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx b/Site/Pages/v5/Ledgers/EndOfMonth.aspx index 4e3484bf..e5223e3c 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx @@ -14,6 +14,7 @@ // set action icons to their respective initial icons + $('img.eomitem-wrench').attr('src', '/Images/Icons/iconshock-balloon-wrench-128x96px.png'); $('img.eomitem-document').attr('src', '/Images/Icons/iconshock-balloon-invoice-128x96px.png'); $('img.eomitem-upload').attr('src', '/Images/Icons/iconshock-upload-128x96px.png'); diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index c31c4c31..ad5e9938 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -39,6 +39,8 @@ namespace Swarmops.Frontend.Pages.Ledgers group1.Header = Resources.Pages.Ledgers.EndOfMonth_Header_ExternalData; group1.Id = "ExternalData"; + string lastUploadItemId = string.Empty; + // Iterate over all Balance accounts and check for automation; // if so, add it to an upload sequence @@ -94,9 +96,27 @@ namespace Swarmops.Frontend.Pages.Ledgers group1.Items.Add(bankStatement); } + // Add data upload item + } } + // If there are any items in Group 1, OR if an account matching is necessary, then + // add that as an action item + + if (group1.Items.Count() > 0 || FinancialTransactions.GetUnbalanced(this.CurrentOrganization).Count() > 0) + { + EomItem matchAccounts = new EomItem(); + matchAccounts.DependsOn = lastUploadItemId; // may be empty if there's nothing to upload and that's ok + matchAccounts.Id = "MatchAccounts"; + matchAccounts.Completed = false; // we already know there's at least one unbalanced + matchAccounts.Icon = "wrench"; + matchAccounts.Skippable = false; + matchAccounts.Name = Resources.Pages.Ledgers.EndOfMonth_MatchAccounts; + + group1.Items.Add(matchAccounts); + } + if (group1.Items.Count > 0) { ItemGroups.Add(group1); From 6daafe34b0ba450aab71e5a0bb96cb4e24b99b4d Mon Sep 17 00:00:00 2001 From: Falkvinge Date: Thu, 3 Jan 2019 21:26:42 +0100 Subject: [PATCH 38/46] Work on EOM 2 --- Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index ad5e9938..f81f15bc 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -98,6 +98,9 @@ namespace Swarmops.Frontend.Pages.Ledgers // Add data upload item + EomItem dataUploadItem = new EomItem(); + dataUploadItem.Id = "BankDataUpload-" + assetAccount.Identity.ToString(CultureInfo.InvariantCulture); + } } From a124dd67e41439f60e330ac83f3ce87b0205c6fa Mon Sep 17 00:00:00 2001 From: Falkvinge Date: Fri, 4 Jan 2019 14:15:45 +0100 Subject: [PATCH 39/46] Small language tweaks --- Site/App_GlobalResources/Pages.Ledgers.designer.cs | 6 +++--- Site/App_GlobalResources/Pages.Ledgers.resx | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Site/App_GlobalResources/Pages.Ledgers.designer.cs b/Site/App_GlobalResources/Pages.Ledgers.designer.cs index 4dcfd9c0..4697eab6 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.designer.cs +++ b/Site/App_GlobalResources/Pages.Ledgers.designer.cs @@ -115,7 +115,7 @@ namespace Resources.Pages { } /// - /// Looks up a localized string similar to Are transactions here excluded from 2-D reports?. + /// Looks up a localized string similar to Is this an account after the EBITDA line?. /// internal static string AccountPlan_Edit_AdministrativeLong { get { @@ -1186,7 +1186,7 @@ namespace Resources.Pages { } /// - /// Looks up a localized string similar to Upload Bank <strong>Statement</strong> ({1}) for {0} for {2}. + /// Looks up a localized string similar to Upload Bank Statement ({1}) for {0} for {2}. /// internal static string EndOfMonth_UploadBankStatementFor { get { @@ -1195,7 +1195,7 @@ namespace Resources.Pages { } /// - /// Looks up a localized string similar to Upload <strong>Transaction Data</strong> ({1}) for {0}. + /// Looks up a localized string similar to Upload Transaction Data ({1}) for {0}. /// internal static string EndOfMonth_UploadTransactionDataFor { get { diff --git a/Site/App_GlobalResources/Pages.Ledgers.resx b/Site/App_GlobalResources/Pages.Ledgers.resx index 4a752d98..0846e416 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.resx +++ b/Site/App_GlobalResources/Pages.Ledgers.resx @@ -402,7 +402,8 @@ Active - Are transactions here excluded from 2-D reports? + Is this an account after the EBITDA line? + Earnings before interest, tax, depreciation and amortization (EBITDA) is a measure of a company's operating performance. Admin @@ -1018,11 +1019,11 @@ Parameter zero is the month that's just ended - Upload Bank <strong>Statement</strong> ({1}) for {0} for {2} + 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 <strong>Transaction Data</strong> ({1}) for {0} + Upload Transaction Data ({1}) for {0} Parameter zero is the account name, parameter one is the format (e.g. XML or CSV) From f91bed1854e6a40b586b15a210a8c39535d9b71d Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Fri, 4 Jan 2019 14:20:14 +0100 Subject: [PATCH 40/46] EOM work --- Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index c31c4c31..667e4f32 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -128,7 +128,7 @@ namespace Swarmops.Frontend.Pages.Ledgers { // There is active payroll - + // TODO: Taxes for last month and processing for this month } else { From 1bfe022954049ace918fac9fb8b677555d2a90ab Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 8 Jan 2019 12:19:22 +0100 Subject: [PATCH 41/46] Update release date in Readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b2c610ae..23ecb0e8 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ wget -qO- https://packages.swarmops.com/swarmops-packages.gpg.key | apt-key add apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF ``` -Then, add the Swarmops repository to your list of software sources, where [your_distro] is `debian` or `ubuntu`, and [your_distro_version] below is `xenial` or `bionic` (Ubuntu) or `stretch` (Debian): +Then, add the Swarmops and Mono repositories to your list of software sources, where [your_distro] is `debian` or `ubuntu`, and [your_distro_version] below is `xenial` or `bionic` (Ubuntu) or `stretch` (Debian): ``` echo "deb https://packages.swarmops.com/ [your_distro_version] contrib" > /etc/apt/sources.list.d/swarmops.list @@ -100,7 +100,7 @@ That also means that any code _you_ commit to Swarmops, whether by checking in c Beta-6 features progress ------------------------ -Beta-6 will be released on January or February 5, 2019, with string freeze three days earlier. Its focus is to increase multicurrency functionality for payouts and bank imports. +Beta-6 will be released on February 5, 2019, with string freeze three days earlier. Its focus is to increase multicurrency functionality for payouts and bank imports. - [x] Parameterize the bank file import procedure (big feature!) - [x] Make it possible to import bank files in non-presentation currency From 08dbd2e892f1bc7c5a62d82c56c3e0b00557ed7e Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 8 Jan 2019 12:19:42 +0100 Subject: [PATCH 42/46] Resource strings --- Site/App_GlobalResources/Global.designer.cs | 18 ++++ Site/App_GlobalResources/Global.resx | 7 ++ Site/App_GlobalResources/Menu5.designer.cs | 94 ++++++++++++++++++- Site/App_GlobalResources/Menu5.resx | 42 ++++++++- .../Pages.Ledgers.designer.cs | 2 +- Site/App_GlobalResources/Pages.Ledgers.resx | 2 +- 6 files changed, 159 insertions(+), 6 deletions(-) diff --git a/Site/App_GlobalResources/Global.designer.cs b/Site/App_GlobalResources/Global.designer.cs index 52bf4e72..06290e0e 100644 --- a/Site/App_GlobalResources/Global.designer.cs +++ b/Site/App_GlobalResources/Global.designer.cs @@ -411,6 +411,24 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Earnings before Interest, Taxes, Depreciation, and Amortization. + /// + internal static string Financial_Ebitda_Long { + get { + return ResourceManager.GetString("Financial_Ebitda_Long", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to EBITDA. + /// + internal static string Financial_Ebitda_Short { + get { + return ResourceManager.GetString("Financial_Ebitda_Short", resourceCulture); + } + } + /// /// Looks up a localized string similar to Expense. /// diff --git a/Site/App_GlobalResources/Global.resx b/Site/App_GlobalResources/Global.resx index bb9c0fa0..0f9d826c 100644 --- a/Site/App_GlobalResources/Global.resx +++ b/Site/App_GlobalResources/Global.resx @@ -1004,4 +1004,11 @@ Skip The "yes" option on the "Skip? Yes/no" dialog + + Earnings before Interest, Taxes, Depreciation, and Amortization + + + EBITDA + Earnings before Interest, Taxes, Depreciation, and Amortization - a financial term + \ No newline at end of file diff --git a/Site/App_GlobalResources/Menu5.designer.cs b/Site/App_GlobalResources/Menu5.designer.cs index 38bfdb64..9c04998b 100644 --- a/Site/App_GlobalResources/Menu5.designer.cs +++ b/Site/App_GlobalResources/Menu5.designer.cs @@ -159,6 +159,33 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Set up Connected Accounts. + /// + internal static string Menu5_Admin_SetupConnectedAccounts { + get { + return ResourceManager.GetString("Menu5_Admin_SetupConnectedAccounts", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Set up Ledger Account Structure. + /// + internal static string Menu5_Admin_SetupLedgerAccountStructure { + get { + return ResourceManager.GetString("Menu5_Admin_SetupLedgerAccountStructure", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Set up Payroll. + /// + internal static string Menu5_Admin_SetupPayroll { + get { + return ResourceManager.GetString("Menu5_Admin_SetupPayroll", resourceCulture); + } + } + /// /// Looks up a localized string similar to Built on {0:MMM d, yyyy}. /// @@ -465,6 +492,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to My Salary. + /// + internal static string Menu5_Financial_Salary { + get { + return ResourceManager.GetString("Menu5_Financial_Salary", resourceCulture); + } + } + /// /// Looks up a localized string similar to Send New Invoice. /// @@ -672,6 +708,24 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Deprecating & Amortized Assets. + /// + internal static string Menu5_Ledgers_DeprecatingAmortizedAssets { + get { + return ResourceManager.GetString("Menu5_Ledgers_DeprecatingAmortizedAssets", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Depreciations and Amortizations. + /// + internal static string Menu5_Ledgers_DepreciationsAmortizations { + get { + return ResourceManager.GetString("Menu5_Ledgers_DepreciationsAmortizations", resourceCulture); + } + } + /// /// Looks up a localized string similar to Import Bank Data. /// @@ -708,6 +762,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Make Payroll Adjustments. + /// + internal static string Menu5_Ledgers_PayrollAdjustments { + get { + return ResourceManager.GetString("Menu5_Ledgers_PayrollAdjustments", resourceCulture); + } + } + /// /// Looks up a localized string similar to Profit & Loss Statement. /// @@ -718,7 +781,7 @@ namespace Resources { } /// - /// Looks up a localized string similar to Resync Bank Account. + /// Looks up a localized string similar to Resync Connected Account. /// internal static string Menu5_Ledgers_ResyncExternalAccount { get { @@ -727,7 +790,7 @@ namespace Resources { } /// - /// Looks up a localized string similar to Set Budget Amounts. + /// Looks up a localized string similar to Set up Budgets. /// internal static string Menu5_Ledgers_SetBudgets { get { @@ -753,6 +816,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Tracked Transactions. + /// + internal static string Menu5_Ledgers_TrackedTransactions { + get { + return ResourceManager.GetString("Menu5_Ledgers_TrackedTransactions", resourceCulture); + } + } + /// /// Looks up a localized string similar to Upload Bank Files. /// @@ -942,6 +1014,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Distributed Assets. + /// + internal static string Menu5_People_DistributedAssets { + get { + return ResourceManager.GetString("Menu5_People_DistributedAssets", resourceCulture); + } + } + /// /// Looks up a localized string similar to List/Find People. /// @@ -1032,6 +1113,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Reports. + /// + internal static string Menu5_Reports { + get { + return ResourceManager.GetString("Menu5_Reports", resourceCulture); + } + } + /// /// Looks up a localized string similar to This is a temporary menu. Yes it's ugly now.. /// diff --git a/Site/App_GlobalResources/Menu5.resx b/Site/App_GlobalResources/Menu5.resx index 3914f133..99fc8b1f 100644 --- a/Site/App_GlobalResources/Menu5.resx +++ b/Site/App_GlobalResources/Menu5.resx @@ -304,10 +304,11 @@ Profit & Loss Statement - Resync Bank Account + Resync Connected Account - Set Budget Amounts + Set up Budgets + "Budget" as in "Cost allowed for a particular purpose" or "Revenue expected from a source". Upload Bank Files @@ -446,4 +447,41 @@ Bitcoin Hotwallet Echo Test + + Set up Connected Accounts + The connected accounts are those where transactions are read from an external source, like a bank account, a blockchain address, etc. + + + Set up Ledger Account Structure + This is sometimes called an "account plan" but this term has many overloaded meanings in the context of operations software. + + + Set up Payroll + + + My Salary + This lists salary payments for the logged on individual + + + Deprecating & Amortized Assets + + + Depreciations and Amortizations + + + Make Payroll Adjustments + As in bonuses, sick leave, lunch extras, whatever. Before or after tax. + + + Tracked Transactions + Tracking of special transactions + + + Distributed Assets + Distributed as in "out among activists"; this tracks who has what equipment + + + Reports + This is financial analysis reports. "Analysis" would also work as translation. + \ 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 4697eab6..4dfda495 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.designer.cs +++ b/Site/App_GlobalResources/Pages.Ledgers.designer.cs @@ -1141,7 +1141,7 @@ namespace Resources.Pages { } /// - /// Looks up a localized string similar to Resolve all unmatched accounts. + /// Looks up a localized string similar to Resolve all unmatched ledger transactions. /// internal static string EndOfMonth_MatchAccounts { get { diff --git a/Site/App_GlobalResources/Pages.Ledgers.resx b/Site/App_GlobalResources/Pages.Ledgers.resx index 0846e416..151b6b5b 100644 --- a/Site/App_GlobalResources/Pages.Ledgers.resx +++ b/Site/App_GlobalResources/Pages.Ledgers.resx @@ -1011,7 +1011,7 @@ This is a checklist of things to do to close the previous month and begin the new one with respect to accounting. - Resolve all unmatched accounts + Resolve all unmatched ledger transactions This means to match bank transactions with incoming/outgoing expected payments (invoices, expense reports, etc) where it couldn't be done automatically From b09df24e45d4b348886aa1bee7efc605c4c2fe17 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 8 Jan 2019 12:22:25 +0100 Subject: [PATCH 43/46] Update release date for beta-7 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 23ecb0e8..99bd7db0 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ Beta-6 will be released on February 5, 2019, with string freeze three days earli Beta-7 features progress ------------------------ -Beta-7 will be released on March 5, 2019, with string freeze on March 2. Its tentative focus will be Fairshift integration and possibly an open API exposure. +Beta-7 will be released on April 5, 2019, with string freeze on April 2. Its tentative focus will be Fairshift integration and possibly an open API exposure. - [ ] Rewrite Bitcoin Cold Storage detection to handle forks, current and future - [ ] Add blockchain-upgrade code that properly splits Core, Cash txs, hashes, accounts From e8fbe6ad1e6b5faf5d6a3f98c62ac9d426f98966 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 8 Jan 2019 15:29:21 +0100 Subject: [PATCH 44/46] EOM UX work --- Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index 509a5644..718ebb8b 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -98,9 +98,17 @@ namespace Swarmops.Frontend.Pages.Ledgers // Add data upload item + // TODO: Check if the last data upload was into the current month + EomItem dataUploadItem = new EomItem(); dataUploadItem.Id = "BankDataUpload-" + assetAccount.Identity.ToString(CultureInfo.InvariantCulture); + dataUploadItem.Icon = "upload"; + dataUploadItem.Completed = false; // todo + dataUploadItem.Name = String.Format(Resources.Pages.Ledgers.EndOfMonth_FetchTransactionDataFor, + "CSV", assetAccount.Name); + dataUploadItem.Skippable = false; + group1.Items.Add(dataUploadItem); } } From e291b02a612b93bc6f373d91f84b93a168c52bb9 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 8 Jan 2019 15:37:06 +0100 Subject: [PATCH 45/46] EOM UX work 2 --- Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index 718ebb8b..49a295ca 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -104,7 +104,7 @@ namespace Swarmops.Frontend.Pages.Ledgers dataUploadItem.Id = "BankDataUpload-" + assetAccount.Identity.ToString(CultureInfo.InvariantCulture); dataUploadItem.Icon = "upload"; dataUploadItem.Completed = false; // todo - dataUploadItem.Name = String.Format(Resources.Pages.Ledgers.EndOfMonth_FetchTransactionDataFor, + dataUploadItem.Name = String.Format(Resources.Pages.Ledgers.EndOfMonth_UploadTransactionDataFor, "CSV", assetAccount.Name); dataUploadItem.Skippable = false; From ec6cdb09080f7659fb17b283fdb23fc389fd2c7a Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 8 Jan 2019 15:42:04 +0100 Subject: [PATCH 46/46] EOM UX work 3 --- Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs index 49a295ca..bee9b39f 100644 --- a/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs +++ b/Site/Pages/v5/Ledgers/EndOfMonth.aspx.cs @@ -105,7 +105,7 @@ namespace Swarmops.Frontend.Pages.Ledgers dataUploadItem.Icon = "upload"; dataUploadItem.Completed = false; // todo dataUploadItem.Name = String.Format(Resources.Pages.Ledgers.EndOfMonth_UploadTransactionDataFor, - "CSV", assetAccount.Name); + assetAccount.Name, "CSV"); dataUploadItem.Skippable = false; group1.Items.Add(dataUploadItem);