Update ProfitLoss.php

This commit is contained in:
sausin 2018-12-14 20:01:30 +05:30 committed by GitHub
parent a85d979bf2
commit 3422d29868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,13 +27,26 @@ class ProfitLoss extends Controller
$status = request('status');
$year = request('year', Date::now()->year);
// check and assign year start
if (($financial_start = Date::parse(setting('general.financial_start')))->month != 1) {
// check if a specific year is requested
if (!is_null(request('year'))) {
$financial_start->year = $year;
}
$year = [$financial_start->format('Y'), $financial_start->addYear()->format('Y')];
$financial_start->subYear()->subQuarter();
}
$income_categories = Category::enabled()->type('income')->orderBy('name')->pluck('name', 'id')->toArray();
$expense_categories = Category::enabled()->type('expense')->orderBy('name')->pluck('name', 'id')->toArray();
// Dates
for ($j = 1; $j <= 12; $j++) {
$dates[$j] = Date::parse($year . '-' . $j)->quarter;
$ym_string = is_array($year) ? $financial_start->addQuarter()->format('Y-m') : $year . '-' . $j;
$dates[$j] = Date::parse($ym_string)->quarter;
// Totals
$totals[$dates[$j]] = array(