Projet

Général

Profil

0001-lingo-show-invoice-no-online-payment-reason-if-prese.patch

Serghei Mihai (congés, retour 15/05), 08 avril 2016 12:42

Télécharger (4,39 ko)

Voir les différences:

Subject: [PATCH] lingo: show invoice no online payment reason if present
 (#10483)

Use invoice no online payment reason to define line style
 combo/apps/lingo/models.py                        | 15 +++++++++++++--
 combo/apps/lingo/templates/lingo/combo/item.html  |  3 +++
 combo/apps/lingo/templates/lingo/combo/items.html |  2 +-
 combo/settings.py                                 |  4 ++++
 4 files changed, 21 insertions(+), 3 deletions(-)
combo/apps/lingo/models.py
65 65
                      subject=data.get('label'),
66 66
                      has_pdf=data.get('has_pdf'),
67 67
                      online_payment=data.get('online_payment'),
68
                      payment_date=data.get('payment_date'))
68
                      paid=data.get('paid'),
69
                      payment_date=data.get('payment_date'),
70
                      no_online_payment_reason=data.get('no_online_payment_reason'))
69 71

  
70 72

  
71 73
class Regie(models.Model):
......
224 226

  
225 227
    def __init__(self, id, regie, creation_date, payment_limit_date,
226 228
                 total_amount, amount, display_id, subject, has_pdf,
227
                 online_payment, payment_date):
229
                 online_payment, paid, payment_date, no_online_payment_reason):
228 230
        self.id = id
229 231
        self.regie = regie
230 232
        self.creation_date = parser.parse(creation_date)
......
235 237
        self.subject = subject
236 238
        self.has_pdf = has_pdf
237 239
        self.online_payment = online_payment
240
        self.paid = paid
241
        self.no_online_payment_reason = no_online_payment_reason
238 242
        if payment_date:
239 243
            self.payment_date = parser.parse(payment_date)
240 244

  
245
    @property
246
    def no_online_payment_reason_details(self):
247
        reasons = {'litigation': _('This invoice is in ligitation.'),
248
                   'autobilling': _('Autobilling has been set for this invoice.')}
249
        return settings.LINGO_NO_ONLINE_PAYMENT_REASONS.get(self.no_online_payment_reason,
250
                                reasons.get(self.no_online_payment_reason))
251

  
241 252

  
242 253
class Transaction(models.Model):
243 254
    regie = models.ForeignKey(Regie, null=True)
combo/apps/lingo/templates/lingo/combo/item.html
29 29
        {% if item.payment_date %}
30 30
        <div class="paid">{% trans "Payed on:" %} <span class="timestamp">{{ item.payment_date|date:"SHORT_DATE_FORMAT" }}</span></div>
31 31
        {% endif %}
32
        {% if item.no_online_payment_reason_details %}
33
        <div class="no-online-payment-reason"><span>{{ item.no_online_payment_reason_details }}</span></div>
34
        {% endif %}
32 35
        {% if item.online_payment and item.amount >= regie.payment_min_amount %}
33 36
        {% csrf_token %}
34 37
        <input type="hidden" name="regie" value="{{ regie.pk }}" />
combo/apps/lingo/templates/lingo/combo/items.html
16 16
  </thead>
17 17
  <tbody>
18 18
  {% for item in items %}
19
  <tr>
19
  <tr{% if item.no_online_payment_reason %} class='{{ item.no_online_payment_reason }}-invoice'{% endif %}>
20 20
    <td class="invoice-id">{{ item.display_id }}</td>
21 21
    <td class="invoice-subject">{{ item.subject }}</td>
22 22
    <td class="invoice-creation-date">{{ item.creation_date|date:"SHORT_DATE_FORMAT" }}</td>
combo/settings.py
241 241

  
242 242
MELLON_IDENTITY_PROVIDERS = []
243 243

  
244
# mapping of payment modes
245
LINGO_NO_ONLINE_PAYMENT_REASONS = {}
246

  
247

  
244 248
local_settings_file = os.environ.get('COMBO_SETTINGS_FILE',
245 249
        os.path.join(os.path.dirname(__file__), 'local_settings.py'))
246 250
if os.path.exists(local_settings_file):
247
-