Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Reinstated "periodshow" and some other stuff.
James Cole3d3842b9d611
diff --git a/app/lib/FireflyIII/Shared/Toolkit/Date.php b/app/lib/FireflyIII/Shared/Toolkit/Date.phpindex b011716bd6..d0ddc9f6e2 100644--- a/app/lib/FireflyIII/Shared/Toolkit/Date.php+++ b/app/lib/FireflyIII/Shared/Toolkit/Date.php@@ -23,7 +23,7 @@ class Datepublic function addPeriod(Carbon $theDate, $repeatFreq, $skip){$date = clone $theDate;- $add = ($skip + 1);+ $add = ($skip + 1);switch ($repeatFreq) {default:throw new FireflyException('Cannot do addPeriod for $repeat_freq ' . $repeatFreq);@@ -47,6 +47,7 @@ class Date$months = $add * 6;$date->addMonths($months);break;+ case 'year':case 'yearly':$date->addYears($add);break;@@ -94,6 +95,28 @@ class Datereturn $currentEnd;}+ public function periodShow(Carbon $date, $repeatFrequency)+ {+ switch ($repeatFrequency) {+ default:+ throw new FireflyException('No date formats for frequency "' . $repeatFrequency . '"!');+ break;+ case 'daily':+ return $date->format('j F Y');+ break;+ case 'weekly':+ return $date->format('\W\e\e\k W, Y');+ break;+ case 'monthly':+ case 'month':+ return $date->format('F Y');+ break;+ case 'yearly':+ return $date->format('Y');+ break;+ }+ }+/*** @param Carbon $theDate* @param $repeatFreq@@ -136,4 +159,46 @@ class Datereturn $date;}-}\ No newline at end of file++ /**+ * @param Carbon $date+ * @param $repeatFreq+ * @param int $subtract+ *+ * @return Carbon+ * @throws FireflyException+ */+ public function subtractPeriod(Carbon $theDate, $repeatFreq, $subtract = 1)+ {+ $date = clone $theDate;+ switch ($repeatFreq) {+ default:+ throw new FireflyException('Cannot do subtractPeriod for $repeat_freq ' . $repeatFreq);+ break;+ case 'daily':+ $date->subDays($subtract);+ break;+ case 'weekly':+ $date->subWeeks($subtract);+ break;+ case 'monthly':+ $date->subMonths($subtract);+ break;+ case 'quarterly':+ $months = $subtract * 3;+ $date->subMonths($months);+ break;+ case 'half-year':+ $months = $subtract * 6;+ $date->subMonths($months);+ break;+ case 'year':+ case 'yearly':+ $date->subYears($subtract);+ break;+ }++ return $date;+ }+}+diff --git a/app/lib/FireflyIII/Shared/Toolkit/Filter.php b/app/lib/FireflyIII/Shared/Toolkit/Filter.phpindex f6c923f15a..f9051252d2 100644--- a/app/lib/FireflyIII/Shared/Toolkit/Filter.php+++ b/app/lib/FireflyIII/Shared/Toolkit/Filter.php@@ -1,15 +1,9 @@<?php-/**- * Created by PhpStorm.- * User: sander- * Date: 11/11/14- * Time: 11:17- */namespace FireflyIII\Shared\Toolkit;use Carbon\Carbon;-use Firefly\Exception\FireflyException;+use FireflyIII\Exception\FireflyException;/*** Class Filter