Class: Ticketbai::Nodes::LroeIssuedInvoices

Inherits:
Object
  • Object
show all
Defined in:
lib/ticketbai/nodes/lroe_issued_invoices.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ LroeIssuedInvoices

Returns a new instance of LroeIssuedInvoices.



4
5
6
7
# File 'lib/ticketbai/nodes/lroe_issued_invoices.rb', line 4

def initialize(args = {})
  @issued_invoices = args[:issued_invoices]
  @operation = args[:operation]
end

Instance Method Details

#build_xml(node) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ticketbai/nodes/lroe_issued_invoices.rb', line 9

def build_xml(node)
  node = Nokogiri::XML::Builder.new if node.nil?
  node.FacturasEmitidas do |xml|
    @issued_invoices.each do |issued_invoice|
      xml.FacturaEmitida do
        case @operation
        when :annulment
          xml.AnulacionTicketBai Base64.strict_encode64(issued_invoice)
        when :issuance
          xml.TicketBai Base64.strict_encode64(issued_invoice)
        when :issuance_unsigned
          xml << issued_invoice
        end
      end
    end
  end
end