Skip to content

Commit

Permalink
Fix QR Bill country
Browse files Browse the repository at this point in the history
  • Loading branch information
TeoGoddet committed Oct 11, 2020
1 parent 4f5d25c commit e20b043
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
5 changes: 3 additions & 2 deletions truffe2/accounting_tools/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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',
Expand Down
26 changes: 13 additions & 13 deletions truffe2/accounting_tools/qrbill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down

0 comments on commit e20b043

Please sign in to comment.