Browse Source

wip adjustment statuses

3.x
Andrew Wallo 6 months ago
parent
commit
7129426faa

+ 24
- 9
app/Filament/Forms/Components/CreateAccountSelect.php View File

46
         return $this;
46
         return $this;
47
     }
47
     }
48
 
48
 
49
+    public function getCategory(): ?AccountCategory
50
+    {
51
+        return $this->category;
52
+    }
53
+
54
+    public function getType(): ?AccountType
55
+    {
56
+        return $this->type;
57
+    }
58
+
59
+    public function includesArchived(): bool
60
+    {
61
+        return $this->includeArchived;
62
+    }
63
+
49
     protected function setUp(): void
64
     protected function setUp(): void
50
     {
65
     {
51
         parent::setUp();
66
         parent::setUp();
59
         $this->options(function () {
74
         $this->options(function () {
60
             $query = Account::query();
75
             $query = Account::query();
61
 
76
 
62
-            if ($this->category) {
63
-                $query->where('category', $this->category);
77
+            if ($this->getCategory()) {
78
+                $query->where('category', $this->getCategory());
64
             }
79
             }
65
 
80
 
66
-            if ($this->type) {
67
-                $query->where('type', $this->type);
81
+            if ($this->getType()) {
82
+                $query->where('type', $this->getType());
68
             }
83
             }
69
 
84
 
70
-            if (! $this->includeArchived) {
85
+            if (! $this->includesArchived()) {
71
                 $query->where('archived', false);
86
                 $query->where('archived', false);
72
             }
87
             }
73
 
88
 
101
                 ->options(function () {
116
                 ->options(function () {
102
                     $query = AccountSubtype::query()->orderBy('name');
117
                     $query = AccountSubtype::query()->orderBy('name');
103
 
118
 
104
-                    if ($this->category) {
105
-                        $query->where('category', $this->category);
119
+                    if ($this->getCategory()) {
120
+                        $query->where('category', $this->getCategory());
106
                     }
121
                     }
107
 
122
 
108
-                    if ($this->type) {
109
-                        $query->where('type', $this->type);
123
+                    if ($this->getType()) {
124
+                        $query->where('type', $this->getType());
110
 
125
 
111
                         return $query->pluck('name', 'id')
126
                         return $query->pluck('name', 'id')
112
                             ->toArray();
127
                             ->toArray();

+ 23
- 4
app/Filament/Forms/Components/CreateAdjustmentSelect.php View File

5
 use App\Enums\Accounting\AdjustmentCategory;
5
 use App\Enums\Accounting\AdjustmentCategory;
6
 use App\Enums\Accounting\AdjustmentComputation;
6
 use App\Enums\Accounting\AdjustmentComputation;
7
 use App\Enums\Accounting\AdjustmentScope;
7
 use App\Enums\Accounting\AdjustmentScope;
8
+use App\Enums\Accounting\AdjustmentStatus;
8
 use App\Enums\Accounting\AdjustmentType;
9
 use App\Enums\Accounting\AdjustmentType;
9
 use App\Models\Accounting\Adjustment;
10
 use App\Models\Accounting\Adjustment;
10
 use Filament\Forms\Components\Actions\Action;
11
 use Filament\Forms\Components\Actions\Action;
25
 
26
 
26
     protected ?AdjustmentType $type = null;
27
     protected ?AdjustmentType $type = null;
27
 
28
 
29
+    protected bool $includeInactive = false;
30
+
28
     public function category(AdjustmentCategory $category): static
31
     public function category(AdjustmentCategory $category): static
29
     {
32
     {
30
         $this->category = $category;
33
         $this->category = $category;
39
         return $this;
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
     public function getCategory(): ?AdjustmentCategory
52
     public function getCategory(): ?AdjustmentCategory
43
     {
53
     {
44
         return $this->category;
54
         return $this->category;
49
         return $this->type;
59
         return $this->type;
50
     }
60
     }
51
 
61
 
62
+    public function includesInactive(): bool
63
+    {
64
+        return $this->includeInactive;
65
+    }
66
+
52
     protected function setUp(): void
67
     protected function setUp(): void
53
     {
68
     {
54
         parent::setUp();
69
         parent::setUp();
63
             name: 'adjustments',
78
             name: 'adjustments',
64
             titleAttribute: 'name',
79
             titleAttribute: 'name',
65
             modifyQueryUsing: function (Builder $query) {
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
                 return $query->orderBy('name');
93
                 return $query->orderBy('name');

+ 2
- 2
app/Providers/Filament/CompanyPanelProvider.php View File

135
                             ->label('Sales')
135
                             ->label('Sales')
136
                             ->icon('heroicon-o-currency-dollar')
136
                             ->icon('heroicon-o-currency-dollar')
137
                             ->items([
137
                             ->items([
138
+                                ...ClientResource::getNavigationItems(),
139
+                                ...EstimateResource::getNavigationItems(),
138
                                 ...InvoiceResource::getNavigationItems(),
140
                                 ...InvoiceResource::getNavigationItems(),
139
                                 ...RecurringInvoiceResource::getNavigationItems(),
141
                                 ...RecurringInvoiceResource::getNavigationItems(),
140
-                                ...EstimateResource::getNavigationItems(),
141
-                                ...ClientResource::getNavigationItems(),
142
                             ]),
142
                             ]),
143
                         NavigationGroup::make('Purchases')
143
                         NavigationGroup::make('Purchases')
144
                             ->label('Purchases')
144
                             ->label('Purchases')

Loading…
Cancel
Save