Add discount/coupon breakdown to invoice template

Add comprehensive pricing breakdown to invoice display showing:
- Subtotal before discounts
- Applied coupon codes and descriptions
- Total discount amount
- Handling costs
- Final total

Critical for ecommerce transparency - both customers and shop owners
can now see what discounts were applied to each invoice.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Russell Ballestrini 2025-07-27 20:28:11 -04:00
parent 267db2e278
commit 76c171df18

View file

@ -4,9 +4,31 @@
<h1>Invoice Identifier<br>{{ invoice.id }}</h1>
<p><strong>Customer Name:</strong> {{ invoice.user.name }}</p>
<p><strong>Date:</strong> {{ invoice.human_created_timestamp }}</p>
<p><strong>Total:</strong> ${{ '%0.2f' % invoice.total }}</p>
<!-- Pricing Breakdown -->
<div style="background-color: #f8f9fa; padding: 15px; border: 1px solid #dee2e6; border-radius: 5px; margin: 15px 0;">
<h3>Total Breakdown</h3>
<p><strong>Subtotal:</strong> ${{ '%0.2f' % (invoice.subtotal_in_cents / 100) }}</p>
{% if invoice.coupon_redemptions %}
<h4>Discounts Applied</h4>
{% for redemption in invoice.coupon_redemptions %}
<p style="color: #28a745;">
<strong>{{ redemption.coupon.code }}:</strong> {{ redemption.coupon.description }}
</p>
{% endfor %}
<p><strong>Total Discounts:</strong> <span style="color: #28a745;">-${{ '%0.2f' % (invoice.discount_amount_in_cents / 100) }}</span></p>
{% endif %}
{% if invoice.handling_cost_in_cents %}
<p><strong>Handling Cost:</strong> ${{ '%0.2f' % (invoice.handling_cost_in_cents / 100) }}</p>
{% endif %}
<hr style="margin: 10px 0;">
<p style="font-size: 1.2em;"><strong>Total:</strong> ${{ '%0.2f' % invoice.total }}</p>
</div>
<p><strong>Shipping/Pickup:</strong> {{ invoice.handling_option }}</p>
<p><strong>Handling Cost:</strong> ${{ '%0.2f' % ((invoice.handling_cost_in_cents or 0) / 100) }}</p>
{% if invoice.delivery_address %}
<p><strong>Delivery Address:</strong> {{ invoice.delivery_address }}</p>
{% endif %}