Repository navigation
Make the line item origin country (BT-159) optional - #65
Merged
halfbyte merged 1 commit intoOct 21, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
LineItem#to_xmlalways writesSpecifiedTradeProduct/OriginTradeCountry(BT-159, item country of origin). Without anorigin_country_codethe 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
OriginTradeCountryis written only whenorigin_country_codeisn'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 onmake_eu_invoice). The full suite passes.