Class: NfseGyn::GerarNfseXML

Inherits:
Object
  • Object
show all
Defined in:
lib/nfse_gyn/gerar_nfse_xml.rb

Instance Method Summary collapse

Constructor Details

#initialize(invoice_info) ⇒ GerarNfseXML

Returns a new instance of GerarNfseXML.



7
8
9
# File 'lib/nfse_gyn/gerar_nfse_xml.rb', line 7

def initialize(invoice_info)
  @invoice = invoice_info
end

Instance Method Details

#bodyObject



15
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
# File 'lib/nfse_gyn/gerar_nfse_xml.rb', line 15

def body
  Gyoku.xml(
    'Rps' => {
      'InfDeclaracaoPrestacaoServico' => {
        '@xmlns' => 'http://nfse.goiania.go.gov.br/xsd/nfse_gyn_v02.xsd',
        'Rps' => {
          '@Id' => raise_if_missing(@invoice[:identification_number], :identification_number),
          'IdentificacaoRps' => {
            'Numero' => @invoice[:identification_number],
            'Serie' => raise_if_missing(NfseGyn.configuration.rps_serie, :rps_serie),
            'Tipo' => raise_if_missing(NfseGyn.configuration.rps_tipo, :rps_tipo)
          },
          'DataEmissao' => raise_if_missing(@invoice[:data_emissao], :data_emissao),
          'Status' => 1
        },

        'Servico' => {
          'Valores' => {
            'ValorServicos' => raise_if_missing(@invoice[:total], :total),
            'Aliquota' => raise_if_missing(NfseGyn.configuration.valor_aliquota, :valor_aliquota)
          },

          'CodigoTributacaoMunicipio' => raise_if_missing(NfseGyn.configuration.codigo_tributacao_municipio, :codigo_tributacao_municipio),
          'Discriminacao' => raise_if_missing(clear(@invoice[:description]), :description),
          'CodigoMunicipio' => raise_if_missing(NfseGyn.configuration.codigo_municipio, :codigo_municipio)
        },

        'Prestador' => {
          'CpfCnpj' => {
            'Cnpj' => raise_if_missing(NfseGyn.configuration.cnpj, :prestador_cnpj)
          },
          'InscricaoMunicipal' => raise_if_missing(NfseGyn.configuration.inscricao_municipal, :prestador_inscricao_municipal)
        },

        'Tomador' => tomador
      }
    }
  )
end

#to_xmlObject



11
12
13
# File 'lib/nfse_gyn/gerar_nfse_xml.rb', line 11

def to_xml
  "<GerarNfseEnvio xmlns=\"http://nfse.goiania.go.gov.br/xsd/nfse_gyn_v02.xsd\">#{sign(body)}</GerarNfseEnvio>"
end