Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix for bug #170, caught thanks to @boerbiet
James Cole2e7d339d7e99
diff --git a/.travis.yml b/.travis.ymlindex f9ca51f24e..abfb2812b8 100644--- a/.travis.yml+++ b/.travis.yml@@ -7,7 +7,9 @@ php:- 7install:- - composer install+ - composer selfupdate+ - composer install --no-dev+ - composer update- php artisan env- mv -v .env.testing .env- php artisan envdiff --git a/app/Support/Navigation.php b/app/Support/Navigation.phpindex 25d8f93298..fe83828573 100644--- a/app/Support/Navigation.php+++ b/app/Support/Navigation.php@@ -70,7 +70,7 @@ class Navigation'1W' => 'addWeek', 'week' => 'addWeek', 'weekly' => 'addWeek','1M' => 'addMonth', 'month' => 'addMonth', 'monthly' => 'addMonth','3M' => 'addMonths', 'quarter' => 'addMonths', 'quarterly' => 'addMonths', '6M' => 'addMonths', 'half-year' => 'addMonths',- 'year' => 'addYear', 'yearly' => 'addYear',+ 'year' => 'addYear', 'yearly' => 'addYear', '1Y' => 'addYear',];$modifierMap = ['quarter' => 3,@@ -82,6 +82,20 @@ class Navigation$subDay = ['week', 'weekly', '1W', 'month', 'monthly', '1M', '3M', 'quarter', 'quarterly', '6M', 'half-year', 'year', 'yearly'];+ // if the range is custom, the end of the period+ // is another X days (x is the difference between start)+ // and end added to $theCurrentEnd+ if ($repeatFreq == 'custom') {+ /** @var Carbon $tStart */+ $tStart = session('start', Carbon::now()->startOfMonth());+ /** @var Carbon $tEnd */+ $tEnd = session('end', Carbon::now()->endOfMonth());+ $diffInDays = $tStart->diffInDays($tEnd);+ $currentEnd->addDays($diffInDays);++ return $currentEnd;+ }+if (!isset($functionMap[$repeatFreq])) {throw new FireflyException('Cannot do endOfPeriod for $repeat_freq "' . $repeatFreq . '"');}@@ -152,6 +166,7 @@ class Navigation$formatMap = ['1D' => '%e %B %Y','daily' => '%e %B %Y',+ 'custom' => '%e %B %Y','1W' => 'Week %W, %Y','week' => 'Week %W, %Y','weekly' => 'Week %W, %Y',@@ -163,6 +178,7 @@ class Navigation'1Y' => '%Y','year' => '%Y','yearly' => '%Y',+ '6M' => '%B %Y',];@@ -198,6 +214,7 @@ class Navigation'quarterly' => 'firstOfQuarter','year' => 'startOfYear','yearly' => 'startOfYear',+ '1Y' => 'startOfYear',];if (isset($functionMap[$repeatFreq])) {$function = $functionMap[$repeatFreq];@@ -214,6 +231,11 @@ class Navigationreturn $date;}+ if ($repeatFreq === 'custom') {+ return $date; // the date is already at the start.+ }++throw new FireflyException('Cannot do startOfPeriod for $repeat_freq "' . $repeatFreq . '"');}@@ -239,12 +261,15 @@ class Navigation'1M' => 'subMonths','monthly' => 'subMonths','year' => 'subYears',+ '1Y' => 'subYears','yearly' => 'subYears',];$modifierMap = ['quarter' => 3,+ '3M' => 3,'quarterly' => 3,'half-year' => 6,+ '6M' => 6,];if (isset($functionMap[$repeatFreq])) {$function = $functionMap[$repeatFreq];@@ -258,6 +283,18 @@ class Navigationreturn $date;}+ // a custom range requires the session start+ // and session end to calculate the difference in days.+ // this is then subtracted from $theDate (* $subtract).+ if($repeatFreq === 'custom') {+ /** @var Carbon $tStart */+ $tStart = session('start', Carbon::now()->startOfMonth());+ /** @var Carbon $tEnd */+ $tEnd = session('end', Carbon::now()->endOfMonth());+ $diffInDays = $tStart->diffInDays($tEnd);+ $date->subDays($diffInDays * $subtract);+ return $date;+ }throw new FireflyException('Cannot do subtractPeriod for $repeat_freq "' . $repeatFreq . '"');}