*!* 27.03.2009 
*!*	Alex.lepadatu
*!* modificari pentru mutare xsets.... in baza de date

*!*	14.04.2009
*!*	Alex.lepadatu
*!* dupa cererea de date din lans se apeleaza 'procedura_lans'; vezi setul 50505

*!* 29.05.2009
*!* marius.mutu
*!* id_set: 10600 - 10603 - banca valuta/lei > incasare/plata facturi in valuta
*!* poAct.suma_22 (banca in valuta > incasare/plata > suma in valuta de incasare)
*!* daca apare itemul 81 (suma_22), nu mai pun in xrequest itemul 11 (suma_2) si nu mai exista poAct.suma_2, deci trebuie sa adaug proprietatea
*!* poAct.suma_22a = suma in valuta incasata si convertita in valuta facturii
*!* poAct.suma_32 = curs valutei in care se incaseaza

*!* 18.02.2010
*!* marius.mutu
*!* + lans_generic - suport pentru note X = Y

*!* 14.01.2015
*!* marius.mutu
*!* LANS: se transmite poActAnterior, daca se alege continuarea cu aceeasi operatie. Se completeaza automat valorile din operatia precedenta.
*!* doar pentru contabilitate. 
*!* La gestiune nu se copiaza numarul facturii si partenerul

*!* 16.01.2015
*!* marius.mutu
*!* LANS: se poate opta cu DA continuare operatie cu copiere date / NU continuare operatie fara copiere date / Renuntare
*!* nu se mai sare peste numar act, dataact, suma valuta

*!*	04.03.2015
*!*	marius.mutu
*!*	LANS: Completare informatii din documentul anterior
*!*	Nu mai copiez partenerul, in afara de banca/casa (ex: 5311 = 4111, se retine doar casa, nu si clientul)
*!*	Nu mai completez nract (nu se mai genera un numar nou la tipurilede documente cu serii, ex. chitante,facturi)

*!* 04.01.2015
*!*	marius.mutu
*!* lans - oxset.id_jtax pentru documentele din 2015 introduse in 2016 - nu mai afisau explicatia de TVA initiala cu 24%

*!* 06.01.2015
*!* marius.mutu
*!* introducere_compacta
*!* In 2015 lucrez cu TVA 24%. Transform TVA din 20% in 24%

*!* 18.08.2017
*!* marius.mutu
*!* lans - corectie NIR/BON

*!* 22.08.2025
*!* marius.mutu
* introducere_compacta
* Am introdus Calendar.impozit_profit
* ID_SET = 10609 Platitorii impozit venit, pentru limitare deducere 50% nu le trebuie 2 note CHELTUIELI DEDUCTIBILE si NEDEDUCTIBILE

*!* 20.07.2026
*!* marius.mutu
*!* introducere_compacta
*!* Aduc explicatia, explicatia4 si explicatia5 in cursorul introdc, ca sa poata fi editate pe fiecare rand din grila

*--------------------------------------------
Function deschide_menu
	Parameters tabela, cc1, cc2, mnrtata, stinga, sus, ONT

	Public nt, no, m
	nt = Alltrim(tabela) + '_' + Alltrim(Str(mnrtata))

	If Upper(Left(tabela, 6)) = '_MENU1'
		no = 'o' + nt
		zz = 'SELECT ' + cc1 + ' AS C1, ' + cc2 + ' AS C2,nrnod,PROCEDURA,TATAFIU,ID_SET,LISTA_NOTE FROM ' + ;
			tabela + ' WHERE NRTATA=' + Alltrim(Str(mnrtata)) + ' INTO CURSOR ' + nt
	Else
		no = 'o_' + nt
		zz = 'SELECT ' + cc1 + ' AS C1, ' + cc2 + ' AS C2,nrnod,PROCEDURA,TATAFIU,ID_SET FROM ' + ;
			tabela + ' WHERE NRTATA=' + Alltrim(Str(mnrtata)) + ' INTO CURSOR ' + nt
	Endif
	&zz
	m = 0

	Select &nt
	Scan
		mm = Len(Alltrim(c1))
		m = Iif(m > mm, m, mm)
	Endscan

	ta = _Tally
	If ta = 0
		Return '0'
	Endif

	If Type("&no")!= 'O'
		Public &no
		zz = no + '=crea("menuclasic")'
		&zz

		With &no
			wm = m * 7
			.NUME = no
			.ONUMETATA = ONT
			.Left = stinga
			.Top = sus
			.tabela = tabela
			.camp1 = cc1
			.camp2 = cc2
			.sursa = nt
			.Width = wm + 2 * .margine
			.NRFII = ta
			.rh = .container1.cwm1.Height
			.Height = (.rh + 1) * .NRFII + 2 * .margine + 2
			*.show()
		Endwith
	Endif

	Release nt, m
	Return no



	*------------------------------------------------------------------------------------------
Procedure deschide_menuuri
	*!*	If !Used('menu1')
	*!*		Use &DIRGEN\CONTAB\Date\menu1 In 0 Alias menu1 Order Tag 'nrnod'
	*!*	Endif
	*!*	If !Used('menu2')
	*!*		Use &DIRGEN\CONTAB\Date\menu2 In 0 Alias menu2 Order Tag 'nrnod'
	*!*	Endif
	*!*	If !Used('menu3')
	*!*		Use &DIRGEN\CONTAB\Date\menu3 In 0 Alias menu3 Order Tag 'nrnod'
	*!*	Endif
	*!*	If !Used('menu4')
	*!*		Use &DIRGEN\CONTAB\Date\menu4 In 0 Alias menu4 Order Tag 'nrnod'
	*!*	Endif

	*!*	If PRIMADATA
	*!*		Do CE_WINDOWS
	*!*		omenuvertical=Crea('menuvertical')
	*!*		omenuvertical.Show()
	*!*	Endif
	*deschide_menu(tabela, cc1,cc2,mnrtata,stinga,sus,ONT
	Return




	*--------------------------------------
Procedure CE_WINDOWS
	Local vermajor, verminor
	Public TIP_MENU, COL_MENU, cewin
	Store '' To cewin
	Store 0 To vermajor, verminor, TIP_MENU

	vermajor = Val(Os(3))
	verminor = Val(Os(4))
	Do Case
		Case vermajor < 4
			cewin = '95'
		Case vermajor = 4
			cewin = '98'
		Case vermajor >= 5
			Do Case
				Case verminor = 0
					cewin = '2000'
				Case verminor = 1
					cewin = 'XP'
				Otherwise
					cewin = 'MAINOU'
			Endcase
	Endcase


	*IF INLIST(CEWIN,'95','98','2000')
	TIP_MENU = 0&&'RAISED'
	*ELSE
	*TIP_MENU=2&&'FLAT'
	*ENDIF

	*!*	Do Case
	*!*	Case Inlist(cewin,'95','98')
	*!*		COL_MENU=Rgb(192,192,192)&&GRI
	*!*	Case cewin='2000'
	*!*		COL_MENU=Rgb(212,208,200)&&NISIP GRI
	*!*	Case cewin='XP'
	*!*		COL_MENU=Rgb(236,233,216)&&NISIP BEJ
	*!*	Otherwise
	COL_MENU = Rgb(255, 255, 255)&&ALB
	*!*	Endcase


	Return


	*!* 18.02.2010
	*** LANSEAZA LANS CU UN ID_SET SI CONTURILE X (CN), Y (CNY)
Procedure lans_generic
	Lparameters tnIds, tcContX, tcAcontX, tcContY, tcAcontY
	*!*		X		=	Y
	*!*		4426	=	Y
	Private pcACN, CNY, pcACNY
	pcACN = ""
	CNY = ""
	pcACNY = ""

	If Type('tcContX') = 'C' And !Empty(tcContX)
		*** CN E VARIABILA GLOBALA IN PROGRAMUL PRINCIPAL
		CN = tcContX
	Endif

	If Type('tcAcontX') = 'C' And !Empty(tcAcontX)
		pcACN = tcAcontX
	Endif

	If Type('tcContY') = 'C' And !Empty(tcContY)
		CNY = tcContY
	Endif

	If Type('tcaContY') = 'C' And !Empty(tcAcontY)
		pcACNY = tcContY
	Endif

	lans(tnIds)

Endproc
*!* 18.02.2010 ^

*--------------------------------------------------------
Function lans
	Lparameters IDS, tlContinua, tlVerificaAcont, taValori, tnDeducere, poActAnterior
	*!*	modificare	v 2.2.20	:	tnDeducere

	* poActAnterior: obiectul poAct completat la un LANS din operatia anterioara. Este completat daca se doreste acelasi tip de operatie
	* parametrul poActAnterior poate sa aiba si valorile: "corectie,1234" = modificare NIR/BON din ROAGEST, codul 1234
	
	Local lcACT, lcForm, lcMesaj, lcNOM_CONTRACTE, lcNOM_FDOC, lcNOM_GESTIUNI, lcNOM_LUCRARI
	Local lcNOM_PARTENERI, lcNOM_RESPONSABILI, lcNOM_SECTII, lcNOM_SUCURSALE, lcNOM_VALUTE
	Local lcNOM_VENIT_CHELTUIELI, lcProcedura, lcSql, lcTip, lcUTILIZATORI, lcValoareDefault
	Local lcVariabila, llAfiseaza, llContinua, llCreareGeneratorNumere, llEnabled, llLunaInchisa
	Local llSucces, llTabStop, llVerificaAcont, lnIndexVariabile, lnLengthVariabile, lnNumarParametri
	Local lnRandVariabila, lnRaspuns, lnSucces
	Local lcProprietateAnt, lcValoareAnt, lnProprietate, lnProprietati, llCorectie, lnCod
	*:Global pcSirFacturi, taActAnterior[1]
	*:Global ID_SET, OXSET, buton, i, oitem, pcSelect, poAct
	Store .T. To llContinua, llVerificaAcont
	llCorectie = .F.
	lnCod = 0
	IF TYPE('poActAnterior') = 'O'
		llCorectie = IIF(PEMSTATUS(poActAnterior, 'lCorectie', 5), poActAnterior.lCorectie, .F.)
		lnCod = IIF(m.llCorectie, poActAnterior.nCod, 0)
	ENDIF 	
	
	lnRaspuns = 6
	*!* MODIFICAT 03.11.2005
	*!* MARIUS.MUTU

	llLunaInchisa = is_luna_blocata(gcS, gnId_Prg_Owner, gnAn, gnLuna)
	If llLunaInchisa
		aMESSAGEBOX("Aceasta luna este închisa!", 0 + 48, "Luna închisa")
		Return 2
	Endif
	lnNumarParametri = Pcount()		&&	modificare	v 2.2.20

	Do Case
		Case lnNumarParametri = 2
			llContinua = tlContinua
		Case lnNumarParametri >= 3
			llContinua = tlContinua
			llVerificaAcont = tlVerificaAcont
	Endcase

	* gcS = variabila globala care imi tine minte schema (diferita in functie de firma)
	lcNOM_FDOC = gcS + '.NOM_FDOC'
	lcNOM_SUCURSALE =  gcS + 'NOM_SUCURSALE'
	lcNOM_PARTENERI = gcS + '.NOM_PARTENERI'
	lcNOM_VENIT_CHELTUIELI = gcS + '.NOM_VENIT_CHELTUIELI'
	lcNOM_RESPONSABILI = gcS + '.VNOM_RESPONSABILI'
	lcUTILIZATORI = 'syn_UTILIZATORI'
	lcNOM_SECTII = gcS + '.NOM_SECTII'
	lcNOM_SUCURSALE = gcS + '.NOM_SUCURSALE'
	lcNOM_LUCRARI = gcS + '.NOM_LUCRARI'
	lcNOM_GESTIUNI = gcS + '.NOM_GESTIUNI'
	lcNOM_VALUTE = gcS + '.NOM_VALUTE'
	lcACT = gcS + '.ACT'
	lcNOM_CONTRACTE = gcS + '.VCONTRACTE'

	If gnAn >= Iif(Type('gnAnFormNou') = 'U', 2007, gnAnFormNou)
		pcSelect = ["SELECT A.SERIE_ACT,A.ID_ACT,A.LUNA,A.AN,A.COD, A.DATAIREG as datairegt,A.NRACT,] + ;
			[A.DATAACT as dataactt,A.suma, A.EXPLICATIA,A.SCD,A.ASCD,A.SCC,A.ASCC, A.PERECHED,A.PERECHEC,"+] + ;
			["A.SUMA_VAL,A.EXPLICATIA4,A.EXPLICATIA5,A.CURS,A.DATASCAD as datascadt,A.NEIMPOZAB,A.NNIR,] + ;
			[A.ID_UTIL,UTIL2.UTILIZATOR AS UTIL,A.DATAORA,A.ID_UTILS,UTIL1.UTILIZATOR AS UTILS,A.DATAORAS,"+] + ;
			['A.ID_RESPONSABIL,RESP.NUME AS NRESP,A.ID_VENCHELT,VENCHELT.EXPLICATIE AS DST_CHLT,A.ID_LUCRARE,] + ;
			[LUCR.NRORD,A.ID_CTR,CTR.CONTRACT,A.ID_SECTIE,SECTII.SECTIE,A.PROC_TVA,A.ID_SET,A.ID_FACT,] + ;
			[ A.ID_FACTD, A.ID_FACTC,'+] + ;
			['A.ID_PARTD,PART1.NUME AS PARTD,A.ID_PARTC,PART.NUME AS PARTC,A.ID_SUCURSALA,S.SUCURSALA,A.ID_FDOC,FDOC.FEL_DOCUMENT AS FDOC, ' +] + ;
			["A.ID_GESTIN,A.ID_JTVA_COLOANA,G1.NUME_GESTIUNE AS GESTIN,A.ID_GESTOUT,G2.NUME_GESTIUNE AS GESTOUT,A.ID_VALUTA,V.NUME_VAL," + ] + ;
			["0000000000 as id_pol, lpad(' ',30,' ') as nume_lista_preturi,0 as tva_incasare, "+] + ;
			["cast(0 as Number(20)) as id_instiintare, cast(0 as Number(14)) as numar_instiintare, CAST(null as number(6)) as taxcode, CAST(null as varchar2(9)) as paymentcode, "+] + ;
			["cast(null as varchar2(250)) as taxname, cast(null as varchar2(250)) as paymentname, cast(null as varchar2(250)) as explicatie_tva "+] + ;			
			['FROM &lcACT A '+] + ;
			['LEFT JOIN &lcNOM_FDOC FDOC ON A.ID_FDOC=FDOC.ID_FDOC '+] + ;
			['LEFT JOIN &lcNOM_SUCURSALE S ON A.ID_SUCURSALA = S.ID_SUCURSALA '+] + ;
			['LEFT JOIN &lcNOM_PARTENERI PART ON A.ID_PARTC=PART.ID_PART '+] + ;
			['LEFT JOIN &lcNOM_PARTENERI PART1 ON A.ID_PARTD=PART1.ID_PART '+] + ;
			['LEFT JOIN &lcNOM_VENIT_CHELTUIELI VENCHELT ON A.ID_VENCHELT=VENCHELT.ID_VENCHELT '+] + ;
			['LEFT JOIN &lcNOM_RESPONSABILI RESP ON A.ID_RESPONSABIL=RESP.ID_RESPONSABIL '+] + ;
			['LEFT JOIN &lcUTILIZATORI UTIL1 ON A.ID_UTILS=UTIL1.ID_UTIL '+] + ;
			['LEFT JOIN &lcUTILIZATORI UTIL2 ON A.ID_UTIL=UTIL2.ID_UTIL '+] + ;
			['LEFT JOIN &lcNOM_LUCRARI LUCR ON A.ID_LUCRARE=LUCR.ID_LUCRARE  '+] + ;
			['LEFT JOIN &lcNOM_CONTRACTE CTR ON A.ID_CTR=CTR.ID_CTR '+] + ;
			['LEFT JOIN &lcNOM_GESTIUNI G1 ON A.ID_GESTIN=G1.ID_GESTIUNE '+] + ;
			['LEFT JOIN &lcNOM_GESTIUNI G2 ON A.ID_GESTOUT=G2.ID_GESTIUNE '+] + ;
			['LEFT JOIN &lcNOM_VALUTE V ON A.ID_VALUTA=V.ID_VALUTA '+] + ;
			['LEFT JOIN &lcNOM_SECTII SECTII ON A.ID_SECTIE=SECTII.ID_SECTIE where 1=2']
	Else
		pcSelect = ["SELECT A.SERIE_ACT,A.ID_ACT,A.LUNA,A.AN,A.COD, A.DATAIREG as datairegt,A.NRACT, ] + ;
			[A.DATAACT as dataactt,A.suma, A.EXPLICATIA,A.SCD,A.ASCD,A.SCC,A.ASCC, A.PERECHED,A.PERECHEC,"+] + ;
			["A.SUMA_VAL,A.EXPLICATIA4,A.EXPLICATIA5,A.CURS,A.DATASCAD as datascadt,A.NEIMPOZAB,A.NNIR,] + ;
			[A.ID_UTIL,UTIL2.UTILIZATOR AS UTIL,A.DATAORA,A.ID_UTILS,UTIL1.UTILIZATOR AS UTILS,A.DATAORAS,"+] + ;
			['A.ID_RESPONSABIL,RESP.NUME AS NRESP,A.ID_VENCHELT,VENCHELT.EXPLICATIE AS DST_CHLT,A.ID_LUCRARE,] + ;
			[LUCR.NRORD,A.ID_CTR,CTR.CONTRACT,A.ID_SECTIE,SECTII.SECTIE,A.PROC_TVA,A.ID_SET,A.ID_FACT, A.ID_FACTD, A.ID_FACTC,'+] + ;
			['A.ID_PARTD,PART1.NUME AS PARTD,A.ID_PARTC,PART.NUME AS PARTC,A.ID_SUCURSALA,S.SUCURSALA, ] + ;
			[A.ID_FDOC,FDOC.FEL_DOCUMENT AS FDOC, ' +] + ;
			["A.ID_GESTIN,G1.NUME_GESTIUNE AS GESTIN,A.ID_GESTOUT,G2.NUME_GESTIUNE AS GESTOUT,A.ID_VALUTA,V.NUME_VAL," +] + ;
			["0000000000 as id_pol, lpad(' ',30,' ') as nume_lista_preturi,0 as tva_incasare, "+] + ;
			["cast(0 as Number(20)) as id_instiintare, cast(0 as Number(14)) as nr_instiintare, CAST(null as number(6)) as taxcode, CAST(null as varchar2(9)) as paymentcode, "+] + ;
			["cast(null as varchar2(250)) as taxname, cast(null as varchar2(250)) as paymentname, cast(null as varchar2(250)) as explicatie_tva "+] + ;				
			['FROM &lcACT A '+] + ;
			['LEFT JOIN &lcNOM_FDOC FDOC ON A.ID_FDOC=FDOC.ID_FDOC '+] + ;
			['LEFT JOIN &lcNOM_SUCURSALE S ON A.ID_SUCURSALA = S.ID_SUCURSALA '+] + ;
			['LEFT JOIN &lcNOM_PARTENERI PART ON A.ID_PARTC=PART.ID_PART '+] + ;
			['LEFT JOIN &lcNOM_PARTENERI PART1 ON A.ID_PARTD=PART1.ID_PART '+] + ;
			['LEFT JOIN &lcNOM_VENIT_CHELTUIELI VENCHELT ON A.ID_VENCHELT=VENCHELT.ID_VENCHELT '+] + ;
			['LEFT JOIN &lcNOM_RESPONSABILI RESP ON A.ID_RESPONSABIL=RESP.ID_RESPONSABIL '+] + ;
			['LEFT JOIN &lcUTILIZATORI UTIL1 ON A.ID_UTILS=UTIL1.ID_UTIL '+] + ;
			['LEFT JOIN &lcUTILIZATORI UTIL2 ON A.ID_UTIL=UTIL2.ID_UTIL '+] + ;
			['LEFT JOIN &lcNOM_LUCRARI LUCR ON A.ID_LUCRARE=LUCR.ID_LUCRARE  '+] + ;
			['LEFT JOIN &lcNOM_CONTRACTE CTR ON A.ID_CTR=CTR.ID_CTR '+] + ;
			['LEFT JOIN &lcNOM_GESTIUNI G1 ON A.ID_GESTIN=G1.ID_GESTIUNE '+] + ;
			['LEFT JOIN &lcNOM_GESTIUNI G2 ON A.ID_GESTOUT=G2.ID_GESTIUNE '+] + ;
			['LEFT JOIN &lcNOM_VALUTE V ON A.ID_VALUTA=V.ID_VALUTA '+] + ;
			['LEFT JOIN &lcNOM_SECTII SECTII ON A.ID_SECTIE=SECTII.ID_SECTIE where 1=2']
	Endif
	*!*	modificare serii numere - 10.2007
	llCreareGeneratorNumere = .F.
	If Type('poGeneratorNumere') = 'U'
		Private poGeneratorNumere
		poGeneratorNumere = Createobject('oGeneratorNumere')
		llCreareGeneratorNumere = .T.
	Endif
	*!*	modificare serii numere - 10.2007	^

	Private podateintrod
	Store '' To podateintrod
	llAfiseaza = .F.
	lnSucces = gencursor('podateintrod', 'crsact', pcSelect, [1=2], [''], '', llAfiseaza)
	podateintrod.ca_baza1.afisare()

	If Used('actactan')
		Use In actactan
	Endif

	Select 0000 As nr_nota, c.*, c.SUMA As TOTFTVA, c.SUMA As TOTTVA, Ttod(c.dataactt) As dataact, ;
		Ttod(c.datairegt) As dataireg, Ttod(c.datascadt) As datascad, 0 As POZITIE_1, 0 As POZITIE_2 ;
		From crsact c Into Cursor actactan Readwrite

	Use In crsact
	Release podateintrod

	Select actactan
	Scatter Name poAct
	*!* 29.05.2009
	*!* marius.mutu
	*!* poAct.suma_22 (banca in valuta > incasare/plata > suma in valuta de incasare)
	*!* daca apare itemul 81 (suma_22), nu mai pun in xrequest itemul 11 (suma_2) si nu mai exista poAct.suma_2, deci trebuie sa adaug proprietatea
	*!* poAct.suma_22a = suma in valuta incasata si convertita in valuta facturii
	*!* poAct.suma_32 = cursul valutei in care se incaseaza
	AddProperty(poAct, "suma_2", 0.0000)
	AddProperty(poAct, "suma_22", 0.0000)
	AddProperty(poAct, "suma_22a", 0.0000)
	AddProperty(poAct, "suma_32", 0.0000)
	AddProperty(poAct, "nume_val2", "")
	AddProperty(poAct, "id_valuta2", Cast(0 As I))
	AddProperty(poAct, "deducere", 0)		&&	modificare v 2.2.20
	AddProperty(poAct, "id_gestiune", 0)
	AddProperty(poAct, "cgest", "")
	AddProperty(poAct, "nume_gestiune", "")
	AddProperty(poAct, "nume_val3", "")
	AddProperty(poAct, "id_valuta3", Cast(0 As I))

	m.ID_SET = IDS
	poAct.ID_SET = IDS

	Select XSETS
	Seek IDS && trebuie sa raman pozitionat in xsets pe setul curent pentru ca ma bazez in alte proceduri pe setul curent
	If Found()
		Scatter Name OXSET
		*!*	modificare JC/JV 2007
		If gnNeplatitoare_tva = 1
			OXSET.id_jtax = OXSET.id_jtaxn
			OXSET.id_jnetax = OXSET.id_jtaxn
		ELSE 
		
			DO CASE 
				CASE BETWEEN(m.gnAn*12+m.gnLuna, 2016*12+1, 2025*12+7)
					* 08/2025: 19 > 21
					DO case
						CASE oxset.id_jtax = 208
							oxset.id_jtax = 105
						CASE oxset.id_jtax = 216 
							oxset.id_jtax = 141
						CASE oxset.id_jtax = 220
							oxset.id_jtax = 118
						CASE oxset.id_jtax = 35
							oxset.id_jtax = 1
					ENDCASE 																																		

				CASE gnAn <= 2015
					* achizitiile si livrarile pe 2015 trebuie sa propuna TVA 24%. 
					* In xsets s-a modificat 20% de la 01.01.2016

					DO case
						CASE oxset.id_jtax = 176
							oxset.id_jtax = 156
						CASE oxset.id_jtax = 186 
							oxset.id_jtax = 162
						CASE oxset.id_jtax = 180 
							oxset.id_jtax = 158
						CASE oxset.id_jtax = 27 
							oxset.id_jtax = 15
					ENDCASE 																																		
			ENDCASE  
		ENDIF 	
	Else
		Scatter Name OXSET Blank
	Endif


	*!*	modificare JC/JV 2007 ^
	If gnAn >= Iif(Type('gnAnFormNou') = 'U', 2007, gnAnFormNou)
		If Inlist(OXSET.ID_SET, 208, 209, 220, 221)		&&	achizitie import/intern cu recalculare pret achizitie din ROAGEST
			Do update_jtva_coloane With (OXSET.tipjurnal), [], 1
		Else
			Do update_jtva_coloane With (OXSET.tipjurnal)
		Endif
		lcForm = [actbaza2007]
	Else
		Do update_cote_TVA
		lcForm = [actbaza]
	Endif

	*!*	modificare JC/JV 2007	^
	oitem = Createobject(lcForm)
	oitem.ID_SET = IDS
	oitem.formgest = OXSET.formgest
	oitem.lVerificaAcont = llVerificaAcont
	oitem.pcobj = 'poAct'
	IF TYPE('oitem.lCorectie') = 'L'
		oitem.lCorectie = m.llCorectie && daca este corectie de NIR/BON din ROAGEST
		oitem.nCod = m.lnCod && codul operatiei la care se face corectie, pentru a o putea-o sterge
	ENDIF 

	lnIndexVariabile = 0
	If Pcount() >= 4 And Type('taValori', 1) = 'A'
		External Array taValori
		With oitem
			For I = 1 To Alen(taValori, 1)
				.variabile[i, 1] = Upper(taValori[i, 1])	&& numele variabilei : poAct.* sau poAct.id_v*
				&& (ptr. campurile care ar fi trebuit completate din nomenclatoare)
				&& exemplu: poAct.nume sau poAct.id_vnume
				.variabile[i, 2] = taValori[i, 2]			&& valoarea variabilei
				.variabile[i, 3] = taValori[i, 3]			&& .T. =>	tabstop = .F.
				.variabile[i, 4] = Iif(Type("taValori[i,4]") = "L", taValori[i, 4], .F.)	&&	.T.	=>	enabled = .F.
				lnIndexVariabile = I
			Endfor
		Endwith

	Endif && pcount

	*** VALORI DEFAULT XITEMS (ID_FDOC...)
	Text To lcSql Noshow Textmerge
	select r.valoare_default,
	       r.id_item,
	       i.camp_lista,
	       i.id_fisier,
	       CASE
	         WHEN i.id_fisier is not null then
	          pack_util.GetText(i.fis_lista,
	                            i.id_fisier,
	                            to_number(r.valoare_default),
	                            replace(i.camp_lista, ',', ' || '' '' || '))
	         ELSE
	          r.valoare_default
	       end as valoare_default_text,
	       i.var_item
	  from xrequest r join xitems i on i.id_item = r.id_item
      where r.id_set = <<m.IDS>> and r.valoare_default is not null 
	Endtext

	llSucces = goExecutor.oExecuta(lcSql, [crsRequest])

	If m.llSucces
		*** VALORI DEFAULT XNOTE (ID_PART...)	
		Text To m.lcSql Noshow Textmerge
		select n.cont, n.id_part, n.id_set, p.nume, n.tip
		  from (select n1.xscd as cont,
		               n1.id_partd as id_part,
		               n1.id_set,
		               'D' as tip
		          from xnote n1
		         where nvl(n1.id_partd, 0) <> 0
		           and n1.id_set = <<m.IDS>>
		        union
		        select n2.xscc as cont,
		               n2.id_partc as id_part,
		               n2.id_set,
		               'C' as tip
		          from xnote n2
		         where nvl(n2.id_partc, 0) <> 0
		           and n2.id_set = <<m.IDS>>) n
		  join nom_parteneri p
		    on n.id_part = p.id_part
		Endtext

		llSucces = goExecutor.oExecuta(lcSql, [crsNumePartener])
	Endif

	If !Used('crsNumePartener')
		Create Cursor crsNumePartener (Cont c(4), id_part I, ID_SET I, NUME c(100), tip c(1))
	Endif

	If !Used('crsRequest')
		Create Cursor crsRequest(valoare_default c(100), id_item I, camp_lista c(100), id_fisier c(100), valoare_default_text c(100), var_item c(100))
	ENDIF

	* Completare valori din documentul anterior
	Create Cursor crsActAnterior (variabila c(100), valoare c(250), ltabstop L, lenabled L)
	If Type('poActAnterior') = 'O'
		lnProprietati = Amembers(taActAnterior, poActAnterior)
		For lnProprietate = 1 To lnProprietati
			lcProprietateAnt = Upper(taActAnterior[lnProprietate])

			llLoop = !(lcProprietateAnt + ',' $ [FDOC,ID_FDOC,DATAIREG,DATAACT,DATASCAD,SERIE_ACT,DST_CHLT,ID_VENCHELT,NRESP,ID_RESPONSABIL,] + ;
					  [NRORD,ID_LUCRARE,SECTIE,ID_SECTIE,CONTRACT,ID_CONTRACT,NUME_VAL,ID_VALUTA,NUME_VAL2,ID_VALUTA2,NUME_LISTA_PRETURI,ID_POL,] + ;
					  [SUMA_3,SUMA_32,] Or Left(m.lcProprietateAnt, 1) = 'V' Or Left(m.lcProprietateAnt, 5) = 'ID_VV')

			IF !m.llLoop
				* Nu copiez partenerul, in afara de banca/casa (ex: 5311 = 4111, se retine doar casa, nu si clientul)
				llLoop = (Left(m.lcProprietateAnt, 1) = 'V' Or Left(m.lcProprietateAnt, 5) = 'ID_VV') AND !(Left(m.lcProprietateAnt, 2) = 'V5' Or Left(m.lcProprietateAnt, 6) = 'ID_VV5')
			ENDIF 		
			IF !m.llLoop			
				* La gestiune nu se copiaza numarul facturii si partenerul
				llLoop = Type('gcNumeProgram') = 'C' And m.gcNumeProgram = 'ROAGEST' And (lcProprietateAnt + ',' $ [NRACT,SERIE_ACT,] Or Left(m.lcProprietateAnt, 1) = 'V' Or Left(m.lcProprietateAnt, 5) = 'ID_VV')
			ENDIF

			* Copiez toate proprietatile daca este corectie de NIR/Bon
			llLoop = m.llLoop and !m.llCorectie			
			IF m.llLoop
				LOOP 
			ENDIF 

			lcValoareAnt = Transform(Evaluate('poActAnterior.' + m.lcProprietateAnt))
			llTabStop = !lcProprietateAnt + ',' $ [DATAIREG,DATAACT,DATASCAD,NRACT,SERIE_ACT,SUMA_3,SUMA_32,] && sa nu fie tabstop = .t. la nract,...
			llEnabled = .F.
			Insert Into crsActAnterior (variabila, valoare, ltabstop, lenabled) Values ('poAct.' + m.lcProprietateAnt, m.lcValoareAnt, m.llTabStop, m.llEnabled)
		Endfor
	Endif

	Create Cursor crsValori (variabila c(100), valoare c(250), ltabstop L, lenabled L)

	Insert Into crsValori (variabila, valoare, ltabstop, lenabled) ;
		Select "poact." + Upper(Alltrim(Nvl(crsRequest.id_fisier, []))) As variabila, ;
		Allt(Nvl(crsRequest.valoare_default, [])) As valoare, ;
		.T. As ltabstop, ;
		.F. As lenabled ;
		From crsRequest ;
		Where !Empty(Nvl(crsRequest.id_fisier, [])) ;
		Union All ;
		Select "poAct." + Allt(Nvl(crsRequest.var_item, [])) As variabila, ;
		Alltrim(Nvl(crsRequest.valoare_default_text, [])) As valoare, ;
		.T. As ltabstop, ;
		.F. As lenabled ;
		From crsRequest	;
		Union All ;
		Select "poact.id_vv" + Alltrim(Nvl(crsNumePartener.Cont, [])) + Iif(Inlist(Left(Cont, 2), '51', '53'), Iif(tip = 'D', '0', '1'), '') As variabila, ;
		Alltrim(Str(Nvl(crsNumePartener.id_part, 0))) As valoare, ;
		.T. As ltabstop, ;
		.F. As lenabled ;
		From crsNumePartener ;
		Union All ;
		Select "poact.v" + Alltrim(crsNumePartener.Cont) + Iif(Inlist(Left(Cont, 2), '51', '53'), Iif(tip = 'D', '0', '1'), '') As variabila, ;
		Alltrim(Nvl(crsNumePartener.NUME, [])) As valoare, ;
		.T. As ltabstop, ;
		.F. As lenabled ;
		From crsNumePartener ;
		Union All ;
		Select variabila, valoare, ltabstop, lenabled ;
		From crsActAnterior

	Use In (Select('crsActAnterior'))

	lnLengthVariabile = Alen(oitem.variabile, 1)
	Select crsValori
	Scan
		lcVariabila = Alltrim(variabila)
		lcValoareDefault = Alltrim(valoare)
		llTabStop = ltabstop
		llEnabled = lenabled
		*** caut randul pe care se gaseste poact.id_fdoc Case Insensitive; Return row number; Exact ON
		*** daca nu il gasesc il adaug in array
		lnRandVariabila = Ascan(oitem.variabile, m.lcVariabila, 1, m.lnLengthVariabile, 1, 15)
		If m.lnRandVariabila = 0
			lnIndexVariabile = m.lnIndexVariabile + 1
			oitem.variabile(m.lnIndexVariabile, 1) =  m.lcVariabila
			oitem.variabile(m.lnIndexVariabile, 2) = m.lcValoareDefault
			oitem.variabile(m.lnIndexVariabile, 3) = m.llTabStop
			oitem.variabile(m.lnIndexVariabile, 4) = m.llEnabled
		Endif
	Endscan

	Use In (Select('crsValori'))

	oitem.Show(1)
	*!*	adaugat 14.04.2009
	*!*	modificare	v 2.2.20
	If lnNumarParametri >= 5 And Type('tnDeducere') = 'N'
		tnDeducere = poAct.deducere
	Endif
	*!*	modificare	v 2.2.20	^

	*!*	alex.lepadatu
	Release oitem
	If pl_verificat
		lcProcedura = Alltrim(Nvl(OXSET.procedura_lans, ""))
		If !Empty(lcProcedura)
			Do &lcProcedura
		Endif

	ENDIF

	*!*	14.04.2009
	If Type("OXSET.nu_sterg") = "N"
		OXSET.nu_sterg = Iif(OXSET.nu_sterg = 1, .T., .F.)
	Endif
	If OXSET.nu_sterg = .F. And buton!= 2 And llContinua
		lcTip = [Confirmare]
		lcMesaj = [Doriti sa continuati cu operatii de acest fel?] + Chr(13) + Chr(10) + [DA=copiere date / NU=fara copiere date / Abandon]
		lnRaspuns = aMESSAGEBOX(lcMesaj, 3 + 32, lcTip)
		If Used('cote_tva')
			Use In cote_tva
		Endif
		If Used('jtva_coloane')
			Use In jtva_coloane
		Endif
		*!*	modificare v 2.5.16	: ar trebui resetate toate variabilele initializate inainte de lans
		If Type('pcSirFacturi') <> 'U'
			Store [] To pcSirFacturi
		Endif
		*!*	modificare v 2.5.16	^
		*!*		If buton=1
		If Inlist(lnRaspuns, 6, 7) && 6=DA=copiere date;7=NU=fara copiere date
			If Type('poGeneratorNumere') <> 'U'
				poGeneratorNumere.ResetAll()
			Endif
			If Type('taValori', 1) = 'A'
				lans(m.IDS, m.llContinua, m.llVerificaAcont, @taValori)
			Else
				If lnRaspuns = 6 && DA cu copiere date
					lans(m.IDS, m.llContinua, m.llVerificaAcont, .F., .F., m.poAct)
				Else
					lans(m.IDS, m.llContinua, m.llVerificaAcont)
				Endif
			Endif
		Endif
	Else
		lnRaspuns = Iif(buton = 1, 6, 2)
	Endif
	Release OXSET

	If Inlist(lnRaspuns, 6, 7) && DA
		buton = 1
	Else && NU
		buton = 2
	Endif

	*!*	modificare serii numere - 	10.2007
	If llCreareGeneratorNumere
		Release poGeneratorNumere
	Endif
	*!*	modificare serii numere - 	10.2007	^
	Return buton


	*----------------------------------------------
Procedure introducere_compacta
	Parameters tcFis, tcscd, tcscc, tl_calcTVA, tl_plata, tctitlu, tctva, tn_idset, tl_acont, tnDeducere, tlCursorCreat, tnTotcTVA
	Local llVerificaAcont, llSucces, llN50, llN100, llNeexigibil, llCursorCreat
	llCursorCreat = .F.
	llVerificaAcont = .T.
	
	*!*	       tcfis = fisierul din calefirma (achi_mat.dbf)
	*!*	       tcscd = simbol cont debitor
	*!*	       tcscc = simbol cont creditor
	*!*	       tl_calctva = daca se calculeaza TVA-ul per total
	*!*	       tl_plata = daca se achita factura respectiva
	*!*	       tctitlu = titlul formularului frm_introd_compact
	*!*	       tctva = contul de TVA (daca tl_calctva=.t.)
	*!*	       tn_idset = parametrul functiei lans()
	*!*		   tl_acont = daca se verifica analiticele
	*!*		   tnDeducere = 0/1 - daca se scriu notele pentru cheltuieli deductibile 50%
	*!*		   tlCursorCreat (optional) = .T. daca cursorul cnote_contabile este creat anterior (Ex: import din eFactura)
	*!*		   tnTotcTVA (optional) = Valoarea cu TVA import eFactura

	If Pcount() >= 9
		llVerificaAcont = tl_acont
	ENDIF

	If Pcount() >= 11
		llCursorCreat = m.tlCursorCreat
	ENDIF 	

	Select actactan
	Locate
	Scatter Name poAct
	AddProperty(poAct, "deducere", Iif(Empty(tnDeducere), 0, tnDeducere))	&&	modificare	v 2.2.20

	If Used('introdc')
		Use In introdc
	ENDIF	

	*!*	modificare JC/JV 2007
	If gnAn >= Iif(Type('gnAnFormNou') = 'U', 2007, gnAnFormNou)	
		*!*	modificare ROACONT v 2.4.0
		Select actactan
		Calculate Max(tva_incasare) To lnTvaIncasare
		*!*	modificare ROACONT v 2.4.0	^
		
		IF !m.llCursorCreat
			lcSql = [select id_note,explicatie,scd,ascd,scc,ascc,cu_tva,id_set,ordine,in_valuta,ptva,] + ;
				Iif(lnTvaIncasare = 1, [nvl(id_jtva_coloana_neex,id_jtva_coloana)], [id_jtva_coloana]) + [ as id_jtax,] + ;
				Iif(lnTvaIncasare = 1, [nvl(explicatie_tva_neex,explicatie_tva)], [explicatie_tva]) + [ as denumiretax,] + ;
				[CAST(0 as Number(16,4)) as suma, CAST(0 as Number(16,4)) as suma_val, CAST(0 as Number(5)) as id_valuta, CAST(null as Varchar2(5)) as nume_val,] + ;
				[CAST(0 as Number(16,4)) as curs, ] + ;
				[tipjurnal, taxcode, paymentcode from vnote_contabile where id_set = ] + Alltrim(Str(tn_idset))
			lcCursor = [cnote_contabile]
			llSucces = goExecutor.oExecuta(lcSql, lcCursor)
			If !m.llSucces
				Return
			ENDIF

			* 22.08.2025
			* Am introdus Calendar.impozit_profit
			* Platitorii impozit venit, pentru limitare deducere 50% nu le trebuie 2 note CHELTUIELI DEDUCTIBILE si NEDEDUCTIBILE
			IF m.tn_idset = 10609 AND EMPTY(NVL(goCalendar.impozit_profit,0)) AND RECCOUNT('cnote_contabile') = 2
				* STERG LINIA 2
				SELECT cnote_contabile
				GO BOTTOM 
				DELETE 				
			ENDIF 
			
		ELSE
			IF !USED('cnote_contabile')
				AMESSAGEBOX('Nu exista cursorul cnote_contabile!',48, _screen.Caption)
				RETURN 
			ENDIF 	
		ENDIF 	

		DO CASE 
			CASE BETWEEN(m.gnAn*12+m.gnLuna,2018*12+1, 2025*12+7)
				* achizitiile si livrarile inainte de 08/2025 trebuie sa propuna TVA 19%. 
				* In xsets s-a modificat 21% de la 01.08.2025

				* Ach int 19%
				IF m.lnTvaIncasare = 1
					update cnote_contabile  set ptva = 19, id_jtax = 188, denumiretax = 'ACH. INT. NEEX. 19%' where INLIST(id_jtax, 208, 210) && 21%
					update cnote_contabile  set ptva = 19, id_jtax = 189, denumiretax = 'TVA ACH. INT. NEEX. 19%' where INLIST(id_jtax, 209, 211) && 21%
				ELSE
					update cnote_contabile  set ptva = 19, id_jtax = 105, denumiretax = 'ACH. INT. 19%' where INLIST(id_jtax, 208, 210) && 21%
					update cnote_contabile  set ptva = 19, id_jtax = 106, denumiretax = 'TVA ACH. INT. 19%' where INLIST(id_jtax, 209, 211) && 21%
				ENDIF 	
			
				* Ach. b. imp. 19%
				update cnote_contabile  set ptva = 19, id_jtax = 118, denumiretax = 'ACH. IMP. 19%' where id_jtax = 220
				update cnote_contabile  set ptva = 19, id_jtax = 119, denumiretax = 'TVA ACH. IMP. 19%' WHERE id_jtax = 221
				
				* Ach b. CE 19%
				update cnote_contabile  set ptva = 19, id_jtax = 133, denumiretax = 'ACH. BUNURI CE. 19%' where id_jtax = 226
				update cnote_contabile  set ptva = 19, id_jtax = 134, denumiretax = 'TVA ACH. BUNURI CE. 19%' where id_jtax = 227

				* Ach s. CE 19%
				update cnote_contabile  set ptva = 19, id_jtax = 190, denumiretax = 'ACH. SERVICII CE. 19%' where id_jtax = 222
				update cnote_contabile  set ptva = 19, id_jtax = 191, denumiretax = 'TVA ACH. SERVICII CE. 19%' where id_jtax = 223
				
				* Ach Tx inversa 19%
				update cnote_contabile  set ptva = 19, id_jtax = 141, denumiretax = 'TX. INV. 19%' where id_jtax = 216
				update cnote_contabile  set ptva = 19, id_jtax = 142, denumiretax = 'TVA TX. INV. 19%' where id_jtax = 217

				* LIV INT 19%
				IF m.lnTvaIncasare = 1
					update cnote_contabile  set ptva = 19, id_jtax = 31, denumiretax = 'LIVR.INTERN NEEX. 19%' where INLIST(id_jtax, 35, 37)
					update cnote_contabile  set ptva = 19, id_jtax = 32, denumiretax = 'TVA LIVR.INTERN NEEX. 19%' where INLIST(id_jtax, 36, 38)
				ELSE 			
					update cnote_contabile  set ptva = 19, id_jtax = 1, denumiretax = 'LIVR.INTERN 19%'  where INLIST(id_jtax, 35, 37)
					update cnote_contabile  set ptva = 19, id_jtax = 2, denumiretax = 'TVA LIVR.INTERN 19%' where INLIST(id_jtax, 36, 38)
				ENDIF 

			CASE BETWEEN(m.gnAn, 2016, 2017)
				* achizitiile si livrarile pe 2016 trebuie sa propuna TVA 20%. 
				* In xsets s-a modificat 19% de la 01.01.2017
					
			CASE m.gnAn = 2016
				* In 2016 lucrez cu TVA 20%. Transform TVA din 19% in 20%
				* Ach int 20%
				IF m.lnTvaIncasare = 1
					update cnote_contabile  set ptva = 20, id_jtax = 178, denumiretax = 'ACH. INT. NEEX. 20%' where INLIST(id_jtax, 101, 103, 105, 188) && 19%
					update cnote_contabile  set ptva = 20, id_jtax = 179, denumiretax = 'TVA ACH. INT. NEEX. 20%' where INLIST(id_jtax, 102, 104, 106, 189) && 19%
				ELSE
					update cnote_contabile  set ptva = 20, id_jtax = 176, denumiretax = 'ACH. INT. 20%' where INLIST(id_jtax, 101, 103, 105, 188) && 19%
					update cnote_contabile  set ptva = 20, id_jtax = 177, denumiretax = 'TVA ACH. INT. 20%' where INLIST(id_jtax, 102, 104, 106, 189) && 19%
				ENDIF 	

			
				* Ach. b. imp. 20%
				update cnote_contabile  set ptva = 20, id_jtax = 180, denumiretax = 'ACH. IMP. 20%' where INLIST(id_jtax, 114, 116, 118)
				update cnote_contabile  set ptva = 20, id_jtax = 181, denumiretax = 'TVA ACH. IMP. 20%' where INLIST(id_jtax, 115, 117, 119)
				
				* Ach b. CE 20%
				update cnote_contabile  set ptva = 20, id_jtax = 182, denumiretax = 'ACH. BUNURI CE. 20%' where INLIST(id_jtax, 127, 129, 133)
				update cnote_contabile  set ptva = 20, id_jtax = 183, denumiretax = 'TVA ACH. BUNURI CE. 20%' where INLIST(id_jtax, 128, 130, 134)

				* Ach Tx inversa 20%
				update cnote_contabile  set ptva = 20, id_jtax = 186, denumiretax = 'TX. INV. 20%' where INLIST(id_jtax, 137, 139, 141)
				update cnote_contabile  set ptva = 20, id_jtax = 187, denumiretax = 'TVA TX. INV. 20%' where INLIST(id_jtax, 138, 140, 142)

				* LIV INT 20%
				IF m.lnTvaIncasare = 1
					update cnote_contabile  set ptva = 20, id_jtax = 29, denumiretax = 'LIVR.INTERN NEEX. 20%' where INLIST(id_jtax, 1, 31)
					update cnote_contabile  set ptva = 20, id_jtax = 30, denumiretax = 'TVA LIVR.INTERN NEEX. 20%' where INLIST(id_jtax, 2, 32)
				ELSE 			
					update cnote_contabile  set ptva = 20, id_jtax = 27, denumiretax = 'LIVR.INTERN 20%'  where INLIST(id_jtax, 1, 31)
					update cnote_contabile  set ptva = 20, id_jtax = 28, denumiretax = 'TVA LIVR.INTERN 20%' where INLIST(id_jtax, 2, 32)
				ENDIF 
			
		CASE gnAn <= 2015
			* In 2015 lucrez cu TVA 24%. Transform TVA din 20% in 24%		
			IF m.lnTvaIncasare = 1
				update cnote_contabile  set ptva = 24, id_jtax = 170, denumiretax = 'ACH. INT. NEEX. 24%' where INLIST(id_jtax, 176, 178)
				update cnote_contabile  set ptva = 24, id_jtax = 171, denumiretax = 'TVA ACH. INT. NEEX. 24%' where INLIST(id_jtax, 177, 179)
			ELSE 
				* Ach int 24% - 20%
				update cnote_contabile  set ptva = 24, id_jtax = 156, denumiretax = 'ACH. INT. 24%' where INLIST(id_jtax, 176, 178)
				update cnote_contabile  set ptva = 24, id_jtax = 157, denumiretax = 'TVA ACH. INT. 24%' where INLIST(id_jtax, 177, 179)
			ENDIF 	

			
			* Ach. b. imp. 24%
			update cnote_contabile  set ptva = 24, id_jtax = 158, denumiretax = 'ACH. IMP. 24%' where id_jtax = 180
			update cnote_contabile  set ptva = 24, id_jtax = 159, denumiretax = 'TVA ACH. IMP. 24%' where id_jtax = 181
			
			* Ach b. CE 24%
			update cnote_contabile  set ptva = 24, id_jtax = 160, denumiretax = 'ACH. BUNURI CE. 24%' where id_jtax = 182
			update cnote_contabile  set ptva = 24, id_jtax = 161, denumiretax = 'TVA ACH. BUNURI CE. 24%' where id_jtax = 183

			* Ach Tx inversa 24%
			update cnote_contabile  set ptva = 24, id_jtax = 162, denumiretax = 'TX. INV. 24%' where id_jtax = 186
			update cnote_contabile  set ptva = 24, id_jtax = 163, denumiretax = 'TVA TX. INV. 24%' where id_jtax = 187

			* LIV INT 24%
			IF m.lnTvaIncasare = 1
				update cnote_contabile  set ptva = 24, id_jtax = 21, denumiretax = 'LIVR.INTERN NEEX. 24%' where INLIST(id_jtax, 27, 29)
				update cnote_contabile  set ptva = 24, id_jtax = 22, denumiretax = 'TVA LIVR.INTERN NEEX. 24%' where INLIST(id_jtax, 28, 30)
			ELSE 
				update cnote_contabile  set ptva = 24, id_jtax = 15, denumiretax = 'LIVR.INTERN 24%' where INLIST(id_jtax, 27, 29)
				update cnote_contabile  set ptva = 24, id_jtax = 16, denumiretax = 'TVA LIVR.INTERN 24%' where INLIST(id_jtax, 28, 30)
			ENDIF 

		ENDCASE  && gnAn <= 2015

		lcForm = [FRM_INTROD_COMPACT2007]

		*!*	modificare	ROACONT v 2.4.0  : am adaugat lnTvaIncasare
		Select N.*, A.id_responsabil, A.id_partd, A.id_partc, A.partd, A.partc, ;
			A.nresp, A.id_sectie, A.sectie, A.id_venchelt, A.dst_chlt, N.id_jtax As id_jtva_coloana, ;
			00000000000000 As id_factd, 00000000000000 As id_factc, 00000000000000 As pereched, 00000000000000 As perechec, ;
			a.nrord, a.id_lucrare, ;
			A.explicatia, A.explicatia4, A.explicatia5 ;
			From cnote_contabile N Join actactan A On N.ID_SET = A.ID_SET ;
			Where N.ID_SET = tn_idset ;
			Into Cursor introdc Readwrite Order By ordine

		If !Used('saft_taxtable')
			update_saft_taxtable()
		ENDIF 	
		If !Used('saft_mecanisme_plati')
			update_saft_mecanisme_plati()
		ENDIF 	

		* Actualizez taxcode SAFT in functie de furnizori RTVAI
		IF m.gl406
			* llN50/llN100 = .T. doar pentru linia cu Explicatie TVA = "Limitare deducere TVA"
			llN50 = .F. && (tn_idset = 10609) or (poAct.deducere = 1) && deducere 50%
			llN100 = .F. && (tn_idset = 10647)	&& deducere 100%		

			SELECT distinct id_jtva_coloana, NVL(id_partc, id_partd) as id_part, (LEFT(scd,3) = '418' OR LEFT(scc,3) = '408') as neexigibil ;
				FROM introdc ;
				WHERE INLIST(ALLTRIM(NVL(tipjurnal,'')), 'JC', 'JV') ;
				INTO CURSOR cIntrodcTemp
			SELECT cIntrodcTemp
			SCAN
				lnIdJtva = id_jtva_coloana
				lnIdPart = id_part
				llNeexigibil = neexigibil
				
				lnTaxCode = GetTaxCodeIdPart(m.gnAn, m.gnLuna, poAct.DataAct, m.lnIdJtva, m.lnIdPart, m.llN50, m.llN100, m.llNeexigibil)
				UPDATE introdc SET taxcode = m.lnTaxcode WHERE id_jtva_coloana = m.lnIdJtva AND NVL(id_partc, id_partd) = m.lnIdPart
			ENDSCAN 
		ENDIF 
			
		Use In (SELECT('crsjtva'))
		Use In (SELECT('crstemp'))

		Select Distinct tipjurnal From cnote_contabile Where !Isnull(tipjurnal) Into Cursor crstemp
		If Reccount('crstemp') = 1
			Select crstemp
			lcTipJurnal = Upper(Alltrim(tipjurnal)) + [ = 1]
			*!*	modificare ROACONT v 2.4.0
			*!*	Select denumire As denumiretax,id_jtva_coloana,cota_tva From jtva_coloane Where &lcTipJurnal Into Cursor crsjtva
			If lnTvaIncasare = 0
				Select denumire As denumiretax, id_jtva_coloana, cota_tva From jtva_coloane Where &lcTipJurnal And Isnull(id_jtva_ex) Into Cursor crsjtva
			Else
				Select denumire As denumiretax, id_jtva_coloana, cota_tva From jtva_coloane Where &lcTipJurnal And Isnull(id_jtva_neex) Into Cursor crsjtva
			Endif
			*!*	modificare ROACONT v 2.4.0	^
		Else
			*!*	modificare ROACONT v 2.4.0
			*!*	Select denumire As denumiretax,id_jtva_coloana,cota_tva From jtva_coloane Into Cursor crsjtva
			If lnTvaIncasare = 0
				Select denumire As denumiretax, id_jtva_coloana, cota_tva From jtva_coloane Where Isnull(id_jtva_ex) Into Cursor crsjtva
			Else
				Select denumire As denumiretax, id_jtva_coloana, cota_tva From jtva_coloane Where Isnull(id_jtva_neex) Into Cursor crsjtva
			Endif
			*!*	modificare ROACONT v 2.4.0	^
		Endif

		If Used('crstemp')
			Use In crstemp
		Endif
	Else
		lcSql = [select * from ] + gcS + [.note_contabile where id_set = ] + Alltrim(Str(tn_idset))
		lcCursor = [cnote_contabile]
		lnSucces = goExecutor.oExecute(lcSql, lcCursor)
		If lnSucces < 0
			Return
		Endif

		lcForm = [FRM_INTROD_COMPACT]
		Select N.*, 00000000000000.0000 As SUMA, A.id_responsabil, A.id_partd, A.id_partc, A.partd, A.partc, ;
			A.nresp, A.id_sectie, A.sectie, A.id_venchelt, A.dst_chlt, ;
			00000000000000 As id_factd, 00000000000000 As id_factc, 00000000000000 As pereched, 00000000000000 As perechec ;
			From cnote_contabile N Join actactan A On N.ID_SET = A.ID_SET ;
			Where N.ID_SET = tn_idset ;
			Into Cursor introdc Readwrite Order By ordine

		lcSql = [SELECT descriere as tva, procent as ptva FROM ] + gcS + [.cote_tva where sters = 0 and an = ] + pcAn + [ and luna = ] + pcNl
		lcCursor = [ttva]
		lnSucces = goExecutor.oExecute(lcSql, lcCursor)
		If lnSucces < 0
			Return
		Endif

		Select ttva
		Replace All tva With Alltrim(Str(ptva)) + ' %'
	Endif
	*!*	modificare JC/JV 2007	^

	Use In cnote_contabile

	Select introdc
	If Flock()

		If !Empty(tcscd)
			Replace All SCD With tcscd For Empty(SCD) Or Upper(SCD) = 'X'
		Endif

		If !Empty(tcscc)
			Replace All SCC With tcscc For Empty(SCC) Or Upper(SCC) = 'X'
		Endif

		*!*		If m.ctva-1 = 0
		*!*			Replace All ptva With 0
		*!*		Endif

		Replace All id_partd With 0, partd With '' FOR EMPTY(NVL(id_partd,0))
		Replace All id_partc With 0, partc With '' FOR EMPTY(NVL(id_partc,0))
		
		Replace All ascd With '' For Isnull(ascd)
		Replace All ascc With '' For Isnull(ascc)

		If Used('xcont')
			Select Xcont
			Scan
				pcContPart = contPart
				lnIdPart = idpart
				lcNumePart = numePart
				Select introdc
				Scan For SCD = pcContPart
					Replace id_partd With lnIdPart
					Replace partd With lcNumePart
				Endscan

				Scan For SCC = pcContPart
					Replace id_partc With lnIdPart
					Replace partc With lcNumePart
				Endscan
				Select Xcont
			Endscan
		Endif

	Endif
	Unlock

	Select actactan
	Zap


	*Create Table &gcTempPath\ttva (tva c(11), ptva N(3))


	lcExceptii_scc = '0'
	lcExceptii_scd = '0'

	If !Empty(tcscd)
		lcSql = [select * from ] + gcS + [.exceptii_ireg where invers = 1 and debit = 1 and cont = ] + tcscd
		lcCursor = [ex_debit]
		lnSucces = goExecutor.oExecute(lcSql, lcCursor)
		If lnSucces < 0
			Return
		Endif
		Select ex_debit
		Scan
			lcExceptii_scd = lcExceptii_scd + ',' + Alltrim(cont_c)
		Endscan
		Use In ex_debit
	Endif

	If !Empty(tcscc)
		lcSql = [select * from ] + gcS + [.exceptii_ireg where invers = 1 and debit = 0 and cont = ] + tcscc
		lcCursor = [ex_credit]
		lnSucces = goExecutor.oExecute(lcSql, lcCursor)
		If lnSucces < 0
			Return
		Endif
		Select ex_credit
		Scan
			lcExceptii_scc = lcExceptii_scc + ',' + Alltrim(cont_c)
		Endscan
		Use In ex_credit
	Endif

	Select introdc
	Go Top

	obj = Createobject(lcForm)
	obj.cSCD = tcscd
	obj.cSCC = tcscc
	obj.gridb1.column3.BackColor = Rgb(255, 255, 255)
	obj.gridb1.column4.BackColor = Rgb(255, 255, 255)
	obj.pcobj = 'poAct'
	obj.pcExceptii_scd = lcExceptii_scd
	obj.pcExceptii_scc = lcExceptii_scc
	obj.lVerificaAcont = llVerificaAcont


	obj.titlufrumos1.Caption = tctitlu
	obj.Show(1)

	USE IN (SELECT('crsTaxTable'))
	USE IN (SELECT('crsjtva'))

	If buton = 2
		Do deschid_actc
		Return
	Endif

	*!*	IF tn_idset=10455  && rate leasing
	*!*		lans(10411)
	*!*	ENDIF

	Select actactan
	Replace All ID_SET With tn_idset

	Select actactan
	Do oscrie_in_fisiere.prg

	Do deschid_actc

Endproc &&introducere_compacta

*---------------------------------------------------------------------------------------

Procedure deschid_actc

	If Used('actactan')
		Use In actactan
	Endif

	If Used('xcont')
		Use In 'xcont'
	Endif

	If Used('introdc')
		Use In 'introdc'
	Endif

	If Used('ttva')
		Use In ttva
	Endif
Endproc && deschid_actc

*____________________________________________________
Procedure inchid_actcv

	If Used('actcv')
		Use In actcv
	Endif

	If Used('ACTcv1')
		Use In 'ACTcv1'
	Endif

Endproc && inchid_actcv


*_____________________________________________________________________________________________________________________



*--------------------------------------------------------------------
Procedure umple_log
	Parameters textul, textmare
	Local datatext
	datatext = ""
	*----------------FACE INREGISTRARI IN LOG_TEXT.
	datatext = CALEFIRMA + "\logs\contab\log_" + Alltrim(Str(Day(Date()))) + "_" + Alltrim(Str(Month(Date()))) + "_" + Alltrim(Str(Year(Date()))) + ".txt"
	Cd &CALEFIRMA
	If !Directory("LOGS")
		Md logs
	Endif
	Cd &CALEFIRMA\logs
	If !Directory("contab")
		Md contab
	Endif
	Set Textmerge On
	Set Textmerge Noshow
	Set Textmerge To &datatext Additive
\\<<Datetime()>>,<<Alltrim(utilizator)>>,<<textul>>,<<textmare>>
\
	Set Textmerge To
	Cd &dirgen

	Return         &&-------UMPLE_LOG


	*!*	*______________________________________________________



Procedure introducere_monetar



Endproc
