mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 14:48:11 +00:00
Code cleanup.
This commit is contained in:
@@ -30,19 +30,11 @@ use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Trait TransactionCalculation
|
||||
*
|
||||
*/
|
||||
trait TransactionCalculation
|
||||
{
|
||||
/**
|
||||
* Get all expenses for a set of accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $opposing
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getExpensesForOpposing(Collection $accounts, Collection $opposing, Carbon $start, Carbon $end): array
|
||||
{
|
||||
@@ -51,23 +43,16 @@ trait TransactionCalculation
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts($total)
|
||||
->setRange($start, $end)
|
||||
->withAccountInformation()
|
||||
->setTypes([TransactionType::WITHDRAWAL]);
|
||||
->setRange($start, $end)
|
||||
->withAccountInformation()
|
||||
->setTypes([TransactionType::WITHDRAWAL])
|
||||
;
|
||||
|
||||
return $collector->getExtractedJournals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all expenses by tags.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $tags
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
protected function getExpensesForTags(Collection $accounts, Collection $tags, Carbon $start, Carbon $end): array
|
||||
{
|
||||
@@ -75,40 +60,28 @@ trait TransactionCalculation
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])
|
||||
->setTags($tags)->withAccountInformation();
|
||||
->setTags($tags)->withAccountInformation()
|
||||
;
|
||||
|
||||
return $collector->getExtractedJournals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function that collects expenses for the given budgets.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $budgets
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getExpensesInBudgets(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end): array
|
||||
{
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])
|
||||
->setBudgets($budgets)->withAccountInformation();
|
||||
->setBudgets($budgets)->withAccountInformation()
|
||||
;
|
||||
|
||||
return $collector->getExtractedJournals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all expenses in a period for categories.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $categories
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getExpensesInCategories(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): array
|
||||
{
|
||||
@@ -119,44 +92,33 @@ trait TransactionCalculation
|
||||
->setRange($start, $end)
|
||||
->setTypes([TransactionType::WITHDRAWAL, TransactionType::TRANSFER])
|
||||
->setCategories($categories)
|
||||
->withAccountInformation();
|
||||
->withAccountInformation()
|
||||
;
|
||||
|
||||
return $collector->getExtractedJournals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all income for a period and a bunch of categories.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $categories
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getIncomeForCategories(Collection $accounts, Collection $categories, Carbon $start, Carbon $end): array
|
||||
{
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])
|
||||
->setCategories($categories)->withAccountInformation();
|
||||
->setCategories($categories)->withAccountInformation()
|
||||
;
|
||||
|
||||
return $collector->getExtractedJournals();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the income for a set of accounts.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $opposing
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getIncomeForOpposing(Collection $accounts, Collection $opposing, Carbon $start, Carbon $end): array
|
||||
{
|
||||
$total = $accounts->merge($opposing);
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts($total)->setRange($start, $end)->withAccountInformation()->setTypes([TransactionType::DEPOSIT]);
|
||||
@@ -166,20 +128,14 @@ trait TransactionCalculation
|
||||
|
||||
/**
|
||||
* Get all income by tag.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Collection $tags
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getIncomeForTags(Collection $accounts, Collection $tags, Carbon $start, Carbon $end): array
|
||||
{
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setAccounts($accounts)->setRange($start, $end)->setTypes([TransactionType::DEPOSIT, TransactionType::TRANSFER])
|
||||
->setTags($tags)->withAccountInformation();
|
||||
->setTags($tags)->withAccountInformation()
|
||||
;
|
||||
|
||||
return $collector->getExtractedJournals();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user