*!* 30.11.2011
*!* marius.mutu
*!* creare_bon_fiscal
*!* procentul de tva nu se afla corect: str(lnidfact,20)

*!*	25.11.2014
*!*	marius.mutu
*!*	casademarcat_roacont - functioneaza si pentru incasare cu bon fiscal prin POS (banca) id_set 10576
*!*	creare_bon_fiscal - functioneaza si pentru incasare cu bon fiscal prin POS (banca) id_set 10576, cont 5125 sume in curs de decontare

*!* 11.05.2015
*!* marius.mutu
*!* gcArticolBonFiscalCont: numele articolului care se va lista pe bonul fiscal. daca nu este completat se listeaza (Fact. Nr.)

Procedure casademarcat_roacont
	Lparameters tnIdSet

	Local lnLungime, lnRaspuns, lnIdSet, lnSucces
	
	*:Global glListareBonFiscalCont, taValori[1]
	*!*	Private poGeneratorNumere
	*!*	poGeneratorNumere = Createobject('oGeneratorNumere')
	If Empty(tnIdSet) Or Type('tnIdSet') <> 'N'
		lnIdSet = 10576 && Casa incasari - Clienti ( cu bon fiscal )
	Else
		lnIdSet = m.tnIdSet && (10617 Banca incasari - Clienti (cu bon fiscal POS))
	ENDIF

	gcArticolBonFiscalCont = ""
	IF INLIST(m.lnIdSet, 10619, 10620) && Bacsis fara TVA; Bacsis cu TVA
		gcArticolBonFiscalCont = 'BACSIS'
	ENDIF 
	
	lnLungime = 2
	lnRaspuns = 6
	Dimension taValori[lnLungime, 3]
	Do While lnRaspuns = 6
		glListareBonFiscalCont = .T.
		taValori[1, 1] = "poAct.id_fdoc"
		taValori[1, 2] = Alltrim(Str(gnid_fdoc_bonfiscal))
		taValori[1, 3] = .T.

		taValori[2, 1] = "poAct.fdoc"
		taValori[2, 2] = [BON FISCAL]
		taValori[2, 3] = .T.

		*!*		Store -1 To lnNumarBon
		*!*		lnRezultat = poGeneratorNumere.creeaza_cursor_serii_bf()
		*!*		lnNumarBon = poGeneratorNumere.aloca_numar_bf()
		*!*		If lnNumarBon = -1
		*!*			glListareBonFiscalCont=.F.		
		*!*			Return
		*!*		Endif

		*!*		taValori[3,1]="poAct.nract"
		*!*		taValori[3,2]=Alltrim(Str(lnNumarBon))
		*!*		taValori[3,3]=.T.

		lnSucces = lans(m.lnIdSet, .F., .T., @taValori)
		*!*		lnSucces=lans(10329,.F.,.T.,@taValori)
		*!*		If lnSucces=2
		*!*			poGeneratorNumere.dezaloca_numar_bf()		&&	in oserii_numere.prg
		*!*		Endif
		glListareBonFiscalCont = .F.
		gcArticolBonFiscalCont = ""
		lnRaspuns = AMESSAGEBOX('Doriti sa continuati cu operatii de acest fel?', 4 + 32, "Confirmare")
	Enddo
	Release poGeneratorNumere
Endproc
******************************************************************************************
Procedure creare_bon_fiscal
	Local lnNumarBonFiscal, lnTotalSuma, lnIdCasa, lnTip, lnNrFact, lnSuma, lnProcTva
	*!*	Local lcSirBonFiscal,lnTip,lnIdCasa,lnTotalSuma,ldDataBonFiscal,lnNumarBonFiscal,lnTotalSuma
	lnNumarBonFiscal = 0
	lnTotalSuma = 0
	lnSumaNumerar = 0
	lnSumaCard = 0
		
	*!*	modificare v 2.0.74
	*!*	lcSirBonFiscal=[]
	&&	lcSirBonFiscal (explicatii) :
	&&	5 (incasare);suma achitata;0(numerar);0(moneda);0(numar card credit)
	*!*	ldDataBonFiscal=get_ora()
	*!*	Select actactan
	*!*	Set Filter To scd='5311'
	*!*	Scan
	*!*		lnNumarBonFiscal=nract
	*!*		lnIdCasa=id_partd
	*!*		Do Case
	*!*		Case Type('gnId_casa_achit')<>'U' And lnIdCasa=gnId_casa_achit		&&	optiune din Devize
	*!*			lnTip=1
	*!*	*!*		Case TYPE('gnId_Part_Bufet')<>'U' AND lnIdCasa=gnId_Part_Bufet		&&	optiune din Gestiuni
	*!*	*!*			lnTip=2
	*!*		Otherwise
	*!*			lnTip=3
	*!*		Endcase
	*!*		lcSirBonFiscal=lcSirBonFiscal+[1;Fact.]+Alltrim(Str(perechec))+[;1;]+Alltrim(Str(lnTip))+[;1;]+Alltrim(Str(suma*100))+[;1000;0]+CRLF
	*!*		lnTotalSuma=lnTotalSuma+suma
	*!*	Endscan
	*!*	Set Filter To
	*!*	If !Empty(lcSirBonFiscal)
	*!*		lcSirBonFiscal=lcSirBonFiscal+[5;]+Alltrim(Str(lnTotalSuma*100))+[;0;0;0]+CRLF+CRLF
	*!*		imprimare_bon_fiscal(lcSirBonFiscal,ldDataBonFiscal,lnNumarBonFiscal)
	*!*	Else
	*!*		aMessagebox("Bonul nu contine nici un element!",0+48,"Atentie")
	*!*	Endif
	Local lcCursor
	lcCursor = [crsDateBon]
	Create Cursor (lcCursor) (DENUMIRE C(100), UM C(10), CANT N(10, 4), Pret N(18, 4), DEPARTAMENT N(2), PROC_TVAV N(5, 2))


	Select actactan
	Set Filter To Inlist(scd, '5311', '5125')
	Scan
		lnNumarBonFiscal = nract
		lnIdCasa = id_partd
		Do Case
			Case Type('gnId_casa_achit') <> 'U' And lnIdCasa = gnId_casa_achit		&&	optiune din Devize
				lnTip = 1
			Otherwise
				lnTip = 3
		Endcase
		lnNrFact = perechec
		lnIdFactC = id_Factc
		lnProcTva = proc_tva
		lnSuma = suma
		lnTotalSuma = lnTotalSuma + lnSuma
		IF scd = '5311'
			lnSumaNumerar = m.lnSumaNumerar + m.lnSuma
		ELSE
			lnSumaCard = m.lnSumaCard + m.lnSuma
		ENDIF 	
		
		*!*	nu am proc_tva completat asa ca trebuie sa-l citesc din inregistrari
		If Empty(lnProcTva) And !Empty(lnIdFactC)
			lcSql = [select 1 + (cota_tva / 100) as proc_tva from ] + gcS + [.jtva_coloane where id_jtva_coloana in (select id_jtva_coloana ] + ;
				[ from ] + gcS + [.act where id_fact = ] + Alltrim(Str(lnIdFactC, 20)) + [ and sters = 0) and afisat <> 0 and id_jtva_coloana>0 and sters = 0]
			lnSucces = goExecutor.oExecute(lcSql, [crsbfpt])
			If lnSucces < 0
				AMESSAGEBOX(goExecutor.cEroare, 16, "Eroare")
			Else
				If Reccount('crsbfpt') > 0
					Select crsbfpt
					lnProcTva = proc_tva
				Endif
			Endif
			Use In (Select([crsbfpt]))
		Endif
		Select (lcCursor)
		Append Blank
		Replace DENUMIRE With IIF(!EMPTY(m.gcArticolBonFiscalCont), m.gcArticolBonFiscalCont,  [Fact.] + Alltrim(Str(lnNrFact))), CANT With 1, Pret With lnSuma, PROC_TVAV With lnProcTva, DEPARTAMENT With lnTip
		Select actactan
	Endscan
	Set Filter To
	If Reccount(lcCursor) > 0
		Local loHash
		loHash = GetHash()
		loHash.SetValue("cTip", "1;")
		loHash.SetValue("nNumarBon", lnNumarBonFiscal)
		loHash.SetValue("nValoareNumerar", m.lnSumaNumerar)
		loHash.SetValue("nValoareCard", m.lnSumaCard)		
		loHash.SetValue("nValoareTotal", lnTotalSuma)
		loHash.SetValue("cCursor", lcCursor)
		loHash.SetValue("tDataOra", get_ora())
		goControllerEcr.imprima(loHash)
		Release loHash
	Else
		AMESSAGEBOX("Bonul nu contine nici un element!", 0 + 48, "Atentie")
	Endif
	Use In (lcCursor)
	*!*	modificare v 2.0.74	^
Endproc
******************************************************************************************  