invopop / gobl.fatturapa

GOBL Conversion into FatturaPA in Italy
Apache License 2.0
4 stars 2 forks source link

Find local codes using tax tags, schemes, and invoice type #2

Closed lucanioi closed 1 year ago

lucanioi commented 1 year ago

This is what it would look like form the Italy provider with the new Tags as well as Scheme+InvoiceType approach to mapping FatturaPA codes. I put everything in codes.go so it's easier to evaluate.

What do you think? Feels like the logic is too complex and too dependent on gobl's inner workings to put inside of the provider... at the same time, I'm not sure moving this logic to gobl would make sense either, given it's pretty Italy-specific. Or maybe we can at least create a gobl functionality where you can fetch the scheme definitions based on on the invoice properties. Something like:

regime := tax.RegimeFor(l10n.IT, l10n.CodeEmpty)

for _, schemeKey := range invoice.Schemes {
  schemeDef := regime.SchemeDefsFor(schemeKey, invoice.InvoiceType)
  // process
}  
samlown commented 1 year ago

@lucanioi yes, I agree, it does feel too complex. I was working on simplifying last week, but hit a few road blocks. In my opinion from the gobl package it should be possible to get a list of scheme objects for the current document directly from the regime.