Árvore de páginas

Versões comparadas

Chave

  • Esta linha foi adicionada.
  • Esta linha foi removida.
  • A formatação mudou.

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

Bloco de código
languagedelphi
titleExemplo: GFEXFB13
linenumberstrue
#INCLUDE#Include 'PROTHEUSProtheus.CHch'

 
User Function GFEXFB13()
local;
	      local nValorComp  := 0,;
	
      local nValorTaxa  := 0,;
	cNrReg,;
	aAreaAnt
      local cNrReg
      local aAreaAnt    := getArea()
	
      GFEXFB_1AREA(lTabTemp,cTRBTCF, @aTRBTCF1)
      GFEXFB_2TOP(lTabTemp,cTRBSTF cTRBTCF, @aTRBTCF1, @aTRBSTF15) //dbSelectArea(cTRBSTF) - Tabela de Frete
GFEXFB_1AREA(lTabTemp,cTRBCCF, @aTRBCCF1) //dbSelectArea(cTRBCCF) - Componentes de Frete

dbSelectArea((cTRBCCF))
(cTRBCCF)->(dbGoTop())
while (cTRBCCF)->(!eof())
	conout("comp: " + (cTRBCCF)->CDCOMP)
	if alltrim((cTRBCCF)->CDCOMP 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)->VALOR
	endif
	(cTRBCCF)->(dbSkip())
enddo

dbSelectArea("GV8")
if, @aTRBCCF1, 9,"VALOR")
                  EndIf
                  GFEXFB_1AREA(lTabTemp,cTRBCCF, @aTRBCCF1)
                  GFEXFB_8SKIP(lTabTemp, cTRBCCF, 9)
            EndDo

            GV8->(dbSetOrder(1))
            if GV8->(dbSeek(xFilial("GV8") + (cTRBSTF)->CDTRP + (cTRBSTF)->NRTAB + (cTRBSTF)->NRNEG + (cTRBSTF)->NRROTA))
	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
			dbSelectArea("GU9")
			                             GV9->(dbSetOrder(1))
                             if GU9->(dbSeek(xFilial("GU9") + cNrReg))
				if (cTRBSTF)->CDCLFR ==                                    // 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

if                                   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 
	dbSelectArea((cTRBCCF))
	(cTRBCCF)->(dbGoTop())
	while (cTRBCCF)->(!eof())
		if alltrim((cTRBCCF)->CDCOMP
                  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'
			RecLock(                             GFEXFB_DRECLOCK(lTabTemp,cTRBCCF,.fF.)
			(cTRBCCF)->VALOR := nValorTaxa
			MsUnLock(cTRBCCF)
		endif
		(cTRBCCF)->(dbSkip())
	enddo
endif
                             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