Only generate bill if no overlap

This commit is contained in:
fnux 2020-03-01 15:47:27 +01:00
commit 4f25086a63
2 changed files with 27 additions and 14 deletions

View file

@ -1,4 +1,5 @@
from django.db import models
from functools import reduce
from django.contrib.auth import get_user_model
from django.core.validators import MinValueValidator
from django.utils.translation import gettext_lazy as _
@ -41,8 +42,8 @@ class Bill(models.Model):
@property
def total(self):
#return helpers.sum_amounts(self.entries)
pass
orders = Order.objects.filter(bill=self)
return reduce(lambda acc, order: acc + order.amount, orders, 0)
class BillEntry():
start_date = timezone.now()
@ -95,12 +96,14 @@ class Order(models.Model):
default = RecurringPeriod.PER_MONTH)
# def amount(self):
# amount = recurring_price
# if recurring and first_month:
# amount += one_time_price
@property
def amount(self):
# amount = recurring_price
# if recurring and first_month:
# amount += one_time_price
# return amount # you get the picture
amount=1
return amount
class PaymentMethod(models.Model):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)