浏览代码

wip adjustment statuses

3.x
Andrew Wallo 6 个月前
父节点
当前提交
7129426faa

+ 24
- 9
app/Filament/Forms/Components/CreateAccountSelect.php 查看文件

@@ -46,6 +46,21 @@ class CreateAccountSelect extends Select
46 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 64
     protected function setUp(): void
50 65
     {
51 66
         parent::setUp();
@@ -59,15 +74,15 @@ class CreateAccountSelect extends Select
59 74
         $this->options(function () {
60 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 86
                 $query->where('archived', false);
72 87
             }
73 88
 
@@ -101,12 +116,12 @@ class CreateAccountSelect extends Select
101 116
                 ->options(function () {
102 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 126
                         return $query->pluck('name', 'id')
112 127
                             ->toArray();

+ 23
- 4
app/Filament/Forms/Components/CreateAdjustmentSelect.php 查看文件

@@ -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');

+ 2
- 2
app/Providers/Filament/CompanyPanelProvider.php 查看文件

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

正在加载...
取消
保存