* test_debifare_invaluta.prg - verifica fix-ul Grid1.cInValuta.Check1.Valid (COMUN\clase\
* ointroduceri.vcx, clasa IMPORT_nota): la debifare (in_valuta=0) se sterg valuta/suma_val/
* curs SI suma_doc_val (runda 2) pe TOATE randurile documentului (doc_key), prin
* copiaza_valoare (propagare pe grup); la re-bifare (in_valuta=1) doar in_valuta se propaga
* neconditionat, campurile de valuta raman goale (nu se restaureaza).
*
* Runda 4: dupa orice Valid relevant (cInValuta, cCurs, cParticipaValuta), formularul
* armeaza o sincronizare amanata (lSyncPending+tmrSync) care ruleaza sincronizeaza():
* recalculeaza()+do_reface() (repretare articole), sparge_document/uneste_document pe
* TOATE documentele din grid (nu doar cel editat), recalc_diferente, valideaza_sume,
* repozitionare. nr_doc trebuie sa fie UNIC per document (invariant real, calc_doc_key) -
* altfel sparge_document trateaza gresit mai multe documente ca fiind "principalul" (nr_doc
* minim), amestecandu-le. Documentele: 2001 (nr_doc=1, principal - are articole in rul_temp),
* 101 (nr_doc=2, secundar, mod_manual=0 pe S - participa la spargere/repartizare), 102
* (nr_doc=3, secundar, mod_manual=1 pe S - sparge_document il lasa neatins, guard manual).
*
* Pasi: PAS1/2 pozitioneaza pe randul B (doc 2001), debifeaza (Check1.Value=0 + Valid()),
* verifica armarea sincronizarii, apoi (dupa DOEVENTS) TOATE randurile documentului rezultate
* din sync; re-bifeaza (Value=1 + Valid()), verifica propagarea neconditionata a in_valuta si
* ca valuta ramane goala. PAS3 debifeaza randul S al doc 101 (secundar, nemanual) si verifica
* ca valideaza_sume() ramane .T.. PAS4 schimba cursul pe randul S al doc 102 (secundar, manual -
* sparge_document nu il atinge) si verifica recalcularea sumelor + totalurile. PAS5 (nou)
* debifeaza cParticipaValuta pe doc 102 si verifica armarea + consumarea sincronizarii amanate.
*
* Rulare (prin harness):
*   powershell -ExecutionPolicy Bypass -File vfp_ui_harness.ps1 -TestPrg <acest.prg> -Steps @(...)
* Log: test_debifare_invaluta_log.txt

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_debifare_invaluta_log.txt"
gcSyncDir = "D:\ROA\ROAGEST\COMUN\utile\Teste\achizitie_import\uisync_debifare\"
STRTOFILE("START " + TTOC(DATETIME()) + CHR(13)+CHR(10), gcUILog)

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

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

	lcPath = 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 UILog 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 UILog WITH 'SET CLASSLIB OK'

	*----- PROCEDURI -----
	SET PROCEDURE TO PROCEDURI
	SET PROCEDURE TO "D:\ROA\ROAGEST\COMUN\utile\Teste\mock_amessagebox.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

	*----- Harness UI reutilizabil -----
	SET PROCEDURE TO "D:\ROA\ROAGEST\COMUN\utile\Teste\ui_harness.prg" ADDITIVE

	DO UILog WITH 'SET PROCEDURE OK'

	*----- Globale minimale cerute de definitia clasei / Init -----
	PUBLIC gnPc, gnPval, gnPcant, gnPpret, gnPPretval, gnPCurs, gnPVal, gnPPretV, gnPPretVal
	gnPc = 2
	gnPval = 2
	gnPVal = 2
	gnPcant = 3
	gnPpret = 4
	gnPPretval = 4
	gnPPretVal = 4
	gnPPretV = 4
	gnPCurs = 4

	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)

	*----- goExecutor dummy -----
	PUBLIC goExecutor
	goExecutor = CREATEOBJECT('dummyexecutor')
	DO UILog WITH 'goExecutor dummy creat'

	*----- goApp dummy -----
	PUBLIC goApp
	goApp = CREATEOBJECT('dummyapp')
	DO UILog WITH 'goApp dummy creat'

	*----- poAct dummy -----
	PUBLIC poAct
	poAct = CREATEOBJECT('Custom')
	poAct.AddProperty('nume_val', 'USD')
	poAct.AddProperty('curs', 4.56)
	poAct.AddProperty('proc_tva', 1.21)
	poAct.AddProperty('nnir', 0)
	poAct.AddProperty('dataact', DATE())
poAct.AddProperty('id_valuta', 1)

	*----- jtva_coloane2: minimal -----
	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. 21%', 1, 0, 1, 'RO21B', 'RO21T', 21, 209)
	INSERT INTO jtva_coloane2 VALUES (2, 209, 'TVA ACH. INT. 21%', 1, 0, 1, 'RO21T', '', 21, 0)
	DO UILog WITH 'jtva_coloane2 creat (minimal)'

	*----- saft_taxtable: minimal -----
	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)
	DO UILog WITH 'saft_taxtable creat (minimal)'

	*----- introdc: RecordSource Grid1. Documente cu nr_doc UNIC per document (invariant real,
	*      vezi calc_doc_key) - altfel sincronizeaza() confunda mai multe documente cu nr_doc egal
	*      drept "principalul" (nr_doc minim). Document 2001 (nr_doc=1, principal): rand B
	*      (suma=1000, suma_val=219.30) + rand T pereche (suma=210=1000*21%, suma_val=46.05,
	*      ptva=21 - consistent, ca do_executa sa nu modifice suma la recalculare). in_valuta=1,
	*      id_valuta=1, nume_val='USD', curs=4.56 pe ambele randuri. -----
	IF USED('introdc')
		USE IN ('introdc')
	ENDIF
	CREATE CURSOR introdc ( ;
		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))

	INSERT INTO introdc (tip_rand, scd, scc, ascc, suma, suma_val, id_jtva_coloana, ptva, explicatie_tva, ;
			in_valuta, participa_valuta, id_valuta, curs, nume_val, nr_doc, nract, serie_act, fdoc, partc, explicatia, ;
			cu_tva, dataact, suma_doc, suma_doc_val, doc_key, mod_manual) ;
		VALUES ('B','371','401','FURN01', 1000, 219.30, 208, 21, 'ACH. INT. 21%', ;
			1, .T., 1, 4.56, 'USD', 1, 2001, 'A', 'Factura', 'FURNIZOR ABC SRL', 'Marfa achizitionata valuta', ;
			1, DATE(), 1000, 219.30, 'A|2001|0|0', 0)
	INSERT INTO introdc (tip_rand, scd, scc, ascc, suma, suma_val, id_jtva_coloana, ptva, explicatie_tva, ;
			in_valuta, participa_valuta, id_valuta, curs, nume_val, nr_doc, nract, serie_act, fdoc, partc, explicatia, ;
			cu_tva, dataact, suma_doc, suma_doc_val, doc_key, mod_manual) ;
		VALUES ('T','4426','401','FURN01', 210, 46.05, 209, 21, 'TVA ACH. INT. 21%', ;
			1, .T., 1, 4.56, 'USD', 1, 2001, 'A', 'Factura', 'FURNIZOR ABC SRL', 'TVA deductibil valuta', ;
			1, DATE(), 1000, 219.30, 'A|2001|0|0', 0)
	INSERT INTO introdc (tip_rand, scd, scc, ascc, suma, suma_val, id_jtva_coloana, ptva, explicatie_tva, ;
			in_valuta, participa_valuta, id_valuta, curs, nume_val, nr_doc, nract, serie_act, fdoc, partc, explicatia, ;
			cu_tva, dataact, suma_doc, suma_doc_val, doc_key, mod_manual) ;
		VALUES ('S','371','401','FURN02', 450, 100, 208, 21, 'ACH. INT. 21%', ;
			1, .T., 1, 4.50, 'USD', 2, 101, 'D', 'DVI', 'FURNIZOR XYZ SRL', 'Marfa achizitionata valuta spart pe conturi', ;
			1, DATE(), 450, 100, 'D|101|0|0', 0)
	INSERT INTO introdc (tip_rand, scd, scc, ascc, suma, suma_val, id_jtva_coloana, ptva, explicatie_tva, ;
			in_valuta, participa_valuta, id_valuta, curs, nume_val, nr_doc, nract, serie_act, fdoc, partc, explicatia, ;
			cu_tva, dataact, suma_doc, suma_doc_val, doc_key, mod_manual) ;
		VALUES ('T','4426','401','FURN02', 94.50, 21, 209, 21, 'TVA ACH. INT. 21%', ;
			1, .T., 1, 4.50, 'USD', 2, 101, 'D', 'DVI', 'FURNIZOR XYZ SRL', 'TVA deductibil valuta spart pe conturi', ;
			1, DATE(), 450, 100, 'D|101|0|0', 0)
	INSERT INTO introdc (tip_rand, scd, scc, ascc, suma, suma_val, id_jtva_coloana, ptva, explicatie_tva, ;
			in_valuta, participa_valuta, id_valuta, curs, nume_val, nr_doc, nract, serie_act, fdoc, partc, explicatia, ;
			cu_tva, dataact, suma_doc, suma_doc_val, doc_key, mod_manual) ;
		VALUES ('S','371','401','FURN03', 2615, 500, 208, 21, 'ACH. INT. 21%', ;
			1, .T., 1, 5.23, 'USD', 3, 102, 'D', 'DVI', 'FURNIZOR QRS SRL', 'Marfa achizitionata valuta curs manual', ;
			1, DATE(), 2615, 500, 'D|102|0|0', 1)
	INSERT INTO introdc (tip_rand, scd, scc, ascc, suma, suma_val, id_jtva_coloana, ptva, explicatie_tva, ;
			in_valuta, participa_valuta, id_valuta, curs, nume_val, nr_doc, nract, serie_act, fdoc, partc, explicatia, ;
			cu_tva, dataact, suma_doc, suma_doc_val, doc_key, mod_manual) ;
		VALUES ('T','4426','401','FURN03', 549.15, 105, 209, 21, 'TVA ACH. INT. 21%', ;
			1, .T., 1, 5.23, 'USD', 3, 102, 'D', 'DVI', 'FURNIZOR QRS SRL', 'TVA deductibil valuta curs manual', ;
			1, DATE(), 2615, 500, 'D|102|0|0', 0)
	GO TOP IN introdc
	DO UILog WITH 'introdc populat (' + TRANSFORM(RECCOUNT('introdc')) + ' randuri: doc 2001(nr_doc=1,principal) B+T + doc 101(nr_doc=2,secundar) S+T + doc 102(nr_doc=3,secundar,manual) S+T)'

	*----- rul_temp: RecordSource GridArt. Pre-populat, ca sa nu-l recreeze Init din Oracle. -----
	IF USED('rul_temp')
		USE IN ('rul_temp')
	ENDIF
	CREATE CURSOR rul_temp (denumire C(100), codmat C(30), cant N(14,3), ;
		pret_val N(18,4), pretd N(18,4), pret N(18,4), pret_lei N(18,4), ;
		cont C(10), acont C(20), serie C(30), lot C(30), adata_expirare C(10), ;
		proc_disc N(6,2), cota_tva N(6,2))
	INSERT INTO rul_temp (denumire, codmat, cant, pret_val, pretd, pret, pret_lei, ;
			cont, acont, serie, lot, adata_expirare, proc_disc, cota_tva) ;
		VALUES ('Laptop Dell Latitude', 'ART001', 1, 219.30, 219.30, 1000, 1000, ;
			'371', '01', 'SN-LAP-001', 'L001', '', 0, 21)
	GO TOP IN rul_temp
	DO UILog WITH 'rul_temp populat (' + TRANSFORM(RECCOUNT('rul_temp')) + ' articole)'

	*----- Desktop VFP vizibil, maximizat -----
	_SCREEN.Visible = .T.
	_SCREEN.WindowState = 2
	_SCREEN.Caption = 'TEST debifare in_valuta'

	DO UILog WITH 'mediu pregatit, CREATEOBJECT(import_nota, .F.)'

	SELECT introdc
	PUBLIC goObj
	goObj = CREATEOBJECT('IMPORT_nota', .F.)

	IF VARTYPE(goObj) <> 'O'
		DO UILog WITH 'FAIL: CREATEOBJECT a returnat ' + TRANSFORM(goObj)
		DO HarnessDone WITH 'done-error'
		QUIT
	ENDIF
	goObj.oact = poAct
	*-- suprim auto-deschiderea modala a dialogului Adauga factura din Activate (ar bloca testul)
	goObj.lDialogAratat = .T.
	DO UILog WITH 'PASS: instantiere OK, afisez formularul'

	goObj.WindowType = 0
	goObj.Visible = .T.
	goObj.Show()
	goObj.WindowState = 2
	DOEVENTS FORCE

	*========================= PAS 0: formular afisat =========================
	DO HarnessStep WITH 0, 'Formular afisat: introdc=' + TRANSFORM(RECCOUNT('introdc')) + ' randuri, in_valuta B=' + TRANSFORM(introdc.in_valuta)

	*========================= PAS 1: DEBIFARE (Check1.Value=0 + Valid()) pe randul B, doc 2001 =========================
	PRIVATE pnAsserts, pnPass
	LOCAL lnA1, lnP1
	STORE 0 TO pnAsserts, pnPass

	SELECT introdc
	GO TOP
	LOCATE FOR nract == 2001 AND tip_rand == 'B'
	=Assert3('PAS1: rand B doc 2001 gasit (Found)', IIF(FOUND(),1,0), 1)
	DO UILog WITH 'PAS1: pozitionat pe randul B (nract=2001), in_valuta INAINTE=' + TRANSFORM(introdc.in_valuta) + ' nume_val=' + ALLTRIM(introdc.nume_val)

	goObj.grid1.cInValuta.check1.Value = 0
	goObj.grid1.cInValuta.check1.Valid()

	*-- R4: dupa Valid, INAINTE de DOEVENTS, sincronizarea trebuie doar ARMATA (nu executata inca)
	=Assert3('PAS1 armare: lSyncPending=.T. dupa Valid (pre-DOEVENTS)', IIF(goObj.lSyncPending,1,0), 1)
	=Assert3('PAS1 armare: tmrSync.Interval>0 dupa Valid (pre-DOEVENTS)', IIF(goObj.tmrSync.Interval>0,1,0), 1)

	DOEVENTS FORCE

	*-- dupa DOEVENTS, tmrSync trebuie sa fi consumat armarea si rulat sincronizeaza()
	=Assert3('PAS1 sync consumat: lSyncPending=.F. dupa DOEVENTS', IIF(goObj.lSyncPending,1,0), 0)
	=Assert3('PAS1 sync consumat: tmrSync.Interval=0 dupa DOEVENTS', goObj.tmrSync.Interval, 0)
	DO DumpIntrodc WITH 'dupa PAS1 sync'

	*-- verificare TOATE randurile documentului 2001 dupa sincronizare (sparge_document poate
	*-- re-crea S-uri din rul_temp; B-ul original ramane ca sablon) - filtrate pe nract, nu pe
	*-- pozitie fizica (ordinea/structura se poate schimba dupa sync)
	LOCAL lnCntBS2001, lnSumaLei2001, lnCntT2001
	STORE 0 TO lnCntBS2001, lnSumaLei2001, lnCntT2001
	SELECT introdc
	SCAN FOR nract == 2001
		DO CASE
		CASE INLIST(tip_rand,'B','S')
			lnCntBS2001 = lnCntBS2001 + 1
			lnSumaLei2001 = lnSumaLei2001 + suma
			=Assert3('2001.'+tip_rand+'['+TRANSFORM(RECNO())+'].in_valuta=0', in_valuta, 0)
			=Assert3('2001.'+tip_rand+'['+TRANSFORM(RECNO())+'].id_valuta=0', id_valuta, 0)
			=AssertStr('2001.'+tip_rand+'['+TRANSFORM(RECNO())+'].nume_val=""', ALLTRIM(NVL(nume_val,'?')), '')
			=Assert3('2001.'+tip_rand+'['+TRANSFORM(RECNO())+'].curs=0', curs, 0)
			=Assert3('2001.'+tip_rand+'['+TRANSFORM(RECNO())+'].suma_val=0', suma_val, 0)
			=Assert3('2001.'+tip_rand+'['+TRANSFORM(RECNO())+'].suma_doc_val=0', suma_doc_val, 0)
		CASE tip_rand == 'T'
			lnCntT2001 = lnCntT2001 + 1
			=Assert3('2001.T['+TRANSFORM(RECNO())+'].in_valuta=0', in_valuta, 0)
			=Assert3('2001.T['+TRANSFORM(RECNO())+'].id_valuta=0', id_valuta, 0)
			=AssertStr('2001.T['+TRANSFORM(RECNO())+'].nume_val=""', ALLTRIM(NVL(nume_val,'?')), '')
			=Assert3('2001.T['+TRANSFORM(RECNO())+'].curs=0', curs, 0)
			=Assert3('2001.T['+TRANSFORM(RECNO())+'].suma_val=0', suma_val, 0)
			=Assert3('2001.T['+TRANSFORM(RECNO())+'].suma_doc_val=0', suma_doc_val, 0)
		ENDCASE
	ENDSCAN
	=Assert3('2001: cel putin un rand B/S dupa sync', IIF(lnCntBS2001>0,1,0), 1)
	=Assert3('2001: cel putin un rand T dupa sync', IIF(lnCntT2001>0,1,0), 1)
	=Assert3('2001: total suma randuri B/S = 1000 (baza neschimbata)', lnSumaLei2001, 1000)
	DO UILog WITH 'PAS1: doc 2001 dupa sync - ' + TRANSFORM(lnCntBS2001) + ' rand(uri) B/S, ' + TRANSFORM(lnCntT2001) + ' rand(uri) T'

	goObj.cmesajsync = ''
	LOCAL llOk1
	llOk1 = goObj.valideaza_sume()
	=Assert3('PAS1 valideaza_sume()=.T.', IIF(llOk1,1,0), 1)
	=AssertStr('PAS1 cmesajsync gol', ALLTRIM(NVL(goObj.cmesajsync,'?')), '')
	IF !EMPTY(NVL(goObj.cmesajsync,''))
		DO UILog WITH 'PAS1 cmesajsync=[' + goObj.cmesajsync + ']'
	ENDIF

	lnP1 = pnPass
	lnA1 = pnAsserts
	DO UILog WITH 'PAS1 REZULTAT: ' + TRANSFORM(lnP1) + '/' + TRANSFORM(lnA1) + ' assert-uri PASS'
	DO HarnessStep WITH 1, 'debifare: ' + TRANSFORM(lnP1) + '/' + TRANSFORM(lnA1) + ' PASS'

	*========================= PAS 2: RE-BIFARE (Check1.Value=1 + Valid()) pe randul B/S doc 2001 =========================
	STORE 0 TO pnAsserts, pnPass

	SELECT introdc
	LOCATE FOR nract == 2001 AND INLIST(tip_rand,'B','S')
	=Assert3('PAS2: rand B/S doc 2001 gasit (Found) inainte de re-bifare', IIF(FOUND(),1,0), 1)
	IF FOUND()
		goObj.grid1.cInValuta.check1.Value = 1
		goObj.grid1.cInValuta.check1.Valid()
		DOEVENTS FORCE
	ELSE
		DO UILog WITH 'PAS2: ABANDONAT - nu exista rand B/S pe doc 2001 (stare neasteptata dupa PAS1)'
	ENDIF

	*-- propagare neconditionata a in_valuta pe TOATE randurile doc 2001; campurile de valuta
	*-- raman goale (nu se restaureaza - doar Value=0 le goleste explicit, Value=1 nu le reface)
	LOCAL lnCntRande2001b
	lnCntRande2001b = 0
	SELECT introdc
	SCAN FOR nract == 2001 AND INLIST(tip_rand,'B','S','T')
		lnCntRande2001b = lnCntRande2001b + 1
		=Assert3('2001.'+tip_rand+'['+TRANSFORM(RECNO())+'].in_valuta=1 (re-bifare)', in_valuta, 1)
		=AssertStr('2001.'+tip_rand+'['+TRANSFORM(RECNO())+'].nume_val ramas ""', ALLTRIM(NVL(nume_val,'?')), '')
		=Assert3('2001.'+tip_rand+'['+TRANSFORM(RECNO())+'].id_valuta ramas 0', id_valuta, 0)
		=Assert3('2001.'+tip_rand+'['+TRANSFORM(RECNO())+'].curs ramas 0', curs, 0)
	ENDSCAN
	=Assert3('2001: cel putin un rand verificat la re-bifare', IIF(lnCntRande2001b>0,1,0), 1)

	DO UILog WITH 'PAS2 REZULTAT: ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' assert-uri PASS'
	DO HarnessStep WITH 2, 're-bifare: ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' PASS'

	LOCAL lnP2, lnA2
	lnP2 = pnPass
	lnA2 = pnAsserts

	*========================= PAS 3: debifare pe document secundar spart pe conturi (S/T, doc 101, nemanual) =========================
	STORE 0 TO pnAsserts, pnPass

	SELECT introdc
	LOCATE FOR nract == 101 AND tip_rand == 'S'
	=Assert3('PAS3: rand S doc 101 gasit (Found)', IIF(FOUND(),1,0), 1)
	IF FOUND()
		DO UILog WITH 'PAS3: pozitionat pe randul S (nract=101), in_valuta INAINTE=' + TRANSFORM(introdc.in_valuta)

		goObj.grid1.cInValuta.check1.Value = 0
		goObj.grid1.cInValuta.check1.Valid()
		DOEVENTS FORCE
		DO DumpIntrodc WITH 'dupa PAS3 sync'
	ELSE
		DO UILog WITH 'PAS3: ABANDONAT - nu exista rand S pe doc 101'
	ENDIF

	*-- randul cu contul de marfa (371) al doc 101, indiferent daca a ramas S sau a fost
	*-- rescris de sync (spargere/unire legitima) - esenta testata e golirea valutei
	LOCAL lnSuma101
	lnSuma101 = 0
	SELECT introdc
	SCAN FOR nract == 101 AND ALLTRIM(scd) == '371' AND INLIST(tip_rand,'B','S')
		lnSuma101 = lnSuma101 + suma
		=Assert3('101.'+tip_rand+'(371).in_valuta=0', in_valuta, 0)
		=Assert3('101.'+tip_rand+'(371).suma_val=0', suma_val, 0)
		=Assert3('101.'+tip_rand+'(371).suma_doc_val=0', suma_doc_val, 0)
		=Assert3('101.'+tip_rand+'(371).curs=0', curs, 0)
	ENDSCAN
	=Assert3('101: suma totala cont 371 neschimbata(450)', lnSuma101, 450)

	SELECT introdc
	LOCATE FOR nract == 101 AND ALLTRIM(scd) == '4426' AND tip_rand == 'T'
	IF FOUND()
		=Assert3('101.T(4426).in_valuta=0', introdc.in_valuta, 0)
		=Assert3('101.T(4426).suma_val=0', introdc.suma_val, 0)
		=Assert3('101.T(4426).suma_doc_val=0', introdc.suma_doc_val, 0)
		=Assert3('101.T(4426).curs=0', introdc.curs, 0)
	ELSE
		DO UILog WITH 'PAS3: ATENTIE, nu exista rand T(4426) pt nract=101 dupa sync'
	ENDIF

	goObj.cmesajsync = ''
	LOCAL llOk3
	llOk3 = goObj.valideaza_sume()
	=Assert3('valideaza_sume()=.T.', IIF(llOk3,1,0), 1)
	=AssertStr('cmesajsync gol (fara fals NESINCRONIZAT)', ALLTRIM(NVL(goObj.cmesajsync,'?')), '')
	IF !EMPTY(NVL(goObj.cmesajsync,''))
		DO UILog WITH 'PAS3 cmesajsync=[' + goObj.cmesajsync + ']'
	ENDIF

	DO UILog WITH 'PAS3 REZULTAT: ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' assert-uri PASS'
	DO HarnessStep WITH 3, 'valideaza_sume doc spart: ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' PASS'

	LOCAL lnP3, lnA3
	lnP3 = pnPass
	lnA3 = pnAsserts

	*========================= PAS 4: schimbare curs (Grid1.cCurs.Text1.Valid) pe doc 102 (secundar, manual) =========================
	STORE 0 TO pnAsserts, pnPass

	SELECT introdc
	LOCATE FOR nract == 102 AND tip_rand == 'S'
	=Assert3('PAS4: rand S doc 102 gasit (Found)', IIF(FOUND(),1,0), 1)
	IF FOUND()
		DO UILog WITH 'PAS4: pozitionat pe randul S (nract=102), curs INAINTE=' + TRANSFORM(introdc.curs)

		goObj.grid1.cCurs.text1.Value = 4.00
		goObj.grid1.cCurs.text1.Valid()

		*-- runda8: cCurs.Valid armeaza acum sincronizarea amanata (lSyncPending+tmrSync) in loc
		*-- sa faca doar do_executa - imediat dupa Valid, INAINTE de DOEVENTS: doar armata
		=Assert3('PAS4 armare: lSyncPending=.T. dupa Valid curs (pre-DOEVENTS)', IIF(goObj.lSyncPending,1,0), 1)
		=Assert3('PAS4 armare: tmrSync.Interval>0 dupa Valid curs (pre-DOEVENTS)', IIF(goObj.tmrSync.Interval>0,1,0), 1)

		DOEVENTS FORCE

		=Assert3('PAS4 sync consumat: lSyncPending=.F. dupa DOEVENTS', IIF(goObj.lSyncPending,1,0), 0)
		=Assert3('PAS4 sync consumat: tmrSync.Interval=0 dupa DOEVENTS', goObj.tmrSync.Interval, 0)
	ELSE
		DO UILog WITH 'PAS4: ABANDONAT - nu exista rand S pe doc 102'
	ENDIF

	SELECT introdc
	LOCATE FOR nract == 102 AND ALLTRIM(scd) == '371' AND tip_rand == 'S'
	IF FOUND()
		=Assert3('S102.curs=4', introdc.curs, 4)
		=Assert3('S102.suma=2000 (recalculat)', introdc.suma, 2000)
		=Assert3('S102.suma_val neschimbat(500)', introdc.suma_val, 500)
		=Assert3('S102.suma_doc=2000', introdc.suma_doc, 2000)
		=Assert3('S102.suma_doc_val=500', introdc.suma_doc_val, 500)
	ELSE
		DO UILog WITH 'PAS4: ATENTIE, nu exista rand S(371) pt nract=102 dupa sync (asteptat neschimbat - mod_manual=1)'
		=Assert3('S102 gasit dupa sync (mod_manual=1, sparge_document nu ar trebui sa-l atinga)', 0, 1)
	ENDIF

	SELECT introdc
	LOCATE FOR nract == 102 AND ALLTRIM(scd) == '4426' AND tip_rand == 'T'
	IF FOUND()
		=Assert3('T102.curs=4 (propagat)', introdc.curs, 4)
		=Assert3('T102.suma=420', introdc.suma, 420)
		=Assert3('T102.suma_val neschimbat(105)', introdc.suma_val, 105)
		=Assert3('T102.suma_doc=2000', introdc.suma_doc, 2000)
		=Assert3('T102.suma_doc_val=500', introdc.suma_doc_val, 500)
	ELSE
		DO UILog WITH 'PAS4: ATENTIE, nu exista rand T(4426) pt nract=102 dupa sync'
	ENDIF

	goObj.cmesajsync = ''
	LOCAL llOk4
	llOk4 = goObj.valideaza_sume()
	=Assert3('valideaza_sume()=.T. (PAS4)', IIF(llOk4,1,0), 1)
	=AssertStr('cmesajsync gol (PAS4)', ALLTRIM(NVL(goObj.cmesajsync,'?')), '')
	IF !EMPTY(NVL(goObj.cmesajsync,''))
		DO UILog WITH 'PAS4 cmesajsync=[' + goObj.cmesajsync + ']'
	ENDIF

	DO UILog WITH 'PAS4 REZULTAT: ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' assert-uri PASS'
	DO HarnessStep WITH 4, 'recalc curs doc spart: ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' PASS'

	LOCAL lnP4, lnA4
	lnP4 = pnPass
	lnA4 = pnAsserts

	*========================= PAS 5 (NOU, R4): debifare cParticipaValuta pe doc 102 (S, manual) =========================
	STORE 0 TO pnAsserts, pnPass

	SELECT introdc
	LOCATE FOR nract == 102 AND ALLTRIM(scd) == '371' AND tip_rand == 'S'
	=Assert3('PAS5: rand S doc 102 gasit (Found)', IIF(FOUND(),1,0), 1)
	IF FOUND()
		DO UILog WITH 'PAS5: pozitionat pe randul S (nract=102), participa_valuta INAINTE=' + TRANSFORM(introdc.participa_valuta)

		goObj.grid1.cParticipaValuta.check1.Value = 0
		goObj.grid1.cParticipaValuta.check1.Valid()

		*-- imediat dupa Valid, INAINTE de DOEVENTS: sincronizarea trebuie doar armata
		=Assert3('PAS5 armare: lSyncPending=.T. dupa Valid (pre-DOEVENTS)', IIF(goObj.lSyncPending,1,0), 1)
		=Assert3('PAS5 armare: tmrSync.Interval>0 dupa Valid (pre-DOEVENTS)', IIF(goObj.tmrSync.Interval>0,1,0), 1)

		DOEVENTS FORCE

		*-- dupa DOEVENTS FORCE: sincronizarea trebuie sa fi rulat (armare consumata)
		=Assert3('PAS5 sync consumat: lSyncPending=.F. dupa DOEVENTS', IIF(goObj.lSyncPending,1,0), 0)
		=Assert3('PAS5 sync consumat: tmrSync.Interval=0 dupa DOEVENTS', goObj.tmrSync.Interval, 0)

		goObj.cmesajsync = ''
		LOCAL llOk5
		llOk5 = goObj.valideaza_sume()
		=Assert3('PAS5 valideaza_sume()=.T. dupa sync', IIF(llOk5,1,0), 1)
		=AssertStr('PAS5 cmesajsync gol', ALLTRIM(NVL(goObj.cmesajsync,'?')), '')
		IF !EMPTY(NVL(goObj.cmesajsync,''))
			DO UILog WITH 'PAS5 cmesajsync=[' + goObj.cmesajsync + ']'
		ENDIF
	ELSE
		DO UILog WITH 'PAS5: ABANDONAT - nu exista rand S(371) pe doc 102'
	ENDIF

	DO UILog WITH 'PAS5 REZULTAT: ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' assert-uri PASS'
	DO HarnessStep WITH 5, 'debifare participa_valuta (armare+sync): ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' PASS'

	LOCAL lnP5, lnA5
	lnP5 = pnPass
	lnA5 = pnAsserts

	IF lnP1 = lnA1 AND lnP2 = lnA2 AND lnP3 = lnA3 AND lnP4 = lnA4 AND lnP5 = lnA5
		DO UILog WITH 'VERDICT FINAL: PASS (toate assert-urile au trecut, ' + TRANSFORM(lnP1+lnP2+lnP3+lnP4+lnP5) + '/' + TRANSFORM(lnA1+lnA2+lnA3+lnA4+lnA5) + ')'
	ELSE
		DO UILog WITH 'VERDICT FINAL: FAIL (' + TRANSFORM(lnP1+lnP2+lnP3+lnP4+lnP5) + '/' + TRANSFORM(lnA1+lnA2+lnA3+lnA4+lnA5) + ' assert-uri PASS)'
	ENDIF

	DO UILog WITH 'GATA - toate pasii executati'
	DO HarnessDone WITH 'done'

CATCH TO loExc
	DO UILog 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 Assert3
	*-- compara numeric cu toleranta 0.01, logheaza PASS/FAIL, incrementeaza contoare (byref)
	LPARAMETERS tcLabel, tuActual, tuExpected
	pnAsserts = pnAsserts + 1
	IF ABS(NVL(tuActual,0) - tuExpected) < 0.01
		pnPass = pnPass + 1
		DO UILog WITH '  PASS ' + tcLabel + ' (=' + TRANSFORM(tuActual) + ')'
	ELSE
		DO UILog 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 UILog WITH '  PASS ' + tcLabel + ' (=[' + tcActual + '])'
	ELSE
		DO UILog WITH '  FAIL ' + tcLabel + ' (actual=[' + tcActual + '] asteptat=[' + tcExpected + '])'
	ENDIF
ENDPROC

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

PROCEDURE DumpIntrodc
	LPARAMETERS tcEticheta
	LOCAL lcSel
	lcSel = SELECT()
	SELECT introdc
	DO UILog WITH '--- DUMP introdc [' + tcEticheta + '] (' + TRANSFORM(RECCOUNT()) + ' randuri) ---'
	SCAN
		DO UILog WITH '  rec=' + TRANSFORM(RECNO()) + ' nract=' + TRANSFORM(nract) + ' nr_doc=' + TRANSFORM(nr_doc) + ' tip=' + tip_rand + ' scd=' + ALLTRIM(scd) + ' suma=' + TRANSFORM(suma) + ' suma_val=' + TRANSFORM(suma_val) + ' in_valuta=' + TRANSFORM(in_valuta) + ' mod_manual=' + TRANSFORM(mod_manual) + ' doc_key=[' + ALLTRIM(doc_key) + ']'
	ENDSCAN
	SELECT (lcSel)
ENDPROC

PROCEDURE UILog
	LPARAMETERS tcMsg
	LOCAL lcL
	lcL = 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 'VPLCONT_ANALITIC' $ UPPER(m.tcSql)
			CREATE CURSOR (m.tcCursor) (cont C(10), acont C(20))
			INSERT INTO (m.tcCursor) VALUES ('371', '01')
			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 (m.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. 21%', 1, 0, 'RO21B', 21, 209, 1, 1, 301104)
ENDPROC
