{#- Customer receipt for an 80 mm roll printer (72 mm printable). Frappe reads this file on every print, so a change here needs no migrate. Pure black and bold only: a thermal head has no grey, it dithers. `page-height` is an estimate for the CUPS/PDF path, where JavaScript is off; the browser path measures the real height at the bottom of this file. -#} {%- set brand = get_receipt_branding(doc.branch, doc.company) -%} {%- set text = brand.text -%} {%- set near = "right" if brand.rtl else "left" -%} {%- set far = "left" if brand.rtl else "right" -%} {%- set profile = frappe.db.get_value("POS Profile", doc.pos_profile, ["custom_tip_account", "customer"], as_dict=True) if doc.pos_profile else None -%} {%- set tip_account = profile.custom_tip_account if profile else None -%} {%- set default_customer = profile.customer if profile else None -%} {%- macro plain(value) -%} {%- set amount = frappe.utils.fmt_money(value) -%} {{- amount[:-3] if amount[-3:] in (".00", ",00") else amount -}} {%- endmacro -%} {#- Taxes already inside the prices are shown for information only, below the total, so the bill still adds up. -#} {%- set taxes = [] -%} {%- set included_taxes = [] -%} {%- for tax in doc.taxes -%} {%- if tax.tax_amount_after_discount_amount and not (tax.charge_type == "Actual" and tax.description == "Tip" and tax.account_head == tip_account) -%} {%- set _ = (included_taxes if tax.included_in_print_rate else taxes).append(tax) -%} {%- endif -%} {%- endfor -%} {%- set paid = [] -%} {%- if doc.docstatus == 1 -%} {%- for payment in doc.payments -%} {%- if payment.amount -%}{%- set _ = paid.append(payment) -%}{%- endif -%} {%- endfor -%} {%- endif -%} {%- set height = namespace(mm=(128 if brand.logo else 106)) -%} {%- for row in doc.items -%} {%- set height.mm = height.mm + 9 + (5 if row.qty != 1 else 0) + (5 if row.price_list_rate and row.price_list_rate > row.rate else 0) + (7 * ((row.item_name | length) // 20)) + (5 if get_print_names(row.item_code, row.item_name, doc.branch, "bill").secondary else 0) -%} {%- endfor -%} {%- set height.mm = height.mm + (7 * ((taxes | length) + (included_taxes | length) + (paid | length) + 3)) + ((10 + (6 * (doc.custom_merged_pos_invoice_details | length))) if doc.custom_merged_pos_invoice else 0) -%}
{% if brand.logo %}{% endif %}
{{ (doc.restaurant or doc.company) | e }}
{% if brand.header %}
{{ brand.header | e }}
{% endif %} {% if brand.phone %}
{{ text.phone }}: {{ brand.phone | e }}
{% endif %} {% if brand.tax_id %}
{{ text.tax_no }}: {{ brand.tax_id | e }}
{% endif %} {% if doc.is_return %}
{{ text.returned }}
{% endif %}
{{ text.date }}: {{ frappe.utils.formatdate(doc.posting_date) }} {{ text.time }}: {{ frappe.utils.format_time(doc.posting_time, "HH:mm") }}
{% if doc.restaurant_table %}{% endif %} {% if doc.order_type and not doc.restaurant_table %}{% endif %} {% if doc.waiter %}{% endif %} {% if doc.customer_name and doc.customer != default_customer and doc.customer_name != "Guest" %}{% endif %}
{{ text.table }}{{ doc.restaurant_table | e }}
{{ text.order_type }}{{ (text.order_types.get(doc.order_type) or doc.order_type) | e }}
{{ text.receipt_no }}#{{ doc.name | e }}
{{ text.waiter }}{{ doc.waiter | e }}
{{ text.customer }}{{ doc.customer_name | e }}
{% for row in doc.items %} {%- set names = get_print_names(row.item_code, row.item_name, doc.branch, "bill") %} {% if row.qty != 1 %} {% endif %} {% if row.price_list_rate and row.price_list_rate > row.rate %} {% endif %} {% endfor %}
{{ text.item }}{{ text.qty }}{{ text.amount }}
{{ names.primary | e }}{% if names.secondary %}
{{ names.secondary | e }}
{% endif %}
{{ "%g" | format(row.qty) }} {{ plain(row.amount) }}
{{ "%g" | format(row.qty) }} × {{ plain(row.rate) }}
{{ text.discount }}{% if row.discount_percentage %} {{ "%g" | format(row.discount_percentage) }}%{% endif %} -{{ plain((row.price_list_rate - row.rate) * row.qty) }}
{% if doc.discount_amount %}{% endif %} {% for tax in taxes %}{% endfor %} {% if doc.custom_tip_amount %}{% endif %} {% if doc.rounding_adjustment %}{% endif %}
{{ text.subtotal }}{{ plain(doc.total) }}
{{ text.discount }}-{{ plain(doc.discount_amount) }}
{{ tax.description | e }}{{ plain(tax.tax_amount_after_discount_amount) }}
{{ text.tip }}{{ plain(doc.custom_tip_amount) }}
{{ text.rounding }}{{ plain(doc.rounding_adjustment) }}
{{ text.total }}{{ doc.get_formatted("rounded_total") if doc.rounded_total else doc.get_formatted("grand_total") }}
{% for tax in included_taxes %}{% endfor %}
{{ text.tax_included }} {{ tax.description | e }}{{ plain(tax.tax_amount_after_discount_amount) }}
{% if paid %} {% for payment in paid %}{% endfor %} {% if doc.change_amount %}{% endif %}
{{ text.payment_method }}: {{ _(payment.mode_of_payment) | e }}{{ plain(payment.amount) }}
{{ text.change }}{{ plain(doc.change_amount) }}
{% endif %} {% if doc.custom_merged_pos_invoice %}
{{ text.merged_with }} {{ doc.custom_merged_pos_invoice | e }}
{% for row in doc.custom_merged_pos_invoice_details %} {% endfor %}
{{ "%g" | format(row.qty) }}×{{ row.item_name | e }}{{ plain(row.amount) }}
{{ text.combined_total }}{{ frappe.utils.fmt_money((doc.grand_total | round) + ((doc.custom_merged_total | round) if doc.custom_merged_total else 0), currency=doc.currency) }}
{% endif %}
{{ (brand.footer or (text.thank_you ~ "\n" ~ text.enjoy)) | e }}
{% if brand.legal_note %}
{{ brand.legal_note | e }}
{% endif %}