Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Made invoice similar to Eventbrite #5952

Merged
merged 2 commits into from
Jun 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/api/helpers/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from app.models import db
from app.models.ticket import Ticket
from app.models.ticket_holder import TicketHolder
from app.models.order import OrderTicket


def delete_related_attendees_for_order(order):
Expand Down Expand Up @@ -70,7 +71,9 @@ def create_pdf_tickets_for_holder(order):
save_to_db(holder)

# create order invoices pdf
create_save_pdf(render_template('pdf/order_invoice.html', order=order, event=order.event),
order_ticket_info = OrderTicket.query.filter_by(order_id=order.id).one()
create_save_pdf(render_template('pdf/order_invoice.html', order=order, event=order.event,
tax=order.event.tax, tickets=order.tickets, order_tickets_info=order_ticket_info),
UPLOAD_PATHS['pdf']['order'], dir_path='/static/uploads/pdf/tickets/',
identifier=order.identifier, upload_dir='generated/invoices/')
save_to_db(order)
Expand Down
318 changes: 203 additions & 115 deletions app/templates/pdf/order_invoice.html
Original file line number Diff line number Diff line change
@@ -1,126 +1,214 @@
<!DOCTYPE html>
<html lang="en">
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title> {{ ("Order Invoice") }}</title>
<style type="text/css">
<meta charset="utf-8">
<title>{{ order.identifier }}</title>
<style>
{% include 'bootstrap/bootstrap_pdf.css' %}
table th {
text-align: left;
.invoice-box {
max-width: 800px;
margin: auto;
padding: 30px;
border: 1px solid #eee;
box-shadow: 0 0 10px rgba(0, 0, 0, .15);
font-size: 16px;
line-height: 24px;
font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;
color: #555;
}

.invoice-box table {
width: 100%;
line-height: inherit;
text-align: left;
}

.invoice-box table td {
padding: 5px;
vertical-align: top;
}

.invoice-box table tr td:nth-child(2) {
text-align: right;
}

.invoice-box table tr.top table td {
padding-bottom: 20px;
}

.invoice-box table tr.top table td.title {
font-size: 45px;
line-height: 45px;
color: #333;
}

.invoice-box table tr.information table td {
padding-bottom: 40px;
}

.invoice-box table tr.heading td {
background: #eee;
border-bottom: 1px solid #ddd;
font-weight: bold;
}

.invoice-box table tr.details td {
padding-bottom: 20px;
}

.invoice-box table tr.item td{
border-bottom: 1px solid #eee;
}

.invoice-box table tr.item.last td {
border-bottom: none;
}

.invoice-box table tr.total td:nth-child(2) {
border-top: 2px solid #eee;
font-weight: bold;
}

@media only screen and (max-width: 600px) {
.invoice-box table tr.top table td {
width: 100%;
display: block;
text-align: center;
}

table td {
text-align: left;
border-spacing: 1em;

.invoice-box table tr.information table td {
width: 100%;
display: block;
text-align: center;
}
}
</style>
</head>

table {
margin-top: 20px;
border-collapse: separate;
}
<body>
<h3 style="text-align:center;">{{ ("Order Invoice") }}</h3>
<table class="table with-datatable" id="orders-table" width="100%">
<tbody>
{% if order.status != "deleted" %}
<tr class="padded">
<td><br>
Order Number :<br>
Order By :<br>
Order Status :<br>
Quantity :<br>
Total Amount :<br>
Payment Mode :<br>
Discount Code :<br>
</td>

.total-row {
margin-top: 25px;
}
<hr>

.order-total {
margin-right: 50px;
}
<td><br>
<strong>{{ order.get_invoice_number() }}</strong><br>
{% if order.user and order.user.first_name and order.user.last_name %}
{{ order.user.fullname }}
{% elif order.user %}
{{ order.user.email }}
{% else %}
{{ ('Information unavailable') }}
{% endif %}<br>
{% if order.status == 'completed' %}
{{ order.status | capitalize }}
{% elif order.status == 'pending' or order.status == 'initialized' %}
{{ ("Pending") }}
{% elif order.status == 'placed' %}
{{ order.status | capitalize }}
{% elif order.status == 'cancelled' %}
{{ order.status | capitalize }}
{% else %}
{{ order.status | capitalize }}
{% endif %}<br>
{{ order.tickets_count }}<br>
{{ event.payment_currency | currency_symbol }}{{ order.amount | money }}<br>
{% if order.status == 'completed' %}
{{ order.paid_via | capitalize }}
{% else %}
{{ ('Payment pending') }}
{% endif %}<br>
{% if order.discount_code %}
{{ order.discount_code.code }}<br>
{% else %}
{{ ('NA') }}
{% endif %}<br>
</td>
{% if order.is_billing_enabled %}
<td style="text-align:center;"><br>
<strong>
Company :<br>
Tax Info :<br>
Address :<br>
City :<br>
State/Province :<br>
Zip Code: <br>
Country: <br>
</strong>
</td>
<td><br>
<strong>
{{ order.company }}<br>
{{ order.tax_business_info }}<br>
{{ order.address }}<br>
{{ order.city }}<br>
{{ order.state }}<br>
{{ order.zipcode }}<br>
{{ order.country }}<br>
</strong>
</td>
{% endif %}
</tr>
{% endif %}
</tbody>

</table><br>

tr.padded td{
padding-top : 40px;
}
</style>
</head>
<body id="body">
<h3 style="text-align:center;">{{ ("Order Invoice") }}</h3>
<br>
<table class="table with-datatable" id="orders-table" width="100%">
<thead>
<tr>
<th>
{{ ("Order") }}
</th>
<th>
{{ ("Order Details") }}
</th>
<th>
{{ ("Billing Info") }}
</th>
</tr>
</thead>
<tbody>
{% if order.status != "deleted" %}
<tr class="padded">
<td><br>
Order Number :<br>
Order By :<br>
Order Status :<br>
Quantity :<br>
Total Amount :<br>
Payment Mode :<br>
Discount Code :<br>
</td>
<td><br>
<strong>{{ order.get_invoice_number() }}</strong><br>
{% if order.user and order.user.first_name and order.user.last_name %}
{{ order.user.fullname }}
{% elif order.user %}
{{ order.user.email }}
{% else %}
{{ ('Information unavailable') }}
{% endif %}<br>
{% if order.status == 'completed' %}
{{ order.status | capitalize }}
{% elif order.status == 'pending' or order.status == 'initialized' %}
{{ ("Pending") }}
{% elif order.status == 'placed' %}
{{ order.status | capitalize }}
{% elif order.status == 'cancelled' %}
{{ order.status | capitalize }}
{% else %}
{{ order.status | capitalize }}
{% endif %}<br>
{{ order.tickets_count }}<br>
{{ event.payment_currency | currency_symbol }}{{ order.amount | money }}<br>
{% if order.status == 'completed' %}
{{ order.paid_via | capitalize }}
<hr noshade>

<table class="table">
<thead class="black white-text">
<tr>
<th scope="col">Name</th>
<th scope="col">Price</th>
<th scope="col">Quantity</th>
<th scope="col">Sub-Total(net)</th>
<th scope="col">VAT</th>
<th scope="col">Tax Amount</th>
</tr>
</thead>
<tbody>
{% for ticket in tickets %}
<tr>
<td style="text-align:center">{{ ticket.name }}</td>
<td style="text-align:center">{{ event.payment_currency | currency_symbol }}{{ ticket.price }}</td>
<td style="text-align:center">{{ order_tickets_info.quantity }}</td>
<td style="text-align:center">{{ event.payment_currency | currency_symbol }}{{ order_tickets_info.quantity*ticket.price }}</td>
{% if tax %}
<td style="text-align:center">{{ tax.rate }}%</td>
{% else %}
{{ ('Payment pending') }}
{% endif %}<br>
{% if order.discount_code %}
{{ order.discount_code.code }}<br>
<td style="text-align:center">{{ ("0%") }}</td>
{% endif %}
{% if tax %}
<td style="text-align:center">{{ event.payment_currency | currency_symbol }}{{ tax.rate*ticket.price/100 }}</td>
{% else %}
{{ ('NA') }}
{% endif %}<br>
</td>
{% if order.is_billing_enabled %}
<td style="text-align:center;"><br>
<strong>
Company :<br>
Tax Info :<br>
Address :<br>
City :<br>
State/Province :<br>
Zip Code: <br>
Country: <br>
</strong>
</td>
<td><br>
<strong>
{{ order.company }}<br>
{{ order.tax_business_info }}<br>
{{ order.address }}<br>
{{ order.city }}<br>
{{ order.state }}<br>
{{ order.zipcode }}<br>
{{ order.country }}<br>
</strong>
</td>
{% endif %}
</tr>
{% endif %}
</tbody>
</table>
<td style="text-align:center">{{ event.payment_currency | currency_symbol }}0</td>
{% endif %}
</tr>
{% endfor %}
<tr>
<th scope="row"></th>
<td></td>
<td></td>
<td></td>
<td><b>Grand Total</b></td>
<td> {{ event.payment_currency | currency_symbol }}{{ order.amount | money }}</td>
</tr>
</tbody>
</table>
</table>
</div>
</body>
</html>
</html>