AsciiDoc-based invoice template with automatic calculations via a Ruby extension.
invoice.adoc— Invoice template with parameterized fieldscalc-extension.rb— Ruby extension that evaluates{calc:...}expressionsinvoice-sample.pdf— Original template (for reference)
Requires Asciidoctor (Ruby-based).
# Generate HTML
asciidoctor -r ./calc-extension.rb invoice.adoc
# Generate PDF (requires asciidoctor-pdf gem)
asciidoctor-pdf -r ./calc-extension.rb invoice.adocAll invoice data is defined as AsciiDoc attributes at the top of invoice.adoc. The calc-extension.rb processes {calc:expression} patterns and replaces them with computed values formatted in German locale (e.g. 12.426,00):
:price: 114.00
:qty: 109
:total: {calc:{qty}*{price}} → 12.426,00| Attribute | Description |
|---|---|
| Company / Customer | Name, address, contact, bank details |
invoice_number |
Invoice number |
invoice_date |
Invoice date |
due_date |
Payment due date |
description |
Free-text field (e.g. service period, project name) |
item<N>_desc |
Line item description |
item<N>_details |
Line item details (free-text, e.g. order/article numbers) |
item<N>_qty |
Quantity |
item<N>_price |
Unit price |
item<N>_total |
Line total (use {calc:...}) |
subtotal, vat_amount, total |
Calculated totals |