Compare commits

...

12 Commits

Author SHA1 Message Date
github-actions[bot]
8f0c0f215c Merge pull request #10215 from firefly-iii/release-1745810633
🤖 Automatically merge the PR into the develop branch.
2025-04-28 05:24:02 +02:00
JC5
5fc764e72b 🤖 Auto commit for release 'develop' on 2025-04-28 2025-04-28 05:23:53 +02:00
github-actions[bot]
b330313c55 Merge pull request #10213 from firefly-iii/release-1745742741
🤖 Automatically merge the PR into the develop branch.
2025-04-27 10:32:28 +02:00
JC5
aa9ce73758 🤖 Auto commit for release 'develop' on 2025-04-27 2025-04-27 10:32:21 +02:00
github-actions[bot]
d97fda41b2 Merge pull request #10210 from firefly-iii/release-1745681629
🤖 Automatically merge the PR into the develop branch.
2025-04-26 17:33:56 +02:00
JC5
945ad79c03 🤖 Auto commit for release 'develop' on 2025-04-26 2025-04-26 17:33:49 +02:00
James Cole
6273807525 Merge pull request #10209 from firefly-iii/add-transfer-type
Add transfer type
2025-04-26 17:29:31 +02:00
James Cole
50803a2c24 Add transfer type 2025-04-26 17:29:10 +02:00
github-actions[bot]
a0e9b05680 Merge pull request #10208 from firefly-iii/release-1745674111
🤖 Automatically merge the PR into the develop branch.
2025-04-26 15:28:37 +02:00
JC5
41e74cd816 🤖 Auto commit for release 'develop' on 2025-04-26 2025-04-26 15:28:31 +02:00
James Cole
b379c8e36b Merge pull request #10207 from firefly-iii/fix-running-balance
Fix running balance
2025-04-26 15:24:36 +02:00
James Cole
76e893f86e Fix running balance 2025-04-26 15:24:14 +02:00
7 changed files with 106 additions and 19 deletions

View File

@@ -0,0 +1,67 @@
<?php
declare(strict_types=1);
/*
* 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);
}
}

View File

@@ -101,7 +101,7 @@ class GroupCollector implements GroupCollectorInterface
'category_id',
'budget_id',
];
$this->stringFields = ['amount', 'foreign_amount', 'native_amount', 'native_foreign_amount', 'balance_after'];
$this->stringFields = ['amount', 'foreign_amount', 'native_amount', 'native_foreign_amount', 'source_balance_after', 'destination_balance_after'];
$this->total = 0;
$this->fields = [
// group
@@ -132,7 +132,7 @@ class GroupCollector implements GroupCollectorInterface
// currency info:
'source.amount as amount',
'source.balance_after as balance_after',
'source.balance_after as source_balance_after',
'source.balance_dirty as balance_dirty',
'source.native_amount as native_amount',
'source.transaction_currency_id as currency_id',
@@ -152,6 +152,7 @@ class GroupCollector implements GroupCollectorInterface
// destination account info (always present)
'destination.account_id as destination_account_id',
'destination.balance_after as destination_balance_after',
];
}

View File

@@ -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']);
Log::debug(sprintf('Counted %d transaction(s)', $set->count()));
// the balance value is an array.
// first entry is the balance, second is the date.

24
composer.lock generated
View File

@@ -11217,16 +11217,16 @@
},
{
"name": "phpstan/phpstan",
"version": "2.1.12",
"version": "2.1.13",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "96dde49e967c0c22812bcfa7bda4ff82c09f3b0c"
"reference": "e55e03e6d4ac49cd1240907e5b08e5cd378572a9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/96dde49e967c0c22812bcfa7bda4ff82c09f3b0c",
"reference": "96dde49e967c0c22812bcfa7bda4ff82c09f3b0c",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e55e03e6d4ac49cd1240907e5b08e5cd378572a9",
"reference": "e55e03e6d4ac49cd1240907e5b08e5cd378572a9",
"shasum": ""
},
"require": {
@@ -11271,25 +11271,25 @@
"type": "github"
}
],
"time": "2025-04-16T13:19:18+00:00"
"time": "2025-04-27T12:28:25+00:00"
},
{
"name": "phpstan/phpstan-deprecation-rules",
"version": "2.0.1",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-deprecation-rules.git",
"reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4"
"reference": "9d8e7d4e32711715ad78a1fb6ec368df9af01fdf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/1cc1259cb91ee4cfbb5c39bca9f635f067c910b4",
"reference": "1cc1259cb91ee4cfbb5c39bca9f635f067c910b4",
"url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/9d8e7d4e32711715ad78a1fb6ec368df9af01fdf",
"reference": "9d8e7d4e32711715ad78a1fb6ec368df9af01fdf",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0",
"phpstan/phpstan": "^2.0"
"phpstan/phpstan": "^2.1.13"
},
"require-dev": {
"php-parallel-lint/php-parallel-lint": "^1.2",
@@ -11316,9 +11316,9 @@
"description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.",
"support": {
"issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues",
"source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.1"
"source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/2.0.2"
},
"time": "2024-11-28T21:56:36+00:00"
"time": "2025-04-26T19:59:57+00:00"
},
{
"name": "phpstan/phpstan-strict-rules",

View File

@@ -78,7 +78,7 @@ return [
'running_balance_column' => env('USE_RUNNING_BALANCE', false),
// see cer.php for exchange rates feature flag.
],
'version' => 'develop/2025-04-26',
'version' => 'develop/2025-04-28',
'api_version' => '2.1.0', // field is no longer used.
'db_version' => 25,

6
package-lock.json generated
View File

@@ -5635,9 +5635,9 @@
"license": "MIT"
},
"node_modules/electron-to-chromium": {
"version": "1.5.142",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.142.tgz",
"integrity": "sha512-Ah2HgkTu/9RhTDNThBtzu2Wirdy4DC9b0sMT1pUhbkZQ5U/iwmE+PHZX1MpjD5IkJCc2wSghgGG/B04szAx07w==",
"version": "1.5.143",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.143.tgz",
"integrity": "sha512-QqklJMOFBMqe46k8iIOwA9l2hz57V2OKMmP5eSWcUvwx+mASAsbU+wkF1pHjn9ZVSBPrsYWr4/W/95y5SwYg2g==",
"dev": true,
"license": "ISC"
},

View File

@@ -256,7 +256,25 @@
{% if config('firefly.feature_flags.running_balance_column') %}
<td>
{% if null == transaction.balance_dirty or false == transaction.balance_dirty %}
{{ formatAmountBySymbol(transaction.balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
{% if transaction.transaction_type_type == 'Deposit' %}
{{ formatAmountBySymbol(transaction.destination_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
{% elseif transaction.transaction_type_type == 'Withdrawal' %}
{{ formatAmountBySymbol(transaction.source_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
{% elseif transaction.transaction_type_type == 'Opening balance' %}
{% if transaction.source_account_type == 'Initial balance account' %}
{{ formatAmountBySymbol(transaction.destination_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
{% else %}
{{ formatAmountBySymbol(transaction.source_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
{% 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 %}
&nbsp;
{% endif %}
{% endif %}
</td>
{% endif %}