-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_transactions.py
98 lines (81 loc) · 3.86 KB
/
account_transactions.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
class AccountTransactions:
def __init__(self, account_number, amount, currency, debit_or_credit, narration, referenceId, transaction_time, type_of_transaction, value_date, balance_after=None, channel=None, debit_param=None):
self.account_number = account_number
self.amount = amount
self.currency = currency
self.channel = channel
self.debit_or_credit = debit_or_credit
self.narration = narration
self.referenceId = referenceId
self.transaction_time = transaction_time
self.type_of_transaction = type_of_transaction
self.value_date = value_date
self.balance_after = balance_after
self.debit_param = debit_param
def get_account_number(self):
return self.account_number
def get_amount(self):
return self.amount
def get_currency(self):
return self.currency
def get_channel(self):
return self.channel
def get_debit_or_credit(self):
return self.debit_or_credit
def get_narration(self):
return self.narration
def get_referenceId(self):
return self.referenceId
def get_transactionTime(self):
return self.transaction_time
def get_type_of_transaction(self):
return self.type_of_transaction
def get_valueDate(self):
return self.valueDate
def get_balanceAfter(self):
return self.balance_after
def debit_account(self, amount, account, account_balance):
if (len(self.account_number) == 10 and self.account_number == account["account_number"]):
if int(amount) > 0:
if (account["status"] == "active"):
if (self.currency == account["currency"]):
if (self.debit_or_credit == "Dr"):
if ((int(account_balance["available_balance"] - account_balance["minimum_balance"]) > int(amount)) or (int(account_balance["available_balance"] - account_balance["minimum_balance"]) == int(amount))):
account_balance["available_balance"] = int(account_balance["available_balance"])
account_balance["available_balance"] -= int(amount)
return "Success"
else:
return "Insufficient Funds"
else:
return "Invalid Operation"
else:
return "Invalid Currency"
else:
return "Account not operational"
else:
return "Invalid amount provided for transaction"
else:
return "Account does not exist!"
def credit_account(self, amount, account, account_balance):
if (len(self.account_number) == 10 and self.account_number == account["account_number"]):
if int(amount) > 0:
if (account["status"] == "active"):
if (self.currency == account["currency"]):
if (self.debit_or_credit == "Cr"):
account_balance["available_balance"] = int(account_balance["available_balance"])
account_balance["available_balance"] += int(amount)
return "Success"
else:
return "Invalid Operation"
else:
return "Invalid Currency"
else:
return "Account not suitable for operation"
else:
return "Invalid amount provided for transaction"
else:
return "Invalid Operation"
def freeze_account(self, account):
if (len(self.account_number) == 10 and self.account_number == account["account_number"]):
account["status"] = "inactive"
return "Success"