Parcourir la source

Factorize common parts in invoice/membershipfee/donation templates

Alexandre Aubin il y a 6 ans
Parent
commit
406255e9bd

+ 190 - 0
arn/templates/billing/bill_pdf.html

@@ -0,0 +1,190 @@
+{% load static isptags %}
+<html>
+<head>
+  <title>{{ bill.pdf_title }}</title>
+
+  <style>
+  @page {
+    margin: 0; padding: 40pt;
+  }
+
+  html {
+    box-sizing: border-box;
+  }
+  *, *:before, *:after {
+    box-sizing: inherit;
+  }
+
+  body {
+    font-size: 9pt;
+    font-family: sans-serif;
+    color: #111;
+    padding: 0;
+  }
+  a {
+    color: #111;
+    text-decoration: none;
+  }
+
+  p {
+    margin: 0;
+  }
+  p + p {
+    margin-top: 10pt;
+  }
+  table {
+    border-collapse: collapse;
+    width: 100%;
+    margin: 40pt 0;
+  }
+
+  h1 {
+    font-size: 12pt;
+  }
+
+  #header {
+    margin: 0 0 60pt 0;
+    border: none;
+  }
+
+  #header .logo {
+    height: 50pt;
+    margin: 0;
+  }
+
+  #header .header-left {
+    text-align: left;
+  }
+
+  #header .header-right {
+    text-align: right;
+  }
+
+  footer {
+    position: fixed;
+    bottom: 0;
+    width: 100%;
+  }
+
+  footer .logo {
+    height: 20pt;
+  }
+
+  #coordonnees {}
+
+  #coordonnees td {
+    width: 50%;
+    vertical-align: top;
+  }
+
+  #details {}
+
+  #details th,
+  #details td {
+    padding: 5pt;
+    border:1px solid #ddd;
+  }
+  #details th.cell--empty,
+  #details td.cell--empty {border: 0;}
+
+  /* details cell layout */
+  .cell-label {width: 70%;}
+  .cell-quantity {width: 5%;}
+  .cell-amount {width: 10%;}
+  .cell-tax {width: 5%;}
+  .cell-total {width: 15%;}
+
+  /* details cell style */
+  .cell-result {
+    font-weight: bold;
+  }
+  .cell-quantity {
+    text-align: center;
+  }
+  .cell--money,
+  .cell-tax {
+    text-align: right;
+    white-space: nowrap;
+  }
+
+  .cell-label p + p {
+    margin-top: 5pt;
+  }
+  .period {
+    color:#888;
+  }
+
+  #paiements {
+    margin-top: 40pt;
+    background-color: #f0f0f0;
+    padding: 10pt;
+    font-size: x-small;
+  }
+
+  footer {
+    font-size: xx-small;
+  }
+  .pagination {
+    float: right;
+  }
+  </style>
+</head>
+<body>
+
+  {% block header %}
+  <table id="header">
+      <tr>
+          <td class="header-left">
+              <img class="logo" src="{{ branding.logoURL }}" />
+          </td>
+          <td class="header-right">
+              <h1>{{ bill.pdf_title }}</h1>
+              <p>Date : {{ bill.date }}</p>
+          </td>
+      </tr>
+  </table>
+  {% endblock %}
+
+  {% block coordinates %}
+  <table id="coordonnees">
+    <tr>
+      <td id="coordonnees_isp">
+        <p>
+        {% multiline_isp_addr branding %}
+        </p>
+        <p>
+        <a href="mailto:{{ branding.email }}">{{ branding.email }}</a><br/>
+        <a href="{{ branding.website }}">{{ branding.website }}</a><br />
+        {{ branding.phone_number }}<br />
+        SIRET : {{ branding.registeredoffice.siret }}
+        </p>
+      </td>
+      <td id="coordonnees_client">
+        <p>
+        <strong>À l'intention de :</strong><br/>
+        {% with member=bill.member %}
+        {{ member.last_name }} {{ member.first_name }}<br />
+        {% if member.organization_name != "" %}{{ member.organization_name }}<br />{% endif %}
+        {% if member.address %}{{member.address}}<br />{% endif %}
+        {% if member.postal_code and member.city %}
+        {{ member.postal_code }} {{ member.city }}
+        {% endif %}
+        {% endwith %}
+        </p>
+      </td>
+    </tr>
+  </table>
+  {% endblock %}
+
+  {% block content %}
+  {% endblock %}
+
+  {% block footer %}
+  <footer>
+    <p class="pagination"><pdf:pagenumber>/<pdf:pagecount></p>
+    <p>{{ branding.shortname|upper }} est une association de droit local alsacien-mosellan à but non lucratif.</p>
+  </footer>
+  {% endblock %}
+
+</body>
+</html>

+ 13 - 0
coin/billing/models.py

@@ -325,6 +325,10 @@ class Invoice(Bill):
                 and bool(self.pdf)
                 and private_files_storage.exists(self.pdf.name))
 
+    @property
+    def pdf_title(self):
+        return "Facture N°"+self.number
+
     def __unicode__(self):
         return '#{} {:0.2f}€ {}'.format(
             self.number, self.amount, self.date_due)
@@ -475,6 +479,11 @@ class Donation(Bill):
             raise ValidationError("Le solde n'est pas suffisant pour payer ce don. \
                         Merci de commencer par enregistrer un paiement pour ce membre.")
 
+    @property
+    def pdf_title(self):
+       return "Reçu de don"
+
+
     class Meta:
         verbose_name = 'don'
 
@@ -517,6 +526,10 @@ class MembershipFee(Bill):
         if self.start_date is not None and self.end_date is None:
             self.end_date = self.start_date + datetime.timedelta(364)
 
+    @property
+    def pdf_title(self):
+       return "Reçu de cotisation"
+
     class Meta:
         verbose_name = 'cotisation'
 

+ 175 - 0
coin/billing/templates/billing/bill_pdf.html

@@ -0,0 +1,175 @@
+{% load static isptags %}
+<html>
+<head>
+  <title>{{ bill.pdf_title }}</title>
+
+  <style>
+  @page {
+    margin: 0; padding: 40pt;
+  }
+
+  html {
+    box-sizing: border-box;
+  }
+  *, *:before, *:after {
+    box-sizing: inherit;
+  }
+
+  body {
+    font-size: 9pt;
+    font-family: sans-serif;
+    color: #111;
+    padding: 0;
+  }
+  a {
+    color: #111;
+    text-decoration: none;
+  }
+
+  p {
+    margin: 0;
+  }
+  p + p {
+    margin-top: 10pt;
+  }
+  table {
+    border-collapse: collapse;
+    width: 100%;
+    margin: 40pt 0;
+  }
+
+  h1 {
+    font-size: 12pt;
+  }
+
+  header {
+    margin: 0 0 60pt 0;
+  }
+
+  header .logo {
+    height: 35pt;
+    margin: 0 auto 20pt;
+  }
+
+  footer {
+    position: fixed;
+    bottom: 0;
+    width: 100%;
+  }
+
+  footer .logo {
+    height: 20pt;
+  }
+
+  #coordonnees {}
+
+  #coordonnees td {
+    width: 50%;
+    vertical-align: top;
+  }
+
+  #details {}
+
+  #details th,
+  #details td {
+    padding: 5pt;
+    border:1px solid #ddd;
+  }
+  #details th.cell--empty,
+  #details td.cell--empty {border: 0;}
+
+  /* details cell layout */
+  .cell-label {width: 70%;}
+  .cell-quantity {width: 5%;}
+  .cell-amount {width: 10%;}
+  .cell-tax {width: 5%;}
+  .cell-total {width: 15%;}
+
+  /* details cell style */
+  .cell-result {
+    font-weight: bold;
+  }
+  .cell-quantity {
+    text-align: center;
+  }
+  .cell--money,
+  .cell-tax {
+    text-align: right;
+    white-space: nowrap;
+  }
+
+  .cell-label p + p {
+    margin-top: 5pt;
+  }
+  .period {
+    color:#888;
+  }
+
+  #paiements {
+    margin-top: 40pt;
+    background-color: #f0f0f0;
+    padding: 10pt;
+    font-size: x-small;
+  }
+
+  footer {
+    font-size: xx-small;
+  }
+  .pagination {
+    float: right;
+  }
+  </style>
+</head>
+<body>
+
+  {% block header %}
+  <header>
+    <img class="logo" src="{{ branding.logoURL }}" />
+    <h1>{{ bill.pdf_title }}</h1>
+    <p>Le {{ bill.date }}</p>
+  </header>
+  {% endblock %}
+
+  {% block coordinates %}
+  <table id="coordonnees">
+    <tr>
+      <td id="coordonnees_isp">
+        <p>
+        {% multiline_isp_addr branding %}
+        </p>
+        <p>
+        <a href="mailto:{{ branding.email }}">{{ branding.email }}</a><br/>
+        <a href="{{ branding.website }}">{{ branding.website }}</a><br />
+        {{ branding.phone_number }}
+        </p>
+      </td>
+      <td id="coordonnees_client">
+        <p>
+        <strong>À l'intention de :</strong><br/>
+        {% with member=bill.member %}
+        {{ member.last_name }} {{ member.first_name }}<br />
+        {% if member.organization_name != "" %}{{ member.organization_name }}<br />{% endif %}
+        {% if member.address %}{{member.address}}<br />{% endif %}
+        {% if member.postal_code and member.city %}
+        {{ member.postal_code }} {{ member.city }}
+        {% endif %}
+        {% endwith %}
+        </p>
+      </td>
+    </tr>
+  </table>
+  {% endblock %}
+
+  {% block content %}
+  {% endblock %}
+
+  {% block footer %}
+  <footer>
+    <img class="logo" src="{{ branding.logoURL }}" />
+    <p class="pagination"><pdf:pagenumber>/<pdf:pagecount></p>
+    <p>{{ branding.shortname|upper }}, association loi de 1901 à but non lucratif - SIRET : {{ branding.registeredoffice.siret }}</p>
+  </footer>
+  {% endblock %}
+
+</body>
+</html>

+ 4 - 166
coin/billing/templates/billing/donation_pdf.html

@@ -1,161 +1,6 @@
-{% load static isptags %}
-<html>
-<head>
-  <title>Reçu de don</title>
-
-  <style>
-  @page {
-    margin: 0; padding: 40pt;
-  }
-
-  html {
-    box-sizing: border-box;
-  }
-  *, *:before, *:after {
-    box-sizing: inherit;
-  }
-
-  body {
-    font-size: 9pt;
-    font-family: sans-serif;
-    color: #111;
-    padding: 0;
-  }
-  a {
-    color: #111;
-    text-decoration: none;
-  }
-
-  p {
-    margin: 0;
-  }
-  p + p {
-    margin-top: 10pt;
-  }
-  table {
-    border-collapse: collapse;
-    width: 100%;
-    margin: 40pt 0;
-  }
-
-  h1 {
-    font-size: 12pt;
-  }
-
-  header {
-    margin: 0 0 60pt 0;
-  }
-
-  header .logo {
-    height: 35pt;
-    margin: 0 auto 20pt;
-  }
-
-  footer {
-    position: fixed;
-    bottom: 0;
-    width: 100%;
-  }
-
-  footer .logo {
-    height: 20pt;
-  }
-
-  #coordonnees {}
-
-  #coordonnees td {
-    width: 50%;
-    vertical-align: top;
-  }
-
-  #details {}
-
-  #details th,
-  #details td {
-    padding: 5pt;
-    border:1px solid #ddd;
-  }
-  #details th.cell--empty,
-  #details td.cell--empty {border: 0;}
-
-  /* details cell layout */
-  .cell-label {width: 70%;}
-  .cell-quantity {width: 5%;}
-  .cell-amount {width: 10%;}
-  .cell-tax {width: 5%;}
-  .cell-total {width: 15%;}
-
-  /* details cell style */
-  .cell-result {
-    font-weight: bold;
-  }
-  .cell-quantity {
-    text-align: center;
-  }
-  .cell--money, 
-  .cell-tax {
-    text-align: right;
-    white-space: nowrap;
-  }
-
-  .cell-label p + p {
-    margin-top: 5pt;
-  }
-  .period {
-    color:#888;
-  }
-
-  #paiements {
-    margin-top: 40pt;
-    background-color: #f0f0f0;
-    padding: 10pt;
-    font-size: x-small;
-  }
-
-  footer {
-    font-size: xx-small;
-  }
-  .pagination {
-    float: right;
-  }
-  </style>
-</head>
-<body>
-
-  <header>
-    <img class="logo" src="{{ branding.logoURL }}" />
-    <h1>Reçu de don</h1>
-    <p>Le {{ bill.date }}</p>
-  </header>
-
-  <table id="coordonnees">
-    <tr>
-      <td id="coordonnees_isp">
-        <p>
-        {% multiline_isp_addr branding %}
-        </p>
-        <p>
-        <a href="mailto:{{ branding.email }}">{{ branding.email }}</a><br/>
-        <a href="{{ branding.website }}">{{ branding.website }}</a><br />
-        {{ branding.phone_number }}
-        </p>
-      </td>
-      <td id="coordonnees_client">
-        <p>
-        <strong>Pour :</strong><br/>
-        {% with member=bill.member %}
-        {{ member.last_name }} {{ member.first_name }}<br />
-        {% if member.organization_name != "" %}{{ member.organization_name }}<br />{% endif %}
-        {% if member.address %}{{member.address}}<br />{% endif %}
-        {% if member.postal_code and member.city %}
-        {{ member.postal_code }} {{ member.city }}
-        {% endif %}
-        {% endwith %}
-        </p>
-      </td>
-    </tr>
-  </table>
+{% extends "billing/bill_pdf.html" %}
 
+{% block content %}
   <br />
   <br />
   <br />
@@ -167,15 +12,8 @@
   <br />
   <br />
   <br />
-  
+
   <p>
   N.B. : ce reçu n'a pas valeur de reçu fiscal et ne peut pas être utilisé pour prétendre à une réduction d'impôts.
   </p>
-  
-  <footer>
-    <img class="logo" src="{{ branding.logoURL }}" />
-    <p class="pagination"><pdf:pagenumber>/<pdf:pagecount></p>
-    <p>{{ branding.shortname|upper }}, association loi de 1901 à but non lucratif - SIRET : {{ branding.registeredoffice.siret }}</p>
-  </footer>
-</body>
-</html>
+{% endblock %}

+ 14 - 176
coin/billing/templates/billing/invoice_pdf.html

@@ -1,162 +1,7 @@
-{% load static isptags %}
-<html>
-<head>
-  <title>Facture N°{{ bill.number }}</title>
+{% extends "billing/bill_pdf.html" %}
 
-  <style>
-  @page {
-    margin: 0; padding: 40pt;
-  }
-
-  html {
-    box-sizing: border-box;
-  }
-  *, *:before, *:after {
-    box-sizing: inherit;
-  }
-
-  body {
-    font-size: 9pt;
-    font-family: sans-serif;
-    color: #111;
-    padding: 0;
-  }
-  a {
-    color: #111;
-    text-decoration: none;
-  }
-
-  p {
-    margin: 0;
-  }
-  p + p {
-    margin-top: 10pt;
-  }
-  table {
-    border-collapse: collapse;
-    width: 100%;
-    margin: 40pt 0;
-  }
-
-  h1 {
-    font-size: 12pt;
-  }
-
-  header {
-    margin: 0 0 60pt 0;
-  }
-
-  header .logo {
-    height: 35pt;
-    margin: 0 auto 20pt;
-  }
-
-  footer {
-    position: fixed;
-    bottom: 0;
-    width: 100%;
-  }
-
-  footer .logo {
-    height: 20pt;
-  }
-
-  #coordonnees {}
-
-  #coordonnees td {
-    width: 50%;
-    vertical-align: top;
-  }
-
-  #details {}
-
-  #details th,
-  #details td {
-    padding: 5pt;
-    border:1px solid #ddd;
-  }
-  #details th.cell--empty,
-  #details td.cell--empty {border: 0;}
-
-  /* details cell layout */
-  .cell-label {width: 70%;}
-  .cell-quantity {width: 5%;}
-  .cell-amount {width: 10%;}
-  .cell-tax {width: 5%;}
-  .cell-total {width: 15%;}
-
-  /* details cell style */
-  .cell-result {
-    font-weight: bold;
-  }
-  .cell-quantity {
-    text-align: center;
-  }
-  .cell--money, 
-  .cell-tax {
-    text-align: right;
-    white-space: nowrap;
-  }
-
-  .cell-label p + p {
-    margin-top: 5pt;
-  }
-  .period {
-    color:#888;
-  }
-
-  #paiements {
-    margin-top: 40pt;
-    background-color: #f0f0f0;
-    padding: 10pt;
-    font-size: x-small;
-  }
-
-  footer {
-    font-size: xx-small;
-  }
-  .pagination {
-    float: right;
-  }
-  </style>
-</head>
-<body>
-
-  <header>
-    <img class="logo" src="{{ branding.logoURL }}" />
-    <h1>Facture N°{{ bill.number }}</h1>
-    <p>Le {{ bill.date }}</p>
-  </header>
-
-  <table id="coordonnees">
-    <tr>
-      <td id="coordonnees_isp">
-        <p>
-        {% multiline_isp_addr branding %}
-        </p>
-        <p>
-        <a href="mailto:{{ branding.email }}">{{ branding.email }}</a><br/>
-        <a href="{{ branding.website }}">{{ branding.website }}</a><br />
-        {{ branding.phone_number }}
-        </p>
-      </td>
-      <td id="coordonnees_client">
-        <p>
-        <strong>Facturé à :</strong><br/>
-        {% with member=bill.member %}
-        {{ member.last_name }} {{ member.first_name }}<br />
-        {% if member.organization_name != "" %}{{ member.organization_name }}<br />{% endif %}
-        {% if member.address %}{{member.address}}<br />{% endif %}
-        {% if member.postal_code and member.city %}
-        {{ member.postal_code }} {{ member.city }}
-        {% endif %}
-        {% endwith %}
-        </p>
-      </td>
-    </tr>
-  </table>
-
-  <table id="details" repeat="1">
+{% block content %}
+<table id="details" repeat="1">
     <thead>
       <tr>
         <th class="cell-label cell--empty"></th>
@@ -189,7 +34,7 @@
         <td class="cell-total cell--money">{{ detail.total }}€</td>
       </tr>
       {% endfor %}
-      
+
       <tr>
         <td class="cell-result cell--empty"></td>
         <td class="result-label " colspan="3">Total HT</td>
@@ -200,21 +45,14 @@
         <td class="cell-result result-label" colspan="3">Total TTC</td>
         <td class="cell-result result-total cell--money">{{ bill.amount }}€</td>
       </tr>
-       
-    </tbody>
-  </table>
-  <p>
-    Facture à payer avant le {{ bill.date_due }}.
-  </p>
-
-  <div id="paiements">
-  {% include "billing/payment_howto.html" %}
-  </div>
 
-  <footer>
-    <img class="logo" src="{{ branding.logoURL }}" />
-    <p class="pagination"><pdf:pagenumber>/<pdf:pagecount></p>
-    <p>{{ branding.shortname|upper }}, association loi de 1901 à but non lucratif - SIRET : {{ branding.registeredoffice.siret }}</p>
-  </footer>
-</body>
-</html>
+    </tbody>
+</table>
+<p>
+Facture à payer avant le {{ bill.date_due }}.
+</p>
+
+<div id="paiements">
+{% include "billing/payment_howto.html" %}
+</div>
+{% endblock %}

+ 3 - 165
coin/billing/templates/billing/membershipfee_pdf.html

@@ -1,161 +1,6 @@
-{% load static isptags %}
-<html>
-<head>
-  <title>Reçu de cotisation</title>
-
-  <style>
-  @page {
-    margin: 0; padding: 40pt;
-  }
-
-  html {
-    box-sizing: border-box;
-  }
-  *, *:before, *:after {
-    box-sizing: inherit;
-  }
-
-  body {
-    font-size: 9pt;
-    font-family: sans-serif;
-    color: #111;
-    padding: 0;
-  }
-  a {
-    color: #111;
-    text-decoration: none;
-  }
-
-  p {
-    margin: 0;
-  }
-  p + p {
-    margin-top: 10pt;
-  }
-  table {
-    border-collapse: collapse;
-    width: 100%;
-    margin: 40pt 0;
-  }
-
-  h1 {
-    font-size: 12pt;
-  }
-
-  header {
-    margin: 0 0 60pt 0;
-  }
-
-  header .logo {
-    height: 35pt;
-    margin: 0 auto 20pt;
-  }
-
-  footer {
-    position: fixed;
-    bottom: 0;
-    width: 100%;
-  }
-
-  footer .logo {
-    height: 20pt;
-  }
-
-  #coordonnees {}
-
-  #coordonnees td {
-    width: 50%;
-    vertical-align: top;
-  }
-
-  #details {}
-
-  #details th,
-  #details td {
-    padding: 5pt;
-    border:1px solid #ddd;
-  }
-  #details th.cell--empty,
-  #details td.cell--empty {border: 0;}
-
-  /* details cell layout */
-  .cell-label {width: 70%;}
-  .cell-quantity {width: 5%;}
-  .cell-amount {width: 10%;}
-  .cell-tax {width: 5%;}
-  .cell-total {width: 15%;}
-
-  /* details cell style */
-  .cell-result {
-    font-weight: bold;
-  }
-  .cell-quantity {
-    text-align: center;
-  }
-  .cell--money, 
-  .cell-tax {
-    text-align: right;
-    white-space: nowrap;
-  }
-
-  .cell-label p + p {
-    margin-top: 5pt;
-  }
-  .period {
-    color:#888;
-  }
-
-  #paiements {
-    margin-top: 40pt;
-    background-color: #f0f0f0;
-    padding: 10pt;
-    font-size: x-small;
-  }
-
-  footer {
-    font-size: xx-small;
-  }
-  .pagination {
-    float: right;
-  }
-  </style>
-</head>
-<body>
-
-  <header>
-    <img class="logo" src="{{ branding.logoURL }}" />
-    <h1>Reçu de cotisation</h1>
-    <p>Le {{ bill.date }}</p>
-  </header>
-
-  <table id="coordonnees">
-    <tr>
-      <td id="coordonnees_isp">
-        <p>
-        {% multiline_isp_addr branding %}
-        </p>
-        <p>
-        <a href="mailto:{{ branding.email }}">{{ branding.email }}</a><br/>
-        <a href="{{ branding.website }}">{{ branding.website }}</a><br />
-        {{ branding.phone_number }}
-        </p>
-      </td>
-      <td id="coordonnees_client">
-        <p>
-        <strong>Pour :</strong><br/>
-        {% with member=bill.member %}
-        {{ member.last_name }} {{ member.first_name }}<br />
-        {% if member.organization_name != "" %}{{ member.organization_name }}<br />{% endif %}
-        {% if member.address %}{{member.address}}<br />{% endif %}
-        {% if member.postal_code and member.city %}
-        {{ member.postal_code }} {{ member.city }}
-        {% endif %}
-        {% endwith %}
-        </p>
-      </td>
-    </tr>
-  </table>
+{% extends "billing/bill_pdf.html" %}
 
+{% block content %}
   <br />
   <br />
   <br />
@@ -163,11 +8,4 @@
   <p style="font-size: 1.2em;">
   En date du {{ bill.date }}, l'association {{ branding.shortname|upper }} certifie avoir reçu et accepté une cotisation d'un montant de {{ bill.amount }}€ de la part de {{ bill.member.first_name }} {{ bill.member.last_name }}. Cette cotisation lui confère le statut de membre pour la période du {{ bill.start_date }} au {{ bill.end_date }}.
   </p>
-
-  <footer>
-    <img class="logo" src="{{ branding.logoURL }}" />
-    <p class="pagination"><pdf:pagenumber>/<pdf:pagecount></p>
-    <p>{{ branding.shortname|upper }}, association loi de 1901 à but non lucratif - SIRET : {{ branding.registeredoffice.siret }}</p>
-  </footer>
-</body>
-</html>
+{% endblock %}