86 lines
2.4 KiB
C#
86 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Swarmops.Basic.Enums;
|
|
using Swarmops.Basic.Types.Financial;
|
|
|
|
namespace Swarmops.Logic.Financial
|
|
{
|
|
public class FinancialTransactionRows : List<FinancialTransactionRow>
|
|
{
|
|
[Obsolete("Do not use. Use AmountCentsTotal.", true)]
|
|
public decimal AmountTotal
|
|
{
|
|
get
|
|
{
|
|
decimal result = 0.0m;
|
|
|
|
foreach (FinancialTransactionRow row in this)
|
|
{
|
|
result += row.Amount;
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public Int64 AmountCentsTotal
|
|
{
|
|
get
|
|
{
|
|
Int64 result = 0;
|
|
|
|
foreach (FinancialTransactionRow row in this)
|
|
{
|
|
result += row.AmountCents;
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
[Obsolete("Do not use. Use Int64 BalanceCentsDelta.", true)]
|
|
public decimal BalanceDelta
|
|
{
|
|
get
|
|
{
|
|
decimal result = 0.0m;
|
|
|
|
foreach (FinancialTransactionRow row in this)
|
|
{
|
|
if (row.Account.AccountType == FinancialAccountType.Asset || row.Account.AccountType == FinancialAccountType.Debt)
|
|
{
|
|
result += row.Amount;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public long BalanceCentsDelta
|
|
{
|
|
get
|
|
{
|
|
Int64 result = 0;
|
|
|
|
foreach (FinancialTransactionRow row in this)
|
|
{
|
|
if (row.Account.AccountType == FinancialAccountType.Asset || row.Account.AccountType == FinancialAccountType.Debt)
|
|
{
|
|
result += row.AmountCents;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public static FinancialTransactionRows FromArray(BasicFinancialTransactionRow[] basicArray)
|
|
{
|
|
var result = new FinancialTransactionRows {Capacity = (basicArray.Length*11/10)};
|
|
|
|
foreach (BasicFinancialTransactionRow basic in basicArray)
|
|
{
|
|
result.Add (FinancialTransactionRow.FromBasic (basic));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
} |