mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-03 20:56:21 +00:00
Completed the renaming of some methods.
This commit is contained in:
@@ -320,22 +320,9 @@ class BudgetRepository extends ComponentRepository implements BudgetRepositoryIn
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function balanceInPeriodForList(Budget $budget, Carbon $start, Carbon $end, Collection $accounts)
|
||||
public function balanceInPeriod(Budget $budget, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
return $this->commonBalanceInPeriodForList($budget, $start, $end, $accounts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param bool $shared
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function balanceInPeriod(Budget $budget, Carbon $start, Carbon $end, $shared = true)
|
||||
{
|
||||
return $this->commonBalanceInPeriod($budget, $start, $end, $shared);
|
||||
return $this->commonBalanceInPeriod($budget, $start, $end, $accounts);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -126,19 +126,6 @@ interface BudgetRepositoryInterface
|
||||
*/
|
||||
public function getWithoutBudgetSum(Carbon $start, Carbon $end);
|
||||
|
||||
/**
|
||||
*
|
||||
* Same as ::spentInPeriod but corrects journals for their amount (tags).
|
||||
*
|
||||
* @param Budget $budget
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
* @param boolean $shared
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function balanceInPeriod(Budget $budget, Carbon $start, Carbon $end, $shared = true);
|
||||
|
||||
/**
|
||||
*
|
||||
* Same as ::spentInPeriod but corrects journals for a set of accounts
|
||||
@@ -150,7 +137,7 @@ interface BudgetRepositoryInterface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function balanceInPeriodForList(Budget $budget, Carbon $start, Carbon $end, Collection $accounts);
|
||||
public function balanceInPeriod(Budget $budget, Carbon $start, Carbon $end, Collection $accounts);
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
|
||||
@@ -242,20 +242,6 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
|
||||
->get(['transaction_journals.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @param bool $shared
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function balanceInPeriod(Category $category, Carbon $start, Carbon $end, $shared = false)
|
||||
{
|
||||
return $this->commonBalanceInPeriod($category, $start, $end, $shared);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
* @param Carbon $start
|
||||
@@ -264,9 +250,9 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function balanceInPeriodForList(Category $category, Carbon $start, Carbon $end, Collection $accounts)
|
||||
public function balanceInPeriod(Category $category, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
return $this->commonBalanceInPeriodForList($category, $start, $end, $accounts);
|
||||
return $this->commonBalanceInPeriod($category, $start, $end, $accounts);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -147,21 +147,7 @@ interface CategoryRepositoryInterface
|
||||
public function getWithoutCategory(Carbon $start, Carbon $end);
|
||||
|
||||
/**
|
||||
* Corrected for tags.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param \Carbon\Carbon $start
|
||||
* @param \Carbon\Carbon $end
|
||||
*
|
||||
* @param bool $shared
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function balanceInPeriod(Category $category, Carbon $start, Carbon $end, $shared = false);
|
||||
|
||||
|
||||
/**
|
||||
* Corrected for tags.
|
||||
* Corrected for tags and list of accounts.
|
||||
*
|
||||
* @param Category $category
|
||||
* @param \Carbon\Carbon $start
|
||||
@@ -170,7 +156,7 @@ interface CategoryRepositoryInterface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function balanceInPeriodForList(Category $category, Carbon $start, Carbon $end, Collection $accounts);
|
||||
public function balanceInPeriod(Category $category, Carbon $start, Carbon $end, Collection $accounts);
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
|
||||
@@ -17,55 +17,6 @@ use Illuminate\Support\Collection;
|
||||
class ComponentRepository
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @param bool $shared
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function commonBalanceInPeriod($object, Carbon $start, Carbon $end, $shared = false)
|
||||
{
|
||||
$cache = new CacheProperties; // we must cache this.
|
||||
$cache->addProperty($object->id);
|
||||
$cache->addProperty(get_class($object));
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($shared);
|
||||
$cache->addProperty('balanceInPeriod');
|
||||
|
||||
if ($cache->has()) {
|
||||
return $cache->get(); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
if ($shared === true) { // shared is true: always ignore transfers between accounts!
|
||||
$sum = $object->transactionjournals()
|
||||
->transactionTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::OPENING_BALANCE])
|
||||
->before($end)
|
||||
->after($start)
|
||||
->get(['transaction_journals.*'])->sum('amount');
|
||||
} else {
|
||||
// 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)
|
||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id')
|
||||
->transactionTypes([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::OPENING_BALANCE])
|
||||
->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');
|
||||
}
|
||||
|
||||
$cache->store($sum);
|
||||
|
||||
return $sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @param Carbon $start
|
||||
@@ -74,7 +25,7 @@ class ComponentRepository
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function commonBalanceInPeriodForList($object, Carbon $start, Carbon $end, Collection $accounts)
|
||||
protected function commonBalanceInPeriod($object, Carbon $start, Carbon $end, Collection $accounts)
|
||||
{
|
||||
$cache = new CacheProperties; // we must cache this.
|
||||
$cache->addProperty($object->id);
|
||||
|
||||
Reference in New Issue
Block a user