@@ -89,7 +89,6 @@ type DetalleNoSujeta struct {
8989
9090type taxInfo struct {
9191 simplifiedRegime bool
92- reverseCharge bool
9392 customerRates bool
9493}
9594
@@ -145,7 +144,7 @@ func newDesgloseFactura(taxInfo taxInfo, rates []*tax.RateTotal) *DesgloseFactur
145144 })
146145 } else {
147146 dne := df .Sujeta .NoExenta .appendDetalle (& DetalleNoExenta {
148- TipoNoExenta : taxInfo . nonExemptedType (rate ),
147+ TipoNoExenta : nonExemptedType (rate ),
149148 DesgloseIVA : & DesgloseIVA {},
150149 })
151150
@@ -219,7 +218,7 @@ func (di *DesgloseIVA) appendDetalle(d *DetalleIVA) *DetalleIVA {
219218}
220219
221220func newDetalleIVA (taxInfo taxInfo , rate * tax.RateTotal ) * DetalleIVA {
222- percent := num .PercentageZero // S2 reverse-charge rates have no percent
221+ percent := num .PercentageZero
223222 if rate .Percent != nil {
224223 percent = * rate .Percent
225224 }
@@ -253,28 +252,22 @@ func formatPercent(percent num.Percentage) string {
253252func newTaxInfo (gobl * bill.Invoice ) taxInfo {
254253 return taxInfo {
255254 simplifiedRegime : gobl .HasTags (es .TagSimplifiedScheme ),
256- reverseCharge : gobl .HasTags (tax .TagReverseCharge ),
257255 customerRates : gobl .HasTags (tax .TagCustomerRates ),
258256 }
259257}
260258
261- // notSubjectExemptionCodes are the es-tbai-exemption values that the
262- // es-tbai-v1 addon assigns to "outside-scope" tax combos; they map to
263- // DetalleNoSujeta/Causa in the TicketBAI XML.
259+ // notSubjectExemptionCodes lists the es-tbai-exemption codes that map to
260+ // DetalleNoSujeta/Causa.
264261var notSubjectExemptionCodes = []cbc.Code {"OT" , "RL" , "VT" , "IE" }
265262
266- // reverseChargeExemptionCodes are the es-tbai-exemption values that map
267- // to DetalleNoExenta/TipoNoExenta = S2 (subject to VAT with reverse
268- // charge) in the TicketBAI XML.
263+ // reverseChargeExemptionCodes lists the es-tbai-exemption codes that map to
264+ // DetalleNoExenta/TipoNoExenta = S2.
269265var reverseChargeExemptionCodes = []cbc.Code {"S2" }
270266
271- // nonExemptedType returns the TBAI TipoNoExenta value for a "subject and
272- // non-exempt" tax rate. The new path consults the es-tbai-exemption
273- // extension set by the es-tbai-v1 addon normalizer; the legacy fallback
274- // relies on the invoice-wide reverse-charge tag for callers that have
275- // not been normalized through the addon.
276- func (t taxInfo ) nonExemptedType (r * tax.RateTotal ) string {
277- if t .reverseCharge || r .Ext .Get (tbai .ExtKeyExempt ).In (reverseChargeExemptionCodes ... ) {
267+ // nonExemptedType returns the TBAI TipoNoExenta value for a subject,
268+ // non-exempt tax rate.
269+ func nonExemptedType (r * tax.RateTotal ) string {
270+ if r .Ext .Get (tbai .ExtKeyExempt ).In (reverseChargeExemptionCodes ... ) {
278271 return "S2"
279272 }
280273 return "S1"
0 commit comments