feat: phase 3 — stock balances, restock/adjust mutations with activity logging, movements page
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Services\InsForge\InsForgeTableService;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
|
||||
class StockMovementService extends InsForgeTableService
|
||||
{
|
||||
public const TYPES = ['restock', 'adjustment', 'order_out'];
|
||||
|
||||
protected function table(): string
|
||||
{
|
||||
return 'stock_movements';
|
||||
}
|
||||
|
||||
protected function select(): string
|
||||
{
|
||||
return '*,products(code,name)';
|
||||
}
|
||||
|
||||
protected function searchableColumns(): array
|
||||
{
|
||||
return ['notes', 'type'];
|
||||
}
|
||||
|
||||
protected function sortableColumns(): array
|
||||
{
|
||||
return ['created_at', 'quantity', 'type'];
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $filters */
|
||||
public function paginate(
|
||||
?string $search = null,
|
||||
?string $sortColumn = null,
|
||||
?string $sortDirection = null,
|
||||
int $page = 1,
|
||||
int $perPage = 25,
|
||||
array $filters = [],
|
||||
): LengthAwarePaginator {
|
||||
$extra = array_intersect_key($filters, array_flip(['type', 'product_id']));
|
||||
|
||||
return parent::paginate($search, $sortColumn, $sortDirection, $page, $perPage, $extra);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user