Add inventory management features including Sales, Stock Returns, and Suppliers
- 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.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Fitness_core_BE.Models
|
||||
{
|
||||
/// <summary>Stock going out to a customer. Creating one decrements each line's
|
||||
/// Product.QuantityOnHand -- the whole sale is rejected up front if any line would go
|
||||
/// negative (no backorders).</summary>
|
||||
public class Sale
|
||||
{
|
||||
[Key]
|
||||
public Guid SaleId { get; set; }
|
||||
|
||||
public Guid FKClientId { get; set; }
|
||||
[ForeignKey(nameof(FKClientId))]
|
||||
public Client Client { get; set; }
|
||||
|
||||
[MaxLength(32)]
|
||||
public string SaleNumber { get; set; } = string.Empty;
|
||||
|
||||
public DateTime SoldAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
/// <summary>"Cash" | "Bank" -- same convention as Booking.PaymentMethod.</summary>
|
||||
[MaxLength(20)]
|
||||
public string PaymentMethod { get; set; } = "Cash";
|
||||
|
||||
/// <summary>Optional link to a registered member, purely for identification -- mirrors
|
||||
/// Booking.FKCustomerId (see BookingService.ResolveOptionalCustomerLinkAsync). A walk-in
|
||||
/// buyer leaves this null and uses CustomerName instead.</summary>
|
||||
public Guid? FKCustomerId { get; set; }
|
||||
|
||||
[MaxLength(128)]
|
||||
public string? CustomerName { get; set; }
|
||||
|
||||
public decimal TotalAmount { get; set; } = 0m;
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public virtual ICollection<SaleItem> Items { get; set; } = new List<SaleItem>();
|
||||
}
|
||||
|
||||
public class SaleItem
|
||||
{
|
||||
[Key]
|
||||
public Guid SaleItemId { get; set; }
|
||||
|
||||
public Guid FKSaleId { get; set; }
|
||||
[ForeignKey(nameof(FKSaleId))]
|
||||
public Sale? Sale { get; set; }
|
||||
|
||||
public Guid FKProductId { get; set; }
|
||||
[ForeignKey(nameof(FKProductId))]
|
||||
public Product? Product { get; set; }
|
||||
|
||||
public decimal Quantity { get; set; }
|
||||
public decimal UnitPrice { get; set; }
|
||||
public decimal LineTotal { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user