Commit 3da3f994 authored by Baptiste Jonglez's avatar Baptiste Jonglez
Browse files

Fix a subtle bug with dates: default argument of functions are evaluated when...

Fix a subtle bug with dates: default argument of functions are evaluated when the function is declared, not when it is called...
parent b3985a59
......@@ -13,11 +13,13 @@ from coin.members.models import Member
from coin.billing.models import Invoice, InvoiceDetail
def create_all_members_invoices_for_a_period(date=datetime.date.today()):
def create_all_members_invoices_for_a_period(date=None):
"""
Pour chaque membre ayant au moins un abonnement actif, génère les factures
en prenant la date comme premier mois de la période de facturation
"""
if date is None:
date = datetime.date.today()
members = Member.objects.filter(
Q(offersubscription__resign_date__isnull=True) |
Q(offersubscription__resign_date__gte=date))
......
......@@ -129,19 +129,23 @@ class Member(CoinLdapSyncMixin, AbstractUser):
super(Member, self).set_password(new_password, *args, **kwargs)
self._password_ldap = utils.ldap_hash(new_password)
def get_active_subscriptions(self, date=datetime.date.today()):
def get_active_subscriptions(self, date=None):
"""
Return list of OfferSubscription which are active today
"""
if date is None:
date = datetime.date.today()
return OfferSubscription.objects.filter(
Q(member__exact=self.pk),
Q(subscription_date__lte=date),
Q(resign_date__isnull=True) | Q(resign_date__gte=date))
def get_inactive_subscriptions(self, date=datetime.date.today()):
def get_inactive_subscriptions(self, date=None):
"""
Return list of OfferSubscription which are not active today
"""
if date is None:
date = datetime.date.today()
return OfferSubscription.objects.filter(
Q(member__exact=self.pk),
Q(subscription_date__gt=date) |
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment