This commit is contained in:
Nico Schottelius 2020-05-23 21:32:56 +02:00
commit 8bbcc5df5f
3 changed files with 24 additions and 3 deletions

View file

@ -623,10 +623,23 @@ class Order(models.Model):
blank=True,
null=True)
def active_before(self, ending_date):
# Was this order started before the specified ending date?
if self.starting_date <= ending_date:
if self.ending_date:
if self.ending_date > ending_date:
@property
def is_recurring(self):
return not self.recurring_period == RecurringPeriod.ONE_TIME
@property
def is_terminated(self):
return self.ending_date != None and self.ending_date < timezone.now()
def is_terminated_at(self, a_date):
return self.ending_date != None and self.ending_date < timezone.now()
def terminate(self):
if not self.is_terminated:
self.ending_date = timezone.now()