Skip to content

Commit

Permalink
Update ProfitLoss.php
Browse files Browse the repository at this point in the history
  • Loading branch information
sausin committed Dec 14, 2018
1 parent a85d979 commit 3422d29
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/Http/Controllers/Reports/ProfitLoss.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,27 @@ public function index()

$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(
Expand Down

0 comments on commit 3422d29

Please sign in to comment.