Module: Einvoicing::Formats::UBL
- Defined in:
- lib/einvoicing/formats/ubl.rb
Overview
Generates UBL 2.1 XML compliant with EN 16931 / Peppol BIS Billing 3.0.
Constant Summary collapse
- CUSTOMIZATION_ID =
"urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0"- PROFILE_ID =
"urn:fdc:peppol.eu:2017:poacc:billing:01:1.0"- UBL_NS =
"urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"- UBL_CREDIT_NOTE_NS =
"urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2"- CAC_NS =
"urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"- CBC_NS =
"urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
Class Method Summary collapse
Class Method Details
.generate(invoice) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/einvoicing/formats/ubl.rb', line 19 def self.generate(invoice) b = XMLBuilder.new credit_note = invoice.document_type == :credit_note root_ns = credit_note ? UBL_CREDIT_NOTE_NS : UBL_NS root_tag = credit_note ? "CreditNote" : "Invoice" b.tag( root_tag, "xmlns" => root_ns, "xmlns:cac" => CAC_NS, "xmlns:cbc" => CBC_NS ) do header(b, invoice) supplier_party(b, invoice.seller) customer_party(b, invoice.buyer) billing_reference(b, invoice) if credit_note && invoice.original_invoice_number payment_means(b, invoice) if invoice.payment_means_code tax_total(b, invoice) monetary_total(b, invoice) invoice.lines.each_with_index do |line, idx| invoice_line(b, line, idx + 1, invoice.currency) end end b.to_xml end |