Projet

Général

Profil

« Précédent | Suivant » 

Révision f82ab4b8

Ajouté par Frédéric Péters il y a plus de 9 ans

convert invoice values to proper datatypes (#6433)

This removes the need to call portail_citoyen2 templatetags to do the
conversion at template rendering time.

Voir les différences:

facturier/models.py
1
from datetime import datetime
2
from decimal import Decimal
3

  
1 4
from django.db import models
2 5
from django.core.urlresolvers import reverse
3 6
from django.utils.translation import ugettext_lazy as _, pgettext_lazy
......
99 102
                        invoice['download_url'] = reverse('invoice-download',
100 103
                            args=(self.slug, invoice_id, invoice_hash))
101 104
                        break
105
            # convert values to proper datatypes
106
            for amount_key in ('paid_amount', 'total_amount', 'amount'):
107
                if invoice.get(amount_key):
108
                    invoice[amount_key] = Decimal(invoice[amount_key])
109
            for date_key in ('creation_date', 'expiration_date', 'paid_date',
110
                    'tipi_paid_date'):
111
                if invoice.get(date_key):
112
                    invoice[date_key] = datetime.strptime(invoice[date_key], '%Y-%m-%d')
102 113
        return invoice
103 114

  
104 115

  
facturier/templates/facturier/tipi.html
1 1
{% extends 'base-cms.html' %}
2
{% load i18n portail_citoyen_tags facturier_tags %}
2
{% load i18n facturier_tags %}
3 3

  
4 4
{% block breadcrumbs %}
5 5
<li><a href="/factures/">Mes factures</a></li>
......
44 44
    <h1>Facture n° {{ invoice.id }}</h1>
45 45
    <div class="rteContent col">
46 46
      <div class="wrapSpecial">
47
    {% if invoice.paid_amount|to_decimal and invoice.total_amount != invoice.paid_amount %}
47
    {% if invoice.paid_amount and invoice.total_amount != invoice.paid_amount %}
48 48
    <h2>Facture réglée partiellement</h2>
49 49
    {% endif %}
50 50
    <h2>Montant de la facture : {{ invoice.total_amount }} €</h2>
51 51
    <h2>Montant restant à régler : {{ invoice.amount }} €</h2>
52 52

  
53 53
    <p>Facture émise le
54
      {{ invoice.creation_date|to_date|date:"j F Y" }}
54
      {{ invoice.creation_date|date:"j F Y" }}
55 55
      {% if invoice.prelevement_automatique %}
56 56
      <br />
57 57
      Prélèvement automatique
58
      {% if invoice.amount|to_decimal %}
59
                              prévu le {{ invoice.expiration_date|to_date|date:"j F Y" }}
58
      {% if invoice.amount %}
59
                              prévu le {{ invoice.expiration_date|date:"j F Y" }}
60 60
                              {% else %}
61
                              effectué le {{ invoice.paid_date|to_date|date:"j F Y" }}
61
                              effectué le {{ invoice.paid_date|date:"j F Y" }}
62 62
                              {% endif %}
63 63
                              {% endif %}
64 64
                              </p>
......
91 91
    {% elif invoice.paid %}
92 92
    <p>
93 93
      Cette facture a été réglée
94
      {% if invoice.paid_date %}le {{ invoice.paid_date|to_date|date:"j F Y" }}
95
      {% elif invoice.tipi_paid_date %} le {{ invoice.tipi_paid_date|to_date|date:"j F Y" }} {% endif %}
94
      {% if invoice.paid_date %}le {{ invoice.paid_date|date:"j F Y" }}
95
      {% elif invoice.tipi_paid_date %} le {{ invoice.tipi_paid_date|date:"j F Y" }} {% endif %}
96 96
    </p>
97 97

  
98 98
    {% elif invoice.expired %}

Formats disponibles : Unified diff