Histórico da Página
Composition Setup |
---|
import.css=/download/attachments/327912/newLayout.css |
Portuguese | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Ponto-de-Entrada: ESPISRL - Gera arquivo
Descrição: Ponto de entrada para geração do arquivo de trabalho, com registros referentes às retenções de imposto de renda classificadas por conceito. Programa Fonte CTBXFUNC Sintaxe ESPISRL - Gera arquivo ( < cArqTmp> , < dDataIni> , < dDataFim> , < cPeriodo> ) --> cArqTrb Parâmetros:
Retorno
Exemplos User Function ESPISRL()Local cArqTmp := IxbParam[1]Local dDataIni := IxbParam[2]Local dDataFim := IxbParam[3]Local cPeriodo := IxbParam[4]Local cQuery1 := ""Local XSFELocal XSA2Local aStrQRY1:={}Local cRIFAGENTELocal cArqtrbLocal cNomINDLocal cORDPAGOLocal nORDPAGOLocal cORDPAGO1Local nI := 1 Local nPERCENTLocal cNFISCALDBSELECTAREA("SM0")cRIFAGENTE := alltrim(M0_CGC)DBSELECTAREA("SA2")DBSETORDER(1)XSA2 := xFilial("SA2") DBSELECTAREA("SFE")DBSETORDER(1)XSFE := xFilial("CT1") aadd(aStrQRY1,{ "RIFAGENTE" , "C", 14, 0 })aadd(aStrQRY1,{ "EMISSAO" , "C", 06, 0 })aadd(aStrQRY1,{ "RIFSUJEITO", "C", 14, 0 })aadd(aStrQRY1,{ "NUMFATURA" , "C", 10, 0 })aadd(aStrQRY1,{ "ORDEMPAGO" , "C", 08, 0 })aadd(aStrQRY1,{ "CONCEITO" , "C", 03, 0 })aadd(aStrQRY1,{ "VALORBASE" , "C", 17, 0 })aadd(aStrQRY1,{ "PERCENT" , "C", 06, 0 })cQuery1 := "SELECT DISTINCT '" + cRIFAGENTE + "' RIFAGENTE, FE_EMISSAO EMISSAO , A2_CGC , FE_ORDPAGO, FE_NFISCAL, FE_SERIE "cQUERY1 += ", FE_VALBASE VALORBASE, FE_ALIQ , FE_CONCEPT"cQUERY1 += " FROM " + RetSqlName("SFE") + " SFE"cQUERY1 += ", " + RetSqlName("SA2") + " SA2"cQUERY1 += " WHERE SFE.FE_FILIAL = '" + XSFE + "'"cQUERY1 += " AND SFE.D_E_L_E_T_ = ' '"cQUERY1 += " AND SFE.FE_TIPO='R'"cQUERY1 += " AND SFE.FE_EMISSAO BETWEEN '" + DTOS(MV_PAR01) + "' AND '" + DTOS(MV_PAR02) + "'"cQUERY1 += " AND SA2.D_E_L_E_T_ = ' '"cQUERY1 += " AND SA2.A2_FILIAL = '" + XSA2 + "'"cQUERY1 += " AND (SFE.FE_FORNECE + SFE.FE_LOJA) = (SA2.A2_COD + SA2.A2_LOJA)"cQUERY1 += " ORDER BY SFE.FE_EMISSAO, A2_CGC , SFE.FE_NFISCAL, SFE.FE_ORDPAGO"cQUERY1 := CHANGEQUERY(cQUERY1)IF SELECT("TOPISRL") > 0 DBSELECTAREA("TOPISRL") DBCLOSEAREA()ENDIFTcQuery cQUERY1 New Alias "TOPISRL"DBSELECTAREA("TOPISRL")IF (EOF() .OR. BOF()) MsgAlert(STR0008,STR0005) //Não existe retenções geradas! ### Atenção RETURNendifIF SELECT("ISRL") > 0 DBSELECTAREA("ISRL") DBCLOSEAREA()ENDIFcArqtrb := CriaTrab( aStrQRY1, .T. )cNomIND := ALLTRIM(cArqtrb)cIndTRB := "EMISSAO + RIFSUJEITO + NUMFATURA + ORDEMPAGO"dbUseArea( .T., "DBFCDX", cArqtrb, "ISRL", .T. ,.F. )dbSelectArea("ISRL")IndRegua( "ISRL", cNomIND , cIndTRB )set index todbSetIndex(cNomIND +OrdBagExt())dbSetOrder(1)DBSELECTAREA("TOPISRL")TOPISRL->(DBGOTOP())DO WHILE ! TOPISRL->(EOF()) DBSELECTAREA("TOPISRL") cNFISCAL := (ALLTRIM(TOPISRL->FE_SERIE) + ALLTRIM(TOPISRL->FE_NFISCAL) ) IF "" == cNFISCAL .or. EMPTY(cNFISCAL) cNFISCAL:= "0" ELSE IF LEN(cNFISCAL) > 10 cNFISCAL := RIGHT(cNFISCAL,10) ENDIF ENDIF cORDPAGO1:= ALLTRIM(TOPISRL->FE_ORDPAGO) cORDPAGO := "" IF "" == cORDPAGO1 .OR. EMPTY(cORDPAGO1) cORDPAGO := "NA" ELSE nORDPAGO := LEN(cORDPAGO1) FOR nI := 1 TO nORDPAGO if subs(cORDPAGO1, nI,1) $ "0123456789" cORDPAGO += subs(cORDPAGO1, nI,1) endif NEXT ENDIF nPERCENT := STR(FE_ALIQ,6,2) IF SUBS( nPERCENT , 4, 3) == ".00" // 010.00 nPERCENT := STR(FE_ALIQ,3,0) Endif dbSelectArea("ISRL") RECLOCK("ISRL", .T.) ISRL->RIFAGENTE := ALLTRIM(TOPISRL->RIFAGENTE) ISRL->EMISSAO := cPERIODO // SUBS(TOPISRL->EMISSAO,1,6) ISRL->RIFSUJEITO:= ALLTRIM(TOPISRL->A2_CGC) ISRL->NUMFATURA := cNFISCAL ISRL->ORDEMPAGO := cORDPAGO ISRL->CONCEITO := TOPISRL->FE_CONCEPT ISRL->VALORBASE := alltrim(STR(TOPISRL->VALORBASE,17,2)) ISRL->PERCENT := ALLTRIM(nPERCENT) MSUNLOCK() DBSELECTAREA("TOPISRL") TOPISRL->(DBSKIP())ENDDO dbSelectArea("ISRL")DBGOTOP()Return ("ISRL") Variáveis
|
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas