Skip to content

Allow omitted gross prices and payment information - #69

Merged
halfbyte merged 2 commits into
halfbyte:mainfrom
ronald:upstream/optional-xml-elements
Nov 4, 2026
Merged

halfbyte merged 2 commits into
halfbyte:mainfrom
ronald:upstream/optional-xml-elements

Conversation

@ronald

@ronald ronald commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

An invoice line with only a net unit price currently fails with TypeError: can't convert nil into BigDecimal. Both supported XML versions allow the gross unit price to be omitted. Payment means information is also optional, but a missing payment_text currently produces an empty ram:Information element.

This change accepts a missing gross_amount when no line discount is supplied, omits GrossPriceProductTradePrice in that case, and writes Information only when payment_text is supplied. A discount still requires a gross amount and raises Secretariat::ValidationError when it is missing.

Four regression tests cover omitted gross prices in both XML versions, rejection of discounts without a gross price, omitted payment information, and preserved payment information. The generated invoices without gross prices pass the bundled XSD and Schematron validators for ZUGFeRD 1 and 2.

Validation: all 37 tests passed (138 assertions, no failures, errors or skips) on Ruby 3.4.2 with Minitest 5.25.4 and Java 25. StandardRB 1.57.0 reports the same five existing Style/RedundantStructKeywordInit offenses on this branch and on upstream commit 644acab; this change introduces no additional offenses. Tests were run directly with installed gems. Bundler and other Ruby versions were not checked.

@halfbyte
halfbyte merged commit 2a711ad into halfbyte:main Nov 4, 2026
0 of 4 checks passed
@ronald
ronald deleted the upstream/optional-xml-elements branch November 5, 2026 07:36
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