* test_repro_pret_lei_intern.prg
* REPRO (raportat de Marius): pe ACHIZITIE INTERNA (import_nota cu lIntern=.T.) coloana
* "Pret lei factura" din grila de articole pare READONLY - nu se poate completa pretul
* articolului din factura, desi acesta e chiar pretul care trebuie tastat (pretul calculat
* se obtine din el, umflat cu procentul de repartizare al facturilor secundare: transport, taxe).
*
* Scenariu (flux real, nu insert direct):
*   1. doc principal FACTURA 8888 ARAFURA 1000 lei (participa la pret)
*   2. doc secundar FACTURA 777 TRANSTAXI 200 lei (participa la pret) -> procent_lei = 120
*   3. do_adauga_articol() REAL -> AC GREE BORA, cont 303 (mock dialog)
*   4. dump starea RUNTIME a coloanei cPretFactura (ControlSource/ReadOnly/Enabled/CurrentControl)
*   5. tastare REALA in celula prin ActivateCell + KEYBOARD (comparativ: mai intai Cantitate,
*      coloana despre care se stie ca merge, apoi Pret lei factura)
*   6. calea programatica (do_executa_pret), ca sa se vada daca logica de calcul e ok
*
* Rulare:
*   powershell -ExecutionPolicy Bypass -File test_repro_pret_lei_intern.ps1

SET SAFETY OFF
SET TALK OFF
SET DELETED ON
SET EXACT ON
SET CENTURY ON
SET DATE DMY
SET DECIMALS TO 4
SET NULLDISPLAY TO ''
CLOSE DATABASES

PUBLIC gcUILog, gcSyncDir
gcUILog  = "D:\ROA\ROAGEST\COMUN\utile\Teste\achizitie_import\test_repro_pret_lei_intern_log.txt"
gcSyncDir = "D:\ROA\ROAGEST\COMUN\utile\Teste\achizitie_import\uisync_pret_lei_intern\"
STRTOFILE("START " + TTOC(DATETIME()) + CHR(13)+CHR(10), gcUILog)

ON ERROR DO PlErr WITH ERROR(), MESSAGE(), PROGRAM(), LINENO()
ON SHUTDOWN QUIT

TRY
	LOCAL gcAppPath, lcPath
	gcAppPath = "D:\ROA\ROAGEST\"
	SET DEFAULT TO (gcAppPath)

	lcPath = gcAppPath + 'COMUN\Utile\Teste\achizitie_import\stub_verificare;' + ;
		gcAppPath + 'Date;' + gcAppPath + 'Include;' + gcAppPath + 'FERESTRE;' + ;
		gcAppPath + 'GRAFICE;' + gcAppPath + 'CLASE;' + gcAppPath + 'MENIURI;' + ;
		gcAppPath + 'PROGRAME;' + gcAppPath + 'RAPOARTE;' + gcAppPath + 'COMUN;' + ;
		gcAppPath + 'COMUN\CLASE;' + gcAppPath + 'COMUN\FERESTRE;' + gcAppPath + 'COMUN\PROGRAME;' + ;
		gcAppPath + 'COMUN\GRAFICE;' + gcAppPath + 'COMUN\RAPOARTE;' + gcAppPath + 'COMUN\MENIURI;' + ;
		gcAppPath + 'COMUN\UTILE\GRIDEXTRAS;' + gcAppPath + 'COMUN\UTILE\CTL32;' + ;
		gcAppPath + 'COMUN\UTILE\HPDF;' + gcAppPath + 'COMUN\UTILE\HPDF\REPORTOUTPUT;' + ;
		gcAppPath + 'COMUN\UTILE\WEB;' + gcAppPath + 'COMUN\UTILE\EXCEL;' + ;
		ADDBS(SUBSTR(gcAppPath,1,RAT([\],gcAppPath,2)))+[COMUNROA\]
	SET PATH TO &lcPath ADDITIVE
	DO PlLog WITH 'SET PATH OK'

	*----- CLASE -----
	SET CLASSLIB TO (gcAppPath + "comun\clase\appwiz") ADDITIVE
	SET CLASSLIB TO GESTIUNI ADDITIVE
	SET CLASSLIB TO CAUT ADDITIVE
	SET CLASSLIB TO BAZA ADDITIVE
	SET CLASSLIB TO comun ADDITIVE
	SET CLASSLIB TO accessibility.vcx ADDITIVE
	SET CLASSLIB TO messagebox ADDITIVE
	SET CLASSLIB TO registry ADDITIVE
	SET CLASSLIB TO cauta_alfa_forms.vcx ADDITIVE
	SET CLASSLIB TO DECABAZA ADDITIVE
	SET CLASSLIB TO onomenclatoare ADDITIVE
	SET CLASSLIB TO stocuri.vcx ADDITIVE
	SET CLASSLIB TO rulaje.vcx ADDITIVE
	SET CLASSLIB TO ointroduceri ADDITIVE
	SET CLASSLIB TO ointroduceri_web ADDITIVE
	SET CLASSLIB TO ointroduceri_depozit ADDITIVE
	SET CLASSLIB TO overificari ADDITIVE
	SET CLASSLIB TO ferestre_oracle ADDITIVE
	SET CLASSLIB TO ferestre_cere_date.vcx ADDITIVE
	SET CLASSLIB TO configurare.vcx ADDITIVE
	SET CLASSLIB TO serii_numere.vcx ADDITIVE
	SET CLASSLIB TO omodificari.vcx ADDITIVE
	SET CLASSLIB TO ocompensari.vcx ADDITIVE
	SET CLASSLIB TO caut_ora ADDITIVE
	SET CLASSLIB TO onote_contabile ADDITIVE
	SET CLASSLIB TO otoolbar ADDITIVE
	SET CLASSLIB TO bon_fisc ADDITIVE
	SET CLASSLIB TO onom_articole ADDITIVE
	SET CLASSLIB TO onom_retete ADDITIVE
	SET CLASSLIB TO orapoarte ADDITIVE
	SET CLASSLIB TO orapoarte_gestiuni ADDITIVE
	SET CLASSLIB TO orapoarte_parametri ADDITIVE
	SET CLASSLIB TO ONOM_CURS ADDITIVE
	SET CLASSLIB TO ctl32_statusbar_fals.vcx ADDITIVE
	SET CLASSLIB TO ctl32_common.vcx ADDITIVE
	SET CLASSLIB TO ctl32_structs.vcx ADDITIVE
	SET CLASSLIB TO ctl32_progressbar.vcx ADDITIVE
	SET CLASSLIB TO ctl32_balloontip.vcx ADDITIVE
	SET CLASSLIB TO ocriterii.vcx ADDITIVE
	SET CLASSLIB TO oavize.vcx ADDITIVE
	SET CLASSLIB TO onomenclatoare2 ADDITIVE
	SET CLASSLIB TO wwdialogs.vcx ADDITIVE
	SET CLASSLIB TO oimportxml.vcx ADDITIVE
	SET CLASSLIB TO excelxml.vcx ADDITIVE
	SET CLASSLIB TO orapoarte_obinv.vcx ADDITIVE
	DO PlLog WITH 'SET CLASSLIB OK'

	*----- PROCEDURI (mock-uri PRIMELE, ui_harness la final) -----
	SET PROCEDURE TO PROCEDURI
	SET PROCEDURE TO "D:\ROA\ROAGEST\COMUN\utile\Teste\mock_amessagebox.prg" ADDITIVE
	SET PROCEDURE TO "D:\ROA\ROAGEST\COMUN\utile\Teste\achizitie_import\mock_caut_valuta.prg" ADDITIVE
	SET PROCEDURE TO "D:\ROA\ROAGEST\COMUN\utile\Teste\mock_cauta_nom_articole.prg" ADDITIVE
	SET PROCEDURE TO "D:\ROA\ROAGEST\COMUN\utile\Teste\achizitie_import\mock_oscrie_in_fisiere.prg" ADDITIVE
	SET PROCEDURE TO acces_meniu ADDITIVE
	SET PROCEDURE TO cauta_alfa ADDITIVE
	SET PROCEDURE TO pmenu ADDITIVE
	SET PROCEDURE TO proceduri_comune ADDITIVE
	SET PROCEDURE TO quitapp ADDITIVE
	SET PROCEDURE TO init_program ADDITIVE
	SET PROCEDURE TO oproceduri_listari.prg ADDITIVE
	SET PROCEDURE TO oproceduri_configurare.prg ADDITIVE
	SET PROCEDURE TO oproceduri_articole.prg ADDITIVE
	SET PROCEDURE TO oproceduri_retete.prg ADDITIVE
	SET PROCEDURE TO orapoarte.prg ADDITIVE
	SET PROCEDURE TO mesaje ADDITIVE
	SET PROCEDURE TO oserii_numere.prg ADDITIVE
	SET PROCEDURE TO oexport.prg ADDITIVE
	SET PROCEDURE TO wwConfig.prg ADDITIVE
	SET PROCEDURE TO proceduri_rapoarte.prg ADDITIVE
	SET PROCEDURE TO OPROCEDURI_CURS.PRG ADDITIVE
	SET PROCEDURE TO validare.prg ADDITIVE
	SET PROCEDURE TO GENCURSOR.PRG ADDITIVE
	SET PROCEDURE TO OPROCEDURI_COMUNE.PRG ADDITIVE
	SET PROCEDURE TO OINIT_OPTIUNI.PRG ADDITIVE
	SET PROCEDURE TO updateserver.prg ADDITIVE
	SET PROCEDURE TO oinainte_de.prg ADDITIVE
	SET PROCEDURE TO ooperatii_comune.prg ADDITIVE
	SET PROCEDURE TO Ocompensari.PRG ADDITIVE
	SET PROCEDURE TO OPROCEDURI_aMS.PRG ADDITIVE
	SET PROCEDURE TO oproceduri_rulaje ADDITIVE
	SET PROCEDURE TO oproceduri_stocuri ADDITIVE
	SET PROCEDURE TO OINTRODUCERI ADDITIVE
	SET PROCEDURE TO oHeader.prg ADDITIVE
	SET PROCEDURE TO proceduri_excel.PRG ADDITIVE
	SET PROCEDURE TO onomenclatoare.PRG ADDITIVE
	SET PROCEDURE TO osecurity ADDITIVE
	SET PROCEDURE TO ocautare ADDITIVE
	SET PROCEDURE TO orefaceri ADDITIVE
	SET PROCEDURE TO ofacturare_comun.PRG ADDITIVE
	SET PROCEDURE TO ofacturare_stoc.PRG ADDITIVE
	SET PROCEDURE TO oproceduri_casademarcat ADDITIVE
	SET PROCEDURE TO oproceduri_casa_marcat_e500 ADDITIVE
	SET PROCEDURE TO oproceduri_casa_marcat_mp500 ADDITIVE
	SET PROCEDURE TO oproceduri_util.prg ADDITIVE
	SET PROCEDURE TO wwxmlhttp.prg ADDITIVE
	SET PROCEDURE TO ini.prg ADDITIVE
	SET PROCEDURE TO odocumente.prg ADDITIVE
	SET PROCEDURE TO regex.prg ADDITIVE
	SET PROCEDURE TO wwutils.prg ADDITIVE
	SET PROCEDURE TO inchidere_k ADDITIVE
	SET PROCEDURE TO iniacces.prg ADDITIVE
	SET PROCEDURE TO oupdate.prg ADDITIVE
	SET PROCEDURE TO procese.prg ADDITIVE
	SET PROCEDURE TO version.prg ADDITIVE
	SET PROCEDURE TO xmlaccess.prg ADDITIVE
	SET PROCEDURE TO xmlparser.prg ADDITIVE
	SET PROCEDURE TO filebringer.prg ADDITIVE
	SET PROCEDURE TO wwcodeupdate.prg ADDITIVE
	SET PROCEDURE TO wwhttp.prg ADDITIVE
	SET PROCEDURE TO xdate.prg ADDITIVE
	SET PROCEDURE TO ofacturare.prg ADDITIVE
	SET PROCEDURE TO oproceduri_obinv.prg ADDITIVE
	SET PROCEDURE TO oproceduri_facturare.prg ADDITIVE
	SET PROCEDURE TO email.prg ADDITIVE
	SET PROCEDURE TO "D:\ROA\ROAGEST\COMUN\utile\Teste\ui_harness.prg" ADDITIVE
	DO PlLog WITH 'SET PROCEDURE OK'

	*----- Globale -----
	PUBLIC gnPc, gnPval, gnPcant, gnPpret, gnPPretval, gnPCurs, gnPVal, gnPPretV, gnPPretVal
	STORE 2 TO gnPc, gnPval, gnPVal
	gnPcant = 3
	STORE 4 TO gnPpret, gnPPretval, gnPPretVal, gnPPretV, gnPCurs
	PUBLIC gl406, gcS, gnAn, gnLuna, gnIdFirma, gnIdSucursala, gcAcces, gcFirma
	gl406 = .T.
	gcS = 'CONTAFIN'
	gnAn = YEAR(DATE())
	gnLuna = MONTH(DATE())
	gnIdFirma = 110
	gnIdSucursala = 110
	gcAcces = "1;2;3;4;5;6;7;8;"
	gcFirma = gcS
	PUBLIC nror(65000)

	PUBLIC gnMockRaspuns, gcMockUltimMesaj, gnMockUltimTip, gcMockArtCodmat
	gnMockRaspuns = 6
	gcMockUltimMesaj = ''
	gnMockUltimTip = 0
	PUBLIC gnButon
	gnButon = 1
	gcMockArtCodmat = 'ART-GREE-303'

	PUBLIC gcTempPath, gnHandle, gnTipGest, gcCondSucursala
	gcTempPath = ADDBS(SYS(2023))
	gnHandle = -1
	gnTipGest = 0
	gcCondSucursala = ''

	PUBLIC goExecutor, goApp
	goExecutor = CREATEOBJECT('dummyexecutor')
	goApp = CREATEOBJECT('dummyapp')

	*----- poAct: antet achizitie INTERNA (fara valuta, curs 1) -----
	PUBLIC poAct
	poAct = CREATEOBJECT('Custom')
	poAct.AddProperty('nume_val', '')
	poAct.AddProperty('curs', 1)
	poAct.AddProperty('proc_tva', 1.21)
	poAct.AddProperty('nnir', 0)
	poAct.AddProperty('id_valuta', 0)
	poAct.AddProperty('id_fdoc', 1)
	poAct.AddProperty('fdoc', 'FACTURA')
	poAct.AddProperty('id_partc', 500)
	poAct.AddProperty('partc', 'ARAFURA')
	poAct.AddProperty('serie_act', '')
	poAct.AddProperty('dataact', DATE())
	poAct.AddProperty('tva_incasare', 0)
	poAct.AddProperty('id_set', 1)
	poAct.AddProperty('id_gestin', 1)

	*----- jtva_coloane2 / saft_taxtable -----
	IF USED('jtva_coloane2')
		USE IN ('jtva_coloane2')
	ENDIF
	CREATE CURSOR jtva_coloane2 (ordine N(8), id_jtva_coloana N(14), denumire C(100), ;
		jc N(1), jv N(1), afisat N(1), coloana_jc C(20), coloana_jv C(20), cota_tva N(6,2), id_tva N(14))
	INSERT INTO jtva_coloane2 VALUES (0, 0, '', 0, 0, 1, '', '', 0, 0)
	INSERT INTO jtva_coloane2 VALUES (1, 208, 'ACH. INT. NEEX. 21%', 1, 0, 1, 'RO21B', 'RO21T', 21, 209)
	INSERT INTO jtva_coloane2 VALUES (2, 209, 'TVA ACH. INT. NEEX 21%', 1, 0, 1, 'RO21T', '', 21, 0)

	IF USED('saft_taxtable')
		USE IN ('saft_taxtable')
	ENDIF
	CREATE CURSOR saft_taxtable (taxname C(250) NULL, typename C(250) NULL, taxcode N(6) NULL, ;
		taxtype N(3) NULL, descriere C(250) NULL, tip C(100) NULL, descriere_tip C(250) NULL, ;
		procent_taxa N(7,2) NULL, procent_prorata N(7,2) NULL, inactiv N(1) NULL, tva N(1) NULL, ;
		wht N(1) NULL, tva_achizitii N(1) NULL, tva_livrari N(1) NULL)
	INDEX ON taxcode TAG taxcode
	INSERT INTO saft_taxtable (taxname, taxcode, descriere, procent_taxa, tva, wht, tva_achizitii, tva_livrari) ;
		VALUES ('', 0, '', 0, 1, 1, 1, 1)
	INSERT INTO saft_taxtable (taxname, taxcode, descriere, procent_taxa, tva, wht, tva_achizitii, tva_livrari) ;
		VALUES ('301104-Achizitii de bunuri si servicii taxabile cu cota de 21%', 301104, '', 21, 1, 0, 1, 0)

	DO CreeazaIntrodc WITH 'introdc'
	DO CreeazaIntrodc WITH 'introdc_sablon'
	INSERT INTO introdc_sablon (scd, scc, cu_tva, ordine, id_set, participa_valuta, tip_rand, ;
			id_jtva_coloana, ptva, explicatie_tva) ;
		VALUES ('371', '401', 1, 1, 1, .T., 'B', 208, 21, 'ACH. INT. NEEX. 21%')
	INSERT INTO introdc_sablon (scd, scc, cu_tva, ordine, id_set, participa_valuta, tip_rand, ;
			id_jtva_coloana, ptva, explicatie_tva) ;
		VALUES ('4428', '401', 1, 2, 1, .T., 'T', 209, 21, 'TVA ACH. INT. NEEX 21%')
	GO TOP IN introdc_sablon

	DO CreeazaRulTemp
	INSERT INTO rul_temp (denumire, codmat, cant, pret, pret_lei, cont, cota_tva) ;
		VALUES ('PLACEHOLDER', 'PH', 1, 1, 1, '371', 21)

	SELECT introdc
	INDEX ON Str(Nvl(nr_doc,0),8) + Icase(tip_rand='B','1', tip_rand='S','2', tip_rand='G','3', tip_rand='T','4', tip_rand='D','5', '6') + Padr(Nvl(scd,''),10) TAG ord_doc
	SET ORDER TO ord_doc

	*-- tlIntern BARA, aceeasi valoare ca la CREATEOBJECT (vezi docs/flux-achizitie-import.md)
	PRIVATE tlIntern
	tlIntern = .T.

	DO PlLog WITH 'cursoare pregatite, CREATEOBJECT(import_nota, .T. - ACHIZITIE INTERNA)'
	PUBLIC goObj
	goObj = CREATEOBJECT('IMPORT_nota', .T.)
	IF VARTYPE(goObj) <> 'O'
		DO PlLog WITH 'FAIL: instantiere import_nota'
		DO HarnessDone WITH 'done-error'
		QUIT
	ENDIF
	goObj.lDialogAratat = .T.
	goObj.oact = poAct
	goObj.WindowType = 0
	goObj.Visible = .T.
	goObj.Show()
	goObj.WindowState = 2
	DOEVENTS FORCE

	SELECT rul_temp
	ZAP
	goObj.gridart.Refresh()
	DOEVENTS FORCE

	PRIVATE pnAsserts, pnPass
	STORE 0 TO pnAsserts, pnPass

	DO HarnessStep WITH 0, 'nota interna goala afisata (lIntern=.T.)'

	*========================= DOC 1: FACTURA 8888 ARAFURA 1000 lei =========================
	PUBLIC goDlg, goT
	goDlg = CREATEOBJECT('import_adauga_factura', goObj)
	goDlg.cFelDoc = 'FACTURA'
	goDlg.nIdFdoc = 1
	goDlg.nNract = 8888
	goDlg.dDataAct = DATE()
	goDlg.nIdPartener = 500
	goDlg.cPartener = 'ARAFURA'
	goDlg.cExplicatia = ''
	goDlg.nSuma = 1000
	goDlg.nSumaLei = 0
	goDlg.nCurs = 0
	goDlg.nIdExplicatieTva = 208
	goDlg.cExplicatieTva = 'ACH. INT. NEEX. 21%'
	goDlg.optTipTva.Value = 1
	goDlg.chkInValutaCont.Value = 0
	goDlg.chkParticipaValuta.Value = 1
	goDlg.WindowType = 0
	goDlg.Visible = .T.
	goDlg.Show()
	DOEVENTS FORCE
	DO ConstruiesteToDlg
	DO PlLog WITH 'DOC1 (8888 ARAFURA 1000 lei): do_adauga_factura = ' + TRANSFORM(goObj.do_adauga_factura(goT))
	goDlg.Hide()
	DOEVENTS FORCE

	*========================= DOC 2: FACTURA 777 TRANSTAXI 200 lei (transport) =========================
	goDlg = CREATEOBJECT('import_adauga_factura', goObj)
	goDlg.cFelDoc = 'FACTURA'
	goDlg.nIdFdoc = 1
	goDlg.nNract = 777
	goDlg.dDataAct = DATE()
	goDlg.nIdPartener = 700
	goDlg.cPartener = 'TRANSTAXI'
	goDlg.cExplicatia = ''
	goDlg.nSuma = 200
	goDlg.nSumaLei = 0
	goDlg.nCurs = 0
	goDlg.nIdExplicatieTva = 208
	goDlg.cExplicatieTva = 'ACH. INT. NEEX. 21%'
	goDlg.optTipTva.Value = 1
	goDlg.chkInValutaCont.Value = 0
	goDlg.chkParticipaValuta.Value = 1
	goDlg.WindowType = 0
	goDlg.Visible = .T.
	goDlg.Show()
	DOEVENTS FORCE
	DO ConstruiesteToDlg
	DO PlLog WITH 'DOC2 (777 TRANSTAXI 200 lei): do_adauga_factura = ' + TRANSFORM(goObj.do_adauga_factura(goT))
	goDlg.Hide()
	DOEVENTS FORCE

	goObj.recalculeaza()
	DO PlLog WITH 'procent_lei dupa 2 documente = ' + TRANSFORM(goObj.procent_lei) + ' (astept 120)'

	DO HarnessStep WITH 1, '2 documente adaugate, procent_lei=' + TRANSFORM(goObj.procent_lei)

	*========================= ARTICOL prin fluxul REAL =========================
	LOCAL llEroareAdauga
	llEroareAdauga = .F.
	TRY
		goObj.do_adauga_articol()
	CATCH TO loExcAdd
		llEroareAdauga = .T.
		DO PlLog WITH 'EROARE la do_adauga_articol() ' + TRANSFORM(loExcAdd.ErrorNo) + ' [' + loExcAdd.Message + ;
			'] in ' + loExcAdd.Procedure + ':' + TRANSFORM(loExcAdd.LineNo)
	ENDTRY
	DOEVENTS FORCE
	goObj.gridart.Refresh()
	DOEVENTS FORCE
	DO PlLog WITH 'do_adauga_articol(): rul_temp = ' + TRANSFORM(RECCOUNT_ACTIVE('rul_temp')) + ' randuri, eroare=' + TRANSFORM(llEroareAdauga)

	SELECT rul_temp
	LOCATE FOR ALLTRIM(codmat) == 'ART-GREE-303'
	=Assert3('01-articolul AC GREE BORA (cont 303) adaugat prin fluxul real', IIF(FOUND(),1,0), 1)

	*========================= DUMP STARE RUNTIME COLOANA "Pret lei factura" =========================
	DO PlLog WITH '--- stare runtime GridArt / cPretFactura (lIntern=.T.) ---'
	DO PlLog WITH '  GridArt.RecordSource = [' + goObj.gridart.RecordSource + ']'
	DO PlLog WITH '  GridArt.ReadOnly = ' + TRANSFORM(goObj.gridart.ReadOnly) + '  Enabled = ' + TRANSFORM(goObj.gridart.Enabled)
	DO PlLog WITH '  GridArt.ColumnCount = ' + TRANSFORM(goObj.gridart.ColumnCount) + '  RecordMark=' + TRANSFORM(goObj.gridart.RecordMark)
	DO PlLog WITH '  cPretFactura.ControlSource = [' + goObj.gridart.cPretFactura.ControlSource + ']'
	DO PlLog WITH '  cPretFactura.Header1.Caption = [' + goObj.gridart.cPretFactura.Header1.Caption + ']'
	DO PlLog WITH '  cPretFactura.ReadOnly = ' + TRANSFORM(goObj.gridart.cPretFactura.ReadOnly) + ;
		'  Enabled = ' + TRANSFORM(goObj.gridart.cPretFactura.Enabled) + ;
		'  Visible = ' + TRANSFORM(goObj.gridart.cPretFactura.Visible) + ;
		'  ColumnOrder = ' + TRANSFORM(goObj.gridart.cPretFactura.ColumnOrder)
	DO PlLog WITH '  cPretFactura.CurrentControl = [' + goObj.gridart.cPretFactura.CurrentControl + ']  Sparse = ' + TRANSFORM(goObj.gridart.cPretFactura.Sparse)
	DO PlLog WITH '  cPretFactura.InputMask = [' + goObj.gridart.cPretFactura.InputMask + ']'
	DO PlLog WITH '  cPretFactura.Text1.ReadOnly = ' + TRANSFORM(goObj.gridart.cPretFactura.Text1.ReadOnly) + ;
		'  Enabled = ' + TRANSFORM(goObj.gridart.cPretFactura.Text1.Enabled) + ;
		'  InputMask = [' + goObj.gridart.cPretFactura.Text1.InputMask + ']' + ;
		'  ControlSource = [' + goObj.gridart.cPretFactura.Text1.ControlSource + ']'
	DO PlLog WITH '  cCant.ControlSource = [' + goObj.gridart.cCant.ControlSource + ']  ReadOnly = ' + TRANSFORM(goObj.gridart.cCant.ReadOnly) + ;
		'  ColumnOrder = ' + TRANSFORM(goObj.gridart.cCant.ColumnOrder)
	DO PlLog WITH '  cPretLeiCalculat.ControlSource = [' + goObj.gridart.cPretLeiCalculat.ControlSource + ']  ReadOnly = ' + TRANSFORM(goObj.gridart.cPretLeiCalculat.ReadOnly)

	*-- campul pret_lei chiar exista in rul_temp?
	LOCAL lnCamp, lcCampuri, i
	lcCampuri = ''
	SELECT rul_temp
	FOR i = 1 TO FCOUNT()
		IF INLIST(UPPER(FIELD(i)), 'PRET', 'PRETD', 'PRET_LEI', 'PRET_VAL', 'CANT')
			lcCampuri = lcCampuri + FIELD(i) + '(' + TYPE(FIELD(i)) + ') '
		ENDIF
	ENDFOR
	DO PlLog WITH '  campuri de pret in rul_temp: ' + lcCampuri
	=Assert3('02-campul pret_lei exista in rul_temp', IIF(TYPE('rul_temp.pret_lei') = 'N', 1, 0), 1)
	=Assert3('03-cPretFactura NU e ReadOnly la runtime', IIF(goObj.gridart.cPretFactura.ReadOnly, 0, 1), 1)
	=Assert3('04-GridArt NU e ReadOnly la runtime', IIF(goObj.gridart.ReadOnly, 0, 1), 1)
	=AssertStr('05-cPretFactura legata CALIFICAT pe rul_temp.pret_lei (intern)', LOWER(ALLTRIM(goObj.gridart.cPretFactura.ControlSource)), 'rul_temp.pret_lei')

	DO HarnessStep WITH 2, 'articol adaugat; stare coloana dumpata in log'

	*========================= TASTARE REALA: intai CANTITATE (coloana martor) =========================
	LOCAL lnColCant, lnColPret, lnCantDupa, lnPretLeiDupa
	lnColCant = goObj.gridart.cCant.ColumnOrder
	lnColPret = goObj.gridart.cPretFactura.ColumnOrder

	SELECT rul_temp
	GO TOP
	goObj.gridart.SetFocus()
	DOEVENTS FORCE
	TRY
		goObj.gridart.ActivateCell(1, lnColCant)
	CATCH TO loExcAc
		DO PlLog WITH 'EROARE ActivateCell(cant) ' + TRANSFORM(loExcAc.ErrorNo) + ' [' + loExcAc.Message + ']'
	ENDTRY
	DOEVENTS FORCE
	DO PlLog WITH 'dupa ActivateCell(cant): ActiveControl = [' + IIF(VARTYPE(goObj.ActiveControl)='O', goObj.ActiveControl.Name, '(niciunul)') + ']'
	KEYBOARD '2{ENTER}' PLAIN
	DOEVENTS FORCE
	DOEVENTS FORCE
	SELECT rul_temp
	GO TOP
	lnCantDupa = rul_temp.cant
	DO PlLog WITH 'MARTOR - dupa tastare "2" in Cantitate: rul_temp.cant = ' + TRANSFORM(lnCantDupa)

	*========================= TASTARE REALA: "Pret lei factura" =========================
	SELECT rul_temp
	GO TOP
	goObj.gridart.SetFocus()
	DOEVENTS FORCE
	TRY
		goObj.gridart.ActivateCell(1, lnColPret)
	CATCH TO loExcAc2
		DO PlLog WITH 'EROARE ActivateCell(pret) ' + TRANSFORM(loExcAc2.ErrorNo) + ' [' + loExcAc2.Message + ']'
	ENDTRY
	DOEVENTS FORCE
	DO PlLog WITH 'dupa ActivateCell(pret lei factura): ActiveControl = [' + IIF(VARTYPE(goObj.ActiveControl)='O', goObj.ActiveControl.Name, '(niciunul)') + ']'
	KEYBOARD '1000{ENTER}' PLAIN
	DOEVENTS FORCE
	DOEVENTS FORCE
	SELECT rul_temp
	GO TOP
	lnPretLeiDupa = rul_temp.pret_lei
	DO PlLog WITH 'TESTAT - dupa tastare "1000" in Pret lei factura: rul_temp.pret_lei = ' + TRANSFORM(lnPretLeiDupa) + ;
		'  pret = ' + TRANSFORM(rul_temp.pret) + '  pretd = ' + TRANSFORM(rul_temp.pretd)

	*-- KEYBOARD nu ajunge la celula in harness-ul headless (fereastra e off-screen, fara READ
	*-- care sa consume bufferul): coloana MARTOR ramane si ea pe 0. Diagnostic informativ,
	*-- fara assert; scrierea prin celula se verifica mai jos, prin Text1.Value + iesire din celula.
	DO PlLog WITH 'INFO tastare KEYBOARD nelivrata in harness (martor cant=' + TRANSFORM(lnCantDupa) + ') - fara assert'

	DO HarnessStep WITH 3, 'dupa tastare in grid: cant=' + TRANSFORM(lnCantDupa) + ' pret_lei=' + TRANSFORM(lnPretLeiDupa)

	*========================= CALEA PROGRAMATICA: do_executa_pret (ce face LostFocus) =========================
	SELECT rul_temp
	GO TOP
	REPLACE cant WITH 1, pret_lei WITH 1000
	goObj.do_executa_pret(1, RECNO(), 1000)
	DOEVENTS FORCE
	SELECT rul_temp
	GO TOP
	DO PlLog WITH 'dupa do_executa_pret(1, ., 1000): pret_lei = ' + TRANSFORM(rul_temp.pret_lei) + ;
		'  pret (calculat) = ' + TRANSFORM(rul_temp.pret) + '  procent_lei = ' + TRANSFORM(goObj.procent_lei)
	=Assert3('07-pret calculat = pret_lei * procent_lei/100 (1000 * 120% = 1200)', rul_temp.pret, 1200)

	goObj.sincronizeaza()
	DOEVENTS FORCE
	SELECT rul_temp
	GO TOP
	DO PlLog WITH 'dupa sincronizeaza(): pret_lei = ' + TRANSFORM(rul_temp.pret_lei) + '  pret = ' + TRANSFORM(rul_temp.pret)
	DO PlLog WITH 'cmesajsync = [' + goObj.cmesajsync + ']'
	=Assert3('08-pret_lei supravietuieste sincronizarii', rul_temp.pret_lei, 1000)

	*========================= EXPERIMENT: legarea coloanei (calificat vs necalificat) =========================
	*-- cCant a fost legata de VFP la bindarea grilei (work area = rul_temp) -> ControlSource
	*-- calificat. cPretFactura a primit ControlSource-ul in Init, cand work area curenta era
	*-- introdc (care NU are pret_lei) -> a ramas necalificat = expresie nelegata = celula needitabila.
	DO PlLog WITH '--- EXPERIMENT legare coloana ---'
	*-- proba de legare: Bound + valoarea citita de Text1 pe celula activa (coloana legata
	*-- citeste campul, cea nelegata ramane pe 0)
	SELECT rul_temp
	GO TOP
	goObj.gridart.Refresh()
	DOEVENTS FORCE
	DO PlLog WITH '  cCant.Bound = ' + TRANSFORM(goObj.gridart.cCant.Bound) + ;
		'  cPretFactura.Bound = ' + TRANSFORM(goObj.gridart.cPretFactura.Bound) + ;
		'  cPretLeiCalculat.Bound = ' + TRANSFORM(goObj.gridart.cPretLeiCalculat.Bound) + ;
		'  cValoareLeiCalculat.Bound (nelegata prin design) = ' + TRANSFORM(goObj.gridart.cValoareLeiCalculat.Bound)
	goObj.gridart.ActivateCell(1, goObj.gridart.cPretLeiCalculat.ColumnOrder)
	DOEVENTS FORCE
	DO PlLog WITH '  cPretLeiCalculat.Text1.Value (camp pret=' + TRANSFORM(rul_temp.pret) + ') = ' + TRANSFORM(goObj.gridart.cPretLeiCalculat.Text1.Value)
	goObj.gridart.ActivateCell(1, goObj.gridart.cPretFactura.ColumnOrder)
	DOEVENTS FORCE
	DO PlLog WITH '  cPretFactura.Text1.Value (camp pret_lei=' + TRANSFORM(rul_temp.pret_lei) + ') = ' + TRANSFORM(goObj.gridart.cPretFactura.Text1.Value)

	*-- scriere prin celula activa: pun valoarea in Text1 si ies din celula (ce face grid-ul la Enter/Tab).
	*-- Coloana MARTOR (cCant, legata calificat de VFP la bindare) vs coloana testata (cPretFactura).
	LOCAL lnCantMartor, lnPretScris
	SELECT rul_temp
	GO TOP
	goObj.gridart.ActivateCell(1, goObj.gridart.cCant.ColumnOrder)
	DOEVENTS FORCE
	DO PlLog WITH '  dupa ActivateCell(cCant): ActiveColumn = ' + TRANSFORM(goObj.gridart.ActiveColumn) + ' (cCant e Columns(3))'
	goObj.gridart.cCant.Text1.Value = 7
	goObj.gridart.cCant.Text1.Valid()
	goObj.gridart.cCant.Text1.LostFocus()
	goObj.gridart.ActivateCell(1, goObj.gridart.cSerie.ColumnOrder)
	DOEVENTS FORCE
	SELECT rul_temp
	GO TOP
	lnCantMartor = rul_temp.cant
	DO PlLog WITH '  MARTOR scriere prin Text1.Value=7 pe cCant -> rul_temp.cant = ' + TRANSFORM(lnCantMartor)

	SELECT rul_temp
	GO TOP
	goObj.gridart.ActivateCell(1, goObj.gridart.cPretFactura.ColumnOrder)
	DOEVENTS FORCE
	DO PlLog WITH '  dupa ActivateCell(cPretFactura): ActiveColumn = ' + TRANSFORM(goObj.gridart.ActiveColumn) + ' (cPretFactura e Columns(4))'
	goObj.gridart.cPretFactura.Text1.Value = 555
	goObj.gridart.cPretFactura.Text1.LostFocus()
	goObj.gridart.ActivateCell(1, goObj.gridart.cSerie.ColumnOrder)
	DOEVENTS FORCE
	SELECT rul_temp
	GO TOP
	lnPretScris = rul_temp.pret_lei
	DO PlLog WITH '  TESTAT scriere prin Text1.Value=555 pe cPretFactura -> rul_temp.pret_lei = ' + TRANSFORM(lnPretScris)
	=Assert3('10-MARTOR: scrierea prin celula ajunge in rul_temp.cant', lnCantMartor, 7)
	=Assert3('11-scrierea prin celula "Pret lei factura" ajunge in rul_temp.pret_lei', lnPretScris, 555)

	SELECT introdc
	goObj.gridart.cPretFactura.ControlSource = 'pret_lei'
	DO PlLog WITH '  A. asignare "pret_lei" cu work area = introdc -> ControlSource intors = [' + goObj.gridart.cPretFactura.ControlSource + ']'

	SELECT rul_temp
	goObj.gridart.cPretFactura.ControlSource = 'pret_lei'
	DO PlLog WITH '  B. asignare "pret_lei" cu work area = rul_temp -> ControlSource intors = [' + goObj.gridart.cPretFactura.ControlSource + ']'

	SELECT introdc
	goObj.gridart.cPretFactura.ControlSource = 'rul_temp.pret_lei'
	DO PlLog WITH '  C. asignare "rul_temp.pret_lei" cu work area = introdc -> ControlSource intors = [' + goObj.gridart.cPretFactura.ControlSource + ']'

	=AssertStr('09-ControlSource calificat dupa asignarea explicita', LOWER(ALLTRIM(goObj.gridart.cPretFactura.ControlSource)), 'rul_temp.pret_lei')

	DO PlLog WITH 'REZULTAT: ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' assert-uri PASS'
	IF pnPass = pnAsserts
		DO PlLog WITH 'REZULTAT: PASS'
	ELSE
		DO PlLog WITH 'REZULTAT: FAIL'
	ENDIF

	DO HarnessStep WITH 4, 'final: ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' PASS'
	DO HarnessDone WITH 'done'

CATCH TO loExc
	DO PlLog WITH 'CATCH ErrorNo=' + TRANSFORM(loExc.ErrorNo) + ' Message=' + loExc.Message + ' Proc=' + loExc.Procedure + ' Line=' + TRANSFORM(loExc.LineNo) + ' [' + loExc.LineContents + ']'
	DO HarnessDone WITH 'done-error'
ENDTRY

QUIT

*==================================================================================
PROCEDURE ConstruiesteToDlg
	goT = CREATEOBJECT('Empty')
	=ADDPROPERTY(goT,'serie_act',ALLTRIM(NVL(goDlg.cSerieAct,'')))
	=ADDPROPERTY(goT,'nract',goDlg.nNract)
	=ADDPROPERTY(goT,'dataact',goDlg.dDataAct)
	=ADDPROPERTY(goT,'fdoc',goDlg.cFelDoc)
	=ADDPROPERTY(goT,'id_fdoc',goDlg.nIdFdoc)
	=ADDPROPERTY(goT,'id_partc',goDlg.nIdPartener)
	=ADDPROPERTY(goT,'partc',goDlg.cPartener)
	=ADDPROPERTY(goT,'explicatia',ALLTRIM(NVL(goDlg.cExplicatia,'')))
	=ADDPROPERTY(goT,'suma',IIF(goDlg.chkInValutaCont.Value=1 AND goDlg.nCurs<>0,IIF(goDlg.nSumaLei<>0,goDlg.nSumaLei,ROUND(goDlg.nSuma*goDlg.nCurs,gnPC)),goDlg.nSuma))
	=ADDPROPERTY(goT,'suma_val',IIF(goDlg.chkInValutaCont.Value=1 AND goDlg.nCurs<>0,goDlg.nSuma,0))
	=ADDPROPERTY(goT,'in_valuta',goDlg.chkInValutaCont.Value)
	=ADDPROPERTY(goT,'participa_valuta',(goDlg.chkParticipaValuta.Value=1))
	=ADDPROPERTY(goT,'id_valuta',IIF(goDlg.chkInValutaCont.Value=1,goDlg.nIdValuta,0))
	=ADDPROPERTY(goT,'curs',IIF(goDlg.chkInValutaCont.Value=1,goDlg.nCurs,0))
	=ADDPROPERTY(goT,'nume_val',IIF(goDlg.chkInValutaCont.Value=1,ALLTRIM(NVL(goDlg.cValuta,'')),''))
	=ADDPROPERTY(goT,'cTipTva',IIF(goDlg.optTipTva.Value=1,'F',IIF(goDlg.optTipTva.Value=2,'D','N')))
	=ADDPROPERTY(goT,'id_jtva_coloana',goDlg.nIdExplicatieTva)
	=ADDPROPERTY(goT,'dvi_serie','')
	=ADDPROPERTY(goT,'dvi_nract',0)
	=ADDPROPERTY(goT,'dvi_dataact',goDlg.dDataAct)
	=ADDPROPERTY(goT,'dvi_id_fdoc',0)
	=ADDPROPERTY(goT,'dvi_fdoc','')
	=ADDPROPERTY(goT,'dvi_id_partc',0)
	=ADDPROPERTY(goT,'dvi_partc','')
	=ADDPROPERTY(goT,'dvi_scc','401')
	=ADDPROPERTY(goT,'dvi_tva_lei',0)
	=ADDPROPERTY(goT,'dvi_tva_val',0)
ENDPROC

PROCEDURE CreeazaIntrodc
	LPARAMETERS tcAlias
	IF USED(tcAlias)
		USE IN (tcAlias)
	ENDIF
	CREATE CURSOR (tcAlias) ( ;
		id_note N(14), explicatia C(100), scd C(10), ascd C(20), scc C(10), ascc C(20), ;
		cu_tva N(1), id_set N(14), ordine N(8), in_valuta N(1), id_jtva_coloana N(14) NULL, ;
		ptva N(6,2), explicatie_tva C(50), tipjurnal C(2), taxcode N(6), paymentcode C(9), ;
		suma N(18,4), suma_val N(18,4), id_partd N(14), id_partc N(14), partd C(100), partc C(100), ;
		id_fact N(14), id_factd N(14), id_factc N(14), pereched N(14), perechec N(14), ;
		nract N(14), serie_act C(10), explicatia4 C(50), explicatia5 C(50), participa_valuta L, ;
		id_valuta N(14), curs N(14,4), nume_val C(10), dataact D, fdoc C(50), id_fdoc N(14), ;
		se_scrie N(1), tva_incasare N(1), doc_color N(10), doc_label C(10), tip_rand C(1), ;
		doc_key C(80), nr_doc N(8), suma_doc N(18,4), suma_doc_val N(18,4), mod_manual N(1), expl_manual N(1), ;
		scd_orig C(20), ascd_orig C(20), rand_dvi N(1), valuta_proprie N(1))
ENDPROC

PROCEDURE CreeazaRulTemp
	IF USED('rul_temp')
		USE IN ('rul_temp')
	ENDIF
	CREATE CURSOR rul_temp ( ;
		id_rul N(20,0), an N(4,0), luna N(2,0), cod N(20,0);
		, serie C(100), nnir N(20,0), id_articol N(10,0), denumire C(100);
		, codmat C(50), codmatf C(50), codbare C(50), um C(20);
		, id_gestiune N(5,0), nume_gestiune C(50), cgest C(20), nr_pag N(2,0);
		, gestionar C(50), comisie_receptie1 C(50), comisie_receptie2 C(50), comisie_receptie3 C(50);
		, cant N(14,3), cante N(14,3), cont C(10), acont C(20);
		, pret N(18,4), tva N(18,4), valoare N(18,4), valtva N(18,4);
		, proc_tva N(5,2), pretv N(18,4), pretvtva N(18,4), tvav N(18,4);
		, valoarev N(18,4), valtvav N(18,4), proc_tvav N(5,2), adaos N(18,4);
		, adaos_tva N(18,4), valoare_adaos N(18,4), valtva_adaos N(18,4), procent N(10,3);
		, discunitar N(18,4), discount_tva N(18,4), valoare_discount N(18,4), valtva_discount N(18,4);
		, proc_disc N(7,3), pretd N(14,4), curs N(18,4), id_valuta N(10,0);
		, nume_val C(20), id_lucrare N(20,0), nrord C(100), id_responsabil N(10,0);
		, nresp C(100), resp_marca N(18,4), dataact T, id_util N(5,0);
		, util C(30), dataora T, id_sectie N(5,0), sectie C(50);
		, csectie C(10), alcooltutun N(1,0), datain T, dataout T;
		, id_fact N(20,0), id_gestiunec N(10,0), nume_gestiunec C(50), cgestc C(20);
		, id_responsabilc N(5,0), id_reteta N(10,0), reteta C(50), nrespc C(100);
		, respc_marca N(18,4), id_set N(20,0), id_tip_rulaj N(10,0), tip_rulaj C(50);
		, id_obiect_depozit N(10,0), id_rul_aux N(10,0), nract N(20,0), serie_act C(10);
		, dataoras T, id_utils N(10,0), lot C(30), adata_expirare T;
		, id_sucursala N(5,0), sucursala C(250), id_part_rez N(10,0), part_rez C(100);
		, id_lucrare_rez N(10,0), nrord_rez C(100), subgrupa C(100), grupa C(100);
		, id_subgrupa N(5,0), id_grupa N(5,0), in_stoc N(1,0), in_crm N(1,0);
		, id_furnizor N(10,0), furnizor C(100), id_jtva_coloana N(4,0), explicatie_tva C(100);
		, taxcode N(6,0), taxname C(254), saft_procent N(18,4), codnc8 C(20);
		, id_tara_origine N(4,0), cod_tara_origine C(5), tara_origine C(50), greutate N(12,4);
		, fdoc C(30), id_fdoc N(18,4);
		, pret_lei N(18,4), pret_val N(14,4), cota_tva N(6,2))
ENDPROC

FUNCTION RECCOUNT_ACTIVE
	LPARAMETERS tcAlias
	LOCAL lnSel, lnCnt
	lnSel = SELECT()
	SELECT (tcAlias)
	COUNT TO lnCnt FOR !DELETED()
	SELECT (lnSel)
	RETURN lnCnt
ENDFUNC

PROCEDURE Assert3
	LPARAMETERS tcLabel, tuActual, tuExpected
	pnAsserts = pnAsserts + 1
	IF ABS(NVL(tuActual,0) - tuExpected) < 0.02
		pnPass = pnPass + 1
		DO PlLog WITH '  PASS ' + tcLabel + ' (=' + TRANSFORM(tuActual) + ')'
	ELSE
		DO PlLog WITH '  FAIL ' + tcLabel + ' (actual=' + TRANSFORM(tuActual) + ' asteptat=' + TRANSFORM(tuExpected) + ')'
	ENDIF
ENDPROC

PROCEDURE AssertStr
	LPARAMETERS tcLabel, tcActual, tcExpected
	pnAsserts = pnAsserts + 1
	IF tcActual == tcExpected
		pnPass = pnPass + 1
		DO PlLog WITH '  PASS ' + tcLabel + ' (=[' + tcActual + '])'
	ELSE
		DO PlLog WITH '  FAIL ' + tcLabel + ' (actual=[' + tcActual + '] asteptat=[' + tcExpected + '])'
	ENDIF
ENDPROC

PROCEDURE PlErr
	LPARAMETERS tnErr, tcMsg, tcProg, tnLine
	DO PlLog WITH 'ON ERROR ' + TRANSFORM(tnErr) + ' [' + tcProg + ':' + TRANSFORM(tnLine) + '] ' + tcMsg
ENDPROC

PROCEDURE PlLog
	LPARAMETERS tcMsg
	SET SAFETY OFF
	LOCAL lcL
	lcL = IIF(FILE(gcUILog), FILETOSTR(gcUILog), '')
	STRTOFILE(lcL + tcMsg + CHR(13)+CHR(10), gcUILog)
ENDPROC

DEFINE CLASS dummyapp AS Custom
	PROCEDURE ReadIni
		LPARAMETERS tcSection, tcKey
		RETURN ''
	ENDPROC
	PROCEDURE WriteIni
		LPARAMETERS tcSection, tcKey, tcValue
		RETURN .T.
	ENDPROC
ENDDEFINE

DEFINE CLASS dummyexecutor AS Custom
	cEroare = ''
	PROCEDURE oExecute
		LPARAMETERS tcSql, tcCursor
		IF USED(m.tcCursor)
			USE IN (m.tcCursor)
		ENDIF
		IF 'VJTVA_COLOANE' $ UPPER(m.tcSql)
			DO CreeazaJtvaColoaneView WITH m.tcCursor
			RETURN 1
		ENDIF
		IF UPPER(ALLTRIM(m.tcCursor)) == 'RUL_TEMP'
			DO CreeazaRulTemp
			RETURN 1
		ENDIF
		IF 'CONFIG_ANALITICE' $ UPPER(m.tcSql)
			CREATE CURSOR (m.tcCursor) (camp_leg_prefix C(30), camp_leg_sufix C(30))
			INSERT INTO (m.tcCursor) VALUES ('', '')
			RETURN 1
		ENDIF
		IF 'FCONTURI_ANALITICE' $ UPPER(m.tcSql)
			CREATE CURSOR (m.tcCursor) (acont C(20))
			INSERT INTO (m.tcCursor) VALUES ('')
			RETURN 1
		ENDIF
		IF 'VPLCONT_ANALITIC' $ UPPER(m.tcSql)
			CREATE CURSOR (m.tcCursor) (cont C(10), acont C(20))
			RETURN 1
		ENDIF
		IF 'VCONFIG_CONT_IREG' $ UPPER(m.tcSql)
			CREATE CURSOR (m.tcCursor) (contpart C(10), fel_cont N(1), cu_inregistrari N(1), ;
				explic_cont C(100), exceptie C(10), pozitie N(1), invers N(1), gasit N(1))
			INSERT INTO (m.tcCursor) VALUES ('401', 0, 0, 'Furnizori', '', 0, 0, 0)
			RETURN 1
		ENDIF
		CREATE CURSOR (m.tcCursor) (id_temp N(1))
		RETURN 1
	ENDPROC
	PROCEDURE oExecuta
		LPARAMETERS tcSql, tcCursor
		IF !EMPTY(m.tcCursor)
			IF USED(m.tcCursor)
				USE IN (m.tcCursor)
			ENDIF
			IF UPPER(m.tcCursor) == 'CJTVACOL4427'
				CREATE CURSOR (m.tcCursor) (id_jtva_coloana N(14))
			ELSE
				CREATE CURSOR (m.tcCursor) (id_temp N(1))
			ENDIF
		ENDIF
		RETURN .T.
	ENDPROC
	PROCEDURE oSelect2Value
		LPARAMETERS tcSql, toValue
		toValue = ''
		RETURN 1
	ENDPROC
	PROCEDURE oReset
	ENDPROC
ENDDEFINE

PROCEDURE CreeazaJtvaColoaneView
	LPARAMETERS tcCursor
	IF USED(m.tcCursor)
		USE IN (m.tcCursor)
	ENDIF
	CREATE CURSOR (tcCursor) (id_jtva_coloana N(14), denumire C(100), jc N(1), jv N(1), ;
		coloana_jc C(20), coloana_jv C(20), cota_tva N(6,2), id_tva N(14) NULL, afisat N(1), ;
		id_jtva_ex N(14) NULL, id_jtva_neex N(14) NULL, ordine N(8), ;
		taxcode N(6) NULL, taxcode_neexigibil N(6) NULL, taxcode_n50 N(6) NULL, ;
		taxcode_n50_tvai N(6) NULL, taxcode_n100 N(6) NULL, taxcode_regularizare N(6) NULL, taxcode_tvai N(6) NULL)
	INSERT INTO (m.tcCursor) (id_jtva_coloana, denumire, jc, jv, afisat, ordine, cota_tva) VALUES (0, '', 0, 0, 1, 0, 0)
	INSERT INTO (m.tcCursor) (id_jtva_coloana, denumire, jc, jv, coloana_jc, cota_tva, id_tva, afisat, ordine, taxcode) ;
		VALUES (208, 'ACH. INT. NEEX. 21%', 1, 0, 'RO21B', 21, 209, 1, 1, 301104)
	INSERT INTO (m.tcCursor) (id_jtva_coloana, denumire, jc, jv, coloana_jc, cota_tva, afisat, ordine, taxcode) ;
		VALUES (209, 'TVA ACH. INT. NEEX 21%', 1, 0, 'RO21T', 21, 1, 2, 301104)
ENDPROC
