Files
roaimob/Programe/Vechi/calcamort.prg

28 lines
1.2 KiB
Plaintext

local cond,c,t,i,a,m.amortlun
cond='month(datapif)=val(m.nl) and year(datapif)=val(m.an) and uzuraprec=0'
sele mf
scan
do case
case UPPER(left(tipamort,1))='L'&&LINIARA
repl amortlun with IIF(UZURA>NORMAT or &cond ,0,iif(uzura=normat,valoare-AMORTprec,ROUND((valoare-AMORTprec)/(normat-UZURA+1),0)))
repl amortan with amortlun*12
case UPPER(left(tipamort,1))='A'&&ACCELERATA
IF (P>0 AND P<=0.5) AND UZURA<=12
repl amortlun with IIF(UZURA>NORMAT or &cond ,0,iif(uzura=normat,valoare-AMORTprec,ROUND(valoare*P/12,0)))
ELSE
repl amortlun with IIF(UZURA>NORMAT or &cond ,0,iif(uzura=normat,valoare-AMORTprec,ROUND((valoare*(1-p))/(normat-12),0)))
ENDIF
repl amortan with amortlun*12
case UPPER(left(tipamort,1))='D'&&DEGRESIVA
if mod(uzura,12)=1
c=12*k/normat
repl amortan with iif(uzura>normat,0,round((valoare-amortprec)*c,0))
if amortan<12*valoare/normat
repl amortan with iif(uzura>normat,0,(valoare-amortprec)/(normat/12-round(uzura/12,0)))
endif
endif
REPL AMORTLUN WITH IIF(UZURA>NORMAT or &cond ,0,iif(uzura=normat,valoare-AMORTprec,round(amortan/12,0)))
ENDCASE
repl amorttot with amortprec+amortlun
endscan