nfse_issnet 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +3 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +20 -0
  7. data/CODE_OF_CONDUCT.md +75 -0
  8. data/Dockerfile +16 -0
  9. data/Gemfile +6 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +47 -0
  12. data/Rakefile +6 -0
  13. data/bin/console +14 -0
  14. data/bin/setup +8 -0
  15. data/docker-compose.yml +15 -0
  16. data/lib/nfse_issnet.rb +74 -0
  17. data/lib/nfse_issnet/base.rb +72 -0
  18. data/lib/nfse_issnet/configuration.rb +10 -0
  19. data/lib/nfse_issnet/entities/base_entity.rb +11 -0
  20. data/lib/nfse_issnet/entities/nota_fiscal.rb +19 -0
  21. data/lib/nfse_issnet/entities/servico_consultar_lote_rps_envio.rb +8 -0
  22. data/lib/nfse_issnet/entities/servico_consultar_nfse_envio.rb +7 -0
  23. data/lib/nfse_issnet/entities/servico_consultar_nfse_por_rps_envio.rb +8 -0
  24. data/lib/nfse_issnet/entities/servico_enviar_lote_rps_envio.rb +7 -0
  25. data/lib/nfse_issnet/entities/tc_contato.rb +8 -0
  26. data/lib/nfse_issnet/entities/tc_cpf_cnpj.rb +8 -0
  27. data/lib/nfse_issnet/entities/tc_dados_prestador.rb +9 -0
  28. data/lib/nfse_issnet/entities/tc_dados_servico.rb +12 -0
  29. data/lib/nfse_issnet/entities/tc_dados_tomador.rb +10 -0
  30. data/lib/nfse_issnet/entities/tc_endereco.rb +13 -0
  31. data/lib/nfse_issnet/entities/tc_identificacao_intermediario_servico.rb +9 -0
  32. data/lib/nfse_issnet/entities/tc_identificacao_prestador.rb +8 -0
  33. data/lib/nfse_issnet/entities/tc_identificacao_rps.rb +9 -0
  34. data/lib/nfse_issnet/entities/tc_identificacao_tomador.rb +8 -0
  35. data/lib/nfse_issnet/entities/tc_inf_rps.rb +18 -0
  36. data/lib/nfse_issnet/entities/tc_lote_rps.rb +12 -0
  37. data/lib/nfse_issnet/entities/tc_rps.rb +7 -0
  38. data/lib/nfse_issnet/entities/tc_valores.rb +22 -0
  39. data/lib/nfse_issnet/operations/consulta_lote_rps.rb +18 -0
  40. data/lib/nfse_issnet/operations/consulta_nfse.rb +19 -0
  41. data/lib/nfse_issnet/operations/consulta_nfse_por_rps.rb +18 -0
  42. data/lib/nfse_issnet/operations/envia_lote_rps.rb +18 -0
  43. data/lib/nfse_issnet/responses/base.rb +53 -0
  44. data/lib/nfse_issnet/responses/consulta_lote_rps.rb +19 -0
  45. data/lib/nfse_issnet/responses/consulta_nfse.rb +19 -0
  46. data/lib/nfse_issnet/responses/consulta_nfse_por_rps.rb +19 -0
  47. data/lib/nfse_issnet/responses/envia_lote_rps.rb +32 -0
  48. data/lib/nfse_issnet/utils/assinatura.rb +36 -0
  49. data/lib/nfse_issnet/utils/utils.rb +19 -0
  50. data/lib/nfse_issnet/utils/xml.rb +32 -0
  51. data/lib/nfse_issnet/version.rb +3 -0
  52. data/lib/nfse_issnet/xml/_signed_info_sh1.xml.slim +8 -0
  53. data/lib/nfse_issnet/xml/_tc_contato.xml.slim +7 -0
  54. data/lib/nfse_issnet/xml/_tc_cpf_cnpj.xml.slim +4 -0
  55. data/lib/nfse_issnet/xml/_tc_dados_prestador.xml.slim +15 -0
  56. data/lib/nfse_issnet/xml/_tc_dados_servico.xml.slim +12 -0
  57. data/lib/nfse_issnet/xml/_tc_dados_tomador.xml.slim +15 -0
  58. data/lib/nfse_issnet/xml/_tc_endereco.xml.slim +16 -0
  59. data/lib/nfse_issnet/xml/_tc_identificacao_intermediario_servico.xml.slim +7 -0
  60. data/lib/nfse_issnet/xml/_tc_identificacao_prestador.xml.slim +4 -0
  61. data/lib/nfse_issnet/xml/_tc_identificacao_rps.xml.slim +3 -0
  62. data/lib/nfse_issnet/xml/_tc_identificacao_tomador.xml.slim +4 -0
  63. data/lib/nfse_issnet/xml/_tc_inf_rps.xml.slim +43 -0
  64. data/lib/nfse_issnet/xml/_tc_lote_rps.xml.slim +9 -0
  65. data/lib/nfse_issnet/xml/_tc_rps.xml.slim +7 -0
  66. data/lib/nfse_issnet/xml/_tc_valores.xml.slim +48 -0
  67. data/lib/nfse_issnet/xml/servico_consultar_lote_rps_envio.xml.slim +5 -0
  68. data/lib/nfse_issnet/xml/servico_consultar_nfse_envio.xml.slim +4 -0
  69. data/lib/nfse_issnet/xml/servico_consultar_nfse_por_rps_envio.xml.slim +6 -0
  70. data/lib/nfse_issnet/xml/servico_enviar_lote_rps_envio.xml.slim +9 -0
  71. data/lib/nfse_issnet/xml/signature_sh1.xml.slim +10 -0
  72. data/nfse_issnet.gemspec +55 -0
  73. metadata +299 -0
@@ -0,0 +1,32 @@
1
+ module NfseIssnet
2
+ module Responses
3
+ class EnviaLoteRps < Base
4
+ def response
5
+ OpenStruct.new(protocolo: protocolo, numero_lote: numero_lote, data_recebimento: data_recebimento, error_messages: erros)
6
+ end
7
+
8
+ protected
9
+
10
+ def default_values
11
+ super.merge({
12
+ keys_root_path: [:recepcionar_lote_rps_response, :recepcionar_lote_rps_result],
13
+ errors_path: [:enviar_lote_rps_resposta, :lista_mensagem_retorno]
14
+ })
15
+ end
16
+
17
+ private
18
+
19
+ def protocolo
20
+ @protocolo ||= savon_body.dig(:enviar_lote_rps_resposta, :protocolo)
21
+ end
22
+
23
+ def numero_lote
24
+ @numero_lote ||= savon_body.dig(:enviar_lote_rps_resposta, :numero_lote)
25
+ end
26
+
27
+ def data_recebimento
28
+ @data_recebimento ||= savon_body.dig(:enviar_lote_rps_resposta, :data_recebimento)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,36 @@
1
+ module Utils
2
+ module Assinatura
3
+
4
+ class << self
5
+ attr_accessor :certificate, :certificate_key
6
+
7
+ def certificate
8
+ @certificate ||= certificate_pkcs12&.certificate
9
+ end
10
+
11
+ def certificate_key
12
+ @certificate_key ||= certificate_pkcs12&.key
13
+ end
14
+
15
+ private
16
+
17
+ attr_accessor :certificate_pkcs12_value, :certificate_pkcs12
18
+
19
+ def certificate_pkcs12_value
20
+ @certificate_pkcs12_value ||= File.read(NfseIssnet.configuration.certificate_pkcs12_path)
21
+ end
22
+
23
+ def certificate_pkcs12
24
+ return @certificate_pkcs12 if @certificate_pkcs12
25
+ @certificate_pkcs12 = nil
26
+ Thread.new do
27
+ @certificate_pkcs12 = OpenSSL::PKCS12.new(certificate_pkcs12_value, NfseIssnet.configuration.certificate_pkcs12_password)
28
+ end.join
29
+
30
+ @certificate_pkcs12
31
+ rescue
32
+ nil
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,19 @@
1
+ module Utils
2
+ module Utils
3
+ class << self
4
+ def snakecase(key)
5
+ #gsub(/::/, '/').
6
+ key.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
7
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
8
+ tr('-', '_').
9
+ gsub(/\s/, '_').
10
+ gsub(/__+/, '_').
11
+ downcase
12
+ end
13
+
14
+ def remove_quebras(str)
15
+ str.gsub(/\n/, '').gsub(/\t/, '').strip
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,32 @@
1
+ module Utils
2
+ module XML
3
+ class << self
4
+ def render(file_name, opts = {})
5
+ opts ||= {}
6
+ opts[:context] ||= self
7
+
8
+ # Inicializa a variavel xml com nil para comparar se oa rquivo foi de fato encontrado.
9
+ xml = find(file_name, "#{NfseIssnet.root}/lib/nfse_issnet/xml", opts[:context], opts)
10
+
11
+ # Lança uma excessão se não for encontrado o xml
12
+ # Deve verificar se é nil pois o arquivo xml pode estar vazio
13
+ if xml.nil?
14
+ raise "Arquivo #{file_name}.xml.slim não encontrado nos diretórios"
15
+ end
16
+ xml
17
+ end
18
+
19
+ private
20
+
21
+ def namespace_for_tags
22
+ 'tc:'
23
+ end
24
+
25
+ def find(file_name, dir, context = nil, options = {})
26
+ if File.exists?("#{dir}/#{file_name}.xml.slim")
27
+ %Q{#{Slim::Template.new("#{dir}/#{file_name}.xml.slim", disable_escape: true).render(context, options)}}
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module NfseIssnet
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,8 @@
1
+ *{tag: "SignedInfo"}
2
+ *{tag: "CanonicalizationMethod"} Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"
3
+ *{tag: "SignatureMethod"} Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"
4
+ *{tag: "Reference"} URI="#{uri}"
5
+ *{tag: "Transforms"}
6
+ *{tag: "Transform"} Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"
7
+ *{tag: "DigestMethod"} Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"
8
+ *{tag: "DigestValue"} = Utils::Utils.remove_quebras Base64.encode64(OpenSSL::Digest::SHA1.digest(data_xml))
@@ -0,0 +1,7 @@
1
+ - contact ||= false
2
+ - raise "Deve ser passado uma variável local chamda contact" unless contact
3
+
4
+ - if contact.telefone
5
+ *{tag: "#{namespace_for_tags}Telefone"} = contact.telefone
6
+ - if contact.email
7
+ *{tag: "#{namespace_for_tags}Email"} = contact.email
@@ -0,0 +1,4 @@
1
+ - if !cpf_cnpj.cnpj.blank?
2
+ *{tag: "#{namespace_for_tags}Cnpj"} = cpf_cnpj.cnpj
3
+ - elsif !cpf_cnpj.cpf.blank?
4
+ *{tag: "#{namespace_for_tags}Cpf"} = cpf_cnpj.cpf
@@ -0,0 +1,15 @@
1
+ *{tag: "#{namespace_for_tags}IdentificacaoPrestador"}
2
+ = Utils::XML.render '_tc_identificacao_prestador'
3
+
4
+ *{tag: "#{namespace_for_tags}RazaoSocial"} = ts_razao_social(emitente.razao_social)
5
+
6
+ - if emitente.nome_fantasia.present?
7
+ *{tag: "#{namespace_for_tags}NomeFantasia"} = ts_nome_fantasia(emitente.nome_fantasia)
8
+
9
+ - if emitente.endereco.is_present?
10
+ *{tag: "#{namespace_for_tags}Endereco"}
11
+ = Utils::XML.render '_tc_endereco', address: emitente.endereco
12
+
13
+ - if emitente.telefone.present? || emitente.email.present?
14
+ *{tag: "#{namespace_for_tags}Contato"}
15
+ = Utils::XML.render '_tc_contato', contact: emitente
@@ -0,0 +1,12 @@
1
+ - servico ||= false
2
+ - raise "Deve ser passado uma vsariavel local chamada rps" unless servico
3
+
4
+ *{tag: "#{namespace_for_tags}Valores"}
5
+ = Utils::XML.render '_tc_valores', valores: servico.valores
6
+
7
+ *{tag: "#{namespace_for_tags}ItemListaServico"} = servico.item_lista_servico
8
+ *{tag: "#{namespace_for_tags}CodigoCnae"} = servico.codigo_cnae
9
+ *{tag: "#{namespace_for_tags}CodigoTributacaoMunicipio"} = servico.codigo_tributacao_municipio
10
+
11
+ *{tag: "#{namespace_for_tags}Discriminacao"} = servico.discriminacao
12
+ *{tag: "#{namespace_for_tags}MunicipioPrestacaoServico"} = servico.municipio_prestacao_servico
@@ -0,0 +1,15 @@
1
+ - destinatario ||= false
2
+ - raise "Deve ser passado uma vsariavel local chamada destinatario" unless destinatario
3
+ *{tag: "#{namespace_for_tags}IdentificacaoTomador"}
4
+ = Utils::XML.render '_tc_identificacao_tomador', destinatario: destinatario.identificacao_tomador
5
+
6
+ - if destinatario.razao_social
7
+ *{tag: "#{namespace_for_tags}RazaoSocial"} = destinatario.razao_social
8
+
9
+ - if destinatario.endereco
10
+ *{tag: "#{namespace_for_tags}Endereco"}
11
+ = Utils::XML.render '_tc_endereco', address: destinatario.endereco
12
+
13
+ - if destinatario.contato && (destinatario.contato.telefone || destinatario.contato.email)
14
+ *{tag: "#{namespace_for_tags}Contato"}
15
+ = Utils::XML.render '_tc_contato', contact: destinatario.contato
@@ -0,0 +1,16 @@
1
+ - address ||= false
2
+ - raise "Deve ser passado uma variável local chamda address" unless address
3
+
4
+ *{ tag: "#{namespace_for_tags}Endereco" } = address.endereco
5
+ - if address.cep
6
+ *{ tag: "#{namespace_for_tags}Cep" } = address.cep
7
+ - if address.numero
8
+ *{ tag: "#{namespace_for_tags}Numero" } = address.numero
9
+ - if address.complemento
10
+ *{ tag: "#{namespace_for_tags}Complemento" } = address.complemento
11
+ - if address.bairro
12
+ *{ tag: "#{namespace_for_tags}Bairro" } = address.bairro
13
+ - if address.cidade
14
+ *{ tag: "#{namespace_for_tags}Cidade" } = address.cidade
15
+ - if address.estado
16
+ *{ tag: "#{namespace_for_tags}Estado" } = address.estado
@@ -0,0 +1,7 @@
1
+ *{tag: "#{namespace_for_tags}RazaoSocial"} = intermediario.razao_social
2
+
3
+ *{tag: "#{namespace_for_tags}CpfCnpj"}
4
+ = Utils::XML.render '_tc_cpf_cnpj', cpf_cnpj: intermediario.cpf_cnpj
5
+
6
+ - if intermediario.inscricao_municipal
7
+ *{tag: "#{namespace_for_tags}InscricaoMunicipal"} = intermediario.inscricao_municipal
@@ -0,0 +1,4 @@
1
+ *{ tag: "#{namespace_for_tags}CpfCnpj" }
2
+ = Utils::XML.render '_tc_cpf_cnpj', cpf_cnpj: emitente.cpf_cnpj
3
+ - unless emitente.inscricao_municipal.nil?
4
+ *{tag: "#{namespace_for_tags}InscricaoMunicipal"} = emitente.inscricao_municipal
@@ -0,0 +1,3 @@
1
+ *{ tag: "#{namespace_for_tags}Numero" } = identificacao.numero
2
+ *{ tag: "#{namespace_for_tags}Serie" } = identificacao.serie
3
+ *{ tag: "#{namespace_for_tags}Tipo" } = identificacao.tipo
@@ -0,0 +1,4 @@
1
+ *{tag: "#{namespace_for_tags}CpfCnpj"}
2
+ = Utils::XML.render '_tc_cpf_cnpj', cpf_cnpj: destinatario.cpf_cnpj
3
+ - if destinatario.inscricao_municipal
4
+ *{tag: "#{namespace_for_tags}InscricaoMunicipal"} = destinatario.inscricao_municipal
@@ -0,0 +1,43 @@
1
+ - inf_rps ||= false
2
+ - raise "É obrigatório passar um RPS por parâmetro" unless inf_rps
3
+
4
+ *{tag: "#{namespace_for_tags}IdentificacaoRps"}
5
+ = Utils::XML.render '_tc_identificacao_rps', identificacao: inf_rps.identificacao_rps
6
+
7
+ *{tag: "#{namespace_for_tags}DataEmissao"} = inf_rps.data_emissao
8
+ *{tag: "#{namespace_for_tags}NaturezaOperacao"} = inf_rps.natureza_operacao
9
+
10
+ - if inf_rps.regime_especial_tributacao
11
+ / Código de identificação do regime especial de tributação:
12
+ / - (1)Microempresa municipal
13
+ / - (2)Estimativa
14
+ / - (3)Sociedade de profissionais
15
+ / - (4)Cooperativa,
16
+ / - (5)Microempresário Individual (MEI)
17
+ / - (6)Microempresário e Empresa de Pequeno Porte (ME EPP)
18
+ *{tag: "#{namespace_for_tags}RegimeEspecialTributacao"} = inf_rps.regime_especial_tributacao
19
+
20
+ / (1)sim ----- (2)não -----
21
+ *{tag: "#{namespace_for_tags}OptanteSimplesNacional"} = inf_rps.optante_simples_nacional
22
+
23
+ / (1)sim ----- (2)não -----
24
+ *{tag: "#{namespace_for_tags}IncentivadorCultural"} = inf_rps.incentivador_cultural
25
+
26
+ *{tag: "#{namespace_for_tags}Status"} = inf_rps.status
27
+
28
+ - if inf_rps.rps_substituido
29
+ *{tag: "#{namespace_for_tags}RpsSubstituido"}
30
+ = Utils::XML.render '_tc_identificacao_rps', identificacao: inf_rps.rps_substituido
31
+
32
+ *{tag: "#{namespace_for_tags}Servico"}
33
+ = Utils::XML.render '_tc_dados_servico', servico: inf_rps.servico
34
+
35
+ *{tag: "#{namespace_for_tags}Prestador"}
36
+ = Utils::XML.render '_tc_identificacao_prestador', emitente: inf_rps.prestador
37
+
38
+ *{tag: "#{namespace_for_tags}Tomador"}
39
+ = Utils::XML.render '_tc_dados_tomador', destinatario: inf_rps.tomador
40
+
41
+ - if inf_rps.intermediario_servico
42
+ *{tag: "#{namespace_for_tags}IntermediarioServico"}
43
+ = Utils::XML.render '_tc_identificacao_intermediario_servico', intermediario: inf_rps.intermediario_servico
@@ -0,0 +1,9 @@
1
+ *{tag: "#{namespace_for_tags}NumeroLote"} = lote_rps.numero_lote
2
+ *{tag: "#{namespace_for_tags}CpfCnpj"} = Utils::XML.render '_tc_cpf_cnpj', cpf_cnpj: lote_rps.cpf_cnpj
3
+ *{tag: "#{namespace_for_tags}InscricaoMunicipal"} = lote_rps.inscricao_municipal
4
+ *{tag: "#{namespace_for_tags}QuantidadeRps"} = lote_rps.lista_rps.size
5
+ *{tag: "#{namespace_for_tags}ListaRps"}
6
+ - lote_rps.lista_rps.each do |rps|
7
+ *{tag: "#{namespace_for_tags}Rps"}
8
+ / tc_rps já está assinado (se tiver um certificado)
9
+ = Utils::XML.render '_tc_rps', rps: rps
@@ -0,0 +1,7 @@
1
+ - xml_rps = Utils::XML.render '_tc_inf_rps', inf_rps: rps.inf_rps
2
+ - id_rps = "R#{rps.inf_rps.identificacao_rps.numero}"
3
+ *{ tag: "#{namespace_for_tags}InfRps" }
4
+ = xml_rps
5
+
6
+ / - if certificate
7
+ / = Utils::XML.render('signature_sh1', data_xml: xml_rps, uri: id_rps)
@@ -0,0 +1,48 @@
1
+ - valores ||= false
2
+ - raise "É obrigatório passar um RPS por parâmetro" unless valores
3
+
4
+ *{ tag: "#{namespace_for_tags}ValorServicos" } = valores.valor_servicos.round(2)
5
+
6
+ - if valores.valor_deducoes && valores.valor_deducoes.to_f > 0.0
7
+ *{ tag: "#{namespace_for_tags}ValorDeducoes" } = valores.valor_deducoes
8
+
9
+ - if valores.valor_pis && valores.valor_pis.to_f > 0.0
10
+ *{ tag: "#{namespace_for_tags}ValorPis" } = valores.valor_pis.round(2)
11
+
12
+ - if valores.valor_cofins && valores.valor_cofins.to_f > 0.0
13
+ *{ tag: "#{namespace_for_tags}ValorCofins" } = valores.valor_cofins.round(2)
14
+
15
+ - if valores.valor_inss && valores.valor_inss.to_f > 0.0
16
+ *{ tag: "#{namespace_for_tags}ValorInss" } = valores.valor_inss.round(2)
17
+
18
+ - if valores.valor_ir && valores.valor_ir.to_f > 0.0
19
+ *{ tag: "#{namespace_for_tags}ValorIr" } = valores.valor_ir.round(2)
20
+
21
+ - if valores.valor_csll && valores.valor_csll.to_f > 0.0
22
+ *{ tag: "#{namespace_for_tags}ValorCsll" } = valores.valor_csll
23
+
24
+ *{ tag: "#{namespace_for_tags}IssRetido" } = valores.iss_retido
25
+
26
+ - if valores.valor_iss && valores.valor_iss.to_f > 0.0
27
+ *{ tag: "#{namespace_for_tags}ValorIss" } = valores.valor_iss.round(2)
28
+
29
+ - if valores.valor_iss_retido && valores.valor_iss_retido.to_f > 0.0
30
+ *{ tag: "#{namespace_for_tags}ValorIssRetido" } = valores.valor_iss_retido.round(2)
31
+
32
+ - if valores.outras_retencoes && valores.outras_retencoes.to_f > 0.0
33
+ *{ tag: "#{namespace_for_tags}OutrasRetencoes" } = valores.outras_retencoes.round(2)
34
+
35
+ - if valores.base_calculo && valores.base_calculo.to_f > 0.0
36
+ *{ tag: "#{namespace_for_tags}BaseCalculo" } = valores.base_calculo.round(2)
37
+
38
+ - if valores.aliquota && valores.aliquota.to_f > 0.0
39
+ *{ tag: "#{namespace_for_tags}Aliquota" } = valores.aliquota
40
+
41
+ - if valores.valor_liquido_nfse && valores.valor_liquido_nfse.to_f > 0.0
42
+ *{ tag: "#{namespace_for_tags}ValorLiquidoNfse" } = valores.valor_liquido_nfse.round(2)
43
+
44
+ - if valores.desconto_incondicionado && valores.desconto_incondicionado.to_f > 0.0
45
+ *{ tag: "#{namespace_for_tags}DescontoIncondicionado" } = valores.desconto_incondicionado
46
+
47
+ - if valores.desconto_condicionado && valores.desconto_condicionado.to_f > 0.0
48
+ *{ tag: "#{namespace_for_tags}DescontoCondicionado" } = valores.desconto_condicionado
@@ -0,0 +1,5 @@
1
+ doctype xml
2
+ *{ tag: "ConsultarLoteRpsEnvio" } *message_namespaces
3
+ *{tag: "Prestador"}
4
+ = Utils::XML.render '_tc_identificacao_prestador', emitente: content_xml.prestador
5
+ *{tag: "Protocolo"} = content_xml.protocolo
@@ -0,0 +1,4 @@
1
+ doctype xml
2
+ *{tag: "ConsultarNfseEnvio"} *message_namespaces
3
+ *{tag: "Prestador"}
4
+ = Utils::XML.render '_tc_identificacao_prestador', emitente: content_xml.prestador
@@ -0,0 +1,6 @@
1
+ doctype xml
2
+ *{ tag: "ConsultarNfseRpsEnvio" } *message_namespaces
3
+ *{tag: "Prestador"}
4
+ = Utils::XML.render '_tc_identificacao_prestador', emitente: content_xml.prestador
5
+ *{tag: "IdentificacaoRps"}
6
+ = Utils::XML.render '_tc_identificacao_rps', identificacao: content_xml.identificacao_rps
@@ -0,0 +1,9 @@
1
+ doctype xml
2
+ *{ tag: "EnviarLoteRpsEnvio" } *message_namespaces
3
+ - xml_lote_rps = Utils::XML.render '_tc_lote_rps', lote_rps: content_xml.lote_rps
4
+ - id_lote = "L#{content_xml.lote_rps.numero_lote}"
5
+ *{tag: "LoteRps"} *{id: id_lote}
6
+ = xml_lote_rps
7
+
8
+ - if Utils::Assinatura::certificate
9
+ = Utils::XML.render('signature_sh1', data_xml: xml_lote_rps, uri: id_lote, certificate: Utils::Assinatura::certificate, certificate_key: Utils::Assinatura::certificate_key)
@@ -0,0 +1,10 @@
1
+ *{tag: "Signature"} xmlns="http://www.w3.org/2000/09/xmldsig#"
2
+ - info_xml = Utils::XML.render('_signed_info_sh1', data_xml: data_xml, uri: uri)
3
+ = info_xml
4
+
5
+ - signature_hash = certificate_key.sign(OpenSSL::Digest::SHA1.new, info_xml)
6
+ *{tag: "SignatureValue"} = Utils::Utils.remove_quebras( Base64.encode64( signature_hash ) )
7
+
8
+ *{tag: "KeyInfo"}
9
+ *{tag: "X509Data"}
10
+ *{tag: "X509Certificate"} = certificate.to_s.gsub(/\-\-\-\-\-[A-Z]+ CERTIFICATE\-\-\-\-\-/, "").gsub(/\n/,"")
@@ -0,0 +1,55 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "nfse_issnet/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nfse_issnet"
8
+ spec.version = NfseIssnet::VERSION
9
+ spec.authors = ["Eduardo Scottini"]
10
+ spec.email = ["eduardo.scottini@gmail.com"]
11
+
12
+ spec.summary = "Geração e consulta de NFS-e."
13
+ spec.description = "Geração e consulta de NFS-e integrado ao sistema ISSNET."
14
+ spec.homepage = "https://github.com/eduardoscottini/nfse_issnet"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/eduardoscottini/nfse_issnet"
24
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
25
+ else
26
+ raise "RubyGems 2.0 or newer is required to protect against " \
27
+ "public gem pushes."
28
+ end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.required_ruby_version = '~> 2.3'
40
+
41
+ spec.add_dependency "savon", "~> 2.12.0"
42
+ spec.add_dependency "ox"
43
+ spec.add_dependency "dry-validation", "0.13.0"
44
+ spec.add_dependency "dry-struct", "0.7.0"
45
+ spec.add_dependency "slim"
46
+ spec.add_dependency "xmldsig"
47
+ spec.add_development_dependency "bundler"
48
+ spec.add_development_dependency "rake", "~> 10.0"
49
+ spec.add_development_dependency "pry", "~> 0.12.2"
50
+ spec.add_development_dependency "rspec", "~> 3.0"
51
+ spec.add_development_dependency "webmock"
52
+ spec.add_development_dependency "simplecov"
53
+ spec.add_development_dependency "simplecov-console"
54
+
55
+ end