using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace Fitness_core_BE.Models { /// Stock coming in, optionally from a Supplier -- some GRNs don't have one (e.g. /// self-produced stock, or the supplier just isn't on file). Creating one increments each /// line's Product.QuantityOnHand and overwrites Product.CostPrice with that line's UnitCost /// (a simple latest-cost approach, not a weighted average). public class GoodsReceivedNote { [Key] public Guid GrnId { get; set; } public Guid FKClientId { get; set; } [ForeignKey(nameof(FKClientId))] public Client Client { get; set; } public Guid? FKSupplierId { get; set; } [ForeignKey(nameof(FKSupplierId))] public Supplier? Supplier { get; set; } [MaxLength(32)] public string GrnNumber { get; set; } = string.Empty; public DateTime ReceivedAt { get; set; } = DateTime.UtcNow; [MaxLength(300)] public string? Notes { get; set; } public decimal TotalAmount { get; set; } = 0m; public DateTime CreatedAt { get; set; } = DateTime.UtcNow; public virtual ICollection Items { get; set; } = new List(); } public class GoodsReceivedNoteItem { [Key] public Guid GrnItemId { get; set; } public Guid FKGrnId { get; set; } [ForeignKey(nameof(FKGrnId))] public GoodsReceivedNote? Grn { get; set; } public Guid FKProductId { get; set; } [ForeignKey(nameof(FKProductId))] public Product? Product { get; set; } public decimal Quantity { get; set; } public decimal UnitCost { get; set; } public decimal LineTotal { get; set; } } }