Skip to content

Make the line item origin country (BT-159) optional - #65

Merged
halfbyte merged 1 commit into
halfbyte:mainfrom
konvenit:MP-53297-optional-origin-country-upstream
Oct 21, 2026
Merged

halfbyte merged 1 commit into
halfbyte:mainfrom
konvenit:MP-53297-optional-origin-country-upstream

Conversation

@ahmedm10

@ahmedm10 ahmedm10 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

LineItem#to_xml always writes SpecifiedTradeProduct/OriginTradeCountry (BT-159, item country of origin). Without an origin_country_code the element is written empty (<ram:ID/>), which the country code-list rules reject. BT-159 is optional in EN 16931, and many invoices have no meaningful value for it: it describes where goods were made, which a service (a hotel night, a fee, a commission) doesn't have.

Change

  • OriginTradeCountry is written only when origin_country_code isn't blank.

Callers that pass a code get the same XML as before. A caller passing no code now gets no element instead of an empty one.

Tests

Two new tests in test/invoice_test.rb: the origin country is still written when given; lines without one leave the element out, also validated against the schematron (based on make_eu_invoice). The full suite passes.

OriginTradeCountry (EN 16931 BT-159) was always written, empty when no
origin_country_code was given. It is optional, and a service has no
country of origin, so it is now left out when the code is blank.
@ahmedm10
ahmedm10 marked this pull request as ready for review October 20, 2026 16:03
@halfbyte
halfbyte merged commit b535ac3 into halfbyte:main Oct 21, 2026
4 checks passed
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