More on Expensify, committing work-in-progress

This commit is contained in:
Rick Falkvinge
2018-01-06 22:39:00 +01:00
parent d86d0bfedd
commit 6c56303502
5 changed files with 124 additions and 22 deletions
+1 -1
View File
@@ -898,7 +898,7 @@ namespace Resources.Pages {
}
/// <summary>
/// Looks up a localized string similar to Based on the organization&apos;s settings, the &quot;Default CSV&quot; profile in Expensify should be good to go..
/// Looks up a localized string similar to Based on the organization&apos;s settings, the &quot;Default CSV&quot; export profile in Expensify should be sufficient for Swarmops..
/// </summary>
internal static string FileExpenseClaim_Expensify_InstructionsNothingAdvanced {
get {
@@ -678,7 +678,7 @@
<comment>{0} is the organization name.</comment>
</data>
<data name="FileExpenseClaim_Expensify_InstructionsNothingAdvanced" xml:space="preserve">
<value>Based on the organization's settings, the "Default CSV" profile in Expensify should be good to go.</value>
<value>Based on the organization's settings, the "Default CSV" export profile in Expensify should be sufficient for Swarmops.</value>
</data>
<data name="FileExpenseClaim_Title_Expensify" xml:space="preserve">
<value>Upload Expensify Report For Reimbursement</value>
+40 -10
View File
@@ -85,6 +85,26 @@
}
var vatEnable = <%= this.CurrentOrganization.VatEnabled? "true" : "false" %>;
var expensifyProcessingHalfway = false;
function onExpensifyUpload() {
$('#divExpensifyProcessing').fadeIn();
$('#divExpensifyProgress').progressbar({ value: 0, max: 100 });
$('#divExpensifyProgressFake').progressbar({ value: 0, max: 100 });
$('#divExpensifyProgressFake').progressbar({ value: 100 }); // this guy is swapped in on completion
$('#divExpensifyResults').slideUp();
expensifyProcessingHalfway = false;
$.ajax({
type: "POST",
url: "/Pages/v5/Ledgers/UploadBankFiles.aspx/InitializeProcessing",
data: "{'guid': '<%= this.UploadFile.GuidString %>', 'accountIdString':'" + $('#<%= this.DropAccounts.ClientID %>').val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
setTimeout('updateProgressProcessing();', 1000);
}
}); }
</script>
@@ -136,24 +156,34 @@
<div style="clear:both"></div>
</div>
<div title="<img src='/Images/Icons/expensify-icon-official.png' width='40' height='40' style='padding-top:12px'>">
<h2><asp:Label runat="server" ID="LabelExpensifyUploadHeader" /></h2>
<div id="divExpensifyResults" style="display:none; margin-bottom:10px">
<h2><asp:Label ID="LabelProcessingComplete" runat="server" /></h2>
<div id="divExpensifyProgressFake" style="width:100%"></div>
<div id="divExpensifyResultsGood" style="display:none"><div id="DivUploadResultsGoodText"></div></div>
<div id="divExpensifyResultsBad" style="display:none">
<div style="float:left;margin-right:10px"><img src="/Images/Icons/iconshock-cross-96px.png" /></div><div id="DivUploadResultsBadText"></div>
</div>
</div>
<div id="divExpensifyInstructions">
<h2><asp:Label runat="server" ID="LabelExpensifyUploadHeader" /></h2>
<p><asp:Label runat="server" ID="LabelExpensifyInstructions1"/></p>
<p><asp:Label runat="server" ID="LabelExpensifyInstructions2"/></p>
</div>
<div id="DivUploadExpensify">
<div id="divExpensifyUploadAnotherHeader"><h2><asp:Label runat="server" ID="LabelUploadAnotherFileHeader" /></h2></div>
<div id="DivPrepData">
<div id="divExpensifyUploadAnotherHeader" style="display:none"><h2><asp:Label runat="server" ID="LabelUploadAnotherFileHeader" /></h2></div>
<div class="entryFields">
<Swarmops5:FileUpload runat="server" ID="UploadExpensify" Filter="NoFilter" DisplayCount="8" HideTrigger="true" ClientUploadCompleteCallback="uploadCompletedCallback" />
<asp:Button ID="ButtonExpensifyUpload" runat="server" CssClass="buttonAccentColor NoInputFocus" OnClientClick="alert('click'); return false;" Text="Request"/>
</div>
<div class="entryLabels">
<asp:Label runat="server" ID="LabelExpensifyCsv" />
</div>
<div class="entryFields">
<Swarmops5:FileUpload runat="server" ID="UploadExpensify" Filter="NoFilter" DisplayCount="8" ClientUploadCompleteCallback="uploadCompletedCallback" />
</div>
<div class="entryLabels">
<asp:Label runat="server" ID="LabelExpensifyCsv" />
</div>
<br clear="all"/>
@@ -1,11 +1,17 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Web;
using System.Web.Services;
using Swarmops.Interface.Support;
using Swarmops.Logic.Cache;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Security;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
using Swarmops.Logic.Swarm;
using Swarmops.Site.Pages.Ledgers;
namespace Swarmops.Frontend.Pages.v5.Financial
{
@@ -145,7 +151,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial
this.LabelExpensifyCsv.Text = Resources.Pages.Financial.FileExpenseClaim_Expensify_CsvUploadDescription;
this.LabelExpensifyInstructions1.Text =
Resources.Pages.Financial.FileExpenseClaim_Expensify_InstructionsBasic;
this.ButtonExpensifyUpload.Text = Resources.Global.Global_Upload;
if (CurrentOrganization.VatEnabled)
{
@@ -160,6 +165,73 @@ namespace Swarmops.Frontend.Pages.v5.Financial
}
[WebMethod(true)]
public static void InitializeExpensifyProcessing(string guid)
{
// Start an async thread that does all the work, then return
AuthenticationData authData = GetAuthenticationDataAndCulture();
Thread initThread = new Thread(ProcessExpensifyUploadThread);
ProcessThreadArguments args = new ProcessThreadArguments
{
Guid = guid,
Organization = authData.CurrentOrganization,
CurrentUser = authData.CurrentUser
};
initThread.Start(args);
}
private class ProcessThreadArguments
{
public string Guid { get; set; }
public Organization Organization { get; set; }
public Person CurrentUser { get; set; }
}
public class ReportedImportResults
{
public string Category { get; set; }
public string Html { get; set; }
}
private static void ProcessExpensifyUploadThread(object args)
{
string guid = ((ProcessThreadArguments) args).Guid;
Person currentUser = ((ProcessThreadArguments) args).CurrentUser;
Organization organization = ((ProcessThreadArguments) args).Organization;
Documents documents = Documents.RecentFromDescription(guid);
GuidCache.Set(guid + "-Progress", 1); // to make sure results aren't repeated from last file
GuidCache.Set(guid + "-Result", UploadBankFiles.ImportResultsCategory.Bad);
// default - this is what happens if exception
if (documents.Count != 1)
{
return; // abort
}
Document uploadedDoc = documents[0];
}
private enum ExpensifyColumns
{
Unknown = 0,
AmountCents,
Description,
CategoryCustom,
CategoryStandard,
VatCents,
ReceiptUrl
}
protected void ButtonRequest_Click (object sender, EventArgs e)
{
// The data has been validated client-side already. We'll throw unfriendly exceptions if invalid data is passed here.
+9 -9
View File
@@ -219,6 +219,15 @@ namespace Swarmops.Frontend.Pages.v5.Financial {
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelBankAccount;
/// <summary>
/// LabelProcessingComplete control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label LabelProcessingComplete;
/// <summary>
/// LabelExpensifyUploadHeader control.
/// </summary>
@@ -264,15 +273,6 @@ namespace Swarmops.Frontend.Pages.v5.Financial {
/// </remarks>
protected global::Swarmops.Controls.Base.FileUpload UploadExpensify;
/// <summary>
/// ButtonExpensifyUpload control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Button ButtonExpensifyUpload;
/// <summary>
/// LabelExpensifyCsv control.
/// </summary>