diff --git a/truffe2/accounting_tools/models.py b/truffe2/accounting_tools/models.py index 251bae6f..31136474 100644 --- a/truffe2/accounting_tools/models.py +++ b/truffe2/accounting_tools/models.py @@ -330,7 +330,7 @@ def __init__(self, *args, **kwargs): title = models.CharField(max_length=140) client_name = models.CharField(_('Nom du client'), help_text=_(u'Exemple: \'Licorne SA - Monsieur Poney\''), max_length=70) - address = models.CharField(_('Adresse'), help_text=_(u'Exemple: \'Rue Des Arc en Ciel 25 - Case Postale 2, CH-1015 Lausanne\''), max_length=140, blank=True, null=True) + address = models.CharField(_('Adresse'), help_text=_(u'Format: \'Rue Des Arc en Ciel 25 - Case Postale 2, CH-1015 Lausanne\''), max_length=140, blank=True, null=True) date_and_place = models.CharField(_(u'Lieu et date'), max_length=512, blank=True, null=True) preface = models.TextField(_(u'Introduction'), help_text=_(u'Texte affiché avant la liste. Exemple: \'Pour l\'achat du Yearbook 2014\' ou \'Chère Madame, - Par la présente, je me permets de vous remettre notre facture pour le financement de nos activités associatives pour l\'année académique 2014-2015.\''), blank=True, null=True) @@ -671,7 +671,8 @@ def generate_QR(self): debtor={ 'name': self.client_name, 'line1': address[0][0:70], - 'line2': address[1][0:70] if len(address) > 1 else '' + 'line2': address[1][0:70] if len(address) > 1 else '', + 'country': 'CH', #otherwise not accepted by some banks }, creditor={ 'name': u'Ass. Genérale Des Etudiants de l\'EPFL', 'street': u'Case Postale', 'house_num': u'16', 'pcode': u'1015', 'city': u'Lausanne', u'country': u'CH', diff --git a/truffe2/accounting_tools/qrbill.py b/truffe2/accounting_tools/qrbill.py index b58df2f5..e87018f3 100644 --- a/truffe2/accounting_tools/qrbill.py +++ b/truffe2/accounting_tools/qrbill.py @@ -103,25 +103,25 @@ def __init__(self, **_3to2kwargs): raise ValueError(u"City is mandatory") elif len(self.city) > 35: raise ValueError(u"A city cannot have more than 35 characters.") - country = (country or u'').strip() - # allow users to write the country as if used in an address in the local language - if not country or country.lower() in [u'schweiz', u'suisse', u'svizzera', u'svizra']: - country = u'CH' - if country.lower() in [u'fürstentum liechtenstein']: - country = u'LI' - try: - self.country = countries.get(country).alpha2 - except KeyError: - raise ValueError(u"The country code '%s' is not valid" % country) - self.country = countries.get(country).alpha2 self.combined = False - + + country = (country or u'').strip() + # allow users to write the country as if used in an address in the local language + if not country or country.lower() in [u'schweiz', u'suisse', u'svizzera', u'svizra']: + country = u'CH' + if country.lower() in [u'fürstentum liechtenstein']: + country = u'LI' + try: + self.country = countries.get(country).alpha2 + except KeyError: + raise ValueError(u"The country code '%s' is not valid" % country) + def data_list(self): u"""Return address values as a list, appropriate for qr generation.""" # 'S': structured address if self.combined: return [ - u'K', self.name, self.line1, self.line2, '', '', '' + u'K', self.name, self.line1, self.line2, '', '', self.country ] else: return [