2eb88b058e
- Implement Sale and SaleItem models for tracking sales transactions. - Create StockReturn model to manage stock adjustments for various reasons. - Introduce Supplier model to represent suppliers of products. - Develop InventoryRepository for CRUD operations on products, suppliers, sales, and stock returns. - Implement InventoryService to handle business logic for inventory management. - Update TenantDbContext to include new models and relationships. - Enhance ProfitLossRepository to account for sales, purchases, and stock returns in profit and loss calculations. - Modify Program.cs to register new inventory-related services.
56 lines
1.8 KiB
C#
56 lines
1.8 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace Fitness_core_BE.Models
|
|
{
|
|
/// <summary>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).</summary>
|
|
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<GoodsReceivedNoteItem> Items { get; set; } = new List<GoodsReceivedNoteItem>();
|
|
}
|
|
|
|
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; }
|
|
}
|
|
}
|