Make eboutic working

This commit is contained in:
Skia
2016-07-26 18:28:36 +02:00
parent 60e606b370
commit c099f1c5d7
7 changed files with 125 additions and 9 deletions

View File

@ -28,7 +28,6 @@ class Invoice(models.Model):
max_length=20, verbose_name=_('payment method'))
validated = models.BooleanField(_("validated"), default=False)
def get_total(self):
total = 0
for i in self.items.all():
@ -41,13 +40,17 @@ class Invoice(models.Model):
if self.payment_method == "SITH_ACCOUNT":
self.user.customer.amount -= self.get_total()
self.user.customer.save()
else:
for i in self.items.filter(type="REFILLING").all():
self.user.customer.amount += i.product_unit_price * i.quantity
self.user.customer.save()
self.validated = True
self.save()
class AbstractBaseItem(models.Model):
product_name = models.CharField(_('product name'), max_length=255)
type = models.CharField(_('product type'), max_length=255)
product_unit_price = CurrencyField(_('unit price'))
quantity = models.IntegerField(_('quantity'))