Árvore de páginas

GFEXFB13 - FUNCIONALIDADES ADICIONAIS ANTES DA CRIAÇÃO DOS IMPOSTOS DO FRETE

Características do Requisito

Linha de Produto:

Microsiga Protheus

Segmento:

Supply Chain - Logística

Módulo:

SIGAGFE

  

Ponto de Entrada:GFEXFB13

Descrição:

Permitir a inclusão de funcionalidades adicionais no processo de cálculo do frete.

Localização:

Chamado antes do cálculo de impostos

Programa Fonte:

GFEXFUNB - Cálculo do Frete

Parâmetros:

Nenhum

Retorno:

Nenhum

Exemplo: GFEXFB13
#Include 'Protheus.ch'
User Function GFEXFB13()
      local nValorComp  := 0
      local nValorTaxa  := 0
      local cNrReg
      local aAreaAnt    := getArea()

      GFEXFB_1AREA(lTabTemp,cTRBTCF, @aTRBTCF1)
      GFEXFB_2TOP(lTabTemp, cTRBTCF, @aTRBTCF1, 5) // Posiciona na 1a rota para selecao
      GFEXFB_BORDER(lTabTemp,cTRBTCF,01,5)
      While !GFEXFB_3EOF(lTabTemp, cTRBTCF, @aTRBTCF1, 5)
            
            //percorre os componentes do calculo de frete relacionada
            nValorComp := 0
            nValorTaxa := 0
            GFEXFB_1AREA(lTabTemp,cTRBCCF, @aTRBCCF1)
            GFEXFB_BORDER(lTabTemp,cTRBCCF,01,9)
            GFEXFB_CSEEK(lTabTemp, cTRBCCF, @aTRBCCF1, 9,{GFEXFB_5CMP(lTabTemp, cTRBTCF, @aTRBTCF1, 5,"NRCALC")})
            While  !GFEXFB_3EOF(lTabTemp, cTRBCCF, @aTRBCCF1, 9) .AND. ;
                        GFEXFB_5CMP(lTabTemp, cTRBCCF, @aTRBCCF1, 9,"NRCALC") == GFEXFB_5CMP(lTabTemp, cTRBTCF, @aTRBTCF1, 5,"NRCALC")
                  if alltrim(GFEXFB_5CMP(lTabTemp, cTRBCCF, @aTRBCCF1, 9,"CDCOMP")) <> 'TAXA DE ENTREGA' .And. ;
                     alltrim(GFEXFB_5CMP(lTabTemp, cTRBCCF, @aTRBCCF1, 9,"CDCOMP")) <> 'PEDÁGIO' 
                        nValorComp += GFEXFB_5CMP(lTabTemp, cTRBCCF, @aTRBCCF1, 9,"VALOR")
                  EndIf
                  GFEXFB_1AREA(lTabTemp,cTRBCCF, @aTRBCCF1)
                  GFEXFB_8SKIP(lTabTemp, cTRBCCF, 9)
            EndDo

            GV8->(dbSetOrder(1))
            if GV8->(dbSeek(xFilial("GV8") + GFEXFB_5CMP(lTabTemp, cTRBTCF, @aTRBTCF1, 5,"CDTRP") + ;
                                                  GFEXFB_5CMP(lTabTemp, cTRBTCF, @aTRBTCF1, 5,"NRTAB") + ;
                                                  GFEXFB_5CMP(lTabTemp, cTRBTCF, @aTRBTCF1, 5,"NRNEG") + ;
                                                  GFEXFB_5CMP(lTabTemp, cTRBTCF, @aTRBTCF1, 5,"NRROTA") ))                                 
                  cNrReg := ""
                  If GV8->GV8_TPORIG != "2"
                        If GV8->GV8_TPDEST == "3" // Busca tabela com região destino
                             cNrReg := GV8->GV8_NRREDS
                             GV9->(dbSetOrder(1))
                             if GU9->(dbSeek(xFilial("GU9") + cNrReg))
                                   // Se a classif. Frete do documento igual a classif. da região
                                   if alltrim(GFEXFB_5CMP(lTabTemp, cTRBTCF, @aTRBTCF1, 5,"CDCLFR")) == alltrim(GU9->GU9_XCLFR)
                                         nValorTaxa := (nValorComp * (GU9->GU9_PENT / 100))
                                   endif
                             endif                   
                        endif
                  EndIf
            endif

            //Busca o componente Taxa de Entrega e gravo na, tabela temporária, o valor da taxa calculado anteriormente
            If nValorTaxa > 0
                  GFEXFB_1AREA(lTabTemp,cTRBCCF, @aTRBCCF1)
                  GFEXFB_BORDER(lTabTemp,cTRBCCF,01,9)
                  GFEXFB_CSEEK(lTabTemp, cTRBCCF, @aTRBCCF1, 9,{GFEXFB_5CMP(lTabTemp, cTRBTCF, @aTRBTCF1, 5,"NRCALC")})
                  While  !GFEXFB_3EOF(lTabTemp, cTRBCCF, @aTRBCCF1, 9) .AND. ;
                             GFEXFB_5CMP(lTabTemp, cTRBCCF, @aTRBCCF1, 9,"NRCALC") == GFEXFB_5CMP(lTabTemp, cTRBTCF, @aTRBTCF1, 5,"NRCALC")
                        if alltrim(GFEXFB_5CMP(lTabTemp, cTRBCCF, @aTRBCCF1, 9,"CDCOMP")) == 'TAXA DE ENTREGA'
                             GFEXFB_DRECLOCK(lTabTemp,cTRBCCF,.F.)
                             GFEXFB_5CMP(lTabTemp, cTRBCCF, @aTRBCCF1, 9,"VALOR",nValorTaxa)
                             GFEXFB_EMSUNLOCK(lTabTemp,cTRBCCF)
                        EndIf
                        GFEXFB_1AREA(lTabTemp,cTRBCCF, @aTRBCCF1)
                        GFEXFB_8SKIP(lTabTemp, cTRBCCF, 9)
                  EndDo
            EndIf
            GFEXFB_8SKIP(lTabTemp, cTRBTCF, 5)
      enddo
      restArea(aAreaAnt) 
Return