From 1a799fc5861c12554c201c84c9cd50914ad755dc Mon Sep 17 00:00:00 2001 From: Nils Gother Date: Sun, 29 Mar 2026 16:50:04 +0200 Subject: [PATCH 1/2] feat: solution for issue #29 Closes #29 Payouts: - EVM: 0xe744f6791a685b0A0cC316ED44375B69361c837F - SOL: 8BsByR6rPqxDPku6dYtdoiSk6bdgE9YETbLQF2RGSw1C PoA-Signature: poa_03e27c3d405e8bad --- .gitignore | 2 ++ bank.py | 15 ++++++++++--- commit_msg.txt | 10 +++++++++ pr_body.txt | 15 +++++++++++++ test_process_loan_payments.py | 40 +++++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 commit_msg.txt create mode 100644 pr_body.txt create mode 100644 test_process_loan_payments.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6c56ff1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +.pytest_cache/ diff --git a/bank.py b/bank.py index ab74f6f..a89fd85 100644 --- a/bank.py +++ b/bank.py @@ -45,9 +45,18 @@ def calculate_total_assets(self): pass - def process_loan_payments(self): - # Processes loan payments by deducting the installment amount from the balance. - pass + def process_loan_payments(self): + # Processes loan payments by deducting the installment amount from the balance. + for loan in self.loans: + if loan.tenure <= 0 or loan.remaining_balance <= 0: + continue + + installment = min(loan.remaining_balance, loan.amount / loan.tenure) + for account in self.accounts: + if account.account_number == loan.account_number and account.balance >= installment: + account.balance -= installment + loan.remaining_balance -= installment + break class Account: diff --git a/commit_msg.txt b/commit_msg.txt new file mode 100644 index 0000000..3f62cd8 --- /dev/null +++ b/commit_msg.txt @@ -0,0 +1,10 @@ +feat: solution for issue #29 + +Closes #29 + +Payouts: +- EVM: 0xe744f6791a685b0A0cC316ED44375B69361c837F +- SOL: 8BsByR6rPqxDPku6dYtdoiSk6bdgE9YETbLQF2RGSw1C + + +PoA-Signature: poa_03e27c3d405e8bad diff --git a/pr_body.txt b/pr_body.txt new file mode 100644 index 0000000..151e41d --- /dev/null +++ b/pr_body.txt @@ -0,0 +1,15 @@ +## 🛠️ Automated Fix for #29 + +### Summary +Implements `process_loan_payments()` by calculating installments, deducting them from matching funded accounts, and reducing remaining loan balances, with regression tests for normal, insufficient-funds, and invalid-tenure scenarios. + +### Payout Details +- **Wallet (EVM):** 0xe744f6791a685b0A0cC316ED44375B69361c837F +- **Solana:** 8BsByR6rPqxDPku6dYtdoiSk6bdgE9YETbLQF2RGSw1C + + +/claim #29 +/payout EVM: 0xe744f6791a685b0A0cC316ED44375B69361c837F +/payout SOL: 8BsByR6rPqxDPku6dYtdoiSk6bdgE9YETbLQF2RGSw1C + +PoA-Signature: poa_03e27c3d405e8bad diff --git a/test_process_loan_payments.py b/test_process_loan_payments.py new file mode 100644 index 0000000..2bf61fd --- /dev/null +++ b/test_process_loan_payments.py @@ -0,0 +1,40 @@ +from bank import Account, Bank, Loan + + +def test_process_loan_payments_deducts_installment_and_reduces_remaining_balance(): + bank = Bank("Test Bank") + account = Account("ACC-1", "Alice", 200.0) + loan = Loan("LOAN-1", "ACC-1", 120.0, 5.0, 12) + bank.accounts.append(account) + bank.loans.append(loan) + + bank.process_loan_payments() + + assert account.balance == 190.0 + assert loan.remaining_balance == 110.0 + + +def test_process_loan_payments_skips_accounts_with_insufficient_balance(): + bank = Bank("Test Bank") + account = Account("ACC-2", "Bob", 5.0) + loan = Loan("LOAN-2", "ACC-2", 120.0, 5.0, 12) + bank.accounts.append(account) + bank.loans.append(loan) + + bank.process_loan_payments() + + assert account.balance == 5.0 + assert loan.remaining_balance == 120.0 + + +def test_process_loan_payments_skips_loans_with_non_positive_tenure(): + bank = Bank("Test Bank") + account = Account("ACC-3", "Charlie", 100.0) + loan = Loan("LOAN-3", "ACC-3", 100.0, 5.0, 0) + bank.accounts.append(account) + bank.loans.append(loan) + + bank.process_loan_payments() + + assert account.balance == 100.0 + assert loan.remaining_balance == 100.0 From a7843bfc43b7d13ae5acec69d4997540dc95e75d Mon Sep 17 00:00:00 2001 From: Nils Gother Date: Mon, 30 Mar 2026 01:09:31 +0200 Subject: [PATCH 2/2] chore: remove PR helper files Cleanup-only follow-up for PR #113. PoA-Signature: poa_2639b821ed115cdf --- commit_msg.txt | 10 ---------- pr_body.txt | 15 --------------- 2 files changed, 25 deletions(-) delete mode 100644 commit_msg.txt delete mode 100644 pr_body.txt diff --git a/commit_msg.txt b/commit_msg.txt deleted file mode 100644 index 3f62cd8..0000000 --- a/commit_msg.txt +++ /dev/null @@ -1,10 +0,0 @@ -feat: solution for issue #29 - -Closes #29 - -Payouts: -- EVM: 0xe744f6791a685b0A0cC316ED44375B69361c837F -- SOL: 8BsByR6rPqxDPku6dYtdoiSk6bdgE9YETbLQF2RGSw1C - - -PoA-Signature: poa_03e27c3d405e8bad diff --git a/pr_body.txt b/pr_body.txt deleted file mode 100644 index 151e41d..0000000 --- a/pr_body.txt +++ /dev/null @@ -1,15 +0,0 @@ -## 🛠️ Automated Fix for #29 - -### Summary -Implements `process_loan_payments()` by calculating installments, deducting them from matching funded accounts, and reducing remaining loan balances, with regression tests for normal, insufficient-funds, and invalid-tenure scenarios. - -### Payout Details -- **Wallet (EVM):** 0xe744f6791a685b0A0cC316ED44375B69361c837F -- **Solana:** 8BsByR6rPqxDPku6dYtdoiSk6bdgE9YETbLQF2RGSw1C - - -/claim #29 -/payout EVM: 0xe744f6791a685b0A0cC316ED44375B69361c837F -/payout SOL: 8BsByR6rPqxDPku6dYtdoiSk6bdgE9YETbLQF2RGSw1C - -PoA-Signature: poa_03e27c3d405e8bad