-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.py
More file actions
47 lines (42 loc) · 1.67 KB
/
Copy pathTransaction.py
File metadata and controls
47 lines (42 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
totalBalance = 0
class Transaction:
type = None # debit or credit
amount = None # amount of transaction
description = None
comments = None # additional comments
date = None # date of transaction
acc = None # accont number
bank = None # bank
tags = [] # tags related to transaction
availableBalance = None # available balance until this transaction
def addTransaction(myself, type, description, comments, amount, acc, bank, tags, date=None):
global totalBalance
myself.type = type
myself.description = description
myself.amount = amount
myself.comments = comments
myself.acc = acc
myself.bank = bank
myself.tags = tags.split(",")
if date is not None:
myself.date = date
else:
myself.date = date.today().strftime("%d/%m/%Y")
if type == "Debit":
myself.availableBalance = totalBalance - amount
totalBalance = myself.availableBalance
else:
myself.availableBalance = totalBalance + (amount)
totalBalance = myself.availableBalance
def printTransaction(self):
print(">>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
print("Type: " + self.type)
print("description: " + self.description)
print("amount: " + str(self.amount))
print("availableBalance: " + str(self.availableBalance))
print("comments: " + self.comments)
print("tags: " + str(self.tags))
print("date: " + self.date)
print("acc: " + self.acc)
print("bank: " + self.bank)
print(">>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n")