use locale to format currency
This commit is contained in:
@@ -69,9 +69,9 @@
|
||||
<th class="text-right">TVA</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-right">${layout.to_decz(dossier.TOTALHT)}</td>
|
||||
<td class="text-right">${layout.to_euroz(dossier.TOTALTVA)}</td>
|
||||
<td class="text-right">${layout.to_euroz(dossier.TOTALTTC)}</td>
|
||||
<td class="text-right">${layout.to_euro(dossier.TOTALHT)}</td>
|
||||
<td class="text-right">${layout.to_euro(dossier.TOTALTVA)}</td>
|
||||
<td class="text-right">${layout.to_euro(dossier.TOTALTTC)}</td>
|
||||
<td class="text-right">${dossier.TAUXTVA} %</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -88,7 +88,7 @@
|
||||
<tr tal:repeat="detail details">
|
||||
<td>${detail.REF}</td>
|
||||
<td>${detail.LIB}</td>
|
||||
<td class="text-right">${layout.to_decz(detail.QTE)}</td>
|
||||
<td class="text-right">${layout.to_euro(detail.QTE)}</td>
|
||||
<td class="text-right">${layout.to_euroz(detail.PRIXHT)}</td>
|
||||
<td class="text-right">${layout.to_euroz(detail.MTHT)}</td>
|
||||
<td class="text-center">${detail.USERMAJ}</td>
|
||||
|
||||
@@ -44,9 +44,9 @@
|
||||
<th class="text-right">TVA</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-right">${layout.to_decz(dossier.TOTALHT)}</td>
|
||||
<td class="text-right">${layout.to_euroz(dossier.TOTALTVA)}</td>
|
||||
<td class="text-right">${layout.to_euroz(dossier.TOTALTTC)}</td>
|
||||
<td class="text-right">${layout.to_euro(dossier.TOTALHT)}</td>
|
||||
<td class="text-right">${layout.to_euro(dossier.TOTALTVA)}</td>
|
||||
<td class="text-right">${layout.to_euro(dossier.TOTALTTC)}</td>
|
||||
<td class="text-right">${dossier.TAUXTVA} %</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -305,8 +305,8 @@ def devis_preview(request):
|
||||
dt_html += '<i>%s</i><br />' % ligne.deduction
|
||||
dt_html += '</p></div>'
|
||||
dt_html += '<div class="col-sm-1"><p class="text-right">%s</p></div>' % ligne.qte
|
||||
dt_html += '<div class="col-sm-2"><p class="text-right">%s</p></div>' % ligne.prixht
|
||||
dt_html += '<div class="col-sm-2"><p class="text-right">%s</p></div>' % ligne.mtht
|
||||
dt_html += '<div class="col-sm-2"><p class="text-right">%s</p></div>' % to_euro(ligne.prixht)
|
||||
dt_html += '<div class="col-sm-2"><p class="text-right">%s</p></div>' % to_euro(ligne.mtht)
|
||||
|
||||
return {
|
||||
'page_title': '',
|
||||
|
||||
Reference in New Issue
Block a user