mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-06 18:02:42 +00:00
Add new “earned in period” method. #524
This commit is contained in:
@@ -74,6 +74,25 @@ class CategoryRepository implements CategoryRepositoryInterface
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection $categories
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function earnedInPeriodCollector(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string
|
||||||
|
{
|
||||||
|
/** @var JournalCollectorInterface $collector */
|
||||||
|
$collector = app(JournalCollectorInterface::class, [$this->user]);
|
||||||
|
$collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->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
|
||||||
|
|||||||
@@ -41,6 +41,16 @@ interface CategoryRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function earnedInPeriod(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string;
|
public function earnedInPeriod(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 earnedInPeriodCollector(Collection $categories, Collection $accounts, Carbon $start, Carbon $end): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Collection $accounts
|
* @param Collection $accounts
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
|
|||||||
Reference in New Issue
Block a user