#13: formular de facturare unificat - etapa curenta
Squash al branch-ului de lucru plan13-s2. Clase: ofacturare (nucleul formularului unificat), ofacturare_comun, ferestre_cere_date, ocomenzi, caut_ora (lista de preturi in combo-urile de cautare), omodificari. Programe: ofacturare impartit - ofacturare_antet, ofacturare_rutare_scriere si ogrid_latimi sunt fisiere noi; oproceduri_facturare primeste discountul pe linie si cota standard de TVA cand articolul nu are cota pe politica. Documentatie: capcana SQLExec no_data_found, conventia de encoding, depanarea testelor VFP si regulile de lucru - conflictele cu modificarile venite din alte proiecte sunt rezolvate pastrand ambele parti. Loguri de rulare a testelor scoase din versionare; testele raman. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PkyjGyrV2S7932om4kfSiK
This commit is contained in:
305
utile/Teste/facturare_unificat/test_s5c_semnal_proforma.prg
Normal file
305
utile/Teste/facturare_unificat/test_s5c_semnal_proforma.prg
Normal file
@@ -0,0 +1,305 @@
|
||||
* test_s5c_semnal_proforma.prg
|
||||
* Headless (-A -T): S5c, semnalul "sursa era proforma" pe oDateFactura (COMUN\programe\ofacturare_comun.prg)
|
||||
* si pozitia apelului scrie_legatura_proforma() in frm_facturare_articole2.do_scrie_factura
|
||||
* (COMUN\clase\ofacturare.vc2).
|
||||
* A1 - completeaza_setari_document(sursa cu eproforma=1, .T.) seteaza lProformaSursa/nIdProformaSursa/listaid
|
||||
* A2 - aceeasi cale cu eproforma=0 nu ridica semnalul
|
||||
* A3 - Reset() curata semnalul (fara asta, al doilea document din aceeasi sesiune ar primi legatura falsa)
|
||||
* A4 - sursa fara proprietatea eproforma: garda PEMSTATUS tine, fara eroare
|
||||
* A5 - static: apelul scrie_legatura_proforma() e INAINTE de do_inchide_tranzactie(1) (deci inainte de COMMIT)
|
||||
* A6 - static: apelul e in ramura If llReturn, nu neconditionat; cate o data in v1 si in v2
|
||||
* A7 - runtime: functia e vizibila si iese curat cand nu exista poDate
|
||||
* A8 - runtime: cu lProformaSursa = .F. iese fara SQL
|
||||
* A9 - runtime: garda Between pe nid_vanzare (ramas 9999999999) opreste apelul
|
||||
*
|
||||
* Nu emite documente, nu scrie in Oracle. Conexiunea Oracle se face doar pentru globalele de mediu
|
||||
* (gnZileScadentaFact, gnDiscountEvidentiat) folosite de oDateFactura.Reset.
|
||||
*
|
||||
* Rulare: vfp9.exe -A -T "D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\test_s5c_semnal_proforma.prg"
|
||||
* Log: D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out\test_s5c_semnal_proforma.log
|
||||
* Mediu: ROA_CENTRAL / MARIUSM_AUTO; gnIdUtil = 8.
|
||||
|
||||
SET SAFETY OFF
|
||||
SET TALK OFF
|
||||
SET NOTIFY OFF
|
||||
PUBLIC gcLog, gnFail, gnPass, gnSarit, gcCaz
|
||||
gcLog = "D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out\test_s5c_semnal_proforma.log"
|
||||
IF !DIRECTORY("D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out")
|
||||
MD "D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out"
|
||||
ENDIF
|
||||
STRTOFILE("START " + TTOC(DATETIME()) + CHR(13) + CHR(10), gcLog)
|
||||
gnFail = 0
|
||||
gnPass = 0
|
||||
gnSarit = 0
|
||||
gcCaz = ""
|
||||
ON ERROR DO AfErr WITH ERROR(), MESSAGE(), PROGRAM(), LINENO()
|
||||
|
||||
DO "D:\ROA\ROAFACTURARE\COMUN\utile\Teste\test_init_env_auto_roafacturare.prg" WITH 'CENTRAL', 'MARIUSM_AUTO', 'ROMFASTSOFT'
|
||||
IF TYPE('gnHandle') <> 'N' OR gnHandle <= 0
|
||||
DO AfLog WITH "FAIL: conexiune Oracle esuata"
|
||||
DO Final
|
||||
ENDIF
|
||||
SQLSETPROP(gnHandle, "QueryTimeOut", 45)
|
||||
IF TYPE('goExecutor.nHandle') = 'N' AND goExecutor.nHandle > 0 AND goExecutor.nHandle <> gnHandle
|
||||
SQLSETPROP(goExecutor.nHandle, "QueryTimeOut", 45)
|
||||
ENDIF
|
||||
PUBLIC gcMockUltimMesaj, gnMockUltimTip
|
||||
gcMockUltimMesaj = ""
|
||||
gnMockUltimTip = 0
|
||||
IF !actualizeaza_optiuni_program()
|
||||
DO AfLog WITH "FAIL: actualizeaza_optiuni_program()"
|
||||
DO Final
|
||||
ENDIF
|
||||
gnIdUtil = 8
|
||||
goExecutor.oExecuta([begin pack_sesiune.set_Id_Util(?gnIdUtil); end;])
|
||||
DO AfLog WITH "ENV OK"
|
||||
|
||||
PRIVATE poDate
|
||||
poDate = NULL
|
||||
|
||||
DO TestSemnalCopiereProforma
|
||||
DO TestSemnalCopiereNeproforma
|
||||
DO TestResetCurataSemnal
|
||||
DO TestSursaFaraEproforma
|
||||
DO TestPozitieApelInaintePreCommit
|
||||
DO TestApelCondionatSiNumaiInV2
|
||||
DO TestFunctieVizibilaFaraPoDate
|
||||
DO TestFunctieIeseFaraSemnal
|
||||
DO TestGardaNidVanzareInitial
|
||||
|
||||
DO Final
|
||||
|
||||
*----------------------------------------------------------------------------------------
|
||||
* obiect sursa echivalent cu SCATTER NAME loFactura MEMO din crsFacturi (campurile citite de
|
||||
* completeaza_setari_document, ramura de copiere)
|
||||
FUNCTION SursaCopiere
|
||||
LPARAMETERS tnEProforma, tlFaraEproforma
|
||||
LOCAL loSursa
|
||||
loSursa = CREATEOBJECT('Empty')
|
||||
AddProperty(loSursa, 'id_lucrare', 111)
|
||||
AddProperty(loSursa, 'lucrare', 'LUCRARE TEST')
|
||||
AddProperty(loSursa, 'id_sectie', 2)
|
||||
AddProperty(loSursa, 'sectie', 'SECTIA 2')
|
||||
AddProperty(loSursa, 'id_agent', 3)
|
||||
AddProperty(loSursa, 'nume_agent', 'AGENT TEST')
|
||||
AddProperty(loSursa, 'id_delegat', 4)
|
||||
AddProperty(loSursa, 'delegat', 'DELEGAT TEST')
|
||||
AddProperty(loSursa, 'BIdelegat', 'XX')
|
||||
AddProperty(loSursa, 'CNPdelegat', '1234567890123')
|
||||
AddProperty(loSursa, 'nrinmat', 'B00XYZ')
|
||||
AddProperty(loSursa, 'id_masina', 5)
|
||||
AddProperty(loSursa, 'id_vanzare', 4242424)
|
||||
AddProperty(loSursa, 'serie_act', 'PRO')
|
||||
AddProperty(loSursa, 'numar_act', 77)
|
||||
AddProperty(loSursa, 'id_part', 6)
|
||||
AddProperty(loSursa, 'client', 'CLIENT TEST')
|
||||
IF !tlFaraEproforma
|
||||
AddProperty(loSursa, 'eproforma', tnEProforma)
|
||||
ENDIF
|
||||
RETURN loSursa
|
||||
ENDFUNC
|
||||
|
||||
PROCEDURE TestSemnalCopiereProforma
|
||||
LOCAL loSursa, loD
|
||||
gcCaz = "[A1 copiere din proforma] "
|
||||
loSursa = SursaCopiere(1, .F.)
|
||||
loD = CREATEOBJECT('oDateFactura', 0, 5)
|
||||
loD.completeaza_setari_document(loSursa, .T.)
|
||||
DO Assert WITH loD.lProformaSursa = .T., "lProformaSursa = .T., e=" + TRANSFORM(loD.lProformaSursa)
|
||||
DO Assert WITH loD.nIdProformaSursa = loSursa.id_vanzare, ;
|
||||
"nIdProformaSursa = id_vanzare sursa (" + TRANSFORM(loSursa.id_vanzare) + "), e=" + TRANSFORM(loD.nIdProformaSursa)
|
||||
DO Assert WITH loD.listaid = loSursa.id_vanzare, "listaid neatins de modificare, e=" + TRANSFORM(loD.listaid)
|
||||
DO Assert WITH loD.lCopiere = .T., "lCopiere = .T. (ramura de copiere chiar s-a executat)"
|
||||
RELEASE loD, loSursa
|
||||
ENDPROC
|
||||
|
||||
PROCEDURE TestSemnalCopiereNeproforma
|
||||
LOCAL loSursa, loD
|
||||
gcCaz = "[A2 copiere din document non-proforma] "
|
||||
loSursa = SursaCopiere(0, .F.)
|
||||
loD = CREATEOBJECT('oDateFactura', 0, 5)
|
||||
loD.completeaza_setari_document(loSursa, .T.)
|
||||
DO Assert WITH loD.lProformaSursa = .F., "lProformaSursa = .F., e=" + TRANSFORM(loD.lProformaSursa)
|
||||
DO Assert WITH loD.nIdProformaSursa = 0, "nIdProformaSursa = 0, e=" + TRANSFORM(loD.nIdProformaSursa)
|
||||
RELEASE loD, loSursa
|
||||
ENDPROC
|
||||
|
||||
PROCEDURE TestResetCurataSemnal
|
||||
LOCAL loSursa, loD
|
||||
gcCaz = "[A3 Reset curata semnalul] "
|
||||
loSursa = SursaCopiere(1, .F.)
|
||||
loD = CREATEOBJECT('oDateFactura', 0, 5)
|
||||
loD.completeaza_setari_document(loSursa, .T.)
|
||||
DO Assert WITH loD.lProformaSursa = .T., "preconditie: semnalul e ridicat inainte de Reset"
|
||||
loD.Reset(5)
|
||||
DO Assert WITH loD.lProformaSursa = .F., "dupa Reset lProformaSursa = .F., e=" + TRANSFORM(loD.lProformaSursa)
|
||||
DO Assert WITH loD.nIdProformaSursa = 0, "dupa Reset nIdProformaSursa = 0, e=" + TRANSFORM(loD.nIdProformaSursa)
|
||||
RELEASE loD, loSursa
|
||||
ENDPROC
|
||||
|
||||
PROCEDURE TestSursaFaraEproforma
|
||||
LOCAL loSursa, loD, llEroare
|
||||
gcCaz = "[A4 sursa fara proprietatea eproforma] "
|
||||
loSursa = SursaCopiere(0, .T.)
|
||||
loD = CREATEOBJECT('oDateFactura', 0, 5)
|
||||
llEroare = .F.
|
||||
TRY
|
||||
loD.completeaza_setari_document(loSursa, .T.)
|
||||
CATCH
|
||||
llEroare = .T.
|
||||
ENDTRY
|
||||
DO Assert WITH !llEroare, "garda PEMSTATUS: nu se arunca eroare pe o sursa fara eproforma"
|
||||
DO Assert WITH loD.lProformaSursa = .F., "lProformaSursa = .F., e=" + TRANSFORM(loD.lProformaSursa)
|
||||
DO Assert WITH loD.nIdProformaSursa = 0, "nIdProformaSursa = 0, e=" + TRANSFORM(loD.nIdProformaSursa)
|
||||
RELEASE loD, loSursa
|
||||
ENDPROC
|
||||
|
||||
* fereastra de text a metodei frm_facturare_articole2.do_scrie_factura: ancorata pe
|
||||
* Thisform.marcheaza_linii_proforma() (apare o singura data in tot fisierul, doar in v2 - vezi
|
||||
* test_s5b_proforma.prg) si terminata pe primul ENDPROC de dupa
|
||||
FUNCTION FereastraDoScrieFactura
|
||||
LPARAMETERS tcTxt
|
||||
LOCAL lnStart, lnEnd
|
||||
lnStart = AT("Thisform.marcheaza_linii_proforma()", tcTxt)
|
||||
IF lnStart = 0
|
||||
RETURN ""
|
||||
ENDIF
|
||||
lnEnd = AT("ENDPROC", SUBSTR(tcTxt, lnStart))
|
||||
IF lnEnd = 0
|
||||
RETURN ""
|
||||
ENDIF
|
||||
RETURN SUBSTR(tcTxt, lnStart, lnEnd)
|
||||
ENDFUNC
|
||||
|
||||
PROCEDURE TestPozitieApelInaintePreCommit
|
||||
LOCAL lcTxt, lcMetoda, lnApel, lnCommit
|
||||
gcCaz = "[A5 static: apelul e inainte de COMMIT] "
|
||||
lcTxt = FILETOSTR("D:\ROA\ROAFACTURARE\COMUN\clase\ofacturare.vc2")
|
||||
IF EMPTY(lcTxt)
|
||||
DO Assert WITH .F., "FILETOSTR ofacturare.vc2 a esuat/gol"
|
||||
RETURN
|
||||
ENDIF
|
||||
lcMetoda = FereastraDoScrieFactura(lcTxt)
|
||||
IF EMPTY(lcMetoda)
|
||||
DO Assert WITH .F., "nu s-a putut izola do_scrie_factura din frm_facturare_articole2"
|
||||
RETURN
|
||||
ENDIF
|
||||
DO AfLog WITH "DIAG A5: fereastra do_scrie_factura len=" + TRANSFORM(LEN(lcMetoda))
|
||||
lnApel = AT("scrie_legatura_proforma()", lcMetoda)
|
||||
lnCommit = AT("Thisform.do_inchide_tranzactie(1)", lcMetoda)
|
||||
DO Assert WITH lnApel > 0, "scrie_legatura_proforma() apelat din do_scrie_factura, poz=" + TRANSFORM(lnApel)
|
||||
DO Assert WITH lnCommit > 0, "do_inchide_tranzactie(1) prezent in metoda, poz=" + TRANSFORM(lnCommit)
|
||||
IF lnApel > 0 AND lnCommit > 0
|
||||
DO Assert WITH lnApel < lnCommit, ;
|
||||
"apelul e INAINTE de do_inchide_tranzactie(1) (aceeasi tranzactie), apel=" + TRANSFORM(lnApel) + ;
|
||||
" commit=" + TRANSFORM(lnCommit)
|
||||
ENDIF
|
||||
ENDPROC
|
||||
|
||||
PROCEDURE TestApelCondionatSiNumaiInV2
|
||||
LOCAL lcTxt, lcMetoda, lcSecventa
|
||||
gcCaz = "[A6 static: apel conditionat, o data in v1 si o data in v2] "
|
||||
lcTxt = FILETOSTR("D:\ROA\ROAFACTURARE\COMUN\clase\ofacturare.vc2")
|
||||
IF EMPTY(lcTxt)
|
||||
DO Assert WITH .F., "FILETOSTR ofacturare.vc2 a esuat/gol"
|
||||
RETURN
|
||||
ENDIF
|
||||
lcMetoda = FereastraDoScrieFactura(lcTxt)
|
||||
IF EMPTY(lcMetoda)
|
||||
DO Assert WITH .F., "nu s-a putut izola do_scrie_factura din frm_facturare_articole2"
|
||||
RETURN
|
||||
ENDIF
|
||||
* linia de apel e precedata imediat de If llReturn - exact textul scris la write-back
|
||||
lcSecventa = "If llReturn" + CHR(13) + CHR(10) + REPLICATE(CHR(9), 4) + "llReturn = scrie_legatura_proforma()"
|
||||
DO Assert WITH lcSecventa $ lcMetoda, "apelul e in ramura If llReturn (nu neconditionat)"
|
||||
DO Assert WITH OCCURS("scrie_legatura_proforma", lcTxt) = 2, ;
|
||||
"scrie_legatura_proforma apare de doua ori in ofacturare.vc2 (v1 si v2), ocurente=" + ;
|
||||
TRANSFORM(OCCURS("scrie_legatura_proforma", lcTxt))
|
||||
DO Assert WITH OCCURS("scrie_legatura_proforma", lcMetoda) = 1, ;
|
||||
"unica ocurenta e chiar in do_scrie_factura din frm_facturare_articole2"
|
||||
ENDPROC
|
||||
|
||||
PROCEDURE TestFunctieVizibilaFaraPoDate
|
||||
LOCAL llRez, llEroare
|
||||
gcCaz = "[A7 runtime: functia e vizibila si iese curat cand poDate nu e obiect] "
|
||||
poDate = NULL
|
||||
llEroare = .F.
|
||||
llRez = .F.
|
||||
TRY
|
||||
llRez = scrie_legatura_proforma()
|
||||
CATCH
|
||||
llEroare = .T.
|
||||
ENDTRY
|
||||
DO Assert WITH !llEroare, "scrie_legatura_proforma() e vizibila (SET PROCEDURE ofacturare_comun.prg)"
|
||||
DO Assert WITH TYPE('poDate') <> 'O', "preconditie: Type('poDate') <> 'O', e=" + TYPE('poDate')
|
||||
DO Assert WITH llRez = .T., "intoarce .T. cand poDate nu e obiect, e=" + TRANSFORM(llRez)
|
||||
ENDPROC
|
||||
|
||||
PROCEDURE TestFunctieIeseFaraSemnal
|
||||
LOCAL llRez
|
||||
gcCaz = "[A8 runtime: iese fara SQL cand lProformaSursa = .F.] "
|
||||
poDate = CREATEOBJECT('oDateFactura', 0, 5)
|
||||
poDate.lProformaSursa = .F.
|
||||
poDate.nIdProformaSursa = 0
|
||||
poDate.nid_vanzare = 123456
|
||||
llRez = scrie_legatura_proforma()
|
||||
DO Assert WITH llRez = .T., "intoarce .T. fara sa cheme Oracle, e=" + TRANSFORM(llRez)
|
||||
poDate = NULL
|
||||
ENDPROC
|
||||
|
||||
PROCEDURE TestGardaNidVanzareInitial
|
||||
LOCAL llRez, lnInainte
|
||||
gcCaz = "[A9 runtime: garda Between pe nid_vanzare ramas 9999999999] "
|
||||
poDate = CREATEOBJECT('oDateFactura', 0, 5)
|
||||
poDate.lProformaSursa = .T.
|
||||
poDate.nIdProformaSursa = 4242424
|
||||
DO Assert WITH poDate.nid_vanzare = 9999999999, ;
|
||||
"preconditie: nid_vanzare are valoarea initiala, e=" + TRANSFORM(poDate.nid_vanzare)
|
||||
lnInainte = NumarLegaturi(4242424)
|
||||
llRez = scrie_legatura_proforma()
|
||||
DO Assert WITH llRez = .T., "intoarce .T. (garda opreste apelul, nu il raporteaza ca eroare), e=" + TRANSFORM(llRez)
|
||||
DO Assert WITH NumarLegaturi(4242424) = lnInainte, ;
|
||||
"nu s-a scris nicio legatura pentru id fictiv, inainte=" + TRANSFORM(lnInainte) + ;
|
||||
" dupa=" + TRANSFORM(NumarLegaturi(4242424))
|
||||
poDate = NULL
|
||||
ENDPROC
|
||||
|
||||
FUNCTION NumarLegaturi
|
||||
LPARAMETERS tnIdProforma
|
||||
LOCAL lcSql, lnRez
|
||||
lnRez = -1
|
||||
lcSql = [select count(*) as nr from vanzari_coresp where tip = 4 and id_vanzare_aviz = ] + ;
|
||||
ALLTRIM(STR(tnIdProforma, 20, 0))
|
||||
IF goExecutor.oExecute(lcSql, [crsnrleg]) >= 0 AND USED('crsnrleg')
|
||||
lnRez = crsnrleg.nr
|
||||
USE IN (SELECT('crsnrleg'))
|
||||
ENDIF
|
||||
RETURN lnRez
|
||||
ENDFUNC
|
||||
|
||||
PROCEDURE Assert
|
||||
LPARAMETERS tlCond, tcMsg
|
||||
IF tlCond
|
||||
gnPass = gnPass + 1
|
||||
ELSE
|
||||
gnFail = gnFail + 1
|
||||
DO AfLog WITH "FAIL: " + gcCaz + tcMsg
|
||||
ENDIF
|
||||
ENDPROC
|
||||
|
||||
PROCEDURE AfLog
|
||||
LPARAMETERS tcMsg
|
||||
STRTOFILE(tcMsg + CHR(13) + CHR(10), gcLog, 1)
|
||||
ENDPROC
|
||||
|
||||
PROCEDURE AfErr
|
||||
LPARAMETERS tnErr, tcMsg, tcProg, tnLine
|
||||
gnFail = gnFail + 1
|
||||
DO AfLog WITH "ERROR " + gcCaz + TRANSFORM(tnErr) + " [" + tcProg + ":" + TRANSFORM(tnLine) + "] " + tcMsg
|
||||
ENDPROC
|
||||
|
||||
PROCEDURE Final
|
||||
DO AfLog WITH "TOTAL pass=" + TRANSFORM(gnPass) + " fail=" + TRANSFORM(gnFail) + " sarit=" + TRANSFORM(gnSarit)
|
||||
DO AfLog WITH "END " + TTOC(DATETIME())
|
||||
QUIT
|
||||
ENDPROC
|
||||
Reference in New Issue
Block a user