Coverage for django_napse/core/models/transactions/managers/debit.py: 100%
11 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
2from django.db.transaction import atomic
5class DebitManager(models.Manager):
6 @atomic()
7 def create(self, wallet, amount, ticker):
8 if amount == 0:
9 return None
10 debit = self.model(
11 wallet=wallet,
12 amount=amount,
13 ticker=ticker,
14 )
16 debit.save()
17 wallet.spend(amount, ticker, force=True)
18 return debit