Skip to content

TicketBAI: enable exempt reasons & not-subject transactions#669

Open
StefanKert wants to merge 4 commits into
mainfrom
claude/nervous-ishizaka-3555fc
Open

TicketBAI: enable exempt reasons & not-subject transactions#669
StefanKert wants to merge 4 commits into
mainfrom
claude/nervous-ishizaka-3555fc

Conversation

@StefanKert
Copy link
Copy Markdown
Member

Summary

Implements market-es#97 — replaces the hard-coded subject / not exempt / S1 TicketBAI branch with a mapper-driven build of all <Sujeta>/<Exenta>, <Sujeta>/<NoExenta> and <NoSujeta> sub-branches based on the charge item's NatureOfVat.

  • New TicketBaiNatureOfVatMapping centralises the NatureOfVatES → (ClaveRegimen, Branch, CausaExencion?, TipoNoExenta?, CausaNoSujeta?) table from the issue.
  • TicketBaiFactory.GetFacturaDetails now groups items by NatureOfVat, builds the correct branch combination, and applies the same logic inside the foreign-recipient <Entrega> / <PrestacionServicios> split.
  • Claves is derived from the items (exports → 02, mixed → both 01 and 02) instead of being pinned to Item01.

Coverage of the spec table

NN NatureOfVatES Result
[10] Exports ExteptArticle21 <Exenta CausaExencion=E2>, Claves 02
[11] Intra-community delivery ExteptArticle25 <Exenta CausaExencion=E5>, Claves 01
[13] Treated as exports ExteptArticle22 <Exenta CausaExencion=E3>, Claves 02
[14] Customs / tax-regulation ExteptArticle23And24 <Exenta CausaExencion=E4>, Claves 02
[20] Not subject — location NotSubjectLocationRules <NoSujeta Causa=RL>
[21] Not subject — Art. 7/14 NotSubjectArticle7and14 <NoSujeta Causa=OT>
[30] Exempted domestic ExteptArticle20 <Exenta CausaExencion=E1>
[31] Other exemptions ExteptOthers <Exenta CausaExencion=E6>
[50] Reverse charge ReverseCharge <NoExenta TipoNoExenta=S2>

Out of scope (matches the issue's open questions)

  • NN [60] (IE — foreign tax IPSI/IGIC) and NN [80] (VT — third-party transactions) have no ChargeItemCaseNatureOfVatES value yet; the mapper throws NotSupportedException if those ever show up.
  • The Entrega vs. PrestacionServicios split still uses the existing TypeOfService-based filter — the open question about queue-es carrying explicit goods-vs-services is unresolved upstream.
  • No additional spec validation beyond what the mapper enforces by construction.

Test plan

  • dotnet test scu-es/test/fiskaltrust.Middleware.SCU.ES.UnitTest — 17 new tests pass (11 mapping + 7 factory). Pre-existing VeriFactuTest certificate-dependent cases unchanged.
  • Smoke-check against the Araba / Bizkaia / Gipuzkoa sandbox endpoints with a domestic exempt + not-subject + reverse-charge invoice (requires local certificates, out of CI scope).

🤖 Generated with Claude Code

…fVat

Replaces the hard-coded 'subject, not exempt, S1' TicketBAI branch with a mapper-driven build of the Sujeta/Exenta, Sujeta/NoExenta and NoSujeta sub-branches per the table in fiskaltrust/market-es#97. ClaveRegimen is derived from the items (exports -> 02) instead of being pinned to 01.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@StefanKert StefanKert requested a review from a team as a code owner May 22, 2026 06:17
@github-actions github-actions Bot added market-es Related to the spanish market area-tests Affects the test scu-es-ticketbaiaraba Related to the spanish ticketbai araba scu scu-es-ticketbaibizkaia Related to the spanish ticketbai bizkaia scu scu-es-ticketbaigipuzkoa Related to the spanish ticketbai gipuzkoa scu labels May 22, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 22, 2026

SCU.ES Test Results

  2 files    2 suites   0s ⏱️
 81 tests  78 ✅ 3 💤 0 ❌
162 runs  156 ✅ 6 💤 0 ❌

Results for commit a843759.

♻️ This comment has been updated with latest results.

StefanKert and others added 3 commits May 22, 2026 08:42
Pins the produced TicketBAI XML for nine scenarios (single usual VAT, reverse charge, each exempt and not-subject branch, a mixed all-branches receipt, a mixed receipt with exports producing two Claves entries, and a foreign customer split across Entrega and PrestacionServicios). Run with UPDATE_TICKETBAI_SNAPSHOTS=1 to regenerate after a deliberate spec change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds 10 reference XMLs (NN [10]-[60]) from fiskaltrust/market-es#95 under TestData/TicketBAI/ReferenceSamples/ and a new acceptance test that asserts the factory produces matching CausaExencion / TipoNoExenta / CausaNoSujeta / ClaveRegimenIvaOpTrascendencia codes and lands in the same DesgloseFactura vs DesgloseTipoOperacion/Entrega vs PrestacionServicios branch as each published sample. NN [60] (foreign tax / IE) is documented but skipped pending a queue-es enum variant for it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@StefanKert StefanKert added meta-no-issue This PR does not need to have a linked issue category-enhancement New feature or request area-sign Affects the signing endpoint and removed area-tests Affects the test labels May 26, 2026
@github-actions github-actions Bot added the area-tests Affects the test label May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-sign Affects the signing endpoint area-tests Affects the test category-enhancement New feature or request market-es Related to the spanish market meta-no-issue This PR does not need to have a linked issue scu-es-ticketbaiaraba Related to the spanish ticketbai araba scu scu-es-ticketbaibizkaia Related to the spanish ticketbai bizkaia scu scu-es-ticketbaigipuzkoa Related to the spanish ticketbai gipuzkoa scu

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant