Pārlūkot izejas kodu

wip timezone handling

3.x
Andrew Wallo 2 mēnešus atpakaļ
vecāks
revīzija
b31677a91d
1 mainītis faili ar 8 papildinājumiem un 16 dzēšanām
  1. 8
    16
      app/Providers/MacroServiceProvider.php

+ 8
- 16
app/Providers/MacroServiceProvider.php Parādīt failu

@@ -5,9 +5,7 @@ namespace App\Providers;
5 5
 use Akaunting\Money\Currency;
6 6
 use Akaunting\Money\Money;
7 7
 use App\Enums\Accounting\AdjustmentComputation;
8
-use App\Enums\Setting\DateFormat;
9 8
 use App\Models\Accounting\AccountSubtype;
10
-use App\Models\Setting\Localization;
11 9
 use App\Services\CompanySettingsService;
12 10
 use App\Utilities\Accounting\AccountCode;
13 11
 use App\Utilities\Currency\CurrencyAccessor;
@@ -173,24 +171,17 @@ class MacroServiceProvider extends ServiceProvider
173 171
         });
174 172
 
175 173
         TextColumn::macro('defaultDateFormat', function (): static {
176
-            $localization = Localization::firstOrFail();
174
+            $dateFormat = CompanySettingsService::getDefaultDateFormat();
177 175
 
178
-            $dateFormat = $localization->date_format->value ?? DateFormat::DEFAULT;
179
-            $timezone = $localization->timezone ?? company_now()->timezoneName;
180
-
181
-            $this->date($dateFormat, $timezone);
176
+            $this->date($dateFormat);
182 177
 
183 178
             return $this;
184 179
         });
185 180
 
186 181
         DatePicker::macro('defaultDateFormat', function (): static {
187
-            $localization = Localization::firstOrFail();
188
-
189
-            $dateFormat = $localization->date_format->value ?? DateFormat::DEFAULT;
190
-            $timezone = $localization->timezone ?? company_now()->timezoneName;
182
+            $dateFormat = CompanySettingsService::getDefaultDateFormat();
191 183
 
192
-            $this->displayFormat($dateFormat)
193
-                ->timezone($timezone);
184
+            $this->displayFormat($dateFormat);
194 185
 
195 186
             return $this;
196 187
         });
@@ -492,10 +483,11 @@ class MacroServiceProvider extends ServiceProvider
492 483
         });
493 484
 
494 485
         Carbon::macro('toDefaultDateFormat', function () {
495
-            $companyId = auth()->user()?->current_company_id;
496
-            $dateFormat = CompanySettingsService::getDefaultDateFormat($companyId);
486
+            $dateFormat = CompanySettingsService::getDefaultDateFormat();
497 487
 
498
-            return $this->format($dateFormat);
488
+            $this->format($dateFormat);
489
+
490
+            return $this;
499 491
         });
500 492
 
501 493
         ExportColumn::macro('money', function () {

Notiek ielāde…
Atcelt
Saglabāt