*/* ********************************
*/* PROCEDURE gen_exp_kros_kosice
*/* ********************************
PARAMETERS kontroluj,rokuct,mesuct
PRIVATE old_century,menoexp,oldsetdate,oldsetdele, riadkov, sumacelk,dokluzod,dokluzdo,prijemky, vydajky, ok
PRIVATE auzaverka
m.gcuexp_path=IIF(EMPTY(m.gcuexp_path),m.gcucto_path,m.gcuexp_path)
m.old_century=SET("century")
m.oldsetdate=SET("date")
m.oldsetdele=SET("dele")
SET DATE TO GERMAN
SET DELETED ON

m.gcuexp_path=ALLTRIM(IIF(EMPTY(m.gcuexp_path),m.gcucto_path,m.gcuexp_path))
IF ! DIRECTORY(m.gcuexp_path)
	MKDIR (m.gcuexp_path)
ENDIF
SET CENTURY ON
gen_exp_had = CREATEOBJECT("had", jaz("form gener export"))
gen_exp_had.SHOW()
gen_exp_had.set_max(20)
*** Trzby ***
IF m.gcuct_trzba
	*/* vymazanie nefiskalnych trzieb z exportu
	*/* ***************************************
	IF m.issql
		USE (m.sqlprefix+"rdruhypl") ALIAS druhy_pl IN 0
	ELSE 
		USE (m.gchom_path+"druhy_pl.dbf") IN 0
	ENDIF 
	DELETE FROM u_ex_platby WHERE druh_pl IN (SELECT nazev as druh_pl FROM druhy_pl WHERE cisfplat<1)
	USE IN druhy_pl
	*/* koniec vymazanie nefiskalnych trzieb z exportu
	*/* **********************************************
	gen_exp_had.INCREMENT("Tržby")
	IF !m.issql
		IF !FILE(m.gcdat_path+"sap_cd.dbf")
			SELECT 0
			CREATE TABLE (m.gcdat_path+"sap_cd") FREE (meno c(8), pc i, rok c(4), mesiac c(2),evidencia c(4), cisrad c(4))
			USE
		ELSE
			SELECT 0
			USE (m.gcdat_path+"sap_cd.dbf")
			IF FSIZE("cisrad")=0
				USE IN sap_cd
				TRY
					USE (m.gcdat_path+"sap_cd.dbf") EXCLUSIVE
					ALTER TABLE sap_cd ADD COLUMN cisrad c(4)
					USE IN sap_cd
				CATCH
				ENDTRY
			ENDIF
		ENDIF
		DO pozavirej WITH "sap_cd"
	ENDIF 
	SELECT SUM(castka) AS ciastka, MD,dal,md2,dal2,hs_dal,hs_md,partner,pz, poznamka, $0 AS celkom, 1.000000000 AS koef FROM u_ex_platby GROUP BY pz,poznamka,MD,dal INTO CURSOR u_doklady READWRITE 
	SELECT SUM(castka) AS ciastka, pz FROM u_ex_platby GROUP BY pz INTO CURSOR u_platby READWRITE 
	INDEX ON ALLTRIM(pz) TAG pz
	SELECT u_doklady
	SET RELATION TO ALLTRIM(pz) INTO u_platby
	REPLACE ALL u_doklady.celkom WITH u_platby.ciastka
	SET RELATION OFF INTO u_platby
	USE IN u_platby
	REPLACE ALL koef WITH IIF(celkom=0,1,ciastka/celkom)

	SELECT SUM(castka) AS ciastka, MD,dal,hs_md, hs_dal,md2,dal2, pz, partner,poznamka,poznamka AS txtdan, $0 AS danzakl, $0 AS dan FROM u_ex_polozky GROUP BY pz,poznamka,MD,dal INTO CURSOR u_dokl1  READWRITE  
	SELECT u_dokl1
	REPLACE ALL txtdan WITH SUBSTR(txtdan,RAT(" ",ALLTRIM(txtdan)))
	REPLACE ALL dan WITH ciastka*VAL(txtdan)/(100+VAL(txtdan))
	REPLACE ALL danzakl WITH ciastka-dan
	SELECT pz,SUM(ciastka) AS ciastka, SUM(danzakl) AS danzakl, SUM(dan) AS dan, SUM(dan) AS danxx, SUM(dan) AS danxxx,partner, MD, dal, md2, dal2,hs_md, hs_dal, poznamka,txtdan  FROM u_dokl1 GROUP BY pz, MD, dal, hs_md, hs_dal, txtdan, poznamka INTO CURSOR u_dokl2 READWRITE 
	INDEX ON pz TAG pz
	SELECT pz, SUM(dan) AS dan FROM u_dokl1 GROUP BY pz INTO CURSOR u_doklxx READWRITE 
	INDEX ON pz TAG pz
	USE IN u_dokl1
	SELECT u_dokl2
	SET RELATION TO pz INTO u_doklxx
	SET SKIP TO u_doklxx
	REPLACE ALL danxx WITH ground(u_doklxx.dan,2)
	SET RELATION OFF INTO u_doklxx
	USE IN u_doklxx
	REPLACE ALL ciastka WITH ground(ciastka,2), danzakl WITH ground(danzakl,2), dan WITH ground(dan,2)
	SELECT pz, SUM(dan) AS dan FROM u_dokl2 GROUP BY pz INTO CURSOR u_doklxx READWRITE 
	INDEX ON pz TAG pz
	SELECT u_dokl2
	SET RELATION TO pz INTO u_doklxx
	SET SKIP TO u_doklxx
	REPLACE ALL danxxx WITH u_doklxx.dan
	SET RELATION OFF INTO u_doklxx
	USE IN u_doklxx
	SELECT u_dokl2
	m.ptz="yayayaya"
	SCAN ALL
		IF m.ptz=u_dokl2.pz
		ELSE
			IF ALLTRIM(txtdan)<>"0"
				REPLACE dan	WITH dan+danxx-danxxx
				m.ptz=u_dokl2.pz
			ENDIF
		ENDIF
	ENDSCAN
	REPLACE ALL danzakl WITH ciastka-dan
	SELECT pz,SUM(ciastka) AS ciastka, SUM(danzakl) AS danzakl, SUM(dan) AS dan, partner, MD, dal, hs_md, hs_dal, md2, dal2,poznamka,txtdan  FROM u_dokl2 GROUP BY pz, MD, dal, hs_md, hs_dal, txtdan, poznamka INTO CURSOR u_dokl READWRITE 
	INDEX ON ALLTRIM(pz) TAG pz
	USE IN u_dokl2
	SELECT u_doklady
	IF !prazdna()
		m.gcuexp_path = ALLTRIM(m.gcuexp_path)
		IF ! DIRECTORY(m.gcuexp_path)
			MKDIR (m.gcuexp_path)
		ENDIF
		SELECT SPACE(17) AS uzaverka,ciastka, MD,dal,md2,dal2,hs_dal,hs_md,poznamka, poznamka AS pozn_pol,celkom, $0 AS danzakl, $0 AS dan, ;
			SPACE(5) AS sadzba FROM u_doklady INTO  CURSOR vondbf WHERE .f. READWRITE 
		SELECT u_doklady
		SCAN FOR !EMPTY(u_doklady.MD) .AND. !EMPTY(u_doklady.dal) .AND. u_doklady.ciastka<>0
			SELECT u_dokl
			SCAN FOR pz=u_doklady.pz .AND. !EMPTY(u_dokl.MD) .AND. !EMPTY(u_dokl.dal)
				IF u_doklady.MD=u_dokl.dal
					INSERT INTO vondbf (uzaverka,ciastka,MD,dal,md2,dal2,hs_md,hs_dal, danzakl, dan, sadzba, poznamka, pozn_pol) VALUES ;
						(LEFT(u_dokl.pz,17),ROUND(u_dokl.ciastka*u_doklady.koef,2),u_dokl.MD,u_doklady.dal,u_dokl.md2,u_doklady.dal2,u_dokl.hs_md,u_doklady.hs_dal,ROUND(u_dokl.danzakl*u_doklady.koef,2),ROUND(u_dokl.dan*u_doklady.koef,2),u_dokl.txtdan,u_doklady.poznamka,u_dokl.poznamka)
				ELSE
					IF u_doklady.dal=u_dokl.MD
						INSERT INTO vondbf (uzaverka,ciastka,MD,dal,md2,dal2,hs_md,hs_dal, danzakl, dan, sadzba,poznamka,pozn_pol) VALUES ;
							(LEFT(u_dokl.pz,17),ROUND(u_dokl.ciastka*u_doklady.koef,2),u_doklady.MD,u_dokl.dal,u_doklady.md2,u_dokl.dal2,u_doklady.hs_md,u_dokl.hs_dal,ROUND(u_dokl.danzakl*u_doklady.koef,2),ROUND(u_dokl.dan*u_doklady.koef,2),u_dokl.txtdan,u_doklady.poznamka,u_dokl.poznamka)
					ENDIF
				ENDIF
			ENDSCAN
			SELECT u_doklady
		ENDSCAN
		SELECT uzaverka,SUM(ciastka) AS ciastka,MD,dal,md2,dal2,hs_md,hs_dal, SUM(danzakl) AS danzakl, SUM(dan) AS dan, sadzba,poznamka, pozn_pol FROM vondbf ;
			GROUP BY uzaverka, MD, dal, sadzba,poznamka, pozn_pol INTO CURSOR vondbf2 READWRITE 
		SELECT uzaverka, SUM(ciastka) AS ciastka,MD,dal,md2,dal2,hs_md,hs_dal, 0000000000.00 AS cena0, 0000000000.00 AS cena5, 0000000000.00 AS cena23, 000000000.00 AS dan5, 000000000.00 AS dan23,.F. AS vymaz,.F. AS storno,poznamka, pozn_pol FROM vondbf ;
			GROUP BY uzaverka, MD, dal,poznamka, pozn_pol INTO CURSOR vondbf1 READWRITE  
		m.riadkov=1
		SCAN ALL
			SELECT vondbf2
			SCAN FOR MD=vondbf1.MD .AND. dal=vondbf1.dal .AND. uzaverka=vondbf1.uzaverka .AND. poznamka=vondbf1.poznamka .AND. pozn_pol=vondbf1.pozn_pol
				DO CASE
					CASE ALLTRIM(sadzba)="0"
						REPLACE vondbf1.cena0 WITH vondbf2.danzakl
					CASE ALLTRIM(sadzba)=ALLTRIM(STR((m.uctdphlo-1)*100,10,0))
						REPLACE vondbf1.cena5 WITH vondbf2.danzakl, vondbf1.dan5 WITH vondbf2.dan
					OTHERWISE
						REPLACE vondbf1.cena23 WITH vondbf2.danzakl, vondbf1.dan23 WITH vondbf2.dan
				ENDCASE
			ENDSCAN
		ENDSCAN
		IF !m.issql
			IF FILE(m.gcdat_path+"uexarsk.dbf")
				SELECT 0
				USE (m.gcdat_path+"uexarsk.dbf")
			ELSE
				SELECT vondbf1
				COPY STRUCTURE TO (m.gcdat_path+"uexarsk.dbf")
				SELECT 0
				USE (m.gcdat_path+"uexarsk.dbf")
			ENDIF
		ENDIF 
		IF m.kontroluj
			SELECT DISTINCT uzaverka FROM vondbf1 INTO CURSOR datumy READWRITE 
			SCAN ALL
				m.hladajuzaverka=datumy.uzaverka
				m.oprava=0
				SELECT vondbf1
				SCAN FOR uzaverka=datumy.uzaverka
					IF m.issql
						IF USED("uexarsk")
							=REQUERY("uexarsk")
						ELSE
							USE (m.sqlprefix+"ruexarsk_uzaverka") ALIAS uexarsk IN 0
							=CURSORSETPROP("Buffering",5,"uexarsk")
						ENDIF 
					ENDIF 
					SELECT uexarsk
					LOCATE FOR uzaverka=vondbf1.uzaverka
					IF FOUND()
						LOCATE FOR ALLTRIM(uzaverka)=ALLTRIM(vondbf1.uzaverka) .AND. ciastka=vondbf1.ciastka .AND. ALLTRIM(MD)=ALLTRIM(vondbf1.MD) .AND. ALLTRIM(dal)=ALLTRIM(vondbf1.dal) .AND. cena0=vondbf1.cena0 .AND. cena5=vondbf1.cena5 ;
							.AND. cena23=vondbf1.cena23 .AND. dan5=vondbf1.dan5 .AND. dan23=vondbf1.dan23 .AND. ALLTRIM(hs_md)=ALLTRIM(vondbf1.hs_md) .AND. ALLTRIM(hs_dal)=ALLTRIM(vondbf1.hs_dal) .AND. ALLTRIM(poznamka)=ALLTRIM(vondbf1.poznamka) .AND. ALLTRIM(pozn_pol)=ALLTRIM(vondbf1.pozn_pol)
						IF !FOUND()
							m.oprava=2
						ELSE
							m.oprava=1
						ENDIF
					ELSE
						m.oprava=0
					ENDIF
					SELECT vondbf1
					IF m.oprava=2
						EXIT
					ENDIF
				ENDSCAN
				DO CASE
					CASE m.oprava=2
						SELECT uexarsk
						SCAN FOR uzaverka=datumy.uzaverka
							INSERT INTO vondbf1 (uzaverka,ciastka,MD,dal,hs_md, hs_dal,md2,dal2,cena0,cena5,cena23,dan5,dan23,storno, poznamka, pozn_pol);
								VALUES (uexarsk.uzaverka,-uexarsk.ciastka,uexarsk.MD,uexarsk.dal,uexarsk.hs_md,uexarsk.hs_dal,uexarsk.md2,uexarsk.dal2,-uexarsk.cena0,-uexarsk.cena5,;
								-uexarsk.cena23,-uexarsk.dan5,-uexarsk.dan23,.T., uexarsk.poznamka, uexarsk.pozn_pol)
						ENDSCAN
					CASE m.oprava=1
						SELECT vondbf1
						DELETE FOR uzaverka=datumy.uzaverka
				ENDCASE
				SELECT datumy
			ENDSCAN
			IF m.issql
				USE (m.sqlprefix+"ruexarsk_zoznam_uzavierok") ALIAS uexzoznam IN 0
				SELECT DISTINCT uzaverka FROM uexzoznam WHERE uzaverka>m.skuzod .AND. uzaverka<=m.skuzdo .AND. !(uzaverka IN (SELECT DISTINCT uzaverka FROM datumy));
					INTO CURSOR datumy2 READWRITE 
				USE IN uexzoznam
			ELSE 
				SELECT DISTINCT uzaverka FROM uexarsk WHERE uzaverka>m.skuzod .AND. uzaverka<=m.skuzdo .AND. !(uzaverka IN (SELECT DISTINCT uzaverka FROM datumy));
					INTO CURSOR datumy2 READWRITE 
			ENDIF 
			SCAN ALL
				m.hladajuzaverka=datumy2.uzaverka
				IF m.issql
					IF USED("uexarsk")
						=REQUERY("uexarsk")
					ELSE
						USE (m.sqlprefix+"ruexarsk_uzaverka") ALIAS uexarsk IN 0
						=CURSORSETPROP("Buffering",5,"uexarsk")
					ENDIF 
				ENDIF 
				SELECT uexarsk
				SCAN FOR uzaverka=datumy2.uzaverka
					INSERT INTO vondbf1 (uzaverka,ciastka,MD,dal,hs_md, hs_dal,cena0,cena5,cena23,dan5,dan23,storno,vymaz, poznamka, pozn_pol);
						VALUES (uexarsk.uzaverka,-uexarsk.ciastka,uexarsk.MD,uexarsk.dal,uexarsk.hs_md,uexarsk.hs_dal,-uexarsk.cena0,-uexarsk.cena5,;
						-uexarsk.cena23,-uexarsk.dan5,-uexarsk.dan23,.F.,.T., uexarsk.poznamka, uexarsk.pozn_pol)
				ENDSCAN
				SELECT datumy2
			ENDSCAN
			USE IN datumy2
		ENDIF
		SELECT DISTINCT uzaverka FROM vondbf1 INTO CURSOR uzaverky WHERE !EMPTY(uzaverka) READWRITE 
		IF RECCOUNT()>0
			SCAN ALL
				m.hladajuzaverka=uzaverky.uzaverka
				m.rokuct=LEFT(m.hladajuzaverka,4)
				m.mesuct=SUBSTR(m.hladajuzaverka,5,2)
				SELECT 0
				m.poraduz=dajsapcdcislo("Kasy",m.rokuct, m.mesuct, "", m.gcuct_evidencia2, m.gcuct_cisrad2)
				m.evidencia=m.gcuct_evidencia2
				m.menoexp="Kasy"+RIGHT(m.rokuct,2)+m.mesuct+STRTRAN(STR(m.poraduz,4,0)," ","0")+".txt"
				SELECT vondbf1
				GO TOP
				COUNT TO m.assasas FOR !DELETED() AND uzaverka=m.hladajuzaverka
				IF m.assasas>0
					m.lihandle= FCREATE(m.gcuexp_path + m.menoexp)
					IF m.lihandle > 0
						SELECT vondbf1
						*						SCATTER memvar
						SELECT DISTINCT SUBSTR(pozn_pol,5,2) AS id_kas FROM vondbf1 INTO CURSOR uct_kasy WHERE uzaverka=m.hladajuzaverka READWRITE 
						IF RECCOUNT()>0
							DO kros_kosice_trz_00
							SELECT SUM(ciastka) AS ciastka, $0 AS c0,  $0 AS c5, $0 AS c23, $0 AS d5, $0 AS d23, $0 AS cb FROM vondbf1 INTO CURSOR uct_polozky WHERE uzaverka=m.hladajuzaverka READWRITE 
							SELECT vondbf1
							SUM cena0 TO uct0 FOR SUBSTR(ALLTRIM(pozn_pol),1+RAT(" ",ALLTRIM(pozn_pol)))="0" .AND. !("City tax"$pozn_pol) AND uzaverka=m.hladajuzaverka
							SELECT uct_polozky
							REPLACE c0 WITH m.uct0
							SELECT vondbf1
							SUM cena0 TO uct0 FOR SUBSTR(ALLTRIM(pozn_pol),1+RAT(" ",ALLTRIM(pozn_pol)))="0" .AND. ("City tax"$pozn_pol) AND uzaverka=m.hladajuzaverka
							SELECT uct_polozky
							REPLACE cb WITH m.uct0
							SELECT vondbf1
							SUM cena5 TO uct0 FOR SUBSTR(ALLTRIM(pozn_pol),1+RAT(" ",ALLTRIM(pozn_pol)))=ALLTRIM(STR(m.uctdphlo*100-100,2,0)) AND uzaverka=m.hladajuzaverka
							SELECT uct_polozky
							REPLACE c5 WITH m.uct0
							SELECT vondbf1
							SUM cena23 TO uct0 FOR SUBSTR(ALLTRIM(pozn_pol),1+RAT(" ",ALLTRIM(pozn_pol)))=ALLTRIM(STR(m.uctdphhi*100-100,2,0)) AND uzaverka=m.hladajuzaverka
							SELECT uct_polozky
							REPLACE c23 WITH m.uct0
							SELECT vondbf1
							SUM dan5 TO uct0 FOR SUBSTR(ALLTRIM(pozn_pol),1+RAT(" ",ALLTRIM(pozn_pol)))=ALLTRIM(STR(m.uctdphlo*100-100,2,0)) AND uzaverka=m.hladajuzaverka
							SELECT uct_polozky
							REPLACE d5 WITH m.uct0
							SELECT vondbf1
							SUM dan23 TO uct0 FOR SUBSTR(ALLTRIM(pozn_pol),1+RAT(" ",ALLTRIM(pozn_pol)))=ALLTRIM(STR(m.uctdphhi*100-100,2,0)) AND uzaverka=m.hladajuzaverka
							SELECT uct_polozky
							REPLACE d23 WITH m.uct0
							DO kros_kosice_trz_01 WITH m.hladajuzaverka
							USE IN uct_polozky
							SELECT uct_kasy
							SCAN ALL
								SCATTER MEMVAR FIELDS id_kas
								SELECT SUM(ciastka) AS ciastka, MD,SPACE(6) AS dal,(poznamka+" "+SUBSTR(pozn_pol,8,2)) AS poznamka, "" AS hs_md, "" AS hs_dal,"S" AS typ FROM vondbf1 GROUP BY poznamka, pozn_pol, MD, dal, hs_md, hs_dal WHERE SUBSTR(pozn_pol,5,2)=m.id_kas AND uzaverka=m.hladajuzaverka INTO CURSOR uct_polozky READWRITE 
								SCAN FOR uct_polozky.ciastka<>0
									DO kros_kosice_trz_02
								ENDSCAN
								USE IN uct_polozky
								SELECT SUM(dan5+dan23) AS ciastka, md2 AS MD, dal2 AS dal, "DPH "+IIF(m.id_kas="HO","Hores",m.id_kas)+" "+SUBSTR(pozn_pol,8,2) AS poznamka, "" AS hs_md, "" AS hs_dal,"04" AS typ FROM vondbf1 GROUP BY MD, dal, poznamka,pozn_pol, hs_md, hs_dal INTO CURSOR uct_polozky WHERE SUBSTR(pozn_pol,5,2)=m.id_kas AND uzaverka=m.hladajuzaverka READWRITE 
								SCAN FOR uct_polozky.ciastka<>0
									DO kros_kosice_trz_02
								ENDSCAN
								USE IN uct_polozky
								SELECT SUM(cena0+cena5+cena23) AS ciastka, SPACE(6) AS MD, dal, "Trzba "+SUBSTR(pozn_pol,5) AS poznamka, hs_md, hs_dal,"03" AS typ, RIGHT(ALLTRIM(pozn_pol),2) AS dan FROM vondbf1 GROUP BY MD, dal, poznamka, pozn_pol, hs_md, hs_dal INTO CURSOR uct_polozky   WHERE SUBSTR(pozn_pol,5,2)=m.id_kas AND uzaverka=m.hladajuzaverka READWRITE
								REPLACE typ WITH "V" FOR dan=" 0"
								SCAN FOR uct_polozky.ciastka<>0
									DO kros_kosice_trz_02
								ENDSCAN
								USE IN uct_polozky
								SELECT uct_kasy
							ENDSCAN
							USE IN uct_kasy
							=FCLOSE(m.lihandle)
						ENDIF
						IF m.issql
							DO open_database
							IF USED("uexarsk")
								=REQUERY("uexarsk")
							ELSE
								USE (m.sqlprefix+"ruexarsk_uzaverka") ALIAS uexarsk IN 0
								=CURSORSETPROP("Buffering",5,"uexarsk")
							ENDIF 
							SELECT uexarsk
							DELETE ALL 
							=tux(.t.,.t.,"uexarsk")
						ELSE 
							SELECT uexarsk
							DELETE FOR uzaverka=m.hladajuzaverka
						ENDIF 
						SELECT uexarsk
						IF m.archivovatprenosy   
							APPEND FROM DBF("vondbf1") FOR !storno .AND. !vymaz .AND. uzaverka=m.hladajuzaverka
						ENDIF 
						IF m.issql
							=tux(.t.,.t.,"uexarsk")
						ENDIF 
					ENDIF
				ENDIF 
				SELECT uzaverky
			ENDSCAN
		ENDIF
		DO pozavirej WITH "uzaverky,uexarsk"
		IF !m.issql
			IF f_acc_ex(m.gcdat_path+"uexarsk")
				PACK
				USE
			ENDIF
		ENDIF 
	ENDIF
	SET CENTURY &old_century
	SET DATE &oldsetdate
	SET DELETED &oldsetdele
	DO pozavirej WITH "vondbf,u_doklady,u_dokl, vondbf1,vondbf2,datumy,u_ex"
ENDIF
SET DELETED &oldsetdele
RELEASE gen_exp_had
RETURN

PROCEDURE kros_kosice_trz_00
m.uct00="R00"+CHR(9) &&prvy riadok zapisu
m.uct00=m.uct00+"T00" &&EUD
= FPUTS(m.lihandle, m.uct00)

PROCEDURE kros_kosice_trz_01()
PARAMETERS _akt_uzaverka
PRIVATE m.pis_datum, m.kk
*/*m.pis_datum=DTOC(GOMONTH(CTOD("01."+m.mesuct+"."+m.rokuct),1)-1)
m.pis_datum=SUBSTR(_akt_uzaverka,7,2)+"."+SUBSTR(_akt_uzaverka,5,2)+"."+SUBSTR(_akt_uzaverka,1,4)
m.mesuct=SUBSTR(_akt_uzaverka,5,2)
m.rokuct=SUBSTR(_akt_uzaverka,1,4)
* Export do KROSu - trzby
m.uct00="R01"+CHR(9) &&druhy riadok
m.uct00=m.uct00+"180"+CHR(9) &&typ dokladu
m.uct00=m.uct00+m.gcuct_evidencia2+CHR(9) &&kod evidencie
m.uct00=m.uct00+m.gcuct_cisrad2+CHR(9) &&kod ciselneho radu
*!*	m.uct00=m.uct00+m.gcuct_evidencia2+"/"+m.gcuct_cisrad2+"/"+m.mesuct+"/"+m.rokuct+"/T"+ALLTRIM(STR(m.poraduz,5,0))+CHR(9) &&cislo interne
*!*	m.uct00=m.uct00+m.gcuct_evidencia2+"/"+m.gcuct_cisrad2+"/"+m.mesuct+"/"+m.rokuct+"/T"+ALLTRIM(STR(m.poraduz,5,0))+CHR(9) &&cislo externe
m.uct00=m.uct00+m.gcuct_evidencia2+m.mesuct+"/"+m.rokuct+"/T"+ALLTRIM(STR(m.poraduz,5,0))+CHR(9) &&cislo interne
m.uct00=m.uct00+m.gcuct_evidencia2+m.mesuct+"/"+m.rokuct+"/T"+ALLTRIM(STR(m.poraduz,5,0))+CHR(9) &&cislo externe
m.uct00=m.uct00+CHR(9) &&meno firmy
m.uct00=m.uct00+CHR(9) &&ICO
m.uct00=m.uct00+CHR(9) &&DIC
m.uct00=m.uct00+m.pis_datum+CHR(9) &&datum vystavenia
m.uct00=m.uct00+CHR(9) &&datum prijatia
m.uct00=m.uct00+m.pis_datum+CHR(9) &&datum splatnosti
m.uct00=m.uct00+m.pis_datum+CHR(9) &&datum uskutocnenia zdanitelneho plnenia
m.uct00=m.uct00+m.pis_datum+CHR(9) &&datum uskutocnenia uctovneho pripadu
m.uct00=m.uct00+"EUR"+CHR(9) &&mena
m.uct00=m.uct00+"1"+CHR(9) &&mnozstvo jednotky
m.uct00=m.uct00+"1"+CHR(9) &&kurz NBS
m.uct00=m.uct00+"0"+CHR(9) &&kurz banka
SELECT uct_polozky
m.uct00=m.uct00+ALLTRIM(STR(uct_polozky.ciastka,15,2))+CHR(9) &&suma spolu CM
m.uct00=m.uct00+ALLTRIM(STR(uct_polozky.ciastka,15,2))+CHR(9) &&suma spolu TM
m.uct00=m.uct00+ALLTRIM(STR(m.uctdphlo*100-100,5,0))+CHR(9) &&sadzba nizsia
m.uct00=m.uct00+ALLTRIM(STR(m.uctdphhi*100-100,5,0))+CHR(9) &&sadzba vyssia
m.uct00=m.uct00+ALLTRIM(STR(uct_polozky.c5,15,2))+CHR(9) &&zaklad nizsia
m.uct00=m.uct00+ALLTRIM(STR(uct_polozky.c23,15,2))+CHR(9) &&zaklad vyssia
m.uct00=m.uct00+ALLTRIM(STR(uct_polozky.c0,15,2))+CHR(9) &&zaklad 0
m.uct00=m.uct00+ALLTRIM(STR(uct_polozky.cb,15,2))+CHR(9) &&zaklad neobsahuje
m.uct00=m.uct00+ALLTRIM(STR(uct_polozky.d5,15,2))+CHR(9) &&suma DPH nizsia
m.uct00=m.uct00+ALLTRIM(STR(uct_polozky.d23,15,2))+CHR(9) &&suma DPH vyssia
m.uct00=m.uct00+ALLTRIM(STR(ciastka-c0-cb-c5-c23-d5-d23,15,2))+CHR(9) &&halierove vyrovnanie
m.uct00=m.uct00+"FoodMan"+CHR(9)  && zaevidoval
m.uct00=STRTRAN(m.uct00,",",".")
= FPUTS(m.lihandle, m.uct00)


PROCEDURE kros_kosice_trz_02
* Export do KROSu - trzby
m.uct00="R02"+CHR(9) &&udaje
m.uct00=m.uct00+"0"+CHR(9) &&typ polozky :0=uctovny zapis
m.uct00=m.uct00+LEFT(ALLTRIM(uct_polozky.MD),3)+CHR(9) &&MD syntetika
m.uct00=m.uct00+SUBSTR(ALLTRIM(uct_polozky.MD),4,3)+CHR(9) &&MD analytika
m.uct00=m.uct00+LEFT(ALLTRIM(uct_polozky.dal),3)+CHR(9) &&DAL syntetika
m.uct00=m.uct00+SUBSTR(ALLTRIM(uct_polozky.dal),4,3)+CHR(9) &&DAL analytika
m.uct00=m.uct00+ALLTRIM(STR(uct_polozky.ciastka,16,2))+CHR(9) &&suma TM
m.uct00=m.uct00+ALLTRIM(STR(uct_polozky.ciastka,16,2))+CHR(9) &&suma CM
m.uct00=m.uct00+ALLTRIM(uct_polozky.poznamka)+CHR(9) &&text polozky
m.uct00=m.uct00+uct_polozky.typ+CHR(9) &&kod typu sumy
m.uct00=m.uct00+""+CHR(9) &&cislo uhradzaneho dokladu
m.uct00=m.uct00+""+CHR(9) &&cislo odpocitavaneho dokladu
m.uct00=m.uct00+ALLTRIM(uct_polozky.hs_md)+ALLTRIM(uct_polozky.hs_dal)+CHR(9) &&kod strediska
m.uct00=m.uct00+""+CHR(9) &&nazov strediska
m.uct00=m.uct00+ALLTRIM(uct_polozky.hs_md)+ALLTRIM(uct_polozky.hs_dal)+CHR(9) &&kod zakazky


m.uct00=STRTRAN(m.uct00,",",".")
= FPUTS(m.lihandle, m.uct00)
