Histórico da Página
...
Descrição: | Integrar as Faturas de Frete no Financeiro utilizando a data de integração no Fiscal dos Documentos de Frete. | ||||||||
Localização: | Quando for integrar com EMS Genérico | ||||||||
Programa Fonte: | GFEA070 - Fatura de Frete | ||||||||
Parâmetros: | Não se aplica | ||||||||
Retorno: |
|
Exemplo: GFEA0706GFEA0707
Bloco de código | ||||
---|---|---|---|---|
| ||||
#INCLUDE "PROTHEUS.CH" User Function GFEA0707() Local aRet := {.T.,'',.F.,'GFEA0707'} Local cQuery conout("GFEA0707") aRet := IntFinCFis(GW6->GW6_FILIAL,GW6->GW6_EMIFAT,GW6->GW6_SERFAT,GW6->GW6_NRFAT,GW6->GW6_DTEMIS,aRet) conout("fim GFEA0707") Return aRet Static Function IntFinCFis(cGW6_FILIAL,cGW6_EMIFAT,cGW6_SERFAT,cGW6_NRFAT,cGW6_DTEMIS,aRet) Local cQuery Local cAliasGW3 Local cMV_XDTOF := GetMv("MV_XDTOF") Local dData aRet[2] := STOD('00000000') conout(cvaltochar(cMV_XDTOF) + " / " + cGW6_NRFAT ) If cMV_XDTOF == 1 cQuery := 'SELECT DISTINCT GW3.GW3_DTFIS, GW3.GW3_DTREC, GW3.GW3_NRDF,' cQuery += ' GV5.GV5_SENTID FROM '+RetSqlName('GW3')+" GW3" cQuery += ' INNER JOIN '+RetSqlName('GW4')+" GW4" cQuery += ' ON GW4.GW4_FILIAL = GW3.GW3_FILIAL cQuery += ' AND GW4.GW4_EMISDF = GW3.GW3_EMISDF cQuery += ' AND GW4.GW4_CDESP = GW3.GW3_CDESP cQuery += ' AND GW4.GW4_SERDF = GW3.GW3_SERDF cQuery += ' AND GW4.GW4_NRDF = GW3.GW3_NRDF cQuery += ' AND GW4.GW4_DTEMIS = GW3.GW3_DTEMIS cQuery += " AND GW4.D_E_L_E_T_ = ' '" cQuery += ' LEFT JOIN '+RetSqlName('GW1')+" GW1" cQuery += ' ON GW1.GW1_FILIAL = GW4.GW4_FILIAL cQuery += ' AND GW1.GW1_CDTPDC = GW4.GW4_TPDC cQuery += ' AND GW1.GW1_EMISDC = GW4.GW4_EMISDC cQuery += ' AND GW1.GW1_SERDC = GW4.GW4_SERDC cQuery += ' AND GW1.GW1_NRDC = GW4.GW4_NRDC cQuery += " AND GW1.D_E_L_E_T_ = ' '" cQuery += ' INNER JOIN '+RetSqlName('GV5')+" GV5" cQuery += ' ON GV5.GV5_CDTPDC = GW1.GW1_CDTPDC' cQuery += " WHERE GW3.GW3_FILIALFILFAT = '"+GW6->GW6cGW6_FILIAL+"'" cQuery += " AND GW3.GW3_EMIFAT = '"+GW6->GW6cGW6_EMIFAT +"'" cQuery += " AND GW3.GW3_SERFAT = '"+GW6->GW6cGW6_SERFAT+"'" cQuery += " AND GW3.GW3_NRFAT = '"+GW6->GW6cGW6_NRFAT+"'" cQuery += " AND GW3.GW3_DTEMISDTEMFA = '"+DTOS(GW6->GW6cGW6_DTEMIS)+"'" cQuery += " AND GW3.D_E_L_E_T_ = ''" cQuery := ChangeQuery(cQuery) cAliasGW3 := GetNextAlias() DbUseArea(.T.,'TOPCONN',TcGenQry(,,cQuery),cAliasGW3,.F.,.T.) conout(cQuery) While !(cAliasGW3)->( Eof() ) conout("Documento de frete: " + (cAliasGW3)->GV5_SENTID + "/" + (cAliasGW3)->GW3_NRDF) If EMPTY((cAliasGW3)->GW3_DTFIS) .and. EMPTY((cAliasGW3)->GW3_DTREC) If aRet[4] == 'GFEA0707' Msginfo("Documento de Frete "+(cAliasGW3)->GW3_NRDF+" não está integrado no módulo Fiscal."; +" Integração com o Financeiro não permitida","Documento de Frete ínvalido") Else dData aRet[4] := "** Documento de Frete "+(cAliasGW3)->GW3_NRDF+" não está integrado no módulo Fiscal."; +" Integração com o Financeiro não permitida" EndIf aRet[2] := ''Date() Exit EndIf if !EMPTY((cAliasGW3)->GW3_DTFIS) .and. (cAliasGW3)->GV5_SENTID == '2' If (cAliasGW3)->GW3_DTFIS > DTOS(dDataaRet[2]) dDataaRet[2] := STOD((cAliasGW3)->GW3_DTFIS) aRet[3] := .T. aRet[4] := '' EndIF ElseIf !EMPTY((cAliasGW3)->GW3_DTREC) .and. (cAliasGW3)->GV5_SENTID == '1' If (cAliasGW3)->GW3_DTREC > DTOS(dDataaRet[2]) dDataaRet[2] := STOD((cAliasGW3)->GW3_DTREC) aRet[3] := .T. aRet[4] := '' EndIF EndIf (cAliasGW3)->( dbSkip() ) EndDo (cAliasGW3)->(dbCloseArea()) If !EMPTY(dData) CONOUT("Data integração: " + cvaltochar(aRet[12] := dData ) + "/" + cvaltochar(aRet[3])) Else aRet[21] := .TF. EndIf EndIf Return aRet |
Visão Geral
Import HTML Content
Conteúdo das Ferramentas
Tarefas