class BillXmlRequest

Public Class Methods

new_xml(*args, &block) click to toggle source
# File lib/bill_xml_request.rb, line 4
def self.new_xml(*args, &block)
  instance = allocate
  instance.my_initialize(*args, &block)
  instance
end

Public Instance Methods

generate_xml_request() click to toggle source

Generate an XML file by CFDI gem

# File lib/bill_xml_request.rb, line 17
def generate_xml_request
  tax_receipt = generate_tax_receipt
  @certificate.certifica tax_receipt
  @key.sella tax_receipt
  tax_receipt.to_xml
end
my_initialize(biller, bill) click to toggle source
# File lib/bill_xml_request.rb, line 10
def my_initialize biller, bill
  @certificate = CFDI::Certificado.new biller[:certificate]
  @key = CFDI::Key.new biller[:key], biller[:password]
  @bill = bill
end

Private Instance Methods

bill_emissor_pass() click to toggle source
# File lib/bill_xml_request.rb, line 26
def bill_emissor_pass
  @bill[:emisor_pass]
end
generate_tax_receipt() click to toggle source
# File lib/bill_xml_request.rb, line 30
def generate_tax_receipt
  tax_receipt = CFDI::Comprobante.new @bill[:factura]
  tax_receipt.emisor = get_tax_receipt_emissor
  tax_receipt.receptor = get_tax_receipt_receptor
  set_tax_receipt_concepts tax_receipt
  tax_receipt.impuestos << get_tax_receipt_taxes
  tax_receipt
end
get_tax_receipt_emissor() click to toggle source
# File lib/bill_xml_request.rb, line 39
def get_tax_receipt_emissor
  @bill[:emisor][:domicilioFiscal] = CFDI::Domicilio.new @bill[:emisor][:domicilioFiscal]
  @bill[:emisor][:expedidoEn] = CFDI::Domicilio.new @bill[:emisor][:expedidoEn]
  CFDI::Entidad.new @bill[:emisor]
end
get_tax_receipt_receptor() click to toggle source
# File lib/bill_xml_request.rb, line 45
def get_tax_receipt_receptor
  @bill[:cliente][:domicilioFiscal] = CFDI::Domicilio.new @bill[:cliente][:domicilioFiscal]
  CFDI::Entidad.new @bill[:cliente]
end
get_tax_receipt_taxes() click to toggle source
# File lib/bill_xml_request.rb, line 56
def get_tax_receipt_taxes
  @bill[:impuestos]
end
set_tax_receipt_concepts(tax_receipt) click to toggle source
# File lib/bill_xml_request.rb, line 50
def set_tax_receipt_concepts tax_receipt
  @bill[:conceptos].each do |concept|
    tax_receipt.conceptos << CFDI::Concepto.new(concept)
  end
end