diff --git a/src/monopoly/banks/bank_of_america/boa.py b/src/monopoly/banks/bank_of_america/boa.py index 2bf5474..5cb9d53 100644 --- a/src/monopoly/banks/bank_of_america/boa.py +++ b/src/monopoly/banks/bank_of_america/boa.py @@ -22,7 +22,6 @@ class BankOfAmerica(BankBase): header_pattern=regex(r"(Date.*Description.*Amount)"), transaction_pattern=CreditTransactionPatterns.BANK_OF_AMERICA, multiline_transactions=True, - safety_check=False, transaction_auto_polarity=False, ) diff --git a/src/monopoly/banks/chase/chase.py b/src/monopoly/banks/chase/chase.py index aebce7e..5b45981 100644 --- a/src/monopoly/banks/chase/chase.py +++ b/src/monopoly/banks/chase/chase.py @@ -22,7 +22,6 @@ class Chase(BankBase): transaction_pattern=CreditTransactionPatterns.CHASE, multiline_transactions=True, transaction_auto_polarity=False, - safety_check=False, ) identifiers = [ diff --git a/src/monopoly/statements/credit_statement.py b/src/monopoly/statements/credit_statement.py index c6df047..ff2f9bc 100644 --- a/src/monopoly/statements/credit_statement.py +++ b/src/monopoly/statements/credit_statement.py @@ -2,6 +2,7 @@ import re from monopoly.constants import EntryType +from monopoly.statements.debit_statement import DebitStatement from monopoly.statements.transaction import Transaction, TransactionGroupDict from .base import BaseStatement, SafetyCheckError @@ -59,10 +60,14 @@ def perform_safety_check(self) -> bool: amounts = [transaction.amount for transaction in transactions] total_amount = abs(round(sum(amounts), 2)) - result = total_amount in numbers - if not result: - raise SafetyCheckError( - f"Total amount {total_amount} cannot be found in credit statement" - ) + total_amount_found = total_amount in numbers - return result + # attempt a debit-statement style safety for banks that have + # debit and credit amounts as separate numbers and not a single total sum + if total_amount_found or DebitStatement.perform_safety_check(self): + logger.debug("Running debit statement safety check for credit statement") + return True + + raise SafetyCheckError( + f"Total amount {total_amount} cannot be found in credit statement" + )