Skip to content

feat: add BT-120 VAT exemption reason#247

Merged
barredterra merged 1 commit intoalyf-de:developfrom
0xD0M1M0:BT-120
Apr 27, 2026
Merged

feat: add BT-120 VAT exemption reason#247
barredterra merged 1 commit intoalyf-de:developfrom
0xD0M1M0:BT-120

Conversation

@0xD0M1M0
Copy link
Copy Markdown
Contributor

Adds a BT-120 textfield for the VAT exemption reason to the E-Invoice Settings: #183

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 21, 2026

Greptile Summary

This PR implements BT-120 (VAT exemption reason text) support for the EU e-invoice module by adding a "Default VAT exemption reason" setting in E Invoice Settings and writing its value to the ram:ExemptionReason XML element on VAT breakdowns that already emit a BT-121 exemption reason code. It also supports round-tripping by reading BT-120 back from imported CII XML and storing it in the E Invoice Trade Tax child table, and includes a defensive guard in _set_seller_id to handle customers that lack a supplier_numbers attribute.

Confidence Score: 5/5

Safe to merge — the feature is correctly scoped, BT-120 text is only emitted alongside BT-121 code, and import round-tripping is handled consistently.

All changes are well-scoped: the exemption reason text is fetched once per invoice generation and applied only where the exemption reason code is already emitted, keeping BT-120 and BT-121 in sync. The import path is None-safe. No blocking issues were found.

No files require special attention.

Important Files Changed

Filename Overview
eu_einvoice/european_e_invoice/custom/sales_invoice.py Adds BT-120 exemption reason text to item-level and document-level zero-rate VAT breakdowns; new helper is only invoked where BT-121 reason code is already present, keeping the two fields in sync. Also adds a defensive getattr guard in _set_seller_id.
eu_einvoice/european_e_invoice/doctype/e_invoice_import/e_invoice_import.py Reads tax.exemption_reason._text from parsed CII XML and stores it in the E Invoice Trade Tax child row; None-safe handling is correct.
eu_einvoice/european_e_invoice/doctype/e_invoice_settings/e_invoice_settings.json Adds a new VAT exemption (e-invoice) section with a Small Text field vat_exemption_reason_text; schema and description are accurate.
eu_einvoice/european_e_invoice/doctype/e_invoice_trade_tax/e_invoice_trade_tax.json Adds vat_exemption_reason_text (Small Text, read-only) to the child table used during invoice import; field order and auto-generated types are consistent.

Sequence Diagram

sequenceDiagram
    participant UI as E Invoice Settings UI
    participant DB as Frappe DB
    participant Gen as EInvoiceGenerator
    participant XML as CII XML

    UI->>DB: Save vat_exemption_reason_text (BT-120)

    note over Gen: create_einvoice()
    Gen->>DB: get_single_value("E Invoice Settings", "vat_exemption_reason_text")
    DB-->>Gen: reason_text (or "")

    alt Zero-rate item (rate == 0)
        Gen->>XML: set exemption_reason_code (BT-121)
        Gen->>XML: set exemption_reason (BT-120) via _set_optional_vat_exemption_reason_text
    end

    alt No taxes (empty invoice)
        Gen->>XML: set exemption_reason_code (BT-121)
        Gen->>XML: set exemption_reason (BT-120) via _set_optional_vat_exemption_reason_text
    end

    note over Gen: Import flow (e_invoice_import.py)
    XML-->>Gen: parse tax.exemption_reason._text
    Gen->>DB: store in E Invoice Trade Tax.vat_exemption_reason_text
Loading

Reviews (1): Last reviewed commit: "feat: add BT-120 VAT exemption reason" | Re-trigger Greptile

@barredterra barredterra self-requested a review April 22, 2026 01:39
Copy link
Copy Markdown
Member

@barredterra barredterra left a comment

Choose a reason for hiding this comment

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

LGTM

@barredterra barredterra merged commit cec83b5 into alyf-de:develop Apr 27, 2026
6 checks passed
@barredterra
Copy link
Copy Markdown
Member

@Mergifyio backport version-16-hotfix version-15-hotfix

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 27, 2026

backport version-16-hotfix version-15-hotfix

✅ Backports have been created

Details

Cherry-pick of cec83b5 has failed:

On branch mergify/bp/version-16-hotfix/pr-247
Your branch is up to date with 'origin/version-16-hotfix'.

You are currently cherry-picking commit cec83b5.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   eu_einvoice/european_e_invoice/custom/sales_invoice.py
	modified:   eu_einvoice/european_e_invoice/doctype/e_invoice_import/e_invoice_import.py
	modified:   eu_einvoice/european_e_invoice/doctype/e_invoice_settings/e_invoice_settings.json
	modified:   eu_einvoice/european_e_invoice/doctype/e_invoice_settings/e_invoice_settings.py
	modified:   eu_einvoice/european_e_invoice/doctype/e_invoice_trade_tax/e_invoice_trade_tax.json
	modified:   eu_einvoice/european_e_invoice/doctype/e_invoice_trade_tax/e_invoice_trade_tax.py

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   eu_einvoice/locale/de.po
	both modified:   eu_einvoice/locale/main.pot

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Cherry-pick of cec83b5 has failed:

On branch mergify/bp/version-15-hotfix/pr-247
Your branch is up to date with 'origin/version-15-hotfix'.

You are currently cherry-picking commit cec83b5.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   eu_einvoice/european_e_invoice/custom/sales_invoice.py
	modified:   eu_einvoice/european_e_invoice/doctype/e_invoice_import/e_invoice_import.py
	modified:   eu_einvoice/european_e_invoice/doctype/e_invoice_settings/e_invoice_settings.json
	modified:   eu_einvoice/european_e_invoice/doctype/e_invoice_settings/e_invoice_settings.py
	modified:   eu_einvoice/european_e_invoice/doctype/e_invoice_trade_tax/e_invoice_trade_tax.json
	modified:   eu_einvoice/european_e_invoice/doctype/e_invoice_trade_tax/e_invoice_trade_tax.py

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   eu_einvoice/locale/de.po
	both modified:   eu_einvoice/locale/main.pot

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

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.

2 participants