commit some more invoice stuff
This commit is contained in:
parent
d8a1ec132b
commit
6f61220363
|
@ -8,9 +8,9 @@ def send_email(emailtype, recipient, formatdict, subject, sender='BornHack <nore
|
|||
html_template=None
|
||||
|
||||
if emailtype == 'invoice':
|
||||
text_template = 'emails/invoice.txt'
|
||||
html_template = 'emails/invoice.html'
|
||||
attachment_filename = formatdict['attachmentname']
|
||||
text_template = 'emails/invoice_email.txt'
|
||||
html_template = 'emails/invoice_email.html'
|
||||
attachment_filename = formatdict['filename']
|
||||
elif emailtype == 'testmail':
|
||||
text_template = 'emails/testmail.txt'
|
||||
else:
|
||||
|
@ -25,7 +25,7 @@ def send_email(emailtype, recipient, formatdict, subject, sender='BornHack <nore
|
|||
if html_template:
|
||||
msg.attach_alternative(render_to_string(html_template, formatdict), 'text/html')
|
||||
|
||||
### is there an attachment to this mail?
|
||||
### is there a pdf attachment to this mail?
|
||||
if attachment:
|
||||
msg.attach(attachment_filename, attachment, 'application/pdf')
|
||||
|
||||
|
@ -43,16 +43,17 @@ def send_email(emailtype, recipient, formatdict, subject, sender='BornHack <nore
|
|||
def send_invoice_email(invoice, attachment):
|
||||
# put formatdict together
|
||||
formatdict = {
|
||||
'order': invoice.order,
|
||||
'attachmentname': invoice.filename,
|
||||
'ordernumber': invoice.order.pk,
|
||||
'invoicenumber': invoice.pk,
|
||||
'filename': invoice.filename,
|
||||
}
|
||||
|
||||
subject = 'BornHack invoice %s' % order.pk
|
||||
subject = 'BornHack invoice %s' % invoice.pk
|
||||
|
||||
# send mail
|
||||
return send_email(
|
||||
emailtype='invoice',
|
||||
recipient=order.user.email,
|
||||
recipient=invoice.order.user.email,
|
||||
formatdict=formatdict,
|
||||
subject=subject,
|
||||
sender='noreply@bornfiber.dk',
|
||||
|
|
|
@ -24,6 +24,7 @@ class Command(BaseCommand):
|
|||
formatdict = {
|
||||
'invoice': invoice,
|
||||
}
|
||||
|
||||
# generate the pdf
|
||||
try:
|
||||
pdffile = generate_pdf_letter(
|
||||
|
@ -35,6 +36,7 @@ class Command(BaseCommand):
|
|||
except Exception as E:
|
||||
self.stdout.write('ERROR: Unable to generate PDF file for invoice #%s. Error: %s' % (invoice.pk, E))
|
||||
continue
|
||||
|
||||
# so, do we have a pdf?
|
||||
if not pdffile:
|
||||
self.stdout.write('ERROR: Unable to generate PDF file for invoice #%s' % invoice.pk)
|
||||
|
@ -61,4 +63,3 @@ class Command(BaseCommand):
|
|||
### pause for a bit
|
||||
sleep(60)
|
||||
|
||||
|
||||
|
|
16
shop/templates/emails/invoice_email.html
Normal file
16
shop/templates/emails/invoice_email.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
Hello!<br>
|
||||
<br>
|
||||
This email contains the invoice for your purchase from BornHack.<br>
|
||||
Your order number is <b>{{ ordernumber }}</b> and your invoice number is <b>{{ invoicenumber }}</b>.<br>
|
||||
<br>
|
||||
Your order has been paid in full. The invoice is attached in PDF format with the filename <b>{{ filename }}</b>.<br>
|
||||
<br>
|
||||
Tickets will be generated closer to the event. Ticket holders will receive an email when tickets can be downloaded from the webshop. Merchandise can be picked up from the info booth during the event.<br>
|
||||
<br>
|
||||
Thank your for your purchase!<br>
|
||||
<br>
|
||||
<br>
|
||||
Best regards,<br>
|
||||
<br>
|
||||
The BornHack Team<br>
|
||||
<br>
|
19
shop/templates/emails/invoice_email.txt
Normal file
19
shop/templates/emails/invoice_email.txt
Normal file
|
@ -0,0 +1,19 @@
|
|||
Hello!
|
||||
|
||||
This email contains the invoice for your purchase from BornHack.
|
||||
Your order number is {{ ordernumber }} and your invoice number is {{ invoicenumber }}.
|
||||
|
||||
Your order has been paid in full. The invoice is attached in PDF
|
||||
format with the filename {{ filename }}.
|
||||
|
||||
Tickets will be generated closer to the event. Ticket
|
||||
holders will receive an email when tickets can be downloaded
|
||||
from the webshop. Merchandise can be picked up from the info
|
||||
booth during the event.
|
||||
|
||||
Thank your for your purchase!
|
||||
|
||||
|
||||
Best regards,
|
||||
|
||||
The BornHack Team
|
1
shop/templates/emails/testmail.txt
Normal file
1
shop/templates/emails/testmail.txt
Normal file
|
@ -0,0 +1 @@
|
|||
testmail from bornhack website
|
42
shop/templates/invoice.html
Normal file
42
shop/templates/invoice.html
Normal file
|
@ -0,0 +1,42 @@
|
|||
{% load shop_tags %}
|
||||
This is an invoice.
|
||||
|
||||
<table class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Name
|
||||
<th>
|
||||
Quantity
|
||||
<th>
|
||||
Price
|
||||
<th>
|
||||
Total
|
||||
<tbody>
|
||||
{% for order_product in invoice.order.orderproductrelation_set.all %}
|
||||
<tr>
|
||||
<td>
|
||||
{{ order_product.product.name }}
|
||||
<td>
|
||||
{{ order_product.quantity }}
|
||||
<td>
|
||||
{{ order_product.product.price|currency }}
|
||||
<td>
|
||||
{{ order_product.total|currency }}
|
||||
{% endfor %}
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<td>
|
||||
<strong>Hereof VAT (25%)</strong>
|
||||
<td>
|
||||
{{ order.vat|currency }}
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<td>
|
||||
<strong>Total</strong>
|
||||
<td>
|
||||
{{ order.total|currency }}
|
||||
|
||||
</table>
|
Loading…
Reference in a new issue