Repository navigation
Conversation
2 of 4 tasks
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
The document type code (BT-3) is hardcoded to
380(commercial invoice), marked# TODO: make configurable. Credit notes (381) and corrected invoices (384) can therefore not be written; a cancellation goes out as an invoice with negative amounts, which recipients' software books the wrong way.A credit note or correction should also refer to the invoice it relates to (BG-3, preceding invoice reference: BT-25 number, BT-26 issue date). There is no way to write that today.
Finally,
SpecifiedLegalOrganization/ID(BT-30) always carries aschemeID, defaulting to0002(French SIRENE). The scheme is optional in EN 16931 (BT-30-1), and an identifier without a registered scheme — for example a German commercial register entry such asHRB München 123456— would be mislabelled as a SIRENE number.Change
Invoice#type_code(BT-3): written as given,380when not set.Invoice#preceding_invoice_id(BT-25) and#preceding_invoice_issue_date(BT-26, optional): written asInvoiceReferencedDocumentafter the monetary summation, where the CII schema places it. Version 2 only, like attachments.TradeParty#legal_organization:{ id: '...', scheme_id: nil }writes the ID withoutschemeID. Without the key,0002is still the default.Existing callers get the same XML as before. The one behaviour change: a caller that passes
scheme_id: nilexplicitly used to get0002and now gets no scheme.Tests
Six new tests in
test/invoice_test.rb: the type code defaults to 380; a 381 credit note with the preceding invoice and its date, also validated against the schematron (based onmake_eu_invoice, becausemake_de_invoicedoes not pass the version 2 schematron on its own); the preceding invoice without a date; no preceding invoice by default; BT-30 without a scheme; BT-30 still defaults to0002. The full suite passes.