From 662e706eabe0d6798eb9ad75e364e4777390ebc9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 21 Jun 2020 23:54:57 +0200 Subject: [PATCH] begin to fix bill view --- uncloud_pay/admin.py | 4 +++- uncloud_pay/templates/bill.html.j2 | 14 +++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/uncloud_pay/admin.py b/uncloud_pay/admin.py index 74b1e2e..190550e 100644 --- a/uncloud_pay/admin.py +++ b/uncloud_pay/admin.py @@ -47,7 +47,9 @@ class BillAdmin(admin.ModelAdmin): raise self._get_404_exception(object_id) output_file = NamedTemporaryFile() - bill_html = render_to_string("bill.html.j2", {'bill': bill}) + bill_html = render_to_string("bill.html.j2", {'bill': bill, + 'bill_records': bill.bill_records.all() + }) bytestring_to_pdf(bill_html.encode('utf-8'), output_file) response = FileResponse(output_file, content_type="application/pdf") diff --git a/uncloud_pay/templates/bill.html.j2 b/uncloud_pay/templates/bill.html.j2 index f8ed28b..4f186c2 100644 --- a/uncloud_pay/templates/bill.html.j2 +++ b/uncloud_pay/templates/bill.html.j2 @@ -717,19 +717,11 @@ oAsAAAAAAACGQNAFAAAAAAAAQyDoAgAAAAAAgCEQdAEAAAAAAMAQCLoAAAAAAABgCP83AL6WQ1Y7 - {% for record in bill.records %} + {% for record in bill_records %} - {{ record.description }} - - {{ record.recurring_price }} * {{ record.recurring_count }} - {{ record.recurring_period }} - {% if record.one_time_price != 0 %} - + one time {{ record.one_time_price }} - {% endif %} + A + {{ record.quantity }} - {{ record.amount }} - {{ record.vat_amount }} ({{ record.vat_rate }}) - {{ record.total }} {% endfor %}