Class: BrNfe::Service::Response::Build::InvoiceBuild

Inherits:
Base show all
Includes:
Paths::V1::TcNfse
Defined in:
lib/br_nfe/service/response/build/invoice_build.rb

Direct Known Subclasses

ConsultaLoteRps, ConsultaNfsPorRps, ConsultaNfse

Instance Attribute Summary collapse

Attributes inherited from Base

#body_xml_path, #keys_root_path, #lot_number_path, #message_code_key, #message_errors_path, #message_msg_key, #message_solution_key, #savon_response, #xml_encode

Attributes inherited from ActiveModelBase

#reference

Instance Method Summary collapse

Methods inherited from Base

#body_converted_to_xml, #find_value_for_keys, #get_lot_number, #get_message_for_hash, #get_message_for_path, #path_with_root, #response, #savon_body

Methods inherited from ActiveModelBase

#assign_attributes, #initialize

Constructor Details

This class inherits a constructor from BrNfe::ActiveModelBase

Instance Attribute Details

#invoice_base_calculo_pathObject

Valor da base de cálculo



51
52
53
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 51

def invoice_base_calculo_path
  @invoice_base_calculo_path
end

#invoice_cancelamento_cnpj_pathObject

CNPJ da NF cancelada



63
64
65
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 63

def invoice_cancelamento_cnpj_path
  @invoice_cancelamento_cnpj_path
end

#invoice_cancelamento_codigo_pathObject

Código do cancelamento da NFS



61
62
63
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 61

def invoice_cancelamento_codigo_path
  @invoice_cancelamento_codigo_path
end

#invoice_cancelamento_data_hora_pathObject

Data e hora do cancelamento



65
66
67
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 65

def invoice_cancelamento_data_hora_path
  @invoice_cancelamento_data_hora_path
end

#invoice_cancelamento_inscricao_municipal_pathObject

Inscrição municipal da nota cancelada



66
67
68
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 66

def invoice_cancelamento_inscricao_municipal_path
  @invoice_cancelamento_inscricao_municipal_path
end

#invoice_cancelamento_municipio_pathObject

Municipo da nota cancelada



64
65
66
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 64

def invoice_cancelamento_municipio_path
  @invoice_cancelamento_municipio_path
end

#invoice_cancelamento_numero_nf_pathObject

Número da NFS cancelada



62
63
64
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 62

def invoice_cancelamento_numero_nf_path
  @invoice_cancelamento_numero_nf_path
end

#invoice_cnae_code_pathObject

CNAE utilizado na nf



38
39
40
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 38

def invoice_cnae_code_path
  @invoice_cnae_code_path
end

#invoice_codigo_art_pathObject

Código art



69
70
71
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 69

def invoice_codigo_art_path
  @invoice_codigo_art_path
end

#invoice_codigo_municipio_pathObject

Código do municipio prestador do serviço



40
41
42
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 40

def invoice_codigo_municipio_path
  @invoice_codigo_municipio_path
end

#invoice_codigo_obra_pathObject

Código obra



68
69
70
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 68

def invoice_codigo_obra_path
  @invoice_codigo_obra_path
end

#invoice_codigo_verificacao_pathObject

código de verificação



20
21
22
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 20

def invoice_codigo_verificacao_path
  @invoice_codigo_verificacao_path
end

#invoice_competencia_pathObject

Competência da nf



31
32
33
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 31

def invoice_competencia_path
  @invoice_competencia_path
end

#invoice_data_emissao_pathObject

Data de emissão da NF



21
22
23
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 21

def invoice_data_emissao_path
  @invoice_data_emissao_path
end

#invoice_data_emissao_rps_pathObject

Data de emissão do RPS



30
31
32
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 30

def invoice_data_emissao_rps_path
  @invoice_data_emissao_rps_path
end

#invoice_deducoes_pathObject

Valor das deduções



42
43
44
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 42

def invoice_deducoes_path
  @invoice_deducoes_path
end

#invoice_desconto_condicionado_pathObject

Valor do desconto condicionado



54
55
56
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 54

def invoice_desconto_condicionado_path
  @invoice_desconto_condicionado_path
end

#invoice_desconto_incondicionado_pathObject

Valor do desconto incondicionado



55
56
57
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 55

def invoice_desconto_incondicionado_path
  @invoice_desconto_incondicionado_path
end

#invoice_description_pathObject

Descrição da nf



39
40
41
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 39

def invoice_description_path
  @invoice_description_path
end

#invoice_destinatario_cnpj_pathObject

Cnpj do destinatário da NFS



84
85
86
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 84

def invoice_destinatario_cnpj_path
  @invoice_destinatario_cnpj_path
end

#invoice_destinatario_cpf_pathObject

Cpf do destinatário da NFS



83
84
85
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 83

def invoice_destinatario_cpf_path
  @invoice_destinatario_cpf_path
end

#invoice_destinatario_email_pathObject

Email do destinatário da NFS



90
91
92
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 90

def invoice_destinatario_email_path
  @invoice_destinatario_email_path
end

#invoice_destinatario_endereco_bairro_pathObject

Bairro do destinatário da NFS



94
95
96
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 94

def invoice_destinatario_endereco_bairro_path
  @invoice_destinatario_endereco_bairro_path
end

#invoice_destinatario_endereco_cep_pathObject

Cep do destinatário da NFS



97
98
99
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 97

def invoice_destinatario_endereco_cep_path
  @invoice_destinatario_endereco_cep_path
end

#invoice_destinatario_endereco_codigo_municipio_pathObject

Codigo_municipio do destinatário da NFS



95
96
97
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 95

def invoice_destinatario_endereco_codigo_municipio_path
  @invoice_destinatario_endereco_codigo_municipio_path
end

#invoice_destinatario_endereco_complemento_pathObject

Complemento do destinatário da NFS



93
94
95
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 93

def invoice_destinatario_endereco_complemento_path
  @invoice_destinatario_endereco_complemento_path
end

#invoice_destinatario_endereco_logradouro_pathObject

Logradouro do destinatário da NFS



91
92
93
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 91

def invoice_destinatario_endereco_logradouro_path
  @invoice_destinatario_endereco_logradouro_path
end

#invoice_destinatario_endereco_numero_pathObject

Numero do destinatário da NFS



92
93
94
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 92

def invoice_destinatario_endereco_numero_path
  @invoice_destinatario_endereco_numero_path
end

#invoice_destinatario_endereco_uf_pathObject

Uf do destinatário da NFS



96
97
98
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 96

def invoice_destinatario_endereco_uf_path
  @invoice_destinatario_endereco_uf_path
end

#invoice_destinatario_inscricao_estadual_pathObject

Inscricao estadual do destinatário da NFS



86
87
88
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 86

def invoice_destinatario_inscricao_estadual_path
  @invoice_destinatario_inscricao_estadual_path
end

#invoice_destinatario_inscricao_municipal_pathObject

Inscricao municipal do destinatário da NFS



85
86
87
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 85

def invoice_destinatario_inscricao_municipal_path
  @invoice_destinatario_inscricao_municipal_path
end

#invoice_destinatario_inscricao_suframa_pathObject

Inscricao suframa do destinatário da NFS



87
88
89
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 87

def invoice_destinatario_inscricao_suframa_path
  @invoice_destinatario_inscricao_suframa_path
end

#invoice_destinatario_razao_social_pathObject

Razao social do destinatário da NFS



88
89
90
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 88

def invoice_destinatario_razao_social_path
  @invoice_destinatario_razao_social_path
end

#invoice_destinatario_telefone_pathObject

Telefone do destinatário da NFS



89
90
91
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 89

def invoice_destinatario_telefone_path
  @invoice_destinatario_telefone_path
end

#invoice_emitente_cnpj_pathObject

Cnpj do emitente da NFS



70
71
72
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 70

def invoice_emitente_cnpj_path
  @invoice_emitente_cnpj_path
end

#invoice_emitente_email_pathObject

Email do emitente da NFS



75
76
77
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 75

def invoice_emitente_email_path
  @invoice_emitente_email_path
end

#invoice_emitente_endereco_bairro_pathObject

Bairro do emitente da NFS



79
80
81
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 79

def invoice_emitente_endereco_bairro_path
  @invoice_emitente_endereco_bairro_path
end

#invoice_emitente_endereco_cep_pathObject

Cep do emitente da NFS



82
83
84
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 82

def invoice_emitente_endereco_cep_path
  @invoice_emitente_endereco_cep_path
end

#invoice_emitente_endereco_codigo_municipio_pathObject

Codigo_municipio do emitente da NFS



80
81
82
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 80

def invoice_emitente_endereco_codigo_municipio_path
  @invoice_emitente_endereco_codigo_municipio_path
end

#invoice_emitente_endereco_complemento_pathObject

Complemento do emitente da NFS



78
79
80
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 78

def invoice_emitente_endereco_complemento_path
  @invoice_emitente_endereco_complemento_path
end

#invoice_emitente_endereco_logradouro_pathObject

Logradouro do emitente da NFS



76
77
78
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 76

def invoice_emitente_endereco_logradouro_path
  @invoice_emitente_endereco_logradouro_path
end

#invoice_emitente_endereco_numero_pathObject

Numero do emitente da NFS



77
78
79
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 77

def invoice_emitente_endereco_numero_path
  @invoice_emitente_endereco_numero_path
end

#invoice_emitente_endereco_uf_pathObject

Uf do emitente da NFS



81
82
83
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 81

def invoice_emitente_endereco_uf_path
  @invoice_emitente_endereco_uf_path
end

#invoice_emitente_inscricao_municipal_pathObject

Inscricao municipal do emitente da NFS



71
72
73
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 71

def invoice_emitente_inscricao_municipal_path
  @invoice_emitente_inscricao_municipal_path
end

#invoice_emitente_nome_fantasia_pathObject

Nome fantasia do emitente da NFS



73
74
75
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 73

def invoice_emitente_nome_fantasia_path
  @invoice_emitente_nome_fantasia_path
end

#invoice_emitente_razao_social_pathObject

Razao social do emitente da NFS



72
73
74
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 72

def invoice_emitente_razao_social_path
  @invoice_emitente_razao_social_path
end

#invoice_emitente_telefone_pathObject

Telefone do emitente da NFS



74
75
76
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 74

def invoice_emitente_telefone_path
  @invoice_emitente_telefone_path
end

#invoice_incentivador_cultural_pathObject

Incentivo cultural



35
36
37
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 35

def invoice_incentivador_cultural_path
  @invoice_incentivador_cultural_path
end

#invoice_iss_aliquota_pathObject

Percentual do imposto de ISS



52
53
54
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 52

def invoice_iss_aliquota_path
  @invoice_iss_aliquota_path
end

#invoice_iss_retido_pathObject

Se o ISS está retido



48
49
50
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 48

def invoice_iss_retido_path
  @invoice_iss_retido_path
end

#invoice_item_lista_servico_pathObject

Código do serviço prestado



37
38
39
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 37

def invoice_item_lista_servico_path
  @invoice_item_lista_servico_path
end

#invoice_municipio_incidencia_pathObject

Código do municipio em que o serviço foi prestado



58
59
60
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 58

def invoice_municipio_incidencia_path
  @invoice_municipio_incidencia_path
end

#invoice_natureza_operacao_pathObject

natureza de operação



32
33
34
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 32

def invoice_natureza_operacao_path
  @invoice_natureza_operacao_path
end

#invoice_nfe_substituidora_pathObject

Número da NFS substituidora



67
68
69
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 67

def invoice_nfe_substituidora_path
  @invoice_nfe_substituidora_path
end

#invoice_numero_nf_pathObject

numero da nota fiscal



19
20
21
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 19

def invoice_numero_nf_path
  @invoice_numero_nf_path
end

#invoice_numero_processo_pathObject

Número do processo da NF



57
58
59
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 57

def invoice_numero_processo_path
  @invoice_numero_processo_path
end

#invoice_optante_simples_nacional_pathObject

Se é optante do simples



34
35
36
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 34

def invoice_optante_simples_nacional_path
  @invoice_optante_simples_nacional_path
end

#invoice_orgao_gerador_municipio_pathObject

Órgão gerador municipal da NFS



59
60
61
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 59

def invoice_orgao_gerador_municipio_path
  @invoice_orgao_gerador_municipio_path
end

#invoice_orgao_gerador_uf_pathObject

Órgão gerador estadual da NFS



60
61
62
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 60

def invoice_orgao_gerador_uf_path
  @invoice_orgao_gerador_uf_path
end

#invoice_outras_informacoes_pathObject

Outras informações da nf



36
37
38
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 36

def invoice_outras_informacoes_path
  @invoice_outras_informacoes_path
end

#invoice_outras_retencoes_pathObject

Valor Outras retenções



49
50
51
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 49

def invoice_outras_retencoes_path
  @invoice_outras_retencoes_path
end

#invoice_regime_especial_tributacao_pathObject

Regime especial de tributação



33
34
35
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 33

def invoice_regime_especial_tributacao_path
  @invoice_regime_especial_tributacao_path
end

#invoice_responsavel_retencao_pathObject

Responsável pela retenção



56
57
58
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 56

def invoice_responsavel_retencao_path
  @invoice_responsavel_retencao_path
end

#invoice_rps_numero_pathObject

Número do RPS da nota



23
24
25
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 23

def invoice_rps_numero_path
  @invoice_rps_numero_path
end

#invoice_rps_serie_pathObject

Número da série do RPS da nota



24
25
26
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 24

def invoice_rps_serie_path
  @invoice_rps_serie_path
end

#invoice_rps_situacao_pathObject

Situação da NF



26
27
28
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 26

def invoice_rps_situacao_path
  @invoice_rps_situacao_path
end

#invoice_rps_substituido_numero_pathObject

Número do RPS da nota substituido



27
28
29
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 27

def invoice_rps_substituido_numero_path
  @invoice_rps_substituido_numero_path
end

#invoice_rps_substituido_serie_pathObject

Número da série do RPS da nota substituido



28
29
30
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 28

def invoice_rps_substituido_serie_path
  @invoice_rps_substituido_serie_path
end

#invoice_rps_substituido_tipo_pathObject

Tipo do RPS substituido



29
30
31
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 29

def invoice_rps_substituido_tipo_path
  @invoice_rps_substituido_tipo_path
end

#invoice_rps_tipo_pathObject

Tipo do RPS



25
26
27
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 25

def invoice_rps_tipo_path
  @invoice_rps_tipo_path
end

#invoice_total_iss_pathObject

Valor total de ISS



50
51
52
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 50

def invoice_total_iss_path
  @invoice_total_iss_path
end

#invoice_url_nf_pathObject

URL para visualizar a DANFE (apenas alguns emissores disponibilizam isso)



22
23
24
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 22

def invoice_url_nf_path
  @invoice_url_nf_path
end

#invoice_valor_cofins_pathObject

Valor do COFINS



44
45
46
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 44

def invoice_valor_cofins_path
  @invoice_valor_cofins_path
end

#invoice_valor_csll_pathObject

Valor da CSLL



47
48
49
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 47

def invoice_valor_csll_path
  @invoice_valor_csll_path
end

#invoice_valor_inss_pathObject

Valor do INSS



45
46
47
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 45

def invoice_valor_inss_path
  @invoice_valor_inss_path
end

#invoice_valor_ir_pathObject

Valor do IR



46
47
48
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 46

def invoice_valor_ir_path
  @invoice_valor_ir_path
end

#invoice_valor_liquido_pathObject

Valor liquido da NFS



53
54
55
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 53

def invoice_valor_liquido_path
  @invoice_valor_liquido_path
end

#invoice_valor_pis_pathObject

Valor do PIS



43
44
45
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 43

def invoice_valor_pis_path
  @invoice_valor_pis_path
end

#invoice_valor_total_servicos_pathObject

Valor total dos serviços



41
42
43
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 41

def invoice_valor_total_servicos_path
  @invoice_valor_total_servicos_path
end

#invoices_pathObject

Caminho para encontrar



18
19
20
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 18

def invoices_path
  @invoices_path
end

#nfe_xml_pathObject

Caminho para encontrar o XML da NF-e



13
14
15
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 13

def nfe_xml_path
  @nfe_xml_path
end

Instance Method Details

#build_cancelation_fields_nfe(nfe, invoice_hash) ⇒ Object



279
280
281
282
283
284
285
286
287
288
289
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 279

def build_cancelation_fields_nfe(nfe, invoice_hash)
	nfe.assign_attributes({
		cancelamento_codigo:              find_value_for_keys(invoice_hash, invoice_cancelamento_codigo_path             ),
		cancelamento_numero_nf:           find_value_for_keys(invoice_hash, invoice_cancelamento_numero_nf_path          ),
		cancelamento_cnpj:                find_value_for_keys(invoice_hash, invoice_cancelamento_cnpj_path               ),
		cancelamento_inscricao_municipal: find_value_for_keys(invoice_hash, invoice_cancelamento_inscricao_municipal_path),
		cancelamento_municipio:           find_value_for_keys(invoice_hash, invoice_cancelamento_municipio_path          ),
		cancelamento_data_hora:           find_value_for_keys(invoice_hash, invoice_cancelamento_data_hora_path          ),
		nfe_substituidora:                find_value_for_keys(invoice_hash, invoice_nfe_substituidora_path               ),
	})
end

#build_destinatario_nfe(nfe, invoice_hash) ⇒ Object



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 333

def build_destinatario_nfe(nfe, invoice_hash)
	nfe.assign_attributes({
		destinatario: {
			cpf_cnpj: (find_value_for_keys(invoice_hash, invoice_destinatario_cpf_path) || find_value_for_keys(invoice_hash, invoice_destinatario_cnpj_path)),
			inscricao_municipal:       find_value_for_keys(invoice_hash, invoice_destinatario_inscricao_municipal_path),
			inscricao_estadual:        find_value_for_keys(invoice_hash, invoice_destinatario_inscricao_estadual_path),
			inscricao_suframa:         find_value_for_keys(invoice_hash, invoice_destinatario_inscricao_suframa_path),
			razao_social:              find_value_for_keys(invoice_hash, invoice_destinatario_razao_social_path),
			telefone:                  find_value_for_keys(invoice_hash, invoice_destinatario_telefone_path),
			email:                     find_value_for_keys(invoice_hash, invoice_destinatario_email_path),
			endereco: {
				logradouro:             find_value_for_keys(invoice_hash, invoice_destinatario_endereco_logradouro_path),
				numero:                 find_value_for_keys(invoice_hash, invoice_destinatario_endereco_numero_path),
				complemento:            find_value_for_keys(invoice_hash, invoice_destinatario_endereco_complemento_path),
				bairro:                 find_value_for_keys(invoice_hash, invoice_destinatario_endereco_bairro_path),
				codigo_municipio:       find_value_for_keys(invoice_hash, invoice_destinatario_endereco_codigo_municipio_path),
				uf:                     find_value_for_keys(invoice_hash, invoice_destinatario_endereco_uf_path),
				cep:                    find_value_for_keys(invoice_hash, invoice_destinatario_endereco_cep_path),
			}
		}
	})
end

#build_emitente_nfe(nfe, invoice_hash) ⇒ Object



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 311

def build_emitente_nfe(nfe, invoice_hash)
	nfe.assign_attributes({
		emitente: {
			cnpj:                find_value_for_keys(invoice_hash, invoice_emitente_cnpj_path                  ),
			inscricao_municipal: find_value_for_keys(invoice_hash, invoice_emitente_inscricao_municipal_path   ),
			razao_social:        find_value_for_keys(invoice_hash, invoice_emitente_razao_social_path          ),
			nome_fantasia:       find_value_for_keys(invoice_hash, invoice_emitente_nome_fantasia_path         ),
			telefone:            find_value_for_keys(invoice_hash, invoice_emitente_telefone_path              ),
			email:               find_value_for_keys(invoice_hash, invoice_emitente_email_path                 ),
			endereco: {
				logradouro:       find_value_for_keys(invoice_hash, invoice_emitente_endereco_logradouro_path         ),
				numero:           find_value_for_keys(invoice_hash, invoice_emitente_endereco_numero_path             ),
				complemento:      find_value_for_keys(invoice_hash, invoice_emitente_endereco_complemento_path        ),
				bairro:           find_value_for_keys(invoice_hash, invoice_emitente_endereco_bairro_path             ),
				codigo_municipio: find_value_for_keys(invoice_hash, invoice_emitente_endereco_codigo_municipio_path   ),
				uf:               find_value_for_keys(invoice_hash, invoice_emitente_endereco_uf_path                 ),
				cep:              find_value_for_keys(invoice_hash, invoice_emitente_endereco_cep_path                ),
			}
		}
	})
end

#build_rps_fields_nfe(nfe, invoice_hash) ⇒ Object



266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 266

def build_rps_fields_nfe(nfe, invoice_hash)
	nfe.assign_attributes({
		rps_numero:                       find_value_for_keys(invoice_hash, invoice_rps_numero_path                      ),
		rps_serie:                        find_value_for_keys(invoice_hash, invoice_rps_serie_path                       ),
		rps_tipo:                         find_value_for_keys(invoice_hash, invoice_rps_tipo_path                        ),
		rps_situacao:                     find_value_for_keys(invoice_hash, invoice_rps_situacao_path                    ),
		rps_substituido_numero:           find_value_for_keys(invoice_hash, invoice_rps_substituido_numero_path          ),
		rps_substituido_serie:            find_value_for_keys(invoice_hash, invoice_rps_substituido_serie_path           ),
		rps_substituido_tipo:             find_value_for_keys(invoice_hash, invoice_rps_substituido_tipo_path            ),
		data_emissao_rps:                 find_value_for_keys(invoice_hash, invoice_data_emissao_rps_path                ),
	})
end

#build_values_nfe(nfe, invoice_hash) ⇒ Object



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 291

def build_values_nfe(nfe, invoice_hash)
	nfe.assign_attributes({
		valor_total_servicos:          find_value_for_keys(invoice_hash, invoice_valor_total_servicos_path                  ),
		deducoes:              find_value_for_keys(invoice_hash, invoice_deducoes_path                      ),
		valor_pis:               find_value_for_keys(invoice_hash, invoice_valor_pis_path                       ),
		valor_cofins:            find_value_for_keys(invoice_hash, invoice_valor_cofins_path                    ),
		valor_inss:              find_value_for_keys(invoice_hash, invoice_valor_inss_path                      ),
		valor_ir:                find_value_for_keys(invoice_hash, invoice_valor_ir_path                        ),
		valor_csll:              find_value_for_keys(invoice_hash, invoice_valor_csll_path                      ),
		iss_retido:            find_value_for_keys(invoice_hash, invoice_iss_retido_path                    ),
		outras_retencoes:        find_value_for_keys(invoice_hash, invoice_outras_retencoes_path                ),
		total_iss:               find_value_for_keys(invoice_hash, invoice_total_iss_path                       ),
		base_calculo:        find_value_for_keys(invoice_hash, invoice_base_calculo_path                ),
		iss_aliquota:            find_value_for_keys(invoice_hash, invoice_iss_aliquota_path                    ),
		valor_liquido:           find_value_for_keys(invoice_hash, invoice_valor_liquido_path                   ),
		desconto_condicionado:   find_value_for_keys(invoice_hash, invoice_desconto_condicionado_path           ),
		desconto_incondicionado: find_value_for_keys(invoice_hash, invoice_desconto_incondicionado_path         ),
	})
end

#default_valuesObject

DEFINIÇÃO DOS VALORES PADRÕES PARA O CAMINHO DA NFSE ###############



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 104

def default_values
	super.merge({
		# invoices_path:                                       response_invoices_path,
		invoice_numero_nf_path:                              response_invoice_numero_nf_path,
		invoice_codigo_verificacao_path:                     response_invoice_codigo_verificacao_path,
		invoice_data_emissao_path:                           response_invoice_data_emissao_path,
		# invoice_url_nf_path:                                 response_invoice_url_nf_path,
		invoice_rps_numero_path:                             response_invoice_rps_numero_path,
		invoice_rps_serie_path:                              response_invoice_rps_serie_path,
		invoice_rps_tipo_path:                               response_invoice_rps_tipo_path,
		# invoice_rps_situacao_path:                           response_invoice_rps_situacao_path,
		# invoice_rps_substituido_numero_path:                 response_invoice_rps_substituido_numero_path,
		# invoice_rps_substituido_serie_path:                  response_invoice_rps_substituido_serie_path,
		# invoice_rps_substituido_tipo_path:                   response_invoice_rps_substituido_tipo_path,
		invoice_data_emissao_rps_path:                       response_invoice_data_emissao_rps_path,
		invoice_competencia_path:                            response_invoice_competencia_path,
		invoice_natureza_operacao_path:                      response_invoice_natureza_operacao_path,
		invoice_regime_especial_tributacao_path:             response_invoice_regime_especial_tributacao_path,
		invoice_optante_simples_nacional_path:               response_invoice_optante_simples_nacional_path,
		invoice_incentivador_cultural_path:                  response_invoice_incentivador_cultural_path,
		invoice_outras_informacoes_path:                     response_invoice_outras_informacoes_path,
		invoice_item_lista_servico_path:                     response_invoice_item_lista_servico_path,
		invoice_cnae_code_path:                              response_invoice_cnae_code_path,
		invoice_description_path:                            response_invoice_description_path,
		invoice_codigo_municipio_path:                       response_invoice_codigo_municipio_path,
		invoice_valor_total_servicos_path:                         response_invoice_valor_total_servicos_path,
		invoice_deducoes_path:                             response_invoice_deducoes_path,
		invoice_valor_pis_path:                              response_invoice_valor_pis_path,
		invoice_valor_cofins_path:                           response_invoice_valor_cofins_path,
		invoice_valor_inss_path:                             response_invoice_valor_inss_path,
		invoice_valor_ir_path:                               response_invoice_valor_ir_path,
		invoice_valor_csll_path:                             response_invoice_valor_csll_path,
		invoice_iss_retido_path:                           response_invoice_iss_retido_path,
		invoice_outras_retencoes_path:                       response_invoice_outras_retencoes_path,
		invoice_total_iss_path:                              response_invoice_total_iss_path,
		invoice_base_calculo_path:                       response_invoice_base_calculo_path,
		invoice_iss_aliquota_path:                           response_invoice_iss_aliquota_path,
		invoice_valor_liquido_path:                          response_invoice_valor_liquido_path,
		invoice_desconto_condicionado_path:                  response_invoice_desconto_condicionado_path,
		invoice_desconto_incondicionado_path:                response_invoice_desconto_incondicionado_path,
		# invoice_responsavel_retencao_path:                   response_invoice_responsavel_retencao_path,
		# invoice_numero_processo_path:                        response_invoice_numero_processo_path,
		# invoice_municipio_incidencia_path:                   response_invoice_municipio_incidencia_path,
		invoice_orgao_gerador_municipio_path:                response_invoice_orgao_gerador_municipio_path,
		invoice_orgao_gerador_uf_path:                       response_invoice_orgao_gerador_uf_path,
		invoice_cancelamento_codigo_path:                    response_invoice_cancelamento_codigo_path,
		invoice_cancelamento_numero_nf_path:                 response_invoice_cancelamento_numero_nf_path,
		invoice_cancelamento_cnpj_path:                      response_invoice_cancelamento_cnpj_path,
		invoice_cancelamento_municipio_path:                 response_invoice_cancelamento_municipio_path,
		invoice_cancelamento_data_hora_path:                 response_invoice_cancelamento_data_hora_path,
		invoice_cancelamento_inscricao_municipal_path:       response_invoice_cancelamento_inscricao_municipal_path,
		invoice_nfe_substituidora_path:                      response_invoice_nfe_substituidora_path,
		invoice_codigo_obra_path:                            response_invoice_codigo_obra_path,
		invoice_codigo_art_path:                             response_invoice_codigo_art_path,
		invoice_emitente_cnpj_path:                          response_invoice_emitente_cnpj_path,
		invoice_emitente_inscricao_municipal_path:           response_invoice_emitente_inscricao_municipal_path,
		invoice_emitente_razao_social_path:                  response_invoice_emitente_razao_social_path,
		invoice_emitente_nome_fantasia_path:                 response_invoice_emitente_nome_fantasia_path,
		invoice_emitente_telefone_path:                      response_invoice_emitente_telefone_path,
		invoice_emitente_email_path:                         response_invoice_emitente_email_path,
		invoice_emitente_endereco_logradouro_path:           response_invoice_emitente_endereco_logradouro_path,
		invoice_emitente_endereco_numero_path:               response_invoice_emitente_endereco_numero_path,
		invoice_emitente_endereco_complemento_path:          response_invoice_emitente_endereco_complemento_path,
		invoice_emitente_endereco_bairro_path:               response_invoice_emitente_endereco_bairro_path,
		invoice_emitente_endereco_codigo_municipio_path:     response_invoice_emitente_endereco_codigo_municipio_path,
		invoice_emitente_endereco_uf_path:                   response_invoice_emitente_endereco_uf_path,
		invoice_emitente_endereco_cep_path:                  response_invoice_emitente_endereco_cep_path,
		invoice_destinatario_cpf_path:                       response_invoice_destinatario_cpf_path,
		invoice_destinatario_cnpj_path:                      response_invoice_destinatario_cnpj_path,
		invoice_destinatario_inscricao_municipal_path:       response_invoice_destinatario_inscricao_municipal_path,
		invoice_destinatario_inscricao_estadual_path:        response_invoice_destinatario_inscricao_estadual_path,
		invoice_destinatario_inscricao_suframa_path:         response_invoice_destinatario_inscricao_suframa_path,
		invoice_destinatario_razao_social_path:              response_invoice_destinatario_razao_social_path,
		invoice_destinatario_telefone_path:                  response_invoice_destinatario_telefone_path,
		invoice_destinatario_email_path:                     response_invoice_destinatario_email_path,
		invoice_destinatario_endereco_logradouro_path:       response_invoice_destinatario_endereco_logradouro_path,
		invoice_destinatario_endereco_numero_path:           response_invoice_destinatario_endereco_numero_path,
		invoice_destinatario_endereco_complemento_path:      response_invoice_destinatario_endereco_complemento_path,
		invoice_destinatario_endereco_bairro_path:           response_invoice_destinatario_endereco_bairro_path,
		invoice_destinatario_endereco_codigo_municipio_path: response_invoice_destinatario_endereco_codigo_municipio_path,
		invoice_destinatario_endereco_uf_path:               response_invoice_destinatario_endereco_uf_path,
		invoice_destinatario_endereco_cep_path:              response_invoice_destinatario_endereco_cep_path,
	})
end

#get_invoicesObject

Método que retorna as notas fiscais emitidas. Como pode ser que retorne mais de uma NF, a busca pela NF pode retornar um Array ou um Hash. Se retornar um array é porque existe mais de uma NFE, então é necessario percorer com um loop e instanciar cada nota com seus valores. Se retornar um Hash é porque tem apenas uma NFe, e nesse caso irá instanciar apenas a nfe encontrada.

Tipo de retorno: Array



201
202
203
204
205
206
207
208
209
210
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 201

def get_invoices
	invoices = []
	_invoices = find_value_for_keys(savon_body, path_with_root(invoices_path))
	if _invoices.is_a?(Hash)
		invoices << instance_invoice(_invoices)
	elsif _invoices.is_a?(Array)
		_invoices.map{|inv| invoices << instance_invoice(inv) }
	end
	invoices
end

#get_xml_nfObject

Método utilizado para pegar o XML da NF É necessário canonicalizar o document para que seja colocado os namespaces nas tags corretas. Caso contrário o XML não irá abrir.

Tipo de retorno: String



218
219
220
221
222
223
224
225
226
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 218

def get_xml_nf
	if body_xml_path.present?
		canonicalize(Nokogiri::XML.parse( body_converted_to_xml , nil, 'UTF-8').xpath(nfe_xml_path).to_xml)
	else
		canonicalize(Nokogiri::XML.parse(canonicalize(savon_response.doc.to_s), nil, 'UTF-8').xpath(nfe_xml_path).to_xml)
	end
rescue
	savon_response.xml
end

#instance_invoice(invoice_hash) ⇒ Object

Método responsável por instanciar a nota fiscal de acordo com o hash

passado por parêmetro

O parâmetro recebido deve ser o Hash representado pelo tipo de dados tcCompNfse(do manual NFS-e v1)



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/br_nfe/service/response/build/invoice_build.rb', line 232

def instance_invoice(invoice_hash)
	nfe = BrNfe::Service::Response::NotaFiscal.new({
		xml_nf:                           get_xml_nf.force_encoding('UTF-8'),
		numero_nf:                        find_value_for_keys(invoice_hash, invoice_numero_nf_path                       ),
		codigo_verificacao:               find_value_for_keys(invoice_hash, invoice_codigo_verificacao_path              ),
		data_emissao:                     find_value_for_keys(invoice_hash, invoice_data_emissao_path                    ),
		url_nf:                           find_value_for_keys(invoice_hash, invoice_url_nf_path                          ),
		competencia:                      find_value_for_keys(invoice_hash, invoice_competencia_path                     ),
		natureza_operacao:                find_value_for_keys(invoice_hash, invoice_natureza_operacao_path               ),
		regime_especial_tributacao:       find_value_for_keys(invoice_hash, invoice_regime_especial_tributacao_path      ),
		optante_simples_nacional:         find_value_for_keys(invoice_hash, invoice_optante_simples_nacional_path        ),
		incentivador_cultural:            find_value_for_keys(invoice_hash, invoice_incentivador_cultural_path           ),
		outras_informacoes:               find_value_for_keys(invoice_hash, invoice_outras_informacoes_path              ),
		item_lista_servico:               find_value_for_keys(invoice_hash, invoice_item_lista_servico_path              ),
		cnae_code:                        find_value_for_keys(invoice_hash, invoice_cnae_code_path                       ),
		description:                      find_value_for_keys(invoice_hash, invoice_description_path                     ),
		codigo_municipio:                 find_value_for_keys(invoice_hash, invoice_codigo_municipio_path                ),
		responsavel_retencao:             find_value_for_keys(invoice_hash, invoice_responsavel_retencao_path            ),
		numero_processo:                  find_value_for_keys(invoice_hash, invoice_numero_processo_path                 ),
		municipio_incidencia:             find_value_for_keys(invoice_hash, invoice_municipio_incidencia_path            ),
		orgao_gerador_municipio:          find_value_for_keys(invoice_hash, invoice_orgao_gerador_municipio_path         ),
		orgao_gerador_uf:                 find_value_for_keys(invoice_hash, invoice_orgao_gerador_uf_path                ),
		codigo_obra:                      find_value_for_keys(invoice_hash, invoice_codigo_obra_path                     ),
		codigo_art:                       find_value_for_keys(invoice_hash, invoice_codigo_art_path                      ),
	})

	build_rps_fields_nfe(nfe, invoice_hash)
	build_cancelation_fields_nfe(nfe, invoice_hash)
	build_values_nfe(nfe, invoice_hash)
	build_emitente_nfe(nfe, invoice_hash)
	build_destinatario_nfe(nfe, invoice_hash)
	nfe
end