diff --git a/Site/App_GlobalResources/Pages.Financial.designer.cs b/Site/App_GlobalResources/Pages.Financial.designer.cs
index e046579c..3bc9c2a4 100644
--- a/Site/App_GlobalResources/Pages.Financial.designer.cs
+++ b/Site/App_GlobalResources/Pages.Financial.designer.cs
@@ -987,6 +987,24 @@ namespace Resources.Pages {
}
}
+ ///
+ /// Looks up a localized string similar to Claim successfully filed..
+ ///
+ internal static string FileExpenseClaim_Expensify_SuccessOne {
+ get {
+ return ResourceManager.GetString("FileExpenseClaim_Expensify_SuccessOne", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Successfully filed {0} claims..
+ ///
+ internal static string FileExpenseClaim_Expensify_SuccessSeveral {
+ get {
+ return ResourceManager.GetString("FileExpenseClaim_Expensify_SuccessSeveral", 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 c95b7beb..f6f44fb6 100644
--- a/Site/App_GlobalResources/Pages.Financial.resx
+++ b/Site/App_GlobalResources/Pages.Financial.resx
@@ -725,4 +725,10 @@
Ready to submit {0} claims
The {0} is replaced by a number, 2 or higher
+
+ Claim successfully filed.
+
+
+ Successfully filed {0} claims.
+
\ No newline at end of file
diff --git a/Site/Pages/v5/Financial/FileExpenseClaim.aspx b/Site/Pages/v5/Financial/FileExpenseClaim.aspx
index 1f66c393..4a7da3ff 100644
--- a/Site/Pages/v5/Financial/FileExpenseClaim.aspx
+++ b/Site/Pages/v5/Financial/FileExpenseClaim.aspx
@@ -121,6 +121,24 @@
});
});
+ $('#buttonExpensifySubmit').click(function() {
+ SwarmopsJS.ajaxCall (
+ '/Pages/v5/Financial/FileExpenseClaim.aspx/ExpensifyRecordsetCommit',
+ { masterGuid: '<%=this.UploadExpensify.GuidString%>' },
+ function(result) {
+ if (result.Success) {
+ alertify.success(result.DisplayMessage);
+ $('#divExpensifyResults').slideUp();
+ $('#divExpensifyUploadAnotherHeader').show();
+ $('#divExpensifyUploadFile').show();
+ $('#divExpensifyInstructions').hide();
+ $('#divUploadExpensify').slideDown();
+ } else {
+ alertify.dialog(result.DisplayMessage);
+ console.log(result.DisplayMessage);
+ }
+ });
+
}); // end of doc.ready
diff --git a/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs b/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs
index f7c1fe1d..313439dc 100644
--- a/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs
+++ b/Site/Pages/v5/Financial/FileExpenseClaim.aspx.cs
@@ -5,6 +5,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
+using System.Runtime.CompilerServices;
using System.Security.Principal;
using System.Text.RegularExpressions;
using System.Threading;
@@ -21,6 +22,7 @@ using Swarmops.Logic.Support.BackendServices;
using Swarmops.Logic.Swarm;
using Swarmops.Site.Pages.Ledgers;
using CsvHelper;
+using Swarmops.Common.Enums;
using Swarmops.Frontend.Automation;
using Formatting = Swarmops.Logic.Support.Formatting;
@@ -259,6 +261,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
csvEntire = reader.ReadToEnd();
}
+ GuidCache.Set("ExpensifyRaw-" + guidFiles, csvEntire);
+
string[] csvLines = csvEntire.Split(new char[] {'\r', '\n'});
string[] fieldNames = csvLines[0].Split(',');
@@ -663,6 +667,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
public static AjaxCallExpensifyRecordResult ExpensifyRecordProceed(string masterGuid, string recordGuid,
string amountString, string amountVatString, int budgetId, string description)
{
+ GetAuthenticationDataAndCulture();
+
List recordList = (List)GuidCache.Get("ExpensifyData-" + masterGuid);
int index = LocateRecordsetIndex(recordList, recordGuid);
@@ -724,6 +730,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
[WebMethod]
public static AjaxCallExpensifyRecordResult ExpensifyRecordDelete(string masterGuid, string recordGuid)
{
+ GetAuthenticationDataAndCulture();
+
List recordList = (List)GuidCache.Get("ExpensifyData-" + masterGuid);
int index = LocateRecordsetIndex(recordList, recordGuid);
@@ -763,6 +771,66 @@ namespace Swarmops.Frontend.Pages.v5.Financial
}
+ [WebMethod]
+ public static AjaxCallResult ExpensifyRecordsetCommit(string masterGuid)
+ {
+ AuthenticationData authData = GetAuthenticationDataAndCulture();
+
+ // Commit all expenses in the recordset
+
+ try
+ {
+ List recordList = (List) GuidCache.Get("ExpensifyData-" + masterGuid);
+ string expensifyRaw = (string) GuidCache.Get("ExpensifyRaw-" + masterGuid);
+
+ ExpenseClaimGroup expenseClaimGroup = ExpenseClaimGroup.Create(authData.CurrentOrganization,
+ authData.CurrentUser, ExpenseClaimGroupType.Expensify, expensifyRaw);
+
+ foreach (ExpensifyRecord record in recordList)
+ {
+ FinancialAccount budget = FinancialAccount.FromIdentity(record.BudgetId);
+
+ ExpenseClaim claim = ExpenseClaim.Create(authData.CurrentUser, authData.CurrentOrganization, budget,
+ record.Timestamp, record.CategoryCustom + " / " + record.Description, record.AmountCents,
+ record.VatCents,
+ expenseClaimGroup);
+
+ record.Documents.SetForeignObjectForAll(claim);
+
+ // TODO: Log
+ }
+
+ if (recordList.Count > 1)
+ {
+ return new AjaxCallResult
+ {
+ Success = true,
+ DisplayMessage =
+ String.Format(Resources.Pages.Financial.FileExpenseClaim_Expensify_SuccessSeveral,
+ recordList.Count)
+ };
+ }
+
+ return new AjaxCallResult
+ {
+ Success = true,
+ DisplayMessage = Resources.Pages.Financial.FileExpenseClaim_Expensify_SuccessOne
+ };
+ }
+ catch (Exception exc)
+ {
+ return new AjaxCallResult
+ {
+ Success = false,
+ DisplayMessage = exc.ToString()
+ };
+ }
+
+
+ }
+
+
+
[WebMethod]
public static AjaxCallExpensifyUploadResult GetExpensifyUploadResult(string guid)
{
@@ -775,6 +843,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
[WebMethod]
public static AjaxCallExpensifyRecordResult GetExpensifyRecord(string masterGuid, string recordGuid)
{
+ GetAuthenticationDataAndCulture();
+
List recordList = (List) GuidCache.Get("ExpensifyData-" + masterGuid);
int index = LocateRecordsetIndex(recordList, recordGuid);