sync SVN r18057

This commit is contained in:
2026-08-24 19:28:22 +03:00
parent 5d60d96d50
commit c6e401c408
11 changed files with 475 additions and 755 deletions

View File

@@ -0,0 +1,196 @@
* test_chk_amort_introducere.prg
* Test headless pentru "bifa amortizare maxim deductibila la introducere imobilizare
* corporala" (frm_introducere din Clase\oimobilizari.vc2).
*
* Verifica:
* 1) formularul frm_introducere se instantiaza fara eroare (obiectul chk_amort_max_deductibil
* e adaugat corect, metoda .Valid se leaga)
* 2) la introducere noua (tnTipModificare=1): bifa NEACTIVA, campul read-only, valoarea NULL
* (toata amortizarea deductibila)
* 3) activarea bifei -> campul devine editabil, valoarea 0; dezactivarea -> NULL din nou
* 4) expresia de salvare pcAmortMaxDeductibil -> 'NULL' la debifat / valoarea la bifat
*
* Rulare: vfp9.exe -A -T "test_chk_amort_introducere.prg"
* (DO test_init_env_auto_roaimob din acelasi folder, cu DSN CENTRAL / schema MARIUSM_AUTO)
* Verdict in test_chk_amort_introducere_log.txt (langa acest fisier).
SET SAFETY OFF
SET TALK OFF
SET DELETED ON
SET EXACT ON
SET CENTURY ON
SET DATE DMY
SET NULLDISPLAY TO ''
CLOSE DATABASES
PUBLIC gcUILog
gcUILog = "D:\ROA\ROAIMOB\teste\test_chk_amort_introducere_log.txt"
STRTOFILE("START " + TTOC(DATETIME()) + CHR(13)+CHR(10), gcUILog)
ON ERROR DO PrErrLocal WITH ERROR(), MESSAGE(), PROGRAM(), LINENO()
ON SHUTDOWN QUIT
TRY
DO "D:\ROA\ROAIMOB\teste\test_init_env_auto_roaimob.prg" WITH 'CENTRAL', 'MARIUSM_AUTO', 'ROMFASTSOFT'
IF gnHandle <= 0
DO PrLogLocal WITH 'FAIL: conectare Oracle esuata (gnHandle=' + TRANSFORM(gnHandle) + ')'
QUIT
ENDIF
DO PrLogLocal WITH 'mediu ROAIMOB initializat'
*-- variabile globale de care depinde formularul
PUBLIC gnPa, gnPC
gnPa = 2
gnPC = 2
gnIdSucursala = gnIdFirma
*-- cursorii pe care ii folosesc combobox-urile formularului (v_tipuri_amort, v_tipuri_imob, cote_TVA)
IF USED('v_tipuri_amort')
USE IN v_tipuri_amort
ENDIF
CREATE CURSOR v_tipuri_amort (denumire C(30), id_tip_amortizare N(4))
INSERT INTO v_tipuri_amort (denumire, id_tip_amortizare) VALUES ('LINIARA', 1)
INSERT INTO v_tipuri_amort (denumire, id_tip_amortizare) VALUES ('ACCELERATA', 2)
IF USED('v_tipuri_imob')
USE IN v_tipuri_imob
ENDIF
CREATE CURSOR v_tipuri_imob (denumire C(30), id_tip_imobilizare N(4))
INSERT INTO v_tipuri_imob (denumire, id_tip_imobilizare) VALUES ('CORPORALA', 1)
IF USED('cote_TVA')
USE IN cote_TVA
ENDIF
CREATE CURSOR cote_TVA (procent N(6,2), descriere C(40), id_proc_tva N(4), proc_tva N(6,2))
INSERT INTO cote_TVA (procent, descriere, id_proc_tva, proc_tva) VALUES (1.19, 'standard', 1, 1.19)
*-- stub poGeneratorNumere pentru apelul poGeneratorNumere.aloca_numar din Init (tnTipModificare=1)
PUBLIC poGeneratorNumere
poGeneratorNumere = CREATEOBJECT('stub_generator')
*-- poMF trebuie sa existe ca variabila (formularul il foloseste in metode)
PUBLIC poMF
poMF = CREATEOBJECT('custom')
DO PrLogLocal WITH 'cursori + stubs pregatite'
*-- instantiez formularul real (introducere imobilizare CORPORALA = tnTip 1, modificare 1)
LOCAL ofrm
ofrm = CREATEOBJECT('frm_intro_test', 1, 1)
DO PrLogLocal WITH 'frm_introducere instantiat OK'
DO PrLogLocal WITH 'chk exista: ' + TRANSFORM(PEMSTATUS(ofrm, 'chk_amort_max_deductibil', 5))
*-- 1) stare initiala la introducere noua (INANTE de orice modificare)
LOCAL lcStare1
lcStare1 = 'bifa=' + TRANSFORM(ofrm.chk_amort_max_deductibil.Value) + ;
' readonly=' + TRANSFORM(ofrm.clb_amort_max_deductibil.text_simplu1.ReadOnly) + ;
' valoare=[' + TRANSFORM(ofrm.clb_amort_max_deductibil.text_simplu1.Value) + ']'
DO PrLogLocal WITH 'stare initiala: ' + lcStare1
*-- stare initiala trebuie sa fie: bifa .F., readonly .T., valoare NULL
LOCAL llBifaNeactiva, llReadOnly, llNull, llOk
llBifaNeactiva = (ofrm.chk_amort_max_deductibil.Value = .F.)
llReadOnly = (ofrm.clb_amort_max_deductibil.text_simplu1.ReadOnly = .T.)
llNull = ISNULL(ofrm.clb_amort_max_deductibil.text_simplu1.Value)
llOk = (m.llBifaNeactiva AND m.llReadOnly AND m.llNull)
IF m.llOk
DO PrLogLocal WITH 'PASS: stare initiala corecta (bifa neactiva, camp read-only, valoare NULL = toata amortizarea deductibila)'
ELSE
DO PrLogLocal WITH 'FAIL: stare initiala incorecta (bifa=' + TRANSFORM(m.llBifaNeactiva) + ;
' readonly=' + TRANSFORM(m.llReadOnly) + ' null=' + TRANSFORM(m.llNull) + ')'
ENDIF
*-- 2) activez bifa -> camp editabil, valoare 0
ofrm.chk_amort_max_deductibil.Value = .T.
ofrm.chk_amort_max_deductibil.Valid()
LOCAL llToggleOk
llToggleOk = (ofrm.clb_amort_max_deductibil.text_simplu1.ReadOnly = .F.) ;
AND (ofrm.clb_amort_max_deductibil.text_simplu1.Value = 0)
DO PrLogLocal WITH 'dupa activare bifa: readonly=' + TRANSFORM(ofrm.clb_amort_max_deductibil.text_simplu1.ReadOnly) + ;
' valoare=[' + TRANSFORM(ofrm.clb_amort_max_deductibil.text_simplu1.Value) + ']'
IF m.llToggleOk
DO PrLogLocal WITH 'PASS: activarea bifei face campul editabil cu valoare 0'
ELSE
DO PrLogLocal WITH 'FAIL: activarea bifei nu a activat campul corect'
m.llOk = .F.
ENDIF
*-- 3) dezactivez bifa -> NULL din nou, camp read-only
ofrm.chk_amort_max_deductibil.Value = .F.
ofrm.chk_amort_max_deductibil.Valid()
LOCAL llDezOk
llDezOk = (ofrm.clb_amort_max_deductibil.text_simplu1.ReadOnly = .T.) ;
AND ISNULL(ofrm.clb_amort_max_deductibil.text_simplu1.Value)
DO PrLogLocal WITH 'dupa dezactivare bifa: readonly=' + TRANSFORM(ofrm.clb_amort_max_deductibil.text_simplu1.ReadOnly) + ;
' valoare=[' + TRANSFORM(ofrm.clb_amort_max_deductibil.text_simplu1.Value) + ']'
IF m.llDezOk
DO PrLogLocal WITH 'PASS: dezactivarea bifei revine la NULL + read-only'
ELSE
DO PrLogLocal WITH 'FAIL: dezactivarea bifei nu a revenit la NULL'
m.llOk = .F.
ENDIF
*-- 4) expresia de salvare pcAmortMaxDeductibil
LOCAL pcAmortMaxDeductibil, pnAmortMaxDeductibil, lcSaveNull, lcSaveVal
ofrm.chk_amort_max_deductibil.Value = .F.
ofrm.chk_amort_max_deductibil.Valid()
pnAmortMaxDeductibil = ofrm.clb_amort_max_deductibil.text_simplu1.Value
pcAmortMaxDeductibil = IIF(ISNULL(m.pnAmortMaxDeductibil), 'NULL', ALLTRIM(STR(m.pnAmortMaxDeductibil, 14, gnPC)))
lcSaveNull = m.pcAmortMaxDeductibil
DO PrLogLocal WITH 'pcAmortMaxDeductibil (debifat) = [' + lcSaveNull + ']'
ofrm.chk_amort_max_deductibil.Value = .T.
ofrm.chk_amort_max_deductibil.Valid()
ofrm.clb_amort_max_deductibil.text_simplu1.Value = 1500
pnAmortMaxDeductibil = ofrm.clb_amort_max_deductibil.text_simplu1.Value
pcAmortMaxDeductibil = IIF(ISNULL(m.pnAmortMaxDeductibil), 'NULL', ALLTRIM(STR(m.pnAmortMaxDeductibil, 14, gnPC)))
lcSaveVal = m.pcAmortMaxDeductibil
DO PrLogLocal WITH 'pcAmortMaxDeductibil (bifat=1500) = [' + lcSaveVal + ']'
LOCAL llSaveOk
llSaveOk = (m.lcSaveNull == 'NULL') AND (VAL(m.lcSaveVal) = 1500)
IF m.llSaveOk
DO PrLogLocal WITH 'PASS: pcAmortMaxDeductibil corect (NULL la debifat, valoare la bifat)'
ELSE
DO PrLogLocal WITH 'FAIL: pcAmortMaxDeductibil incorect (debifat=[' + m.lcSaveNull + '] bifat=[' + m.lcSaveVal + '])'
m.llOk = .F.
ENDIF
DO PrLogLocal WITH 'VERDICT: ' + IIF(m.llOk, 'PASS', 'FAIL')
DO PrLogLocal WITH 'GATA'
CATCH TO loExcMain
DO PrLogLocal WITH 'CATCH ErrorNo=' + TRANSFORM(loExcMain.ErrorNo) + ' Message=' + loExcMain.Message + ;
' Proc=' + loExcMain.Procedure + ' Line=' + TRANSFORM(loExcMain.LineNo) + ' [' + loExcMain.LineContents + ']'
ENDTRY
QUIT
PROCEDURE PrErrLocal
LPARAMETERS tnErr, tcMsg, tcProg, tnLine
DO PrLogLocal WITH 'ON ERROR ' + TRANSFORM(tnErr) + ' [' + tcProg + ':' + TRANSFORM(tnLine) + '] ' + tcMsg
ENDPROC
PROCEDURE PrLogLocal
LPARAMETERS tcMsg
SET SAFETY OFF
LOCAL lcL
lcL = IIF(FILE(gcUILog), FILETOSTR(gcUILog), '')
STRTOFILE(lcL + tcMsg + CHR(13)+CHR(10), gcUILog)
ENDPROC
* DEFINE CLASS la finalul fisierului (capcana: DEFINE CLASS nu poate sta la mijloc)
DEFINE CLASS stub_generator AS custom
PROCEDURE aloca_numar
LPARAMETERS tnTipDoc, tnTip
RETURN 1
ENDPROC
PROCEDURE ResetAll
ENDPROC
ENDDEFINE
DEFINE CLASS frm_intro_test AS frm_introducere
PROCEDURE Load
* suprascriu Load-ul parinte (_frm_base), care ar deschide o fereastra de atentionare
* daca cselect/ccursor sunt goale
ENDPROC
ENDDEFINE

View File

@@ -0,0 +1,239 @@
* test_init_env_auto_roaimob.prg
* Varianta ROAIMOB a test_init_env_auto.prg (COMUN\utile\Teste): acesta seteaza gcAppPath fix pe
* D:\ROA\ROACONT\ (harness scris pentru ROACONT), deci nu poate testa cod din COMUN\ asa cum e
* editat in checkout-ul ROAIMOB (fiecare aplicatie are propriul working copy SVN al COMUN\).
* Identic altfel, minus class libs/proceduri specifice ROACONT (contabilitate) care nu exista sub
* ROAIMOB\COMUN sau ROAIMOB\Clase, si cu adaugarea celor specifice ROAIMOB (oimobilizari.vcx,
* ofundal_imob, serii_numere, onom_imob, oproceduri_imob, oproceduri_operatii, ofunctii_imob,
* oproceduri_listari, proceduri_meniu, sitan).
*
* Utilizare: DO test_init_env_auto_roaimob WITH 'CENTRAL', 'MARIUSM_AUTO', 'parola'
* ATENTIE: mentine sincronizat cu test_init_env_auto.prg pentru partea comuna si cu
* Programe\roaimob.prg pentru wiring-ul specific aplicatiei (SET PATH/CLASSLIB/PROCEDURE).
LPARAMETERS tcHost, tcSchema, tcPassword, tnAn, tnLuna
tcHost = IIF(EMPTY(tcHost), 'CENTRAL', tcHost)
tcSchema = IIF(EMPTY(tcSchema), 'MARIUSM_AUTO', tcSchema)
tcPassword = IIF(EMPTY(tcPassword), 'ROMFASTSOFT', tcPassword)
SET DELETED ON
SET ANSI ON
SET EXACT ON
SET SAFETY OFF
CLOSE DATABASES
SET CENTURY ON
SET DATE DMY
SET NULLDISPLAY TO ''
PUBLIC CT_SUCCES, CT_INSUCCES, crlf, gnAn, gnLuna, gnIdUtil, glEMama, gnIdFirma, gcCondSucursala, ;
gnIdSucursala, gcS, gcFirma, gcUserName, gcNumeProgram, gcAppName, glLunaInchisa, ;
buton, gnButon, pnButon, gl406, gcAcces
CT_SUCCES = 1
CT_INSUCCES = -1
crlf = CHR(13) + CHR(10)
gnAn = IIF(EMPTY(tnAn), YEAR(DATE()), tnAn)
gnLuna = IIF(EMPTY(tnLuna), MONTH(DATE()), tnLuna)
gnIdUtil = -3
gnIdFirma = 110
gcCondSucursala = []
gnIdSucursala = m.gnIdFirma
gcS = UPPER(ALLTRIM(tcSchema))
gcFirma = m.gcS
gcUserName = m.gcS
gcNumeProgram = [ROAIMOB]
gcAppName = [ROAIMOB]
glLunaInchisa = .F.
glEMama = .F.
gl406 = .F.
PUBLIC nror(65000)
buton = 1
gnButon = 1
pnButon = 1
LOCAL lcPath
PUBLIC gcAppPath, DIRGEN, gcBasePath, gcTempPath, gcGeneralIniFile, gcSettingsFile
gcAppPath = [D:\ROA\ROAIMOB\]
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
Set Classlib To appwiz Additive
Set Classlib To CAUT Additive
Set Classlib To BAZA Additive
Set Classlib To comun Additive
Set Classlib To oimobilizari.vcx Additive
Set Classlib To registry Additive
Set Classlib To cauta_alfa_forms Additive
Set Classlib To caut_ora Additive
Set Classlib To ofundal_imob Additive
Set Classlib To serii_numere Additive
Set Procedure To proceduri_comune Additive
Set Procedure To sitan Additive
Set Procedure To quitapp Additive
Set Procedure To init_program Additive
Set Procedure To oproceduri_listari Additive
Set Procedure To proceduri_meniu Additive
Set Procedure To oserii_numere Additive
Set Procedure To regex Additive
Set Classlib To DECABAZA Additive
Set Classlib To onomenclatoare Additive
Set Classlib To ferestre_oracle Additive
Set Classlib To onom_imob Additive
Set Classlib To otoolbar Additive
Set Classlib To ocriterii Additive
Set Classlib To MESSAGEBOX Additive
SET CLASSLIB TO wwdialogs.vcx additive
SET CLASSLIB TO serii_numere.vcx additive
SET CLASSLIB TO accessibility.vcx additive
SET CLASSLIB TO locale additive
Set Procedure To gencursor.prg Additive
Set Procedure To oproceduri_comune.prg Additive
Set Procedure To oproceduri_imob.prg Additive
Set Procedure To oproceduri_operatii.prg Additive
Set Procedure To ofunctii_imob.prg Additive
Set Procedure To oinit_optiuni.prg Additive
Set Procedure To update_imob.prg Additive
Set Procedure To updateserver.prg Additive
Set Procedure To oproceduri_ams.prg Additive
Set Procedure To ocautare.prg Additive
Set Procedure To osecurity.prg Additive
Set Procedure To acces_meniu.prg Additive
Set Procedure To oheader.prg Additive
Set Procedure To oproceduri_comune_imob.prg Additive
Set Procedure To cauta_alfa.prg Additive
Set Procedure To oexport.prg Additive
Set Procedure To validare.prg 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 wwxmlhttp.prg ADDITIVE
Set Procedure To ini.prg ADDITIVE
Set Procedure To wwconfig.prg ADDITIVE
Set Procedure To excelxml.prg ADDITIVE
Set Procedure To wwutils.PRG Additive
Set Procedure To wwapi.PRG Additive
Declare Integer GetPrivateProfileString In WIN32API ;
string, String, String, String @, Integer, String
Declare Integer WritePrivateProfileString In Win32Api ;
string, String, String, String
Declare Integer CopyFile In WIN32API ;
STRING lpExistingFileName, STRING lpNewFileName, INTEGER bFailIfExists
Declare Integer PathFileExists In shlwapi STRING pszPath
If Type('goApi') = 'U'
Public goApi
goApi = Newobject("wwAPI", "wwAPI.prg")
ENDIF
set procedure to oinit_optiuni.prg additive
set procedure to oproceduri_comune.prg additive
PUBLIC gnHandle, goExecutor, goConn, goFirma, goCalendar, poLog, goLog, goApp
DIRGEN = [D:\ROA\]
gcBasePath = dirgen
gcGeneralIniFile = DIRGEN + "settings.ini"
gcSettingsFile = m.gcGeneralIniFile
gcTempPath = Addbs(shortpath(goApi.GetTempPath())) + gcS + [\]
If !Directory(gcTempPath)
Md (gcTempPath)
Endif
gcAcces = [1;2;3;4;5;6;7;8;]
poLog = Newobject("Log_Mesaje","Log_Mesaje.prg")
goLog = poLog
goApp = Createobject("wzApplication")
gnHandle = 0
goExecutor = createobject("oExecutor")
goConn = createobject("oConn")
goConn.Connect(m.tcHost, m.tcSchema, m.tcPassword)
IF m.gnHandle <= 0
RETURN .F.
ENDIF
LOCAL llSucces, lcSql
goFirma = null
llSucces = goExecutor.oExecuta("select * from syn_v_nom_firme where schema = ?gcS", "cFirma")
IF m.llSucces
SELECT cFirma
gnIdFirma = id_firma
gnIdSucursala = null
gcFirma = ALLTRIM(firma)
SCATTER NAME goFirma
IF TYPE('goFirma.codfiscalfro') = 'U'
ADDPROPERTY(goFirma, 'codfiscalfro', ALLTRIM(STRTRAN(ALLTRIM(NVL(goFirma.cod_fiscal, '')), 'RO', '')))
ENDIF
ELSE
goFirma = CREATEOBJECT('custom')
goFirma.addproperty('cod_fiscal', '')
goFirma.addproperty('schema', m.gcS)
goFirma.addproperty('firma', m.gcS)
goFirma.addproperty('codfiscalfro', '')
ENDIF
USE IN (SELECT('cFirma'))
goCalendar = null
llSucces = goExecutor.oExecuta('SELECT anul, luna, tva_incasare FROM calendar WHERE an*12+luna = (select MAX(an*12+luna) FROM calendar)', 'cCalendar')
IF m.llSucces
SELECT cCalendar
GO TOP
IF EMPTY(m.tnAn)
gnAn = anul
gnLuna = luna
ENDIF
SCATTER NAME goCalendar
ENDIF
USE IN (SELECT('cCalendar'))
CREATE CURSOR dual (dummy c(10))
INSERT INTO dual (dummy) VALUES ("")
actualizeaza_optiuni()
Do optiuni_firma IN oinit_optiuni.prg
lcSql = [begin pack_sesiune.set_Id_Util(?gnIdUtil); end;]
llSucces = goExecutor.oExecuta(lcSql)
lcSql = [begin pack_sesiune.setluna(?gnLuna); pack_sesiune.setan(?gnAn); end;]
llSucces = goExecutor.oExecuta(lcSql)
lcSql = [begin pack_sesiune.setlunabal(?gnLuna); pack_sesiune.setanbal(?gnAn); end;]
llSucces = goExecutor.oExecuta(lcSql)
lcSql = [begin pack_sesiune.set_data_ron(?gcS); end;]
llSucces = goExecutor.oExecuta(lcSql)
lcSql = [begin pack_contafin.set_id_sucursala(?gnIdSucursala); end;]
llSucces = goExecutor.oExecuta(lcSql)
lcSql = [begin pack_contafin.set_id_firma(?gnIdFirma); end;]
llSucces = goExecutor.oExecuta(lcSql)
RETURN .T.