]> err.no Git - peojumk/commitdiff
Add support for dumping invoices as text
authorTollef Fog Heen <tfheen@err.no>
Sat, 9 Jun 2012 18:54:36 +0000 (20:54 +0200)
committerTollef Fog Heen <tfheen@err.no>
Sat, 9 Jun 2012 18:54:36 +0000 (20:54 +0200)
invoice/urls.py
invoice/views.py
templates/invoice/invoice_detail.txt [new file with mode: 0644]

index f667fbdf01a62b93f8342b606ac331ce3f1937ff..f4781a5aa350265f003aca0fb1e5855092d81dc9 100644 (file)
@@ -1,7 +1,7 @@
 from django.conf.urls import patterns, include, url
 import django.contrib.auth.views
 from invoice.views import UpdateClient, DeleteClient, CreateClient, DetailClient, \
-     CreateInvoice, DetailInvoice
+     CreateInvoice, DetailInvoice, invoice_text
 
 import invoice.views
 
@@ -15,4 +15,5 @@ urlpatterns = patterns('invoice.views',
                 url(r'^accounts/login/$', django.contrib.auth.views.login),
                 url(r'^invoice/new$', CreateInvoice.as_view(), name="invoice_new"),
                 url(r'^invoice/(?P<pk>\d+)$', DetailInvoice.as_view(), name='invoice_view'),
+                url(r'^invoice/(?P<pk>\d+)/text$', invoice_text, name='invoice_view'),
 )
index 1fdee68876e5fcb70a38b53dbfa6e7c85c51dc67..32f38c2fe48757d586ed92e6d71f762c9d4f0c26 100644 (file)
@@ -20,6 +20,12 @@ def index(request):
     sent_invoices = Invoice.objects.filter(status = 'S')
     return render_to_response('invoice/index.html', locals())
 
+@login_required
+def invoice_text(request, pk):
+    invoice = Invoice.objects.get(pk = pk)
+
+    return render_to_response('invoice/invoice_detail.txt', locals(), mimetype="text/plain")
+
 # ------------------- CLIENT ---------------
 
 class DetailClient(DetailView):
diff --git a/templates/invoice/invoice_detail.txt b/templates/invoice/invoice_detail.txt
new file mode 100644 (file)
index 0000000..5e36782
--- /dev/null
@@ -0,0 +1,34 @@
+INVOICE
+------------------------------------------------------------------------------
+err.no AS
+Disengrenda 5b
+0587 Oslo
+Norway
+
+Transfer to:
+Account number (IBAN) : NO5915032765650
+
+Branch Address:
+DNB ASA
+0021 Oslo
+Norway
+Phone: +47 73 58 21 01
+
+SWIFT Code: DNBANOKK / DNBANOKKXXX
+------------------------------------------------------------------------------
+Charge to:
+
+{{ invoice.customer.name }}
+{{ invoice.customer.address }}
+
+------------------------------------------------------------------------------
+Invoice # {{ invoice.id }}
+Date: {{ invoice.date|date:"Y-m-d"}}
+------------------------------------------------------------------------------
+Description                   Hours     Rate      Sum
+------------------------------------------------------------------------------
+{% for line in invoice.invoiceline_set.all %}{{ line.description|ljust:"30" }}{{ line.time|rjust:"5" }}    {{ line.hourly_rate|rjust:"5" }}{{ line.amount|rjust:"9" }}{% endfor %}
+
+{{ invoice.comment }}
+------------------------------------------------------------------------------
+Total: {{ invoice.currency }} {{ invoice.total_sum }}