Merge pull request #7644 from firefly-iii/fix-7630

Fix #7630
This commit is contained in:
James Cole 2023-06-12 06:24:46 +02:00 committed by GitHub
commit 2ab3fb3a71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 1 deletions

View File

@ -51,6 +51,14 @@ class FixUnevenAmount extends Command
->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]);
/** @var stdClass $entry */
foreach ($journals as $entry) {
$sum = (string)$entry->the_sum;
if (!is_numeric($sum)) {
$message = sprintf('Journal #%d has an invalid sum ("%s"). No sure what to do.', $entry->transaction_journal_id, $entry->the_sum);
$this->warn($message);
app('log')->warning($message);
$count++;
continue;
}
if (0 !== bccomp((string)$entry->the_sum, '0')) {
$message = sprintf('Sum of journal #%d is %s instead of zero.', $entry->transaction_journal_id, $entry->the_sum);
$this->warn($message);

View File

@ -60,7 +60,6 @@ class ReportIntegrity extends Command
'firefly-iii:create-group-memberships',
'firefly-iii:report-empty-objects',
'firefly-iii:report-sum',
'firefly-iii:restore-oauth-keys',
'firefly-iii:upgrade-group-information',
];
foreach ($commands as $command) {

View File

@ -58,6 +58,11 @@ class ReportSum extends Command
/** @var User $user */
foreach ($userRepository->all() as $user) {
$sum = (string)$user->transactions()->sum('amount');
if (!is_numeric($sum)) {
$message = sprintf('Error: Transactions for user #%d (%s) have an invalid sum ("%s").', $user->id, $user->email, $sum);
$this->error($message);
continue;
}
if (0 !== bccomp($sum, '0')) {
$message = sprintf('Error: Transactions for user #%d (%s) are off by %s!', $user->id, $user->email, $sum);
$this->error($message);

View File

@ -65,6 +65,7 @@ class UpgradeDatabase extends Command
'firefly-iii:upgrade-liabilities',
'firefly-iii:liabilities-600',
'firefly-iii:budget-limit-periods',
'firefly-iii:restore-oauth-keys',
];
$args = [];
if ($this->option('force')) {