Add support for custom fields in billing invoices

Customers (especially in Europe) need the ability to add Tax IDs, VAT IDs, and other custom fields to their invoices.

Fixes #106
This commit is contained in:
Joseph Schorr 2015-06-12 12:32:41 -04:00
parent 683d5080d8
commit e7fa560787
9 changed files with 426 additions and 8 deletions

View file

@ -25,6 +25,8 @@ def renderInvoiceToPdf(invoice, user):
def renderInvoiceToHtml(invoice, user):
""" Renders a nice HTML display for the given invoice. """
from endpoints.api.billing import get_invoice_fields
def get_price(price):
if not price:
return '$0'
@ -44,7 +46,8 @@ def renderInvoiceToHtml(invoice, user):
'invoice': invoice,
'invoice_date': format_date(invoice.date),
'getPrice': get_price,
'getRange': get_range
'getRange': get_range,
'custom_fields': get_invoice_fields(user)[0],
}
template = env.get_template('invoice.tmpl')

View file

@ -19,6 +19,12 @@
<table>
<tr><td>Date:</td><td>{{ invoice_date }}</td></tr>
<tr><td>Invoice #:</td><td style="font-size: 10px">{{ invoice.id }}</td></tr>
{% for custom_field in custom_fields %}
<tr>
<td>*{{ custom_field['title'] }}:</td>
<td style="font-size: 10px">{{ custom_field['value'] }}</td>
</tr>
{% endfor %}
</table>
</td>
</tr>
@ -38,8 +44,8 @@
<td style="padding: 4px; min-width: 150px;">{{ getPrice(line.amount) }}</td>
</tr>
{%- endfor -%}
<tr>
<td></td>
<td valign="right">
@ -54,7 +60,7 @@
</tr>
</tbody>
</table>
<div style="margin: 6px; padding: 6px; width: 100%; max-width: 640px; border-top: 2px solid #eee; text-align: center; font-size: 14px; -webkit-text-adjust: none; font-weight: bold;">
We thank you for your continued business!
</div>