Class: Nfe::Transport

Inherits:
Object
  • Object
show all
Defined in:
lib/nfe_reader/transport.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Transport

Fields Values:

modFrete: 0- Por conta do emitente;

1- Por conta do destinat


16
17
18
19
20
21
22
23
24
25
26
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/nfe_reader/transport.rb', line 16

def initialize(attrs = {})
  # Modalidade
  @kind = attrs[:modFrete]
  
  # == Grupo de Retenção do ICMS do transporte
  if attrs[:retTransp]
    # Valor do Servico
    @service_value = attrs[:retTransp][:vServ]
    # BC da Retenção do ICMS
    @base = attrs[:retTransp][:vBCRet]
    # Alíquota da Retenção
    @icms_aliquot = attrs[:retTransp][:pICMSRet]
    # Valor do ICMS Retido
    @icms_value = attrs[:retTransp][:vICMSRet]
    # CFOP
    @cfop = attrs[:retTransp][:CFOP]
    # Municipio gerador de ICMS
    @city = attrs[:retTransp][:cMunFG]
  end

  # == Veiculo
  if attrs[:veicTransp]
    # Placa
    @vehicle_plaque = attrs[:veicTransp][:placa]
    # Estado
    @vehicle_state = attrs[:veicTransp][:UF]
    # Registro Nacional de Transportador de Carga
    @vehicle_rntc = attrs[:veicTransp][:RNTC]
  end

  # == Reboque
  if attrs[:reboque]
    # Placa
    @hauling_palque = attrs[:reboque][:placa]
    # Estado
    @hauling_state = attrs[:reboque][:UF]
    # Registro Nacional de Transportador de Carga
    @hauling_rntc = attrs[:reboque][:RNTC]
  end

  # Vagao
  @wagon = attrs[:vagao]
  # Balsa
  @ferry = attrs[:balsa]
  
  # == Volume
  if attrs[:vol]
    # Quantidade de volumes
    @volume_amount = attrs[:vol][:qVol]
    # Espécie dos volumes
    @volume_kind = attrs[:vol][:esp]
    # Marca dos volumes
    @volume_brand = attrs[:vol][:marca]
    # Numeração dos volumes
    @volume_number = attrs[:vol][:nVol]
    # Peso Liquido
    @weight_net = attrs[:vol][:pesoL]
    # Peso Bruto
    @weight_gross = attrs[:vol][:pesoB]
    # Lacres
    @seals = set_seals(attrs[:vol][:lacres])
  end

  # Transportadora
  if attrs[:transporta]
    @carrier = Nfe::Carrier.new(attrs[:transporta])
  end
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def base
  @base
end

#carrierObject (readonly)

Returns the value of attribute carrier.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def carrier
  @carrier
end

#cfopObject (readonly)

Returns the value of attribute cfop.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def cfop
  @cfop
end

#cityObject (readonly)

Returns the value of attribute city.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def city
  @city
end

#ferryObject (readonly)

Returns the value of attribute ferry.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def ferry
  @ferry
end

#hauling_palqueObject (readonly)

Returns the value of attribute hauling_palque.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def hauling_palque
  @hauling_palque
end

#hauling_rntcObject (readonly)

Returns the value of attribute hauling_rntc.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def hauling_rntc
  @hauling_rntc
end

#hauling_stateObject (readonly)

Returns the value of attribute hauling_state.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def hauling_state
  @hauling_state
end

#icms_aliquotObject (readonly)

Returns the value of attribute icms_aliquot.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def icms_aliquot
  @icms_aliquot
end

#icms_valueObject (readonly)

Returns the value of attribute icms_value.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def icms_value
  @icms_value
end

#kindObject (readonly)

Returns the value of attribute kind.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def kind
  @kind
end

#sealsObject (readonly)

Returns the value of attribute seals.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def seals
  @seals
end

#service_valueObject (readonly)

Returns the value of attribute service_value.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def service_value
  @service_value
end

#vehicle_plaqueObject (readonly)

Returns the value of attribute vehicle_plaque.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def vehicle_plaque
  @vehicle_plaque
end

#vehicle_rntcObject (readonly)

Returns the value of attribute vehicle_rntc.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def vehicle_rntc
  @vehicle_rntc
end

#vehicle_stateObject (readonly)

Returns the value of attribute vehicle_state.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def vehicle_state
  @vehicle_state
end

#volume_amountObject (readonly)

Returns the value of attribute volume_amount.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def volume_amount
  @volume_amount
end

#volume_brandObject (readonly)

Returns the value of attribute volume_brand.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def volume_brand
  @volume_brand
end

#volume_kindObject (readonly)

Returns the value of attribute volume_kind.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def volume_kind
  @volume_kind
end

#volume_numberObject (readonly)

Returns the value of attribute volume_number.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def volume_number
  @volume_number
end

#wagonObject (readonly)

Returns the value of attribute wagon.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def wagon
  @wagon
end

#weight_grossObject (readonly)

Returns the value of attribute weight_gross.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def weight_gross
  @weight_gross
end

#weight_netObject (readonly)

Returns the value of attribute weight_net.



4
5
6
# File 'lib/nfe_reader/transport.rb', line 4

def weight_net
  @weight_net
end

Instance Method Details

#set_seals(attrs = {}) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/nfe_reader/transport.rb', line 85

def set_seals(attrs = {})
  return unless attrs

  if attrs.is_a? Array
    seals = attrs.map { |l| l[:nLacre] }.join(', ')
  else
    seals = attrs[:nLacre]
  end

  seals
end