First attempt to make the year charts and month reports report the same thing [skip ci]

This commit is contained in:
James Cole 2015-01-01 21:20:41 +01:00
parent cb8e082414
commit 823afe877b
2 changed files with 10 additions and 12 deletions

View File

@ -47,7 +47,6 @@ class GoogleChartController extends BaseController
$this->_chart->addColumn('Day of month', 'date');
$this->_chart->addColumn('Balance for ' . $account->name, 'number');
// TODO this can be combined in some method, it's coming up quite often, is it?
$start = $this->_start;
$end = $this->_end;
$count = $account->transactions()->count();
@ -62,7 +61,6 @@ class GoogleChartController extends BaseController
$start = new Carbon($first->date);
$end = new Carbon($last->date);
}
// todo until this part.
$current = clone $start;

View File

@ -468,24 +468,24 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
}
/**
* TODO This query includes incomes to "shared" accounts which arent income.
*
* @param Carbon $date
*
* @return float
*/
public function getSumOfIncomesByMonth(Carbon $date)
{
$end = clone $date;
$date->startOfMonth();
$end->endOfMonth();
/** @var \FireflyIII\Report\ReportInterface $reportRepository */
$reportRepository = \App::make('FireflyIII\Report\ReportInterface');
$sum = \DB::table('transactions')->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->leftJoin(
'transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id'
)->where('amount', '>', 0)->where('transaction_types.type', '=', 'Deposit')->where('transaction_journals.date', '>=', $date->format('Y-m-d'))->where(
'transaction_journals.date', '<=', $end->format('Y-m-d')
)->sum('transactions.amount');
$sum = floatval($sum);
$incomes = $reportRepository->getIncomeForMonth($date);
$totalIn = 0;
foreach ($incomes as $entry) {
$totalIn += floatval($entry->transactions[1]->amount);
}
return $sum;
return $totalIn;
}
/**