Skip to content

Firefly III: a personal finances manager

Remove unused code.

James Colebc825a860379
diff --git a/app/Generator/Chart/Category/CategoryChartGeneratorInterface.php b/app/Generator/Chart/Category/CategoryChartGeneratorInterface.php
index d5950bbaeb..ee8ff8eb96 100644
--- a/app/Generator/Chart/Category/CategoryChartGeneratorInterface.php
+++ b/app/Generator/Chart/Category/CategoryChartGeneratorInterface.php
@@ -30,14 +30,6 @@ interface CategoryChartGeneratorInterface
*/
public function all(Collection $entries): array;
- /**
- * @param Collection $categories
- * @param Collection $entries
- *
- * @return array
- */
- public function earnedInPeriod(Collection $categories, Collection $entries): array;
-
/**
* @param Collection $entries
*
@@ -66,11 +58,4 @@ interface CategoryChartGeneratorInterface
*/
public function pieChart(array $data): array;
- /**
- * @param Collection $categories
- * @param Collection $entries
- *
- * @return array
- */
- public function spentInPeriod(Collection $categories, Collection $entries): array;
}
diff --git a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php
index 7aea9c65cd..1787125c23 100644
--- a/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php
+++ b/app/Generator/Chart/Category/ChartJsCategoryChartGenerator.php
@@ -58,39 +58,6 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
return $data;
}
- /**
- * @param Collection $categories
- * @param Collection $entries
- *
- * @return array
- */
- public function earnedInPeriod(Collection $categories, Collection $entries): array
- {
-
- // language:
- $format = (string)trans('config.month');
-
- $data = [
- 'count' => 0,
- 'labels' => [],
- 'datasets' => [],
- ];
-
- foreach ($categories as $category) {
- $data['labels'][] = $category->name;
- }
-
- foreach ($entries as $entry) {
- $date = $entry[0]->formatLocalized($format);
- array_shift($entry);
- $data['count']++;
- $data['datasets'][] = ['label' => $date, 'data' => $entry];
- }
-
- return $data;
-
- }
-
/**
* @param Collection $entries
*
@@ -204,36 +171,4 @@ class ChartJsCategoryChartGenerator implements CategoryChartGeneratorInterface
return $data;
}
- /**
- * @param Collection $categories
- * @param Collection $entries
- *
- * @return array
- */
- public function spentInPeriod(Collection $categories, Collection $entries): array
- {
-
- // language:
- $format = (string)trans('config.month');
-
- $data = [
- 'count' => 0,
- 'labels' => [],
- 'datasets' => [],
- ];
-
- foreach ($categories as $category) {
- $data['labels'][] = $category->name;
- }
-
- foreach ($entries as $entry) {
- $date = $entry[0]->formatLocalized($format);
- array_shift($entry);
- $data['count']++;
- $data['datasets'][] = ['label' => $date, 'data' => $entry];
- }
-
- return $data;
-
- }
}
diff --git a/app/Generator/Report/Category/MonthReportGenerator.php b/app/Generator/Report/Category/MonthReportGenerator.php
index 78713fb205..0f97417001 100644
--- a/app/Generator/Report/Category/MonthReportGenerator.php
+++ b/app/Generator/Report/Category/MonthReportGenerator.php
@@ -60,8 +60,8 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
$accountIds = join(',', $this->accounts->pluck('id')->toArray());
$categoryIds = join(',', $this->categories->pluck('id')->toArray());
$reportType = 'category';
- $accountSummary = $this->getAccountSummary();
- $categorySummary = $this->getCategorySummary();
+ $accountSummary = $this->getObjectSummary($this->getSpentAccountSummary(), $this->getEarnedAccountSummary());
+ $categorySummary = $this->getObjectSummary($this->getSpentCategorySummary(), $this->getEarnedCategorySummary());
$averageExpenses = $this->getAverages($this->getExpenses(), SORT_ASC);
$averageIncome = $this->getAverages($this->getIncome(), SORT_DESC);
$topExpenses = $this->getTopExpenses();
@@ -129,45 +129,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
return $this;
}
- /**
- * @return array
- */
- private function getAccountSummary(): array
- {
- $spent = $this->getSpentAccountSummary();
- $earned = $this->getEarnedAccountSummary();
- $return = [];
-
- /**
- * @var int $accountId
- * @var string $entry
- */
- foreach ($spent as $accountId => $entry) {
- if (!isset($return[$accountId])) {
- $return[$accountId] = ['spent' => 0, 'earned' => 0];
- }
-
- $return[$accountId]['spent'] = $entry;
- }
- unset($entry);
-
- /**
- * @var int $accountId
- * @var string $entry
- */
- foreach ($earned as $accountId => $entry) {
- if (!isset($return[$accountId])) {
- $return[$accountId] = ['spent' => 0, 'earned' => 0];
- }
-
- $return[$accountId]['earned'] = $entry;
- }
-
-
- return $return;
-
- }
-
/**
* @param Collection $collection
* @param int $sortFlag
@@ -212,43 +173,6 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
return $result;
}
- /**
- * @return array
- */
- private function getCategorySummary(): array
- {
- $spent = $this->getSpentCategorySummary();
- $earned = $this->getEarnedCategorySummary();
- $return = [];
-
- /**
- * @var int $categoryId
- * @var string $entry
- */
- foreach ($spent as $categoryId => $entry) {
- if (!isset($return[$categoryId])) {
- $return[$categoryId] = ['spent' => 0, 'earned' => 0];
- }
-
- $return[$categoryId]['spent'] = $entry;
- }
- unset($entry);
-
- /**
- * @var int $categoryId
- * @var string $entry
- */
- foreach ($earned as $categoryId => $entry) {
- if (!isset($return[$categoryId])) {
- $return[$categoryId] = ['spent' => 0, 'earned' => 0];
- }
-
- $return[$categoryId]['earned'] = $entry;
- }
-
- return $return;
- }
-
/**
* @return array
*/
@@ -331,6 +255,45 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
return $transactions;
}
+ /**
+ * @param array $spent
+ * @param array $earned
+ *
+ * @return array
+ */
+ private function getObjectSummary(array $spent, array $earned): array
+ {
+ $return = [];
+
+ /**
+ * @var int $accountId
+ * @var string $entry
+ */
+ foreach ($spent as $accountId => $entry) {
+ if (!isset($return[$accountId])) {
+ $return[$accountId] = ['spent' => 0, 'earned' => 0];
+ }
+
+ $return[$accountId]['spent'] = $entry;
+ }
+ unset($entry);
+
+ /**
+ * @var int $accountId
+ * @var string $entry
+ */
+ foreach ($earned as $accountId => $entry) {
+ if (!isset($return[$accountId])) {
+ $return[$accountId] = ['spent' => 0, 'earned' => 0];
+ }
+
+ $return[$accountId]['earned'] = $entry;
+ }
+
+
+ return $return;
+ }
+
/**
* @return array
*/