Jump to content

dev botao

Registro C500 do Sped Fiscal


  • Este tópico foi criado há 4573 dias atrás.
  • Talvez seja melhor você criar um NOVO TÓPICO do que postar uma resposta aqui.

Recommended Posts

  • Membros Pro

estou gerando 5 notas fiscal com cabecalho e itens no entando quando vai para o arquivo ele gera somente um C500 e depois pega todos os C590.

estou obdecendo a hierarquia pai e filho ou seja uma nota varios itens pois

os C590 nao pertencem a nota 755 do C500.

|C500|1|0|755|06|00|1||01|078073681|02022011|02022011|1922,64|0,00|1922,64|0,00|0,00|0,00|1922,64|557,57|0,00|0,00||0,00|0,00|1|01|

|C590|090|1949|0,00|1661,00|0,00|0,00|0,00|0,00|0,00||

|C590|090|1949|0,00|2565,75|0,00|0,00|0,00|0,00|0,00||

|C590|090|1949|0,00|115,21|0,00|0,00|0,00|0,00|0,00||

|C590|090|1949|0,00|471,56|0,00|0,00|0,00|0,00|0,00||

|C590|000|1252|29,00|1922,64|1922,64|557,57|0,00|0,00|0,00||

Dangelo Porto

Link to comment
Share on other sites

estou gerando 5 notas fiscal com cabecalho e itens no entando quando vai para o arquivo ele gera somente um C500 e depois pega todos os C590.

estou obdecendo a hierarquia pai e filho ou seja uma nota varios itens pois

os C590 nao pertencem a nota 755 do C500.

|C500|1|0|755|06|00|1||01|078073681|02022011|02022011|1922,64|0,00|1922,64|0,00|0,00|0,00|1922,64|557,57|0,00|0,00||0,00|0,00|1|01|

|C590|090|1949|0,00|1661,00|0,00|0,00|0,00|0,00|0,00||

|C590|090|1949|0,00|2565,75|0,00|0,00|0,00|0,00|0,00||

|C590|090|1949|0,00|115,21|0,00|0,00|0,00|0,00|0,00||

|C590|090|1949|0,00|471,56|0,00|0,00|0,00|0,00|0,00||

|C590|000|1252|29,00|1922,64|1922,64|557,57|0,00|0,00|0,00||

Coloque o código de como vc esta alimentando o C500 e C590, para ser analisada se esta certo

C500 é uma Lista


while NF LOOP
begin
// C500
with RegistroC500New do
begin
....

C590 - filho do C500 tem que ficar aqui dentro
while ITENS LOOP
begin
with RegistroC590New
begin
...
end;
end;
end
end
[/code]

Abs

--
Isaque Pinheiro
Aracruz/ES - Brasil
___________________________________________________________________________
Site Oficial: www.isaquepinheiro.com.br 
Youtube: youtube.com/isaquepinheirooficialbr
Facebook: facebook.com.br/isaquepinheirooficialbr
Instagram: instagram.com/isaquepinheirooficialbr
Linkdin: https://www.linkedin.com/in/isaquepinheirooficialbr

Conheça o Projeto ORMBr Framework for Delphi - https://www.ormbr.com.br

 

Link to comment
Share on other sites

  • Membros Pro

e isso mesmo que esta sendo feito.

esse e o laço VEJA

         ModuloCadastro.IBQDocumento.Close;

         ModuloCadastro.IBQDocumento.SQL.Clear;

         ModuloCadastro.IBQDocumento.SQL.Add('SELECT * FROM DOCUMENTO                                             ');

         ModuloCadastro.IBQDocumento.SQL.Add('WHERE COD_EMPRESA   = :COD_EMPRESA                                  ');

         ModuloCadastro.IBQDocumento.SQL.Add('AND   DATA_EMISSAO >= :DATA_INI                                     ');

         ModuloCadastro.IBQDocumento.SQL.Add('AND   DATA_EMISSAO <= :DATA_FIN                                     ');

         ModuloCadastro.IBQDocumento.SQL.Add('AND   ((MODELO = ''06'') OR (MODELO = ''28'') OR (MODELO = ''29'')) ');


         ModuloCadastro.IBQDocumento.Parameters.ParamByName('COD_EMPRESA').Value := Modulo.RecCodEmp;

         ModuloCadastro.IBQDocumento.Parameters.ParamByName('DATA_INI').Value    := EDataInicial.Date;

         ModuloCadastro.IBQDocumento.Parameters.ParamByName('DATA_FIN').Value    := EDataFinal.Date;

         ModuloCadastro.IBQDocumento.Open;


         If ModuloCadastro.IBQDocumento.RecordCount > 0 Then Begin


            ModuloCadastro.IBQDocumento.First;


            With RegistroC500New Do Begin


               While ModuloCadastro.IBQDocumento.Eof = False Do Begin


                  Application.ProcessMessages;


                  If (ModuloCadastro.IBQDocumentoMODELO.AsString = '06') Or

                     (ModuloCadastro.IBQDocumentoMODELO.AsString = '28') Or

                     (ModuloCadastro.IBQDocumentoMODELO.AsString = '29') Then Begin


                     If ModuloCadastro.IBQDocumentoINDICADOR_OPERACAO.AsString = '0' Then Begin

                       IND_OPER := tpEntradaAquisicao;

                     End Else If ModuloCadastro.IBQDocumentoINDICADOR_OPERACAO.AsString = '1' Then Begin

                       IND_OPER := tpSaidaPrestacao;

                     End;


                     If ModuloCadastro.IBQDocumentoINDICADOR_EMISSAO.AsInteger = 0 Then Begin

                       IND_EMIT := edEmissaoPropria;

                     End Else Begin

                       IND_EMIT := edTerceiros;

                     End;


                     COD_PART := ModuloCadastro.IBQDocumentoCOD_FORNECEDOR.AsString;

                     COD_MOD  := ModuloCadastro.IBQDocumentoMODELO.AsString;


                     If ModuloCadastro.IBQDocumentoCOD_SITUACAO.AsString = '0' Then Begin

                        COD_SIT := sdRegular;

                     End Else If ModuloCadastro.IBQDocumentoCOD_SITUACAO.AsString = '1' Then Begin

                        COD_SIT := sdExtempRegular;

                     End Else If ModuloCadastro.IBQDocumentoCOD_SITUACAO.AsString = '2' Then Begin

                        COD_SIT := sdCancelado;

                     End Else If ModuloCadastro.IBQDocumentoCOD_SITUACAO.AsString = '3' Then Begin

                        COD_SIT := sdCanceladoExtemp;

                     End Else If ModuloCadastro.IBQDocumentoCOD_SITUACAO.AsString = '4' Then Begin

                        COD_SIT := sdDoctoDenegado;

                     End Else If ModuloCadastro.IBQDocumentoCOD_SITUACAO.AsString = '5' Then Begin

                        COD_SIT := sdDoctoNumInutilizada;

                     End Else If ModuloCadastro.IBQDocumentoCOD_SITUACAO.AsString = '6' Then Begin

                        COD_SIT := sdFiscalCompl;

                     End Else If ModuloCadastro.IBQDocumentoCOD_SITUACAO.AsString = '7' Then Begin

                        COD_SIT := sdExtempCompl;

                     End Else If ModuloCadastro.IBQDocumentoCOD_SITUACAO.AsString = '8' Then Begin

                        COD_SIT := sdRegimeEspecNEsp;

                     End;


                     SER      := ModuloCadastro.IBQDocumentoSERIE.AsString;

                     SUB      := '';


                     If (ModuloCadastro.IBQDocumentoMODELO.AsString = '06') Or

                        (ModuloCadastro.IBQDocumentoMODELO.AsString = '28') Then Begin


                        if ModuloCadastro.IBQDocumentoCOD_CONSUMIDOR.AsString = '1' Then Begin

                          COD_CONS := ccComercial;

                        End Else if ModuloCadastro.IBQDocumentoCOD_CONSUMIDOR.AsString = '2' Then Begin

                          COD_CONS := ccConsumoProprio;

                        End Else if ModuloCadastro.IBQDocumentoCOD_CONSUMIDOR.AsString = '3' Then Begin

                          COD_CONS := ccIluminacaoPublica;

                        End Else if ModuloCadastro.IBQDocumentoCOD_CONSUMIDOR.AsString = '4' Then Begin

                          COD_CONS := ccIndustrial;

                        End Else if ModuloCadastro.IBQDocumentoCOD_CONSUMIDOR.AsString = '5' Then Begin

                          COD_CONS := ccPoderPublico;

                        End Else if ModuloCadastro.IBQDocumentoCOD_CONSUMIDOR.AsString = '6' Then Begin

                          COD_CONS := ccResidencial;

                        End Else if ModuloCadastro.IBQDocumentoCOD_CONSUMIDOR.AsString = '7' Then Begin

                          COD_CONS := ccRural;

                        End Else if ModuloCadastro.IBQDocumentoCOD_CONSUMIDOR.AsString = '8' Then Begin

                          COD_CONS := ccServicoPublico;

                        End;

                     End Else If (ModuloCadastro.IBQDocumentoMODELO.AsString = '29') Then Begin

//                       COD_CONS := ccServicoPublico;

                     End;


                     NUM_DOC       := ModuloCadastro.IBQDocumentoN_DOCUMENTO.AsString;

                     DT_DOC        := ModuloCadastro.IBQDocumentoDATA_EMISSAO.AsDateTime;

                     DT_E_S        := ModuloCadastro.IBQDocumentoDATA_EMISSAO.AsDateTime;

                     VL_DOC        := ModuloCadastro.IBQDocumentoVALOR_DOCUMENTO.AsFloat;

                     VL_DESC       := 0;

                     VL_FORN       := ModuloCadastro.IBQDocumentoVALOR_DOCUMENTO.AsFloat;

                     VL_SERV_NT    := 0;

                     VL_TERC       := 0;

                     VL_DA         := ModuloCadastro.IBQDocumentoVALOR_OUTROS.AsFloat;

                     VL_BC_ICMS    := ModuloCadastro.IBQDocumentoBASE_ICMS.AsFloat;

                     VL_ICMS       := ModuloCadastro.IBQDocumentoVALOR_ICMS.AsFloat;

                     VL_BC_ICMS_ST := ModuloCadastro.IBQDocumentoBASE_ICMS_ST.AsFloat;

                     VL_ICMS_ST    := ModuloCadastro.IBQDocumentoVALOR_ICMS_ST.AsFloat;

                     COD_INF       := ModuloCadastro.IBQDocumentoCOD_OBSERVACAO.AsString;

                     VL_PIS        := ModuloCadastro.IBQDocumentoVALOR_PIS.AsFloat;

                     VL_COFINS     := ModuloCadastro.IBQDocumentoVALOR_COFINS.AsFloat;


                     If ModuloCadastro.IBQDocumentoCOD_TIPO_LIGACAO.AsString = '1' Then Begin

                        TP_LIGACAO := tlMonofasico;

                     End Else If ModuloCadastro.IBQDocumentoCOD_TIPO_LIGACAO.AsString = '2' Then Begin

                        TP_LIGACAO := tlBifasico;

                     End Else If ModuloCadastro.IBQDocumentoCOD_TIPO_LIGACAO.AsString = '3' Then Begin

                        TP_LIGACAO := tlTrifasico;

                     End;


                     If (ModuloCadastro.IBQDocumentoMODELO.AsString = '06') Then Begin


                        If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '1' Then Begin

                           COD_GRUPO_TENSAO := gtA1;

                        End Else If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '2' Then Begin

                           COD_GRUPO_TENSAO := gtA2;

                        End Else If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '3' Then Begin

                           COD_GRUPO_TENSAO := gtA3;

                        End Else If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '4' Then Begin

                           COD_GRUPO_TENSAO := gtA3a;

                        End Else If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '5' Then Begin

                           COD_GRUPO_TENSAO := gtA4;

                        End Else If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '6' Then Begin

                           COD_GRUPO_TENSAO := gtAS;

                        End Else If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '7' Then Begin

                           COD_GRUPO_TENSAO := gtB107;

                        End Else If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '8' Then Begin

                           COD_GRUPO_TENSAO := gtB108;

                        End Else If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '9' Then Begin

                           COD_GRUPO_TENSAO := gtB209;

                        End Else If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '10' Then Begin

                           COD_GRUPO_TENSAO := gtB2Rural;

                        End Else If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '11' Then Begin

                           COD_GRUPO_TENSAO := gtB2Irrigacao;

                        End Else If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '12' Then Begin

                           COD_GRUPO_TENSAO := gtB3;

                        End Else If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '13' Then Begin

                           COD_GRUPO_TENSAO := gtB4a;

                        End Else If ModuloCadastro.IBQDocumentoCOD_TENSAO.AsString = '14' Then Begin

                           COD_GRUPO_TENSAO := gtB4b;

                        End;

                     End;


                     If (ModuloCadastro.IBQDocumentoMODELO.AsString = '06') Or

                        (ModuloCadastro.IBQDocumentoMODELO.AsString = '28') Or

                        (ModuloCadastro.IBQDocumentoMODELO.AsString = '29') Then Begin


                        // REGISTRO C590

                        lblTexto.Caption := 'Registro C590';

                        lblTexto.Refresh;


                        IBQC590.Close;

                        IBQC590.SQL.Clear;

                        IBQC590.SQL.Add('SELECT DISTINCT SITUACAO_TRIBUTARIA, CFOP, PERC_ICMS,                ');

                        IBQC590.SQL.Add('                SUM(TOTAL_ITEM)                  AS VALOR_OPERACAO,  ');

                        IBQC590.SQL.Add('                SUM(BASE_ICMS)                   AS BASE_ICMS,       ');

                        IBQC590.SQL.Add('                SUM(VALOR_ICMS)                  AS VALOR_ICMS,      ');

                        IBQC590.SQL.Add('                SUM(VALOR_IPI)                   AS VALOR_IPI,       ');

                        IBQC590.SQL.Add('                SUM(VALOR_DESCONTO)              AS VALOR_DESCONTO,  ');

                        IBQC590.SQL.Add('                SUM(VALOR_OUTROS)                AS VALOR_OUTROS,    ');

                        IBQC590.SQL.Add('                SUM(VALOR_FRETE)                 AS VALOR_FRETE,     ');

                        IBQC590.SQL.Add('                SUM(VALOR_ACRESCIMO)             AS VALOR_ACRESCIMO, ');

                        IBQC590.SQL.Add('                SUM(VALOR_SEGURO)                AS VALOR_SEGURO     ');


                        IBQC590.SQL.Add('FROM DOCUMENTO_ITENS                                                 ');


                        IBQC590.SQL.Add('WHERE COD_EMPRESA   = :COD_EMPRESA                                   ');

                        IBQC590.SQL.Add('AND   DATA_EMISSAO  = :DATA_EMISSAO                                  ');

                        IBQC590.SQL.Add('AND   N_DOCUMENTO   = :N_DOCUMENTO                                   ');

                        IBQC590.SQL.Add('GROUP BY SITUACAO_TRIBUTARIA, CFOP, PERC_ICMS                        ');


                        IBQC590.Parameters.ParamByName('COD_EMPRESA').Value  := Modulo.RecCodEmp;

                        IBQC590.Parameters.ParamByName('DATA_EMISSAO').Value := ModuloCadastro.IBQDocumentoDATA_EMISSAO.AsDateTime;

                        IBQC590.Parameters.ParamByName('N_DOCUMENTO').Value  := ModuloCadastro.IBQDocumentoN_DOCUMENTO.AsInteger;

                        IBQC590.Open;


                        If IBQC590.RecordCount > 0 Then Begin


                          IBQC590.First;


                          While IBQC590.Eof = False Do Begin


                            With RegistroC590New Do Begin


                              If (IBQC590SITUACAO_TRIBUTARIA.AsString = '030') Or

                                 (IBQC590SITUACAO_TRIBUTARIA.AsString = '040') Or

                                 (IBQC590SITUACAO_TRIBUTARIA.AsString = '041') Or

                                 (IBQC590SITUACAO_TRIBUTARIA.AsString = '050') Or

                                 (IBQC590SITUACAO_TRIBUTARIA.AsString = '060') Then Begin


                                ALIQ_ICMS  := 0;

                                VL_BC_ICMS := 0;

                                VL_ICMS    := 0;

                              End Else Begin

                                ALIQ_ICMS  := IBQC590PERC_ICMS.AsFloat;

                                VL_BC_ICMS := IBQC590BASE_ICMS.AsFloat;

                                VL_ICMS    := IBQC590VALOR_ICMS.AsFloat;

                              End;


                              CST_ICMS      := IBQC590SITUACAO_TRIBUTARIA.AsString;

                              CFOP          := IBQC590CFOP.AsString;

                              VL_OPR        := IBQC590VALOR_OPERACAO.AsFloat;

                              VL_BC_ICMS_ST := 0;

                              VL_ICMS_ST    := 0;

                              VL_RED_BC     := 0;

                              COD_OBS       := '';

                            End;


                          IBQC590.Next;

                          End;

                        End;

                     End;

                  End;


               ModuloCadastro.IBQDocumento.Next;

               End;

            End;

         End; //FIM C500

MODERAÇÃO: Coloquei seu código dentro da tag code. EMBarbosa

Dangelo Porto

Link to comment
Share on other sites

e isso mesmo que esta sendo feito.

esse e o laço VEJA

MODERAÇÃO: Coloquei seu código dentro da tag code. EMBarbosa

While Modularization.IBQDocumento.Eof = False Do Begin

With RegistroC500New Do Begin

se IBQDocumento são as NFs, o "RegistroC500New" tem que estar dentro do laço, para que seja criado um C500, para cada NF, do jeito que vc fez, só terá um NF mesmo.

T+

--
Isaque Pinheiro
Aracruz/ES - Brasil
___________________________________________________________________________
Site Oficial: www.isaquepinheiro.com.br 
Youtube: youtube.com/isaquepinheirooficialbr
Facebook: facebook.com.br/isaquepinheirooficialbr
Instagram: instagram.com/isaquepinheirooficialbr
Linkdin: https://www.linkedin.com/in/isaquepinheirooficialbr

Conheça o Projeto ORMBr Framework for Delphi - https://www.ormbr.com.br

 

Link to comment
Share on other sites

  • Este tópico foi criado há 4573 dias atrás.
  • Talvez seja melhor você criar um NOVO TÓPICO do que postar uma resposta aqui.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.