Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def update_transactions(file_path: str, transaction_list: list): You are part of a team tasked to create an application that helps bankers by saving their transactions for

def update_transactions(file_path: str, transaction_list: list): """ You are part of a team tasked to create an application that helps bankers by saving their transactions for them. Your job within the project is to implement the feature that actually saves the transactions to the hard drive. The scope of your task is that you will be given a file path to where the data should be written and a list of bank transaction objects to be written to the file. The file will contain a JSON array of transactions that the banker previously saved. The bankers at this bank are silly sometimes and they make duplicate transactions, your function should remove the duplicate transactions in the transaction_list and update the existing transaction list saved in the file with the new transactions. Make sure when you are preforming the update of the new transactions that you overwrite old transactions (transactions that already exist in the file) with duplicate new transactions (transactions that are found in the transaction_list). You will know that a transaction is a duplicate if it has the same ID. In the end the file should contain a JSON list with transaction Objects that have been updated with the new information from the transaction_list. The JSON list should contain no transactions with the same ID. The transaction object referred to here in is outlined below. In actual testing of your code the professors transaction object will be used, which will have all the documented functionality. class Transaction: def __init__(self, id:int, type:str, amount:float): self.id:int = id self.type:str = type self.amount:float = amount def __str__(self): return 'Transaction[%s] %s $%s' (self.id, self.type, self.amount) def __hash__(self): return hash(self.id) def __eq__(self, other): return hasattr(other,'id') and other.id == self.id

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Strategic Public Finance

Authors: Stephen Bailey

1st Edition

0333922212, 978-033392221

More Books

Students also viewed these Finance questions