summaryrefslogtreecommitdiff
path: root/app/income/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/income/views.py')
-rw-r--r--app/income/views.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/app/income/views.py b/app/income/views.py
index 2c3e34a..fc22c0d 100644
--- a/app/income/views.py
+++ b/app/income/views.py
@@ -20,8 +20,7 @@ class MonthlyInvoiceView(DetailView):
total_time = []
for item in context['object_list']:
total_time.append(item.rounded_total)
- duration = (sum(total_time, datetime.timedelta()))
- hours = duration.total_seconds() // 3600
+ hours = (sum(total_time))
context['total_hours'] = hours
context['total_billed'] = int(hours * 100)
context['invoice_number'] = self.object.id+21
@@ -37,10 +36,17 @@ class DownloadMonthlyInvoiceView(MonthlyInvoiceView):
logger = logging.getLogger('weasyprint')
logger.addHandler(logging.FileHandler('weasyprint.log'))
self.object = self.get_object() # assign the object to the view
- c = {'object': self.object}
+ context = self.get_context_data()
+ c = {
+ 'object': self.object,
+ 'object_list': context['object_list'],
+ 'total_hours': context['total_hours'],
+ 'total_billed': context['total_billed'],
+ 'invoice_number': self.object.id+23
+ }
t = render_to_string('details/invoice.html', c).encode('utf-8')
html = HTML(string=t, base_url=self.request.build_absolute_uri())
- pdf = html.write_pdf(stylesheets=[CSS(settings.MEDIA_ROOT + 'site/media/pdf_gen.css')], presentational_hints=True)
+ pdf = html.write_pdf(stylesheets=[CSS(settings.MEDIA_ROOT + '/pdf_gen.css')], presentational_hints=True)
response = HttpResponse(pdf, content_type='application/pdf')
response['Content-Disposition'] = 'inline; filename="invoice.pdf"'
return response