moved financial quarters to trait
This commit is contained in:
parent
53f20c890e
commit
8cfbf82e0a
@ -16,7 +16,6 @@ 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;
|
||||||
|
|
||||||
@ -376,7 +375,7 @@ abstract class Report
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 'quarterly':
|
case 'quarterly':
|
||||||
$quarters = $this->getFiscalBaseQuarters($this->year);
|
$quarters = $this->getFinancialQuarters($this->year);
|
||||||
|
|
||||||
foreach ($quarters as $quarter) {
|
foreach ($quarters as $quarter) {
|
||||||
if ($date->lessThan($quarter->getStartDate()) || $date->greaterThan($quarter->getEndDate())) {
|
if ($date->lessThan($quarter->getStartDate()) || $date->greaterThan($quarter->getEndDate())) {
|
||||||
@ -498,16 +497,4 @@ 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Traits;
|
namespace App\Traits;
|
||||||
|
|
||||||
use App\Traits\SearchString;
|
use App\Traits\SearchString;
|
||||||
|
use Carbon\CarbonPeriod;
|
||||||
use Date;
|
use Date;
|
||||||
|
|
||||||
trait DateTime
|
trait DateTime
|
||||||
@ -117,6 +118,18 @@ trait DateTime
|
|||||||
return $financial_start;
|
return $financial_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFinancialQuarters($year)
|
||||||
|
{
|
||||||
|
$quarters = [];
|
||||||
|
$start = $this->getFinancialStart($year);
|
||||||
|
|
||||||
|
for ($i = 0; $i < 4; $i++) {
|
||||||
|
$quarters[] = CarbonPeriod::create($start->copy()->addQuarters($i), $start->copy()->addQuarters($i + 1)->subDay());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $quarters;
|
||||||
|
}
|
||||||
|
|
||||||
public function getMonthlyDateFormat($year = null)
|
public function getMonthlyDateFormat($year = null)
|
||||||
{
|
{
|
||||||
$format = 'M';
|
$format = 'M';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user