Class: UnovaFacturX::XmlGenerator
- Inherits:
-
Object
- Object
- UnovaFacturX::XmlGenerator
- Defined in:
- lib/unova_factur_x/xml_generator.rb
Constant Summary collapse
- VALIDATION_PROFILES =
{ br_fr: "validators/BR-FR-CII-validation-V1.3.1.xsl", en16931: "validators/EN16931-CII-validation.xslt" }.freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(document, type: :invoice, currency: "EUR", validate: true, validator_profile: :br_fr) ⇒ Nokogiri::XML::Document
constructor
The generated XML document.
Constructor Details
#initialize(document, type: :invoice, currency: "EUR", validate: true, validator_profile: :br_fr) ⇒ Nokogiri::XML::Document
Returns The generated XML document.
15 16 17 18 19 20 21 |
# File 'lib/unova_factur_x/xml_generator.rb', line 15 def initialize(document, type: :invoice, currency: "EUR", validate: true, validator_profile: :br_fr) @document = document @type = type @currency = currency @validate = validate @validator_profile = VALIDATION_PROFILES.has_key?(validator_profile.to_sym) ? validator_profile : :br_fr end |
Instance Method Details
#call ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/unova_factur_x/xml_generator.rb', line 23 def call builder = ::Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml| xml['rsm'].CrossIndustryInvoice( 'xmlns:rsm' => 'urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100', 'xmlns:udt' => 'urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100', 'xmlns:qdt' => 'urn:un:unece:uncefact:data:standard:QualifiedDataType:100', 'xmlns:ram' => 'urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100' ) do build_exchanged_document_context(xml) build_exchanged_document(xml) build_supply_chain_trade_transaction(xml) end end validate_with_xslt!(builder.doc, profile: @validator_profile) if @validate # Returns the XML document builder.doc end |