Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Andorra (AD) tax regime to the GOBL regimes catalogue, including VAT/IGI rate definitions, invoice constraints, tax identity validation/normalization behavior, and accompanying examples and generated regime data.
Changes:
- Register the new
adregime and provide itstax.RegimeDef(metadata, corrections, scenarios). - Add Andorra VAT/IGI tax category + rates, plus invoice and NRT (tax ID) validation logic.
- Add Andorra examples and generated
data/regimes/ad.json, and adjust an existing “unknown regime” invoice test.
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
regimes/regimes.go |
Registers the new ad regime via blank import. |
regimes/ad/ad.go |
Defines the Andorra RegimeDef, hooks validator/normalizer, and sets corrections/scenarios. |
regimes/ad/invoices.go |
Adds regime-specific invoice validation (supplier tax ID required). |
regimes/ad/tax_categories.go |
Defines Andorra VAT/IGI category with rates and sources. |
regimes/ad/tax_identity.go |
Adds NRT validation via regexp-based code check. |
regimes/ad/ad_test.go |
Tests regime construction, invoice validation, tax categories, validate/normalize entrypoints. |
regimes/ad/tax_identity_test.go |
Unit tests for NRT validation patterns. |
examples/ad/invoice.yaml |
Adds an Andorra invoice example input. |
examples/ad/credit-note.yaml |
Adds an Andorra credit note example input. |
examples/ad/out/invoice.json |
Generated JSON output for the invoice example. |
examples/ad/out/credit-note.json |
Generated JSON output for the credit note example. |
data/regimes/ad.json |
Generated regime data for Andorra. |
bill/invoice_test.go |
Updates “unknown regime” test to use a different country code. |
CHANGELOG.md |
Adds changelog entry for the new Andorra regime. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
samlown
left a comment
There was a problem hiding this comment.
Good first attempt. I think the naming of the tax category is important to re-consider. A comment that mentions the lack of a checksum in the Tax ID and a source for potential changes would be useful for tax IDs.
| return validation.ValidateStruct(p, | ||
| validation.Field(&p.TaxID, | ||
| validation.Required, | ||
| tax.RequireIdentityCode, |
There was a problem hiding this comment.
Is this always the case? There may be a threshold for VAT related IDs.
There was a problem hiding this comment.
AFAIK all invoices must include the NRT, regardless of turnover, if that's what you mean.
| // | ||
| return []*tax.CategoryDef{ | ||
| { | ||
| Code: tax.CategoryVAT, |
There was a problem hiding this comment.
I think this one would need to be checked as the name in English is General Indirect Tax and not Value Added Tax. While it appears to be the same functionally wise, I don't think its totally compatible.
There was a problem hiding this comment.
I think this is actually a VAT, despite the translation. It is a tax added to any goods or services sold. Like IVA in Spain. I would consider it a VAT, unless there's something else I'm missing. As per how's described in the official website: "The IGI is the tax that levies consumption by taxing the deliveries of goods and the provision of services carried out by businessmen or professionals, as well as the imports of goods.".
| validation.Field(&t.Code, | ||
| validation.Required, | ||
| validation.Match(nrtRegexp), | ||
| ), |
There was a problem hiding this comment.
No checksum validation is available here? This alternative implementation doesn't appear to define one either: https://github.com/ltns35/go-vat/blob/main/countries/andorra.go
There was a problem hiding this comment.
No checksum is used. There are many sources that explain different rules for the NRT, but none of them official. What I did is taking the most commonly mentioned rules. I can see that the alternative implementation you mentioned has implemented some rules linking the first letter with the number; this is something I've only seen mentioned in this document that quotes stuff from 2014/15, and has all the reference links broken, so I simply didn't consider it reliable.
On top of that, I had a phone call with the Andorra Tax Agency, and they told me no algorithm is used for creating the NRTs. The only rules they mention is the letters F A E and L.
Add Andorra regime
a.
gobl.exe build -i -e examples\ad\credit-note.yaml > examples\ad\out\credit-note.json".b.
go test -run TestConvertExamplesToJSON -v -update.go generate .to populate the Regime data.Warning
Given the ongoing PR #736, I decided to remove the
READMEfile entirely and move what was in there to theDescriptionfield in the regime. The sources are also included in the description, so it will be convenient to move them to the new field once the changes in #736 are merged.Pre-Review Checklist
go generate .to ensure that the Schemas and Regime data are up to date.Only after checking off all the previous items: