Class: BrNfe::Product::Nfe::Transporte::Base

Inherits:
ActiveModelBase show all
Defined in:
lib/br_nfe/product/nfe/transporte/base.rb

Instance Attribute Summary collapse

Attributes inherited from ActiveModelBase

#reference

Instance Method Summary collapse

Methods inherited from ActiveModelBase

#assign_attributes, #initialize

Constructor Details

This class inherits a constructor from BrNfe::ActiveModelBase

Instance Attribute Details

#forma_transporteObject

Attr utilizado para saber como será validado os dados do ‘veiculo’ utilizado para transportar a carga.

Type: Symbol Allowed: _:veiculo, :balsa, :vagao_ Required: Yes Default: :veiculo



113
114
115
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 113

def forma_transporte
  @forma_transporte
end

#identificacao_balsaObject

Identificação da balsa (v2.0)

Type: String Required: No (Yes if forma_transporte == :balsa) tag: balsa



133
134
135
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 133

def identificacao_balsa
  @identificacao_balsa
end

#identificacao_vagaoObject

Identificação do vagao (v2.0)

Type: String Required: No (Yes if forma_transporte == :vagao) tag: vagao



142
143
144
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 142

def identificacao_vagao
  @identificacao_vagao
end

#modalidade_freteObject

Modalidade do frete 0- Por conta do emitente; 1- Por conta do destinatário/remetente; 2- Por conta de terceiros; 9- Sem frete

Type: Number Required: Yes Default: 9 Length: 1 tag: modFrete



19
20
21
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 19

def modalidade_frete
  @modalidade_frete
end

#retencao_aliquotaObject

Percentual de aliquota da retenção do ICMS Exemplo:

Se a aliquota for de 2,56% ent

Type: Float Required: No Default: nil tag: pICMSRet



66
67
68
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 66

def retencao_aliquota
  @retencao_aliquota
end

#retencao_base_calculo_icmsObject

Base de Cálculo da Retenção do ICMS

Type: Float Required: No Default: nil tag: vBCRet



53
54
55
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 53

def retencao_base_calculo_icms
  @retencao_base_calculo_icms
end

#retencao_cfopObject

CFOP de Serviço de Transporte

Type: Number Required: No (Yes if retencao_icms?) Default: nil tag: CFOP



91
92
93
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 91

def retencao_cfop
  @retencao_cfop
end

#retencao_codigo_municipioObject

Código do município de ocorrência do fato gerador do ICMS do transporte

Type: Number Required: No (Yes if retencao_icms?) Default: nil tag: cMunFG



102
103
104
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 102

def retencao_codigo_municipio
  @retencao_codigo_municipio
end

#retencao_valor_icmsObject

Valor do ICMS Retido Caso não seja setado nenhum valor, irá calcular automaticamente através dos atributos ‘retencao_base_calculo_icms’ e ‘retencao_aliquota’

Type: Float Required: No Default: nil tag: vICMSRet



78
79
80
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 78

def retencao_valor_icms
  @retencao_valor_icms
end

#retencao_valor_sevicoObject

Valor do serviço

Type: Float Required: No Default: nil tag: vServ



43
44
45
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 43

def retencao_valor_sevico
  @retencao_valor_sevico
end

Instance Method Details

#default_valuesObject



203
204
205
206
207
208
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 203

def default_values
  {
    modalidade_frete: 9,        # 9 = Sem frete
    forma_transporte: :veiculo, # Define qualer tipo de veículo terrestre (Caminhão, van, etc..)
  }
end

#forma_transporte_balsa?Boolean

Returns:

  • (Boolean)


241
242
243
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 241

def forma_transporte_balsa?
  forma_transporte == :balsa
end

#forma_transporte_vagao?Boolean

Returns:

  • (Boolean)


245
246
247
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 245

def forma_transporte_vagao?
  forma_transporte == :vagao
end

#forma_transporte_veiculo?Boolean

Returns:

  • (Boolean)


237
238
239
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 237

def forma_transporte_veiculo?
  forma_transporte == :veiculo
end

#have_carriage?Boolean

Returns:

  • (Boolean)


233
234
235
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 233

def have_carriage?
  modalidade_frete.to_i != 9
end

#retencao_icms?Boolean

Método para saber se há retenção de ICMS, e se houver, aplica as validações e adiciona a tag no XML

Type: Boolean tag: retTransp

Returns:

  • (Boolean)


32
33
34
# File 'lib/br_nfe/product/nfe/transporte/base.rb', line 32

def retencao_icms?
  retencao_valor_sevico.to_f > 0.0
end