|
@@ -29,7 +29,8 @@ class DateRangeService
|
29
|
29
|
private function generateDateRangeOptions(): array
|
30
|
30
|
{
|
31
|
31
|
$earliestDate = Carbon::parse(Accounting::getEarliestTransactionDate());
|
32
|
|
- $currentDate = now();
|
|
32
|
+ $currentDate = company_today();
|
|
33
|
+ $currentYear = $currentDate->year;
|
33
|
34
|
$fiscalYearStartCurrent = Carbon::parse($this->fiscalYearStartDate);
|
34
|
35
|
|
35
|
36
|
$options = [
|
|
@@ -46,7 +47,7 @@ class DateRangeService
|
46
|
47
|
foreach ($period as $date) {
|
47
|
48
|
$options['Fiscal Year']['FY-' . $date->year] = $date->year;
|
48
|
49
|
|
49
|
|
- $fiscalYearStart = $fiscalYearStartCurrent->copy()->subYears($currentDate->year - $date->year);
|
|
50
|
+ $fiscalYearStart = $fiscalYearStartCurrent->copy()->subYears($currentYear - $date->year);
|
50
|
51
|
|
51
|
52
|
for ($i = 0; $i < 4; $i++) {
|
52
|
53
|
$quarterNumber = $i + 1;
|
|
@@ -86,7 +87,7 @@ class DateRangeService
|
86
|
87
|
continue;
|
87
|
88
|
}
|
88
|
89
|
|
89
|
|
- $expectedEnd = $expectedEnd->isFuture() ? now()->startOfDay() : $expectedEnd;
|
|
90
|
+ $expectedEnd = $expectedEnd->isFuture() ? company_today() : $expectedEnd;
|
90
|
91
|
|
91
|
92
|
if ($startDate->eq($expectedStart) && $endDate->eq($expectedEnd)) {
|
92
|
93
|
return $key; // Return the matching range key (e.g., "FY-2024")
|
|
@@ -99,17 +100,19 @@ class DateRangeService
|
99
|
100
|
|
100
|
101
|
private function getExpectedDateRange(string $type, string $key): array
|
101
|
102
|
{
|
|
103
|
+ $currentYear = company_today()->year;
|
|
104
|
+
|
102
|
105
|
switch ($type) {
|
103
|
106
|
case 'Fiscal Year':
|
104
|
107
|
$year = (int) substr($key, 3);
|
105
|
|
- $start = Carbon::parse($this->fiscalYearStartDate)->subYears(now()->year - $year)->startOfDay();
|
106
|
|
- $end = Carbon::parse($this->fiscalYearEndDate)->subYears(now()->year - $year)->startOfDay();
|
|
108
|
+ $start = Carbon::parse($this->fiscalYearStartDate)->subYears($currentYear - $year)->startOfDay();
|
|
109
|
+ $end = Carbon::parse($this->fiscalYearEndDate)->subYears($currentYear - $year)->startOfDay();
|
107
|
110
|
|
108
|
111
|
break;
|
109
|
112
|
|
110
|
113
|
case 'Fiscal Quarter':
|
111
|
114
|
[$quarter, $year] = explode('-', substr($key, 3));
|
112
|
|
- $start = Carbon::parse($this->fiscalYearStartDate)->subYears(now()->year - $year)->addMonths(($quarter - 1) * 3)->startOfDay();
|
|
115
|
+ $start = Carbon::parse($this->fiscalYearStartDate)->subYears($currentYear - $year)->addMonths(($quarter - 1) * 3)->startOfDay();
|
113
|
116
|
$end = $start->copy()->addMonths(3)->subDay()->startOfDay();
|
114
|
117
|
|
115
|
118
|
break;
|