diff --git a/mondumas/templates/devis/devis_view.pt b/mondumas/templates/devis/devis_view.pt index 61f28e5..c0f5390 100644 --- a/mondumas/templates/devis/devis_view.pt +++ b/mondumas/templates/devis/devis_view.pt @@ -69,9 +69,9 @@ TVA - ${layout.to_decz(dossier.TOTALHT)} - ${layout.to_euroz(dossier.TOTALTVA)} - ${layout.to_euroz(dossier.TOTALTTC)} + ${layout.to_euro(dossier.TOTALHT)} + ${layout.to_euro(dossier.TOTALTVA)} + ${layout.to_euro(dossier.TOTALTTC)} ${dossier.TAUXTVA} % @@ -88,7 +88,7 @@ ${detail.REF} ${detail.LIB} - ${layout.to_decz(detail.QTE)} + ${layout.to_euro(detail.QTE)} ${layout.to_euroz(detail.PRIXHT)} ${layout.to_euroz(detail.MTHT)} ${detail.USERMAJ} diff --git a/mondumas/templates/devis/devis_web.pt b/mondumas/templates/devis/devis_web.pt index 1fc1d04..42933bd 100644 --- a/mondumas/templates/devis/devis_web.pt +++ b/mondumas/templates/devis/devis_web.pt @@ -44,9 +44,9 @@ TVA - ${layout.to_decz(dossier.TOTALHT)} - ${layout.to_euroz(dossier.TOTALTVA)} - ${layout.to_euroz(dossier.TOTALTTC)} + ${layout.to_euro(dossier.TOTALHT)} + ${layout.to_euro(dossier.TOTALTVA)} + ${layout.to_euro(dossier.TOTALTTC)} ${dossier.TAUXTVA} % diff --git a/mondumas/views/default.py b/mondumas/views/default.py index 4409c39..d7ac081 100644 --- a/mondumas/views/default.py +++ b/mondumas/views/default.py @@ -17,12 +17,13 @@ from pyramid.httpexceptions import ( from pyramid_mailer import get_mailer from pyramid_mailer.message import Message, Attachment from datetime import * -import hashlib from sqlalchemy.exc import DBAPIError from ..security import groupfinder from user_agents import parse import json +import locale +import hashlib from ..models.default import * from ..models.agenda import * @@ -37,25 +38,23 @@ def to_decimal(x): def to_euro(x): """Takes a float and returns a string""" - #if x == 0: - # return "" - #else: - return ("%.2f €" % x).replace('.', ',') + locale.setlocale(locale.LC_ALL,'') + return locale.currency(x, True, True) def to_euroz(x): """Takes a float and returns a string""" if x == 0: return "" else: - return ("%9.2f €" % x).replace('.', ',') + return to_euro(x) def to_decz(x): - """Takes a decimal and returns a string""" + """Takes a float and returns a number with 2 dec""" + locale.setlocale(locale.LC_ALL,'') if x == 0: return "" else: - return ("%.2f" % x).replace('.', ',') - + return locale.format_string('%.2f',x, False) def to_sha1(message): return hashlib.sha1(message.encode('utf-8')).hexdigest() diff --git a/mondumas/views/devis.py b/mondumas/views/devis.py index 9151a00..c19a92a 100644 --- a/mondumas/views/devis.py +++ b/mondumas/views/devis.py @@ -305,8 +305,8 @@ def devis_preview(request): dt_html += '%s
' % ligne.deduction dt_html += '

' dt_html += '

%s

' % ligne.qte - dt_html += '

%s

' % ligne.prixht - dt_html += '

%s

' % ligne.mtht + dt_html += '

%s

' % to_euro(ligne.prixht) + dt_html += '

%s

' % to_euro(ligne.mtht) return { 'page_title': '',