Coverage for django_napse/core/models/transactions/credit.py: 100%
20 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-12 13:49 +0000
1from django.db import models
3from django_napse.core.models.transactions.managers import CreditManager
6class Credit(models.Model):
7 wallet = models.ForeignKey("Wallet", on_delete=models.CASCADE, related_name="credits")
8 amount = models.FloatField()
9 ticker = models.CharField(max_length=10)
11 created_at = models.DateTimeField(auto_now_add=True)
13 objects = CreditManager()
15 def __str__(self):
16 return f"DEBIT: {self.pk})"
18 def info(self, verbose=True, beacon=""):
19 string = ""
20 string += f"{beacon}Credit {self.pk=}\n"
21 string += f"{beacon}Args:\n"
22 string += f"{beacon}\t{self.amount=}\n"
23 string += f"{beacon}\t{self.ticker=}\n"
24 string += f"{beacon}Credited Wallet:\n"
25 wall_str = self.wallet.info(verbose=False, beacon=beacon + "\t")
26 string += f"{wall_str}\n"
28 if verbose: # pragma: no cover
29 print(string)
30 return string