From c4cae73d601ea1651c9130cd6e312f4ca08bb6a4 Mon Sep 17 00:00:00 2001 From: hummusonrails Date: Fri, 15 May 2026 09:03:08 +0300 Subject: [PATCH] Implement apply_interest in bank account --- __pycache__/bank.cpython-314.pyc | Bin 0 -> 7031 bytes bank.py | 374 ++++++++++++++++--------------- 2 files changed, 190 insertions(+), 184 deletions(-) create mode 100644 __pycache__/bank.cpython-314.pyc diff --git a/__pycache__/bank.cpython-314.pyc b/__pycache__/bank.cpython-314.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b550a92d95ee9cea1ccebcdd204a0ebd4cd93b95 GIT binary patch literal 7031 zcmb^$Yi||Db@slz_hlQd-xz$st(yxDCJ8h&wGxshG?7x5tdOZx!D_vCZEw7H@6GI7 zsDsqHEo~ukps6ZBl&Ixfu~ez*mo`%W1Slpr^NFgT`VH(#?#G@p`?$OJ0d|^^d^~&R z%$zeb=Q;OCcRoX)75<)jw>&_|zwpCv39qyDE_7B%KRHMgGDsBZc+4GPE-nVRcz}}x zT>@~)02dRu6yUl7TwLH}z@-CRLdlGiQdajR!2go>u{8@F4dggan4}OEyCAXn0I7mJ zgM=j%kb)(ZIKY$w+*y~B1Sl)Om8F#~fEfk2v8<8?m{T$=KTBA*k_C=Ao_I~OmvnDm zf+P0hgveXd&{-kpdToJ5aFomv+n3Az3TBEinCCWyjFUBKrj+0bTdNpc)^xpEx0%Cp zjB2){>CCL!4o_ND_$tMC!ZECQnu6I5E;%v5PfXRQc~N7=6sy#x=5Y4%vx@)?`fNq7 zO;Mv(b*2=6ie{Fl=3pO3Ys*|#Rns<^s`5N;?Wq5WqB;8ktdNI&L#yeHp^>YJ)%?cj zfvbsid3d9L@M_|EW(x?29&7_XaJ%9-P_`9NgmFTX&|M>?I7J=e-QM2R#i~^{DDOf3 zre>*gnx)yg;ox!;6B9HmsC8<}sCM)Eha*lRGFLFhlWTL%5xfW{@ z%dS`E4C)=LD@1m|V1Wd^LV^$mSE2m~1n1zw0rOU0)rB#G_ zJ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qmTumxngQOGV$%^|Y%)fnx!hz!K3zL+TOptJBD0z7Tvg!n|qpcTv7!r-*&H8hHy&_<@1aITg9k!;!LM)psQycku3@S43V!|yK>Mhk$883V z;}1xOcL9z=)S7PbDWduQ!|U?MhUgyr))#)9MDO9ZHtH*$I6G8@xr(-A_|GbQj}Rn` z`V*`hGSH_ON{CalJ@jM2)^c8aL~v|7_UEsQ_1?z&m4AHayEk6aS}+@DBnVR*+zY@S(J>5Uj7nz=q>O z?S%nA9m?Zy(+!MYI;F96f*P~pL~5p9tX^qdXJBh?SnC&u(~SNH2;pFT0|qlNcC+$P z<@TF*%70l}Tl#$9CHP$+yRm=bkLN!=f9I9YUVkt>b8mX)^Zh@>9|}hNQWMO!k%C`= zm8dY_Ut~gOm)hdD;2!4;?V+5W3?$2=;!Kd)&JOjYd nN%_YF!1kgvg 0 - - - def validate_transaction(self): - # Validates the transaction before processing. - return self.amount > 0 - - - def reverse_transaction(self): - # Reverses a transaction by negating the amount. - pass - - -class BankEmployee: - # Represents a bank employee with an ID, name, and role. - def __init__(self, employee_id, name, role): - self.employee_id = employee_id - self.name = name - self.role = role - - - def approve_loan(self, account_number, amount): - # Approves a loan request if the amount is positive. - return amount > 0 - - - def view_account_details(self, account_number): - # Views account details given an account number by returning account number - pass - - - def suspend_account(self, account_number): - # Return suspension message as string - pass - - - def generate_financial_report(self): - # Return string "Financial Report Generated" - return "Financial Report Generated" - - -class Loan: - # Represents a loan with an ID, amount, interest rate, and tenure. - def __init__(self, loan_id, account_number, amount, interest_rate, tenure): - self.loan_id = loan_id - self.account_number = account_number - self.amount = amount - self.interest_rate = interest_rate - self.tenure = tenure - self.remaining_balance = amount - - - def make_payment(self, amount): - # Makes a loan payment if the amount is within the remaining balance. - pass - - - def get_remaining_balance(self): - # Returns the remaining balance of the loan. - pass - - - def calculate_interest(self): - # Calculates interest on the remaining balance. - pass - - - def check_loan_eligibility(self, account_number, income, credit_score): - # Checks if an applicant is eligible for a loan based on income(>50k) and credit score(>650). Return boolean - pass - - # Allows restructuring of the loan with new terms. - def restructure_loan(self, new_terms): - self.tenure = new_terms.get("tenure", self.tenure) - self.interest_rate = new_terms.get("interest_rate", self.interest_rate) - return True +class Bank: + + def __init__(self, name): + # Manages accounts, transactions, and loans. Generates unique account numbers. + self.name = name + self.accounts = [] + self.transactions = [] + self.loans = [] + + + def create_account(self, account_holder, initial_balance): + # Creates a new account with a unique number and initial balance, add it to accounts array and return account number + pass + + + def get_account(self, account_number): + # Retrieves an account by its number, returns None if not found. + pass + + + def list_accounts(self): + # Lists all accounts with their details like account number, holder, balance + pass + + + def close_account(self, account_number): + # Closes an account by removing it from the list. + pass + + + def transfer_funds(self, from_account, to_account, amount): + # Transfers funds between accounts if sufficient balance is available, return boolean values depending on + # transfer success + pass + + + def generate_account_statement(self, account_number): + # Generates a transaction history for a given account number, return None if no account number found + pass + + + + def calculate_total_assets(self): + # Calculates the total assets by summing all account balances. + pass + + + def process_loan_payments(self): + # Processes loan payments by deducting the installment amount from the balance. + pass + + +class Account: + # Represents a bank account with balance and transactions. Default balance is 0. + def __init__(self, account_number, account_holder, balance=0.0): + self.account_number = account_number + self.account_holder = account_holder + self.balance = balance + self.transactions = [] + + + def deposit(self, amount): + # Deposits a positive amount to the account and records the transaction. When adding transaction to array specift "Deposit" and amount + pass + + + def withdraw(self, amount): + # Withdraws an amount if sufficient balance is available. When adding into transactions array, specify Withdraw and amount + pass + + + def get_balance(self): + # Returns the current balance of the account. + pass + + + def get_transaction_history(self): + # Retrieves the transaction history of the account. + pass + + + def apply_interest(self, rate): + # Applies interest based on a given rate. + if rate < 0: + return False + + interest = self.balance * rate / 100 + self.balance += interest + self.transactions.append(("Interest", interest)) + return True + + + def overdraft_protection(self, amount): + # Checks if a withdrawal amount is within available balance. + pass + + + def update_contact_information(self, new_contact_info): + # Updates the contact information of the account holder. + pass + + +class Transaction: + # Represents a transaction with an ID, type, amount, and timestamp. + def __init__(self, transaction_id, account_number, amount, transaction_type, timestamp): + self.transaction_id = transaction_id + self.account_number = account_number + self.amount = amount + self.transaction_type = transaction_type + self.timestamp = timestamp + + + def process_transaction(self): + # Processes a transaction if the amount is positive. + return self.amount > 0 + + + def validate_transaction(self): + # Validates the transaction before processing. + return self.amount > 0 + + + def reverse_transaction(self): + # Reverses a transaction by negating the amount. + pass + + +class BankEmployee: + # Represents a bank employee with an ID, name, and role. + def __init__(self, employee_id, name, role): + self.employee_id = employee_id + self.name = name + self.role = role + + + def approve_loan(self, account_number, amount): + # Approves a loan request if the amount is positive. + return amount > 0 + + + def view_account_details(self, account_number): + # Views account details given an account number by returning account number + pass + + + def suspend_account(self, account_number): + # Return suspension message as string + pass + + + def generate_financial_report(self): + # Return string "Financial Report Generated" + return "Financial Report Generated" + + +class Loan: + # Represents a loan with an ID, amount, interest rate, and tenure. + def __init__(self, loan_id, account_number, amount, interest_rate, tenure): + self.loan_id = loan_id + self.account_number = account_number + self.amount = amount + self.interest_rate = interest_rate + self.tenure = tenure + self.remaining_balance = amount + + + def make_payment(self, amount): + # Makes a loan payment if the amount is within the remaining balance. + pass + + + def get_remaining_balance(self): + # Returns the remaining balance of the loan. + pass + + + def calculate_interest(self): + # Calculates interest on the remaining balance. + pass + + + def check_loan_eligibility(self, account_number, income, credit_score): + # Checks if an applicant is eligible for a loan based on income(>50k) and credit score(>650). Return boolean + pass + + # Allows restructuring of the loan with new terms. + def restructure_loan(self, new_terms): + self.tenure = new_terms.get("tenure", self.tenure) + self.interest_rate = new_terms.get("interest_rate", self.interest_rate) + return True