not enough balance error
This commit is contained in:
parent
6f568125b3
commit
f385f4a0e6
1 changed files with 2 additions and 0 deletions
|
|
@ -67,6 +67,8 @@ class Transaction(models.Model):
|
|||
|
||||
def withdraw_from_payer_balance(self):
|
||||
payer = self.get_payer()
|
||||
if self.amount > payer.balance:
|
||||
raise APIException('not enough balance')
|
||||
payer.balance = F('balance') - self.amount
|
||||
payer.save(update_fields=['balance'])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue