Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Japan (JP) tax regime to GOBL, including Consumption Tax (standard/reduced) configuration, Corporate Number validation/normalization, and working invoice examples.
Changes:
- Register the new
JPregime and generate its regime data + schema enum update. - Implement JP Consumption Tax category/rates, reverse-charge scenario note, and credit-note correction support.
- Add JP Corporate Number normalization + checksum validation with accompanying tests and examples.
Reviewed changes
Copilot reviewed 12 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
regimes/regimes.go |
Registers the JP regime via blank import so it’s available at runtime. |
regimes/jp/jp.go |
Defines the JP tax.RegimeDef (metadata, categories, scenarios, corrections, validator/normalizer hooks). |
regimes/jp/tax_categories.go |
Adds Consumption Tax (VAT) category with standard/reduced rates and effective dates. |
regimes/jp/scenarios.go |
Adds a reverse-charge scenario that injects a legal note when tagged. |
regimes/jp/tax_identity.go |
Implements normalization (strip separators + T prefix) and Corporate Number checksum validation. |
regimes/jp/tax_identity_test.go |
Tests normalization and checksum validation behavior. |
data/schemas/tax/regime-code.json |
Adds JP to the regime code schema enum. |
data/regimes/jp.json |
Generated JSON representation of the JP regime definition. |
examples/jp/*.yaml |
Adds JP invoice examples (standard, reverse charge, credit note). |
examples/jp/out/*.json |
Adds generated envelope outputs for the JP examples. |
CHANGELOG.md |
Documents the addition of the JP tax regime. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #768 +/- ##
=======================================
Coverage 93.05% 93.06%
=======================================
Files 333 335 +2
Lines 17806 17894 +88
=======================================
+ Hits 16570 16653 +83
- Misses 870 873 +3
- Partials 366 368 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Implement the Japanese Consumption Tax (消費税) regime: - Standard rate 10% and reduced rate 8% (since Oct 2019) - 13-digit Corporate Number validation with checksum - Registration Number (T prefix) normalization - Reverse charge scenario for cross-border B2B services - Credit note support (Qualified Return Invoice)
98d9baa to
39d6441
Compare
samlown
left a comment
There was a problem hiding this comment.
Thanks for this @miguelsaddress! I'd review the tax category details as I don't think VAT is the right choice here.
We've just made a new major release of GOBL to the new rules based validation, so that would need updating for a final release also.
|
|
||
| var taxCategories = []*tax.CategoryDef{ | ||
| { | ||
| Code: tax.CategoryVAT, |
There was a problem hiding this comment.
Are you sure this should be VAT? I'd expect the consumption tax to be more like a sales tax and it might make sense to add a new CT type.
| }, | ||
| }, | ||
| Retained: false, | ||
| Keys: tax.GlobalVATKeys(), |
There was a problem hiding this comment.
Are you sure this applies here? Does JP support reverse-charge and similar things?
Summary
Adds the Japanese tax regime to GOBL, implementing the Consumption Tax (消費税, Shōhi zei) system and Corporate Number (法人番号, Hōjin Bangō) validation.
Note
I am not a tax professional. The tax rates, checksum algorithm, and regulatory details in this PR are based on publicly available sources (listed below). I recommend having someone with Japanese tax expertise verify the data before merging.
What's included
Tprefix on the Corporate Number; normalization strips it so the same underlying number is validated consistently.reverse-charge, for cross-border B2B services.credit-noteas a correction type (Qualified Return Invoice / 適格返還請求書).Scope decisions
These are deliberate choices to keep this PR focused:
Withholding Tax is not included. Japan's withholding tax (源泉徴収, Gensen Chōshū) uses tiered rates: 10.21% up to ¥1,000,000 and 20.42% on the excess. This cannot be expressed with a single
RateValueDef.Percent. Other regimes that implement withholding (ES, IT, MX) use flat rates that fit the current model. This could be added in a follow-up if the model is extended to support tiered rates.Only current and previous tax rates. The full history (3% in 1989, 5% in 1997) is omitted. Only the rates relevant for active invoicing are included: 10%/8% since 2019-10-01 and 8% since 2014-04-01.
Registration Number normalized to Corporate Number. The Qualified Invoice System assigns Registration Numbers as
T+ Corporate Number. Since the base number is identical, normalization strips the prefix and validates the underlying 13 digits.Corrections defined inline in
jp.go. Only one correction type is needed (credit note), so a separatecorrections.gofile is not warranted. This follows the UAE regime pattern.Translations limited to EN and JA. Consistent with other regimes (e.g., AE uses EN + AR, GR uses EN + EL).
Verification
mage lint— passesmage test— all 69 packages pass, no regressionsmage generate— regenerated, no unexpected changesgo vet ./...— no warningsgo test ./regimes/jp/... -cover— 91.7% coverageSources
Note
Last verified: 2026-03-21 16:00 CET (UTC+1)
Pre-Review Checklist
go generate .to ensure that the Schemas and Regime data are up to date.And if you are part of the org: