mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Remove unused methods.
This commit is contained in:
@@ -130,29 +130,6 @@ class CategoryRepository implements CategoryRepositoryInterface
|
|||||||
return $return;
|
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:
|
* A very cryptic method name that means:
|
||||||
*
|
*
|
||||||
@@ -660,30 +637,6 @@ class CategoryRepository implements CategoryRepositoryInterface
|
|||||||
return $return;
|
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:
|
* A very cryptic method name that means:
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -60,20 +60,6 @@ interface CategoryRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function earnedInPeriod(Category $category, Collection $accounts, Carbon $start, Carbon $end): array;
|
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:
|
* 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;
|
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:
|
* A very cryptic method name that means:
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ class CategoryTransformer extends AbstractTransformer
|
|||||||
$start = $this->parameters->get('start');
|
$start = $this->parameters->get('start');
|
||||||
$end = $this->parameters->get('end');
|
$end = $this->parameters->get('end');
|
||||||
if (null !== $start && null !== $end) {
|
if (null !== $start && null !== $end) {
|
||||||
$spent = $this->getSpentInformation($category, $start, $end);
|
$earned = array_values($this->repository->earnedInPeriod($category, new Collection, $start, $end));
|
||||||
$earned = $this->getEarnedInformation($category, $start, $end);
|
$spent = array_values($this->repository->spentInPeriod($category, new Collection, $start, $end));
|
||||||
}
|
}
|
||||||
$data = [
|
$data = [
|
||||||
'id' => (int)$category->id,
|
'id' => (int)$category->id,
|
||||||
@@ -88,77 +88,4 @@ class CategoryTransformer extends AbstractTransformer
|
|||||||
|
|
||||||
return $data;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user