This commit is contained in:
2025-07-10 20:26:11 +01:00
parent 7a28e2cc66
commit be9944f066
2 changed files with 117 additions and 0 deletions

View File

@@ -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<JournalPost> 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<JournalPost> 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<ValidationResult> Validate(ValidationContext validationContext)
{
throw new NotImplementedException();
}
}
}

View File

@@ -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
{
}
}