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

View File

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

View File

@@ -75,7 +75,7 @@ class BillControllerTest extends TestCase
Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Amount::shouldReceive('getCurrencyCode')->andReturn('X');
$this->call('GET', '/bills/create'); $this->call('GET', '/bills/create');
$this->assertViewHas('subTitle', 'Create new'); $this->assertViewHas('subTitle', 'Create new bill');
$this->assertResponseOk(); $this->assertResponseOk();
} }