Module: Einvoicing::Formats::CII

Defined in:
lib/einvoicing/formats/cii.rb

Overview

Generates CII D16B (Cross Industry Invoice) XML compliant with EN 16931 and the Factur-X EN16931 profile.

Examples:

xml = Einvoicing::Formats::CII.generate(invoice)
File.write("invoice.xml", xml)

Constant Summary collapse

GUIDELINE_ID =
"urn:cen.eu:en16931:2017"
RSM_NS =
"urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"
RAM_NS =
"urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
UDT_NS =
"urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100"
QDT_NS =
"urn:un:unece:uncefact:data:standard:QualifiedDataType:100"

Class Method Summary collapse

Class Method Details

.generate(invoice, profile: :en16931) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/einvoicing/formats/cii.rb', line 19

def self.generate(invoice, profile: :en16931)
  b = XMLBuilder.new
  b.tag(
    "rsm:CrossIndustryInvoice",
    "xmlns:rsm" => RSM_NS,
    "xmlns:ram" => RAM_NS,
    "xmlns:udt" => UDT_NS,
    "xmlns:qdt" => QDT_NS,
    "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance"
  ) do
    exchanged_document_context(b)
    exchanged_document(b, invoice)
    supply_chain_trade_transaction(b, invoice, profile)
  end
  b.to_xml
end