Class: Ticketbai::Documents::Issuance

Inherits:
Ticketbai::Document show all
Defined in:
lib/ticketbai/documents/issuance.rb

Constant Summary collapse

ROOT_NAME =
'T:TicketBai'.freeze
XMLNS =
{
  'xmlns:T' => 'urn:ticketbai:emision'
}.freeze
ATTRIBUTES =
%i[issuer receiver invoice_header invoice_data breakdown_type invoice_chaining software].freeze

Constants inherited from Ticketbai::Document

Ticketbai::Document::TBAI_VERSION

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ Issuance

Returns a new instance of Issuance.

Parameters:



22
23
24
# File 'lib/ticketbai/documents/issuance.rb', line 22

def initialize(**args)
  super(args)
end

Instance Method Details

#createNokogiri::XML::Builder

Returns:

  • (Nokogiri::XML::Builder)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ticketbai/documents/issuance.rb', line 27

def create
  builder = Nokogiri::XML::Builder.new(encoding: Encoding::UTF_8.to_s) do |xml|
    xml.TicketBai(XMLNS) do
      xml.Cabecera do
        xml.IDVersionTBAI TBAI_VERSION
      end
      xml.Sujetos do
        @issuer.build_xml(xml)
        @receiver&.build_xml(xml)
      end
      xml.Factura do
        @invoice_header.build_xml(xml)
        @invoice_data.build_xml(xml)
        @breakdown_type.build_xml(xml)
      end
      xml.HuellaTBAI do
        @invoice_chaining&.build_xml(xml)
        @software.build_xml(xml)
      end
    end
  end

  modify_xml_root_name(builder)

  builder
end