Selaa lähdekoodia

feat: make DateRangeSelect.php

3.x
wallo 1 vuosi sitten
vanhempi
commit
c44b5fd762

+ 61
- 52
app/Filament/Company/Pages/Accounting/Transactions.php Näytä tiedosto

@@ -9,6 +9,7 @@ use App\Enums\Accounting\TransactionType;
9 9
 use App\Enums\Setting\DateFormat;
10 10
 use App\Facades\Accounting;
11 11
 use App\Filament\Company\Pages\Service\ConnectedAccount;
12
+use App\Forms\Components\DateRangeSelect;
12 13
 use App\Forms\Components\JournalEntryRepeater;
13 14
 use App\Models\Accounting\Account;
14 15
 use App\Models\Accounting\Transaction;
@@ -16,6 +17,7 @@ use App\Models\Banking\BankAccount;
16 17
 use App\Models\Company;
17 18
 use App\Models\Setting\Localization;
18 19
 use Awcodes\TableRepeater\Header;
20
+use Exception;
19 21
 use Filament\Actions;
20 22
 use Filament\Facades\Filament;
21 23
 use Filament\Forms;
@@ -194,6 +196,9 @@ class Transactions extends Page implements HasTable
194 196
             ->columns(1);
195 197
     }
196 198
 
199
+    /**
200
+     * @throws Exception
201
+     */
197 202
     public function table(Table $table): Table
198 203
     {
199 204
         return $table
@@ -261,48 +266,6 @@ class Transactions extends Page implements HasTable
261 266
                             ->extraAttributes([
262 267
                                 'class' => 'border-b border-gray-200 dark:border-white/10 pb-8',
263 268
                             ]),
264
-                        Grid::make()
265
-                            ->schema([
266
-                                Select::make('posted_at_date_range')
267
-                                    ->label('Posted Date')
268
-                                    ->placeholder('Select a date range')
269
-                                    ->options([
270
-                                        'all' => 'All Dates', // Handle this later
271
-                                        'custom' => 'Custom Date Range',
272
-                                    ]),
273
-                                DatePicker::make('posted_at_start_date')
274
-                                    ->label('Posted From')
275
-                                    ->displayFormat('Y-m-d')
276
-                                    ->columnStart(1),
277
-                                DatePicker::make('posted_at_end_date')
278
-                                    ->label('Posted To')
279
-                                    ->displayFormat('Y-m-d'),
280
-                                TextInput::make('posted_at_combined_dates')
281
-                                    ->hidden(),
282
-                            ])
283
-                            ->extraAttributes([
284
-                                'class' => 'border-b border-gray-200 dark:border-white/10 pb-8',
285
-                            ]),
286
-                        Grid::make()
287
-                            ->schema([
288
-                                Select::make('updated_at_date_range')
289
-                                    ->label('Last Modified Date')
290
-                                    ->placeholder('Select a date range')
291
-                                    ->options([
292
-                                        'all' => 'All Dates', // Handle this later
293
-                                        'custom' => 'Custom Date Range',
294
-                                    ]),
295
-                                DatePicker::make('updated_at_start_date')
296
-                                    ->label('Last Modified From')
297
-                                    ->displayFormat('Y-m-d')
298
-                                    ->columnStart(1),
299
-                                DatePicker::make('updated_at_end_date')
300
-                                    ->label('Last Modified To')
301
-                                    ->displayFormat('Y-m-d'),
302
-                                TextInput::make('updated_at_combined_dates')
303
-                                    ->label('Updated Date Range')
304
-                                    ->hidden(),
305
-                            ]),
306 269
                     ])->query(function (Builder $query, array $data): Builder {
307 270
                         if (filled($data['reviewed'])) {
308 271
                             $reviewedStatus = $data['reviewed'] === '1';
@@ -311,11 +274,7 @@ class Transactions extends Page implements HasTable
311 274
 
312 275
                         $query
313 276
                             ->when($data['account_id'], fn (Builder $query, $accountIds) => $query->whereIn('account_id', $accountIds))
314
-                            ->when($data['type'], fn (Builder $query, $types) => $query->whereIn('type', $types))
315
-                            ->when($data['posted_at_start_date'], fn (Builder $query, $startDate) => $query->whereDate('posted_at', '>=', $startDate))
316
-                            ->when($data['posted_at_end_date'], fn (Builder $query, $endDate) => $query->whereDate('posted_at', '<=', $endDate))
317
-                            ->when($data['updated_at_start_date'], fn (Builder $query, $startDate) => $query->whereDate('updated_at', '>=', $startDate))
318
-                            ->when($data['updated_at_end_date'], fn (Builder $query, $endDate) => $query->whereDate('updated_at', '<=', $endDate));
277
+                            ->when($data['type'], fn (Builder $query, $types) => $query->whereIn('type', $types));
319 278
 
320 279
                         return $query;
321 280
                     })
@@ -325,11 +284,11 @@ class Transactions extends Page implements HasTable
325 284
                         $this->addIndicatorForSingleSelection($data, 'reviewed', $data['reviewed'] === '1' ? 'Reviewed' : 'Not Reviewed', $indicators);
326 285
                         $this->addMultipleSelectionIndicator($data, 'account_id', fn ($accountId) => Account::find($accountId)->name, 'account_id', $indicators);
327 286
                         $this->addMultipleSelectionIndicator($data, 'type', fn ($type) => TransactionType::parse($type)->getLabel(), 'type', $indicators);
328
-                        $this->addIndicatorForDateRange($data, 'posted_at_start_date', 'posted_at_end_date', 'Posted', 'posted_at_combined_dates', $indicators);
329
-                        $this->addIndicatorForDateRange($data, 'updated_at_start_date', 'updated_at_end_date', 'Last Modified', 'updated_at_combined_dates', $indicators);
330 287
 
331 288
                         return $indicators;
332 289
                     }),
290
+                $this->buildDateRangeFilter('posted_at', 'Posted', true),
291
+                $this->buildDateRangeFilter('updated_at', 'Last Modified'),
333 292
             ], layout: Tables\Enums\FiltersLayout::Modal)
334 293
             ->deferFilters()
335 294
             ->filtersFormColumns(2)
@@ -622,6 +581,56 @@ class Transactions extends Page implements HasTable
622 581
         );
623 582
     }
624 583
 
584
+    /**
585
+     * @throws Exception
586
+     */
587
+    protected function buildDateRangeFilter(string $fieldPrefix, string $label, bool $hasBottomBorder = false): Tables\Filters\Filter
588
+    {
589
+        return Tables\Filters\Filter::make($fieldPrefix)
590
+            ->columnSpanFull()
591
+            ->form([
592
+                Grid::make()
593
+                    ->live()
594
+                    ->schema([
595
+                        DateRangeSelect::make("{$fieldPrefix}_date_range")
596
+                            ->label($label)
597
+                            ->selectablePlaceholder(false)
598
+                            ->placeholder('Select a date range')
599
+                            ->startDateField("{$fieldPrefix}_start_date")
600
+                            ->endDateField("{$fieldPrefix}_end_date"),
601
+                        DatePicker::make("{$fieldPrefix}_start_date")
602
+                            ->label("{$label} From")
603
+                            ->displayFormat('Y-m-d')
604
+                            ->columnStart(1)
605
+                            ->afterStateUpdated(static function (Set $set) use ($fieldPrefix) {
606
+                                $set("{$fieldPrefix}_date_range", 'Custom');
607
+                            }),
608
+                        DatePicker::make("{$fieldPrefix}_end_date")
609
+                            ->label("{$label} To")
610
+                            ->displayFormat('Y-m-d')
611
+                            ->afterStateUpdated(static function (Set $set) use ($fieldPrefix) {
612
+                                $set("{$fieldPrefix}_date_range", 'Custom');
613
+                            }),
614
+                    ])
615
+                    ->extraAttributes($hasBottomBorder ? ['class' => 'border-b border-gray-200 dark:border-white/10 pb-8'] : []),
616
+            ])
617
+            ->query(function (Builder $query, array $data) use ($fieldPrefix): Builder {
618
+                $query
619
+                    ->when($data["{$fieldPrefix}_start_date"], fn (Builder $query, $startDate) => $query->whereDate($fieldPrefix, '>=', $startDate))
620
+                    ->when($data["{$fieldPrefix}_end_date"], fn (Builder $query, $endDate) => $query->whereDate($fieldPrefix, '<=', $endDate));
621
+
622
+                return $query;
623
+            })
624
+            ->indicateUsing(function (array $data) use ($fieldPrefix, $label): array {
625
+                $indicators = [];
626
+
627
+                $this->addIndicatorForDateRange($data, "{$fieldPrefix}_start_date", "{$fieldPrefix}_end_date", $label, $indicators);
628
+
629
+                return $indicators;
630
+            });
631
+
632
+    }
633
+
625 634
     protected function addIndicatorForSingleSelection($data, $key, $label, &$indicators): void
626 635
     {
627 636
         if (filled($data[$key])) {
@@ -641,13 +650,13 @@ class Transactions extends Page implements HasTable
641 650
         }
642 651
     }
643 652
 
644
-    protected function addIndicatorForDateRange($data, $startKey, $endKey, $labelPrefix, $combinedFieldKey, &$indicators): void
653
+    protected function addIndicatorForDateRange($data, $startKey, $endKey, $labelPrefix, &$indicators): void
645 654
     {
646 655
         $formattedStartDate = filled($data[$startKey]) ? Carbon::parse($data[$startKey])->toFormattedDateString() : null;
647 656
         $formattedEndDate = filled($data[$endKey]) ? Carbon::parse($data[$endKey])->toFormattedDateString() : null;
648 657
         if ($formattedStartDate && $formattedEndDate) {
649
-            $indicators[] = Tables\Filters\Indicator::make("{$labelPrefix}: {$formattedStartDate} - {$formattedEndDate}")
650
-                ->removeField($combinedFieldKey); // Associate with the hidden combined_dates field for removal
658
+            // If both start and end dates are set, show the combined date range as the indicator, no specific field needs to be removed since the entire filter will be removed
659
+            $indicators[] = Tables\Filters\Indicator::make("{$labelPrefix}: {$formattedStartDate} - {$formattedEndDate}");
651 660
         } else {
652 661
             if ($formattedStartDate) {
653 662
                 $indicators[] = Tables\Filters\Indicator::make("{$labelPrefix} After: {$formattedStartDate}")

+ 5
- 115
app/Filament/Company/Pages/Reports/AccountBalances.php Näytä tiedosto

@@ -3,15 +3,14 @@
3 3
 namespace App\Filament\Company\Pages\Reports;
4 4
 
5 5
 use App\DTO\AccountBalanceReportDTO;
6
+use App\Forms\Components\DateRangeSelect;
6 7
 use App\Models\Company;
7 8
 use App\Services\AccountBalancesExportService;
8 9
 use App\Services\AccountService;
9 10
 use Barryvdh\DomPDF\Facade\Pdf;
10
-use Carbon\CarbonPeriod;
11 11
 use Filament\Actions\Action;
12 12
 use Filament\Actions\ActionGroup;
13 13
 use Filament\Forms\Components\DatePicker;
14
-use Filament\Forms\Components\Select;
15 14
 use Filament\Forms\Components\Split;
16 15
 use Filament\Forms\Form;
17 16
 use Filament\Forms\Set;
@@ -57,7 +56,7 @@ class AccountBalances extends Page
57 56
         $this->fiscalYearStartDate = $this->company->locale->fiscalYearStartDate();
58 57
         $this->fiscalYearEndDate = $this->company->locale->fiscalYearEndDate();
59 58
         $this->dateRange = $this->getDefaultDateRange();
60
-        $this->updateDateRange($this->dateRange);
59
+        $this->setDateRange(Carbon::parse($this->fiscalYearStartDate), Carbon::parse($this->fiscalYearEndDate));
61 60
 
62 61
         $this->loadAccountBalances();
63 62
     }
@@ -117,13 +116,11 @@ class AccountBalances extends Page
117 116
         return $form
118 117
             ->schema([
119 118
                 Split::make([
120
-                    Select::make('dateRange')
119
+                    DateRangeSelect::make('dateRange')
121 120
                         ->label('Date Range')
122
-                        ->options($this->getDateRangeOptions())
123 121
                         ->selectablePlaceholder(false)
124
-                        ->afterStateUpdated(function ($state) {
125
-                            $this->updateDateRange($state);
126
-                        }),
122
+                        ->startDateField('startDate')
123
+                        ->endDateField('endDate'),
127 124
                     DatePicker::make('startDate')
128 125
                         ->label('Start Date')
129 126
                         ->displayFormat('Y-m-d')
@@ -140,113 +137,6 @@ class AccountBalances extends Page
140 137
             ]);
141 138
     }
142 139
 
143
-    public function getDateRangeOptions(): array
144
-    {
145
-        $earliestDate = Carbon::parse($this->accountService->getEarliestTransactionDate());
146
-        $currentDate = now();
147
-        $fiscalYearStartCurrent = Carbon::parse($this->fiscalYearStartDate);
148
-
149
-        $options = [
150
-            'Fiscal Year' => [],
151
-            'Fiscal Quarter' => [],
152
-            'Calendar Year' => [],
153
-            'Calendar Quarter' => [],
154
-            'Month' => [],
155
-            'Custom' => [],
156
-        ];
157
-
158
-        $period = CarbonPeriod::create($earliestDate, '1 month', $currentDate);
159
-
160
-        foreach ($period as $date) {
161
-            $options['Fiscal Year']['FY-' . $date->year] = $date->year;
162
-
163
-            $fiscalYearStart = $fiscalYearStartCurrent->copy()->subYears($currentDate->year - $date->year);
164
-
165
-            for ($i = 0; $i < 4; $i++) {
166
-                $quarterNumber = $i + 1;
167
-                $quarterStart = $fiscalYearStart->copy()->addMonths(($quarterNumber - 1) * 3);
168
-                $quarterEnd = $quarterStart->copy()->addMonths(3)->subDay();
169
-
170
-                if ($quarterStart->lessThanOrEqualTo($currentDate) && $quarterEnd->greaterThanOrEqualTo($earliestDate)) {
171
-                    $options['Fiscal Quarter']['FQ-' . $quarterNumber . '-' . $date->year] = 'Q' . $quarterNumber . ' ' . $date->year;
172
-                }
173
-            }
174
-
175
-            $options['Calendar Year']['Y-' . $date->year] = $date->year;
176
-            $quarterKey = 'Q-' . $date->quarter . '-' . $date->year;
177
-            $options['Calendar Quarter'][$quarterKey] = 'Q' . $date->quarter . ' ' . $date->year;
178
-            $options['Month']['M-' . $date->format('Y-m')] = $date->format('F Y');
179
-            $options['Custom']['Custom'] = 'Custom';
180
-        }
181
-
182
-        $options['Fiscal Year'] = array_reverse($options['Fiscal Year'], true);
183
-        $options['Fiscal Quarter'] = array_reverse($options['Fiscal Quarter'], true);
184
-        $options['Calendar Year'] = array_reverse($options['Calendar Year'], true);
185
-        $options['Calendar Quarter'] = array_reverse($options['Calendar Quarter'], true);
186
-        $options['Month'] = array_reverse($options['Month'], true);
187
-
188
-        return $options;
189
-    }
190
-
191
-    public function updateDateRange($state): void
192
-    {
193
-        [$type, $param1, $param2] = explode('-', $state) + [null, null, null];
194
-        $this->processDateRange($type, $param1, $param2);
195
-    }
196
-
197
-    public function processDateRange($type, $param1, $param2): void
198
-    {
199
-        match ($type) {
200
-            'FY' => $this->processFiscalYear($param1),
201
-            'FQ' => $this->processFiscalQuarter($param1, $param2),
202
-            'Y' => $this->processCalendarYear($param1),
203
-            'Q' => $this->processCalendarQuarter($param1, $param2),
204
-            'M' => $this->processMonth("{$param1}-{$param2}"),
205
-            'Custom' => null,
206
-        };
207
-    }
208
-
209
-    public function processFiscalYear($year): void
210
-    {
211
-        $currentYear = now()->year;
212
-        $diff = $currentYear - $year;
213
-        $fiscalYearStart = Carbon::parse($this->fiscalYearStartDate)->subYears($diff);
214
-        $fiscalYearEnd = Carbon::parse($this->fiscalYearEndDate)->subYears($diff);
215
-        $this->setDateRange($fiscalYearStart, $fiscalYearEnd);
216
-    }
217
-
218
-    public function processFiscalQuarter($quarter, $year): void
219
-    {
220
-        $currentYear = now()->year;
221
-        $diff = $currentYear - $year;
222
-        $fiscalYearStart = Carbon::parse($this->company->locale->fiscal_year_start_date)->subYears($diff);
223
-        $quarterStart = $fiscalYearStart->copy()->addMonths(($quarter - 1) * 3);
224
-        $quarterEnd = $quarterStart->copy()->addMonths(3)->subDay();
225
-        $this->setDateRange($quarterStart, $quarterEnd);
226
-    }
227
-
228
-    public function processCalendarYear($year): void
229
-    {
230
-        $start = Carbon::createFromDate($year)->startOfYear();
231
-        $end = Carbon::createFromDate($year)->endOfYear();
232
-        $this->setDateRange($start, $end);
233
-    }
234
-
235
-    public function processCalendarQuarter($quarter, $year): void
236
-    {
237
-        $month = ($quarter - 1) * 3 + 1;
238
-        $start = Carbon::createFromDate($year, $month, 1);
239
-        $end = Carbon::createFromDate($year, $month, 1)->endOfQuarter();
240
-        $this->setDateRange($start, $end);
241
-    }
242
-
243
-    public function processMonth($yearMonth): void
244
-    {
245
-        $start = Carbon::parse($yearMonth)->startOfMonth();
246
-        $end = Carbon::parse($yearMonth)->endOfMonth();
247
-        $this->setDateRange($start, $end);
248
-    }
249
-
250 140
     public function setDateRange(Carbon $start, Carbon $end): void
251 141
     {
252 142
         $this->startDate = $start->format('Y-m-d');

+ 171
- 0
app/Forms/Components/DateRangeSelect.php Näytä tiedosto

@@ -0,0 +1,171 @@
1
+<?php
2
+
3
+namespace App\Forms\Components;
4
+
5
+use App\Facades\Accounting;
6
+use App\Models\Company;
7
+use Carbon\CarbonPeriod;
8
+use Filament\Forms\Components\Select;
9
+use Filament\Forms\Set;
10
+use Illuminate\Support\Carbon;
11
+
12
+class DateRangeSelect extends Select
13
+{
14
+    public string $fiscalYearStartDate = '';
15
+
16
+    public string $fiscalYearEndDate = '';
17
+
18
+    public string $startDateField = '';
19
+
20
+    public string $endDateField = '';
21
+
22
+    public Company $company;
23
+
24
+    protected function setUp(): void
25
+    {
26
+        parent::setUp();
27
+
28
+        $this->company = auth()->user()->currentCompany;
29
+        $this->fiscalYearStartDate = $this->company->locale->fiscalYearStartDate();
30
+        $this->fiscalYearEndDate = $this->company->locale->fiscalYearEndDate();
31
+
32
+        $this->options($this->getDateRangeOptions())
33
+            ->afterStateUpdated(function ($state, Set $set) {
34
+                $this->updateDateRange($state, $set);
35
+            });
36
+    }
37
+
38
+    public function startDateField(string $fieldName): static
39
+    {
40
+        $this->startDateField = $fieldName;
41
+
42
+        return $this;
43
+    }
44
+
45
+    public function endDateField(string $fieldName): static
46
+    {
47
+        $this->endDateField = $fieldName;
48
+
49
+        return $this;
50
+    }
51
+
52
+    public function getDateRangeOptions(): array
53
+    {
54
+        $earliestDate = Carbon::parse(Accounting::getEarliestTransactionDate());
55
+        $currentDate = now();
56
+        $fiscalYearStartCurrent = Carbon::parse($this->fiscalYearStartDate);
57
+
58
+        $options = [
59
+            'Fiscal Year' => [],
60
+            'Fiscal Quarter' => [],
61
+            'Calendar Year' => [],
62
+            'Calendar Quarter' => [],
63
+            'Month' => [],
64
+            'Custom' => [],
65
+        ];
66
+
67
+        $period = CarbonPeriod::create($earliestDate, '1 month', $currentDate);
68
+
69
+        foreach ($period as $date) {
70
+            $options['Fiscal Year']['FY-' . $date->year] = $date->year;
71
+
72
+            $fiscalYearStart = $fiscalYearStartCurrent->copy()->subYears($currentDate->year - $date->year);
73
+
74
+            for ($i = 0; $i < 4; $i++) {
75
+                $quarterNumber = $i + 1;
76
+                $quarterStart = $fiscalYearStart->copy()->addMonths(($quarterNumber - 1) * 3);
77
+                $quarterEnd = $quarterStart->copy()->addMonths(3)->subDay();
78
+
79
+                if ($quarterStart->lessThanOrEqualTo($currentDate) && $quarterEnd->greaterThanOrEqualTo($earliestDate)) {
80
+                    $options['Fiscal Quarter']['FQ-' . $quarterNumber . '-' . $date->year] = 'Q' . $quarterNumber . ' ' . $date->year;
81
+                }
82
+            }
83
+
84
+            $options['Calendar Year']['Y-' . $date->year] = $date->year;
85
+            $quarterKey = 'Q-' . $date->quarter . '-' . $date->year;
86
+            $options['Calendar Quarter'][$quarterKey] = 'Q' . $date->quarter . ' ' . $date->year;
87
+            $options['Month']['M-' . $date->format('Y-m')] = $date->format('F Y');
88
+            $options['Custom']['Custom'] = 'Custom';
89
+        }
90
+
91
+        $options['Fiscal Year'] = array_reverse($options['Fiscal Year'], true);
92
+        $options['Fiscal Quarter'] = array_reverse($options['Fiscal Quarter'], true);
93
+        $options['Calendar Year'] = array_reverse($options['Calendar Year'], true);
94
+        $options['Calendar Quarter'] = array_reverse($options['Calendar Quarter'], true);
95
+        $options['Month'] = array_reverse($options['Month'], true);
96
+
97
+        return $options;
98
+    }
99
+
100
+    public function updateDateRange($state, Set $set): void
101
+    {
102
+        if ($state === null) {
103
+            $set($this->startDateField, null);
104
+            $set($this->endDateField, null);
105
+
106
+            return;
107
+        }
108
+
109
+        [$type, $param1, $param2] = explode('-', $state) + [null, null, null];
110
+        $this->processDateRange($type, $param1, $param2, $set);
111
+    }
112
+
113
+    public function processDateRange($type, $param1, $param2, Set $set): void
114
+    {
115
+        match ($type) {
116
+            'FY' => $this->processFiscalYear($param1, $set),
117
+            'FQ' => $this->processFiscalQuarter($param1, $param2, $set),
118
+            'Y' => $this->processCalendarYear($param1, $set),
119
+            'Q' => $this->processCalendarQuarter($param1, $param2, $set),
120
+            'M' => $this->processMonth("{$param1}-{$param2}", $set),
121
+            'Custom' => null,
122
+        };
123
+    }
124
+
125
+    public function processFiscalYear($year, Set $set): void
126
+    {
127
+        $currentYear = now()->year;
128
+        $diff = $currentYear - $year;
129
+        $fiscalYearStart = Carbon::parse($this->fiscalYearStartDate)->subYears($diff);
130
+        $fiscalYearEnd = Carbon::parse($this->fiscalYearEndDate)->subYears($diff);
131
+        $this->setDateRange($fiscalYearStart, $fiscalYearEnd, $set);
132
+    }
133
+
134
+    public function processFiscalQuarter($quarter, $year, Set $set): void
135
+    {
136
+        $currentYear = now()->year;
137
+        $diff = $currentYear - $year;
138
+        $fiscalYearStart = Carbon::parse($this->company->locale->fiscal_year_start_date)->subYears($diff);
139
+        $quarterStart = $fiscalYearStart->copy()->addMonths(($quarter - 1) * 3);
140
+        $quarterEnd = $quarterStart->copy()->addMonths(3)->subDay();
141
+        $this->setDateRange($quarterStart, $quarterEnd, $set);
142
+    }
143
+
144
+    public function processCalendarYear($year, Set $set): void
145
+    {
146
+        $start = Carbon::createFromDate($year)->startOfYear();
147
+        $end = Carbon::createFromDate($year)->endOfYear();
148
+        $this->setDateRange($start, $end, $set);
149
+    }
150
+
151
+    public function processCalendarQuarter($quarter, $year, Set $set): void
152
+    {
153
+        $month = ($quarter - 1) * 3 + 1;
154
+        $start = Carbon::createFromDate($year, $month, 1);
155
+        $end = Carbon::createFromDate($year, $month, 1)->endOfQuarter();
156
+        $this->setDateRange($start, $end, $set);
157
+    }
158
+
159
+    public function processMonth($yearMonth, Set $set): void
160
+    {
161
+        $start = Carbon::parse($yearMonth)->startOfMonth();
162
+        $end = Carbon::parse($yearMonth)->endOfMonth();
163
+        $this->setDateRange($start, $end, $set);
164
+    }
165
+
166
+    public function setDateRange(Carbon $start, Carbon $end, Set $set): void
167
+    {
168
+        $set($this->startDateField, $start->format('Y-m-d'));
169
+        $set($this->endDateField, $end->isFuture() ? now()->format('Y-m-d') : $end->format('Y-m-d'));
170
+    }
171
+}

+ 43
- 43
composer.lock Näytä tiedosto

@@ -497,16 +497,16 @@
497 497
         },
498 498
         {
499 499
             "name": "aws/aws-sdk-php",
500
-            "version": "3.304.1",
500
+            "version": "3.304.3",
501 501
             "source": {
502 502
                 "type": "git",
503 503
                 "url": "https://github.com/aws/aws-sdk-php.git",
504
-                "reference": "6dac9b3257873a807ac73f6dc4418bdc49a5d9db"
504
+                "reference": "d1ecaba720dc5d935d4ff66255f990fce3aa9727"
505 505
             },
506 506
             "dist": {
507 507
                 "type": "zip",
508
-                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/6dac9b3257873a807ac73f6dc4418bdc49a5d9db",
509
-                "reference": "6dac9b3257873a807ac73f6dc4418bdc49a5d9db",
508
+                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/d1ecaba720dc5d935d4ff66255f990fce3aa9727",
509
+                "reference": "d1ecaba720dc5d935d4ff66255f990fce3aa9727",
510 510
                 "shasum": ""
511 511
             },
512 512
             "require": {
@@ -586,9 +586,9 @@
586 586
             "support": {
587 587
                 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
588 588
                 "issues": "https://github.com/aws/aws-sdk-php/issues",
589
-                "source": "https://github.com/aws/aws-sdk-php/tree/3.304.1"
589
+                "source": "https://github.com/aws/aws-sdk-php/tree/3.304.3"
590 590
             },
591
-            "time": "2024-04-09T19:25:27+00:00"
591
+            "time": "2024-04-11T18:05:41+00:00"
592 592
         },
593 593
         {
594 594
             "name": "aws/aws-sdk-php-laravel",
@@ -1980,16 +1980,16 @@
1980 1980
         },
1981 1981
         {
1982 1982
             "name": "filament/actions",
1983
-            "version": "v3.2.63",
1983
+            "version": "v3.2.65",
1984 1984
             "source": {
1985 1985
                 "type": "git",
1986 1986
                 "url": "https://github.com/filamentphp/actions.git",
1987
-                "reference": "03da7f930763c60b7917f93e6657fb9bf9f8234b"
1987
+                "reference": "7f978130358ce997bdb5f7fe7994915cebf9f524"
1988 1988
             },
1989 1989
             "dist": {
1990 1990
                 "type": "zip",
1991
-                "url": "https://api.github.com/repos/filamentphp/actions/zipball/03da7f930763c60b7917f93e6657fb9bf9f8234b",
1992
-                "reference": "03da7f930763c60b7917f93e6657fb9bf9f8234b",
1991
+                "url": "https://api.github.com/repos/filamentphp/actions/zipball/7f978130358ce997bdb5f7fe7994915cebf9f524",
1992
+                "reference": "7f978130358ce997bdb5f7fe7994915cebf9f524",
1993 1993
                 "shasum": ""
1994 1994
             },
1995 1995
             "require": {
@@ -2029,20 +2029,20 @@
2029 2029
                 "issues": "https://github.com/filamentphp/filament/issues",
2030 2030
                 "source": "https://github.com/filamentphp/filament"
2031 2031
             },
2032
-            "time": "2024-04-05T21:55:09+00:00"
2032
+            "time": "2024-04-11T21:38:13+00:00"
2033 2033
         },
2034 2034
         {
2035 2035
             "name": "filament/filament",
2036
-            "version": "v3.2.63",
2036
+            "version": "v3.2.65",
2037 2037
             "source": {
2038 2038
                 "type": "git",
2039 2039
                 "url": "https://github.com/filamentphp/panels.git",
2040
-                "reference": "46f425d6097c77b98782f3db5f3717e2439bb3e8"
2040
+                "reference": "669ce35aef3a577af7f5d27b8acc7e4622c45f33"
2041 2041
             },
2042 2042
             "dist": {
2043 2043
                 "type": "zip",
2044
-                "url": "https://api.github.com/repos/filamentphp/panels/zipball/46f425d6097c77b98782f3db5f3717e2439bb3e8",
2045
-                "reference": "46f425d6097c77b98782f3db5f3717e2439bb3e8",
2044
+                "url": "https://api.github.com/repos/filamentphp/panels/zipball/669ce35aef3a577af7f5d27b8acc7e4622c45f33",
2045
+                "reference": "669ce35aef3a577af7f5d27b8acc7e4622c45f33",
2046 2046
                 "shasum": ""
2047 2047
             },
2048 2048
             "require": {
@@ -2094,20 +2094,20 @@
2094 2094
                 "issues": "https://github.com/filamentphp/filament/issues",
2095 2095
                 "source": "https://github.com/filamentphp/filament"
2096 2096
             },
2097
-            "time": "2024-04-05T21:55:28+00:00"
2097
+            "time": "2024-04-11T21:38:39+00:00"
2098 2098
         },
2099 2099
         {
2100 2100
             "name": "filament/forms",
2101
-            "version": "v3.2.63",
2101
+            "version": "v3.2.65",
2102 2102
             "source": {
2103 2103
                 "type": "git",
2104 2104
                 "url": "https://github.com/filamentphp/forms.git",
2105
-                "reference": "26676242e9470d28bb15f6686fff3e12da650d23"
2105
+                "reference": "5ecbfdfd124ad072d0bb77edba33262494c137eb"
2106 2106
             },
2107 2107
             "dist": {
2108 2108
                 "type": "zip",
2109
-                "url": "https://api.github.com/repos/filamentphp/forms/zipball/26676242e9470d28bb15f6686fff3e12da650d23",
2110
-                "reference": "26676242e9470d28bb15f6686fff3e12da650d23",
2109
+                "url": "https://api.github.com/repos/filamentphp/forms/zipball/5ecbfdfd124ad072d0bb77edba33262494c137eb",
2110
+                "reference": "5ecbfdfd124ad072d0bb77edba33262494c137eb",
2111 2111
                 "shasum": ""
2112 2112
             },
2113 2113
             "require": {
@@ -2150,11 +2150,11 @@
2150 2150
                 "issues": "https://github.com/filamentphp/filament/issues",
2151 2151
                 "source": "https://github.com/filamentphp/filament"
2152 2152
             },
2153
-            "time": "2024-04-05T21:55:12+00:00"
2153
+            "time": "2024-04-11T21:38:19+00:00"
2154 2154
         },
2155 2155
         {
2156 2156
             "name": "filament/infolists",
2157
-            "version": "v3.2.63",
2157
+            "version": "v3.2.65",
2158 2158
             "source": {
2159 2159
                 "type": "git",
2160 2160
                 "url": "https://github.com/filamentphp/infolists.git",
@@ -2205,16 +2205,16 @@
2205 2205
         },
2206 2206
         {
2207 2207
             "name": "filament/notifications",
2208
-            "version": "v3.2.63",
2208
+            "version": "v3.2.65",
2209 2209
             "source": {
2210 2210
                 "type": "git",
2211 2211
                 "url": "https://github.com/filamentphp/notifications.git",
2212
-                "reference": "27efac9801a7688e991b4c8e029c52922222fc8a"
2212
+                "reference": "067117fb0708dfd04955faafcfc82cd6d182e52f"
2213 2213
             },
2214 2214
             "dist": {
2215 2215
                 "type": "zip",
2216
-                "url": "https://api.github.com/repos/filamentphp/notifications/zipball/27efac9801a7688e991b4c8e029c52922222fc8a",
2217
-                "reference": "27efac9801a7688e991b4c8e029c52922222fc8a",
2216
+                "url": "https://api.github.com/repos/filamentphp/notifications/zipball/067117fb0708dfd04955faafcfc82cd6d182e52f",
2217
+                "reference": "067117fb0708dfd04955faafcfc82cd6d182e52f",
2218 2218
                 "shasum": ""
2219 2219
             },
2220 2220
             "require": {
@@ -2253,20 +2253,20 @@
2253 2253
                 "issues": "https://github.com/filamentphp/filament/issues",
2254 2254
                 "source": "https://github.com/filamentphp/filament"
2255 2255
             },
2256
-            "time": "2024-04-05T21:55:20+00:00"
2256
+            "time": "2024-04-11T21:38:28+00:00"
2257 2257
         },
2258 2258
         {
2259 2259
             "name": "filament/support",
2260
-            "version": "v3.2.63",
2260
+            "version": "v3.2.65",
2261 2261
             "source": {
2262 2262
                 "type": "git",
2263 2263
                 "url": "https://github.com/filamentphp/support.git",
2264
-                "reference": "17ddf2035ac79183bd61806bc0c7d4851228f2a1"
2264
+                "reference": "4b629597f5c2130abe0701c82e4da5b266bcbafa"
2265 2265
             },
2266 2266
             "dist": {
2267 2267
                 "type": "zip",
2268
-                "url": "https://api.github.com/repos/filamentphp/support/zipball/17ddf2035ac79183bd61806bc0c7d4851228f2a1",
2269
-                "reference": "17ddf2035ac79183bd61806bc0c7d4851228f2a1",
2268
+                "url": "https://api.github.com/repos/filamentphp/support/zipball/4b629597f5c2130abe0701c82e4da5b266bcbafa",
2269
+                "reference": "4b629597f5c2130abe0701c82e4da5b266bcbafa",
2270 2270
                 "shasum": ""
2271 2271
             },
2272 2272
             "require": {
@@ -2311,20 +2311,20 @@
2311 2311
                 "issues": "https://github.com/filamentphp/filament/issues",
2312 2312
                 "source": "https://github.com/filamentphp/filament"
2313 2313
             },
2314
-            "time": "2024-04-05T21:55:36+00:00"
2314
+            "time": "2024-04-11T21:38:59+00:00"
2315 2315
         },
2316 2316
         {
2317 2317
             "name": "filament/tables",
2318
-            "version": "v3.2.63",
2318
+            "version": "v3.2.65",
2319 2319
             "source": {
2320 2320
                 "type": "git",
2321 2321
                 "url": "https://github.com/filamentphp/tables.git",
2322
-                "reference": "5dfc41c56de5eab326ce1ecc5ceb5ba2baad8005"
2322
+                "reference": "1cdf9ee9ba35cad6e8e41725896e26e397549440"
2323 2323
             },
2324 2324
             "dist": {
2325 2325
                 "type": "zip",
2326
-                "url": "https://api.github.com/repos/filamentphp/tables/zipball/5dfc41c56de5eab326ce1ecc5ceb5ba2baad8005",
2327
-                "reference": "5dfc41c56de5eab326ce1ecc5ceb5ba2baad8005",
2326
+                "url": "https://api.github.com/repos/filamentphp/tables/zipball/1cdf9ee9ba35cad6e8e41725896e26e397549440",
2327
+                "reference": "1cdf9ee9ba35cad6e8e41725896e26e397549440",
2328 2328
                 "shasum": ""
2329 2329
             },
2330 2330
             "require": {
@@ -2364,11 +2364,11 @@
2364 2364
                 "issues": "https://github.com/filamentphp/filament/issues",
2365 2365
                 "source": "https://github.com/filamentphp/filament"
2366 2366
             },
2367
-            "time": "2024-04-05T21:55:42+00:00"
2367
+            "time": "2024-04-11T07:41:14+00:00"
2368 2368
         },
2369 2369
         {
2370 2370
             "name": "filament/widgets",
2371
-            "version": "v3.2.63",
2371
+            "version": "v3.2.65",
2372 2372
             "source": {
2373 2373
                 "type": "git",
2374 2374
                 "url": "https://github.com/filamentphp/widgets.git",
@@ -3093,16 +3093,16 @@
3093 3093
         },
3094 3094
         {
3095 3095
             "name": "laravel/framework",
3096
-            "version": "v11.3.0",
3096
+            "version": "v11.3.1",
3097 3097
             "source": {
3098 3098
                 "type": "git",
3099 3099
                 "url": "https://github.com/laravel/framework.git",
3100
-                "reference": "cbcb0ee3da8c5f98497d9a282609732251a7dd1e"
3100
+                "reference": "3b87d0767e9cbddec46480d883010ba720e50dea"
3101 3101
             },
3102 3102
             "dist": {
3103 3103
                 "type": "zip",
3104
-                "url": "https://api.github.com/repos/laravel/framework/zipball/cbcb0ee3da8c5f98497d9a282609732251a7dd1e",
3105
-                "reference": "cbcb0ee3da8c5f98497d9a282609732251a7dd1e",
3104
+                "url": "https://api.github.com/repos/laravel/framework/zipball/3b87d0767e9cbddec46480d883010ba720e50dea",
3105
+                "reference": "3b87d0767e9cbddec46480d883010ba720e50dea",
3106 3106
                 "shasum": ""
3107 3107
             },
3108 3108
             "require": {
@@ -3294,7 +3294,7 @@
3294 3294
                 "issues": "https://github.com/laravel/framework/issues",
3295 3295
                 "source": "https://github.com/laravel/framework"
3296 3296
             },
3297
-            "time": "2024-04-09T15:19:11+00:00"
3297
+            "time": "2024-04-10T15:13:49+00:00"
3298 3298
         },
3299 3299
         {
3300 3300
             "name": "laravel/prompts",

+ 6
- 6
package-lock.json Näytä tiedosto

@@ -918,9 +918,9 @@
918 918
             }
919 919
         },
920 920
         "node_modules/caniuse-lite": {
921
-            "version": "1.0.30001607",
922
-            "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001607.tgz",
923
-            "integrity": "sha512-WcvhVRjXLKFB/kmOFVwELtMxyhq3iM/MvmXcyCe2PNf166c39mptscOc/45TTS96n2gpNV2z7+NakArTWZCQ3w==",
921
+            "version": "1.0.30001608",
922
+            "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001608.tgz",
923
+            "integrity": "sha512-cjUJTQkk9fQlJR2s4HMuPMvTiRggl0rAVMtthQuyOlDWuqHXqN8azLq+pi8B2TjwKJ32diHjUqRIKeFX4z1FoA==",
924 924
             "dev": true,
925 925
             "funding": [
926 926
                 {
@@ -1066,9 +1066,9 @@
1066 1066
             "dev": true
1067 1067
         },
1068 1068
         "node_modules/electron-to-chromium": {
1069
-            "version": "1.4.731",
1070
-            "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.731.tgz",
1071
-            "integrity": "sha512-+TqVfZjpRz2V/5SPpmJxq9qK620SC5SqCnxQIOi7i/U08ZDcTpKbT7Xjj9FU5CbXTMUb4fywbIr8C7cGv4hcjw==",
1069
+            "version": "1.4.733",
1070
+            "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.733.tgz",
1071
+            "integrity": "sha512-gUI9nhI2iBGF0OaYYLKOaOtliFMl+Bt1rY7VmEjwxOxqoYLub/D9xmduPEhbw2imE6gYkJKhIE5it+KE2ulVxQ==",
1072 1072
             "dev": true
1073 1073
         },
1074 1074
         "node_modules/emoji-regex": {

Loading…
Peruuta
Tallenna