CLOSE ALL


SET DELETED ON

SET DATE GERMAN
SET CENTURY on	
USE zagkalk ALIAS zagkalk IN 0
SELECT zagkalk
ZAP
APPEND BLANK
replace zagkalk.brdok WITH "PS"
REPLACE zagkalk.datum WITH CTOD("01.01.2021")

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.2021")
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 mnab
SUM kolicina*pcena TO mpro
SELECT zagkalk
GOTO top
replace zagkalk.nvred WITH mnab
replace zagkalk.pvred WITH mpro
replace zagkalk.dobvre WITH mnab

USE nivstav ALIAS nivstav 
SELECT nivstav
zap

USE povstav ALIAS povstav 
SELECT povstav
ZAP
	
USE prihod ALIAS prihod 
SELECT prihod
ZAP

USE kalostav ALIAS kalostav 
SELECT kalostav
ZAP

USE racstav ALIAS racstav 
SELECT racstav
ZAP

USE rpovstav ALIAS rpovstav 
SELECT rpovstav
ZAP

USE rzagpov ALIAS rzagpov 
SELECT rzagpov
ZAP

USE zagkalo ALIAS zagkalo 
SELECT zagkalo
ZAP

USE zagniv ALIAS zagniv 
SELECT zagniv
ZAP

USE zagpov ALIAS zagpov 
SELECT zagpov
ZAP

USE zagrac ALIAS zagrac 
SELECT zagrac
ZAP

USE zagracp ALIAS zagracp 
SELECT zagracp
zap		