Skip to content

Add support to no tax code customer#38

Merged
mrdanwa merged 1 commit into
mainfrom
customer-no-tax-code
May 8, 2026
Merged

Add support to no tax code customer#38
mrdanwa merged 1 commit into
mainfrom
customer-no-tax-code

Conversation

@mrdanwa
Copy link
Copy Markdown
Contributor

@mrdanwa mrdanwa commented May 7, 2026

  • Support Spanish customers to issue simplified invoices using passport
  • Map identities country that was not mapped
  • Use identities country to get IDType
  • Adapt to new linter

Copy link
Copy Markdown

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 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=ES but empty TaxID.Code as “identified via identities” (e.g., passport) instead of forcing an empty NIF.
  • Extend customer “other identity” mapping to populate CodigoPais from the identity’s country when present, and introduce partyCountry to derive country from either TaxID or 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

  • newClaves now uses partyCountry, which can return the customer's country from identities when TaxID is missing. This changes behavior for Spanish customers identified only via an identity with Country: "ES" (they should no longer get export key "02"). Add/adjust a test case covering Customer.TaxID == nil with 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

  • newTipoDesglose now relies on partyCountry, which can classify a customer as Spanish based on identity country even when TaxID is nil. This is a functional change (e.g., Spanish passport customer with Identities[0].Country == "ES" should now produce DesgloseFactura instead of DesgloseTipoOperacion). 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.

Comment thread convert/parties.go
@mrdanwa mrdanwa force-pushed the customer-no-tax-code branch from 448625c to 2178ac0 Compare May 8, 2026 13:36
Copy link
Copy Markdown

@pmenendz pmenendz left a comment

Choose a reason for hiding this comment

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

LGTM, just solve the issue with gocosnt and add a test for the new use case in parties

@mrdanwa mrdanwa force-pushed the customer-no-tax-code branch from 2178ac0 to f8c948e Compare May 8, 2026 15:23
@mrdanwa mrdanwa merged commit 2299b6f into main May 8, 2026
5 checks passed
@mrdanwa mrdanwa deleted the customer-no-tax-code branch May 8, 2026 15:35
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