Trying adding footer to Expensify
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
function(result) {
|
||||
if (result.Success) {
|
||||
|
||||
displayExpensifyDataGrid(result.DataUpdate);
|
||||
displayExpensifyDataGrid(result.DataUpdate, result.FooterUpdate);
|
||||
|
||||
if (result.Guid.length > 1) // there's a new record
|
||||
{
|
||||
@@ -79,7 +79,7 @@
|
||||
if (result.Success) {
|
||||
// A record has been deleted. It is possible that a new one is displayed.
|
||||
|
||||
displayExpensifyDataGrid(result.DataUpdate);
|
||||
displayExpensifyDataGrid(result.DataUpdate, result.FooterUpdate);
|
||||
|
||||
if (result.Guid.length > 1) // there's a new record
|
||||
{
|
||||
@@ -198,9 +198,21 @@
|
||||
}
|
||||
|
||||
|
||||
function displayExpensifyDataGrid(data) {
|
||||
function displayExpensifyDataGrid(rows, footer) {
|
||||
|
||||
$('#expensifyDataGrid').datagrid('loadData', data);
|
||||
var gridData = {
|
||||
rows: rows,
|
||||
footer: footer
|
||||
};
|
||||
|
||||
$('#expensifyDataGrid').datagrid('loadData', gridData);
|
||||
|
||||
$('#expensifyDataGrid').datagrid('mergeCells', {
|
||||
index: 1,
|
||||
field: 'BudgetText',
|
||||
colspan: 3,
|
||||
type: 'footer'
|
||||
});
|
||||
|
||||
// Bind to enable document viewing
|
||||
|
||||
@@ -287,7 +299,7 @@
|
||||
|
||||
$('#divDocumentsHidden').html(result.Documents);
|
||||
|
||||
displayExpensifyDataGrid(result.Data);
|
||||
displayExpensifyDataGrid(result.Data, result.Footer);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
@@ -536,6 +536,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
{
|
||||
Success = true,
|
||||
Data = FormatExpensifyOutputRecords(recordList),
|
||||
Footer = FormatExpensifyFooter(recordList),
|
||||
Documents = documentsAll
|
||||
};
|
||||
|
||||
@@ -596,6 +597,31 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
}
|
||||
|
||||
|
||||
private static ExpensifyOutputRecord[] FormatExpensifyFooter(List<ExpensifyRecord> recordList)
|
||||
{
|
||||
Int64 amountCentsTotal =0;
|
||||
Int64 vatCentsTotal =0;
|
||||
|
||||
foreach (ExpensifyRecord record in recordList)
|
||||
{
|
||||
amountCentsTotal += record.AmountCents;
|
||||
vatCentsTotal += record.VatCents;
|
||||
}
|
||||
|
||||
ExpensifyOutputRecord newRecord = new ExpensifyOutputRecord
|
||||
{
|
||||
Amount = "<span class='weight-emphasis'>" + amountCentsTotal.ToString("N2") + "</span>",
|
||||
AmountVat = "<span class='weight-emphasis'>" + amountCentsTotal.ToString("N2") + "</span>",
|
||||
BudgetText = "<span class='weight-emphasis'>" + Resources.Global.Global_Total + "</span>"
|
||||
};
|
||||
|
||||
List<ExpensifyOutputRecord> listResult = new List<ExpensifyOutputRecord>();
|
||||
listResult.Add(newRecord);
|
||||
|
||||
return listResult.ToArray();
|
||||
}
|
||||
|
||||
|
||||
[WebMethod]
|
||||
public static AjaxCallExpensifyRecordResult ExpensifyRecordProceed(string masterGuid, string recordGuid,
|
||||
string amountString, string amountVatString, int budgetId, string description)
|
||||
@@ -649,7 +675,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
Guid = recordList[index].Guid,
|
||||
ExistNext = (index < recordList.Count - 1 ? true : false),
|
||||
Success = true,
|
||||
DataUpdate = FormatExpensifyOutputRecords(recordList)
|
||||
DataUpdate = FormatExpensifyOutputRecords(recordList),
|
||||
FooterUpdate = FormatExpensifyFooter (recordList)
|
||||
};
|
||||
|
||||
}
|
||||
@@ -687,7 +714,8 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
Guid = recordList[index].Guid,
|
||||
ExistNext = (index < recordList.Count - 1 ? true : false),
|
||||
Success = true,
|
||||
DataUpdate = FormatExpensifyOutputRecords(recordList)
|
||||
DataUpdate = FormatExpensifyOutputRecords(recordList),
|
||||
FooterUpdate = FormatExpensifyFooter(recordList)
|
||||
};
|
||||
|
||||
}
|
||||
@@ -937,6 +965,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
{
|
||||
public string ErrorType { get; set; }
|
||||
public ExpensifyOutputRecord[] Data { get; set; }
|
||||
public ExpensifyOutputRecord[] Footer { get; set; }
|
||||
public string Documents { get; set; }
|
||||
}
|
||||
|
||||
@@ -951,6 +980,7 @@ namespace Swarmops.Frontend.Pages.v5.Financial
|
||||
public bool ExistNext { get; set; }
|
||||
|
||||
public ExpensifyOutputRecord[] DataUpdate { get; set; }
|
||||
public ExpensifyOutputRecord[] FooterUpdate { get; set; }
|
||||
public bool CanCommit { get; set; }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user