mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Add transfer type
This commit is contained in:
65
app/Console/Commands/System/RecalculatesRunningBalance.php
Normal file
65
app/Console/Commands/System/RecalculatesRunningBalance.php
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* RecalculatesRunningBalance.php
|
||||||
|
* Copyright (c) 2025 james@firefly-iii.org.
|
||||||
|
*
|
||||||
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace FireflyIII\Console\Commands\System;
|
||||||
|
|
||||||
|
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
||||||
|
use FireflyIII\Support\Models\AccountBalanceCalculator;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class RecalculatesRunningBalance extends Command
|
||||||
|
{
|
||||||
|
use ShowsFriendlyMessages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'firefly-iii:refresh-running-balance {--F|force : Force the execution of this command.}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Refreshes all running balances. May take a long time to run if forced.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
if (true === config('firefly.feature_flags.running_balance_column')) {
|
||||||
|
$this->friendlyInfo('Will recalculate account balances. This may take a LONG time. Please be patient.');
|
||||||
|
$this->correctBalanceAmounts($this->option('force'));
|
||||||
|
$this->friendlyInfo('Done recalculating account balances.');
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
$this->friendlyWarning('This command has been disabled.');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function correctBalanceAmounts(bool $forced): void
|
||||||
|
{
|
||||||
|
AccountBalanceCalculator::recalculateAll($forced);
|
||||||
|
}
|
||||||
|
}
|
@@ -89,6 +89,7 @@ class AccountBalanceCalculator
|
|||||||
}
|
}
|
||||||
|
|
||||||
$set = $query->get(['transactions.id', 'transactions.balance_dirty', 'transactions.transaction_currency_id', 'transaction_journals.date', 'transactions.account_id', 'transactions.amount']);
|
$set = $query->get(['transactions.id', 'transactions.balance_dirty', 'transactions.transaction_currency_id', 'transaction_journals.date', 'transactions.account_id', 'transactions.amount']);
|
||||||
|
Log::debug(sprintf('Counted %d transaction(s)', $set->count()));
|
||||||
|
|
||||||
// the balance value is an array.
|
// the balance value is an array.
|
||||||
// first entry is the balance, second is the date.
|
// first entry is the balance, second is the date.
|
||||||
|
@@ -266,6 +266,12 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{{ formatAmountBySymbol(transaction.source_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
{{ formatAmountBySymbol(transaction.source_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% elseif transaction.transaction_type_type == 'Transfer' %}
|
||||||
|
{% if account.id == transaction.source_account_id %}
|
||||||
|
{{ formatAmountBySymbol(transaction.source_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
|
{% else %}
|
||||||
|
{{ formatAmountBySymbol(transaction.destination_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Reference in New Issue
Block a user