mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 14:37:16 +00:00
wip
This commit is contained in:
105
src/bnhtrade.Core/Model/Stock/StockJournal.cs
Normal file
105
src/bnhtrade.Core/Model/Stock/StockJournal.cs
Normal 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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
src/bnhtrade.Core/Model/Stock/StockJournalType.cs
Normal file
12
src/bnhtrade.Core/Model/Stock/StockJournalType.cs
Normal 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
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user