|
@@ -5,6 +5,7 @@ namespace App\Filament\Forms\Components;
|
5
|
5
|
use App\Enums\Accounting\AdjustmentCategory;
|
6
|
6
|
use App\Enums\Accounting\AdjustmentComputation;
|
7
|
7
|
use App\Enums\Accounting\AdjustmentScope;
|
|
8
|
+use App\Enums\Accounting\AdjustmentStatus;
|
8
|
9
|
use App\Enums\Accounting\AdjustmentType;
|
9
|
10
|
use App\Models\Accounting\Adjustment;
|
10
|
11
|
use Filament\Forms\Components\Actions\Action;
|
|
@@ -25,6 +26,8 @@ class CreateAdjustmentSelect extends Select
|
25
|
26
|
|
26
|
27
|
protected ?AdjustmentType $type = null;
|
27
|
28
|
|
|
29
|
+ protected bool $includeInactive = false;
|
|
30
|
+
|
28
|
31
|
public function category(AdjustmentCategory $category): static
|
29
|
32
|
{
|
30
|
33
|
$this->category = $category;
|
|
@@ -39,6 +42,13 @@ class CreateAdjustmentSelect extends Select
|
39
|
42
|
return $this;
|
40
|
43
|
}
|
41
|
44
|
|
|
45
|
+ public function includeInactive(bool $includeInactive = true): static
|
|
46
|
+ {
|
|
47
|
+ $this->includeInactive = $includeInactive;
|
|
48
|
+
|
|
49
|
+ return $this;
|
|
50
|
+ }
|
|
51
|
+
|
42
|
52
|
public function getCategory(): ?AdjustmentCategory
|
43
|
53
|
{
|
44
|
54
|
return $this->category;
|
|
@@ -49,6 +59,11 @@ class CreateAdjustmentSelect extends Select
|
49
|
59
|
return $this->type;
|
50
|
60
|
}
|
51
|
61
|
|
|
62
|
+ public function includesInactive(): bool
|
|
63
|
+ {
|
|
64
|
+ return $this->includeInactive;
|
|
65
|
+ }
|
|
66
|
+
|
52
|
67
|
protected function setUp(): void
|
53
|
68
|
{
|
54
|
69
|
parent::setUp();
|
|
@@ -63,12 +78,16 @@ class CreateAdjustmentSelect extends Select
|
63
|
78
|
name: 'adjustments',
|
64
|
79
|
titleAttribute: 'name',
|
65
|
80
|
modifyQueryUsing: function (Builder $query) {
|
66
|
|
- if ($this->category) {
|
67
|
|
- $query->where('category', $this->category);
|
|
81
|
+ if ($this->getCategory()) {
|
|
82
|
+ $query->where('category', $this->getCategory());
|
|
83
|
+ }
|
|
84
|
+
|
|
85
|
+ if ($this->getType()) {
|
|
86
|
+ $query->where('type', $this->getType());
|
68
|
87
|
}
|
69
|
88
|
|
70
|
|
- if ($this->type) {
|
71
|
|
- $query->where('type', $this->type);
|
|
89
|
+ if (! $this->includesInactive()) {
|
|
90
|
+ $query->where('status', AdjustmentStatus::Active);
|
72
|
91
|
}
|
73
|
92
|
|
74
|
93
|
return $query->orderBy('name');
|