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

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

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

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

4
 
4
 
5
 use Filament\Actions\Action;
5
 use Filament\Actions\Action;
6
 use Filament\Forms\Components\DatePicker;
6
 use Filament\Forms\Components\DatePicker;
7
-use Filament\Forms\Components\DateTimePicker;
8
 use Filament\Forms\Form;
7
 use Filament\Forms\Form;
9
 use Illuminate\Support\Arr;
8
 use Illuminate\Support\Arr;
10
 use Illuminate\Support\Carbon;
9
 use Illuminate\Support\Carbon;
106
         Arr::set($this->deferredFilters, $name, $value);
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
     protected function queryStringHasDeferredFiltersForm(): array
108
     protected function queryStringHasDeferredFiltersForm(): array
123
     {
109
     {
124
         // Get the filter keys dynamically from the filters form
110
         // Get the filter keys dynamically from the filters form
171
         $flatFields = $this->getFiltersForm()->getFlatFields();
157
         $flatFields = $this->getFiltersForm()->getFlatFields();
172
 
158
 
173
         foreach ($this->filters as $key => $value) {
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
 use App\Filament\Company\Pages\Reports;
9
 use App\Filament\Company\Pages\Reports;
10
 use App\Filament\Forms\Components\DateRangeSelect;
10
 use App\Filament\Forms\Components\DateRangeSelect;
11
 use App\Models\Company;
11
 use App\Models\Company;
12
-use App\Services\CompanySettingsService;
13
 use App\Services\DateRangeService;
12
 use App\Services\DateRangeService;
14
 use App\Support\Column;
13
 use App\Support\Column;
15
 use Filament\Actions\Action;
14
 use Filament\Actions\Action;
92
     {
91
     {
93
         $flatFields = $this->getFiltersForm()->getFlatFields();
92
         $flatFields = $this->getFiltersForm()->getFlatFields();
94
 
93
 
94
+        /** @var DateRangeSelect|null $dateRangeField */
95
         $dateRangeField = Arr::first($flatFields, static fn ($field) => $field instanceof DateRangeSelect);
95
         $dateRangeField = Arr::first($flatFields, static fn ($field) => $field instanceof DateRangeSelect);
96
 
96
 
97
         if (! $dateRangeField) {
97
         if (! $dateRangeField) {
254
         return DatePicker::make('startDate')
254
         return DatePicker::make('startDate')
255
             ->label('Start date')
255
             ->label('Start date')
256
             ->live()
256
             ->live()
257
-            ->timezone(CompanySettingsService::getDefaultTimezone())
258
             ->afterStateUpdated(static function ($state, Set $set) {
257
             ->afterStateUpdated(static function ($state, Set $set) {
259
                 $set('dateRange', 'Custom');
258
                 $set('dateRange', 'Custom');
260
             });
259
             });
265
         return DatePicker::make('endDate')
264
         return DatePicker::make('endDate')
266
             ->label('End date')
265
             ->label('End date')
267
             ->live()
266
             ->live()
268
-            ->timezone(CompanySettingsService::getDefaultTimezone())
269
             ->afterStateUpdated(static function (Set $set) {
267
             ->afterStateUpdated(static function (Set $set) {
270
                 $set('dateRange', 'Custom');
268
                 $set('dateRange', 'Custom');
271
             });
269
             });

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

280
         Tables\Actions\CreateAction::configureUsing(static fn (Tables\Actions\CreateAction $action) => FilamentComponentConfigurator::configureActionModals($action));
280
         Tables\Actions\CreateAction::configureUsing(static fn (Tables\Actions\CreateAction $action) => FilamentComponentConfigurator::configureActionModals($action));
281
         Tables\Actions\DeleteAction::configureUsing(static fn (Tables\Actions\DeleteAction $action) => FilamentComponentConfigurator::configureDeleteAction($action));
281
         Tables\Actions\DeleteAction::configureUsing(static fn (Tables\Actions\DeleteAction $action) => FilamentComponentConfigurator::configureDeleteAction($action));
282
         Tables\Actions\DeleteBulkAction::configureUsing(static fn (Tables\Actions\DeleteBulkAction $action) => FilamentComponentConfigurator::configureDeleteAction($action));
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
         Tables\Table::configureUsing(static function (Tables\Table $table): void {
284
         Tables\Table::configureUsing(static function (Tables\Table $table): void {
288
             $table::$defaultDateDisplayFormat = CompanySettingsService::getDefaultDateFormat(session('current_company_id') ?? auth()->user()->current_company_id);
285
             $table::$defaultDateDisplayFormat = CompanySettingsService::getDefaultDateFormat(session('current_company_id') ?? auth()->user()->current_company_id);

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

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

Loading…
取消
儲存