瀏覽代碼

wip timezone handling

3.x
Andrew Wallo 2 月之前
父節點
當前提交
a146271f4c

+ 5
- 5
app/Models/Accounting/Budget.php 查看文件

154
     public function scopeCurrentlyActive(Builder $query): Builder
154
     public function scopeCurrentlyActive(Builder $query): Builder
155
     {
155
     {
156
         return $query->active()
156
         return $query->active()
157
-            ->where('start_date', '<=', now())
158
-            ->where('end_date', '>=', now());
157
+            ->where('start_date', '<=', company_now())
158
+            ->where('end_date', '>=', company_now());
159
     }
159
     }
160
 
160
 
161
     protected function isCurrentlyInPeriod(): Attribute
161
     protected function isCurrentlyInPeriod(): Attribute
162
     {
162
     {
163
         return Attribute::get(function () {
163
         return Attribute::get(function () {
164
-            return now()->between($this->start_date, $this->end_date);
164
+            return company_now()->between($this->start_date, $this->end_date);
165
         });
165
         });
166
     }
166
     }
167
 
167
 
174
             throw new \RuntimeException('Budget cannot be approved.');
174
             throw new \RuntimeException('Budget cannot be approved.');
175
         }
175
         }
176
 
176
 
177
-        $approvedAt ??= now();
177
+        $approvedAt ??= company_now();
178
 
178
 
179
         $this->update([
179
         $this->update([
180
             'status' => BudgetStatus::Active,
180
             'status' => BudgetStatus::Active,
191
             throw new \RuntimeException('Budget cannot be closed.');
191
             throw new \RuntimeException('Budget cannot be closed.');
192
         }
192
         }
193
 
193
 
194
-        $closedAt ??= now();
194
+        $closedAt ??= company_now();
195
 
195
 
196
         $this->update([
196
         $this->update([
197
             'status' => BudgetStatus::Closed,
197
             'status' => BudgetStatus::Closed,

+ 1
- 1
app/Models/Accounting/BudgetAllocation.php 查看文件

38
 
38
 
39
     public function isCurrentPeriod(): bool
39
     public function isCurrentPeriod(): bool
40
     {
40
     {
41
-        return now()->between($this->start_date, $this->end_date);
41
+        return company_now()->between($this->start_date, $this->end_date);
42
     }
42
     }
43
 }
43
 }

+ 1
- 1
app/Models/Accounting/RecurringInvoice.php 查看文件

693
 
693
 
694
         $nextDate = $this->calculateNextDate();
694
         $nextDate = $this->calculateNextDate();
695
 
695
 
696
-        if (! $nextDate || $nextDate->startOfDay()->isFuture()) {
696
+        if (! $nextDate || $nextDate->startOfDay()->isAfter(company_now())) {
697
             return false;
697
             return false;
698
         }
698
         }
699
 
699
 

+ 2
- 2
app/Models/Setting/Localization.php 查看文件

63
     public static function getWeekStart(string $locale): int
63
     public static function getWeekStart(string $locale): int
64
     {
64
     {
65
         /** @var Carbon $date */
65
         /** @var Carbon $date */
66
-        $date = now()->locale($locale);
66
+        $date = company_now()->locale($locale);
67
 
67
 
68
         $firstDay = $date->startOfWeek()->dayOfWeekIso;
68
         $firstDay = $date->startOfWeek()->dayOfWeekIso;
69
 
69
 
91
     public function fiscalYearEndDate(): string
91
     public function fiscalYearEndDate(): string
92
     {
92
     {
93
         return once(function () {
93
         return once(function () {
94
-            $today = now();
94
+            $today = company_now();
95
             $fiscalYearEndThisYear = Carbon::createFromDate($today->year, $this->fiscal_year_end_month, $this->fiscal_year_end_day);
95
             $fiscalYearEndThisYear = Carbon::createFromDate($today->year, $this->fiscal_year_end_month, $this->fiscal_year_end_day);
96
 
96
 
97
             if ($today->gt($fiscalYearEndThisYear)) {
97
             if ($today->gt($fiscalYearEndThisYear)) {

+ 1
- 1
app/Observers/AdjustmentObserver.php 查看文件

78
 
78
 
79
         // Ensure consistency between paused status and paused_at field
79
         // Ensure consistency between paused status and paused_at field
80
         if ($adjustment->status === AdjustmentStatus::Paused && ! $adjustment->paused_at) {
80
         if ($adjustment->status === AdjustmentStatus::Paused && ! $adjustment->paused_at) {
81
-            $adjustment->paused_at = now();
81
+            $adjustment->paused_at = company_now();
82
         }
82
         }
83
     }
83
     }
84
 }
84
 }

+ 1
- 1
app/Observers/RecurringInvoiceObserver.php 查看文件

20
 
20
 
21
         if ($recurringInvoice->end_type?->isAfter() && $recurringInvoice->occurrences_count >= $recurringInvoice->max_occurrences) {
21
         if ($recurringInvoice->end_type?->isAfter() && $recurringInvoice->occurrences_count >= $recurringInvoice->max_occurrences) {
22
             $recurringInvoice->status = RecurringInvoiceStatus::Ended;
22
             $recurringInvoice->status = RecurringInvoiceStatus::Ended;
23
-            $recurringInvoice->ended_at = now();
23
+            $recurringInvoice->ended_at = company_now();
24
         }
24
         }
25
     }
25
     }
26
 
26
 

Loading…
取消
儲存