Merge pull request #1834 from SevanNerse/master
quarterly based reports
This commit is contained in:
commit
53f20c890e
@ -16,6 +16,7 @@ use App\Traits\Charts;
|
|||||||
use App\Traits\DateTime;
|
use App\Traits\DateTime;
|
||||||
use App\Traits\SearchString;
|
use App\Traits\SearchString;
|
||||||
use App\Utilities\Chartjs;
|
use App\Utilities\Chartjs;
|
||||||
|
use Carbon\CarbonPeriod;
|
||||||
use Date;
|
use Date;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@ -277,44 +278,28 @@ abstract class Report
|
|||||||
case 'yearly':
|
case 'yearly':
|
||||||
$start->addYear();
|
$start->addYear();
|
||||||
|
|
||||||
$date = $this->getFormattedDate($start);
|
|
||||||
|
|
||||||
$this->dates[$j] = $date;
|
|
||||||
|
|
||||||
foreach ($this->tables as $table) {
|
|
||||||
$this->footer_totals[$table][$date] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$j += 11;
|
$j += 11;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'quarterly':
|
case 'quarterly':
|
||||||
$start->addQuarter();
|
$start->addQuarter();
|
||||||
|
|
||||||
$date = $this->getFormattedDate($start);
|
|
||||||
|
|
||||||
$this->dates[$j] = $date;
|
|
||||||
|
|
||||||
foreach ($this->tables as $table) {
|
|
||||||
$this->footer_totals[$table][$date] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$j += 2;
|
$j += 2;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$start->addMonth();
|
$start->addMonth();
|
||||||
|
|
||||||
$date = $this->getFormattedDate($start);
|
|
||||||
|
|
||||||
$this->dates[$j] = $date;
|
|
||||||
|
|
||||||
foreach ($this->tables as $table) {
|
|
||||||
$this->footer_totals[$table][$date] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$date = $this->getFormattedDate($start);
|
||||||
|
|
||||||
|
$this->dates[] = $date;
|
||||||
|
|
||||||
|
foreach ($this->tables as $table) {
|
||||||
|
$this->footer_totals[$table][$date] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,15 +373,26 @@ abstract class Report
|
|||||||
switch ($this->getSetting('period')) {
|
switch ($this->getSetting('period')) {
|
||||||
case 'yearly':
|
case 'yearly':
|
||||||
$i = $date->copy()->format($this->getYearlyDateFormat());
|
$i = $date->copy()->format($this->getYearlyDateFormat());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'quarterly':
|
case 'quarterly':
|
||||||
$start = $date->copy()->startOfQuarter()->format($this->getQuarterlyDateFormat($this->year));
|
$quarters = $this->getFiscalBaseQuarters($this->year);
|
||||||
$end = $date->copy()->endOfQuarter()->format($this->getQuarterlyDateFormat($this->year));
|
|
||||||
|
foreach ($quarters as $quarter) {
|
||||||
|
if ($date->lessThan($quarter->getStartDate()) || $date->greaterThan($quarter->getEndDate())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$start = $quarter->getStartDate()->format($this->getQuarterlyDateFormat($this->year));
|
||||||
|
$end = $quarter->getEndDate()->format($this->getQuarterlyDateFormat($this->year));
|
||||||
|
}
|
||||||
|
|
||||||
$i = $start . '-' . $end;
|
$i = $start . '-' . $end;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$i = $date->copy()->format($this->getMonthlyDateFormat($this->year));
|
$i = $date->copy()->format($this->getMonthlyDateFormat($this->year));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,4 +498,16 @@ abstract class Report
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getFiscalBaseQuarters($year)
|
||||||
|
{
|
||||||
|
$periods = [];
|
||||||
|
$fiscal_start = $this->getFinancialStart($year);
|
||||||
|
|
||||||
|
for ($i = 0; $i < 4; $i++) {
|
||||||
|
$periods[] = CarbonPeriod::create($fiscal_start->copy()->addQuarters($i), $fiscal_start->copy()->addQuarters($i + 1)->subDay());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $periods;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user