misc. invoice fixes

This commit is contained in:
Thomas Steen Rasmussen 2016-05-31 06:51:30 +02:00
parent f8ed60f8b6
commit ed79b8f73a
4 changed files with 18 additions and 18 deletions

View file

@ -6,6 +6,7 @@ from shop.pdf import generate_pdf_letter
from shop.email import send_invoice_email
from shop.models import Order, Invoice
from time import sleep
from decimal import Decimal
class Command(BaseCommand):

View file

@ -79,17 +79,17 @@ class Order(CreatedUpdatedModel):
@property
def vat(self):
return self.total*0.2
return Decimal(self.total*0.2)
@property
def total(self):
return self.products.aggregate(
return Decimal(self.products.aggregate(
sum=Sum(
models.F('orderproductrelation__product__price') *
models.F('orderproductrelation__quantity'),
output_field=models.IntegerField()
)
)['sum']
)['sum'])
def get_coinify_callback_url(self, request):
return 'https://' + request.get_host() + str(reverse_lazy('shop:coinify_callback', kwargs={'pk': self.pk}))

View file

@ -3,28 +3,26 @@
<table style="width:100%;">
<tr>
<td style="text-align: right">Order number: {{ ordernumber }}</td>
<td style="text-align: right">Order number: {{ invoice.order.pk }}</td>
</tr>
<tr>
<td style="text-align: right">Invoice number: {{ invoicenumber }}</td>
<td style="text-align: right">Invoice number: {{ invoice.pk }}</td>
</tr>
<tr>
<td style="text-align: right">Date: {% now "j/n-Y" %}</td>
</tr>
</table>
<table style="width:100%;">
<thead>
<table style="width:100%;" border=1>
<tr>
<th>
Name
<th>
Quantity
<th>
Price
<th>
Total
<tbody>
<td>
<b>Name
<td>
<b>Quantity
<td>
<b>Price
<td>
<b>Total
{% for order_product in invoice.order.orderproductrelation_set.all %}
<tr>
<td>
@ -40,7 +38,7 @@
<tr>
<td colspan="2">
<td>
<strong>Hereof VAT (25%)</strong>
<strong>Danish VAT (25%)</strong>
<td>
{{ order.vat|currency }}

View file

@ -1,5 +1,6 @@
from django import template
from django.utils.safestring import mark_safe
from decimal import Decimal
register = template.Library()
@ -7,7 +8,7 @@ register = template.Library()
@register.filter
def currency(value):
try:
return "{0:.2f} DKK".format(int(value))
return "{0:.2f} DKK".format(Decimal(value))
except ValueError:
return False