Account: check_negative() -> update_negative()

This commit is contained in:
Aurélien Delobelle 2017-04-13 15:48:13 +02:00
parent 18425b82c2
commit 9668f1d1ec
2 changed files with 3 additions and 3 deletions

View file

@ -210,7 +210,7 @@ class Account(models.Model):
def delete(self, *args, **kwargs):
pass
def check_negative(self):
def update_negative(self):
if self.real_balance < 0:
if hasattr(self, 'negative') and not self.negative.start:
self.negative.start = timezone.now()

View file

@ -1113,7 +1113,7 @@ def kpsul_perform_operations(request):
.update(balance=F('balance') + operationgroup.amount)
)
on_acc.refresh_from_db()
on_acc.check_negative()
on_acc.update_negative()
# Updating checkout's balance
if to_checkout_balance:
@ -1312,7 +1312,7 @@ def kpsul_cancel_operations(request):
if not account.is_cash:
# Should always be true, but we want to be sure
account.refresh_from_db()
account.check_negative()
account.update_negative()
for checkout in to_checkouts_balances:
Checkout.objects.filter(pk=checkout.pk).update(
balance = F('balance') + to_checkouts_balances[checkout])