def needs_invoice(self, obj):
if obj.last_invoice_date is None:
return True
date = now()
if obj.quota_type.periodicity == obj.quota_type.ANUAL:
start = make_aware(datetime.datetime(date.year, 1, 1), utc)
return obj.last_invoice_date < start
elif obj.quota_type.periodicity == obj.quota_type.ANUAL:
if date.month == 12:
year = date.year + 1
month = 1
else:
year = date.year
month = date.month + 1
start = make_aware(datetime.datetime(year, month, 1), utc)
return obj.last_invoice_date < start
return False
评论列表
文章目录