Skip to content

Add Türkiye (TR) tax regime#743

Open
mrdanwa wants to merge 2 commits into
invopop:mainfrom
mrdanwa:add-tr-regime
Open

Add Türkiye (TR) tax regime#743
mrdanwa wants to merge 2 commits into
invopop:mainfrom
mrdanwa:add-tr-regime

Conversation

@mrdanwa
Copy link
Copy Markdown
Contributor

@mrdanwa mrdanwa commented Feb 26, 2026

  • New Türkiye tax regime (regimes/tr/) with:
    • VKN (10-digit) tax identity validation with checksum verification
    • TCKN (11-digit) org identity validation with checksum verification
    • KDV (VAT) rates: standard 20%, reduced 10%, super-reduced 1%, with historical rates back to 1999
    • Corrective invoice type
    • Supplier TaxID or TCKN identity required on all invoices
    • 5 example invoices: standard, reduced, corrective, exempt, tckn
    • Registered in regimes/regimes.go, generated data/regimes/tr.json and updated regime-code.json
    • CHANGELOG updated

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.
  • Marked this PR as ready for review.

And if you are part of the org:

  • Requested a review from Copilot and fixed or dismissed (with a reason) all the feedback raised.
  • Requested a review 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 pull request adds a comprehensive tax regime implementation for Türkiye (TR) to the GOBL tax library. The implementation includes tax identity validation for both company (VKN) and individual (TCKN) tax numbers with checksum verification, VAT (KDV) rate definitions with historical rates dating back to 1999, and support for corrective invoices in compliance with Turkish tax law.

Changes:

  • Added complete Türkiye tax regime with VKN (10-digit) and TCKN (11-digit) tax identity validation using checksum algorithms
  • Defined KDV (VAT) rates: standard 20%, reduced 10%, super-reduced 1%, with historical rate changes since 1999
  • Implemented corrective invoice type as the only valid correction method per Tax Procedure Law Article 227

Reviewed changes

Copilot reviewed 14 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
regimes/tr/tr.go Main regime definition with corrections configuration and validation/normalization hooks
regimes/tr/tax_identity.go VKN and TCKN validation logic with checksum verification algorithms
regimes/tr/tax_identity_test.go Comprehensive tests for tax identity normalization and validation
regimes/tr/tax_categories.go KDV rate definitions with historical rates and source documentation
regimes/tr/invoices.go Invoice validation requiring supplier tax ID
regimes/tr/invoices_test.go Invoice validation tests
regimes/regimes.go Registration of TR regime
examples/tr/*.yaml Four example invoices demonstrating standard, reduced, exempt, and corrective scenarios
examples/tr/out/*.json Generated JSON outputs for example invoices
data/regimes/tr.json Generated regime data file
data/schemas/tax/regime-code.json Added TR regime code to schema
CHANGELOG.md Documented new TR regime addition

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

Comment thread CHANGELOG.md Outdated
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.

Thanks for providing this! A few changes are required around the tax identity handling and the use of non-public or official sources. Some good stuff here though!

Comment thread regimes/tr/tax_categories.go Outdated
Comment thread regimes/tr/tax_identity.go Outdated
Comment thread regimes/tr/tr.go Outdated
Comment thread regimes/tr/invoices.go Outdated
Comment thread regimes/tr/tr.go
Comment thread regimes/tr/tax_categories.go Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 95.69892% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.07%. Comparing base (926130f) to head (26f1e03).
⚠️ Report is 26 commits behind head on main.

Files with missing lines Patch % Lines
regimes/tr/tax_identity.go 90.47% 2 Missing and 2 partials ⚠️
regimes/tr/identities.go 95.00% 1 Missing and 1 partial ⚠️
regimes/tr/invoices.go 94.11% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #743      +/-   ##
==========================================
+ Coverage   93.05%   93.07%   +0.02%     
==========================================
  Files         333      337       +4     
  Lines       17785    17971     +186     
==========================================
+ Hits        16549    16727     +178     
- Misses        870      874       +4     
- Partials      366      370       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mrdanwa
Copy link
Copy Markdown
Contributor Author

mrdanwa commented Feb 27, 2026

Thanks for the review Sam. You were right, TCKN is a national identity number used domestically by individuals and sole traders and not a valid tax ID for international trade. Only VKN serves that purpose. I've moved TCKN to org.Identity and updated supplier validation to require either a VKN (via TaxID) or a TCKN (via Identities). Also replaced sources with official publications, added a regime description, fixed lint issues, and added a TCKN example invoice.

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