Árvore de páginas

Ponto-de-Entrada: VM011PFIN - Altera parcelas do financiamento
Abrangências: Microsiga Protheus 10
Versões: Todas
Compatível Países: Todos
Sistemas Operacionais: Todos
Compatível às Bases de Dados: Todos
Descrição:
O ponto de entrada VM011PFIN está localizado na rotina de Atendimento de veiculo, para que possa ser alterado as parcelas do financiamento.
Eventos

Function FS_CALC011()

 

Local cont

Local cDia

Local nMes

Local nMesAnt

Local nValFin := 0

 

FS_VALOR011()

 

lCalcVEI := .f.

 

//nValFin := iIf(Empty(M->VV0_VALFIN),M->VV0_VALTOT-nTotalEnt,M->VV0_VALFIN)

//nValFin := M->VV0_VALTOT-nTotalEnt

//If M->VV0_VALFIN > 0

//          nValFin := M->VV0_VALFIN

//Else

            nValFin := (M->VV0_VALTOT-Round(nAcresFin,2))-nTotalEnt-M->VV0_VALFIN

            If Round(nAcresFin,2) > 0

                        M->VV0_VALTOT -= Round(nAcresFin,2)

            Endif

//Endif

//if !Empty(M->VV0_VALTAC)

//If !Empty(M->VV0_TABFAI)

//   DbSelectArea("VAR")

//   DbSeek(xFilial("VAR")+M->VV0_CODBCO)

//          if VAR->VAR_TACFIN == "1"

//                      nValFin += M->VV0_VALTAC

//          Endif

//Endif

 

if nValFin < 0

            nValFin := 0

Endif

nAcresFin := 0

dbSelectarea("SE4")

dbSetOrder(1)

if dbSeek(xFilial("SE4")+M->VV0_FORPAG)

            if (!AllTrim(SE4->E4_COND) == "0" .or. SE4->E4_TIPO == "A") .and. M->VV0_TIPFIN <> "1"

                        FG_CONDICAO(M->VV0_DATINI,strzero(M->VV0_DIA1PC,4),strzero(M->VV0_PARCEL,4),strzero(M->VV0_INTERV,4),"1","VV0_FORPAG",nValFin,cTipOpe)

                        if M->VV0_FIXDIA == "1" .and. Val(M->VV0_DIAFIX) > 0 .and. Val(M->VV0_DIAFIX) < 32

                                   cDia    := M->VV0_DIAFIX

                                   nMesAnt := 0

                                   For cont := 1 to Len(aIteParc)

                                               if Val(cDia) > Day(LastDay(aIteParc[cont,1]))

                                                           cDia := Str(Day(LastDay(aIteParc[cont,1])),2)

                                               Else

                                                           cDia := M->VV0_DIAFIX

                                               Endif

                                               cDia := StrZero(Val(cDia),2)

                                               nMes := Month(aIteParc[cont,1])

                                               if nMesAnt == nMes

                                                           nMes := Month(aIteParc[cont,1])+1                                                                                         

                                                           If nMes == 13

                                                                       aIteParc[cont,1] := ctod(left(Transform(aIteParc[cont,1],"@D"),6)+Substr(Str(Year(aIteParc[cont,1])+1,4),3,2))

                                                           Endif

                                               Endif

                                               aIteParc[cont,1] := ctod(cDia+'/'+StrZero(nMes,2)+"/"+Substr(Str(Year(aIteParc[cont,1]),4),3,2))

                                               nMesAnt := nMes

                                   Next

                        Endif

                        /// PROBLEMA aIteParc *********************************************************************** ///

               If M->VV0_TIPFIN == "0" // Faturamento Proprio

                                   if M->VV0_COEFIC > 0                 

                                  

                                               If MsgYesno("Valores de Parcela linear?",OemToAnsi(STR0012))

                                                           nCoef   := (M->VV0_COEFIC/30)*M->VV0_INTERV

                                                           nCoefic := 1+(nCoef/100)

                                                           nParcAnt := aIteParc[1,2]

                                                           nTotal  := 0    

                                                           nTotAnt := 0     

                                                           For cont := 1 to Len(aIteParc)

                                                                       nExp    := (aIteParc[cont,1]-dDatabase)/30

                                                                       if nExp <= 0

                                                                          nJurMes := 1

                                                                       Else

                                                                          nJurMes := nCoefic**nExp

                                                                       Endif

//                                                                     nTotAnt += aIteParc[cont,2]

//                                                                     aIteParc[cont,2] := nParcAnt * nJurmes

                                                                       aIteParc[cont,2] := aIteParc[cont,2] * nJurmes

                                                                       nParcAnt := aIteParc[cont,2]

                                                                       nTotal += nParcAnt

                                                           Next           

                                                           For cont := 1 to Len(aIteParc)             

                                                                       aIteParc[cont,2] := nTotal/Len(aIteParc)

                                                           Next           

                                                           nAcresFin := nTotal - nTotAnt

                                                           M->VV0_VALTOT += naCresFin

                                               Else

                                                  // Juro simples

            //                                             nValPar := (nValFin / Len(aIteParc))

            //                                             nCoefic := (M->VV0_COEFIC/30)/100

            //                                             For cont := 1 to Len(aIteParc)             

            //                                                         nAcresci := (((aIteParc[cont,2] * nCoefic)) * (aIteParc[cont,1]-dDatabase))

            //                                                         aIteParc[cont,2] := nValPar + nAcresci

            //                                             Next           

           

                                                           // Juro Composto     

                                                           nCoef   := (M->VV0_COEFIC/30)*M->VV0_INTERV

                                                           nCoefic := 1+(nCoef/100)

                                                           nParcAnt := aIteParc[1,2]

                                                           nTotal  := 0

                                                           nTotAnt := 0

                                                           For cont := 1 to Len(aIteParc)             

                                                                       nExp    := (aIteParc[cont,1]-dDatabase)/30

                                                                       if nExp <= 0

                                                                          nJurMes := 1

                                                                       Else

                                                                          nJurMes := nCoefic**nExp

                                                                       Endif

//                                                                     nTotAnt += aIteParc[cont,2]

//                                                                     aIteParc[cont,2] := nParcAnt * nJurMes

                                                                       aIteParc[cont,2] := aIteParc[cont,2] * nJurMes

                                                                       nParcAnt := aIteParc[cont,2]

                                                                       nTotal  += nParcAnt

                                                           Next            

                                                           nAcresFin := nTotal - nTotAnt

                                                           M->VV0_VALTOT += naCresFin

                                               Endif                                      

                                              

//                                             nValPar := (nValFin / Len(aIteParc)

//                                             nValPar := (nValFin * (1+(M->VV0_COEFIC/100))) / Len(aIteParc)

//                                             For cont := 1 to Len(aIteParc)

//                                                         aIteParc[cont,2] := nValPar

//                                             Next

                                   Endif

                        Endif

            Else

                        dDatPar := dDataBase

                        if !Empty(M->VV0_DATINI)

                                   dDatPar := M->VV0_DATINI

                        Endif

                        //             aIteParc := {{dDatPar,iIf(Empty(M->VV0_VALFIN),M->VV0_VALTOT-nTotalEnt,M->VV0_VALFIN)}}

                        aIteParc := {{dDatPar,M->VV0_VALTOT-nTotalEnt-M->VV0_VALFIN}}

            Endif

Endif

 

//M->VV0_VALPAR := nValFin * M->VV0_COEFIC

 

If ( ExistBlock("VM011PFIN") )// Altera Parcelas do Financiamento (aIteParc)

            aParcFin := ExecBlock("VM011PFIN",.F.,.F.,{aIteParc})

            If ( ValType(aParcFin) == "A" )

                        aIteParc := aClone(aParcFin)

            EndIf

EndIf

 

if lTroco .and. nValFin <= 0  //M->VV0_VALFIN == M->VV0_VALTOT

            nValPar  := 0

            aIteParc := {{cTod(""),0}}

Endif

 

if Type("oLbParc") <> "U"

            oLbParc:SetArray(aIteParc)

            oLbParc:bLine := { || { dToc(aIteParc[oLbParc:nAt,1]),;

            Transform(aIteParc[oLbParc:nAt,2],"@E 999,999,999.99")}}

            oLbParc:Refresh()

Endif

 

lJaCal011 := .t.

 

Return(.t.)

Programa Fonte
VEIVM011
Sintaxe

VM011PFIN - Altera parcelas do financiamento ( [ ] )

Parâmetros:
Nome Tipo Descrição Default Obrigatório Referência
Array of Record
Retorno
    ()
Observações

 User Function VM011PFIN(aParc)

 

aParcelas := ParamIxb[1]

 

MsgAlert("O Ponto de Entrada 'VM011PFIN' foi executado!","Sucesso!")

 

 

return(aParcelas)

Exemplos
User Function VM011PFIN(aParc)aParcelas := ParamIxb[1]MsgAlert("O Ponto de Entrada 'VM011PFIN' foi executado!","Sucesso!")return(aParcelas)
Variáveis
Nome Tipo Escopo Pode Alterar descrição
Array of Record Global Não