
CLOSE ALL

SET DEFAULT TO D:\2025\BAZE
SET DELETED ON

SET DATE GERMAN
SET CENTURY on	
SET EXCLUSIVE on
set console off
SET SAFETY OFF
set talk off


USE zagkalk ALIAS zagkalk IN 0
SELECT zagkalk
ZAP

USE kalkstav ALIAS kalkstav IN 0
SELECT kalkstav
ZAP

USE brisano ALIAS brisano IN 0
SELECT brisano 
ZAP

USE brojac ALIAS brojac IN 0
SELECT brojac
GOTO top
*replace faktura WITH SPACE(6)
replace kalkulacc WITH SPACE(6)
replace kalkulac WITH SPACE(6)
*replace racun WITH SPACE(6)
replace kalkulac WITH SPACE(6)

USE crta ALIAS crta IN 0
SELECT crta
ZAP

*USE greska ALIAS greska IN 0
*SELECT greska
*ZAP

USE greske ALIAS greske IN 0
SELECT greske
ZAP

USE intstav ALIAS intstav IN 0
SELECT intstav
ZAP

USE inventar ALIAS inventar IN 0
SELECT inventar
ZAP

USE invstav ALIAS invstav IN 0
SELECT invstav
ZAP

USE izvod ALIAS izvod IN 0
SELECT izvod
ZAP

USE kalkstavc ALIAS kalkstavc IN 0
SELECT kalkstavc
ZAP

*USE kalkstavu ALIAS kalkstavu IN 0
*SELECT kalkstavu
*ZAP

USE kalostav ALIAS kalostav IN 0
SELECT kalostav
ZAP

USE nivstav ALIAS nivstav IN 0
SELECT nivstav
ZAP

USE povstav ALIAS povstav IN 0
SELECT povstav
ZAP

USE prihod ALIAS prihod IN 0
SELECT prihod
ZAP

USE racstav ALIAS racstav IN 0
SELECT racstav
ZAP

USE racstavp ALIAS racstavp IN 0
SELECT racstavp
ZAP

USE rpovstav ALIAS rpovstav IN 0
SELECT rpovstav
ZAP

USE rzagpov ALIAS rzagpov IN 0
SELECT rzagpov
ZAP

*USE virman ALIAS virman IN 0
*SELECT virman
*ZAP

USE zagfak ALIAS zagfak IN 0
SELECT zagfak
ZAP

USE zagint ALIAS zagint IN 0
SELECT zagint
ZAP

USE zaginv ALIAS zaginv IN 0
SELECT zaginv
ZAP

USE zagkalkc ALIAS zagkalkc IN 0
SELECT zagkalkc
ZAP

*USE zagkalku ALIAS zagkalku IN 0
*SELECT zagkalku
*ZAP

USE zagkalo ALIAS zagkalo IN 0
SELECT zagkalo
ZAP

USE zagniv ALIAS zagniv IN 0
SELECT zagniv
ZAP

USE zagpov ALIAS zagpov IN 0
SELECT zagpov
ZAP

USE zagrac ALIAS zagrac IN 0
SELECT zagrac
ZAP

USE zagracp ALIAS zagracp IN 0
SELECT zagracp
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
	a2=0
endif	
IF a31<0.1
	a31=1
endif	
a4=roba.tarifa
SELECT kalkstavc
APPEND blank
replace kalkstavc.brdok WITH "PS"
replace kalkstavc.datum WITH CTOD("01.01.2025")
replace kalkstavc.sifrob WITH a1
replace kalkstavc.kolicina WITH a2
replace kalkstavc.dobcen WITH a31
replace kalkstavc.ncena WITH a31
replace kalkstavc.pcena WITH a3
replace kalkstavc.tarifa WITH a4
IF a4="20"
	replace kalkstavc.stopa WITH 20
ELSE
	replace kalkstavc.stopa WITH 10
ENDIF
SELECT roba
SKIP
ENDDO

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

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

RETURN
