Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
NyanKiyoshi committed Feb 20, 2018
2 parents cbeebdd + d1b3487 commit acb4370
Show file tree
Hide file tree
Showing 15 changed files with 570 additions and 165 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
source =
invoice_generator
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: python
cache: pip
sudo: false
python:
- "3.6"
- "3.5"
- "nightly"
- "pypy3"
install:
- pip install codecov coverage
matrix:
allow_failures:
- python: "nightly"
- python: "pypy3"
script:
- pip3 install -e ".[testing]"
- coverage run -m unittest discover -s tests
after_success:
- codecov
2 changes: 1 addition & 1 deletion invoice_generator/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Invoice(object):

def __init__(self, order_data: Order,
vendor: Vendor, billing_address: Address,
*items: OrderItem):
items: OrderItem):
self.order = order_data
self.vendor = vendor
self.billing_address = billing_address
Expand Down
325 changes: 163 additions & 162 deletions invoice_generator/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,179 +1,180 @@
{% load i18n %}

<html>
<head>
<link rel="stylesheet" href="style.css">
<style>
@page {
margin: 5cm 2cm 5cm 2cm;
<head>
<title>
{% blocktrans with order_id=order.order_id %}Invoice {{ order_id}}{% endblocktrans %}
</title>
<link rel="stylesheet" href="style.css">
<style>
@page {
margin: 5cm 2cm 5cm 2cm;

@top-right {
content: url("logo-document.svg");
}
@top-right {
content: url("logo-document.svg");
}

@bottom-left {
white-space: pre;
text-align: left;
font-size: 8pt;
content: "{{ vendor.address.name }}" "\a"
"{{ vendor.address.street }}" "\a"
"{{ vendor.address.postcode }} {{ vendor.address.city }}" "\a"
"{% trans "VAT Number:" %} {{ vendor.vat_number }}" "\a"
"\a" "\a"
}
@bottom-left {
white-space: pre;
text-align: left;
font-size: 8pt;
content: "{{ vendor.address.name }}" "\a"
"{{ vendor.address.street }}" "\a"
"{{ vendor.address.postcode }} {{ vendor.address.city }}" "\a"
"{% trans "VAT Number:" %} {{ vendor.vat_number }}" "\a"
"\a" "\a"
}

@bottom-center {
white-space: pre;
text-align: center;
font-size: 8pt;
content: {% for text in vendor.additional_text %} "{{ text }}" "\a"{% endfor %}
{{ vendor.additional_text_suffix|safe }}
{% blocktrans %}"Page " counter(page) " of " counter(pages){% endblocktrans %}
}
@bottom-center {
white-space: pre;
text-align: center;
font-size: 8pt;
content: {% for text in vendor.additional_text %} "{{ text }}" "\a"{% endfor %}
{{ vendor.additional_text_suffix|safe }}
{% blocktrans %}"Page " counter(page) " of " counter(pages){% endblocktrans %}
}

@bottom-right {
white-space: pre;
text-align: left;
font-size: 8pt;
content: "{% trans "Management Board" %}" "\a"
"{{ executive.name }}" "\a"
"{{ executive.text }}" "\a"
"\a\a\a"
}
}
</style>
</head>
<body>
<div>
<table class="adressTable">
<tr>
<td class="small">
{{ vendor.address.name }},
{{ vendor.address.street }},
{{ vendor.address.postcode }} {{ vendor.address.city }}
</td>
</tr>
@bottom-right {
white-space: pre;
text-align: left;
font-size: 8pt;
content: "{% trans "Management Board" %}" "\a"
"{{ executive.name }}" "\a"
"{{ executive.text }}" "\a"
"\a\a\a"
}
}
</style>
</head>
<body>
<div>
<table class="addressTable">
<tr>
<td class="small">
{{ vendor.address.name }},
{{ vendor.address.street }},
{{ vendor.address.postcode }} {{ vendor.address.city }}
</td>
</tr>

<tr>
<td>{{ billing_address.name }}</td>
</tr>
<tr>
<td>{{ billing_address.name }}</td>
</tr>

<tr>
<td>{{ billing_address.street }}</td>
</tr>
<tr>
<td>{{ billing_address.street }}</td>
</tr>

<tr>
<td>
{{ billing_address.postcode }}
{{ billing_address.city }}
</td>
</tr>
</table>
</div>
<tr>
<td>
{{ billing_address.postcode }}
{{ billing_address.city }}
</td>
</tr>
</table>
</div>

<div class="section">
<table class="infoTable">
<tr>
<td>
<strong>
{% blocktrans with order_id=order.order_id %}Order ID: {{ order_id }}{% endblocktrans %}
</strong>
</td>
<div class="section">
<table class="infoTable">
<tr>
<td class="bold">
{% blocktrans with order_id=order.order_id %}Order ID: {{ order_id }}{% endblocktrans %}
</td>

<td>
{% blocktrans with customer_id=order.customer_id %}Customer ID: {{ customer_id }}{% endblocktrans %}
</td>
</tr>
<tr>
{% if order.shipping_date_range %}
<td class="small">{% blocktrans %}The order will be shipped upon receipt of payment.{% endblocktrans %}</td>
{% endif %}
<td>
{% blocktrans with date=order.date|date %}Date of Invoice: {{ date }}{% endblocktrans %}
</td>
</tr>
</table>
</div>
<td>
{% blocktrans with customer_id=order.customer_id %}Customer ID: {{ customer_id }}{% endblocktrans %}
</td>
</tr>
<tr>
{% if order.shipping_date_range %}
<td class="small">{% blocktrans %}The order will be shipped upon receipt of payment.{% endblocktrans %}</td>
{% endif %}
<td>
{% blocktrans with date=order.date|date %}Date of Invoice: {{ date }}{% endblocktrans %}
</td>
</tr>
</table>
</div>

<div class="section">
<table class="invoiceTable">
<thead>
<tr>
<td>{% blocktrans %}REF{% endblocktrans %}</td>
<td>{% blocktrans %}Description{% endblocktrans %}</td>
<td>{% blocktrans %}Quantity{% endblocktrans %}</td>
<td>{% blocktrans %}Price per Unit{% endblocktrans %}</td>
<td>{% blocktrans %}Tax Rate{% endblocktrans %}</td>
<td>{% blocktrans %}Net Price{% endblocktrans %}</td>
</tr>
</thead>
<tbody>
{% for item in invoice.items %}
<tr>
<td class="text-center">{{ item.reference }}</td>
<td>{{ item.text|safe }}</td>
<td class="nowrap text-center">{{ item.quantity }}</td>
<td class="nowrap text-center">{{ item.net_price|floatformat:2 }} {{ currency }}</td>
<td class="nowrap text-center">{{ item.tax_rate }} %</td>
<td class="nowrap text-center">{{ item.total_net|floatformat:2 }} {{ currency }}</td>
</tr>
{% endfor %}
<tr class="tfoot">
<td class="padrow"></td>
</tr>
{% if order.total_discounted %}
<tr class="tfoot">
<td class="noborder"></td>
<td class="noborder"></td>
<td colspan="3"> {% blocktrans %}Total discounted{% endblocktrans %}</td>
<td class="nowrap" colspan="2">{{ order.total_discounted|floatformat:2 }} {{ currency }}</td>
</tr>
{% endif %}
{% if order.total_shipping_net %}
<tr class="tfoot">
<td class="noborder"></td>
<td class="noborder"></td>
<td colspan="3"> {% blocktrans %}Shipping{% endblocktrans %}</td>
<td class="nowrap" colspan="2">{{ order.total_shipping_net|floatformat:2 }} {{ currency }}</td>
</tr>
{% endif %}
<tr class="tfoot">
<td class="noborder"></td>
<td class="noborder"></td>
<td colspan="3"> {% blocktrans %}Net total{% endblocktrans %}</td>
<td class="nowrap" colspan="2">{{ order.total_net|floatformat:2 }} {{ currency }}</td>
</tr>
<tr class="tfoot">
<td class="noborder"></td>
<td class="noborder"></td>
<td colspan="3">{% blocktrans with tax=order.tax_rate %}VAT ({{ tax }}%){% endblocktrans %}</td>
<td class="nowrap" colspan="2">{{ order.total_tax|floatformat:2 }} {{ currency }}</td>
</tr>
<tr class="tfoot gross-total">
<td class="noborder"></td>
<td class="noborder"></td>
<td colspan="3"> {% blocktrans %}Gross total{% endblocktrans %}</td>
<td class="nowrap" colspan="2">{{ order.total_gross|floatformat:2 }} {{ currency }}</td>
</tr>
</tbody>
</table>
</div>
<div class="section">
<p>{% blocktrans %}Thank you for your order.{% endblocktrans %}</p>
<div class="section">
<table class="invoiceTable">
<thead>
<tr>
<td>{% blocktrans %}REF{% endblocktrans %}</td>
<td>{% blocktrans %}Description{% endblocktrans %}</td>
<td>{% blocktrans %}Quantity{% endblocktrans %}</td>
<td>{% blocktrans %}Price per Unit{% endblocktrans %}</td>
<td>{% blocktrans %}Tax Rate{% endblocktrans %}</td>
<td>{% blocktrans %}Net Price{% endblocktrans %}</td>
</tr>
</thead>
<tbody>
{% for item in invoice.items %}
<tr>
<td class="text-center">{{ item.reference }}</td>
<td>{{ item.text|safe }}</td>
<td class="nowrap text-center">{{ item.quantity }}</td>
<td class="nowrap text-center">{{ item.net_price|floatformat:2 }} {{ currency }}</td>
<td class="nowrap text-center">{{ item.tax_rate }} %</td>
<td class="nowrap text-center">{{ item.total_net|floatformat:2 }} {{ currency }}</td>
</tr>
{% endfor %}
<tr class="tfoot">
<td class="padrow"></td>
</tr>
{% if order.total_discounted %}
<tr class="tfoot">
<td class="noborder"></td>
<td class="noborder"></td>
<td colspan="3"> {% blocktrans %}Total discounted{% endblocktrans %}</td>
<td class="nowrap" colspan="2">{{ order.total_discounted|floatformat:2 }} {{ currency }}</td>
</tr>
{% endif %}
{% if order.total_shipping_net %}
<tr class="tfoot">
<td class="noborder"></td>
<td class="noborder"></td>
<td colspan="3"> {% blocktrans %}Shipping{% endblocktrans %}</td>
<td class="nowrap" colspan="2">{{ order.total_shipping_net|floatformat:2 }} {{ currency }}</td>
</tr>
{% endif %}
<tr class="tfoot">
<td class="noborder"></td>
<td class="noborder"></td>
<td colspan="3"> {% blocktrans %}Net total{% endblocktrans %}</td>
<td class="nowrap" colspan="2">{{ order.total_net|floatformat:2 }} {{ currency }}</td>
</tr>
<tr class="tfoot">
<td class="noborder"></td>
<td class="noborder"></td>
<td colspan="3">{% blocktrans with tax=order.tax_rate %}VAT ({{ tax }}%){% endblocktrans %}</td>
<td class="nowrap" colspan="2">{{ order.total_tax|floatformat:2 }} {{ currency }}</td>
</tr>
<tr class="tfoot gross-total bold">
<td class="noborder"></td>
<td class="noborder"></td>
<td colspan="3"> {% blocktrans %}Gross total{% endblocktrans %}</td>
<td class="nowrap" colspan="2">{{ order.total_gross|floatformat:2 }} {{ currency }}</td>
</tr>
</tbody>
</table>
</div>

<div class="section">
<p>{% blocktrans %}Thank you for your order.{% endblocktrans %}</p>

{% if order.pay_until_date %}
<p>{% blocktrans with date=order.pay_until_date|date %}Please settle the payment by {{ date }}{% endblocktrans %}.</p>
{% endif %}
{% if order.pay_until_date %}
<p>{% blocktrans with date=order.pay_until_date|date %}Please settle the payment by {{ date }}{% endblocktrans %}.</p>
{% endif %}

{% if order.shipping_date_range %}
<p>
{% blocktrans with from=order.shipping_from|date to=order.shipping_to|date %}
Order will be delivered between {{ from }} and {{ to }}.
{% endblocktrans %}
</p>
{% endif %}
</div>
{% if order.shipping_date_range %}
<p>
{% blocktrans with from=order.shipping_from|date to=order.shipping_to|date %}
Order will be delivered between {{ from }} and {{ to }}.
{% endblocktrans %}
</p>
{% endif %}
</div>

</body>
</body>
</html>
4 changes: 2 additions & 2 deletions invoice_generator/templates/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ html {
white-space: nowrap;
}

.gross-total {
.bold {
font-weight: bold;
}

/**
* Address table
*/
.adressTable tr:nth-child(1) td {
.addressTable tr:nth-child(1) td {
border-bottom: 1px solid black;
}

Expand Down
Loading

0 comments on commit acb4370

Please sign in to comment.