diff --git a/boxoffice/templates/cash_receipt.html.jinja2 b/boxoffice/templates/cash_receipt.html.jinja2 deleted file mode 100644 index 464c7cfc..00000000 --- a/boxoffice/templates/cash_receipt.html.jinja2 +++ /dev/null @@ -1,310 +0,0 @@ - - - - - - - - {% trans %}Receipt{% endtrans %} - - - - - -
-

{% trans %}Cash Receipt{% endtrans %}

- -
- {%- if org.details.get('logo') %} - - {%- endif %} - -
- {%- if org.details.get('address') %} - {{ org.details.get('address')|safe }} - {%- endif %} - {%- if org.details.get('cin') %} -

{% trans %}CIN:{% endtrans %} {{ org.details.get('cin') }}

- {%- elif org.details.get('llpin') %} -

{% trans %}LLPIN:{% endtrans %} {{ org.details.get('llpin') }}

- {%- endif %} - {%- if org.details.get('pan') %} -

{% trans %}PAN:{% endtrans %} {{ org.details.get('pan') }}

- {%- endif %} - {%- if org.details.get('service_tax_no') %} -

{% trans %}Service Tax No:{% endtrans %} {{ org.details.get('service_tax_no') }}

- {%- endif %} - {%- if org.details.get('website') %} -

{{ org.details.get('website') }}

- {%- endif %} -

{{ org.contact_email }}

-
-
- -
- - - - - - - - - - - - - - - - -
{% trans %}Bill To{% endtrans %}
{% trans %}Name{% endtrans %}{{ order.buyer_fullname }}
{% trans %}Email{% endtrans %}{{ order.buyer_email }}
{% trans %}Phone{% endtrans %}{{ order.buyer_phone }}
- - - - - - - - - - -
{% trans %}Receipt#{% endtrans %}{{ order.receipt_no }}
{% trans %}Date{% endtrans %}{{ order.paid_at | longdate }}
-
- - - - - - - - - - {% for line_item in line_items -%} - - - - - - - - - - {%- endfor %} - - - - - - {% if order.refunded_amount > 0 %} - - - - - - {% endif %} -
{% trans %}Ticket No.{% endtrans %}{% trans %}Base Price{% endtrans %}{% trans %}Discount{% endtrans %}{% trans %}Final Price{% endtrans %}
{{ line_item.line_item_seq }} - {{ line_item.ticket.title }}
- {{ line_item.ticket.description }} -
-

{{ currency_symbol }} {{ line_item.base_amount }}

-
-

{{ currency_symbol }} {{ line_item.discounted_amount }}

- {% if line_item.discount_policy %} -

{{ line_item.discount_policy.title }}

- {% endif %} -
-

{{ currency_symbol }} {{ line_item.final_amount }}

-
{% trans %}Total paid{% endtrans %}
{{ currency_symbol }} {{ order.paid_amount }}
{% trans %}Net paid (post refund){% endtrans %}
{{ currency_symbol }} {{ order.net_amount }}
- - {%- if order.refunded_amount %} -

{% trans %}Refunds{% endtrans %}

- - - - - - - - - {% for transaction in order.refund_transactions -%} - - - - - {%- if transaction.refund_description %} - - {%- elif transaction.refunded_at %} - - {%- else %} - - {%- endif %} - - - {%- endfor %} - - - - - -
{% trans %}No.{% endtrans %}{% trans %}Receipt#{% endtrans %}{% trans %}Refund date{% endtrans %}{% trans %}Refund reason{% endtrans %}{% trans %}Amount{% endtrans %}
{{ loop.index }}{{ order.receipt_no }} - {% if transaction.refunded_at %} - {{ transaction.refunded_at | longdate }} - {%- endif %} - {{ transaction.refund_description }}{% trans date=transaction.refunded_at|longdate %}Refunded on {{ date }}{% endtrans %}{% trans %}Refund{% endtrans %}
{{ currency_symbol }} {{ transaction.amount }}
{% trans %}Total refund{% endtrans %}{{ currency_symbol }} {{ order.refunded_amount }}
- {%- endif %} - -
-
{{ org.details.get('refund_policy', '')|safe }}
-
- -
- - - diff --git a/boxoffice/templates/layout_email.html.jinja2 b/boxoffice/templates/layout_email.html.jinja2 new file mode 100644 index 00000000..7f2fb52c --- /dev/null +++ b/boxoffice/templates/layout_email.html.jinja2 @@ -0,0 +1,643 @@ + + + + {# utf-8 works for most cases #} + + + + {# What it does: Makes background images in 72ppi Outlook render at correct size. #} + + + {# Outlook / @font-face : BEGIN #} + + {# Desktop Outlook chokes on web font references and defaults to Times New Roman, so we force a safe fallback font. #} + + + {# Outlook / @font-face : END #} + + {% block stylesheet -%} + {# CSS Reset : BEGIN #} + + {# CSS Reset : END #} + + {# Progressive Enhancements : BEGIN #} + + {# Progressive Enhancements : END #} + {%- endblock stylesheet %} + + {# Element styles : BEGIN #} + + + + + + {# + The email background color (#f0f0f0) is defined in three places: + 1. body tag: for most email clients + 2. center tag: for Gmail and Inbox mobile apps and web versions of Gmail, GSuite, Inbox, Yahoo, AOL, Libero, Comcast, freenet, Mail.ru, Orange.fr + 3. mso conditional: For Windows 10 Mail + #} + + {%- block jsonld %}{%- if jsonld %} + + {%- endif %}{%- endblock jsonld %} + +
+ + + {# + Set the email width. Defined in two places: + 1. max-width for all clients except Desktop Windows Outlook, allowing the email to squish on narrow but never go wider than 600px. + 2. MSO tags for Desktop Windows Outlook enforce a 600px width. + #} +
+ + + {# Email Header : BEGIN #} + + + + +
+ +
+ {# Email Header : END #} + + {# Email Header : BODY #} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+ {# Email Footer : BEGIN #} + {% block footer %} + + + + {% endblock footer %}
+ {# Email Footer : END #} + +
+ + diff --git a/boxoffice/templates/macros_email.html.jinja2 b/boxoffice/templates/macros_email.html.jinja2 new file mode 100644 index 00000000..636260f4 --- /dev/null +++ b/boxoffice/templates/macros_email.html.jinja2 @@ -0,0 +1,29 @@ +{% macro cta_button(btn_url, btn_text, btn_style) %} +
+ + + + + + +
+ +
+ +
+{% endmacro %} + +{% macro line_break(ln_break) %} + + +
+ + +{% endmacro %} diff --git a/boxoffice/templates/payment_receipt.html.jinja2 b/boxoffice/templates/payment_receipt.html.jinja2 new file mode 100644 index 00000000..ea51b115 --- /dev/null +++ b/boxoffice/templates/payment_receipt.html.jinja2 @@ -0,0 +1,387 @@ +{%- extends "layout_email.html.jinja2" -%} +{%- from "macros_email.html.jinja2" import cta_button, line_break -%} +{%- block content -%} + + +

+ {%- trans %}Payment Receipt{% endtrans -%} +

+ + + + +
+ + + + +

+ {%- trans %}Receipt no. {% endtrans -%} + {{ order.receipt_no }} +

+ + + + {{ line_break(gettext('double_linebreak')) }} + + + +

{{ org.details.get('name') }}

+ + + + + +
+ + {{ line_break(gettext('linebreak')) }} + {%- if org.details %} + + + + {{ line_break(gettext('linebreak')) }} + + + + {%- endif %} +
+

+ {%- trans %}Address{% endtrans -%} +

+

{{ org.details.get('address')|safe }}

+

+

+ {%- trans %}PAN{% endtrans -%} +

+

{{ org.details.get('pan') }}

+
+
+ +
+ + {%- if org.details %} + {{ line_break(gettext('linebreak')) }} + + + + {%- endif %} + {{ line_break(gettext('linebreak')) }} + + + +
+

+ {%- trans %}CIN{% endtrans -%} +

+

{{ org.details.get('cin') }}

+
+

+ {%- trans %}Email{% endtrans -%} +

+

{{ org.contact_email }}

+
+
+ + + + + {{ line_break(gettext('double_linebreak')) }} + + + +

+ {%- trans %}Buyer details{% endtrans -%} +

+ + + + + +
+ + {{ line_break(gettext('linebreak')) }} + + + + {{ line_break(gettext('linebreak')) }} + + + +
+

+ {%- trans -%}Name{%- endtrans -%} +

+

{{ order.buyer_fullname }}

+
+

+ {%- trans %}Phone{% endtrans -%} +

+

{{ order.buyer_phone }}

+
+
+ +
+ + + {{ line_break(gettext('linebreak')) }} + + + {{ line_break(gettext('linebreak')) }} + + + +
+

+ {%- trans %}Paid on{% endtrans -%} +

+

{{ order.paid_at | longdate }}

+
+

+ {%- trans %}Email{% endtrans -%} +

+

{{ order.buyer_email }}

+
+
+ + + + + {{ line_break(gettext('linebreak')) }} + + + +

+ {%- trans %}Order Summary{% endtrans -%} +

+ + + {{ line_break(gettext('linebreak')) }} + + + {%- trans %}Item{% endtrans -%} + + + {%- trans %}Price{% endtrans -%} + + + {{ line_break(gettext('linebreak')) }} + {% for line_item in line_items -%} + + +

{{ loop.index }}{{ '. ' + line_item.ticket.title }}

+ + +

{{ currency_symbol }} {{ line_item.base_amount }}

+ + + + {% if not refunds %} + {{ line_item.ticket.description| safe}} + {% endif %} + + {%- endfor %} + {{ line_break(gettext('linebreak')) }} + + + + + + + + + + + + + + + +
+

+ {%- trans %}Sub-total{% endtrans-%} +

+
+

{{ currency_symbol }} {{ total_base_amount }}

+
+

+ {%- trans %}Discount{% endtrans -%} +

+
+ {% if total_discount_amount %} +

{{ currency_symbol }} {{ total_discount_amount }}

+ {% else %} +

{{ currency_symbol }} 0

+ {% endif %} +
+

+ {%- trans %}Total Paid{% endtrans -%} +

+
+

{{ currency_symbol }} {{ final_amount }}

+
+ + + + {{ line_break(gettext('double_linebreak')) }} + {% if refunds %} + + +

+ {%- trans %}Refund{% endtrans -%} +

+ + + {{ line_break(gettext('linebreak')) }} + {% for refund in refunds -%} + + + +
+ + + + +
+

+ {%- trans -%}Refund receipt{%- endtrans -%} +

+

{{ order.receipt_no }}

+
+
+ +
+ + + + +
+

+ {%- trans %}Refund date{% endtrans -%} +

+

+ {{ refund.refunded_at | longdate }} +

+
+
+ + + + + + {%- trans %}Refund reason{% endtrans -%} + + + {%- trans %}Amount{% endtrans -%} + + + {{ line_break(gettext('linebreak')) }} + + + + + {%- if refund.refund_description %} + + {%- elif refund.refunded_at %} + + {%- else %} + + {%- endif %} + + + {{ line_break(gettext('linebreak')) }} + {%- endfor %} + + + + + + + + +
+

+ {{ loop.index }}{{ '. ' + refund.refund_description }} +

+
+

+ {%- trans date=refund.refunded_at|longdate %}Refunded on{{ date }}{% endtrans -%} +

+
+

+ {%- trans %}Refund{% endtrans -%} +

+

{{ currency_symbol }} {{ refund.amount }}

+

+ {%- trans %}Total Refund{% endtrans-%} +

+
+

{{ currency_symbol }} {{ order.refunded_amount }}

+
+

+ {%- trans %}Net Paid{% endtrans -%} +

+
+

+ {{ currency_symbol }} {{ order.refunded_amount }} +

+
+ + + {%- endif %} + {{ line_break(gettext('linebreak')) }} + {% if not refunds %} + + +

+ {%- trans %}To access the benefits of this ticket please ensure you are logged in to your Hasgeek account with this same email address.{% endtrans -%} +

+ + + {{ line_break(gettext('linebreak')) }} + + + {{ cta_button('{base_url}/order/{access_token}/ticket'.format(base_url=base_url, access_token=order.access_token), gettext("Assign ticket"), gettext("primary") )}} + {{ cta_button('{base_url}/order/{access_token}/invoice'.format(base_url=base_url, access_token=order.access_token), gettext("GST invoice"), gettext("dark") )}} + + + {{ line_break(gettext('linebreak')) }} + + +
+

Cancellation and transfer

+ {{ org.details.get('refund_policy')|safe }} +
+ + + {% endif %} +{%- endblock content -%} diff --git a/boxoffice/views/order.py b/boxoffice/views/order.py index 077270fc..2b93984c 100644 --- a/boxoffice/views/order.py +++ b/boxoffice/views/order.py @@ -509,8 +509,18 @@ def receipt(order: Order) -> str: line_items = LineItem.query.filter( LineItem.order == order, LineItem.status == LineItemStatus.CONFIRMED ).all() + total_base_amount = sum([line_item.base_amount for line_item in line_items]) + total_item_discount = sum([line_item.discounted_amount for line_item in line_items]) + final_amount = sum([line_item.final_amount for line_item in line_items]) + refunds = [] + for transaction in order.refund_transactions: + refunds.append(transaction) return render_template( - 'cash_receipt.html.jinja2', + 'payment_receipt.html.jinja2', + total_base_amount=total_base_amount, + total_item_discount=total_item_discount, + final_amount=final_amount, + refunds=refunds, order=order, org=order.organization, line_items=line_items,