From 7a40b55f43bcb065aee2d53239164297f4c6761d Mon Sep 17 00:00:00 2001 From: Serghei Mihai Date: Wed, 30 Mar 2016 18:10:17 +0200 Subject: [PATCH] lingo: show invoice no online payment reason details if present (#10483) Use invoice no online payment reason to define line style --- combo/apps/lingo/models.py | 12 ++++++++++-- combo/apps/lingo/templates/lingo/combo/item.html | 5 +++++ combo/apps/lingo/templates/lingo/combo/items.html | 2 +- combo/settings.py | 5 +++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/combo/apps/lingo/models.py b/combo/apps/lingo/models.py index 7f021de..87bc856 100644 --- a/combo/apps/lingo/models.py +++ b/combo/apps/lingo/models.py @@ -73,7 +73,9 @@ def build_remote_item(data, regie): subject=data.get('label'), has_pdf=data.get('has_pdf'), online_payment=data.get('online_payment'), - payment_date=data.get('payment_date')) + paid=data.get('paid'), + payment_date=data.get('payment_date'), + no_online_payment_reason=data.get('no_online_payment_reason')) class Regie(models.Model): @@ -232,7 +234,7 @@ class RemoteItem(object): def __init__(self, id, regie, creation_date, payment_limit_date, total_amount, amount, display_id, subject, has_pdf, - online_payment, payment_date): + online_payment, paid, payment_date, no_online_payment_reason): self.id = id self.regie = regie self.creation_date = parser.parse(creation_date) @@ -243,9 +245,15 @@ class RemoteItem(object): self.subject = subject self.has_pdf = has_pdf self.online_payment = online_payment + self.paid = paid + self.no_online_payment_reason = no_online_payment_reason if payment_date: self.payment_date = parser.parse(payment_date) + @property + def no_online_payment_reason_details(self): + return settings.LINGO_NO_ONLINE_PAYMENT_REASONS.get(self.no_online_payment_reason) + class Transaction(models.Model): regie = models.ForeignKey(Regie, null=True) diff --git a/combo/apps/lingo/templates/lingo/combo/item.html b/combo/apps/lingo/templates/lingo/combo/item.html index 13b902e..756d184 100644 --- a/combo/apps/lingo/templates/lingo/combo/item.html +++ b/combo/apps/lingo/templates/lingo/combo/item.html @@ -29,6 +29,11 @@ {% if item.payment_date %} {% endif %} + {% with no_online_payment_reason_details=item.no_online_payment_reason_details %} + {% if no_online_payment_reason_details %} +
{{ no_online_payment_reason_details }}
+ {% endif %} + {% endwith %} {% if item.online_payment and item.amount >= regie.payment_min_amount %} {% csrf_token %} diff --git a/combo/apps/lingo/templates/lingo/combo/items.html b/combo/apps/lingo/templates/lingo/combo/items.html index cd5342a..93801b4 100644 --- a/combo/apps/lingo/templates/lingo/combo/items.html +++ b/combo/apps/lingo/templates/lingo/combo/items.html @@ -16,7 +16,7 @@ {% for item in items %} - + {{ item.display_id }} {{ item.subject }} {{ item.creation_date|date:"SHORT_DATE_FORMAT" }} diff --git a/combo/settings.py b/combo/settings.py index 7b57799..d33a7ac 100644 --- a/combo/settings.py +++ b/combo/settings.py @@ -240,6 +240,11 @@ MELLON_USERNAME_TEMPLATE = '{attributes[name_id_content]}' MELLON_IDENTITY_PROVIDERS = [] +# mapping of payment modes +LINGO_NO_ONLINE_PAYMENT_REASONS = {'litigation': _('This is a litigation invoice, thus not payable online'), + 'autobilling': _('This is an autobilling invoice, thus not payable online')} + + local_settings_file = os.environ.get('COMBO_SETTINGS_FILE', os.path.join(os.path.dirname(__file__), 'local_settings.py')) if os.path.exists(local_settings_file): -- 2.8.0.rc3