-
Notifications
You must be signed in to change notification settings - Fork 0
/
transaction.py
38 lines (30 loc) · 980 Bytes
/
transaction.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
from datetime import datetime as dt
class Transaction:
def __init__(self, amount):
self._amount = amount
self._executed = False
self._reversed = False
@property
def executed(self):
return self._executed
@property
def reversed(self):
return self._reversed
@property
def date_stamp(self):
return self._date_stamp
@property
def succeeded(self):
return
def execute(self):
if self._executed:
raise Exception("Cannot execute this transaction as it has already been executed.")
self._executed = True
self._date_stamp = dt.now()
def rollback(self):
if not self._executed:
raise Exception("Cannot reverse a transaction that has not already been executed")
if self._reversed:
raise Exception("Cannot reverse a transaction that has already been reversed")
def print(self):
return