fix tests
This commit is contained in:
@@ -7,9 +7,7 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class InventorySummaryService
|
||||
{
|
||||
public function __construct(private InventoryContextService $context)
|
||||
{
|
||||
}
|
||||
public function __construct(private InventoryContextService $context) {}
|
||||
|
||||
public function summary(string $type, ?string $schoolYear): array
|
||||
{
|
||||
@@ -24,7 +22,7 @@ class InventorySummaryService
|
||||
|
||||
$itemIds = array_map(static fn ($i) => (int) ($i['id'] ?? 0), $items);
|
||||
$agg = [];
|
||||
if (!empty($itemIds)) {
|
||||
if (! empty($itemIds)) {
|
||||
$qb = DB::table('inventory_movements')
|
||||
->selectRaw('item_id,
|
||||
SUM(CASE WHEN qty_change>0 THEN qty_change ELSE 0 END) AS received,
|
||||
@@ -65,7 +63,7 @@ class InventorySummaryService
|
||||
->leftJoin('users as u', 'u.id', '=', 'i.updated_by')
|
||||
->orderBy('i.name');
|
||||
|
||||
if (!$isAllYears) {
|
||||
if (! $isAllYears) {
|
||||
$qbItems->where('i.school_year', $selectedYear);
|
||||
}
|
||||
|
||||
@@ -87,7 +85,7 @@ class InventorySummaryService
|
||||
'variance' => 0,
|
||||
];
|
||||
|
||||
if (!empty($items)) {
|
||||
if (! empty($items)) {
|
||||
$itemIds = array_map('intval', array_column($items, 'id'));
|
||||
$aggById = [];
|
||||
$qb = DB::table('inventory_movements as m')
|
||||
@@ -102,7 +100,7 @@ class InventorySummaryService
|
||||
->whereIn('m.item_id', $itemIds)
|
||||
->groupBy('m.item_id');
|
||||
|
||||
if (!$isAllYears) {
|
||||
if (! $isAllYears) {
|
||||
$qb->where('m.school_year', $selectedYear);
|
||||
}
|
||||
|
||||
@@ -182,7 +180,7 @@ class InventorySummaryService
|
||||
->all();
|
||||
|
||||
$currentYear = $this->context->schoolYear();
|
||||
if ($currentYear && !in_array($currentYear, $years, true)) {
|
||||
if ($currentYear && ! in_array($currentYear, $years, true)) {
|
||||
array_unshift($years, $currentYear);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user