mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Reorganized the category charts in the year report to properly reflect income and expenses. Necessary to facilitate the changes needed for bug #99
This commit is contained in:
@@ -315,7 +315,7 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*/
|
||||
public function spentInPeriodCorrected(Budget $budget, Carbon $start, Carbon $end, $shared = true)
|
||||
{
|
||||
return $this->spentInPeriod($budget, $start, $end, $shared);
|
||||
return $this->balanceInPeriod($budget, $start, $end, $shared);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -185,7 +185,7 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
|
||||
*/
|
||||
public function spentInPeriodCorrected(Category $category, Carbon $start, Carbon $end, $shared = false)
|
||||
{
|
||||
return $this->spentInPeriod($category, $start, $end, $shared);
|
||||
return $this->balanceInPeriod($category, $start, $end, $shared);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -24,7 +24,7 @@ class ComponentRepository
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function spentInPeriod($object, Carbon $start, Carbon $end, $shared = false)
|
||||
protected function balanceInPeriod($object, Carbon $start, Carbon $end, $shared = false)
|
||||
{
|
||||
$cache = new CacheProperties; // we must cache this.
|
||||
$cache->addProperty($object->id);
|
||||
@@ -45,14 +45,13 @@ class ComponentRepository
|
||||
// do something else, SEE budgets.
|
||||
// get all journals in this month where the asset account is NOT shared.
|
||||
$sum = $object->transactionjournals()->before($end)->after($start)
|
||||
->transactionTypes(['Withdrawal'])
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||
->leftJoin(
|
||||
'account_meta', function (JoinClause $join) {
|
||||
$join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
|
||||
}
|
||||
)->where('account_meta.data', '!=', '"sharedAsset"')->get(['transaction_journals.*'])->sum('amount');
|
||||
)->where('account_meta.data', '!=', '"sharedAsset"')->get(['transaction_journals.*'])->sum('correct_amount');
|
||||
}
|
||||
|
||||
$cache->store($sum);
|
||||
|
Reference in New Issue
Block a user