Skip to content

Commit

Permalink
fixed vat id parsing if it starts with the country
Browse files Browse the repository at this point in the history
  • Loading branch information
MarlinKuhn committed Dec 20, 2024
1 parent 9614587 commit 2597709
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions internal/ctog/party.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ func (c *Converter) getParty(party *document.Party) *org.Party {
for _, taxReg := range party.SpecifiedTaxRegistration {
if taxReg.ID != nil && taxReg.ID.Value != "" {
switch taxReg.ID.SchemeID {
//Source (XML Document) https://ec.europa.eu/digital-building-blocks/sites/download/attachments/467108974/EN16931%20code%20lists%20values%20v13%20-%20used%20from%202024-05-15.xlsx?version=2&modificationDate=1712937109681&api=v2
// Source (XML Document) https://ec.europa.eu/digital-building-blocks/sites/download/attachments/467108974/EN16931%20code%20lists%20values%20v13%20-%20used%20from%202024-05-15.xlsx?version=2&modificationDate=1712937109681&api=v2
case "VA":
p.TaxID = &tax.Identity{
Country: l10n.TaxCountryCode(party.PostalTradeAddress.CountryID),
Code: cbc.Code(taxReg.ID.Value),
// Parse the country code from the vat
if identity, err := tax.ParseIdentity(taxReg.ID.Value); err == nil {
p.TaxID = identity
} else {
// Fallback to preserve the tax id
p.TaxID = &tax.Identity{
Country: l10n.TaxCountryCode(party.PostalTradeAddress.CountryID),
Code: cbc.Code(taxReg.ID.Value),
}
}
case "FC":
identity := &org.Identity{
Expand Down

0 comments on commit 2597709

Please sign in to comment.