2026-01-26 14:59:24 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Modules\Inventory\Contracts;
|
|
|
|
|
|
|
|
|
|
interface InventoryServiceInterface
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Check if a product has sufficient stock in a specific warehouse.
|
|
|
|
|
*
|
|
|
|
|
* @param int $productId
|
|
|
|
|
* @param int $warehouseId
|
|
|
|
|
* @param float $quantity
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function checkStock(int $productId, int $warehouseId, float $quantity): bool;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Decrease stock for a product (e.g., when an order is placed).
|
|
|
|
|
*
|
|
|
|
|
* @param int $productId
|
|
|
|
|
* @param int $warehouseId
|
|
|
|
|
* @param float $quantity
|
|
|
|
|
* @param string|null $reason
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function decreaseStock(int $productId, int $warehouseId, float $quantity, ?string $reason = null): void;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get all active warehouses.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Support\Collection
|
|
|
|
|
*/
|
|
|
|
|
public function getAllWarehouses();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get multiple products by their IDs.
|
|
|
|
|
*
|
|
|
|
|
* @param array $ids
|
|
|
|
|
* @return \Illuminate\Support\Collection
|
|
|
|
|
*/
|
|
|
|
|
public function getProductsByIds(array $ids);
|
|
|
|
|
|
2026-01-27 08:59:45 +08:00
|
|
|
/**
|
|
|
|
|
* Search products by name.
|
|
|
|
|
*
|
|
|
|
|
* @param string $name
|
|
|
|
|
* @return \Illuminate\Support\Collection
|
|
|
|
|
*/
|
|
|
|
|
public function getProductsByName(string $name);
|
|
|
|
|
|
2026-01-26 14:59:24 +08:00
|
|
|
/**
|
|
|
|
|
* Get a specific product by ID.
|
|
|
|
|
*
|
|
|
|
|
* @param int $id
|
|
|
|
|
* @return object|null
|
|
|
|
|
*/
|
|
|
|
|
public function getProduct(int $id);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a specific warehouse by ID.
|
|
|
|
|
*
|
|
|
|
|
* @param int $id
|
|
|
|
|
* @return object|null
|
|
|
|
|
*/
|
|
|
|
|
public function getWarehouse(int $id);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get all available inventories in a specific warehouse.
|
|
|
|
|
*
|
|
|
|
|
* @param int $warehouseId
|
|
|
|
|
* @return \Illuminate\Support\Collection
|
|
|
|
|
*/
|
|
|
|
|
public function getInventoriesByWarehouse(int $warehouseId);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get all products.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Support\Collection
|
|
|
|
|
*/
|
|
|
|
|
public function getAllProducts();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get all units.
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Support\Collection
|
|
|
|
|
*/
|
|
|
|
|
public function getUnits();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new inventory record (e.g., for finished goods).
|
|
|
|
|
*
|
|
|
|
|
* @param array $data
|
|
|
|
|
* @return object
|
|
|
|
|
*/
|
|
|
|
|
public function createInventoryRecord(array $data);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Decrease quantity of a specific inventory record.
|
|
|
|
|
*
|
|
|
|
|
* @param int $inventoryId
|
|
|
|
|
* @param float $quantity
|
|
|
|
|
* @param string|null $reason
|
|
|
|
|
* @param string|null $referenceType
|
|
|
|
|
* @param int|string|null $referenceId
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function decreaseInventoryQuantity(int $inventoryId, float $quantity, ?string $reason = null, ?string $referenceType = null, $referenceId = null);
|
2026-01-27 08:59:45 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get statistics for the dashboard.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getDashboardStats(): array;
|
2026-01-26 14:59:24 +08:00
|
|
|
}
|