mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Add two methods that have a different way of collecting information #524
This commit is contained in:
parent
dbebfe7c07
commit
b9599d3aa1
@ -414,6 +414,25 @@ class CategoryRepository implements CategoryRepositoryInterface
|
|||||||
return $sum;
|
return $sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $categories
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function spentInPeriodCollector(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string
|
||||||
|
{
|
||||||
|
/** @var JournalCollectorInterface $collector */
|
||||||
|
$collector = app(JournalCollectorInterface::class, [$this->user]);
|
||||||
|
$collector->setRange($start, $end)->setTypes([TransactionType::WITHDRAWAL])->setAccounts($accounts)->setCategories($categories);
|
||||||
|
$set = $collector->getJournals();
|
||||||
|
$sum = strval($set->sum('transaction_amount'));
|
||||||
|
|
||||||
|
return $sum;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection $accounts
|
* @param Collection $accounts
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
@ -429,6 +448,34 @@ class CategoryRepository implements CategoryRepositoryInterface
|
|||||||
return $sum;
|
return $sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function spentInPeriodWithoutCategoryCollector(Collection $accounts, Carbon $start, Carbon $end): string
|
||||||
|
{
|
||||||
|
/** @var JournalCollectorInterface $collector */
|
||||||
|
$collector = app(JournalCollectorInterface::class, [$this->user]);
|
||||||
|
$collector->setRange($start, $end)->setAccounts($accounts)->setTypes([TransactionType::WITHDRAWAL])->withoutCategory();
|
||||||
|
$set = $collector->getJournals();
|
||||||
|
$set = $set->filter(
|
||||||
|
function (Transaction $transaction) {
|
||||||
|
if (bccomp($transaction->transaction_amount, '0') === -1) {
|
||||||
|
return $transaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$sum = strval($set->sum('transaction_amount'));
|
||||||
|
|
||||||
|
return $sum;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
|
@ -140,6 +140,16 @@ interface CategoryRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function spentInPeriod(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string;
|
public function spentInPeriod(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $categories
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function spentInPeriodCollector(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection $accounts
|
* @param Collection $accounts
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
@ -149,6 +159,15 @@ interface CategoryRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function spentInPeriodWithoutCategory(Collection $accounts, Carbon $start, Carbon $end): string;
|
public function spentInPeriodWithoutCategory(Collection $accounts, Carbon $start, Carbon $end): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function spentInPeriodWithoutCategoryCollector(Collection $accounts, Carbon $start, Carbon $end): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $data
|
* @param array $data
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user