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,44 @@
|
||||
using Fitness_core_BE.Models;
|
||||
|
||||
namespace Fitness_core_BE.Interfaces
|
||||
{
|
||||
public interface IInventoryRepository
|
||||
{
|
||||
// Products
|
||||
Task<List<Product>> GetProducts(Guid clientId, bool includeInactive = false);
|
||||
Task<Product?> GetProductById(Guid productId);
|
||||
Task<Product> CreateProduct(Product product);
|
||||
Task<Product> UpdateProduct(Product product);
|
||||
/// <summary>Next sequential number for this client, e.g. 3 -> "PRD-0004" -- Sku is
|
||||
/// system-generated, never user-entered.</summary>
|
||||
Task<int> GetNextProductSequence(Guid clientId);
|
||||
|
||||
// Product detail page: stock-movement history (GRN-in, Sale-out, Return-out).
|
||||
Task<List<GoodsReceivedNoteItem>> GetGrnItemsForProduct(Guid productId);
|
||||
Task<List<SaleItem>> GetSaleItemsForProduct(Guid productId);
|
||||
Task<List<StockReturn>> GetStockReturnsForProduct(Guid productId);
|
||||
|
||||
// Suppliers
|
||||
Task<List<Supplier>> GetSuppliers(Guid clientId, bool includeInactive = false);
|
||||
Task<Supplier?> GetSupplierById(Guid supplierId);
|
||||
Task<Supplier> CreateSupplier(Supplier supplier);
|
||||
|
||||
// GRN
|
||||
Task<GoodsReceivedNote> CreateGrn(GoodsReceivedNote grn);
|
||||
Task<List<GoodsReceivedNote>> GetGrns(Guid clientId);
|
||||
Task<GoodsReceivedNote?> GetGrnById(Guid grnId);
|
||||
/// <summary>Next sequential number for this client, e.g. 3 -> "GRN-0004".</summary>
|
||||
Task<int> GetNextGrnSequence(Guid clientId);
|
||||
|
||||
// Sales
|
||||
Task<Sale> CreateSale(Sale sale);
|
||||
Task<List<Sale>> GetSales(Guid clientId);
|
||||
Task<Sale?> GetSaleById(Guid saleId);
|
||||
Task<int> GetNextSaleSequence(Guid clientId);
|
||||
|
||||
// Returns
|
||||
Task<StockReturn> CreateStockReturn(StockReturn stockReturn);
|
||||
Task<List<StockReturn>> GetStockReturns(Guid clientId);
|
||||
Task<StockReturn?> GetStockReturnById(Guid stockReturnId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace Fitness_core_BE.Interfaces.Services
|
||||
{
|
||||
public interface IInventoryService
|
||||
{
|
||||
Task<object> GetProducts(object payload, HttpContext httpContext);
|
||||
Task<object> GetProductById(object payload, HttpContext httpContext);
|
||||
Task<object> CreateProduct(object payload, HttpContext httpContext);
|
||||
Task<object> UpdateProduct(object payload, HttpContext httpContext);
|
||||
Task<object> UploadProductImage(Guid productId, IFormFile image, HttpContext httpContext);
|
||||
|
||||
Task<object> GetSuppliers(object payload, HttpContext httpContext);
|
||||
Task<object> CreateSupplier(object payload, HttpContext httpContext);
|
||||
|
||||
Task<object> CreateGrn(object payload, HttpContext httpContext);
|
||||
Task<object> GetGrns(object payload, HttpContext httpContext);
|
||||
Task<object> GetGrnById(object payload, HttpContext httpContext);
|
||||
|
||||
Task<object> CreateSale(object payload, HttpContext httpContext);
|
||||
Task<object> GetSales(object payload, HttpContext httpContext);
|
||||
Task<object> GetSaleById(object payload, HttpContext httpContext);
|
||||
|
||||
Task<object> CreateStockReturn(object payload, HttpContext httpContext);
|
||||
Task<object> GetStockReturns(object payload, HttpContext httpContext);
|
||||
Task<object> GetStockReturnById(object payload, HttpContext httpContext);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user