diff --git a/Site/App_GlobalResources/Pages.Financial.designer.cs b/Site/App_GlobalResources/Pages.Financial.designer.cs index a0638bb1..b6ee255f 100644 --- a/Site/App_GlobalResources/Pages.Financial.designer.cs +++ b/Site/App_GlobalResources/Pages.Financial.designer.cs @@ -888,6 +888,15 @@ namespace Resources.Pages { } } + /// + /// Looks up a localized string similar to <p><strong>ERROR: The Expensify CSV file is missing required data fields.</strong> The file appears to be missing at least one of the required fields of Expensify's default CSV profile. Refer to the technical documentation and compare with the file you tried to upload. (It is a more probable cause of error, of course, that you tried to upload the completely wrong file &ndash; maybe a photograph instead of an Expensify CSV &ndash; and that this is the cause for the missing expected data.)</p><p>Unable to pro [rest of string was truncated]";. + /// + internal static string FileExpenseClaim_Expensify_Error_InvalidCsv { + get { + return ResourceManager.GetString("FileExpenseClaim_Expensify_Error_InvalidCsv", resourceCulture); + } + } + /// /// Looks up a localized string similar to <p><strong>ERROR: The Expensify CSV file doesn't have a VAT field.</strong> Since this organization reports Value Added Tax (VAT) to authorities, this must be specified on a per-expense basis. Please enable VAT in Expensify and create a new CSV export profile that exports this under the column header "VAT". If your team has already created such a CSV profile, you may just need to select it when exporting to CSV.</p><p>Unable to process this file.</p>. /// diff --git a/Site/App_GlobalResources/Pages.Financial.resx b/Site/App_GlobalResources/Pages.Financial.resx index cb75939f..f156987b 100644 --- a/Site/App_GlobalResources/Pages.Financial.resx +++ b/Site/App_GlobalResources/Pages.Financial.resx @@ -703,4 +703,7 @@ This is an expense claim from whom? + + <p><strong>ERROR: The Expensify CSV file is missing required data fields.</strong> The file appears to be missing at least one of the required fields of Expensify's default CSV profile. Refer to the technical documentation and compare with the file you tried to upload. (It is a more probable cause of error, of course, that you tried to upload the completely wrong file &ndash; maybe a photograph instead of an Expensify CSV &ndash; and that this is the cause for the missing expected data.)</p><p>Unable to process this file.</p> + \ No newline at end of file diff --git a/Site/Controls/v5/Base/ProgressBar.ascx b/Site/Controls/v5/Base/ProgressBar.ascx index 6524a1e9..4c804d0f 100644 --- a/Site/Controls/v5/Base/ProgressBar.ascx +++ b/Site/Controls/v5/Base/ProgressBar.ascx @@ -20,9 +20,11 @@ function <%=this.ClientID%>_reset() { $('#Div_<%=this.ClientID %>_ProgressBar').progressbar({ value: 0 }); + <%=this.ClientID%>_lastProgress = 0; } function <%=this.ClientID%>_begin() { + <%=this.ClientID%>_lastProgress = 0; $('#Div_<%=this.ClientID %>_ProgressBar').progressbar({ value: 0, max: 100 }); <%=this.ClientID%>_nextPollTimer = setTimeout(function() { <%= this.ClientID%>_progressFallbackPoll(); }, 2500); progressUpdateCallback_<%=this.GuidToken%>(1); // Initializes a small piece of bar diff --git a/Site/Pages/v5/Financial/FileExpenseClaim.aspx b/Site/Pages/v5/Financial/FileExpenseClaim.aspx index 567c1878..7e73f605 100644 --- a/Site/Pages/v5/Financial/FileExpenseClaim.aspx +++ b/Site/Pages/v5/Financial/FileExpenseClaim.aspx @@ -113,7 +113,7 @@ $('#divExpensifyUploadHeader').hide(); // this should be hidden at this time regardless of result SwarmopsJS.ajaxCall('/Pages/v5/Financial/FileExpenseClaim.aspx/GetExpensifyUploadResult', - { guid: '<%=this.UploadExpensify.GuidString%>'}, + { guid: '<%=this.UploadExpensify.GuidString%>' }, function(result) { if (result.Success) { @@ -122,17 +122,23 @@ $('#divExpensifyResultsBad').hide(); $('#divExpensifyResultsGood').show(); <%=this.ProgressExpensify.ClientID%>_hide(); + <%=this.ProgressExpensify.ClientID%>_reset(); <%=this.ProgressExpensifyFake.ClientID%>_show(); $('#divUploadExpensify').hide(); $('#divExpensifyUploadAnotherHeader').show(); $('#divExpensifyResults').slideDown(); + // Display processed data + + + } else { // Make a brutal transition to failure view <%=this.ProgressExpensify.ClientID%>_fadeOut(); <%=this.ProgressExpensify.ClientID%>_hide(); // both fadeOut + hide necessary + <%=this.ProgressExpensify.ClientID%>_reset(); <%=this.ProgressExpensifyFake.ClientID%>_hide(); $('#divExpensifyResultsBad').show(); @@ -148,7 +154,7 @@ // Regardless of whether result is good or bad, reset the upload control <%=this.UploadExpensify.ClientID%>_clear(); - }) + }); } diff --git a/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs b/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs index 19c706e8..ee268131 100644 --- a/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs +++ b/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs @@ -292,6 +292,40 @@ namespace Swarmops.Frontend.Pages.v5.Financial } } + ExpensifyColumns[] requiredData = + { + ExpensifyColumns.AmountFloat, + ExpensifyColumns.CategoryCustom, + ExpensifyColumns.CategoryStandard, + ExpensifyColumns.Comment, + ExpensifyColumns.Merchant, + ExpensifyColumns.OriginalCurrency, + ExpensifyColumns.OriginalCurrencyAmountFloat, + ExpensifyColumns.ReceiptUrl, + ExpensifyColumns.Timestamp + }; + + foreach (ExpensifyColumns requiredColumn in requiredData) + { + if (!fieldMap.ContainsKey(requiredColumn)) + { + // Abort as invalid file + + GuidCache.Set("Results-" + guidFiles, new AjaxCallExpensifyUploadResult + { + Success = false, + ErrorType = "ERR_INVALIDCSV", + DisplayMessage = Resources.Pages.Financial.FileExpenseClaim_Expensify_Error_InvalidCsv + }); + + progress.Set(100); // terminate progress bar, causes retrieval of result + + documents[0].Delete(); // prevents further processing + + return; // terminates thread + } + } + // TODO: Much more general-case error conditions if not all fields are filled bool vatEnabled = organization.VatEnabled; @@ -299,10 +333,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial if (vatEnabled && !fieldMap.ContainsKey(ExpensifyColumns.VatFloat)) { // Error: Organization needs a VAT field - // TODO - // Set result to bad - // Set progress to complete - // Abort GuidCache.Set("Results-" + guidFiles, new AjaxCallExpensifyUploadResult {