What a VAT-Compliant Invoice Actually Requires
Building an invoicing system is one of those projects that seems straightforward until you account for international VAT. A domestic invoice is simple enough. Add the goods or services, apply the rate, show the tax amount, done. But once you're invoicing customers across Europe — with different VAT rules for B2B and B2C customers, different rates by country, and different documentation requirements — the complexity grows quickly.
The good news is that most of this complexity can be automated. The rules are consistent and well-documented. What you need is the right data at the right point in the flow, and the logic to apply it correctly.
The Data You Need Before You Can Generate an Invoice
A VAT-compliant invoice starts with good customer data. You need to know where the customer is based (billing address, not delivery address), whether they're a business or consumer, and if they're a business, their VAT registration number.
This data should be collected and validated at the point of customer onboarding or checkout — not at invoice generation time. By the time you're generating an invoice, the VAT treatment should already be determined.
VAT Number Validation: The Foundation of B2B Invoicing
If you're issuing zero-rated (reverse charge) invoices to B2B customers in other EU countries, validating their VAT number is not optional — it's the basis of your legal justification for not charging VAT. The VAT API provides a REST endpoint that validates EU numbers through VIES and UK numbers through HMRC, returning validity status, business name, and address where available.
Your customer onboarding flow should call this endpoint when a VAT number is entered. Store the full response — valid/invalid status, business name, timestamp — in your customer record. This serves as your audit trail.
For ongoing customers, consider periodic re-validation. VAT registrations can lapse. A customer whose VAT number was valid at signup may have deregistered a year later. Quarterly re-validation of active customer VAT numbers is a reasonable practice for businesses with audit exposure.
VAT Rate Lookup
For B2C invoices to EU consumers, you need the correct VAT rate for the customer's country. Rather than maintaining a rate table yourself, integrate with a VAT rates API that returns current rates by country code.
The rates endpoint at thevatapi.com returns the current standard, reduced, and super-reduced rates for any EU country. Cache the rates in your application with a daily or weekly TTL. Rates change infrequently, but they do change — a cached value from six months ago might be wrong.
Determining the VAT Treatment
With customer data and rates available, the logic for determining VAT treatment looks like this: if the customer is in the same country as the seller, apply domestic VAT rules. If in a different EU country with a valid VAT number, apply the reverse charge. If in a different EU country without a valid VAT number, charge VAT at the customer's country's rate. If in the UK, apply UK VAT rules.
This logic should be encapsulated in a single function that takes customer country, VAT status, and product type, and returns the applicable rate and treatment. Test it thoroughly against each scenario before going live.
What Has to Appear on the Invoice
EU VAT invoices have specific mandatory fields: invoice number, invoice date, seller name and address, seller VAT number, buyer name and address, description of goods/services, unit price, quantity, net amount, VAT rate, VAT amount, and gross amount.
For reverse charge invoices: the buyer's VAT number, and a statement such as "Reverse charge — VAT to be accounted for by the recipient in accordance with Article 196 of Directive 2006/112/EC."
Generating the invoice is the easy part. The hard part is making sure the data going into it is correct. Get the upstream validation and rate logic right, and the invoice almost generates itself.
Invoice Numbering
Invoices need sequential numbering. Use an auto-incrementing integer and format it as needed (INV-2026-0001, etc.). The requirement is that the sequence is unbroken and each number appears only once. Don't delete invoice records; instead, issue credit notes to reverse incorrect invoices.
Credit Notes
When you need to reverse an invoice — due to a refund, an error, or a cancellation — you issue a credit note rather than deleting the original invoice. Credit notes reference the original invoice number, show the reversal amount, and follow the same VAT treatment as the original. Your system needs to handle credit notes as a first-class entity.
Record Retention
VAT records must be retained for specific periods — typically 6 years in the UK, and varying by country across the EU. Your system should store invoice data in a way that makes retrieval by date range and customer straightforward. Alongside the invoice itself, store the VAT validation response and timestamp, and the customer's stated country.
Testing Your VAT Logic
Before going live, test every scenario: domestic B2B, domestic B2C, EU B2B with valid VAT number, EU B2B with invalid VAT number, EU B2C, UK customer, and customer with no country data. Create test invoices for each and verify that the VAT treatment, rates, and invoice content are correct.