diff --git a/src/bnhtrade.Core/Model/Stock/StockJournal.cs b/src/bnhtrade.Core/Model/Stock/StockJournal.cs new file mode 100644 index 0000000..8627a67 --- /dev/null +++ b/src/bnhtrade.Core/Model/Stock/StockJournal.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace bnhtrade.Core.Model.Stock +{ + public class StockJournal : IValidatableObject + { + public StockJournal(int stockJournalId, StockJournalType stockJournalType, int stockId, int stockNumber, DateTime entryDate, DateTime postDate, DateTime lastModified, bool isLocked, List journalPosts) + { + StockJournalId = stockJournalId; + StockJournalType = stockJournalType; + StockId = stockId; + StockNumber = stockNumber; + EntryDate = entryDate; + PostDate = postDate; + LastModified = lastModified; + IsLocked = isLocked; + JournalPosts = journalPosts ?? throw new ArgumentNullException(nameof(journalPosts), "Journal posts cannot be null."); + } + + public int StockJournalId { get; } + + public StockJournalType StockJournalType { get; } + + public int StockId { get; } + + public int StockNumber { get; } + + public DateTime EntryDate { get; } + + public DateTime PostDate { get; } + + public DateTime LastModified { get; } + + public bool IsLocked { get; } + + public List JournalPosts { get; } + + public class JournalPost + { + public JournalPost(int journalPostId, Status status, int quantity) + { + JournalPostId = journalPostId; + Status = status; + Quantity = quantity; + } + + public int JournalPostId { get; } + + [Required()] + public Status Status { get; } + + [Required()] + public int Quantity { get; } + + public bool IsCredit + { + get + { + if (Quantity < 0) + { + return true; + } + else if (Quantity > 0) + { + return false; + } + else + { + throw new InvalidOperationException("Quantity cannot be zero for a journal post."); + } + } + } + + public bool IsDebit + { + get + { + if (Quantity > 0) + { + return true; + } + else if (Quantity < 0) + { + return false; + } + else + { + throw new InvalidOperationException("Quantity cannot be zero for a journal post."); + } + } + } + } + + public IEnumerable Validate(ValidationContext validationContext) + { + throw new NotImplementedException(); + } + + } +} diff --git a/src/bnhtrade.Core/Model/Stock/StockJournalType.cs b/src/bnhtrade.Core/Model/Stock/StockJournalType.cs new file mode 100644 index 0000000..4821394 --- /dev/null +++ b/src/bnhtrade.Core/Model/Stock/StockJournalType.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace bnhtrade.Core.Model.Stock +{ + public class StockJournalType + { + } +}