racourcir les libelles des actions

This commit is contained in:
2022-03-06 16:21:07 +01:00
parent 0125b73ab6
commit f97e03204f
3 changed files with 24 additions and 23 deletions

View File

@@ -24,7 +24,16 @@ class GlobalLayout(object):
return to_decimal(x) return to_decimal(x)
def to_euro(self, x): def to_euro(self, x):
return to_euro(x) if x == 0:
return ''
else:
return to_euro(x)
def zero2space(self, x):
if x == 0:
return ''
else:
return x
def to_usd(self, x): def to_usd(self, x):
return to_usd(x) return to_usd(x)

View File

@@ -108,7 +108,7 @@
<th class="text-right">+/- Valeur</th> <th class="text-right">+/- Valeur</th>
<th class="text-right">% de +/-</th> <th class="text-right">% de +/-</th>
<th class="text-right">Rdt brut</th> <th class="text-right">Rdt brut</th>
<th class="text-right">TER</th> <th class="text-right">% TER</th>
<th class="text-right">% PF</th> <th class="text-right">% PF</th>
</tr> </tr>
</thead> </thead>
@@ -123,11 +123,11 @@
<td class="text-right">${layout.to_euro(ligne.valeur)}</td> <td class="text-right">${layout.to_euro(ligne.valeur)}</td>
<td tal:condition="ligne.plus_value>=0" class="text-right" style="color: green;">${layout.to_euro(ligne.plus_value)}</td> <td tal:condition="ligne.plus_value>=0" class="text-right" style="color: green;">${layout.to_euro(ligne.plus_value)}</td>
<td tal:condition="ligne.plus_value <0" class="text-right" style="color: red;">${layout.to_euro(ligne.plus_value)}</td> <td tal:condition="ligne.plus_value <0" class="text-right" style="color: red;">${layout.to_euro(ligne.plus_value)}</td>
<td tal:condition="ligne.pc_plusvalue>=0" class="text-right" style="color: green;">${layout.to_percent(ligne.pc_plusvalue,1)}</td> <td tal:condition="ligne.pc_plusvalue>=0" class="text-right" style="color: green;">${ligne.pc_plusvalue}</td>
<td tal:condition="ligne.pc_plusvalue <0" class="text-right" style="color: red;">${layout.to_percent(ligne.pc_plusvalue,1)}</td> <td tal:condition="ligne.pc_plusvalue <0" class="text-right" style="color: red;">${ligne.pc_plusvalue}</td>
<td class="text-right">${layout.to_euro(ligne.rendement)}</td> <td class="text-right">${layout.to_euro(ligne.rendement)}</td>
<td class="text-right">${layout.to_percent(ligne.ter,2)}</td> <td class="text-right">${layout.zero2space(ligne.ter)}</td>
<td class="text-right">${ligne.pc_allocation} %</td> <td class="text-right">${ligne.pc_allocation}</td>
</tr> </tr>
<tr> <tr>
<td class="text-right" colspan="4"><b>Total</b></td> <td class="text-right" colspan="4"><b>Total</b></td>
@@ -138,7 +138,7 @@
<td class="text-right"><b>${layout.to_percent(total_pc_value, 1)}</b></td> <td class="text-right"><b>${layout.to_percent(total_pc_value, 1)}</b></td>
<td class="text-right"><b>${layout.to_euro(total_rdt)}</b></td> <td class="text-right"><b>${layout.to_euro(total_rdt)}</b></td>
<td></td> <td></td>
<td class="text-right"><b>100.0 %</b></td> <td class="text-right"><b>100.0</b></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@@ -1,22 +1,10 @@
# -*- coding: utf8 -*- # -*- coding: utf8 -*-
from pyramid.response import Response
from pyramid.renderers import render, get_renderer
from pyramid.view import ( from pyramid.view import (
view_config, view_config,
forbidden_view_config, )
)
from pyramid.httpexceptions import ( from pyramid.httpexceptions import (
HTTPFound, HTTPFound,
HTTPNotFound, )
HTTPForbidden,
)
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 ..models.default import * from ..models.default import *
from ..models.portfolio import * from ..models.portfolio import *
@@ -172,14 +160,18 @@ def actif_edit(request):
ticker = yf.Ticker(symbole) ticker = yf.Ticker(symbole)
new_values['cours'] = ticker.info.get('regularMarketPrice') new_values['cours'] = ticker.info.get('regularMarketPrice')
new_values['devise'] = ticker.info.get('currency') new_values['devise'] = ticker.info.get('currency')
new_values['libelle'] = html.unescape(ticker.info.get('shortName')) libelle = html.unescape(ticker.info.get('shortName'))
# raccourcir le libelle
libelle = libelle.replace('UCITS ','')
libelle = libelle.replace('World U','World')
new_values['libelle'] = libelle
update_actif(request, no_id, new_values) update_actif(request, no_id, new_values)
request.session.flash(u"La fiche a été mise à jour avec succès.", 'success') request.session.flash(u"La fiche a été mise à jour avec succès.", 'success')
return HTTPFound(location=request.route_url('portfolio')) return HTTPFound(location=request.route_url('portfolio'))
if 'form.deleted' in request.params: if 'form.deleted' in request.params:
delete_actif(request, no_id) delete_actif(request, no_id)
request.session.flash(u"La fiche a été supprimée avec succès.", 'success') request.session.flash(u"La fiche as été supprimée avec succès.", 'success')
return HTTPFound(location=request.route_url('portfolio')) return HTTPFound(location=request.route_url('portfolio'))
return { return {