This commit is contained in:
James Cole
2015-05-05 10:30:39 +02:00
parent 23a09b7081
commit 8e20b78731
4 changed files with 19 additions and 22 deletions

View File

@@ -91,11 +91,11 @@ class ReportHelper implements ReportHelperInterface
$end = Carbon::now();
$months = [];
while ($start <= $end) {
$year = $start->format('Y');
$year = $start->year;
$months[$year][] = [
'formatted' => $start->format('F Y'),
'month' => intval($start->format('m')),
'year' => intval($start->format('Y')),
'month' => $start->month,
'year' => $year,
];
$start->addMonth();
}
@@ -114,10 +114,10 @@ class ReportHelper implements ReportHelperInterface
$end = Carbon::now();
$years = [];
while ($start <= $end) {
$years[] = $start->format('Y');
$years[] = $start->year;
$start->addYear();
}
$years[] = Carbon::now()->format('Y');
$years[] = Carbon::now()->year;
// force the current year.
$years = array_unique($years);

View File

@@ -313,21 +313,21 @@ Breadcrumbs::register(
Breadcrumbs::register(
'reports.year', function (Generator $breadcrumbs, Carbon $date) {
$breadcrumbs->parent('reports.index');
$breadcrumbs->push($date->format('Y'), route('reports.year', $date->format('Y')));
$breadcrumbs->push($date->year, route('reports.year', $date->year));
}
);
Breadcrumbs::register(
'reports.month', function (Generator $breadcrumbs, Carbon $date) {
$breadcrumbs->parent('reports.index');
$breadcrumbs->push('Monthly report for ' . $date->format('F Y'), route('reports.month', $date));
$breadcrumbs->push('Monthly report for ' . $date->format('F Y'), route('reports.month', [$date->year, $date->month]));
}
);
Breadcrumbs::register(
'reports.budget', function (Generator $breadcrumbs, Carbon $date) {
$breadcrumbs->parent('reports.index');
$breadcrumbs->push('Budget report for ' . $date->format('F Y'), route('reports.budget', $date));
$breadcrumbs->push('Budget report for ' . $date->format('F Y'), route('reports.budget', [$date->year, $date->month]));
}
);

View File

@@ -148,9 +148,8 @@ class Navigation
}
if (isset($specials[$repeatFreq])) {
$month = intval($theCurrentEnd->format('m'));
$currentEnd->endOfYear();
if ($month <= 6) {
if ($theCurrentEnd->month <= 6) {
$currentEnd->subMonths(6);
}
}
@@ -184,7 +183,7 @@ class Navigation
$date->lastOfQuarter()->addDay();
break;
case '6M':
if (intval($date->format('m')) >= 7) {
if ($date->month >= 7) {
$date->startOfYear()->addYear();
} else {
$date->startOfYear()->addMonths(6);
@@ -230,9 +229,8 @@ class Navigation
return $date;
}
if ($range == '6M') {
$month = intval($date->format('m'));
$date->startOfYear();
if ($month <= 6) {
if ($date->month <= 6) {
$date->subMonths(6);
}
@@ -260,16 +258,15 @@ class Navigation
return $date->format($formatMap[$range]);
}
if ($range == '3M') {
$month = intval($date->format('m'));
return 'Q' . ceil(($month / 12) * 4) . ' ' . $date->format('Y');
return 'Q' . ceil(($date->month / 12) * 4) . ' ' . $date->year;
}
if ($range == '6M') {
$month = intval($date->format('m'));
$half = ceil(($month / 12) * 2);
$half = ceil(($date->month / 12) * 2);
$halfName = $half == 1 ? 'first' : 'second';
return $halfName . ' half of ' . $date->format('Y');
return $halfName . ' half of ' . $date->year;
}
throw new FireflyException('No _periodName() for range "' . $range . '"');
}
@@ -333,7 +330,7 @@ class Navigation
return $date;
}
if ($repeatFreq == 'half-year' || $repeatFreq == '6M') {
$month = intval($date->format('m'));
$month = $date->month;
$date->startOfYear();
if ($month >= 7) {
$date->addMonths(6);
@@ -411,7 +408,7 @@ class Navigation
return $end;
}
if ($range == '6M') {
if (intval($start->format('m')) >= 7) {
if ($start->month >= 7) {
$end->endOfYear();
} else {
$end->startOfYear()->addMonths(6);
@@ -445,7 +442,7 @@ class Navigation
return $start;
}
if ($range == '6M') {
if (intval($start->format('m')) >= 7) {
if ($start->month >= 7) {
$start->startOfYear()->addMonths(6);
} else {
$start->startOfYear();