Work on Payment History
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
+18
@@ -645,6 +645,24 @@ namespace Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Payment #{0:N0}.
|
||||
/// </summary>
|
||||
internal static string Financial_PaymentSpecification {
|
||||
get {
|
||||
return ResourceManager.GetString("Financial_PaymentSpecification", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Payout #{0:N0}.
|
||||
/// </summary>
|
||||
internal static string Financial_PayoutSpecification {
|
||||
get {
|
||||
return ResourceManager.GetString("Financial_PayoutSpecification", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Annual Profit/Loss To Date ({0}).
|
||||
/// </summary>
|
||||
|
||||
@@ -1011,4 +1011,12 @@
|
||||
<value>EBITDA</value>
|
||||
<comment>Earnings before Interest, Taxes, Depreciation, and Amortization - a financial term</comment>
|
||||
</data>
|
||||
<data name="Financial_PaymentSpecification" xml:space="preserve">
|
||||
<value>Payment #{0:N0}</value>
|
||||
<comment>A Payment (as opposed to payout) is money entering the organization</comment>
|
||||
</data>
|
||||
<data name="Financial_PayoutSpecification" xml:space="preserve">
|
||||
<value>Payout #{0:N0}</value>
|
||||
<comment>A Pay-OUT is always money leaving the organization</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -17,6 +17,8 @@ namespace Swarmops.Frontend.Automation
|
||||
{
|
||||
private AuthenticationData _authenticationData;
|
||||
private Person _person;
|
||||
private Dictionary<int, Payout> _payoutLookup;
|
||||
private Dictionary<int, string> _payoutDescriptionOverride;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
@@ -38,9 +40,11 @@ namespace Swarmops.Frontend.Automation
|
||||
}
|
||||
|
||||
List<PaymentHistoryLineItem> list = new List<PaymentHistoryLineItem>();
|
||||
_payoutLookup = new Dictionary<int, Payout>();
|
||||
_payoutDescriptionOverride = new Dictionary<int, string>();
|
||||
|
||||
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<PaymentHistoryLineItem> GetAmountsPaid()
|
||||
{
|
||||
return null;
|
||||
List<PaymentHistoryLineItem> items = new List<PaymentHistoryLineItem>();
|
||||
|
||||
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<PaymentHistoryLineItem> items)
|
||||
|
||||
Reference in New Issue
Block a user