Update ness.py

This commit is contained in:
Tyrel Souza 2023-09-12 21:06:40 +00:00
parent a3a23e165f
commit 03b670bc8d
1 changed files with 11 additions and 6 deletions

17
ness.py
View File

@ -8,8 +8,8 @@ YMD = "%Y-%m-%d"
class Transactions:
def __init__(self, transactions, interest=12.34):
self.interest = interest / 100
def __init__(self, transactions, interest):
self.interest = interest / 100 # to percent
self.transactions = transactions
self.start_date = datetime.datetime.strptime("2023-01-01", YMD)
self.last_date = self._find_last_date()
@ -89,9 +89,14 @@ class Transactions:
total = self.balance(statement["transactions"])
running_balance += total
statement["total"] = total
statement["interest"] = 0
if total > 0:
statement["interest"] = self.interest * total
statement["transactions"].append({
"transaction_id": "tx_InterestCalc",
"transaction_date": "2023-99-99",
"transaction_type": "Interest",
"amount": int(self.interest * total),
"description": "Interest Charge"
})
def statements_print_formatted(self):
total = 0
@ -105,12 +110,12 @@ class Transactions:
f"* {txn['transaction_date']}"
f": {txn['transaction_id']}"
f": {txn['transaction_type']: <9}"
f"\t{txn['amount']}"
f"\t{txn['amount']:.0f}"
f"\t{total}"
f"\t{txn['description']}"
)
out += "\n"
out += f"------------- TOTAL:{statement['total']}, {statement['interest']:.2f}\n"
out += f"------------- TOTAL:{total}\n"
print(out)