Skip to content

Firefly III: a personal finances manager

Remove unused methods.

James Cole499e71368311
diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php
index 0551c930c6..926b7f8da7 100644
--- a/app/Repositories/Category/CategoryRepository.php
+++ b/app/Repositories/Category/CategoryRepository.php
@@ -130,29 +130,6 @@ class CategoryRepository implements CategoryRepositoryInterface
return $return;
}
- /** @noinspection MoreThanThreeArgumentsInspection */
- /**
- * @param Collection $categories
- * @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- */
- public function earnedInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array
- {
- /** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
- $collector->setUser($this->user);
- if (0 !== $accounts->count()) {
- $collector->setAccounts($accounts);
- }
-
- $collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->setCategories($categories);
-
- return $collector->getExtractedJournals();
- }
-
/**
* A very cryptic method name that means:
*
@@ -660,30 +637,6 @@ class CategoryRepository implements CategoryRepositoryInterface
return $return;
}
- /**
- * @param Collection $categories
- * @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- */
- public function spentInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array
- {
- /** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
-
-
- $collector->setUser($this->user);
- $collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setCategories($categories);
-
- if ($accounts->count() > 0) {
- $collector->setAccounts($accounts);
- }
-
- return $collector->getExtractedJournals();
- }
-
/**
* A very cryptic method name that means:
*
diff --git a/app/Repositories/Category/CategoryRepositoryInterface.php b/app/Repositories/Category/CategoryRepositoryInterface.php
index 8a062b7194..a6eaad7bcf 100644
--- a/app/Repositories/Category/CategoryRepositoryInterface.php
+++ b/app/Repositories/Category/CategoryRepositoryInterface.php
@@ -60,20 +60,6 @@ interface CategoryRepositoryInterface
*/
public function earnedInPeriod(Category $category, Collection $accounts, Carbon $start, Carbon $end): array;
- /** @noinspection MoreThanThreeArgumentsInspection */
-
- /**
- * @param Collection $categories
- * @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- */
- public function earnedInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
-
- /** @noinspection MoreThanThreeArgumentsInspection */
-
/**
* A very cryptic method name that means:
*
@@ -218,16 +204,6 @@ interface CategoryRepositoryInterface
*/
public function spentInPeriod(Category $category, Collection $accounts, Carbon $start, Carbon $end): array;
- /**
- * @param Collection $categories
- * @param Collection $accounts
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- */
- public function spentInPeriodCollection(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): array;
-
/**
* A very cryptic method name that means:
*
diff --git a/app/Transformers/CategoryTransformer.php b/app/Transformers/CategoryTransformer.php
index fec2cb6141..5f771b7aae 100644
--- a/app/Transformers/CategoryTransformer.php
+++ b/app/Transformers/CategoryTransformer.php
@@ -68,8 +68,8 @@ class CategoryTransformer extends AbstractTransformer
$start = $this->parameters->get('start');
$end = $this->parameters->get('end');
if (null !== $start && null !== $end) {
- $spent = $this->getSpentInformation($category, $start, $end);
- $earned = $this->getEarnedInformation($category, $start, $end);
+ $earned = array_values($this->repository->earnedInPeriod($category, new Collection, $start, $end));
+ $spent = array_values($this->repository->spentInPeriod($category, new Collection, $start, $end));
}
$data = [
'id' => (int)$category->id,
@@ -88,77 +88,4 @@ class CategoryTransformer extends AbstractTransformer
return $data;
}
-
- /**
- * @param Category $category
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- */
- private function getEarnedInformation(Category $category, Carbon $start, Carbon $end): array
- {
- $collection = $this->repository->earnedInPeriodCollection(new Collection([$category]), new Collection, $start, $end);
- $return = [];
- $total = [];
- $currencies = [];
- /** @var Transaction $transaction */
- foreach ($collection as $transaction) {
- $code = $transaction->transaction_currency_code;
- if (!isset($currencies[$code])) {
- $currencies[$code] = $transaction->transactionCurrency;
- }
- $total[$code] = isset($total[$code]) ? bcadd($total[$code], $transaction->transaction_amount) : $transaction->transaction_amount;
- }
- foreach ($total as $code => $earned) {
- /** @var TransactionCurrency $currency */
- $currency = $currencies[$code];
- $return[] = [
- 'currency_id' => $currency->id,
- 'currency_code' => $code,
- 'currency_symbol' => $currency->symbol,
- 'currency_decimal_places' => $currency->decimal_places,
- 'amount' => round($earned, $currency->decimal_places),
- ];
- }
-
- return $return;
- }
-
- /**
- * @param Category $category
- * @param Carbon $start
- * @param Carbon $end
- *
- * @return array
- */
- private function getSpentInformation(Category $category, Carbon $start, Carbon $end): array
- {
- $collection = $this->repository->spentInPeriodCollection(new Collection([$category]), new Collection, $start, $end);
- $return = [];
- $total = [];
- $currencies = [];
- /** @var Transaction $transaction */
- foreach ($collection as $transaction) {
- $code = $transaction->transaction_currency_code;
- if (!isset($currencies[$code])) {
- $currencies[$code] = $transaction->transactionCurrency;
- }
- $total[$code] = isset($total[$code]) ? bcadd($total[$code], $transaction->transaction_amount) : $transaction->transaction_amount;
- }
- foreach ($total as $code => $spent) {
- /** @var TransactionCurrency $currency */
- $currency = $currencies[$code];
- $return[] = [
- 'currency_id' => $currency->id,
- 'currency_code' => $code,
- 'currency_symbol' => $currency->symbol,
- 'currency_decimal_places' => $currency->decimal_places,
- 'amount' => round($spent, $currency->decimal_places),
- ];
- }
-
- return $return;
- }
-
}