Repository: fossasia/open-event-server

Issue:
Fix Invoice for Ticket Buyers
The ticket invoice for ticket buyers has a number of issues. Please resolve the list below:

* Fix "Post codes" - They do not show zeros at the beginning. If the postcode starts with a leading zero, e.g. 09853 show the leading zero.
* On the **top left** show the data of the ticket buyer
   * delete the number, amount, and discount code
   * Show Organisation [Company/Org of buyer]
   * Name [of buyer]
   * Address [of buyer]
   * Email [of buyer]
   * Tax ID [of buyer]
   * Invoice Date
   * Due Date: Upon Receipt
   * Payment mode. It currently always shows "None". It should show "Paypal, Credit Card, Cash, Purchase on Invoice etc."
   * Payment status: e.g. Order placed, Completed etc.
* On the **top right** of the invoice show the data and contact of organizers (it currently shows the data of ticket buyers)
   * Organisation [Company/Org of Organizer]
   * Name [of Organizer]
   * Address [of Organizer]
   * Phone [of Organizer]
   * Email [of Organizer]
   * Tax ID [of Organizer]
* **On table** 
   * Change "Name" to "Description"
   * Add date of event behind name of the event in the first column
   * Add discount code if any was used  in the first column
   * Move the column "subtotal" to the very right
   * Improve the tax display
      * Unify "VAT" and "Tax Amount" into a column "Tax" 
      * Display if tax is included or added on top of the rate before the tax info
      * Show the number with the percentage in brackets below
      * It should look like e.g. incl. `EUR 150.40 (19%)` or plus `USD 150.40 (6.5%)` Only show something behind the dot of percentages if it is not zero
   * Total: Show Subtotal, Tax and Total in the same way as it is shown on the organizer invoice
![Screenshot from 2021-09-03 18-18-30](https://user-images.githubusercontent.com/1583873/132037568-e1df6b9f-954c-4bb8-82fe-0054ec65445b.png)

* **Other**
   * Payments miss a space between currency and the number and they miss to show two digits after the dot, e.g. it should be EUR 12.50 instead of EUR12.50

* **Translations**: Ensure all text is translatable
![KIX Pro 18 Basis Administration-Invoice-a6faa42f-edcb-48b9-84f5-937ede0415dc](https://user-images.githubusercontent.com/1583873/132012994-b69112a6-9129-4632-a136-4115c6024d0b.png)


![rechnungcorrect](https://user-images.githubusercontent.com/1583873/126496655-e69c5b3c-890a-4a6a-9d82-2a7d0aeae833.jpg)



Discussion:

Resolving patch:
diff --git a/app/api/helpers/order.py b/app/api/helpers/order.py
--- a/app/api/helpers/order.py
+++ b/app/api/helpers/order.py
@@ -3,6 +3,7 @@
 
 from flask import render_template
 from flask_rest_jsonapi.exceptions import ObjectNotFound
+from sqlalchemy.orm import joinedload
 
 from app.api.helpers.db import (
     get_count,
@@ -106,6 +107,8 @@ def create_pdf_tickets_for_holder(order):
         # create order invoices pdf
         order_tickets = OrderTicket.query.filter_by(order_id=order.id).all()
 
+        attendee = TicketHolder.query.filter_by(order_id=order.id).first()
+
         create_save_pdf(
             render_template(
                 'pdf/order_invoice.html',
@@ -113,6 +116,9 @@ def create_pdf_tickets_for_holder(order):
                 event=order.event,
                 tax=order.event.tax,
                 order_tickets=order_tickets,
+                attendee=attendee,
+                event_starts_at=order.event.starts_at_tz.strftime('%d-%m-%Y'),
+                created_at=order.created_at.strftime('%d-%m-%Y'),
                 admin_info=admin_info,
             ),
             UPLOAD_PATHS['pdf']['order'],


Test patch: