Merge pull request #1925 from SevanNerse/fix-reports

if a date could not formatted, method has to return null
This commit is contained in:
Denis Duliçi 2021-03-12 15:01:28 +03:00 committed by GitHub
commit e2d5872417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -369,15 +369,17 @@ abstract class Report
public function getFormattedDate($date) public function getFormattedDate($date)
{ {
$formatted_date = null;
switch ($this->getSetting('period')) { switch ($this->getSetting('period')) {
case 'yearly': case 'yearly':
$financial_year = $this->getFinancialYear($this->year); $financial_year = $this->getFinancialYear($this->year);
if ($date->greaterThanOrEqualTo($financial_year->getStartDate()) && $date->lessThanOrEqualTo($financial_year->getEndDate())) { if ($date->greaterThanOrEqualTo($financial_year->getStartDate()) && $date->lessThanOrEqualTo($financial_year->getEndDate())) {
if (setting('localisation.financial_denote') == 'begins') { if (setting('localisation.financial_denote') == 'begins') {
$i = $financial_year->getStartDate()->copy()->format($this->getYearlyDateFormat()); $formatted_date = $financial_year->getStartDate()->copy()->format($this->getYearlyDateFormat());
} else { } 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)); $start = $quarter->getStartDate()->format($this->getQuarterlyDateFormat($this->year));
$end = $quarter->getEndDate()->format($this->getQuarterlyDateFormat($this->year)); $end = $quarter->getEndDate()->format($this->getQuarterlyDateFormat($this->year));
}
$i = $start . '-' . $end; $formatted_date = $start . '-' . $end;
}
break; break;
default: default:
$i = $date->copy()->format($this->getMonthlyDateFormat($this->year)); $formatted_date = $date->copy()->format($this->getMonthlyDateFormat($this->year));
break; break;
} }
return $i; return $formatted_date;
} }
public function getUrl($action = 'print') public function getUrl($action = 'print')