Selaa lähdekoodia

wip timezone handling

3.x
Andrew Wallo 2 kuukautta sitten
vanhempi
commit
b4e4bd9fd1

+ 6
- 1
app/Filament/Company/Clusters/Settings/Resources/AdjustmentResource.php Näytä tiedosto

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

+ 1
- 3
app/Filament/Company/Resources/Purchases/BillResource/Pages/PayBills.php Näytä tiedosto

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

+ 2
- 4
app/Filament/Company/Resources/Purchases/BillResource/RelationManagers/PaymentsRelationManager.php Näytä tiedosto

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

+ 2
- 2
app/Filament/Company/Resources/Sales/EstimateResource.php Näytä tiedosto

@@ -470,8 +470,8 @@ class EstimateResource extends Resource
470 470
                         ->beforeReplicaSaved(function (Estimate $replica) {
471 471
                             $replica->status = EstimateStatus::Draft;
472 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 476
                         ->withReplicatedRelationships(['lineItems'])
477 477
                         ->withExcludedRelationshipAttributes('lineItems', [

+ 2
- 2
app/Filament/Company/Resources/Sales/InvoiceResource.php Näytä tiedosto

@@ -538,8 +538,8 @@ class InvoiceResource extends Resource
538 538
                         ->beforeReplicaSaved(function (Invoice $replica) {
539 539
                             $replica->status = InvoiceStatus::Draft;
540 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 544
                         ->withReplicatedRelationships(['lineItems'])
545 545
                         ->withExcludedRelationshipAttributes('lineItems', [

+ 1
- 3
app/Filament/Company/Resources/Sales/InvoiceResource/Pages/RecordPayments.php Näytä tiedosto

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

+ 2
- 4
app/Filament/Company/Resources/Sales/InvoiceResource/RelationManagers/PaymentsRelationManager.php Näytä tiedosto

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

Loading…
Peruuta
Tallenna