SET DATE GERMAN
SET CENTURY on
SET DELETED ON
USE D:\2009\POD\jul\zagnal ALIAS zagnal IN 0
USE d:\2009\pod\jul\stavnal ALIAS stavnal IN 0

USE D:\2009\fin\BAZE\gknjiga ALIAS gknjiga IN 0
SELECT GKNJIGA
ZAP

SELECT zagnal
GOTO TOP
DO WHILE !EOF()
mnalid=zagnal.nalogid
mpred=zagnal.preduzece
mnal=zagnal.nalog
mdok=zagnal.dokument
mdat=zagnal.datum
mspo=zagnal.spoljni
IF VAL(mpred)<>1
	SKIP
	LOOP
ENDIF
	
SELECT stavnal
SET ORDER TO tag nalogid
GOTO top
SEEK mnalid
DO WHILE !EOF()
IF mnalid<>stavnal.nalogid
	EXIT
ENDIF

IF FOUND()
*	mdat=stavnal.datum
	mval=stavnal.valuta
	mkonto=stavnal.konto
	manal=stavnal.analitika
	mdug=stavnal.duguje
	mpot=stavnal.potrazuje
	IF mdat=CTOD("01.01.2009")
		mnal="00"
		mdok="PS"
	endif	
	SELECT gknjiga
	APPEND BLANK
	replace gknjiga.datum 	WITH mdat
	replace gknjiga.nalog 	WITH mnal
	replace gknjiga.dokument WITH mdok
	replace gknjiga.konto	WITH mkonto
	replace gknjiga.analitika	WITH manal
	replace gknjiga.opis 	WITH mspo
	replace gknjiga.duguje	WITH mdug
	replace gknjiga.potrazuje	WITH mpot
	replace gknjiga.datknji	WITH mdat
	replace gknjiga.dpo 	WITH mdat
	replace gknjiga.valuta 	WITH mval
ENDIF
SELECT stavnal
SKIP
ENDDO

SELECT zagnal
SKIP
ENDDO

return
