From 2e317e529f40f4a7c8c1754573cb7bed26e0204d Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Wed, 27 Jan 2016 09:16:33 +0000 Subject: [PATCH] Fixed year detection for billing number --- TODO.md | 1 + orchestra/contrib/bills/models.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 9f8921d7..9bf5144d 100644 --- a/TODO.md +++ b/TODO.md @@ -455,3 +455,4 @@ mkhomedir_helper or create ssh homes with bash.rc and such * setuppostgres use porject_name for db name and user instead of orchestra +* show all available choices (plugins) on admin settings value i.e. payment methods diff --git a/orchestra/contrib/bills/models.py b/orchestra/contrib/bills/models.py index 9383961d..c5149cc2 100644 --- a/orchestra/contrib/bills/models.py +++ b/orchestra/contrib/bills/models.py @@ -226,14 +226,14 @@ class Bill(models.Model): prefix = getattr(settings, 'BILLS_%s_NUMBER_PREFIX' % bill_type) if self.is_open: prefix = 'O{}'.format(prefix) - bills = cls.objects.filter(number__regex=r'^%s[1-9]+' % prefix) + year = timezone.now().strftime("%Y") + bills = cls.objects.filter(number__regex=r'^%s%s[1-9]+' % (prefix, year) last_number = bills.order_by('-number').values_list('number', flat=True).first() if last_number is None: last_number = 0 else: last_number = int(last_number[len(prefix)+4:]) number = last_number + 1 - year = timezone.now().strftime("%Y") number_length = settings.BILLS_NUMBER_LENGTH zeros = (number_length - len(str(number))) * '0' number = zeros + str(number)