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:
James Cole
2015-07-31 14:20:18 +02:00
parent 4d09235aef
commit 96ddbe7227
12 changed files with 192 additions and 25 deletions

View File

@@ -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);
}
/**

View File

@@ -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);
}
/**

View File

@@ -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);