72 lines
2.0 KiB
C#
72 lines
2.0 KiB
C#
using System.Collections.Generic;
|
|
using AAIntegration.SimmonsBank.API.Services;
|
|
|
|
namespace AAIntegration.SimmonsBank.API.Entities;
|
|
|
|
public class Transaction
|
|
{
|
|
public int Id { get; set; }
|
|
public DateTime Date { get; set; }
|
|
public DateTime CreatedOn { get; set; }
|
|
public DateTime UpdatedOn { get; set; }
|
|
public string ExternalId { get; set; }
|
|
public string Description { get; set; }
|
|
public Account? DebitAccount { get; set; }
|
|
public Account? CreditAccount { get; set; }
|
|
public Envelope? DebitEnvelope { get; set; }
|
|
public Envelope? CreditEnvelope { get; set; }
|
|
public bool IsEnvelopeFundingTransaction { get; set; }
|
|
public decimal Amount { get; set; }
|
|
public CurrencyType CurrencyType { get; set; }
|
|
public string Notes { get; set; }
|
|
public bool IsPending { get; set; }
|
|
public List<string>? Tags { get; set; }
|
|
}
|
|
|
|
public static class TransactionExtensions
|
|
{
|
|
public static bool HasTag(this Transaction transaction, string tag)
|
|
{
|
|
return transaction.Tags != null && transaction.Tags.Any(t => t.ToUpper() == tag.ToUpper());
|
|
}
|
|
|
|
public static Transaction AddTag(this Transaction transaction, string tag)
|
|
{
|
|
if (transaction.Tags == null)
|
|
transaction.Tags = new List<string>() { tag };
|
|
else if (transaction.Tags.Any(t => t.ToUpper() == tag.ToUpper()) == false)
|
|
transaction.Tags.Add(tag);
|
|
|
|
return transaction;
|
|
}
|
|
|
|
public static Transaction RemoveTag(this Transaction transaction, string tag)
|
|
{
|
|
if (transaction.Tags != null)
|
|
{
|
|
string? actualTag = transaction.Tags
|
|
.Where(t => t.ToUpper() == tag.ToUpper())
|
|
.FirstOrDefault();
|
|
|
|
if (actualTag != null)
|
|
transaction.Tags.Remove(actualTag);
|
|
}
|
|
|
|
return transaction;
|
|
}
|
|
}
|
|
|
|
public enum AutoclassTransactionField
|
|
{
|
|
DATE,
|
|
EXTERNAL_ID,
|
|
DESCRIPTION,
|
|
DEBIT_ACCOUNT,
|
|
CREDIT_ACCOUNT,
|
|
DEBIT_ENVELOPE,
|
|
CREDIT_ENVELOPE,
|
|
AMOUNT,
|
|
CURRENCY_TYPE,
|
|
IS_PENDING,
|
|
TAGS
|
|
} |