Prepare Source
To get started we’re going to need some base data. Take the following yaml, modify as you see fit, and output to a file likeinvoice.yaml
:
$schema
is set to the GOBL Draft-0 invoice definition.supplier
identifies the issuer of the invoice, and thetax_id
specifically sets the origin country for this invoice.customer
includes the minimum amount of data possible for a customer.lines
defines a simple list of items, including the tax codes, in this case the category is “VAT” at the “standard” rate.- A single discount of “10%” has been defined for the line.
- There are no totals or other calculations, just the basic raw data.
Building
Take the invoice details and send them to thegobl build
command:
- Everything has been embedded inside a GOBL Envelope, with a head and signature.
- Each invoice line has been updated with a
sum
andtotal
, where the total is the sum with discounts applied. - Tax rates valid for the
issue_date
have been added automatically. - A
totals
property has been added to the invoice, and details all the taxes that were applied to the calculations made from the lines.
Test PDF
Invopop, the creators of GOBL, offer a free stateless service to be able to test what your invoices look like as a PDFs. We do not recommend this for production use as it does not come with the same service guarantees, but is great for testing. Create a newinvoice.json
file: