mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-03 12:45:20 +00:00
First attempt to make the year charts and month reports report the same thing [skip ci]
This commit is contained in:
@@ -47,7 +47,6 @@ class GoogleChartController extends BaseController
|
|||||||
$this->_chart->addColumn('Day of month', 'date');
|
$this->_chart->addColumn('Day of month', 'date');
|
||||||
$this->_chart->addColumn('Balance for ' . $account->name, 'number');
|
$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;
|
$start = $this->_start;
|
||||||
$end = $this->_end;
|
$end = $this->_end;
|
||||||
$count = $account->transactions()->count();
|
$count = $account->transactions()->count();
|
||||||
@@ -62,7 +61,6 @@ class GoogleChartController extends BaseController
|
|||||||
$start = new Carbon($first->date);
|
$start = new Carbon($first->date);
|
||||||
$end = new Carbon($last->date);
|
$end = new Carbon($last->date);
|
||||||
}
|
}
|
||||||
// todo until this part.
|
|
||||||
|
|
||||||
$current = clone $start;
|
$current = clone $start;
|
||||||
|
|
||||||
|
|||||||
@@ -468,24 +468,24 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO This query includes incomes to "shared" accounts which arent income.
|
||||||
|
*
|
||||||
* @param Carbon $date
|
* @param Carbon $date
|
||||||
*
|
*
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function getSumOfIncomesByMonth(Carbon $date)
|
public function getSumOfIncomesByMonth(Carbon $date)
|
||||||
{
|
{
|
||||||
$end = clone $date;
|
/** @var \FireflyIII\Report\ReportInterface $reportRepository */
|
||||||
$date->startOfMonth();
|
$reportRepository = \App::make('FireflyIII\Report\ReportInterface');
|
||||||
$end->endOfMonth();
|
|
||||||
|
|
||||||
$sum = \DB::table('transactions')->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')->leftJoin(
|
$incomes = $reportRepository->getIncomeForMonth($date);
|
||||||
'transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id'
|
$totalIn = 0;
|
||||||
)->where('amount', '>', 0)->where('transaction_types.type', '=', 'Deposit')->where('transaction_journals.date', '>=', $date->format('Y-m-d'))->where(
|
foreach ($incomes as $entry) {
|
||||||
'transaction_journals.date', '<=', $end->format('Y-m-d')
|
$totalIn += floatval($entry->transactions[1]->amount);
|
||||||
)->sum('transactions.amount');
|
}
|
||||||
$sum = floatval($sum);
|
|
||||||
|
|
||||||
return $sum;
|
return $totalIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user