Skip to content

Write the payment terms text (BT-20) only when given - #68

Open
ahmedm10 wants to merge 1 commit into
halfbyte:mainfrom
konvenit:MP-53297-payment-terms-upstream
Open

ahmedm10 wants to merge 1 commit into
halfbyte:mainfrom
konvenit:MP-53297-payment-terms-upstream

Conversation

@ahmedm10

Copy link
Copy Markdown
Contributor

Problem

Invoice#to_xml always writes SpecifiedTradePaymentTerms with a Description (BT-20, payment terms). Without a payment_terms_text, the description defaults to "Paid". That states something the invoice doesn't know: an unpaid invoice tells its receiver it has been paid. BT-20 is optional in EN 16931; a due date (BT-9) alone satisfies BR-CO-25.

Change

  • Description is written only when payment_terms_text is given.
  • SpecifiedTradePaymentTerms is written only when there is a text, a due date or a direct debit mandate reference; with none of them it's left out instead of written empty.

Callers that pass a text get the same XML as before. A caller passing no text no longer gets "Paid".

Tests

Three new tests in test/invoice_test.rb: the text is still written when given; without one, there's no description but the due date stays, validated against the schematron; with no text, due date or mandate, the element is left out. The full suite passes.

Drops the "Paid" default for BT-20; a due date alone is enough
(BR-CO-25), and no terms at all omit the element.
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.

1 participant