mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Expand income and expense info without a category.
This commit is contained in:
parent
ef6f00fcf5
commit
b100c02779
@ -564,9 +564,17 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
$return = [];
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($set as $transaction) {
|
||||
$currencyId = $transaction->transaction_currency_id;
|
||||
$return[$currencyId] = $return[$currencyId] ?? '0';
|
||||
$return[$currencyId] = bcadd($return[$currencyId], $transaction->transaction_amount);
|
||||
$currencyId = $transaction->transaction_currency_id;
|
||||
if (!isset($return[$currencyId])) {
|
||||
$return[$currencyId] = [
|
||||
'spent' => '0',
|
||||
'currency_id' => $currencyId,
|
||||
'currency_symbol' => $transaction->transaction_currency_symbol,
|
||||
'currency_code' => $transaction->transaction_currency_code,
|
||||
'currency_decimal_places' => $transaction->transaction_currency_dp,
|
||||
];
|
||||
}
|
||||
$return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $transaction->transaction_amount);
|
||||
}
|
||||
|
||||
return $return;
|
||||
@ -783,4 +791,59 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A very cryptic method name that means:
|
||||
*
|
||||
* Get me the amount earned in this period, grouped per currency, where no category was set.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function earnedInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array
|
||||
{
|
||||
/** @var TransactionCollectorInterface $collector */
|
||||
$collector = app(TransactionCollectorInterface::class);
|
||||
$collector->setUser($this->user);
|
||||
$collector->setRange($start, $end)->setTypes([TransactionType::DEPOSIT])->withoutCategory();
|
||||
|
||||
if ($accounts->count() > 0) {
|
||||
$collector->setAccounts($accounts);
|
||||
}
|
||||
if (0 === $accounts->count()) {
|
||||
$collector->setAllAssetAccounts();
|
||||
}
|
||||
|
||||
$set = $collector->getTransactions();
|
||||
$set = $set->filter(
|
||||
function (Transaction $transaction) {
|
||||
if (bccomp($transaction->transaction_amount, '0') === 1) {
|
||||
return $transaction;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
$return = [];
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($set as $transaction) {
|
||||
$currencyId = $transaction->transaction_currency_id;
|
||||
if (!isset($return[$currencyId])) {
|
||||
$return[$currencyId] = [
|
||||
'spent' => '0',
|
||||
'currency_id' => $currencyId,
|
||||
'currency_symbol' => $transaction->transaction_currency_symbol,
|
||||
'currency_code' => $transaction->transaction_currency_code,
|
||||
'currency_decimal_places' => $transaction->transaction_currency_dp,
|
||||
];
|
||||
}
|
||||
$return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $transaction->transaction_amount);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
@ -191,10 +191,23 @@ interface CategoryRepositoryInterface
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function spentInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
|
||||
|
||||
/**
|
||||
* A very cryptic method name that means:
|
||||
*
|
||||
* Get me the amount earned in this period, grouped per currency, where no category was set.
|
||||
*
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function earnedInPeriodPcWoCategory(Collection $accounts, Carbon $start, Carbon $end): array;
|
||||
|
||||
/**
|
||||
* @param Collection $categories
|
||||
* @param Collection $accounts
|
||||
|
Loading…
Reference in New Issue
Block a user