From c66963fe15e6bc241df335ac063a5f61dba1e8af Mon Sep 17 00:00:00 2001 From: Benjamin Dornel Date: Sun, 24 Nov 2024 11:33:58 +0800 Subject: [PATCH] refactor(statements/safety): add additional safety check --- src/monopoly/statements/credit_statement.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/monopoly/statements/credit_statement.py b/src/monopoly/statements/credit_statement.py index ff2f9bc..41e5a58 100644 --- a/src/monopoly/statements/credit_statement.py +++ b/src/monopoly/statements/credit_statement.py @@ -62,6 +62,11 @@ def perform_safety_check(self) -> bool: total_amount_found = total_amount in numbers + # if sum of debit and credit is the same as the total amount + # then the statement is safe + if round(sum(amounts), 2) == total_amount: + return True + # 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):