using System;
using SQLite.Net.Attributes;
using SQLiteNetExtensions.Attributes;
namespace DebtMgr.Model
{
////////////////////////////////////////////////////////////////////////////////////////////////////
/// A transaction.
///
/// Andre Beging, 10.09.2017.
////////////////////////////////////////////////////////////////////////////////////////////////////
public class Transaction
{
#region Id
[PrimaryKey]
public Guid Id { get; set; } = Guid.NewGuid();
#endregion
#region Person Relation
[ForeignKey(typeof(Person))]
public Guid PersonId { get; set; }
[ManyToOne]
public Person Person { get; set; }
#endregion
#region Description
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Gets or sets the description.
///
/// The description.
////////////////////////////////////////////////////////////////////////////////////////////////////
public string Description { get; set; }
#endregion
#region Type
////////////////////////////////////////////////////////////////////////////////////////////////////
/// Gets or sets the type.
///
/// The type.
////////////////////////////////////////////////////////////////////////////////////////////////////
public TransactionType Type
{
get
{
if (!string.IsNullOrWhiteSpace(StringType))
{
return (TransactionType)Enum.Parse(typeof(TransactionType), StringType);
}
return TransactionType.None;
}
set { StringType = value.ToString(); }
}
public string StringType;
#endregion
#region Time
public DateTime Time { get; set; }
#endregion
#region Amount
public double Amount { get; set; }
#endregion
#region SignedAmount
[Ignore]
public double SignedAmount
{
get
{
if (Type == TransactionType.Charge) return Amount * -1;
return Amount;
}
}
#endregion
}
}