Files
bnhtrade/src/bnhtrade.Core/Model/Account/Journal.cs
T

65 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace bnhtrade.Core.Model.Account
{
public class Journal : IValidatableObject
{
internal Journal(int journalId, Core.Model.Account.JournalType type, List<Post> posts, DateTime entryDate, DateTime postDate, DateTime lastModifed, bool isLocked)
{
JournalId = journalId;
Type = type;
Posts = posts;
EntryDate = entryDate;
PostDate = postDate;
LastModified = lastModifed;
IsLocked = isLocked;
}
public int JournalId { get; private set; }
public Core.Model.Account.JournalType Type { get; private set; }
public List<Post> Posts { get; private set; } = new List<Post>();
public DateTime EntryDate { get; private set; }
public DateTime PostDate { get; private set; }
public DateTime LastModified { get;private set; }
public bool IsLocked { get; private set; }
public class Post
{
internal Post(int postId, Core.Model.Account.Account account, decimal amountGbp)
{
PostId = postId;
Account = account;
AmountGbp = amountGbp;
}
public int PostId { get; private set; }
public Core.Model.Account.Account Account { get; private set; }
public decimal AmountGbp { get; private set; }
}
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
var result = new List<ValidationResult>();
// get total of posts
decimal postTotal = 0;
foreach (var post in Posts)
{
postTotal = postTotal + post.AmountGbp;
}
if (postTotal != 0)
{
result.Add(new ValidationResult("Account journal posts do not equal zero"));
}
throw new NotImplementedException();
return result;
}
}
}