SET DELETED ON
SET DATE GERMAN
SET CENTURY on

OPEN DATABASE str SHARED

USE roba ALIAS roba IN 0
USE kalkstav ALIAS kalkstav IN 0
SELECT roba
**ZAP
SELECT kalkstav 
**ZAP

OPEN DATABASE d:\mevex\baze\belcar SHARED

USE fakstav ALIAS fakstav IN 0
**USE roba ALIAS vproba IN 0

*!*	select vproba
*!*	GOTO top
*!*	DO WHILE !EOF()
*!*	a1=vproba.sifrob
*!*	a2=vproba.naziv
*!*	a3=vproba.katbroj
*!*	a4=vproba.tarifa
*!*	SELECT roba
*!*	SET ORDER TO sifrob
*!*	GOTO top
*!*	SEEK a1
*!*	IF !FOUND()
*!*		APPEND BLANK
*!*		replace roba.sifrob  	WITH a1
*!*		replace roba.naziv 		WITH a2
*!*		replace roba.barkod		WITH a3
*!*		replace roba.datum		WITH CTOD("20.10.2011")
*!*		replace roba.tarifa 	WITH a4
*!*	endif
*!*	SELECT vproba
*!*	SKIP
*!*	ENDDO

SELECT fakstav
GOTO top
DO WHILE !EOF()
IF fakstav.brdok<>"000090" &&.and. fakstav.brdok<>"000002" .and. fakstav.brdok<>"000003"
	SKIP
	LOOP
ENDIF
a1=fakstav.sifrob
a2=fakstav.kolicina
a3=fakstav.pcena
a4=fakstav.rabat
a5=fakstav.brdok
SELECT kalkstav
APPEND BLANK
*IF a5="000090"
	replace kalkstav.brdok WITH "000311"
*ENDIF
*!*	IF a5="000002"
*!*		replace kalkstav.brdok WITH "000174"
*!*	ENDIF
*!*	IF a5="000003"
*!*		replace kalkstav.brdok WITH "000175"
*!*	ENDIF	
replace kalkstav.kupdob WITH "0002"
replace kalkstav.datum WITH CTOD("18.10.2011")
replace kalkstav.kolicina WITH a2
replace kalkstav.sifrob	WITH a1
replace kalkstav.dobcen WITH a3
replace kalkstav.rabat WITH a4
replace kalkstav.ncena WITH a3*(1-a4/100)
replace kalkstav.pcena WITH ROUND(a3*1.25*1.18,0)
replace kalkstav.stopa WITH 18
replace kalkstav.tarifa WITH "18"
SELECT fakstav
SKIP
ENDDO


