Class: FE::Document::OtherContent::PriceSmart

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/facturacr/document/other_content/price_smart.rb

Constant Summary collapse

TYPES =
['purchase', 'expense']
NAMESPACES =
{
  "xsi:schemaLocation" => "https://invoicer.ekomercio.com/esquemas https://invoices/ekomercio.com/esquemas/ComplementoPricesmartCR_V1_0.xsd",
  "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
  "xmlns:retail" => "https://invoicer.ekomercio.com/esquemas"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ PriceSmart

Returns a new instance of PriceSmart.



27
28
29
30
31
32
33
# File 'lib/facturacr/document/other_content/price_smart.rb', line 27

def initialize(args={})
  @transaction_type = args[:transaction_type]
  @supplier_number = args[:supplier_number]
  @store_code = args[:store_code]
  @order_number = args[:order_number]
  @order_date = args[:order_date]
end

Instance Attribute Details

#order_dateObject

Returns the value of attribute order_date.



6
7
8
# File 'lib/facturacr/document/other_content/price_smart.rb', line 6

def order_date
  @order_date
end

#order_numberObject

Returns the value of attribute order_number.



6
7
8
# File 'lib/facturacr/document/other_content/price_smart.rb', line 6

def order_number
  @order_number
end

#store_codeObject

Returns the value of attribute store_code.



6
7
8
# File 'lib/facturacr/document/other_content/price_smart.rb', line 6

def store_code
  @store_code
end

#supplier_numberObject

Returns the value of attribute supplier_number.



6
7
8
# File 'lib/facturacr/document/other_content/price_smart.rb', line 6

def supplier_number
  @supplier_number
end

#transaction_typeObject

Returns the value of attribute transaction_type.



6
7
8
# File 'lib/facturacr/document/other_content/price_smart.rb', line 6

def transaction_type
  @transaction_type
end

Instance Method Details

#build_xml(node) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/facturacr/document/other_content/price_smart.rb', line 35

def build_xml(node)
  raise "Invalid Record: #{errors.messages}" unless valid?
  node = Nokogiri::XML::Builder.new if node.nil?         
  node['retail'].Complemento(NAMESPACES) do |xml|
    xml['retail'].NumeroVendedor @supplier_number
    if purchase?
      xml['retail'].OrdenDeCompra do |xml2|
        xml2['retail'].NumeroOrden @order_number
        xml2['retail'].FechaOrden @order_date.xmlschema
      end
    end
    xml['retail'].LugarDeEntrega do |xml2|
      xml2['retail'].GLNLugarDeEntrega @store_code
    end
  end
end

#to_xml(builder) ⇒ Object



52
53
54
# File 'lib/facturacr/document/other_content/price_smart.rb', line 52

def to_xml(builder)
  build_xml(builder)
end