From 0b83bfa2d9319138e8bda5ad3764141208fab2c2 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sun, 4 Mar 2018 14:28:31 +0100 Subject: [PATCH] Expensify ready up until submit button --- Site/App_GlobalResources/Global.designer.cs | 9 ++ Site/App_GlobalResources/Global.resx | 4 + .../Pages.Financial.designer.cs | 36 +++++++ Site/App_GlobalResources/Pages.Financial.resx | 15 +++ Site/Bases/PageV5Base.cs | 6 ++ Site/Pages/v5/Financial/FileExpenseClaim.aspx | 95 +++++++++++++++---- .../v5/Financial/FileExpenseClaim.aspx.cs | 42 ++++++-- 7 files changed, 183 insertions(+), 24 deletions(-) diff --git a/Site/App_GlobalResources/Global.designer.cs b/Site/App_GlobalResources/Global.designer.cs index feb13ae2..4374242f 100644 --- a/Site/App_GlobalResources/Global.designer.cs +++ b/Site/App_GlobalResources/Global.designer.cs @@ -1518,6 +1518,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Submit. + /// + internal static string Global_Submit { + get { + return ResourceManager.GetString("Global_Submit", resourceCulture); + } + } + /// /// Looks up a localized string similar to System. /// diff --git a/Site/App_GlobalResources/Global.resx b/Site/App_GlobalResources/Global.resx index a9176518..8f1db949 100644 --- a/Site/App_GlobalResources/Global.resx +++ b/Site/App_GlobalResources/Global.resx @@ -978,4 +978,8 @@ MMM d, yyyy Convert the formatting only - this is machine interpreted. Example: "Dec 23, 1921". + + Submit + As in "Submit this data for processing" + \ No newline at end of file diff --git a/Site/App_GlobalResources/Pages.Financial.designer.cs b/Site/App_GlobalResources/Pages.Financial.designer.cs index 9449f822..e046579c 100644 --- a/Site/App_GlobalResources/Pages.Financial.designer.cs +++ b/Site/App_GlobalResources/Pages.Financial.designer.cs @@ -942,6 +942,24 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to All expense claims need a budget before submitting.. + /// + internal static string FileExpenseClaim_Expensify_NeedBudgetsForAll { + get { + return ResourceManager.GetString("FileExpenseClaim_Expensify_NeedBudgetsForAll", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No Expensify records to submit. + /// + internal static string FileExpenseClaim_Expensify_NoRecordsLeft { + get { + return ResourceManager.GetString("FileExpenseClaim_Expensify_NoRecordsLeft", resourceCulture); + } + } + /// /// Looks up a localized string similar to Expensify report's currency is. /// @@ -951,6 +969,24 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to Ready to submit one claim. + /// + internal static string FileExpenseClaim_Expensify_SubmitRecordSingle { + get { + return ResourceManager.GetString("FileExpenseClaim_Expensify_SubmitRecordSingle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Ready to submit {0} claims. + /// + internal static string FileExpenseClaim_Expensify_SubmitRecordsSeveral { + get { + return ResourceManager.GetString("FileExpenseClaim_Expensify_SubmitRecordsSeveral", resourceCulture); + } + } + /// /// Looks up a localized string similar to Upload Another Expensify CSV File?. /// diff --git a/Site/App_GlobalResources/Pages.Financial.resx b/Site/App_GlobalResources/Pages.Financial.resx index 36a516ac..c95b7beb 100644 --- a/Site/App_GlobalResources/Pages.Financial.resx +++ b/Site/App_GlobalResources/Pages.Financial.resx @@ -710,4 +710,19 @@ (The amount must exclude any VAT specified!) This refers to when a budget owner is asked to correct an amount to charge their budget, based on seeing an invoice or receipt for that charge, and is instructed that they should not enter the TOTAL as shown on the invoice or receipt, but the TOTAL EXCEPT VAT. + + All expense claims need a budget before submitting. + This is displayed after the user has uploaded an Expensify report with lots of expense claims, but hasn't yet set a budget for all of them + + + No Expensify records to submit + This appears after an empty file is uploaded, or the last record deleted + + + Ready to submit one claim + + + Ready to submit {0} claims + The {0} is replaced by a number, 2 or higher + \ No newline at end of file diff --git a/Site/Bases/PageV5Base.cs b/Site/Bases/PageV5Base.cs index 6cf8865c..83d1a71e 100644 --- a/Site/Bases/PageV5Base.cs +++ b/Site/Bases/PageV5Base.cs @@ -204,6 +204,12 @@ namespace Swarmops.Frontend get { return JavascriptEscape(Resources.Global.Global_Cancel); } } + + public string Localized_ConfirmDialog_Submit + { + get { return JavascriptEscape(Resources.Global.Global_Submit); } + } + public bool SuppressStatisticHeaders { get; set; } // defaults to false } diff --git a/Site/Pages/v5/Financial/FileExpenseClaim.aspx b/Site/Pages/v5/Financial/FileExpenseClaim.aspx index 842cbd80..fce054cf 100644 --- a/Site/Pages/v5/Financial/FileExpenseClaim.aspx +++ b/Site/Pages/v5/Financial/FileExpenseClaim.aspx @@ -62,6 +62,8 @@ displayExpensifyRecord(result); } + displaySubmitPrompt(result.SubmitPrompt); + } else { <%=this.DialogEditExpenseClaim.ClientID%>_open(); // re-open same dialog alertify.error("There was an error submitting the data. Please fix."); @@ -86,7 +88,21 @@ currentlyEditedRecordGuid = result.Guid; displayExpensifyRecord(result); } + else if (result.DataUpdate.length == 0) { + // There are no more records + // No data, so prepare for another upload + + $('#spanLabelExpensifySomethingMissing').text(SwarmopsJS.unescape('<%=this.Localized_Expensify_NoRecords%>')); + $('#divExpensifySomethingMissing').show(); + $('#divExpensifyReadySubmit').hide(); + $('#divExpensifyUploadAnotherHeader').show(); + $('#divExpensifyUploadFile').show(); + $('#divExpensifyInstructions').hide(); + $('#divUploadExpensify').slideDown(); + } else { + displaySubmitPrompt(result.SubmitPrompt); + } } }); }); @@ -229,6 +245,15 @@ }); } + function displaySubmitPrompt(prompt) { + if (prompt.length > 1) { + $('#buttonExpensifySubmit').val(SwarmopsJS.unescape('<%=this.Localized_ConfirmDialog_Submit%>')); + $('#spanLabelExpensifySubmit').text(prompt); + $('#divExpensifySomethingMissing').slideUp(); + $('#divExpensifyReadySubmit').slideDown(); + } + } + var expensifyProcessingHalfway = false; var currentlyEditedRecordGuid = ''; @@ -278,28 +303,50 @@ <%=this.ProgressExpensifyFake.ClientID%>_fadeOut(); }); - // Display processed data + // If there's no data at all, sort of abort and ask for a new file - $('#expensifyDataGrid').datagrid({ - - onBeginEdit: function(index,row){ - var ed = $(this).datagrid('getEditor',{index:index,field:'productid'}); - $(ed.target).combotree({ - url: '...', - value: row.productid - }); - }, - onEndEdit: function(index,row){ - var ed = $(this).datagrid('getEditor',{index:index,field:'productid'}); - row.productname = $(ed.target).combotree('getText'); - } - }); + if (result.Data.length == 0) + { + // No data, so prepare for another upload - // Fill in documents (hidden) + $('#spanLabelExpensifySomethingMissing').text(SwarmopsJS.unescape('<%=this.Localized_Expensify_NoRecords%>')); + $('#divExpensifySomethingMissing').show(); + $('#divExpensifyReadySubmit').hide(); + $('#divExpensifyUploadAnotherHeader').show(); + $('#divExpensifyUploadFile').show(); + $('#divExpensifyInstructions').hide(); + $('#divUploadExpensify').slideDown(); + } + else + { - $('#divDocumentsHidden').html(result.Documents); + // Else, display processed data - displayExpensifyDataGrid(result.Data, result.Footer); + $('#divExpensifySomethingMissing').hide(); + $('#divExpensifyReadySubmit').show(); + + $('#spanLabelExpensifySomethingMissing').text(SwarmopsJS.unescape('<%=this.Localized_Expensify_NeedBudgetsForAll%>')); + + $('#expensifyDataGrid').datagrid({ + onBeginEdit: function(index, row) { + var ed = $(this).datagrid('getEditor', { index: index, field: 'productid' }); + $(ed.target).combotree({ + url: '...', + value: row.productid + }); + }, + onEndEdit: function(index, row) { + var ed = $(this).datagrid('getEditor', { index: index, field: 'productid' }); + row.productname = $(ed.target).combotree('getText'); + } + }); + + // Fill in documents (hidden) + + $('#divDocumentsHidden').html(result.Documents); + + displayExpensifyDataGrid(result.Data, result.Footer); + } } else { @@ -399,6 +446,18 @@ +
+ Need budgets for all +
+ + diff --git a/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs b/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs index e431671e..0ac7b09a 100644 --- a/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs +++ b/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs @@ -513,8 +513,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial // TODO: Suggest initial budgets - // TODO: Once user has confirmed budgets, save expenses - List outputRecords = new List(); string docString = @@ -622,6 +620,26 @@ namespace Swarmops.Frontend.Pages.v5.Financial } + private static string FormatExpensifySubmitPrompt(List recordList) + { + foreach (ExpensifyRecord record in recordList) + { + if (record.BudgetId == 0) + { + return string.Empty; + } + } + + if (recordList.Count == 1) + { + return Resources.Pages.Financial.FileExpenseClaim_Expensify_SubmitRecordSingle; + } + + return String.Format(Resources.Pages.Financial.FileExpenseClaim_Expensify_SubmitRecordsSeveral, + recordList.Count); + } + + [WebMethod] public static AjaxCallExpensifyRecordResult ExpensifyRecordProceed(string masterGuid, string recordGuid, string amountString, string amountVatString, int budgetId, string description) @@ -676,7 +694,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial ExistNext = (index < recordList.Count - 1 ? true : false), Success = true, DataUpdate = FormatExpensifyOutputRecords(recordList), - FooterUpdate = FormatExpensifyFooter (recordList) + FooterUpdate = FormatExpensifyFooter (recordList), + SubmitPrompt = FormatExpensifySubmitPrompt(recordList) }; } @@ -715,7 +734,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial ExistNext = (index < recordList.Count - 1 ? true : false), Success = true, DataUpdate = FormatExpensifyOutputRecords(recordList), - FooterUpdate = FormatExpensifyFooter(recordList) + FooterUpdate = FormatExpensifyFooter(recordList), + SubmitPrompt = FormatExpensifySubmitPrompt (recordList) }; } @@ -943,6 +963,16 @@ namespace Swarmops.Frontend.Pages.v5.Financial { get { return JavascriptEscape(Resources.Pages.Financial.FileExpenseClaim_ValidationError_Documents); } } + + public string Localized_Expensify_NeedBudgetsForAll + { + get { return JavascriptEscape(Resources.Pages.Financial.FileExpenseClaim_Expensify_NeedBudgetsForAll); } + } + + public string Localized_Expensify_NoRecords + { + get { return JavascriptEscape(Resources.Pages.Financial.FileExpenseClaim_Expensify_NoRecordsLeft); } + } } @@ -967,6 +997,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial public ExpensifyOutputRecord[] Data { get; set; } public ExpensifyOutputRecord[] Footer { get; set; } public string Documents { get; set; } + public string SubmitPrompt { get; set; } } public class AjaxCallExpensifyRecordResult : AjaxCallResult @@ -981,7 +1012,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial public ExpensifyOutputRecord[] DataUpdate { get; set; } public ExpensifyOutputRecord[] FooterUpdate { get; set; } - public bool CanCommit { get; set; } + public string SubmitPrompt { get; set; } } - } \ No newline at end of file