浏览代码

wip timezone handling

3.x
Andrew Wallo 2 个月前
父节点
当前提交
b4e4bd9fd1

+ 6
- 1
app/Filament/Company/Clusters/Settings/Resources/AdjustmentResource.php 查看文件

10
 use App\Filament\Company\Clusters\Settings;
10
 use App\Filament\Company\Clusters\Settings;
11
 use App\Filament\Company\Clusters\Settings\Resources\AdjustmentResource\Pages;
11
 use App\Filament\Company\Clusters\Settings\Resources\AdjustmentResource\Pages;
12
 use App\Models\Accounting\Adjustment;
12
 use App\Models\Accounting\Adjustment;
13
+use App\Services\CompanySettingsService;
13
 use Filament\Forms;
14
 use Filament\Forms;
14
 use Filament\Forms\Form;
15
 use Filament\Forms\Form;
15
 use Filament\Notifications\Notification;
16
 use Filament\Notifications\Notification;
80
                     ->columns(),
81
                     ->columns(),
81
                 Forms\Components\Section::make('Dates')
82
                 Forms\Components\Section::make('Dates')
82
                     ->schema([
83
                     ->schema([
83
-                        Forms\Components\DateTimePicker::make('start_date'),
84
+                        Forms\Components\DateTimePicker::make('start_date')
85
+                            ->timezone(CompanySettingsService::getDefaultTimezone()),
84
                         Forms\Components\DateTimePicker::make('end_date')
86
                         Forms\Components\DateTimePicker::make('end_date')
87
+                            ->timezone(CompanySettingsService::getDefaultTimezone())
85
                             ->after('start_date'),
88
                             ->after('start_date'),
86
                     ])
89
                     ])
87
                     ->columns()
90
                     ->columns()
192
                         ->form([
195
                         ->form([
193
                             Forms\Components\DateTimePicker::make('paused_until')
196
                             Forms\Components\DateTimePicker::make('paused_until')
194
                                 ->label('Auto-resume date')
197
                                 ->label('Auto-resume date')
198
+                                ->timezone(CompanySettingsService::getDefaultTimezone())
195
                                 ->helperText('When should this adjustment automatically resume? Leave empty to keep paused indefinitely.')
199
                                 ->helperText('When should this adjustment automatically resume? Leave empty to keep paused indefinitely.')
196
                                 ->after('now'),
200
                                 ->after('now'),
197
                             Forms\Components\Textarea::make('status_reason')
201
                             Forms\Components\Textarea::make('status_reason')
251
                         ->form([
255
                         ->form([
252
                             Forms\Components\DateTimePicker::make('paused_until')
256
                             Forms\Components\DateTimePicker::make('paused_until')
253
                                 ->label('Auto-resume date')
257
                                 ->label('Auto-resume date')
258
+                                ->timezone(CompanySettingsService::getDefaultTimezone())
254
                                 ->helperText('When should these adjustments automatically resume? Leave empty to keep paused indefinitely.')
259
                                 ->helperText('When should these adjustments automatically resume? Leave empty to keep paused indefinitely.')
255
                                 ->after('now'),
260
                                 ->after('now'),
256
                             Forms\Components\Textarea::make('status_reason')
261
                             Forms\Components\Textarea::make('status_reason')

+ 1
- 3
app/Filament/Company/Resources/Purchases/BillResource/Pages/PayBills.php 查看文件

11
 use App\Models\Banking\BankAccount;
11
 use App\Models\Banking\BankAccount;
12
 use App\Models\Common\Vendor;
12
 use App\Models\Common\Vendor;
13
 use App\Models\Setting\Currency;
13
 use App\Models\Setting\Currency;
14
-use App\Services\CompanySettingsService;
15
 use App\Utilities\Currency\CurrencyAccessor;
14
 use App\Utilities\Currency\CurrencyAccessor;
16
 use App\Utilities\Currency\CurrencyConverter;
15
 use App\Utilities\Currency\CurrencyConverter;
17
 use Filament\Actions;
16
 use Filament\Actions;
152
                             ->softRequired(),
151
                             ->softRequired(),
153
                         Forms\Components\DatePicker::make('posted_at')
152
                         Forms\Components\DatePicker::make('posted_at')
154
                             ->label('Date')
153
                             ->label('Date')
155
-                            ->default(now())
156
-                            ->timezone(CompanySettingsService::getDefaultTimezone())
154
+                            ->default(company_today()->toDateString())
157
                             ->softRequired(),
155
                             ->softRequired(),
158
                         Forms\Components\Select::make('payment_method')
156
                         Forms\Components\Select::make('payment_method')
159
                             ->label('Payment method')
157
                             ->label('Payment method')

+ 2
- 4
app/Filament/Company/Resources/Purchases/BillResource/RelationManagers/PaymentsRelationManager.php 查看文件

7
 use App\Models\Accounting\Bill;
7
 use App\Models\Accounting\Bill;
8
 use App\Models\Accounting\Transaction;
8
 use App\Models\Accounting\Transaction;
9
 use App\Models\Banking\BankAccount;
9
 use App\Models\Banking\BankAccount;
10
-use App\Services\CompanySettingsService;
11
 use App\Utilities\Currency\CurrencyAccessor;
10
 use App\Utilities\Currency\CurrencyAccessor;
12
 use App\Utilities\Currency\CurrencyConverter;
11
 use App\Utilities\Currency\CurrencyConverter;
13
 use Closure;
12
 use Closure;
41
             ->columns(1)
40
             ->columns(1)
42
             ->schema([
41
             ->schema([
43
                 Forms\Components\DatePicker::make('posted_at')
42
                 Forms\Components\DatePicker::make('posted_at')
44
-                    ->label('Date')
45
-                    ->timezone(CompanySettingsService::getDefaultTimezone()),
43
+                    ->label('Date'),
46
                 Forms\Components\Grid::make()
44
                 Forms\Components\Grid::make()
47
                     ->schema([
45
                     ->schema([
48
                         Forms\Components\Select::make('bank_account_id')
46
                         Forms\Components\Select::make('bank_account_id')
226
                     ->mountUsing(function (Form $form) {
224
                     ->mountUsing(function (Form $form) {
227
                         $record = $this->getOwnerRecord();
225
                         $record = $this->getOwnerRecord();
228
                         $form->fill([
226
                         $form->fill([
229
-                            'posted_at' => now(),
227
+                            'posted_at' => company_today()->toDateString(),
230
                             'amount' => $record->amount_due,
228
                             'amount' => $record->amount_due,
231
                         ]);
229
                         ]);
232
                     })
230
                     })

+ 2
- 2
app/Filament/Company/Resources/Sales/EstimateResource.php 查看文件

470
                         ->beforeReplicaSaved(function (Estimate $replica) {
470
                         ->beforeReplicaSaved(function (Estimate $replica) {
471
                             $replica->status = EstimateStatus::Draft;
471
                             $replica->status = EstimateStatus::Draft;
472
                             $replica->estimate_number = Estimate::getNextDocumentNumber();
472
                             $replica->estimate_number = Estimate::getNextDocumentNumber();
473
-                            $replica->date = now();
474
-                            $replica->expiration_date = now()->addDays($replica->company->defaultInvoice->payment_terms->getDays());
473
+                            $replica->date = company_today();
474
+                            $replica->expiration_date = company_today()->addDays($replica->company->defaultInvoice->payment_terms->getDays());
475
                         })
475
                         })
476
                         ->withReplicatedRelationships(['lineItems'])
476
                         ->withReplicatedRelationships(['lineItems'])
477
                         ->withExcludedRelationshipAttributes('lineItems', [
477
                         ->withExcludedRelationshipAttributes('lineItems', [

+ 2
- 2
app/Filament/Company/Resources/Sales/InvoiceResource.php 查看文件

538
                         ->beforeReplicaSaved(function (Invoice $replica) {
538
                         ->beforeReplicaSaved(function (Invoice $replica) {
539
                             $replica->status = InvoiceStatus::Draft;
539
                             $replica->status = InvoiceStatus::Draft;
540
                             $replica->invoice_number = Invoice::getNextDocumentNumber();
540
                             $replica->invoice_number = Invoice::getNextDocumentNumber();
541
-                            $replica->date = now();
542
-                            $replica->due_date = now()->addDays($replica->company->defaultInvoice->payment_terms->getDays());
541
+                            $replica->date = company_today();
542
+                            $replica->due_date = company_today()->addDays($replica->company->defaultInvoice->payment_terms->getDays());
543
                         })
543
                         })
544
                         ->withReplicatedRelationships(['lineItems'])
544
                         ->withReplicatedRelationships(['lineItems'])
545
                         ->withExcludedRelationshipAttributes('lineItems', [
545
                         ->withExcludedRelationshipAttributes('lineItems', [

+ 1
- 3
app/Filament/Company/Resources/Sales/InvoiceResource/Pages/RecordPayments.php 查看文件

11
 use App\Models\Banking\BankAccount;
11
 use App\Models\Banking\BankAccount;
12
 use App\Models\Common\Client;
12
 use App\Models\Common\Client;
13
 use App\Models\Setting\Currency;
13
 use App\Models\Setting\Currency;
14
-use App\Services\CompanySettingsService;
15
 use App\Utilities\Currency\CurrencyAccessor;
14
 use App\Utilities\Currency\CurrencyAccessor;
16
 use App\Utilities\Currency\CurrencyConverter;
15
 use App\Utilities\Currency\CurrencyConverter;
17
 use Filament\Actions;
16
 use Filament\Actions;
202
                             ->softRequired(),
201
                             ->softRequired(),
203
                         Forms\Components\DatePicker::make('posted_at')
202
                         Forms\Components\DatePicker::make('posted_at')
204
                             ->label('Date')
203
                             ->label('Date')
205
-                            ->default(now())
206
-                            ->timezone(CompanySettingsService::getDefaultTimezone())
204
+                            ->default(company_today()->toDateString())
207
                             ->softRequired(),
205
                             ->softRequired(),
208
                         Forms\Components\Select::make('payment_method')
206
                         Forms\Components\Select::make('payment_method')
209
                             ->label('Payment method')
207
                             ->label('Payment method')

+ 2
- 4
app/Filament/Company/Resources/Sales/InvoiceResource/RelationManagers/PaymentsRelationManager.php 查看文件

8
 use App\Models\Accounting\Invoice;
8
 use App\Models\Accounting\Invoice;
9
 use App\Models\Accounting\Transaction;
9
 use App\Models\Accounting\Transaction;
10
 use App\Models\Banking\BankAccount;
10
 use App\Models\Banking\BankAccount;
11
-use App\Services\CompanySettingsService;
12
 use App\Utilities\Currency\CurrencyAccessor;
11
 use App\Utilities\Currency\CurrencyAccessor;
13
 use App\Utilities\Currency\CurrencyConverter;
12
 use App\Utilities\Currency\CurrencyConverter;
14
 use Closure;
13
 use Closure;
50
             ->columns(1)
49
             ->columns(1)
51
             ->schema([
50
             ->schema([
52
                 Forms\Components\DatePicker::make('posted_at')
51
                 Forms\Components\DatePicker::make('posted_at')
53
-                    ->label('Date')
54
-                    ->timezone(CompanySettingsService::getDefaultTimezone()),
52
+                    ->label('Date'),
55
                 Forms\Components\Grid::make()
53
                 Forms\Components\Grid::make()
56
                     ->schema([
54
                     ->schema([
57
                         Forms\Components\Select::make('bank_account_id')
55
                         Forms\Components\Select::make('bank_account_id')
239
                     ->mountUsing(function (Form $form) {
237
                     ->mountUsing(function (Form $form) {
240
                         $record = $this->getOwnerRecord();
238
                         $record = $this->getOwnerRecord();
241
                         $form->fill([
239
                         $form->fill([
242
-                            'posted_at' => now(),
240
+                            'posted_at' => company_today()->toDateString(),
243
                             'amount' => abs($record->amount_due),
241
                             'amount' => abs($record->amount_due),
244
                         ]);
242
                         ]);
245
                     })
243
                     })

正在加载...
取消
保存