Add support to no tax code customer#38
Merged
Merged
Conversation
83642bb to
448625c
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates TicketBAI conversion to better support customers without a usable Spanish TaxID code (e.g., simplified invoices for Spanish customers identified via passport), and aligns tests with newer typed constants/linter expectations.
Changes:
- Treat Spanish customers with
TaxID.Country=ESbut emptyTaxID.Codeas “identified via identities” (e.g., passport) instead of forcing an empty NIF. - Extend customer “other identity” mapping to populate
CodigoPaisfrom the identity’s country when present, and introducepartyCountryto derive country from eitherTaxIDor identities. - Update tests to use typed constants (e.g.,
tax.CategoryVAT,org.ItemKeyGoods) and add new conversion scenarios for passport/no-tax-code customers.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| convert/parties.go | Adjusts destinatario identification logic; adds partyCountry; maps CodigoPais from identity country. |
| convert/invoice.go | Uses partyCountry when deciding whether to add “export/foreign” VAT key. |
| convert/breakdown.go | Uses partyCountry to decide domestic vs foreign breakdown structure. |
| convert/doc_test.go | Adds test cases for Spanish passport customers and CodigoPais behavior. |
| convert/invoice_test.go | Introduces typed rate constants and updates tax/category usage in tests. |
| convert/lines_test.go | Updates tax category/rate constants usage in tests. |
| convert/breakdown_test.go | Updates item key and tax category/rate constants usage in tests. |
Comments suppressed due to low confidence (2)
convert/invoice.go:156
newClavesnow usespartyCountry, which can return the customer's country from identities whenTaxIDis missing. This changes behavior for Spanish customers identified only via an identity withCountry: "ES"(they should no longer get export key "02"). Add/adjust a test case coveringCustomer.TaxID == nilwith an identity country of ES to ensure the expected clave is produced.
claves := []IDClave{}
if inv.Customer != nil && partyCountry(inv.Customer) != "ES" {
claves = append(claves, IDClave{
ClaveRegimenIvaOpTrascendencia: "02",
})
}
convert/breakdown.go:112
newTipoDesglosenow relies onpartyCountry, which can classify a customer as Spanish based on identity country even whenTaxIDis nil. This is a functional change (e.g., Spanish passport customer withIdentities[0].Country == "ES"should now produceDesgloseFacturainstead ofDesgloseTipoOperacion). Add a test covering this scenario to lock in the intended behavior.
desglose := &TipoDesglose{}
if gobl.Customer == nil || partyCountry(gobl.Customer) == l10n.ES.Tax() {
desglose.DesgloseFactura = newDesgloseFactura(taxInfo, catTotal.Rates)
} else {
goods, services := splitByTBAIProduct(catTotal.Rates)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
448625c to
2178ac0
Compare
pmenendz
approved these changes
May 8, 2026
pmenendz
left a comment
There was a problem hiding this comment.
LGTM, just solve the issue with gocosnt and add a test for the new use case in parties
2178ac0 to
f8c948e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.