
CLOSE ALL

SET DEFAULT TO E:\2020\BAZE
SET DELETED ON

SET DATE GERMAN
SET CENTURY on	
SET EXCLUSIVE on
USE zagkalk ALIAS zagkalk IN 0
SELECT zagkalk
ZAP

USE kalkstav ALIAS kalkstav IN 0
SELECT kalkstav
ZAP

USE roba ALIAS roba IN 0

SELECT roba
GOTO top
DO WHILE !EOF()
a1=roba.sifrob
a2=roba.kolicina
a3=roba.procen
a31=roba.nabcen
IF a2<=0
**	SKIP
**	LOOP
endif	
IF a31<0.1
	a31=1
endif	
a4=roba.tarifa
SELECT kalkstav
APPEND blank
replace kalkstav.brdok WITH "PS"
replace kalkstav.datum WITH CTOD("01.01.2020")
replace kalkstav.sifrob WITH a1
replace kalkstav.kolicina WITH a2
replace kalkstav.dobcen WITH a31
replace kalkstav.ncena WITH a31
replace kalkstav.pcena WITH a3
replace kalkstav.tarifa WITH a4
IF a4="20"
	replace kalkstav.stopa WITH 20
ELSE
	replace kalkstav.stopa WITH 10
ENDIF
SELECT roba
SKIP
ENDDO

SELECT kalkstav
SUM kolicina*ncena TO mnce
SUM kolicina*pcena TO mpce

SELECT zagkalk
APPEND BLANK
replace zagkalk.brdok WITH "PS"
replace zagkalk.datum WITH CTOD("01.01.2020")
replace zagkalk.valuta WITH CTOD("01.01.2020")
replace zagkalk.nvred WITH mnce
replace zagkalk.pvred WITH mpce

RETURN
