Skip to content

added croatia regime#724

Open
migueltorresvalls wants to merge 3 commits intoinvopop:mainfrom
migueltorresvalls:miguel
Open

added croatia regime#724
migueltorresvalls wants to merge 3 commits intoinvopop:mainfrom
migueltorresvalls:miguel

Conversation

@migueltorresvalls
Copy link
Copy Markdown

@migueltorresvalls migueltorresvalls commented Feb 21, 2026

Added a new Croatia (HR) tax regime, generated regime data and added example documents.

Changes

  • Regime definition using EUR currency, VAT tax scheme, and Europe/Zagreb timezone.
  • VAT categories: General (25%), Reduced (13%), Super-Reduced (5%), and Zero (0%) rates, sourced from the Croatian Tax Administrator.
  • OIB identity type: Defines Personal Identification Number used in Croatia, sourced from Croatian Minister of Finance.
  • Tests for regime validation, identity, and tax identity.
  • Updated regimes.go to import the new hr package so the regime is registered automatically.
  • Added example documents under examples/hr, including standard invoice with VAT and credit note referencing a preceding invoice.

Pre-Review Checklist

  • Opened this PR as a draft
  • Read the CONTRIBUTING.md guide.
  • Performed a self-review of my code.
  • Added thorough tests with at least 90% code coverage.
  • Modified or created example GOBL documents to show my changes in use, if appropriate.
  • Added links to the source of the changes in tax regimes or addons, either structured or in the comments.
  • Run go generate . to ensure that the Schemas and Regime data are up to date.
  • Reviewed and fixed all linter warnings.
  • Been obsessive with pointer nil checks to avoid panics.
  • Updated the CHANGELOG.md with an overview of my changes.
  • Requested a review from Copilot and fixed or dismissed (with a reason) all the feedback raised.

Only after checking off all the previous items:

  • Marked this PR as ready for review and requested one from @samlown.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive support for the Croatian (HR) tax regime to GOBL, including VAT rate definitions, OIB (Personal Identification Number) validation, and example documents.

Changes:

  • Added Croatian tax regime with EUR currency, VAT tax scheme, and Europe/Zagreb timezone
  • Implemented OIB identity validation using ISO 7064 MOD 11.10 checksum algorithm
  • Defined four VAT rates (25%, 13%, 5%, 0%) with references to official Croatian Tax Administration sources
  • Included comprehensive test coverage for regime, identity, and tax identity validation
  • Added example invoice and credit note documents with generated JSON outputs

Reviewed changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
regimes/regimes.go Registered HR regime package in correct alphabetical order
regimes/hr/hr.go Main regime definition with validator and normalizer functions
regimes/hr/identities.go OIB identity type definition and validation setup
regimes/hr/identities_test.go Comprehensive tests for OIB identity validation including edge cases
regimes/hr/tax_identity.go OIB tax code validation with ISO 7064 MOD 11.10 checksum algorithm
regimes/hr/tax_identity_test.go Tests for tax identity validation and normalization with valid/invalid checksums
regimes/hr/tax_categories.go VAT category definitions with four rate tiers and Croatian translations
regimes/hr/hr_test.go Regime initialization and validation tests
regimes/hr/README.md Documentation of Croatian tax regime including OIB format and VAT rates
examples/hr/invoice-hr-hr.yaml Example standard invoice with VAT and discounts
examples/hr/credit-note.yaml Example credit note referencing preceding invoice
examples/hr/out/invoice-hr-hr.json Generated and calculated invoice output
examples/hr/out/credit-note.json Generated and calculated credit note output
data/schemas/tax/regime-code.json Added HR to regime code schema in correct alphabetical position
data/regimes/hr.json Generated regime data file with complete VAT category definitions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread regimes/hr/README.md Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@samlown samlown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid and concise first attempt. A few considerations regarding tax rate and documentation.

},
{
Keys: []cbc.Key{tax.KeyStandard},
Rate: tax.RateZero,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zero rate VAT has its own key now.

Comment thread regimes/hr/hr.go
Name: i18n.String{
i18n.EN: "Croatia",
i18n.HR: "Hrvatska",
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest moving some of the details from the README to here so that the details are available in the generated schema.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 15 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +67 to +80
{
Keys: []cbc.Key{tax.KeyStandard},
Rate: tax.RateZero,
Name: i18n.String{
i18n.EN: "Zero Rate",
i18n.HR: "Nulta stopa",
},
Values: []*tax.RateValueDef{
{
Percent: num.MakePercentage(0, 3),
Since: cal.NewDate(2013, 7, 17),
},
},
},
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The VAT category defines a RateDef with Rate: tax.RateZero under Keys: []cbc.Key{tax.KeyStandard}. In this codebase, VAT “zero” is generally modeled via the zero key (tax.KeyZero) and tax.Combo.Normalize migrates Rate == "zero" into KeyZero and clears the rate. Keeping RateZero here is confusing (rate/key collision) and likely unused after normalization; consider removing this RateZero RateDef and rely on the global zero key instead (or, if you really need an explicit rate, ensure it’s associated with tax.KeyZero and won’t be normalized away).

Suggested change
{
Keys: []cbc.Key{tax.KeyStandard},
Rate: tax.RateZero,
Name: i18n.String{
i18n.EN: "Zero Rate",
i18n.HR: "Nulta stopa",
},
Values: []*tax.RateValueDef{
{
Percent: num.MakePercentage(0, 3),
Since: cal.NewDate(2013, 7, 17),
},
},
},

Copilot uses AI. Check for mistakes.
)

// validateTaxIdentity checks to ensure the Croatian OIB tax code is valid.
func validateTaxIdentity(tID *tax.Identity) error {
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validateTaxIdentity will panic if tID is a typed-nil *tax.Identity (e.g., passed through hr.Validate as an any interface), because it takes &tID.Code unconditionally. Add a nil guard at the start of validateTaxIdentity (or in Validate before calling it) to ensure regime validation cannot panic on nil inputs.

Suggested change
func validateTaxIdentity(tID *tax.Identity) error {
func validateTaxIdentity(tID *tax.Identity) error {
if tID == nil {
return nil
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants