mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-02-07 04:36:24 +00:00
🤖 Auto commit for release 'develop' on 2026-01-23
This commit is contained in:
@@ -66,7 +66,7 @@ class BalanceController extends Controller
|
||||
*/
|
||||
public function general(Collection $accounts, Carbon $start, Carbon $end)
|
||||
{
|
||||
$report = ['budgets' => [], 'accounts' => []];
|
||||
$report = ['budgets' => [], 'accounts' => []];
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
@@ -77,38 +77,39 @@ class BalanceController extends Controller
|
||||
|
||||
/** @var Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
$budgetId = $budget->id;
|
||||
$report['budgets'][$budgetId] = [
|
||||
$budgetId = $budget->id;
|
||||
$report['budgets'][$budgetId] = [
|
||||
'budget_id' => $budgetId,
|
||||
'budget_name' => $budget->name,
|
||||
'spent' => [], // per account
|
||||
'sums' => [] // per currency
|
||||
'sums' => [], // per currency
|
||||
];
|
||||
$spent = [];
|
||||
$spent = [];
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$journals = $collector
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$journals = $collector
|
||||
->setRange($start, $end)
|
||||
->setSourceAccounts($accounts)
|
||||
->setTypes([TransactionTypeEnum::WITHDRAWAL->value])
|
||||
->setBudget($budget)
|
||||
->getExtractedJournals();
|
||||
->getExtractedJournals()
|
||||
;
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($journals as $journal) {
|
||||
$sourceAccount = $journal['source_account_id'];
|
||||
$currencyId = $journal['currency_id'];
|
||||
$spent[$sourceAccount] ??= [
|
||||
$sourceAccount = $journal['source_account_id'];
|
||||
$currencyId = $journal['currency_id'];
|
||||
$spent[$sourceAccount] ??= [
|
||||
'source_account_id' => $sourceAccount,
|
||||
'currency_id' => $journal['currency_id'],
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_name' => $journal['currency_name'],
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_decimal_places' => $journal['currency_decimal_places'],
|
||||
'spent' => '0'
|
||||
'spent' => '0',
|
||||
];
|
||||
$spent[$sourceAccount]['spent'] = bcadd($spent[$sourceAccount]['spent'], (string) $journal['amount']);
|
||||
$spent[$sourceAccount]['spent'] = bcadd($spent[$sourceAccount]['spent'], (string) $journal['amount']);
|
||||
|
||||
// also fix sum:
|
||||
$report['sums'][$budgetId][$currencyId] ??= [
|
||||
@@ -117,16 +118,16 @@ class BalanceController extends Controller
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_name' => $journal['currency_name'],
|
||||
'currency_symbol' => $journal['currency_symbol'],
|
||||
'currency_decimal_places' => $journal['currency_decimal_places']
|
||||
'currency_decimal_places' => $journal['currency_decimal_places'],
|
||||
];
|
||||
$report['sums'][$budgetId][$currencyId]['sum'] = bcadd($report['sums'][$budgetId][$currencyId]['sum'], (string) $journal['amount']);
|
||||
$report['accounts'][$sourceAccount]['sum'] = bcadd($report['accounts'][$sourceAccount]['sum'], (string) $journal['amount']);
|
||||
$report['sums'][$budgetId][$currencyId]['sum'] = bcadd($report['sums'][$budgetId][$currencyId]['sum'], (string) $journal['amount']);
|
||||
$report['accounts'][$sourceAccount]['sum'] = bcadd($report['accounts'][$sourceAccount]['sum'], (string) $journal['amount']);
|
||||
|
||||
// add currency info for account sum
|
||||
$report['accounts'][$sourceAccount]['currency_id'] = $journal['currency_id'];
|
||||
$report['accounts'][$sourceAccount]['currency_code'] = $journal['currency_code'];
|
||||
$report['accounts'][$sourceAccount]['currency_name'] = $journal['currency_name'];
|
||||
$report['accounts'][$sourceAccount]['currency_symbol'] = $journal['currency_symbol'];
|
||||
$report['accounts'][$sourceAccount]['currency_id'] = $journal['currency_id'];
|
||||
$report['accounts'][$sourceAccount]['currency_code'] = $journal['currency_code'];
|
||||
$report['accounts'][$sourceAccount]['currency_name'] = $journal['currency_name'];
|
||||
$report['accounts'][$sourceAccount]['currency_symbol'] = $journal['currency_symbol'];
|
||||
$report['accounts'][$sourceAccount]['currency_decimal_places'] = $journal['currency_decimal_places'];
|
||||
}
|
||||
$report['budgets'][$budgetId]['spent'] = $spent;
|
||||
|
||||
Reference in New Issue
Block a user