-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
30 lines (25 loc) · 765 Bytes
/
Copy pathmodels.py
File metadata and controls
30 lines (25 loc) · 765 Bytes
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
from django.db import models
from .constants import TRANSACTION_TYPE_CHOICES
from accounts.models import UserBankAccount
class Transaction(models.Model):
account = models.ForeignKey(
UserBankAccount,
related_name='transactions',
on_delete=models.CASCADE,
)
amount = models.DecimalField(
decimal_places=2,
max_digits=12
)
balance_after_transaction = models.DecimalField(
decimal_places=2,
max_digits=12
)
transaction_type = models.PositiveSmallIntegerField(
choices=TRANSACTION_TYPE_CHOICES
)
timestamp = models.DateTimeField(auto_now_add=True)
def __str__(self):
return str(self.account.account_no)
class Meta:
ordering = ['timestamp']