Work on Expensify upload
This commit is contained in:
@@ -888,6 +888,15 @@ namespace Resources.Pages {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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]";.
|
||||
/// </summary>
|
||||
internal static string FileExpenseClaim_Expensify_Error_InvalidCsv {
|
||||
get {
|
||||
return ResourceManager.GetString("FileExpenseClaim_Expensify_Error_InvalidCsv", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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>.
|
||||
/// </summary>
|
||||
|
||||
@@ -703,4 +703,7 @@
|
||||
<data name="FileExpenseClaim_ForWhom_Prompt" xml:space="preserve">
|
||||
<value>This is an expense claim from whom?</value>
|
||||
</data>
|
||||
<data name="FileExpenseClaim_Expensify_Error_InvalidCsv" xml:space="preserve">
|
||||
<value><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></value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user