@@ -34,7 +34,44 @@ public ProviderGISS(ConfigNFSe config, OpenMunicipioNFSe municipio) : base(confi
3434
3535 #region RPS
3636
37-
37+ protected override XElement WriteRps ( NotaServico nota )
38+ {
39+ var rootRps = new XElement ( "Rps" ) ;
40+
41+ var infServico = new XElement ( "InfDeclaracaoPrestacaoServico" , new XAttribute ( "Id" , $ "Id_RPS{ nota . IdentificacaoRps . Numero . OnlyNumbers ( ) } ") ) ;
42+ rootRps . Add ( infServico ) ;
43+
44+ infServico . Add ( WriteRpsRps ( nota ) ) ;
45+
46+ infServico . AddChild ( AdicionarTag ( TipoCampo . Dat , "" , "Competencia" , 10 , 10 , Ocorrencia . Obrigatoria , nota . Competencia ) ) ;
47+
48+ infServico . AddChild ( WriteServicosRps ( nota ) ) ;
49+ infServico . AddChild ( WritePrestadorRps ( nota ) ) ;
50+ infServico . AddChild ( WriteTomadorRps ( nota ) ) ;
51+ infServico . AddChild ( WriteIntermediarioRps ( nota ) ) ;
52+ infServico . AddChild ( WriteConstrucaoCivilRps ( nota ) ) ;
53+
54+ string regimeEspecialTributacao ;
55+ string optanteSimplesNacional ;
56+ if ( nota . RegimeEspecialTributacao == RegimeEspecialTributacao . SimplesNacional )
57+ {
58+ regimeEspecialTributacao = "6" ;
59+ optanteSimplesNacional = "1" ;
60+ }
61+ else
62+ {
63+ regimeEspecialTributacao = ( ( int ) nota . RegimeEspecialTributacao ) . ToString ( ) ;
64+ optanteSimplesNacional = "2" ;
65+ }
66+
67+ if ( nota . RegimeEspecialTributacao != RegimeEspecialTributacao . Nenhum )
68+ infServico . AddChild ( AdicionarTag ( TipoCampo . Int , "" , "RegimeEspecialTributacao" , 1 , 1 , Ocorrencia . NaoObrigatoria , regimeEspecialTributacao ) ) ;
69+
70+ infServico . AddChild ( AdicionarTag ( TipoCampo . Int , "" , "OptanteSimplesNacional" , 1 , 1 , Ocorrencia . Obrigatoria , optanteSimplesNacional ) ) ;
71+ infServico . AddChild ( AdicionarTag ( TipoCampo . Int , "" , "IncentivoFiscal" , 1 , 1 , Ocorrencia . Obrigatoria , nota . IncentivadorCultural == NFSeSimNao . Sim ? 1 : 2 ) ) ;
72+
73+ return rootRps ;
74+ }
3875 protected override XElement WriteValoresRps ( NotaServico nota )
3976 {
4077 var valores = new XElement ( "Valores" ) ;
@@ -69,6 +106,49 @@ protected override XElement WriteValoresRps(NotaServico nota)
69106 #endregion RPS
70107
71108 #region Services
109+
110+ protected override void PrepararEnviar ( RetornoEnviar retornoWebservice , NotaServicoCollection notas )
111+ {
112+ if ( retornoWebservice . Lote == 0 ) retornoWebservice . Erros . Add ( new Evento { Codigo = "0" , Descricao = "Lote não informado." } ) ;
113+ if ( notas . Count == 0 ) retornoWebservice . Erros . Add ( new Evento { Codigo = "0" , Descricao = "RPS não informado." } ) ;
114+ if ( retornoWebservice . Erros . Any ( ) ) return ;
115+
116+ var xmlLoteRps = new StringBuilder ( ) ;
117+
118+ foreach ( var nota in notas )
119+ {
120+ var xmlRps = WriteXmlRps ( nota , false , false ) ;
121+ GravarRpsEmDisco ( xmlRps , $ "Rps-{ nota . IdentificacaoRps . DataEmissao : yyyyMMdd} -{ nota . IdentificacaoRps . Numero } .xml", nota . IdentificacaoRps . DataEmissao ) ;
122+ xmlLoteRps . Append ( xmlRps ) ;
123+ }
124+
125+ var xmlLote = new StringBuilder ( ) ;
126+ xmlLote . Append ( $ "<EnviarLoteRpsEnvio { GetNamespace ( ) } >") ;
127+ xmlLote . Append ( $ "<LoteRps Id=\" ID_lote{ retornoWebservice . Lote } \" { GetVersao ( ) } >") ;
128+ xmlLote . Append ( $ "<NumeroLote>{ retornoWebservice . Lote } </NumeroLote>") ;
129+ if ( UsaPrestadorEnvio ) xmlLote . Append ( "<Prestador>" ) ;
130+ xmlLote . Append ( "<CpfCnpj>" ) ;
131+ xmlLote . Append ( Configuracoes . PrestadorPadrao . CpfCnpj . IsCNPJ ( )
132+ ? $ "<Cnpj>{ Configuracoes . PrestadorPadrao . CpfCnpj . ZeroFill ( 14 ) } </Cnpj>"
133+ : $ "<Cpf>{ Configuracoes . PrestadorPadrao . CpfCnpj . ZeroFill ( 11 ) } </Cpf>") ;
134+ xmlLote . Append ( "</CpfCnpj>" ) ;
135+ if ( ! Configuracoes . PrestadorPadrao . InscricaoMunicipal . IsEmpty ( ) ) xmlLote . Append ( $ "<InscricaoMunicipal>{ Configuracoes . PrestadorPadrao . InscricaoMunicipal } </InscricaoMunicipal>") ;
136+ if ( UsaPrestadorEnvio ) xmlLote . Append ( "</Prestador>" ) ;
137+ xmlLote . Append ( $ "<QuantidadeRps>{ notas . Count } </QuantidadeRps>") ;
138+ xmlLote . Append ( "<ListaRps>" ) ;
139+ xmlLote . Append ( xmlLoteRps ) ;
140+ xmlLote . Append ( "</ListaRps>" ) ;
141+ xmlLote . Append ( "</LoteRps>" ) ;
142+ xmlLote . Append ( "</EnviarLoteRpsEnvio>" ) ;
143+
144+ retornoWebservice . XmlEnvio = xmlLote . ToString ( ) ;
145+ }
146+
147+ protected override void AssinarEnviar ( RetornoEnviar retornoWebservice )
148+ {
149+ //retornoWebservice.XmlEnvio = XmlSigning.AssinarXmlTodos(retornoWebservice.XmlEnvio, "Rps", "InfDeclaracaoPrestacaoServico", Certificado);
150+ retornoWebservice . XmlEnvio = XmlSigning . AssinarXml ( retornoWebservice . XmlEnvio , "EnviarLoteRpsEnvio" , "LoteRps" , Certificado ) ;
151+ }
72152
73153 /// <inheritdoc />
74154 protected override void TratarRetornoEnviarSincrono ( RetornoEnviar retornoWebservice ,
0 commit comments