From 89af363ba1135bc6e9a228c77b5759b9b5d77254 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 7 May 2022 19:45:26 +0200 Subject: [PATCH] Add some missing db integrity checks. --- .../Commands/Correction/FixTransactionTypes.php | 6 +++++- config/firefly.php | 12 ++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/Correction/FixTransactionTypes.php b/app/Console/Commands/Correction/FixTransactionTypes.php index 02296d3a36..8ca46f9507 100644 --- a/app/Console/Commands/Correction/FixTransactionTypes.php +++ b/app/Console/Commands/Correction/FixTransactionTypes.php @@ -108,7 +108,11 @@ class FixTransactionTypes extends Command } $expectedType = (string) config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type)); if ($expectedType !== $type) { - $this->line(sprintf('Transaction journal #%d was of type "%s" but is corrected to "%s"', $journal->id, $type, $expectedType)); + $this->line( + sprintf('Transaction journal #%d was of type "%s" but is corrected to "%s" (%s -> %s)', + $journal->id, $type, $expectedType, + $source->accountType->type, $destination->accountType->type, + )); $this->changeJournal($journal, $expectedType); return true; diff --git a/config/firefly.php b/config/firefly.php index 99f09a2d2e..30f26e1881 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -606,7 +606,10 @@ return [ AccountType::RECONCILIATION => TransactionTypeModel::RECONCILIATION, ], AccountType::CASH => [ - AccountType::ASSET => TransactionTypeModel::DEPOSIT, + AccountType::ASSET => TransactionTypeModel::DEPOSIT, + AccountType::LOAN => TransactionTypeModel::DEPOSIT, + AccountType::DEBT => TransactionTypeModel::DEPOSIT, + AccountType::MORTGAGE => TransactionTypeModel::DEPOSIT, ], AccountType::DEBT => [ AccountType::ASSET => TransactionTypeModel::DEPOSIT, @@ -688,9 +691,10 @@ return [ AccountType::ASSET => [AccountType::RECONCILIATION], ], TransactionTypeModel::LIABILITY_CREDIT => [ - AccountType::LOAN => [AccountType::LIABILITY_CREDIT], - AccountType::DEBT => [AccountType::LIABILITY_CREDIT], - AccountType::MORTGAGE => [AccountType::LIABILITY_CREDIT], + AccountType::LOAN => [AccountType::LIABILITY_CREDIT], + AccountType::DEBT => [AccountType::LIABILITY_CREDIT], + AccountType::MORTGAGE => [AccountType::LIABILITY_CREDIT], + AccountType::LIABILITY_CREDIT => [AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE], ], ], // if you add fields to this array, dont forget to update the export routine (ExportDataGenerator).