Coverage for django_napse/core/models/transactions/managers/credit.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 CreditManager(models.Manager):
6 @atomic()
7 def create(self, wallet, amount, ticker):
8 if amount == 0:
9 return None
10 credit = self.model(
11 wallet=wallet,
12 amount=amount,
13 ticker=ticker,
14 )
16 credit.save()
17 wallet.top_up(amount, ticker, force=True)
18 return credit