Andrew Wallo 2 月之前
父節點
當前提交
2aaeb13e20

+ 0
- 1
app/Concerns/HasTransactionAction.php 查看文件

@@ -83,7 +83,6 @@ trait HasTransactionAction
83 83
             ->schema([
84 84
                 Forms\Components\DatePicker::make('posted_at')
85 85
                     ->label('Date')
86
-                    ->native()
87 86
                     ->required(),
88 87
                 Forms\Components\TextInput::make('description')
89 88
                     ->label('Description'),

+ 3
- 33
app/Filament/Company/Pages/Concerns/HasDeferredFiltersForm.php 查看文件

@@ -4,7 +4,6 @@ namespace App\Filament\Company\Pages\Concerns;
4 4
 
5 5
 use Filament\Actions\Action;
6 6
 use Filament\Forms\Components\DatePicker;
7
-use Filament\Forms\Components\DateTimePicker;
8 7
 use Filament\Forms\Form;
9 8
 use Illuminate\Support\Arr;
10 9
 use Illuminate\Support\Carbon;
@@ -106,19 +105,6 @@ trait HasDeferredFiltersForm
106 105
         Arr::set($this->deferredFilters, $name, $value);
107 106
     }
108 107
 
109
-    protected function convertDatesToDateTimeString(array $filters): array
110
-    {
111
-        if (isset($filters['startDate'])) {
112
-            $filters['startDate'] = Carbon::parse($filters['startDate'])->startOfDay()->toDateTimeString();
113
-        }
114
-
115
-        if (isset($filters['endDate'])) {
116
-            $filters['endDate'] = Carbon::parse($filters['endDate'])->endOfDay()->toDateTimeString();
117
-        }
118
-
119
-        return $filters;
120
-    }
121
-
122 108
     protected function queryStringHasDeferredFiltersForm(): array
123 109
     {
124 110
         // Get the filter keys dynamically from the filters form
@@ -171,25 +157,9 @@ trait HasDeferredFiltersForm
171 157
         $flatFields = $this->getFiltersForm()->getFlatFields();
172 158
 
173 159
         foreach ($this->filters as $key => $value) {
174
-            if (! isset($flatFields[$key]) || blank($value)) {
175
-                continue;
176
-            }
177
-
178
-            $field = $flatFields[$key];
179
-
180
-            // Reproduce underlying conversion to UTC for DateTimePicker and DatePicker
181
-            if ($field instanceof DateTimePicker && $field->getTimezone() !== config('app.timezone')) {
182
-                try {
183
-                    $carbonValue = Carbon::parse($value, $field->getTimezone());
184
-
185
-                    // Shift back to UTC and format according to field type
186
-                    $this->filters[$key] = $carbonValue
187
-                        ->setTimezone(config('app.timezone'))
188
-                        ->format($field->getFormat());
189
-
190
-                } catch (\Exception $e) {
191
-                    continue;
192
-                }
160
+            if (isset($flatFields[$key]) && $flatFields[$key] instanceof DatePicker) {
161
+                // TODO: Submit a PR to Filament to address DatePicker being dehydrated as a datetime string in filters
162
+                $this->filters[$key] = Carbon::parse($value)->toDateString();
193 163
             }
194 164
         }
195 165
     }

+ 1
- 3
app/Filament/Company/Pages/Reports/BaseReportPage.php 查看文件

@@ -9,7 +9,6 @@ use App\Filament\Company\Pages\Concerns\HasTableColumnToggleForm;
9 9
 use App\Filament\Company\Pages\Reports;
10 10
 use App\Filament\Forms\Components\DateRangeSelect;
11 11
 use App\Models\Company;
12
-use App\Services\CompanySettingsService;
13 12
 use App\Services\DateRangeService;
14 13
 use App\Support\Column;
15 14
 use Filament\Actions\Action;
@@ -92,6 +91,7 @@ abstract class BaseReportPage extends Page
92 91
     {
93 92
         $flatFields = $this->getFiltersForm()->getFlatFields();
94 93
 
94
+        /** @var DateRangeSelect|null $dateRangeField */
95 95
         $dateRangeField = Arr::first($flatFields, static fn ($field) => $field instanceof DateRangeSelect);
96 96
 
97 97
         if (! $dateRangeField) {
@@ -254,7 +254,6 @@ abstract class BaseReportPage extends Page
254 254
         return DatePicker::make('startDate')
255 255
             ->label('Start date')
256 256
             ->live()
257
-            ->timezone(CompanySettingsService::getDefaultTimezone())
258 257
             ->afterStateUpdated(static function ($state, Set $set) {
259 258
                 $set('dateRange', 'Custom');
260 259
             });
@@ -265,7 +264,6 @@ abstract class BaseReportPage extends Page
265 264
         return DatePicker::make('endDate')
266 265
             ->label('End date')
267 266
             ->live()
268
-            ->timezone(CompanySettingsService::getDefaultTimezone())
269 267
             ->afterStateUpdated(static function (Set $set) {
270 268
                 $set('dateRange', 'Custom');
271 269
             });

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

@@ -280,9 +280,6 @@ class CompanyPanelProvider extends PanelProvider
280 280
         Tables\Actions\CreateAction::configureUsing(static fn (Tables\Actions\CreateAction $action) => FilamentComponentConfigurator::configureActionModals($action));
281 281
         Tables\Actions\DeleteAction::configureUsing(static fn (Tables\Actions\DeleteAction $action) => FilamentComponentConfigurator::configureDeleteAction($action));
282 282
         Tables\Actions\DeleteBulkAction::configureUsing(static fn (Tables\Actions\DeleteBulkAction $action) => FilamentComponentConfigurator::configureDeleteAction($action));
283
-        Forms\Components\DateTimePicker::configureUsing(static function (Forms\Components\DateTimePicker $component) {
284
-            $component->native(false);
285
-        });
286 283
 
287 284
         Tables\Table::configureUsing(static function (Tables\Table $table): void {
288 285
             $table::$defaultDateDisplayFormat = CompanySettingsService::getDefaultDateFormat(session('current_company_id') ?? auth()->user()->current_company_id);

+ 2
- 2
tests/Feature/Accounting/TransactionTest.php 查看文件

@@ -267,7 +267,7 @@ it('can add a transfer transaction', function () {
267 267
     livewire(ListTransactions::class)
268 268
         ->mountAction('createTransfer')
269 269
         ->assertActionDataSet([
270
-            'posted_at' => today(),
270
+            'posted_at' => company_today()->toDateString(),
271 271
             'type' => TransactionType::Transfer,
272 272
             'bank_account_id' => $sourceBankAccount->id,
273 273
             'amount' => '0.00',
@@ -300,7 +300,7 @@ it('can add a journal transaction', function () {
300 300
     livewire(ListTransactions::class)
301 301
         ->mountAction('createJournalEntry')
302 302
         ->assertActionDataSet([
303
-            'posted_at' => today(),
303
+            'posted_at' => company_today()->toDateString(),
304 304
             'journalEntries' => [
305 305
                 ['type' => JournalEntryType::Debit, 'account_id' => $defaultDebitAccount->id, 'amount' => '0.00'],
306 306
                 ['type' => JournalEntryType::Credit, 'account_id' => $defaultCreditAccount->id, 'amount' => '0.00'],

Loading…
取消
儲存