diff --git a/Logic/Financial/CashAdvances.cs b/Logic/Financial/CashAdvances.cs
index 93b67400..546c0334 100644
--- a/Logic/Financial/CashAdvances.cs
+++ b/Logic/Financial/CashAdvances.cs
@@ -4,6 +4,7 @@ using Swarmops.Basic.Types.Financial;
using Swarmops.Database;
using Swarmops.Logic.Structure;
using Swarmops.Logic.Support;
+using Swarmops.Logic.Swarm;
namespace Swarmops.Logic.Financial
{
@@ -68,5 +69,11 @@ namespace Swarmops.Logic.Financial
return FromArray (SwarmDb.GetDatabaseForReading().GetCashAdvances (organization,
includeClosed ? DatabaseCondition.None : DatabaseCondition.OpenTrue));
}
+
+ public static CashAdvances ForPersonAndOrganization(Person person, Organization organization, bool includeClosed)
+ {
+ return FromArray(SwarmDb.GetDatabaseForReading().GetCashAdvances(person, organization,
+ includeClosed ? DatabaseCondition.None : DatabaseCondition.OpenTrue));
+ }
}
}
\ No newline at end of file
diff --git a/Logic/Financial/Payouts.cs b/Logic/Financial/Payouts.cs
index 04fd55bb..bb5f6218 100644
--- a/Logic/Financial/Payouts.cs
+++ b/Logic/Financial/Payouts.cs
@@ -64,6 +64,15 @@ namespace Swarmops.Logic.Financial
return FromArray (SwarmDb.GetDatabaseForReading().GetPayouts (organization, DatabaseCondition.OpenTrue));
}
+ public static Payouts ToPerson(Person person, bool includeClosed)
+ {
+ if (includeClosed)
+ {
+ return FromArray(SwarmDb.GetDatabaseForReading().GetPayouts(organization));
+ }
+ return FromArray(SwarmDb.GetDatabaseForReading().GetPayouts(organization, DatabaseCondition.OpenTrue));
+ }
+
public static Payouts Construct (Organization organization)
{
// Construct a list of not-yet-created payouts. Basically, these are the things that
diff --git a/Site/App_GlobalResources/Global.designer.cs b/Site/App_GlobalResources/Global.designer.cs
index 06290e0e..3ba5f490 100644
--- a/Site/App_GlobalResources/Global.designer.cs
+++ b/Site/App_GlobalResources/Global.designer.cs
@@ -645,6 +645,24 @@ namespace Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Payment #{0:N0}.
+ ///
+ internal static string Financial_PaymentSpecification {
+ get {
+ return ResourceManager.GetString("Financial_PaymentSpecification", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Payout #{0:N0}.
+ ///
+ internal static string Financial_PayoutSpecification {
+ get {
+ return ResourceManager.GetString("Financial_PayoutSpecification", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Annual Profit/Loss To Date ({0}).
///
diff --git a/Site/App_GlobalResources/Global.resx b/Site/App_GlobalResources/Global.resx
index 0f9d826c..944a3fb9 100644
--- a/Site/App_GlobalResources/Global.resx
+++ b/Site/App_GlobalResources/Global.resx
@@ -1011,4 +1011,12 @@
EBITDA
Earnings before Interest, Taxes, Depreciation, and Amortization - a financial term
+
+ Payment #{0:N0}
+ A Payment (as opposed to payout) is money entering the organization
+
+
+ Payout #{0:N0}
+ A Pay-OUT is always money leaving the organization
+
\ No newline at end of file
diff --git a/Site/Automation/Json-MasterPersonEditPaymentHistory.aspx.cs b/Site/Automation/Json-MasterPersonEditPaymentHistory.aspx.cs
index a7599619..0b7ab3ae 100644
--- a/Site/Automation/Json-MasterPersonEditPaymentHistory.aspx.cs
+++ b/Site/Automation/Json-MasterPersonEditPaymentHistory.aspx.cs
@@ -17,6 +17,8 @@ namespace Swarmops.Frontend.Automation
{
private AuthenticationData _authenticationData;
private Person _person;
+ private Dictionary _payoutLookup;
+ private Dictionary _payoutDescriptionOverride;
protected void Page_Load(object sender, EventArgs e)
{
@@ -38,9 +40,11 @@ namespace Swarmops.Frontend.Automation
}
List list = new List();
+ _payoutLookup = new Dictionary();
+ _payoutDescriptionOverride = new Dictionary();
list.AddRange(GetAmountsOwed());
- //list.AddRange(GetAmountsPaid());
+ list.AddRange(GetAmountsPaid());
//list.SortByDate();
Response.ContentType = "application/json";
@@ -75,6 +79,7 @@ namespace Swarmops.Frontend.Automation
Payout payout = claim.Payout;
if (payout != null && payout.Open == false)
{
+ _payoutLookup[payout.Identity] = payout;
newItem.ClosedDate = payout.FinancialTransaction.DateTime;
}
@@ -92,8 +97,8 @@ namespace Swarmops.Frontend.Automation
{
PaymentHistoryLineItem newItem = new PaymentHistoryLineItem();
newItem.Id = "S" + salary.Identity.ToString(CultureInfo.InvariantCulture);
- newItem.Name = Resources.Global.Financial_Salary + " #" + salary.Identity.ToString("N0");
- newItem.Description = "Salary for something XYZ";
+ newItem.Name = Resources.Global.Financial_Salary;
+ newItem.Description = String.Format(Resources.Global.Financial_SalaryDualSpecification, salary.Identity, salary.PayoutDate);
newItem.OwedToPerson = salary.NetSalaryCents;
FinancialTransaction openTx = FinancialTransaction.FromDependency(salary);
@@ -105,6 +110,7 @@ namespace Swarmops.Frontend.Automation
Payout payout = Payout.FromDependency(salary, FinancialDependencyType.Salary);
if (payout != null && payout.Open == false)
{
+ _payoutLookup[payout.Identity] = payout;
newItem.ClosedDate = payout.FinancialTransaction.DateTime;
}
@@ -112,12 +118,62 @@ namespace Swarmops.Frontend.Automation
}
}
+ // Cash advances
+
+ CashAdvances advances = CashAdvances.ForPersonAndOrganization(_person,
+ _authenticationData.CurrentOrganization, true);
+
+ foreach (CashAdvance advance in advances)
+ {
+ if (advance.Open || advance.PaidOut)
+ {
+ Payout payout = advance.PayoutOut;
+ if (payout != null)
+ {
+ _payoutLookup[payout.Identity] = payout;
+ _payoutDescriptionOverride[payout.Identity] =
+ String.Format(Resources.Global.Financial_CashAdvanceSpecification, advance.Identity.ToString("N0"));
+ }
+ }
+ }
+
return items;
}
public List GetAmountsPaid()
{
- return null;
+ List items = new List();
+
+ foreach (Payout payout in _payoutLookup.Values)
+ {
+ if (payout.Open)
+ {
+ continue; // do not list unconfirmed payouts
+ }
+
+ PaymentHistoryLineItem newItem = new PaymentHistoryLineItem();
+ newItem.Id = "PO" + payout.Identity.ToString(CultureInfo.InvariantCulture);
+ if (_payoutDescriptionOverride.ContainsKey(payout.Identity))
+ {
+ newItem.Name = _payoutDescriptionOverride[payout.Identity];
+ }
+ else
+ {
+ newItem.Name = String.Format(Resources.Global.Financial_PayoutSpecification, payout.Identity);
+ }
+ newItem.Description = String.Empty;
+ newItem.PaidToPerson = payout.AmountCents;
+
+ FinancialTransaction closeTx = payout.FinancialTransaction;
+ if (closeTx != null) // it damn well should not be null since Open is false
+ {
+ newItem.ClosedDate = closeTx.DateTime;
+ }
+
+ items.Add(newItem);
+ }
+
+ return items;
}
public string JsonWriteItems(List items)