From 035bd5beef3f82869ca367537e80780e905e7acf Mon Sep 17 00:00:00 2001 From: Sevan Nerse Date: Fri, 12 Mar 2021 13:17:47 +0300 Subject: [PATCH] if a date could not formatted, method has to return null https://app.bugsnag.com/akaunting/cloud-laravel/errors/6028ede05d7e960018fae8d1 akaunting/module-double-entry#415 --- app/Abstracts/Report.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Abstracts/Report.php b/app/Abstracts/Report.php index d8684fb3f..b1aafa3d0 100644 --- a/app/Abstracts/Report.php +++ b/app/Abstracts/Report.php @@ -369,15 +369,17 @@ abstract class Report public function getFormattedDate($date) { + $formatted_date = null; + switch ($this->getSetting('period')) { case 'yearly': $financial_year = $this->getFinancialYear($this->year); if ($date->greaterThanOrEqualTo($financial_year->getStartDate()) && $date->lessThanOrEqualTo($financial_year->getEndDate())) { if (setting('localisation.financial_denote') == 'begins') { - $i = $financial_year->getStartDate()->copy()->format($this->getYearlyDateFormat()); + $formatted_date = $financial_year->getStartDate()->copy()->format($this->getYearlyDateFormat()); } else { - $i = $financial_year->getEndDate()->copy()->format($this->getYearlyDateFormat()); + $formatted_date = $financial_year->getEndDate()->copy()->format($this->getYearlyDateFormat()); } } @@ -392,18 +394,18 @@ abstract class Report $start = $quarter->getStartDate()->format($this->getQuarterlyDateFormat($this->year)); $end = $quarter->getEndDate()->format($this->getQuarterlyDateFormat($this->year)); + + $formatted_date = $start . '-' . $end; } - $i = $start . '-' . $end; - break; default: - $i = $date->copy()->format($this->getMonthlyDateFormat($this->year)); + $formatted_date = $date->copy()->format($this->getMonthlyDateFormat($this->year)); break; } - return $i; + return $formatted_date; } public function getUrl($action = 'print')