fix syntax errors
This commit is contained in:
parent
b8652c921e
commit
18b862c2e1
1 changed files with 26 additions and 11 deletions
|
@ -31,8 +31,8 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
# See https://docs.djangoproject.com/en/dev/ref/models/fields/#field-choices-enum-types
|
||||
class RecurringPeriod(models.TextChoices):
|
||||
PER_YEAR = 'YEAR', _('Per Year') # this is broken - we can make it 365 days
|
||||
PER_MONTH = 'MONTH', _('Per Month') # this is broken - varying times
|
||||
PER_YEAR = 'YEAR', _('Per Year') # this is broken - we can make it 365 days - REMOVE ME
|
||||
PER_MONTH = 'MONTH', _('Per Month') # this is broken - varying times - REMOVE ME
|
||||
|
||||
ONE_TIME = 'ONCE', _('Onetime') # this is ok
|
||||
PER_365D = '365D', _('Per 365 days') # this is ok
|
||||
|
@ -43,6 +43,8 @@ class RecurringPeriod(models.TextChoices):
|
|||
PER_MINUTE = 'MINUTE', _('Per Minute') # this is ok
|
||||
PER_SECOND = 'SECOND', _('Per Second') # this is ok
|
||||
|
||||
|
||||
|
||||
class CountryField(models.CharField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs.setdefault('choices', COUNTRIES)
|
||||
|
@ -111,6 +113,7 @@ class Payment(models.Model):
|
|||
for bill in newly_paid_bills:
|
||||
bill.activate_products()
|
||||
|
||||
|
||||
class PaymentMethod(models.Model):
|
||||
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
owner = models.ForeignKey(get_user_model(),
|
||||
|
@ -276,6 +279,10 @@ class BillNico(models.Model):
|
|||
Generate a bill for the specific month of a user.
|
||||
|
||||
First handle all one time orders
|
||||
|
||||
FIXME:
|
||||
|
||||
- limit this to active users in the future! (2020-05-23)
|
||||
"""
|
||||
|
||||
"""
|
||||
|
@ -285,10 +292,12 @@ class BillNico(models.Model):
|
|||
Can we do this even for recurring / all of them
|
||||
|
||||
"""
|
||||
for order in Order.objects.filter(owner=owner,
|
||||
Q(starting_date__gte=self.starting_date),
|
||||
Q(starting_date__lte=self.ending_date)):
|
||||
order.bill.add(this_bill)
|
||||
for order in Order.objects.filter(Q(starting_date__gte=self.starting_date),
|
||||
Q(starting_date__lte=self.ending_date),
|
||||
owner=owner):
|
||||
|
||||
# order.bill.add(this_bill)
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
|
@ -304,10 +313,11 @@ class BillNico(models.Model):
|
|||
periods =
|
||||
[ we could in theory add this as a property to the order: next
|
||||
"""
|
||||
for order in Order.objects.filter(owner=owner,
|
||||
~Q(recurring_period=RecurringPeriod.ONE_TIME),
|
||||
Q(starting_date__gte=starting_date),
|
||||
Q(starting_date__lte=ending_date)):
|
||||
for order in Order.objects.filter(~Q(recurring_period=RecurringPeriod.ONE_TIME),
|
||||
Q(starting_date__lt=self.starting_date),
|
||||
owner=owner):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -543,7 +553,7 @@ class BillRecord():
|
|||
def __init__(self, bill, order):
|
||||
self.bill = bill
|
||||
self.order = order
|
||||
yep self.recurring_price = order.recurring_price
|
||||
self.recurring_price = order.recurring_price
|
||||
self.recurring_period = order.recurring_period
|
||||
self.description = order.description
|
||||
|
||||
|
@ -683,6 +693,7 @@ class Order(models.Model):
|
|||
if self.starting_date <= ending_date:
|
||||
if self.ending_date:
|
||||
if self.ending_date > ending_date:
|
||||
pass
|
||||
|
||||
@property
|
||||
def is_recurring(self):
|
||||
|
@ -700,6 +711,10 @@ class Order(models.Model):
|
|||
self.ending_date = timezone.now()
|
||||
self.save()
|
||||
|
||||
def is_to_be_charged_in(year, month):
|
||||
if self.recurring_period == RecurringPeriod.PER_YEAR:
|
||||
pass
|
||||
|
||||
# Trigger initial bill generation at order creation.
|
||||
def save(self, *args, **kwargs):
|
||||
if self.ending_date and self.ending_date < self.starting_date:
|
||||
|
|
Loading…
Reference in a new issue