Class: BrNfe::Service::Base

Inherits:
Base show all
Includes:
Helper::ValuesTs::ServiceV1
Defined in:
lib/br_nfe/service/base.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#certificate_pkcs12_password, #certificate_pkcs12_path, #certificate_pkcs12_value, #client_wsdl_ssl_cert_file, #client_wsdl_ssl_cert_key_file, #client_wsdl_ssl_cert_key_password, #client_wsdl_ssl_verify_mode, #env

Instance Method Summary collapse

Methods included from Helper::ValuesTs::ServiceV1

#ts_aliquota, #ts_art, #ts_bairro, #ts_cep, #ts_cnpj, #ts_codigo_cancelamento_nfse, #ts_codigo_cnae, #ts_codigo_mensagem_alerta, #ts_codigo_municipio_ibge, #ts_codigo_obra, #ts_codigo_tributacao, #ts_codigo_verificacao, #ts_complemento_endereco, #ts_cpf, #ts_date, #ts_datetime, #ts_descricao_mensagem_alerta, #ts_discriminacao, #ts_email, #ts_endereco, #ts_id_tag, #ts_indicacao_cpf_cnpj, #ts_inscricao_municipal, #ts_item_lista_servico, #ts_natureza_operacao, #ts_nome_fantasia, #ts_numero_endereco, #ts_numero_lote, #ts_numero_nfse, #ts_numero_protocolo, #ts_numero_rps, #ts_outras_informacoes, #ts_quantidade_rps, #ts_razao_social, #ts_regime_especial_tributacao, #ts_serie_rps, #ts_sim_nao, #ts_situacao_lote_rps, #ts_status_nfse, #ts_status_rps, #ts_telefone, #ts_tipo_rps, #ts_uf, #ts_valor

Methods inherited from Base

#certificado_obrigatorio?, #certificate, #certificate=, #certificate_key, #certificate_key=, #certificate_pkcs12, #certificate_pkcs12=, #client_wsdl, #content_xml, #env_namespace, #find_xml, #get_xml_dirs, #message_namespaces, #method_wsdl, #namespace_for_signature, #namespace_for_tags, #namespace_identifier, #original_response, #render_xml, #response, #response_encoding, #sign_xml, #signature_type, #signature_type?, #soap_namespaces, #soap_xml, #tag_xml, #wsdl, #wsdl_encoding, #xml_builder, #xml_default_dir_path, #xml_version

Methods included from Helper::HaveEmitente

#emitente, #emitente=

Methods inherited from ActiveModelBase

#assign_attributes, #default_values, #initialize

Constructor Details

This class inherits a constructor from BrNfe::ActiveModelBase

Instance Attribute Details

#ibge_code_of_issuer_cityObject

Código IBGE da cidade emitente



14
15
16
# File 'lib/br_nfe/service/base.rb', line 14

def ibge_code_of_issuer_city
  @ibge_code_of_issuer_city
end

#passwordObject

Returns the value of attribute password.



11
12
13
# File 'lib/br_nfe/service/base.rb', line 11

def password
  @password
end

#usernameObject

Alguns orgãos emissores necessitam que seja passado junto ao XML o Usuário e Senha do acesso do sistema da prefeitura.



10
11
12
# File 'lib/br_nfe/service/base.rb', line 10

def username
  @username
end

Instance Method Details

#body_xml_pathObject



37
38
39
# File 'lib/br_nfe/service/base.rb', line 37

def body_xml_path
	[]
end

#id_attribute?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/br_nfe/service/base.rb', line 41

def id_attribute?
	true
end

#nfse_xml_pathObject



32
33
34
35
# File 'lib/br_nfe/service/base.rb', line 32

def nfse_xml_path
	#//Envelope/Body/ConsultarLoteRpsEnvioResponse/ConsultarLoteRpsResposta
	'//*/*/*/*'
end

#requestObject



45
46
47
48
49
50
51
52
53
# File 'lib/br_nfe/service/base.rb', line 45

def request
	set_response( client_wsdl.call(method_wsdl, xml: soap_xml) )
rescue Savon::SOAPFault => error
	return @response = BrNfe::Response::Service::Default.new(status: :soap_error, error_messages: [error.message])
rescue Savon::HTTPError => error
	return @response = BrNfe::Response::Service::Default.new(status: :http_error, error_messages: [error.message])
rescue Exception => error
	return @response = BrNfe::Response::Service::Default.new(status: :unknown_error, error_messages: [error.message])
end

#response_root_pathObject



28
29
30
# File 'lib/br_nfe/service/base.rb', line 28

def response_root_path
	[]
end

#set_response(resp) ⇒ Object



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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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
# File 'lib/br_nfe/service/base.rb', line 55

def set_response(resp)
	@original_response = resp
	@response = BrNfe::Response::Service::BuildResponse.new(
		savon_response: resp, # Rsposta da requisição SOAP
		keys_root_path: response_root_path, # Caminho inicial da resposta / Chave pai principal
		nfe_xml_path:   nfse_xml_path, # Caminho para encontrar a NF dentro do XML
		body_xml_path:  body_xml_path,
		xml_encode:     response_encoding, # Codificação do xml de resposta
		lot_number_path:                                     response_lot_number_path,
		protocol_path:                                       response_protocol_path,
		received_date_path:                                  response_received_date_path,
		situation_path:                                      response_situation_path,
		situation_key_values:                                response_situation_key_values,
		cancelation_date_time_path:                          response_cancelation_date_time_path,
		message_errors_path:                                 response_message_errors_path,
		message_code_key:                                    response_message_code_key,
		message_msg_key:                                     response_message_msg_key,
		message_solution_key:                                response_message_solution_key,
		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_total_services_path:                         response_invoice_total_services_path,
		invoice_deductions_path:                             response_invoice_deductions_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_retained_path:                           response_invoice_iss_retained_path,
		invoice_outras_retencoes_path:                       response_invoice_outras_retencoes_path,
		invoice_total_iss_path:                              response_invoice_total_iss_path,
		invoice_base_calculation_path:                       response_invoice_base_calculation_path,
		invoice_iss_tax_rate_path:                           response_invoice_iss_tax_rate_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,
	).response
end

#xml_current_dir_pathObject

Declaro que o método ‘render_xml` irá verificar os arquivos também presentes no diretório especificado

Tipo de retorno: Array



24
25
26
# File 'lib/br_nfe/service/base.rb', line 24

def xml_current_dir_path
	["#{BrNfe.root}/lib/br_nfe/service/xml/#{xml_version}"]+super
end