From a6d883df69a21505bb7a31583c12f8e6d949d541 Mon Sep 17 00:00:00 2001 From: Marius Mutu Date: Sat, 25 Jul 2026 00:43:23 +0300 Subject: [PATCH] Achizitie din import: schimbarea cursului resincronizeaza articolele si diferenta cCurs.Text1.Valid armeaza sincronizarea amanata (repretare articole + recalc diferente) si propaga cursul principalei in antet (oact.curs, doar pe randuri in valuta). Teste: pas nou de schimbare curs pe DVI secundar in test_valuta_dvi_usd (22/22 PASS), regresie test_debifare_invaluta (68/68) si test_scenariu_dvi_complet PASS. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01KXsyJZBek1e9RvyLAQkoCx --- clase/ointroduceri.vc2 | 15 ++- .../test_debifare_invaluta.prg | 9 ++ .../achizitie_import/test_valuta_dvi_usd.prg | 98 ++++++++++++++++++- .../achizitie_import/test_valuta_dvi_usd.ps1 | 2 +- 4 files changed, 121 insertions(+), 3 deletions(-) diff --git a/clase/ointroduceri.vc2 b/clase/ointroduceri.vc2 index 250c10c..aca3a4d 100644 --- a/clase/ointroduceri.vc2 +++ b/clase/ointroduceri.vc2 @@ -12455,11 +12455,22 @@ DEFINE CLASS import_nota AS frm_termin_renunt OF "_frm_child.vcx" *!* nu-l mai scria in camp) si se copiaza pe randul de TVA pereche; apoi ofer *!* recalcularea sumei in lei din suma in valuta, ca la modificarea sumei in valuta *!* 24.07.2026 claude - recalcularea din curs se aplica pe toate randurile documentului si reface totalurile suma_doc/suma_doc_val - Local lnSumaDinVal, lnRaspuns, lcDocKeyC, lnRecC, lnCntS, lnSLei, lnSVal + Local lnSumaDinVal, lnRaspuns, lcDocKeyC, lnRecC, lnCntS, lnSLei, lnSVal, lnMinNrDocC If This.Value # 0 Select introdc Replace curs With This.Value Thisform.copiaza_valoare([curs]) + lnRecC = Recno('introdc') + lnMinNrDocC = 99999998 + Calculate Min(Iif(Inlist(tip_rand,'B','S'), nr_doc, 99999998)) To lnMinNrDocC + Try + Go lnRecC In introdc + Catch + Go Top In introdc + Endtry + If nr_doc = lnMinNrDocC And in_valuta = 1 + Thisform.oact.curs = This.Value + Endif If in_valuta = 1 And !Empty(Nvl(introdc.doc_key,'')) lcDocKeyC = introdc.doc_key lnRecC = Recno('introdc') @@ -12510,6 +12521,8 @@ DEFINE CLASS import_nota AS frm_termin_renunt OF "_frm_child.vcx" Thisform.do_executa Endif Endif + Thisform.lSyncPending = .T. + Thisform.tmrSync.Interval = 1 Endif ENDPROC diff --git a/utile/Teste/achizitie_import/test_debifare_invaluta.prg b/utile/Teste/achizitie_import/test_debifare_invaluta.prg index fec468b..a09c487 100644 --- a/utile/Teste/achizitie_import/test_debifare_invaluta.prg +++ b/utile/Teste/achizitie_import/test_debifare_invaluta.prg @@ -543,7 +543,16 @@ poAct.AddProperty('id_valuta', 1) 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 diff --git a/utile/Teste/achizitie_import/test_valuta_dvi_usd.prg b/utile/Teste/achizitie_import/test_valuta_dvi_usd.prg index d6e91df..7db9830 100644 --- a/utile/Teste/achizitie_import/test_valuta_dvi_usd.prg +++ b/utile/Teste/achizitie_import/test_valuta_dvi_usd.prg @@ -402,6 +402,102 @@ TRY DO DcLog WITH ' FAIL 7-valideaza_sume (' + TRANSFORM(llValidSume) + ', cmesajsync=[' + ALLTRIM(NVL(goObj.cmesajsync,'')) + '])' ENDIF + *========================= PAS NOU: schimbare curs pe randul S(371) al DVI USD (nract=101) - resincronizare (runda8) ========================= + LOCAL lcDocKeyDvi2 + lcDocKeyDvi2 = '' + SELECT introdc + LOCATE FOR nract = 101 AND ALLTRIM(fdoc) == 'DVI' AND tip_rand == 'S' AND ALLTRIM(scd) == '371' + DO Assert3 WITH '8-rand S DVI USD (371) gasit inainte de schimbare curs', IIF(FOUND(),1,0), 1 + IF FOUND() + lcDocKeyDvi2 = ALLTRIM(NVL(introdc.doc_key,'')) + DO DcLog WITH 'PAS-curs: pozitionat pe randul S (nract=101,scd=371), curs INAINTE=' + TRANSFORM(introdc.curs) + ' doc_key=[' + lcDocKeyDvi2 + ']' + + goObj.grid1.cCurs.text1.Value = 4.50 + goObj.grid1.cCurs.text1.Valid() + + DO Assert3 WITH '9-armare lSyncPending=.T. dupa Valid curs (pre-DOEVENTS)', IIF(goObj.lSyncPending,1,0), 1 + DO Assert3 WITH '10-armare tmrSync.Interval>0 dupa Valid curs (pre-DOEVENTS)', IIF(goObj.tmrSync.Interval>0,1,0), 1 + + DOEVENTS FORCE + + DO Assert3 WITH '11-sync consumat lSyncPending=.F. dupa DOEVENTS', IIF(goObj.lSyncPending,1,0), 0 + DO Assert3 WITH '12-sync consumat tmrSync.Interval=0 dupa DOEVENTS', goObj.tmrSync.Interval, 0 + ELSE + pnAsserts = pnAsserts + 4 + DO DcLog WITH ' FAIL 9-12: nu exista randul S(371) pe DVI 101, sar peste schimbarea de curs' + ENDIF + + DO DcLog WITH 'dump introdc dupa schimbare curs DVI USD (4.50):' + DO DumpIntrodc + + SELECT introdc + LOCATE FOR nract = 101 AND ALLTRIM(fdoc) == 'DVI' AND tip_rand == 'S' AND ALLTRIM(scd) == '371' + IF FOUND() + DO Assert3 WITH '13-S(371) suma recalculata (450 lei)', suma, 450 + ELSE + pnAsserts = pnAsserts + 1 + DO DcLog WITH ' FAIL 13: nu am gasit randul S(371) dupa sync' + ENDIF + + SELECT introdc + LOCATE FOR ALLTRIM(NVL(doc_key,'')) == lcDocKeyDvi2 AND tip_rand == 'T' + IF FOUND() + DO Assert3 WITH '14-T DVI suma recalculata (94.50 lei)', suma, 94.50 + ELSE + pnAsserts = pnAsserts + 1 + DO DcLog WITH ' FAIL 14: nu am gasit randul T al doc2 (doc_key=' + lcDocKeyDvi2 + ') dupa sync' + ENDIF + + DO DcLog WITH 'goObj.procent_val=' + TRANSFORM(goObj.procent_val) + ' goObj.nbaza_val=' + TRANSFORM(goObj.nbaza_val) + DO Assert3 WITH '15-procent_val dupa curs (astept 108.604)', goObj.procent_val, 108.604 + DO Assert3 WITH '16-nbaza_val dupa curs (astept 1086.04)', goObj.nbaza_val, 1086.04 + + SELECT rul_temp + LOCATE FOR ALLTRIM(codmat) == 'ART-A8-371' + IF FOUND() + DO DcLog WITH 'rul_temp dupa curs: pretd=' + TRANSFORM(pretd) + ' pret=' + TRANSFORM(pret) + DO Assert3 WITH '17-rul_temp.pretd dupa curs (astept 1086.04)', pretd, 1086.04 + *!* 5679.99, nu pretd*curs=5680.03 - do_reface rotunjeste intermediar (acelasi tipar ca 3b) + DO Assert3 WITH '18-rul_temp.pret dupa curs (astept 5679.99)', pret, 5679.99 + ELSE + pnAsserts = pnAsserts + 2 + DO DcLog WITH ' FAIL 17/18: nu am gasit articolul ART-A8-371 in rul_temp dupa curs' + ENDIF + + SELECT introdc + LOCATE FOR tip_rand == 'D' + IF FOUND() + DO DcLog WITH 'randul D dupa curs: suma=' + TRANSFORM(suma) + DO Assert3 WITH '19-diferenta D dupa curs (|suma|<=0.02)', ABS(suma), 0 + ELSE + DO DcLog WITH ' INFO 19: nu exista rand D dupa curs - OK' + pnAsserts = pnAsserts + 1 + pnPass = pnPass + 1 + ENDIF + + SELECT introdc + LOCATE FOR nract = 101 AND ALLTRIM(fdoc) == 'DVI' AND tip_rand == 'S' AND ALLTRIM(scd) == '371' + IF FOUND() + DO DcLog WITH 'S doc2 dupa curs: explicatia5=[' + ALLTRIM(NVL(explicatia5,'')) + ']' + DO AssertStr WITH '20-explicatia5 S DVI dupa curs (astept 8.60)', ALLTRIM(NVL(explicatia5,'')), '8.60' + ELSE + pnAsserts = pnAsserts + 1 + DO DcLog WITH ' FAIL 20: nu am gasit randul S(371) pt explicatia5 dupa curs' + ENDIF + + LOCAL llValidSume2 + llValidSume2 = goObj.valideaza_sume() + DO DcLog WITH '21-valideaza_sume() dupa curs=' + TRANSFORM(llValidSume2) + ' cmesajsync=[' + ALLTRIM(NVL(goObj.cmesajsync,'')) + ']' + pnAsserts = pnAsserts + 1 + IF llValidSume2 AND EMPTY(ALLTRIM(NVL(goObj.cmesajsync,''))) + pnPass = pnPass + 1 + DO DcLog WITH ' PASS 21-valideaza_sume dupa curs (.T., cmesajsync gol)' + ELSE + DO DcLog WITH ' FAIL 21-valideaza_sume dupa curs (' + TRANSFORM(llValidSume2) + ', cmesajsync=[' + ALLTRIM(NVL(goObj.cmesajsync,'')) + '])' + ENDIF + + DO HarnessStep WITH 3, 'curs resincronizare DVI USD: ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' PASS' + DO DcLog WITH 'REZULTAT: ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' assert-uri PASS' IF pnPass = pnAsserts DO DcLog WITH 'VERDICT FINAL: PASS (' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ')' @@ -409,7 +505,7 @@ TRY DO DcLog WITH 'VERDICT FINAL: FAIL (' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' assert-uri PASS)' ENDIF - DO HarnessStep WITH 3, 'final: ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' PASS' + DO HarnessStep WITH 4, 'final: ' + TRANSFORM(pnPass) + '/' + TRANSFORM(pnAsserts) + ' PASS' DO HarnessDone WITH 'done' CATCH TO loExc diff --git a/utile/Teste/achizitie_import/test_valuta_dvi_usd.ps1 b/utile/Teste/achizitie_import/test_valuta_dvi_usd.ps1 index 597e662..138912a 100644 --- a/utile/Teste/achizitie_import/test_valuta_dvi_usd.ps1 +++ b/utile/Teste/achizitie_import/test_valuta_dvi_usd.ps1 @@ -5,7 +5,7 @@ $ErrorActionPreference = 'Stop' $Teste = $PSScriptRoot & (Join-Path (Split-Path $Teste -Parent) 'vfp_ui_harness.ps1') ` -TestPrg (Join-Path $Teste 'test_valuta_dvi_usd.prg') ` - -Steps @('2documente','articol_adaugat','sync','final') ` + -Steps @('2documente','articol_adaugat','sync','curs_resync','final') ` -ShotsDir (Join-Path $Teste 'screenshots_valuta_usd') ` -SyncDir (Join-Path $Teste 'uisync_valuta_usd') ` -StepTimeoutSec 180 `