Work on Payment History

This commit is contained in:
Rick Falkvinge
2019-01-29 11:28:24 +01:00
parent 613e6d5004
commit 384030cadf
2 changed files with 83 additions and 8 deletions
@@ -1,9 +1,12 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Swarmops.Logic.Financial;
using Swarmops.Logic.Swarm;
namespace Swarmops.Frontend.Automation
@@ -25,17 +28,89 @@ namespace Swarmops.Frontend.Automation
this._person = Person.FromIdentity(personId);
/*
List<PaymentHistoryLineItem> list = new List<PaymentHistoryLineItem>();
THIS ENTIRE STUFF IS TODO
list.AddRange(GetAmountsOwed());
list.AddRange(GetAmountsPaid());
Response.ContentType = "application/json";
Response.Output.WriteLine("{\"rows\": " + JsonWriteItems(list) + ", \"footer\": [" +
JsonWriteFooter(list) + "]}");
Response.Output.WriteLine("{\"rows\": " + RecurseReport(report.ReportLines) + ", \"footer\": [" +
WriteFooter() + "]}");
Response.End();
Response.End();*/
}
public List<PaymentHistoryLineItem> GetAmountsOwed()
{
List<PaymentHistoryLineItem> items = new List<PaymentHistoryLineItem>();
// Expense claims
ExpenseClaims expenses = ExpenseClaims.FromClaimingPersonAndOrganization(_person,
_authenticationData.CurrentOrganization);
foreach (ExpenseClaim claim in expenses)
{
PaymentHistoryLineItem newItem = new PaymentHistoryLineItem();
newItem.Id = "E" + claim.Identity.ToString(CultureInfo.InvariantCulture);
newItem.Name = Resources.Global.Financial_ExpenseClaim + " #" + claim.Identity.ToString("N0");
newItem.Description = claim.Description;
newItem.OwedToPerson = claim.AmountCents;
items.Add(newItem);
}
return items;
}
public List<PaymentHistoryLineItem> GetAmountsPaid()
{
return null;
}
public string JsonWriteItems(List<PaymentHistoryLineItem> items)
{
StringBuilder result = new StringBuilder(16384);
result.Append("[");
foreach (PaymentHistoryLineItem item in items)
{
result.Append("{");
result.AppendFormat(
"\"id\":\"{0}\",\"name\":\"{1}\",\"description\":\"{2}\",\"owedToPerson\":\"{3:N2}\"",
JsonSanitize(item.Id),
JsonSanitize(item.Name),
JsonSanitize(item.Description),
item.OwedToPerson/100.0
);
result.Append("},");
}
result.Remove(result.Length - 1, 1); // remove last comma
result.Append("]");
return result.ToString();
}
public string JsonWriteFooter(List<PaymentHistoryLineItem> items)
{
return string.Empty;
}
public class PaymentHistoryLineItem
{
public string Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public Int64 OwedToPerson { get; set; }
public Int64 PaidToPerson { get; set; }
public DateTime OpenedDate { get; set; }
public DateTime ClosedDate { get; set; }
}
}
}
+2 -2
View File
@@ -387,8 +387,8 @@
<th field="name" width="178"><asp:Literal ID="MasterPersonEditLiteralHeaderItemName" Text="Item Type XYZ" runat="server"/></th>
<th field="description" width="180"><asp:Literal ID="MasterPersonEditLiteralHeaderItemDescription" Text="Description XYZ" runat="server"/></th>
<th field="opened" width="120"><asp:Literal ID="MasterPersonEditLiteralHeaderItemOpenedDate" Text="Opened date XYZ" runat="server"/></th>
<th field="owedtoperson" width="120" align="right"><asp:Literal ID="MasterPersonEditLiteralHeaderAmountOwed" Text="Payment XYZ" runat="server"/></th>
<th field="paidtoperson" width="120" align="right"><asp:Literal ID="MasterPersonEditLiteralHeaderAmountPaid" Text="Owed to you XYZ" runat="server"/></th>
<th field="owedToPerson" width="120" align="right"><asp:Literal ID="MasterPersonEditLiteralHeaderAmountOwed" Text="Payment XYZ" runat="server"/></th>
<th field="paidToPerson" width="120" align="right"><asp:Literal ID="MasterPersonEditLiteralHeaderAmountPaid" Text="Owed to you XYZ" runat="server"/></th>
<th field="closed" width="120"><asp:Literal ID="MasterPersonEditLiteralHeaderItemClosedDate" Text="Closed date XYZ" runat="server"/></th>
<th field="notes" width="80"><asp:Literal ID="MasterPersonEditLiteralHeaderItemNotes" Text="Notes XYZ" runat="server"/></th>
</tr>