From a9b67d904db66193f98c946ad461dbb60a2219df Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Tue, 29 Jan 2019 18:54:43 +0100 Subject: [PATCH] Work on Payment History --- ...Json-MasterPersonEditPaymentHistory.aspx.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Site/Automation/Json-MasterPersonEditPaymentHistory.aspx.cs b/Site/Automation/Json-MasterPersonEditPaymentHistory.aspx.cs index 0b7ab3ae..2932112d 100644 --- a/Site/Automation/Json-MasterPersonEditPaymentHistory.aspx.cs +++ b/Site/Automation/Json-MasterPersonEditPaymentHistory.aspx.cs @@ -45,7 +45,7 @@ namespace Swarmops.Frontend.Automation list.AddRange(GetAmountsOwed()); list.AddRange(GetAmountsPaid()); - //list.SortByDate(); + list.Sort(LineItemSorterByDate); Response.ContentType = "application/json"; Response.Output.WriteLine("{\"rows\": " + JsonWriteItems(list) + ", \"footer\": [" + @@ -71,7 +71,7 @@ namespace Swarmops.Frontend.Automation { PaymentHistoryLineItem newItem = new PaymentHistoryLineItem(); newItem.Id = "E" + claim.Identity.ToString(CultureInfo.InvariantCulture); - newItem.Name = Resources.Global.Financial_ExpenseClaim + " #" + claim.Identity.ToString("N0"); + newItem.Name = String.Format(Resources.Global.Financial_ExpenseClaimLongSpecification, claim.Identity); newItem.Description = claim.Description; newItem.OpenedDate = claim.CreatedDateTime; newItem.OwedToPerson = claim.AmountCents; @@ -163,6 +163,7 @@ namespace Swarmops.Frontend.Automation } newItem.Description = String.Empty; newItem.PaidToPerson = payout.AmountCents; + newItem.OpenedDate = payout.CreatedDateTime; FinancialTransaction closeTx = payout.FinancialTransaction; if (closeTx != null) // it damn well should not be null since Open is false @@ -189,9 +190,9 @@ namespace Swarmops.Frontend.Automation JsonSanitize(item.Id), JsonSanitize(item.Name), JsonSanitize(item.Description), - item.OpenedDate > Constants.DateTimeLowThreshold? item.OpenedDate.ToString("yyyy-MMM-dd") : string.Empty, - item.OwedToPerson > 0 ? (item.OwedToPerson/100.0).ToString("N2") : string.Empty, - string.Empty, + item.OpenedDate > Constants.DateTimeLowThreshold && item.PaidToPerson == 0? item.OpenedDate.ToString("yyyy-MMM-dd") : string.Empty, + item.OwedToPerson != 0 ? (item.OwedToPerson/100.0).ToString("N2") : string.Empty, + item.PaidToPerson != 0 ? (item.PaidToPerson / 100.0).ToString("N2") : string.Empty, item.ClosedDate < Constants.DateTimeHighThreshold? item.ClosedDate.ToString("yyyy-MMM-dd"): string.Empty ); @@ -205,11 +206,16 @@ namespace Swarmops.Frontend.Automation return result.ToString(); } -public string JsonWriteFooter(List items) + public string JsonWriteFooter(List items) { return string.Empty; } + public static int LineItemSorterByDate(PaymentHistoryLineItem a, PaymentHistoryLineItem b) + { + return a.OpenedDate.CompareTo(b.OpenedDate); + } + public class PaymentHistoryLineItem { public PaymentHistoryLineItem()