*!* 03.01.2017
*!* GetProcTvaStandard TVA 19%

*** proceduri utilitare

*!* get_oluna() intoarce un obiect cu luna, anul de inceput, luna, anul de sfarsit din calendar
*!* tnAn, tnLuna - daca procedura da eroare se anul, luna inceput/sfarsit se intializeaza cu aceste valori
Function get_oluna
	Lparameters tnAn, tnLuna

	Local loReturn
	loReturn = Createobject("EMPTY")
	Local lcSelect, lcCursor, lnSucces, lnMaxLuna, lnMinLuna, lnLunaMax, lnAnMax, lnLunaMin, lnAnMin

	lnLunaMin = tnAn
	lnAnMin = tnLuna
	lnLunaMax = tnAn
	lnAnMax = tnLuna

	AddProperty(loReturn, 'lunamin',0)
	AddProperty(loReturn, 'anmin',0)
	AddProperty(loReturn, 'lunamax',0)
	AddProperty(loReturn, 'anmax',0)


	lcSelect = [select max(anul*12+luna) as maxluna, min(anul*12+luna) as minluna from calendar]
	lcCursor = [crsCalendarTemp]

	lnSucces = goExecutor.oExecute(lcSelect,lcCursor)
	If lnSucces > 0

		Select crsCalendarTemp
		lnMaxLuna = maxluna
		lnMinLuna = minluna

		lnLunaMax = Round(Mod(lnMaxLuna,12),0)
		lnAnMax = Int(lnMaxLuna/12)
		If lnLunaMax = 0 And lnAnMax <> 0
			lnLunaMax = 12
			lnAnMax = lnAnMax - 1
		Endif

		lnLunaMin = Round(Mod(lnMinLuna,12),0)
		lnAnMin = Int(lnMinLuna/12)
		If lnLunaMin = 0 And lnAnMin <> 0
			lnLunaMin = 12
			lnAnMin = lnAnMin - 1
		Endif



		If Used(lcCursor)
			Use In (lcCursor)
		Endif
	Else
		aMESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
	Endif

	loReturn.lunamin = lnLunaMin
	loReturn.anmin = lnAnMin
	loReturn.lunamax = lnLunaMax
	loReturn.anmax = lnAnMax

	Return loReturn

Endfunc && get_oluna

