{% extends "base.html" %} {% load static erp_tags %} {% block title %}Invoice {{ invoice.invoice_number }}{% endblock %} {% block chat_context %} {% endblock %} {% block content %} {# Header #}

Invoice

{{ invoice.invoice_number }}

{% if customer %}{{ customer }} · {% endif %} Order {{ order.order_number }} · Invoiced {{ invoice.invoice_date|date:"M j, Y" }}{% if invoice.due_date %} · Due {{ invoice.due_date|date:"M j, Y" }}{% endif %}

{{ invoice.get_status_display }}
Order {{ order.order_number }} Print preview PDF {% if customer_email and invoice.status != "void" and invoice.status != "cancelled" %}
{% csrf_token %}{% once_field %}
{% endif %} {% if can_record_payment %} Record payment {% endif %} {% if can_refund %} Refund {% endif %}
{# Totals #}

Totals

Subtotal
{{ invoice.subtotal_ex_tax|money:order.currency }}
Tax
{{ invoice.tax_total|money:order.currency }}
Shipping
{{ invoice.shipping_cost|money:order.currency }}
Total
{{ invoice.grand_total|money:order.currency }}
Paid
{{ invoice.amount_paid|money:order.currency }}
{% if refunded_total %}
Refunded
{{ refunded_total|money:order.currency }}
{% endif %}
Balance due
{{ invoice.balance_due|money:order.currency }}
{# Payments #}

Payments

{% if payments %}
{% for p in payments %} {% endfor %}
PaymentDateTypeMethodReferenceStatusAmount
{{ p.payment_number }} {{ p.payment_date|date:"M j, Y" }} {{ p.get_payment_type_display }}{% if p.parent_payment_id %} of {{ p.parent_payment.payment_number }}{% endif %} {{ p.get_payment_method_display }} {% if p.payment_type == "refund" %}{{ p.refund_reason|default:"—" }}{% else %}{{ p.transaction_id|default:"—" }}{% endif %} {{ p.get_status_display }} {% if p.payment_type == "refund" %}({{ p.amount|money:p.currency }}){% else %}{{ p.amount|money:p.currency }}{% endif %}
{% else %}

No payments recorded yet.

{% endif %}
{# Record a payment #}

Record payment

{% if can_record_payment %}
{% csrf_token %}{% once_field %}
{{ form.amount|add_class:"form-control form-control-sm" }}
Balance due: {{ invoice.balance_due|money:order.currency }}
{{ form.payment_date|add_class:"form-control form-control-sm" }}
{{ form.payment_method|add_class:"form-control form-control-sm" }}
{{ form.reference|add_class:"form-control form-control-sm" }}
{{ form.reference.help_text }}
{{ form.notes|add_class:"form-control form-control-sm" }}
{% elif invoice.status == "void" or invoice.status == "cancelled" %}

This invoice is {{ invoice.get_status_display|lower }}; nothing can be recorded against it.

{% else %}

Paid in full{% if invoice.paid_date %} on {{ invoice.paid_date|date:"M j, Y" }}{% endif %}.

{% endif %}
{# Refund #}

Refund

{% if can_refund %}
{% csrf_token %}{% once_field %}
{{ refund_form.payment|add_class:"form-control form-control-sm" }}
Still refundable: {% for p, left in refundable %}{{ p.payment_number }} {{ left|money:p.currency }}{% if not forloop.last %}, {% endif %}{% endfor %}
{{ refund_form.amount|add_class:"form-control form-control-sm" }}
{{ refund_form.reason|add_class:"form-control form-control-sm" }}

The money goes back under the refund posting rule; stock is not changed (a refund returns money, not goods).

{% elif refunded_total %}

Refunded in full: {{ refunded_total|money:order.currency }}.

{% else %}

Nothing to refund: no settled payment on this invoice.

{% endif %}
{% endblock %}