Work on Expensify; Proceed might work
This commit is contained in:
@@ -70,8 +70,6 @@ namespace Swarmops.Frontend.Automation
|
||||
[WebMethod]
|
||||
public static InterpretedCurrencyResult InterpretCurrency(string input)
|
||||
{
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
string[] currencyStrings = input.Split(' ');
|
||||
if (currencyStrings.Length != 2)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,54 @@
|
||||
$('#divTabs').tabs();
|
||||
|
||||
$('#buttonModalProceed').click(function() {
|
||||
// first, validate fields
|
||||
|
||||
var budgetId = <%=this.ComboExpensifyBudgets.ClientID%>_val();
|
||||
|
||||
if (budgetId == 0) {
|
||||
alertify.error("You need to select a budget.");
|
||||
return;
|
||||
}
|
||||
|
||||
var description = $('#textModalExpensifyDescription').val();
|
||||
|
||||
if (description.length < 1) {
|
||||
alertify.error("You need to describe the expense claim.");
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: check for invalid amounts
|
||||
|
||||
var amount = <%=this.CurrencyModalExpensifyAmount.ClientID%>_val();
|
||||
var amountVat = <%=this.CurrencyModalExpensifyAmountVat.ClientID%>_val();
|
||||
<%=this.DialogEditExpenseClaim.ClientID%>_close();
|
||||
|
||||
SwarmopsJS.ajaxCall(
|
||||
'/Pages/v5/Financial/FileExpenseClaim.aspx/ExpensifyRecordProceed',
|
||||
{
|
||||
masterGuid: '<%=this.UploadExpensify.GuidString%>',
|
||||
recordGuid: currentlyEditedRecordGuid,
|
||||
description: description,
|
||||
amountString: amount,
|
||||
amountVatString: amountVat,
|
||||
budgetId: budgetId
|
||||
},
|
||||
function(result) {
|
||||
if (result.Success) {
|
||||
|
||||
$('#expensifyDataGrid').datagrid('loadData', result.DataUpdate);
|
||||
|
||||
if (result.Guid.length > 1) // there's a new record
|
||||
{
|
||||
currentlyEditedRecordGuid = result.Guid;
|
||||
displayExpensifyRecord(result);
|
||||
}
|
||||
|
||||
} else {
|
||||
<%=this.DialogEditExpenseClaim.ClientID%>_open(); // re-open same dialog
|
||||
alertify.error("There was an error submitting the data. Please fix.");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#buttonModalDelete').click(function () {
|
||||
@@ -44,7 +91,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}); // end of doc.ready
|
||||
|
||||
|
||||
|
||||
@@ -128,6 +175,7 @@
|
||||
}
|
||||
|
||||
function displayExpensifyRecord(record) {
|
||||
<%=this.ComboExpensifyBudgets.ClientID%>_val(record.BudgetId);
|
||||
<%=this.CurrencyModalExpensifyAmount.ClientID%>_initialize(record.Amount);
|
||||
<%=this.CurrencyModalExpensifyAmountVat.ClientID%>_initialize(record.AmountVat);
|
||||
$('#textModalExpensifyDescription').val(record.Description);
|
||||
@@ -378,7 +426,7 @@
|
||||
<div class="elementFloatFar" style="width: 200px;padding:10px"><img id="imgModalDocument" style="border: 2px solid #888; width:100%"/></div>
|
||||
<div class="entryFields">
|
||||
<div class="stacked-input-control"><input type="text" id="textModalExpensifyDescription" /></div>
|
||||
<Swarmops5:ComboBudgets ID="DropBudgets" ListType="Expensable" runat="server"/>
|
||||
<Swarmops5:ComboBudgets ID="ComboExpensifyBudgets" ListType="Expensable" runat="server"/>
|
||||
<Swarmops5:Currency ID="CurrencyModalExpensifyAmount" runat="server"/>
|
||||
<div class="ifVatEnabled"><Swarmops5:Currency ID="CurrencyModalExpensifyAmountVat" runat="server"/></div>
|
||||
<input type="button" id="buttonModalProceed" class="buttonAccentColor HalfWidth NoInputFocus" value="Proceed >>"/><input type="button" id="buttonModalDelete" class="buttonAccentColor Red HalfWidth NoInputFocus" value="Delete"/>
|
||||
|
||||
@@ -21,6 +21,8 @@ using Swarmops.Logic.Support.BackendServices;
|
||||
using Swarmops.Logic.Swarm;
|
||||
using Swarmops.Site.Pages.Ledgers;
|
||||
using CsvHelper;
|
||||
using Swarmops.Frontend.Automation;
|
||||
using Formatting = Swarmops.Logic.Support.Formatting;
|
||||
|
||||
|
||||
namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
@@ -557,11 +559,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
|
||||
foreach (ExpensifyRecord record in recordList)
|
||||
{
|
||||
outputRecords.Add(new ExpensifyOutputRecord
|
||||
ExpensifyOutputRecord newRecord = new ExpensifyOutputRecord
|
||||
{
|
||||
BudgetText =
|
||||
"<span class='LocalEditExpenseClaim' data-guid='" + record.Guid + "'>" +
|
||||
Resources.Global.Global_DropInits_SelectFinancialAccount + "</span>",
|
||||
Description = record.CategoryCustom + " / " + record.Description,
|
||||
CreatedDateTime = record.Timestamp.ToString("MMM dd"),
|
||||
Amount = (record.AmountCents/100.0).ToString("N2"),
|
||||
@@ -571,7 +570,26 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
"D" + record.Documents[0].Identity.ToString(CultureInfo.InvariantCulture)) +
|
||||
String.Format(editString, record.Guid),
|
||||
Guid = record.Guid
|
||||
});
|
||||
};
|
||||
|
||||
if (record.BudgetId != 0)
|
||||
{
|
||||
FinancialAccount account = FinancialAccount.FromIdentity(record.BudgetId);
|
||||
newRecord.BudgetText = account.Name;
|
||||
|
||||
if (account.ParentIdentity != 0)
|
||||
{
|
||||
newRecord.BudgetText = account.Parent.Name + " >> " + account.Name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newRecord.BudgetText =
|
||||
"<span class='LocalEditExpenseClaim' data-guid='" + record.Guid + "'>" +
|
||||
Resources.Global.Global_DropInits_SelectFinancialAccount + "</span>";
|
||||
}
|
||||
|
||||
outputRecords.Add(newRecord);
|
||||
}
|
||||
|
||||
return outputRecords.ToArray();
|
||||
@@ -580,11 +598,59 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
|
||||
[WebMethod]
|
||||
public static AjaxCallExpensifyRecordResult ExpensifyRecordProceed(string masterGuid, string recordGuid,
|
||||
int amountCents, int amountVat, int budgetId, string description)
|
||||
string amountString, string amountVatString, int budgetId, string description)
|
||||
{
|
||||
List<ExpensifyRecord> recordList = (List<ExpensifyRecord>)GuidCache.Get("ExpensifyData-" + masterGuid);
|
||||
int index = LocateRecordsetIndex(recordList, recordGuid);
|
||||
|
||||
amountString = amountString.Trim();
|
||||
amountVatString = amountVatString.Trim();
|
||||
|
||||
if (amountString.Contains(" "))
|
||||
{
|
||||
amountString = FinancialFunctions.InterpretCurrency(amountString).DisplayAmount;
|
||||
}
|
||||
|
||||
if (amountVatString.Contains(" "))
|
||||
{
|
||||
amountVatString = FinancialFunctions.InterpretCurrency(amountVatString).DisplayAmount;
|
||||
}
|
||||
|
||||
recordList[index].AmountCents = Formatting.ParseDoubleStringAsCents(amountString);
|
||||
recordList[index].VatCents = Formatting.ParseDoubleStringAsCents(amountVatString);
|
||||
recordList[index].BudgetId = budgetId;
|
||||
recordList[index].Description = description;
|
||||
|
||||
GuidCache.Set("ExpensifyData-" + masterGuid, recordList);
|
||||
|
||||
index++;
|
||||
|
||||
if (index >= recordList.Count)
|
||||
{
|
||||
// We processed the last record, so return a null record
|
||||
|
||||
return new AjaxCallExpensifyRecordResult
|
||||
{
|
||||
Guid = "", // indicates null record
|
||||
DataUpdate = FormatExpensifyOutputRecords(recordList)
|
||||
// TODO: CanCommit
|
||||
};
|
||||
}
|
||||
|
||||
// Display the record next in line
|
||||
|
||||
return new AjaxCallExpensifyRecordResult
|
||||
{
|
||||
Amount = (recordList[index].AmountCents / 100.0).ToString("N2"),
|
||||
AmountVat = (recordList[index].VatCents / 100.0).ToString("N2"),
|
||||
Description = recordList[index].Description,
|
||||
DocumentId = recordList[index].Documents.First().Identity,
|
||||
Guid = recordList[index].Guid,
|
||||
ExistNext = (index < recordList.Count - 1 ? true : false),
|
||||
Success = true,
|
||||
DataUpdate = FormatExpensifyOutputRecords(recordList)
|
||||
};
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
|
||||
+2
-2
@@ -373,13 +373,13 @@ namespace Swarmops.Frontend.Pages.v5.Financial {
|
||||
protected global::Swarmops.Frontend.Controls.Base.ModalDialog DialogEditExpenseClaim;
|
||||
|
||||
/// <summary>
|
||||
/// DropBudgets control.
|
||||
/// ComboExpensifyBudgets control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::Swarmops.Controls.Financial.ComboBudgets DropBudgets;
|
||||
protected global::Swarmops.Controls.Financial.ComboBudgets ComboExpensifyBudgets;
|
||||
|
||||
/// <summary>
|
||||
/// CurrencyModalExpensifyAmount control.
|
||||
|
||||
Reference in New Issue
Block a user