local cond
cond='month(datapif)=val(m.nl) and year(datapif)=val(m.an) and uzuraprec=0'

SET SAFETY Off
close database

LOCAL NRL,NRA,L,A,UZ
local i,t,k,ancrt,luncrt,firmcrt
public m.an, m.nl, m.t_2121, m.t_2122, m.t_2123, m.t_2124, m.t_2125, m.t_2126, an, nl
store 0 to i, k, m.t_2121, m.t_2122, m.t_2123, m.t_2124, m.t_2125, m.t_2126

ancrt=m.an
luncrt=m.nl
firmcrt=nfscurt


select 0
use &calefirma\datean\calendar.dbf again alias calendar
SELE CALENDAR
scan for !deleted()
date = calefirma+'\an'+an+'\date'+nl
*SELECT 0
*if !file('&DATE\mf.dbf')
*	copy file &dirgen\mfix2000\date\*.* to &date\*.*
*endif
*wait wind date
endscan

sele 0
use &DIRGEN\imob2003\datE\sitmf.dbf EXCLUSIVE ALIAS SITMF
ZAP


SELE CALENDAR
scan for !deleted() &&____________

scatter memvar
date = calefirma+'\an'+m.an+'\date'+m.nl
*wait wind date
if file('&DATE\mf.dbf')
select 0
use &DATE\mf.dbf again alias mf
set filter to !casat
*_calc uzura______________________________
STORE 0 TO L,A,UZ
NRL=VAL(M.NL)
NRA=VAL(M.AN)
SELE MF
SCAN
L=MONTH(DATAPIF)
A=YEAR(DATAPIF)
UZ=IIF(NRA<A,0,12*(NRA-A)+NRL-L)
REPL UZURA WITH UZ+uzuraprec
ENDSCAN
*_scriu in sitmf______________________________
for i=1 to 6	
	t='sum amortlun to m.r_212' +str(i,1)+' for left(scd,4) = "212'+str(i,1)+'" '
	&t
	t='sum amorttot to m.t_212' +str(i,1)+' for left(scd,4) = "212'+str(i,1)+'" '
	&t
	t='sum VALOARE to m.V_212' +str(i,1)+' for left(scd,4) = "212'+str(i,1)+'" '
	&t
	t='sum VALOARE to m.Vr_212' +str(i,1)+' for month(dataact)=val(m.nl) and left(scd,4) = "212'+str(i,1)+'" '
	&t
next
sele sitmf
appe blank
gather memvar
SELE MF
USE
endif
endscan	&&___________


m.an=ancrt
m.nl=luncrt
nfscurt=firmcrt


do totv