From d2a16f75a1edd16aaead5d9dae47dbf90c974913 Mon Sep 17 00:00:00 2001 From: Marius Mutu Date: Thu, 17 Sep 2026 11:19:54 +0300 Subject: [PATCH] sync SVN r18152 --- clase/onom_articole.vc2 | 28 ++ programe/ofacturare_comun.prg | 57 +++- .../facturare_unificat/probe_cont_667.prg | 145 +++++++++ .../facturare_unificat/probe_cont_667b.prg | 157 ++++++++++ .../facturare_unificat/probe_cont_667c.prg | 72 +++++ .../facturare_unificat/probe_cont_667d.prg | 57 ++++ .../facturare_unificat/probe_e2e_cont_667.prg | 296 ++++++++++++++++++ .../probe_e2e_cont_667_semn.sql | 73 +++++ .../probe_e2e_cont_667_ui.prg | 125 ++++++++ .../facturare_unificat/restore_pol41.prg | 51 +++ 10 files changed, 1047 insertions(+), 14 deletions(-) create mode 100644 utile/Teste/facturare_unificat/probe_cont_667.prg create mode 100644 utile/Teste/facturare_unificat/probe_cont_667b.prg create mode 100644 utile/Teste/facturare_unificat/probe_cont_667c.prg create mode 100644 utile/Teste/facturare_unificat/probe_cont_667d.prg create mode 100644 utile/Teste/facturare_unificat/probe_e2e_cont_667.prg create mode 100644 utile/Teste/facturare_unificat/probe_e2e_cont_667_semn.sql create mode 100644 utile/Teste/facturare_unificat/probe_e2e_cont_667_ui.prg create mode 100644 utile/Teste/facturare_unificat/restore_pol41.prg diff --git a/clase/onom_articole.vc2 b/clase/onom_articole.vc2 index 613f562..a263fd3 100644 --- a/clase/onom_articole.vc2 +++ b/clase/onom_articole.vc2 @@ -712,7 +712,9 @@ DEFINE CLASS frm_catalog_articole_nou AS _frmbase OF "_frm_base.vcx" *< OBJECTDATA: ObjPath="_pageframe1.Page3.Cb_tx_proc_tvav" UniqueID="" Timestamp="" /> *< OBJECTDATA: ObjPath="_pageframe1.Page3.Cb_tx_venit" UniqueID="" Timestamp="" /> *< OBJECTDATA: ObjPath="_pageframe1.Page3.Clb_tx_scd" UniqueID="" Timestamp="" /> + *< OBJECTDATA: ObjPath="_pageframe1.Page3.Clb_tx_scd.Text1" UniqueID="" Timestamp="" /> *< OBJECTDATA: ObjPath="_pageframe1.Page3.Clb_tx_scc" UniqueID="" Timestamp="" /> + *< OBJECTDATA: ObjPath="_pageframe1.Page3.Clb_tx_scc.Text1" UniqueID="" Timestamp="" /> *< OBJECTDATA: ObjPath="_pageframe1.Page3.Clb_tx_cont_dedus" UniqueID="" Timestamp="" /> *< OBJECTDATA: ObjPath="_pageframe1.Page3.Lb_info_conturi" UniqueID="" Timestamp="" /> *< OBJECTDATA: ObjPath="Cus_odata_parteneri_articole_coduri" UniqueID="" Timestamp="" /> @@ -1586,6 +1588,18 @@ DEFINE CLASS frm_catalog_articole_nou AS _frmbase OF "_frm_base.vcx" Lb_simplu1.Name = "Lb_simplu1" *< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" /> + ADD OBJECT '_pageframe1.Page3.Clb_tx_scc.Text1' AS textbox WITH ; + Format = "!k", ; + Height = 23, ; + Left = 302, ; + MaxLength = 4, ; + Name = "Text1", ; + TabIndex = 2, ; + ToolTipText = "Cont analitic (optional)", ; + Top = 3, ; + Width = 74 + *< END OBJECT: BaseClass="textbox" /> + ADD OBJECT '_pageframe1.Page3.Clb_tx_scd' AS clb_tx_simplu WITH ; Height = 29, ; Left = 9, ; @@ -1604,6 +1618,18 @@ DEFINE CLASS frm_catalog_articole_nou AS _frmbase OF "_frm_base.vcx" Lb_simplu1.Name = "Lb_simplu1" *< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" /> + ADD OBJECT '_pageframe1.Page3.Clb_tx_scd.Text1' AS textbox WITH ; + Format = "!k", ; + Height = 23, ; + Left = 302, ; + MaxLength = 4, ; + Name = "Text1", ; + TabIndex = 2, ; + ToolTipText = "Cont analitic (optional)", ; + Top = 3, ; + Width = 74 + *< END OBJECT: BaseClass="textbox" /> + ADD OBJECT '_pageframe1.Page3.Lb_info_conturi' AS _label WITH ; Caption = "Necompletate: debit 4111, credit contul de venit al articolului", ; Left = 9, ; @@ -1934,6 +1960,8 @@ DEFINE CLASS frm_catalog_articole_nou AS _frmbase OF "_frm_base.vcx" This._pageframe1.Page3.Clb_tx_pret_ctva.Text_simplu1.ControlSource = "Thisform.oPretNom.nPretCtva" This._pageframe1.Page3.Clb_tx_scd.Text_simplu1.ControlSource = "Thisform.oPretNom.cScd" This._pageframe1.Page3.Clb_tx_scc.Text_simplu1.ControlSource = "Thisform.oPretNom.cScc" + This._pageframe1.Page3.Clb_tx_scd.Text1.ControlSource = "Thisform.oPretNom.cAscd" + This._pageframe1.Page3.Clb_tx_scc.Text1.ControlSource = "Thisform.oPretNom.cAscc" This._pageframe1.Page3.Clb_tx_cont_dedus.Text_simplu1.ControlSource = "Thisform.oPretNom.cContDedus" If Used('crsvenchelt') Use In crsvenchelt diff --git a/programe/ofacturare_comun.prg b/programe/ofacturare_comun.prg index 7b6b46b..efd2002 100644 --- a/programe/ofacturare_comun.prg +++ b/programe/ofacturare_comun.prg @@ -74,6 +74,10 @@ *!* marius.mutu *!* + verifica_cont_venit_linie - verificare prietenoasa a contului de venit rezolvat pentru o linie *!* de factura, la adaugarea articolului +*!* 17.09.2026 +*!* agent +*!* cus_pret_nomenclator: conturi analitice (cAscd/cAscc) in nota de vanzare a articolului; +*!* apelul RPC devine pack_preturi.gaseste_creeaza_nota_vanzare (overload 6 arg cu analitice) *************************************************************************************************************** **** Clase: @@ -2375,6 +2379,8 @@ Define Class cus_pret_nomenclator As Custom nIdNota = .NULL. cScd = [] cScc = [] + cAscd = [] + cAscc = [] cContDedus = [] cEroare = [] @@ -2410,6 +2416,8 @@ Define Class cus_pret_nomenclator As Custom This.nIdNota = .NULL. This.cScd = [] This.cScc = [] + This.cAscd = [] + This.cAscc = [] This.cContDedus = [] If This.asigura_politica() <= 0 Return .F. @@ -2450,7 +2458,7 @@ Define Class cus_pret_nomenclator As Custom Use In crspolart Endif If !Isnull(This.nIdNota) - lcSql = [select n.scd, n.scc from crm_note_vanzari v, note_contabile n ] + ; + lcSql = [select n.scd, n.ascd, n.scc, n.ascc from crm_note_vanzari v, note_contabile n ] + ; [where v.id_nota = ] + Alltrim(Str(This.nIdNota)) + [ and n.id_set = v.id_set] If Used('crsnotapol') Use In crsnotapol @@ -2459,6 +2467,8 @@ Define Class cus_pret_nomenclator As Custom If lnSucces >= 0 And Reccount('crsnotapol') > 0 This.cScd = Alltrim(Nvl(crsnotapol.scd,[])) This.cScc = Alltrim(Nvl(crsnotapol.scc,[])) + This.cAscd = Alltrim(Nvl(crsnotapol.ascd,[])) + This.cAscc = Alltrim(Nvl(crsnotapol.ascc,[])) Endif If Used('crsnotapol') Use In crsnotapol @@ -2482,11 +2492,20 @@ Define Class cus_pret_nomenclator As Custom * valideaza conturile si pretul curente; mesaj + .F. la refuz Procedure valideaza This.cEroare = [] - If (!Empty(This.cScd) And Empty(This.cScc)) Or (Empty(This.cScd) And !Empty(This.cScc)) - This.cEroare = [Trebuie completate ambele conturi (debit si credit) sau niciunul.] + If !Empty(This.cAscd) And Empty(This.cScd) + This.cEroare = [Contul analitic debitor nu poate fi completat fara contul sintetic debitor.] Else - If This.nPretFtva < 0 Or This.nPretCtva < 0 - This.cEroare = [Pretul nu poate fi negativ.] + If !Empty(This.cAscc) And Empty(This.cScc) + This.cEroare = [Contul analitic creditor nu poate fi completat fara contul sintetic creditor.] + Endif + Endif + If Empty(This.cEroare) + If (!Empty(This.cScd) And Empty(This.cScc)) Or (Empty(This.cScd) And !Empty(This.cScc)) + This.cEroare = [Trebuie completate ambele conturi (debit si credit) sau niciunul.] + Else + If This.nPretFtva < 0 Or This.nPretCtva < 0 + This.cEroare = [Pretul nu poate fi negativ.] + Endif Endif Endif If !Empty(This.cEroare) @@ -2505,14 +2524,16 @@ Define Class cus_pret_nomenclator As Custom Return .F. Endif If !Empty(This.cScd) And !Empty(This.cScc) - Private pcScd, pcScc, pnIdUtil + Private pcScd, pcScc, pcAscd, pcAscc, pnIdUtil pcScd = This.cScd pcScc = This.cScc + pcAscd = This.cAscd + pcAscc = This.cAscc pnIdUtil = gnIdUtil pnIdNota = 0 - lcSql = [begin pack_preturi.gaseste_sau_creeaza_nota_vanzare(?pcScd,?pcScc,?pnIdUtil,?@pnIdNota); end;] + lcSql = [begin pack_preturi.gaseste_creeaza_nota_vanzare(?pcScd,?pcAscd,?pcScc,?pcAscc,?pnIdUtil,?@pnIdNota); end;] lnSucces = goExecutor.oExecute(lcSql) - Release pcScd, pcScc, pnIdUtil + Release pcScd, pcScc, pcAscd, pcAscc, pnIdUtil If lnSucces < 0 AMESSAGEBOX(goExecutor.oPrelucrareEroare(),16,"Eroare") Release pnIdArticol, pnPretFtva, pnPretCtva, pnProcTvav, pnIdVenchelt, pnIdNota, pnScrieNota @@ -2555,7 +2576,9 @@ Define Class cus_pret_nomenclator As Custom Local lcSql, lnSucces This.cScd = [] This.cScc = [] - lcSql = [select n.scd, n.scc from crm_politici_preturi p, crm_note_vanzari v, note_contabile n ] + ; + This.cAscd = [] + This.cAscc = [] + lcSql = [select n.scd, n.ascd, n.scc, n.ascc from crm_politici_preturi p, crm_note_vanzari v, note_contabile n ] + ; [where p.id_pol = ] + Alltrim(Str(tnIdPol)) + [ and v.id_nota = p.id_nota and n.id_set = v.id_set] If Used('crsnotapolstoc') Use In crsnotapolstoc @@ -2564,6 +2587,8 @@ Define Class cus_pret_nomenclator As Custom If lnSucces >= 0 And Reccount('crsnotapolstoc') > 0 This.cScd = Alltrim(Nvl(crsnotapolstoc.scd,[])) This.cScc = Alltrim(Nvl(crsnotapolstoc.scc,[])) + This.cAscd = Alltrim(Nvl(crsnotapolstoc.ascd,[])) + This.cAscc = Alltrim(Nvl(crsnotapolstoc.ascc,[])) Endif If Used('crsnotapolstoc') Use In crsnotapolstoc @@ -2573,8 +2598,10 @@ Define Class cus_pret_nomenclator As Custom * valideaza (ambele conturi sau niciunul) si scrie nota implicita a politicii date Procedure salveaza_nota_politica - Lparameters tnIdPol, tcScd, tcScc + Lparameters tnIdPol, tcScd, tcScc, tcAscd, tcAscc Local lcSql, lnSucces + tcAscd = Iif(Type('tcAscd')='C', tcAscd, []) + tcAscc = Iif(Type('tcAscc')='C', tcAscc, []) If (!Empty(tcScd) And Empty(tcScc)) Or (Empty(tcScd) And !Empty(tcScc)) This.cEroare = [Trebuie completate ambele conturi (debit si credit) sau niciunul.] AMESSAGEBOX(This.cEroare,0+48,"Atentie") @@ -2583,16 +2610,18 @@ Define Class cus_pret_nomenclator As Custom If Empty(tcScd) And Empty(tcScc) Return .T. Endif - Private pcScd, pcScc, pnIdUtil, pnIdNota, pnIdPol + Private pcScd, pcScc, pcAscd, pcAscc, pnIdUtil, pnIdNota, pnIdPol pcScd = tcScd pcScc = tcScc + pcAscd = tcAscd + pcAscc = tcAscc pnIdUtil = gnIdUtil pnIdNota = 0 - lcSql = [begin pack_preturi.gaseste_sau_creeaza_nota_vanzare(?pcScd,?pcScc,?pnIdUtil,?@pnIdNota); end;] + lcSql = [begin pack_preturi.gaseste_creeaza_nota_vanzare(?pcScd,?pcAscd,?pcScc,?pcAscc,?pnIdUtil,?@pnIdNota); end;] lnSucces = goExecutor.oExecute(lcSql) If lnSucces < 0 AMESSAGEBOX(goExecutor.oPrelucrareEroare(),16,"Eroare") - Release pcScd, pcScc, pnIdUtil, pnIdNota, pnIdPol + Release pcScd, pcScc, pcAscd, pcAscc, pnIdUtil, pnIdNota, pnIdPol Return .F. Endif pnIdPol = tnIdPol @@ -2601,7 +2630,7 @@ Define Class cus_pret_nomenclator As Custom If lnSucces < 0 AMESSAGEBOX(goExecutor.oPrelucrareEroare(),16,"Eroare") Endif - Release pcScd, pcScc, pnIdUtil, pnIdNota, pnIdPol + Release pcScd, pcScc, pcAscd, pcAscc, pnIdUtil, pnIdNota, pnIdPol Return (lnSucces >= 0) Endproc && salveaza_nota_politica Enddefine diff --git a/utile/Teste/facturare_unificat/probe_cont_667.prg b/utile/Teste/facturare_unificat/probe_cont_667.prg new file mode 100644 index 0000000..c627ace --- /dev/null +++ b/utile/Teste/facturare_unificat/probe_cont_667.prg @@ -0,0 +1,145 @@ +SET SAFETY OFF +SET TALK OFF +SET NOTIFY OFF +CLOSE DATABASES + +PUBLIC gcLog, gcCaz, gnPass, gnFail +gcLog = "D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out\probe_cont_667.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) +gcCaz = "" +gnPass = 0 +gnFail = 0 +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 +gnIdUtil = 8 +DO AfLog WITH "ENV OK gnHandle=" + TRANSFORM(gnHandle) + +LOCAL lnOk, lnIdPolStoc, lcSql +lnOk = SQLEXEC(gnHandle, "select varvalue from optiuni where program='ROAFACTURARE' and varname='ID_POL_PRET_STOC'", "crsopt") +lnIdPolStoc = IIF(lnOk > 0 AND USED('crsopt') AND !ISNULL(crsopt.varvalue), VAL(ALLTRIM(crsopt.varvalue)), 0) +IF USED('crsopt') + USE IN crsopt +ENDIF +DO AfLog WITH "politica stoc (CATALOG ARTICOLE) id_pol=" + TRANSFORM(lnIdPolStoc) +IF lnIdPolStoc <= 0 + DO AfLog WITH "FAIL: nu exista ID_POL_PRET_STOC in OPTIUNI" + DO Final +ENDIF +PUBLIC gnId_pol_pret_stoc +gnId_pol_pret_stoc = lnIdPolStoc + +DO AfLog WITH "--- note existente 667/709 ---" +lcSql = "select v.id_nota, v.denumire, n.scd, n.scc, n.ascc, n.ascd, n.in_valuta, n.cu_tva " + ; + "from crm_note_vanzari v join note_contabile n on n.id_set = v.id_set " + ; + "where (trim(n.scd) in ('667','709') or trim(n.scc) in ('667','709')) order by v.id_nota" +lnOk = SQLEXEC(gnHandle, lcSql, "crsnote") +IF lnOk > 0 + SCAN + DO AfLog WITH " id_nota=" + TRANSFORM(crsnote.id_nota) + " den=[" + ALLTRIM(NVL(crsnote.denumire,[])) + "] scd=" + ALLTRIM(NVL(crsnote.scd,[])) + " scc=" + ALLTRIM(NVL(crsnote.scc,[])) + " inv=" + TRANSFORM(NVL(crsnote.in_valuta,0)) + " cu_tva=" + TRANSFORM(NVL(crsnote.cu_tva,0)) + ENDSCAN +ELSE + DO AfLog WITH " select note a esuat lnOk=" + TRANSFORM(lnOk) +ENDIF +IF USED('crsnote') + USE IN crsnote +ENDIF + +DO AfLog WITH "--- articole cu cont 667/709 in politica de stoc ---" +lcSql = "select a.id_articol, e.denumire, e.cont, e.acont, a.id_nota, a.pret " + ; + "from crm_politici_pret_art a join nom_articole e on e.id_articol = a.id_articol " + ; + "where a.id_pol = " + TRANSFORM(lnIdPolStoc) + " and nvl(trim(e.cont),'x') in ('667','709')" +lnOk = SQLEXEC(gnHandle, lcSql, "crsart") +IF lnOk <= 0 + DO AfLog WITH " select articole a esuat lnOk=" + TRANSFORM(lnOk) + DO Final +ENDIF +IF RECCOUNT('crsart') = 0 + DO AfLog WITH " INFO: niciun articol cu cont 667/709 in politica de stoc - caut in tot nomenclatorul" + USE IN crsart + lnOk = SQLEXEC(gnHandle, "select 0 as id_articol, denumire, cont, acont, null as id_nota, 0 as pret from nom_articole where trim(cont) in ('667','709')", "crsart") +ENDIF +DO AfLog WITH " gasite: " + TRANSFORM(RECCOUNT('crsart')) +SCAN + gcCaz = "[art " + TRANSFORM(crsart.id_articol) + "] " + DO AfLog WITH "ART id=" + TRANSFORM(crsart.id_articol) + " den=[" + ALLTRIM(NVL(crsart.denumire,[])) + "] cont=[" + ALLTRIM(NVL(crsart.cont,[])) + "] acont=[" + ALLTRIM(NVL(crsart.acont,[])) + "] id_nota_pol_art=" + TRANSFORM(NVL(crsart.id_nota,0)) + LOCAL lnIdArt, lcDedus, lcMesaj, lcContDedus, lcRezultat + lnIdArt = crsart.id_articol + lcDedus = [] + IF USED('crsded') + USE IN crsded + ENDIF + lnOk = SQLEXEC(gnHandle, "select pack_facturare.cont_venit_articol_stoc(" + TRANSFORM(lnIdArt) + ") as dedus from dual", "crsded") + IF lnOk > 0 AND USED('crsded') + lcDedus = ALLTRIM(NVL(crsded.dedus,[])) + ENDIF + IF USED('crsded') + USE IN crsded + ENDIF + DO AfLog WITH " cont_venit_articol_stoc(" + TRANSFORM(lnIdArt) + ") = [" + lcDedus + "]" + lcRezultat = deriva_cont_venit_fara_pol(lnIdArt, ALLTRIM(NVL(crsart.cont,[]))) + DO AfLog WITH " deriva_cont_venit_fara_pol(id,cont) = [" + lcRezultat + "]" + lcMesaj = verifica_cont_venit_linie(lnIdArt, lnIdPolStoc) + DO AfLog WITH " verifica_cont_venit_linie = [" + lcMesaj + "]" + IF EMPTY(lcMesaj) + gnPass = gnPass + 1 + DO AfLog WITH " REZULTAT: PASS (are cont de venit)" + ELSE + gnFail = gnFail + 1 + DO AfLog WITH " REZULTAT: REPRODUS - eroarea 'nu are cont de venit'" + ENDIF + IF !ISNULL(crsart.id_nota) AND NVL(crsart.id_nota,0) > 0 + IF USED('crsnoteart') + USE IN crsnoteart + ENDIF + lnOk = SQLEXEC(gnHandle, "select n.scd, n.scc from crm_note_vanzari v join note_contabile n on n.id_set=v.id_set where v.id_nota=" + TRANSFORM(crsart.id_nota), "crsnoteart") + IF lnOk > 0 AND USED('crsnoteart') AND RECCOUNT('crsnoteart') > 0 + DO AfLog WITH " nota articolului (id_nota=" + TRANSFORM(crsart.id_nota) + "): scd=[" + ALLTRIM(NVL(crsnoteart.scd,[])) + "] scc=[" + ALLTRIM(NVL(crsnoteart.scc,[])) + "]" + ENDIF + IF USED('crsnoteart') + USE IN crsnoteart + ENDIF + ENDIF +ENDSCAN +IF USED('crsart') + USE IN crsart +ENDIF + +DO AfLog WITH "--- conturi in PLCCONT anul curent ---" +IF USED('crsplcont') + USE IN crsplcont +ENDIF +lnOk = SQLEXEC(gnHandle, "select cont from plcont where an = 2026 and trim(cont) in ('667','709','4111','704','707') order by cont", "crsplcont") +IF lnOk > 0 + SCAN + DO AfLog WITH " plcont 2026: [" + ALLTRIM(crsplcont.cont) + "]" + ENDSCAN +ENDIF +IF USED('crsplcont') + USE IN crsplcont +ENDIF + +DO Final + +PROCEDURE AfLog + LPARAMETERS tcMsg + STRTOFILE(tcMsg + CHR(13) + CHR(10), gcLog, 1) +ENDPROC + +PROCEDURE AfErr + LPARAMETERS tnErr, tcMsg, tcProg, tnLine + DO AfLog WITH "ERROR " + TRANSFORM(tnErr) + " [" + gcCaz + tcProg + ":" + TRANSFORM(tnLine) + "] " + tcMsg +ENDPROC + +PROCEDURE Final + DO AfLog WITH "TOTAL PASS=" + TRANSFORM(gnPass) + " FAIL=" + TRANSFORM(gnFail) + DO AfLog WITH "END " + TTOC(DATETIME()) + QUIT +ENDPROC diff --git a/utile/Teste/facturare_unificat/probe_cont_667b.prg b/utile/Teste/facturare_unificat/probe_cont_667b.prg new file mode 100644 index 0000000..6d34816 --- /dev/null +++ b/utile/Teste/facturare_unificat/probe_cont_667b.prg @@ -0,0 +1,157 @@ +SET SAFETY OFF +SET TALK OFF +SET NOTIFY OFF +CLOSE DATABASES + +PUBLIC gcLog, gcCaz, gnPass, gnFail +gcLog = "D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out\probe_cont_667b.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) +gcCaz = "" +gnPass = 0 +gnFail = 0 +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 +gnIdUtil = 8 +DO AfLog WITH "ENV OK" + +LOCAL lnOk, lnIdPolStoc, lcSql, lcMesaj, lnIdArt667, lcNumeArt667, lnIdArtNise, lnIdNotaOrig +lnOk = SQLEXEC(gnHandle, "select varvalue from optiuni where program='ROAFACTURARE' and varname='ID_POL_PRET_STOC'", "crsopt") +lnIdPolStoc = IIF(lnOk > 0 AND USED('crsopt') AND !ISNULL(crsopt.varvalue), VAL(ALLTRIM(crsopt.varvalue)), 0) +IF USED('crsopt') + USE IN crsopt +ENDIF +PUBLIC gnId_pol_pret_stoc +gnId_pol_pret_stoc = lnIdPolStoc +DO AfLog WITH "politica stoc id_pol=" + TRANSFORM(lnIdPolStoc) +IF lnIdPolStoc <= 0 + DO Final +ENDIF + +IF USED('crspol') + USE IN crspol +ENDIF +lnOk = SQLEXEC(gnHandle, "select nume_lista_preturi, id_nota, preturi_cu_tva from crm_politici_preturi where id_pol = " + TRANSFORM(lnIdPolStoc), "crspol") +IF lnOk > 0 AND USED('crspol') AND RECCOUNT('crspol') > 0 + lnIdNotaOrig = crspol.id_nota + DO AfLog WITH "politica nume=[" + ALLTRIM(NVL(crspol.nume_lista_preturi,[])) + "] id_nota=" + TRANSFORM(NVL(crspol.id_nota,0)) + " preturi_cu_tva=" + TRANSFORM(NVL(crspol.preturi_cu_tva,0)) +ENDIF +IF USED('crspol') + USE IN crspol +ENDIF + +IF !ISNULL(lnIdNotaOrig) AND NVL(lnIdNotaOrig,0) > 0 + IF USED('crsn') + USE IN crsn + ENDIF + lnOk = SQLEXEC(gnHandle, "select scd, scc from crm_note_vanzari v join note_contabile n on n.id_set=v.id_set where v.id_nota=" + TRANSFORM(lnIdNotaOrig), "crsn") + IF lnOk > 0 AND USED('crsn') AND RECCOUNT('crsn') > 0 + DO AfLog WITH "nota politicii: scd=[" + ALLTRIM(NVL(crsn.scd,[])) + "] scc=[" + ALLTRIM(NVL(crsn.scc,[])) + "]" + ENDIF + IF USED('crsn') + USE IN crsn + ENDIF +ENDIF + +IF USED('crsart') + USE IN crsart +ENDIF +lnOk = SQLEXEC(gnHandle, "select a.id_articol, e.denumire from crm_politici_pret_art a join nom_articole e on e.id_articol=a.id_articol where a.id_pol=" + TRANSFORM(lnIdPolStoc) + " and trim(e.cont)='667' and rownum=1", "crsart") +IF lnOk > 0 AND USED('crsart') AND RECCOUNT('crsart') = 1 + lnIdArt667 = crsart.id_articol + lcNumeArt667 = ALLTRIM(NVL(crsart.denumire,[])) +ENDIF +IF USED('crsart') + USE IN crsart +ENDIF +IF USED('crsartn') + USE IN crsartn +ENDIF +lnOk = SQLEXEC(gnHandle, "select a.id_articol, e.denumire from crm_politici_pret_art a join nom_articole e on e.id_articol=a.id_articol where a.id_pol=" + TRANSFORM(lnIdPolStoc) + " and trim(e.cont)='371' and rownum=1", "crsartn") +IF lnOk > 0 AND USED('crsartn') AND RECCOUNT('crsartn') = 1 + lnIdArtNise = crsartn.id_articol +ENDIF +IF USED('crsartn') + USE IN crsartn +ENDIF + +DO AfLog WITH "--- STARE CURENTA (cu nota politicii setata) ---" +lcMesaj = verifica_cont_venit_linie(lnIdArt667, lnIdPolStoc) +DO AfLog WITH "667 [" + lcNumeArt667 + "] -> [" + lcMesaj + "]" +IF !EMPTY(lcMesaj) + gnFail = gnFail + 1 +ELSE + gnPass = gnPass + 1 +ENDIF +IF lnIdArtNise > 0 + lcMesaj = verifica_cont_venit_linie(lnIdArtNise, lnIdPolStoc) + DO AfLog WITH "371 art=" + TRANSFORM(lnIdArtNise) + " -> [" + lcMesaj + "]" +ENDIF + +DO AfLog WITH "--- REPRODUCERE: id_nota politica = NULL (tranzactie, ROLLBACK la final) ---" +lnOk = SQLEXEC(gnHandle, "UPDATE crm_politici_preturi SET id_nota = NULL WHERE id_pol = " + TRANSFORM(lnIdPolStoc)) +DO AfLog WITH "update id_nota=NULL lnOk=" + TRANSFORM(lnOk) +lcMesaj = verifica_cont_venit_linie(lnIdArt667, lnIdPolStoc) +DO AfLog WITH "667 art=" + TRANSFORM(lnIdArt667) + " fara nota politica -> [" + lcMesaj + "]" +IF !EMPTY(lcMesaj) + gnPass = gnPass + 1 + DO AfLog WITH "REPRODUS: eroarea 'nu are cont de venit' apare cand politica nu are nota si articolul e 667" +ELSE + gnFail = gnFail + 1 + DO AfLog WITH "NU S-A REPRODUS" +ENDIF +lcMesaj = deriva_cont_venit_fara_pol(lnIdArt667, "667") +DO AfLog WITH "deriva_cont_venit_fara_pol(667,667)=[" + lcMesaj + "]" + +DO AfLog WITH "--- simulare cursor_articol Oracle pentru articolul 667, fara nota politica ---" +lcSql = "select nvl(pack_facturare.nid_venchelt, nvl(a.id_venchelt, 0)) as id_venchelt, " + ; + "(case when " + TRANSFORM(lnIdPolStoc) + " = 0 then nvl(a.id_nota, b.id_nota) else b.id_nota end) as nota_fol, " + ; + "d.scd as scd, d.scc as scc, d.id_set " + ; + "from crm_politici_pret_art a " + ; + "left join crm_politici_preturi b on a.id_pol = b.id_pol " + ; + "left join crm_note_vanzari c on (case when a.id_pol = " + TRANSFORM(lnIdPolStoc) + " then nvl(a.id_nota, b.id_nota) else b.id_nota end) = c.id_nota " + ; + "left join note_contabile d on d.id_set = c.id_set " + ; + "where a.id_pol = " + TRANSFORM(lnIdPolStoc) + " and a.id_articol = " + TRANSFORM(lnIdArt667) +IF USED('crssim') + USE IN crssim +ENDIF +lnOk = SQLEXEC(gnHandle, lcSql, "crssim") +IF lnOk > 0 AND USED('crssim') + IF RECCOUNT('crssim') > 0 + DO AfLog WITH "Oracle ar folosi nota " + TRANSFORM(NVL(crssim.nota_fol,0)) + " -> scd=[" + ALLTRIM(NVL(crssim.scd,[])) + "] scc=[" + ALLTRIM(NVL(crssim.scc,[])) + "] => daca scc e gol, FACT-033 'nu are cont de venit'" + ELSE + DO AfLog WITH "Oracle: zero randuri pentru articol in politica" + ENDIF +ENDIF +IF USED('crssim') + USE IN crssim +ENDIF + +DO Final + +PROCEDURE AfLog + LPARAMETERS tcMsg + STRTOFILE(tcMsg + CHR(13) + CHR(10), gcLog, 1) +ENDPROC + +PROCEDURE AfErr + LPARAMETERS tnErr, tcMsg, tcProg, tnLine + DO AfLog WITH "ERROR " + TRANSFORM(tnErr) + " [" + gcCaz + tcProg + ":" + TRANSFORM(tnLine) + "] " + tcMsg +ENDPROC + +PROCEDURE Final + IF TYPE('gnHandle') = 'N' AND gnHandle > 0 + SQLEXEC(gnHandle, "ROLLBACK") + DO AfLog WITH "ROLLBACK trimis" + ENDIF + DO AfLog WITH "TOTAL PASS=" + TRANSFORM(gnPass) + " FAIL=" + TRANSFORM(gnFail) + DO AfLog WITH "END " + TTOC(DATETIME()) + QUIT +ENDPROC diff --git a/utile/Teste/facturare_unificat/probe_cont_667c.prg b/utile/Teste/facturare_unificat/probe_cont_667c.prg new file mode 100644 index 0000000..014c005 --- /dev/null +++ b/utile/Teste/facturare_unificat/probe_cont_667c.prg @@ -0,0 +1,72 @@ +SET SAFETY OFF +SET TALK OFF +SET NOTIFY OFF +CLOSE DATABASES + +PUBLIC gcLog +gcLog = "D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out\probe_cont_667c.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) +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 +gnIdUtil = 8 + +DO AfLog WITH "=== politici (id_pol, nume, id_nota, nota scd/scc) ===" +SQLEXEC(gnHandle, "select p.id_pol, p.nume_lista_preturi, p.id_nota, n.scd, n.scc from crm_politici_preturi p left join crm_note_vanzari v on v.id_nota=p.id_nota left join note_contabile n on n.id_set=v.id_set order by p.id_pol", "crspol") +IF USED('crspol') + SCAN + DO AfLog WITH " id_pol=" + TRANSFORM(crspol.id_pol) + " nume=[" + ALLTRIM(NVL(crspol.nume_lista_preturi,[])) + "] id_nota=" + TRANSFORM(NVL(crspol.id_nota,0)) + " scd=[" + ALLTRIM(NVL(crspol.scd,[])) + "] scc=[" + ALLTRIM(NVL(crspol.scc,[])) + "]" + ENDSCAN + USE IN crspol +ENDIF + +DO AfLog WITH "=== randuri crm_politici_pret_art cu id_nota propriu ===" +SQLEXEC(gnHandle, "select a.id_pol, a.id_articol, e.denumire, e.cont, a.id_nota, n.scd, n.scc from crm_politici_pret_art a join nom_articole e on e.id_articol=a.id_articol left join crm_note_vanzari v on v.id_nota=a.id_nota left join note_contabile n on n.id_set=v.id_set where a.id_nota is not null order by a.id_pol, a.id_articol", "crsartnota") +IF USED('crsartnota') + SCAN + DO AfLog WITH " pol=" + TRANSFORM(crsartnota.id_pol) + " art=" + TRANSFORM(crsartnota.id_articol) + " [" + ALLTRIM(NVL(crsartnota.denumire,[])) + "] cont=[" + ALLTRIM(NVL(crsartnota.cont,[])) + "] id_nota=" + TRANSFORM(crsartnota.id_nota) + " scd=[" + ALLTRIM(NVL(crsartnota.scd,[])) + "] scc=[" + ALLTRIM(NVL(crsartnota.scc,[])) + "]" + ENDSCAN + USE IN crsartnota +ENDIF + +DO AfLog WITH "=== articole nomenclator cu cont 667/709/267/2678 ===" +SQLEXEC(gnHandle, "select id_articol, denumire, cont, acont, sters from nom_articole where trim(cont) in ('667','709','267','2678') order by cont, id_articol", "crsnom") +IF USED('crsnom') + SCAN + DO AfLog WITH " art=" + TRANSFORM(crsnom.id_articol) + " cont=[" + ALLTRIM(NVL(crsnom.cont,[])) + "] acont=[" + ALLTRIM(NVL(crsnom.acont,[])) + "] sters=" + TRANSFORM(NVL(crsnom.sters,0)) + " [" + ALLTRIM(NVL(crsnom.denumire,[])) + "]" + ENDSCAN + USE IN crsnom +ENDIF + +DO AfLog WITH "=== plcont 2026 pentru conturile de discount ===" +SQLEXEC(gnHandle, "select cont from plcont where an=2026 and substr(trim(cont),1,3) in ('667','709','267') order by cont", "crspl") +IF USED('crspl') + SCAN + DO AfLog WITH " plcont=[" + ALLTRIM(crspl.cont) + "]" + ENDSCAN + USE IN crspl +ENDIF + +DO Final + +PROCEDURE AfLog + LPARAMETERS tcMsg + STRTOFILE(tcMsg + CHR(13) + CHR(10), gcLog, 1) +ENDPROC + +PROCEDURE AfErr + LPARAMETERS tnErr, tcMsg, tcProg, tnLine + DO AfLog WITH "ERROR " + TRANSFORM(tnErr) + " [" + tcProg + ":" + TRANSFORM(tnLine) + "] " + tcMsg +ENDPROC + +PROCEDURE Final + DO AfLog WITH "END " + TTOC(DATETIME()) + QUIT +ENDPROC diff --git a/utile/Teste/facturare_unificat/probe_cont_667d.prg b/utile/Teste/facturare_unificat/probe_cont_667d.prg new file mode 100644 index 0000000..c8ad0b4 --- /dev/null +++ b/utile/Teste/facturare_unificat/probe_cont_667d.prg @@ -0,0 +1,57 @@ +SET SAFETY OFF +SET TALK OFF +SET NOTIFY OFF +CLOSE DATABASES + +PUBLIC gcLog +gcLog = "D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out\probe_cont_667d.log" +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 +gnIdUtil = 8 + +LOCAL lcSql +lcSql = "select a.id_pol, a.id_articol, e.denumire, e.cont, a.id_nota " +lcSql = lcSql + "from crm_politici_pret_art a, nom_articole e " +lcSql = lcSql + "where a.id_articol = e.id_articol and a.id_nota is not null " +lcSql = lcSql + "order by a.id_pol, a.id_articol" +DO AfLog WITH "=== randuri crm_politici_pret_art cu id_nota propriu ===" +SQLEXEC(gnHandle, lcSql, "crsartnota") +IF USED('crsartnota') + SCAN + DO AfLog WITH " pol=" + TRANSFORM(crsartnota.id_pol) + " art=" + TRANSFORM(crsartnota.id_articol) + " [" + ALLTRIM(NVL(crsartnota.denumire,[])) + "] cont=[" + ALLTRIM(NVL(crsartnota.cont,[])) + "] id_nota=" + TRANSFORM(crsartnota.id_nota) + ENDSCAN + USE IN crsartnota +ELSE + DO AfLog WITH " (niciunul sau select esuat)" +ENDIF + +DO AfLog WITH "=== politica de stoc din OPTIUNI ===" +SQLEXEC(gnHandle, "select varvalue from optiuni where program='ROAFACTURARE' and varname='ID_POL_PRET_STOC'", "crsopt") +IF USED('crsopt') AND RECCOUNT('crsopt') = 1 + DO AfLog WITH " ID_POL_PRET_STOC = [" + ALLTRIM(NVL(crsopt.varvalue,[])) + "]" +ENDIF +IF USED('crsopt') + USE IN crsopt +ENDIF + +DO Final + +PROCEDURE AfLog + LPARAMETERS tcMsg + STRTOFILE(tcMsg + CHR(13) + CHR(10), gcLog, 1) +ENDPROC + +PROCEDURE AfErr + LPARAMETERS tnErr, tcMsg, tcProg, tnLine + DO AfLog WITH "ERROR " + TRANSFORM(tnErr) + " [" + tcProg + ":" + TRANSFORM(tnLine) + "] " + tcMsg +ENDPROC + +PROCEDURE Final + DO AfLog WITH "END " + TTOC(DATETIME()) + QUIT +ENDPROC diff --git a/utile/Teste/facturare_unificat/probe_e2e_cont_667.prg b/utile/Teste/facturare_unificat/probe_e2e_cont_667.prg new file mode 100644 index 0000000..13f76f7 --- /dev/null +++ b/utile/Teste/facturare_unificat/probe_e2e_cont_667.prg @@ -0,0 +1,296 @@ +* probe_e2e_cont_667.prg +* E2E (Pas 4 din docs\handoff_cont_discount_667_709.md): articol cu cont=667 din catalog +* articole (politica de stoc) salvat prin clasa REALA cus_pret_nomenclator, cu conturi analitice, +* si verificat capat-la-capat pe MARIUSM_AUTO: +* - nota per-articol scrisa de pack_preturi.gaseste_creeaza_nota_vanzare (overload 6 arg): +* SCD=667 / ASCD / SCC=4111 / ASCC +* - verifica_cont_venit_linie() = [] (nu mai blocheaza linia) +* - rezolvarea din cursor_articol (pack_facturare) aduce 667/4111 + analiticele, NU contul de +* venit al politicii - deci scrie_nota va aplica semnul negativ (V_SCD in 667/267/2678/709) +* - fallback: articol de discount fara conturi primeste automat nota implicita 667=4111 +* - valideaza: analitic fara cont sintetic = refuz +* TOTUL ruleaza in TRANZACTIE MANUALA (SQLSETPROP Transactions=2) si se inchide cu ROLLBACK - +* nicio scriere nu ramane in schema (vezi capcana din handoff sectiunea 7). +* +* Rulare: vfp9.exe -A -T "...\probe_e2e_cont_667.prg" (dupa _precompile.ps1) +* Log: D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out\probe_e2e_cont_667.log + +SET SAFETY OFF +SET TALK OFF +SET NOTIFY OFF +SET DELETED ON +SET EXACT ON +SET NULLDISPLAY TO '' +CLOSE DATABASES + +PUBLIC gcLog, gnPass, gnFail, gcCaz +gcLog = "D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out\probe_e2e_cont_667.log" +IF !DIRECTORY(JUSTPATH(gcLog)) + MD JUSTPATH(gcLog) +ENDIF +STRTOFILE("START " + TTOC(DATETIME()) + CHR(13) + CHR(10), gcLog) +gnPass = 0 +gnFail = 0 +gcCaz = "" +ON ERROR DO E2eErr 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 E2eLog WITH "FAIL: conexiune Oracle esuata" + DO E2eFinal +ENDIF +gnIdUtil = 8 +SQLSETPROP(gnHandle, "QueryTimeOut", 60) +DO E2eLog WITH "ENV OK (gnHandle=" + TRANSFORM(gnHandle) + ")" + +LOCAL lnIdPolStoc, lnArt, lnIdNotaInitial, lnIdNotaNou, llOk +LOCAL lcScd, lcAscd, lcScc, lcAscc, lcRezScd, lcRezAscd, lcRezScc, lcRezAscc, lcMsg +LOCAL loC, loC2, llTranzactieDeschisa + +*----------------- pregatire: politica de stoc + un articol de discount --------------- +gcCaz = "[setup] " +IF Used('crsoptstoc') + Use In crsoptstoc +ENDIF +goExecutor.oExecute([select varvalue from optiuni where program = 'ROAFACTURARE' and varname = 'ID_POL_PRET_STOC'], 'crsoptstoc') +lnIdPolStoc = 0 +IF Used('crsoptstoc') And Reccount('crsoptstoc') = 1 + lnIdPolStoc = Val(Alltrim(Nvl(crsoptstoc.varvalue, '0'))) +ENDIF +IF Used('crsoptstoc') + Use In crsoptstoc +ENDIF +DO Assert WITH lnIdPolStoc > 0, "politica de stoc rezolvata din OPTIUNI (id=" + TRANSFORM(lnIdPolStoc) + ")" + +IF Used('crsart667') + Use In crsart667 +ENDIF +goExecutor.oExecute([select a.id_articol, e.cont, e.denumire, a.id_nota from crm_politici_pret_art a, nom_articole e ] + ; + [where a.id_pol = ] + TRANSFORM(lnIdPolStoc) + [ and a.id_articol = e.id_articol ] + ; + [ and trim(e.cont) in ('667','709') order by a.id_articol], 'crsart667') +DO Assert WITH Used('crsart667') And Reccount('crsart667') > 0, "exista articole cu cont 667/709 in politica de stoc (count=" + TRANSFORM(Iif(Used('crsart667'), Reccount('crsart667'), -1)) + ")" +lnArt = 0 +lnIdNotaInitial = -1 +IF Used('crsart667') And Reccount('crsart667') > 0 + lnArt = crsart667.id_articol + lnIdNotaInitial = Iif(Isnull(crsart667.id_nota), 0, crsart667.id_nota) + DO E2eLog WITH " articol test=" + TRANSFORM(lnArt) + " cont=" + Alltrim(Nvl(crsart667.cont, [])) + " id_nota initial=" + TRANSFORM(lnIdNotaInitial) +ENDIF +IF Used('crsart667') + Use In crsart667 +ENDIF +IF lnArt = 0 + DO E2eLog WITH "ABANDON: nu am articol de test" + DO E2eFinal +ENDIF + +*----------------- TRANZACTIE MANUALA (orice scriere de mai jos se anuleaza) ---------- +gcCaz = "[tranzactie] " +llTranzactieDeschisa = MyDeschideTranzactie() +DO Assert WITH llTranzactieDeschisa, "tranzactie manuala deschisa (SQLSETPROP Transactions=2)" + +IF llTranzactieDeschisa + + *--- 1. incarca prin clasa: conturile notei curente (667=4111) --------------------- + gcCaz = "[1-incarca] " + loC = CREATEOBJECT('cus_pret_nomenclator') + llOk = loC.incarca(lnArt) + DO Assert WITH llOk, "cus_pret_nomenclator.incarca(" + TRANSFORM(lnArt) + ") = .T." + DO Assert WITH loC.nIdPolitica = lnIdPolStoc, "nIdPolitica=" + TRANSFORM(loC.nIdPolitica) + " (asteptat " + TRANSFORM(lnIdPolStoc) + ")" + DO Assert WITH Alltrim(loC.cScd) = "667", "cScd incarcat=[" + Alltrim(loC.cScd) + "] (asteptat 667)" + DO Assert WITH Alltrim(loC.cScc) = "4111", "cScc incarcat=[" + Alltrim(loC.cScc) + "] (asteptat 4111)" + + *--- 2. salveaza cu analitice (calea reala salveaza -> RPC 6 arg -> nota) ----------- + gcCaz = "[2-salveaza-analitice] " + loC.cScd = "667" + loC.cAscd = "11" + loC.cScc = "4111" + loC.cAscc = "12" + llOk = loC.salveaza(lnArt) + DO Assert WITH llOk, "cus_pret_nomenclator.salveaza(" + TRANSFORM(lnArt) + ") = .T." + + IF Used('crsnotanova') + Use In crsnotanova + ENDIF + goExecutor.oExecute([select a.id_nota, n.scd, n.ascd, n.scc, n.ascc from crm_politici_pret_art a, crm_note_vanzari v, note_contabile n ] + ; + [where a.id_pol = ] + TRANSFORM(lnIdPolStoc) + [ and a.id_articol = ] + TRANSFORM(lnArt) + ; + [ and v.id_nota = a.id_nota and n.id_set = v.id_set], 'crsnotanova') + lnIdNotaNou = 0 + IF Used('crsnotanova') And Reccount('crsnotanova') > 0 + lcScd = Alltrim(Nvl(crsnotanova.scd, [])) + lcAscd = Alltrim(Nvl(crsnotanova.ascd, [])) + lcScc = Alltrim(Nvl(crsnotanova.scc, [])) + lcAscc = Alltrim(Nvl(crsnotanova.ascc, [])) + lnIdNotaNou = crsnotanova.id_nota + DO E2eLog WITH " nota noua id=" + TRANSFORM(lnIdNotaNou) + " : " + lcScd + "/" + lcAscd + " = " + lcScc + "/" + lcAscc + ENDIF + IF Used('crsnotanova') + Use In crsnotanova + ENDIF + DO Assert WITH lnIdNotaNou > 0 And lnIdNotaNou <> lnIdNotaInitial, "nota per-articol noua scrisa (id=" + TRANSFORM(lnIdNotaNou) + ", initial=" + TRANSFORM(lnIdNotaInitial) + ")" + DO Assert WITH lcScd = "667", "nota SCD=[" + lcScd + "] (asteptat 667)" + DO Assert WITH lcAscd = "11", "nota ASCD=[" + lcAscd + "] (asteptat 11)" + DO Assert WITH lcScc = "4111", "nota SCC=[" + lcScc + "] (asteptat 4111)" + DO Assert WITH lcAscc = "12", "nota ASCC=[" + lcAscc + "] (asteptat 12)" + + *--- 3. verifica_cont_venit_linie: linia nu mai e blocata ------------------------- + gcCaz = "[3-verifica_cont_venit_linie] " + gnId_pol_pret_stoc = lnIdPolStoc + lcMsg = verifica_cont_venit_linie(lnArt, lnIdPolStoc) + DO Assert WITH Empty(lcMsg), "verifica_cont_venit_linie = [] (obtinut [" + lcMsg + "])" + + *--- 4. rezolvarea din cursor_articol (pack_facturare) ---------------------------- + gcCaz = "[4-cursor_articol] " + IF Used('crsrezart') + Use In crsrezart + ENDIF + goExecutor.oExecute([select d.scd as scd_rez, d.ascd as ascd_rez, d.scc as scc_rez, d.ascc as ascc_rez ] + ; + [from crm_politici_pret_art a ] + ; + [left join crm_politici_preturi b on a.id_pol = b.id_pol ] + ; + [left join crm_note_vanzari c on c.id_nota = (case when a.id_pol = ] + TRANSFORM(lnIdPolStoc) + [ then nvl(a.id_nota, b.id_nota) else b.id_nota end) ] + ; + [left join note_contabile d on d.id_set = c.id_set ] + ; + [where a.id_pol = ] + TRANSFORM(lnIdPolStoc) + [ and a.id_articol = ] + TRANSFORM(lnArt), 'crsrezart') + lcRezScd = "" + lcRezAscd = "" + lcRezScc = "" + lcRezAscc = "" + IF Used('crsrezart') And Reccount('crsrezart') > 0 + lcRezScd = Alltrim(Nvl(crsrezart.scd_rez, [])) + lcRezAscd = Alltrim(Nvl(crsrezart.ascd_rez, [])) + lcRezScc = Alltrim(Nvl(crsrezart.scc_rez, [])) + lcRezAscc = Alltrim(Nvl(crsrezart.ascc_rez, [])) + ENDIF + IF Used('crsrezart') + Use In crsrezart + ENDIF + DO E2eLog WITH " rezolvare: " + lcRezScd + "/" + lcRezAscd + " = " + lcRezScc + "/" + lcRezAscc + DO Assert WITH lcRezScd = "667", "rezolvare SCD=[" + lcRezScd + "] (asteptat 667, nu contul politicii)" + DO Assert WITH lcRezScc = "4111", "rezolvare SCC=[" + lcRezScc + "] (asteptat 4111, nu contul de venit al politicii)" + DO Assert WITH lcRezAscd = "11" And lcRezAscc = "12", "rezolvare analitice=[" + lcRezAscd + "/" + lcRezAscc + "] (asteptat 11/12)" + + *--- 5. reincarca: clasa citeste analiticele inapoi ------------------------------- + gcCaz = "[5-reincarca] " + loC2 = CREATEOBJECT('cus_pret_nomenclator') + llOk = loC2.incarca(lnArt) + DO Assert WITH llOk And Alltrim(loC2.cAscd) = "11" And Alltrim(loC2.cAscc) = "12", ; + "reincarca citeste analiticele (ascd=[" + Alltrim(loC2.cAscd) + "] ascc=[" + Alltrim(loC2.cAscc) + "])" + + *--- 6. valideaza: analitic fara sintetic = refuz --------------------------------- + gcCaz = "[6-valideaza] " + loC2.cAscd = "11" + loC2.cScd = [] + llOk = loC2.valideaza() + DO Assert WITH !llOk And "analitic debitor" $ Lower(loC2.cEroare), "valideaza refuza analitic fara sintetic (mesaj=[" + loC2.cEroare + "])" + + *--- 7. fallback: articol de discount fara conturi -> nota implicita 667=4111 ----- + gcCaz = "[7-fallback-asigura] " + loC2.cScd = [] + loC2.cAscd = [] + loC2.cScc = [] + loC2.cAscc = [] + llOk = loC2.salveaza(lnArt) + IF Used('crsnotafb') + Use In crsnotafb + ENDIF + goExecutor.oExecute([select a.id_nota, n.scd, n.scc from crm_politici_pret_art a, crm_note_vanzari v, note_contabile n ] + ; + [where a.id_pol = ] + TRANSFORM(lnIdPolStoc) + [ and a.id_articol = ] + TRANSFORM(lnArt) + ; + [ and v.id_nota = a.id_nota and n.id_set = v.id_set], 'crsnotafb') + lcScd = "" + lcScc = "" + lnIdNotaNou = 0 + IF Used('crsnotafb') And Reccount('crsnotafb') > 0 + lcScd = Alltrim(Nvl(crsnotafb.scd, [])) + lcScc = Alltrim(Nvl(crsnotafb.scc, [])) + lnIdNotaNou = crsnotafb.id_nota + ENDIF + IF Used('crsnotafb') + Use In crsnotafb + ENDIF + DO Assert WITH llOk, "salveaza fara conturi pe articol de discount = .T." + DO Assert WITH lcScd = "667" And lcScc = "4111", "fallback a creat/refolosit nota 667=4111 (scd=[" + lcScd + "] scc=[" + lcScc + "])" + + *--- ROLLBACK --------------------------------------------------------------------- + gcCaz = "[rollback] " + loC = .NULL. + loC2 = .NULL. + llOk = MyInchideTranzactie(2) + DO Assert WITH llOk, "ROLLBACK executat (nimic nu ramane in schema)" +ENDIF + +*----------------- verificare post-rollback (conexiune noua, autocommit) -------------- +gcCaz = "[post-rollback] " +IF Used('crsverifrb') + Use In crsverifrb +ENDIF +goExecutor.oExecute([select a.id_nota, n.scd, n.ascd, n.scc, n.ascc from crm_politici_pret_art a, crm_note_vanzari v, note_contabile n ] + ; + [where a.id_pol = ] + TRANSFORM(lnIdPolStoc) + [ and a.id_articol = ] + TRANSFORM(lnArt) + ; + [ and v.id_nota = a.id_nota and n.id_set = v.id_set], 'crsverifrb') +DO Assert WITH Used('crsverifrb') And Reccount('crsverifrb') = 1 And ; + Alltrim(Nvl(crsverifrb.scd, [])) = "667" And Alltrim(Nvl(crsverifrb.scc, [])) = "4111", ; + "post-rollback articolul are din nou nota initiala 667=4111 (id=" + TRANSFORM(Iif(Used('crsverifrb'), crsverifrb.id_nota, 0)) + ")" +DO Assert WITH !(Used('crsverifrb') And Alltrim(Nvl(crsverifrb.ascd, [])) = "11"), "post-rollback analiticul 11 NU a supravietuit (ascd=[" + Alltrim(Nvl(Iif(Used('crsverifrb'), crsverifrb.ascd, ''), [])) + "])" +IF Used('crsverifrb') + Use In crsverifrb +ENDIF + +*----------------- rezumat ----------------------------------------------------------------- +gcCaz = "" +DO E2eLog WITH "" +DO E2eLog WITH "REZULTAT: " + TRANSFORM(gnPass) + " PASS / " + TRANSFORM(gnFail) + " FAIL" +DO E2eFinal + +*========================================================================================== +PROCEDURE E2eLog + LPARAMETERS tcMsg + STRTOFILE(tcMsg + CHR(13) + CHR(10), gcLog, 1) +ENDPROC + +PROCEDURE E2eErr + LPARAMETERS tnErr, tcMsg, tcProg, tnLine + DO E2eLog WITH "ERROR " + TRANSFORM(tnErr) + " [" + tcProg + ":" + TRANSFORM(tnLine) + "] " + tcMsg +ENDPROC + +PROCEDURE Assert + LPARAMETERS tlCond, tcMsg + IF tlCond + gnPass = gnPass + 1 + DO E2eLog WITH "PASS: " + gcCaz + tcMsg + ELSE + gnFail = gnFail + 1 + DO E2eLog WITH "FAIL: " + gcCaz + tcMsg + ENDIF +ENDPROC + +*-- _frm_base.vc2 do_deschide_tranzactie: Transactions=2 +PROCEDURE MyDeschideTranzactie + LOCAL llReturn, lnSuccesLocal + IF TYPE('goExecutor') = 'O' + goExecutor.oExecuta([select * from dual]) + ENDIF + lnSuccesLocal = SQLSETPROP(gnHandle, "Transactions", 2) + llReturn = IIF(lnSuccesLocal < 0, .F., .T.) + RETURN llReturn +ENDPROC + +*-- _frm_base.vc2 do_inchide_tranzactie: 1=commit, altfel rollback +PROCEDURE MyInchideTranzactie + LPARAMETERS tnTip + LOCAL llReturn, lnSuccesLocal + IF tnTip = 1 + lnSuccesLocal = SQLCOMMIT(gnHandle) + ELSE + lnSuccesLocal = SQLROLLBACK(gnHandle) + ENDIF + IF lnSuccesLocal < 0 + llReturn = .F. + ELSE + lnSuccesLocal = SQLSETPROP(gnHandle, "Transactions", 1) + llReturn = IIF(lnSuccesLocal < 0, .F., .T.) + ENDIF + RETURN llReturn +ENDPROC + +PROCEDURE E2eFinal + DO E2eLog WITH "END " + TTOC(DATETIME()) + QUIT +ENDPROC diff --git a/utile/Teste/facturare_unificat/probe_e2e_cont_667_semn.sql b/utile/Teste/facturare_unificat/probe_e2e_cont_667_semn.sql new file mode 100644 index 0000000..4c90a25 --- /dev/null +++ b/utile/Teste/facturare_unificat/probe_e2e_cont_667_semn.sql @@ -0,0 +1,73 @@ +-- probe_e2e_cont_667_semn.sql +-- E2E (Pas 4, partea Oracle): dovada ca pack_facturare.scrie_nota aplica SEMNUL NEGATIV pentru +-- linia de discount generata de fix (SCD=667, ASCD=11, SCC=4111, ASCC=12) - suma scrisa in +-- ACT_TEMP iese negativa, exact ca la articolele 667 din catalogul de articole. +-- Semnul nu e cod nou: regula V_SCD in ('667','267','2678','709') exista deja in scrie_nota +-- (ff_2026_09_16_04_COMUN_PACK_FACTURARE.sql:12879-12887). +-- +-- Ruleaza in TRANZACTIE si se inchide cu ROLLBACK - nu ramane nimic in ACT_TEMP. +-- Rulare: +-- sqlplus MARIUSM_AUTO/@ROA_CENTRAL @probe_e2e_cont_667_semn.sql +-- Rezultat asteptat: E2E2|SUMA=-84.03|SCD=667|SCC=4111|ret=84.03 si ramase_667=0 + +set serveroutput on size 100000 +set feedback off pagesize 200 linesize 250 heading off + +begin + pack_sesiune.set_id_util(8); + pack_sesiune.setluna(8); + pack_sesiune.setan(2026); + pack_sesiune.setlunabal(8); + pack_sesiune.setanbal(2026); + pack_contafin.SET_DATA_RON('MARIUSM_AUTO'); + pack_sesiune.set_data_ron('MARIUSM_AUTO'); + pack_contafin.set_id_sucursala(110); + pack_contafin.set_id_firma(110); +end; +/ + +declare + v_ret number; + v_suma act_temp.suma%type; + v_scd act_temp.scd%type; + v_scc act_temp.scc%type; + v_idval number; + v_idact number; +begin + pack_facturare.nid_util := 8; + pack_facturare.ntip := 1; + pack_facturare.nin_valuta := 0; + v_idval := pack_def.GetIdMonedaNationala(); + pack_facturare.nid_moneda_nationala := v_idval; + select nvl(max(id_act), 0) into v_idact from act_temp; + pack_facturare.nid_act := v_idact; + pack_facturare.nnumar_act := 999999; + pack_facturare.nnumar_bon := 0; + pack_facturare.cserie_act := 'TESTE2E'; + pack_facturare.ddata_ireg := sysdate; + pack_facturare.ddata_act := sysdate; + pack_facturare.ddata_scadenta := sysdate; + pack_facturare.nid_fdoc := 0; + pack_facturare.nid_part := 0; + pack_facturare.nid_partc := 0; + pack_facturare.nid_factc := 0; + pack_facturare.nperechec := 0; + pack_facturare.cexplicatia4 := null; + pack_facturare.nid_responsabil := 0; + pack_facturare.nid_jtva_coloana := null; + pack_facturare.nTaxCode := null; + pack_facturare.nproc_tva_max := 0; + pack_facturare.nid_politica_stoc := 41; + + v_ret := pack_facturare.scrie_nota(1, 100, 0, 1, v_idval, 0, 1, 0, 0, 0, + 'E2E DISCOUNT 667', '667', '11', '4111', '12', 0, 0, 0, 0, 19, null, null, null); + + select suma, scd, scc into v_suma, v_scd, v_scc from act_temp where id_act = pack_facturare.nid_act; + dbms_output.put_line('E2E2|SUMA=' || v_suma || '|SCD=' || v_scd || '|SCC=' || v_scc || '|ret=' || v_ret); +end; +/ + +rollback; +prompt ROLLBACK EFECTUAT +select count(*) ramase_667 from act_temp where scd = '667' and serie_act = 'TESTE2E'; +exit diff --git a/utile/Teste/facturare_unificat/probe_e2e_cont_667_ui.prg b/utile/Teste/facturare_unificat/probe_e2e_cont_667_ui.prg new file mode 100644 index 0000000..836e062 --- /dev/null +++ b/utile/Teste/facturare_unificat/probe_e2e_cont_667_ui.prg @@ -0,0 +1,125 @@ +* probe_e2e_cont_667_ui.prg +* E2E (Pas 3 din docs\handoff_cont_discount_667_709.md): smoke UI pe frm_catalog_articole_nou +* (COMUN\clase\onom_articole.vc2), pagina Page3 "Vanzare" - dovedeste ca dupa write-back-ul .vcx: +* - formularul se instantiaza fara eroare (Init-ul seteaza noile ControlSource-uri, deci un obiect +* Text1 lipsa ar pica aici); +* - pe Clb_tx_scd si Clb_tx_scc exista copilul Text1 (analitic debitor/creditor), MaxLength=4; +* - ControlSource-urile sunt legate la Thisform.oPretNom.cAscd / cAscc. +* O SINGURA instantiere per proces (a doua se autoblocheaza - vezi probe_12b_s6c_fisa_pagina_vanzare). +* Nu scrie in Oracle; ROLLBACK de siguranta la final. +* +* Rulare: vfp9.exe -A "...\probe_e2e_cont_667_ui.prg" +* Log: D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out\probe_e2e_cont_667_ui.log + +SET SAFETY OFF +SET TALK OFF +SET NOTIFY OFF +CLOSE DATABASES + +PUBLIC gcLog, gnPass, gnFail, gcCaz +gcLog = "D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out\probe_e2e_cont_667_ui.log" +STRTOFILE("START " + TTOC(DATETIME()) + CHR(13) + CHR(10), gcLog) +gnPass = 0 +gnFail = 0 +gcCaz = "" +ON ERROR DO UiErr 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 UiLog WITH "FAIL: conexiune Oracle esuata" + DO UiFinal +ENDIF +gnIdUtil = 8 +SQLSETPROP(gnHandle, "QueryTimeOut", 60) + +SET PATH TO (gcAppPath + "COMUN\CLASE") ADDITIVE +SET CLASSLIB TO (gcAppPath + "COMUN\CLASE\ofacturare.vcx") ADDITIVE +SET CLASSLIB TO (gcAppPath + "COMUN\CLASE\onom_articole.vcx") ADDITIVE + +update_um() +update_um_iso() +update_grupe_art() +update_subgrupe_art() + +LOCAL lnIdArt, lnOk, loRec, loForm, llCrapat, lcErrMsg, lnErrNo, loPage3 +lnIdArt = 4294507213 +gcCaz = "[setup] " +lnOk = goExecutor.oExecuta('select * from vnom_articole where id_articol = ' + TRANSFORM(lnIdArt), 'vnom_articole_nou') +DO Assert WITH lnOk # .F. AND USED('vnom_articole_nou') AND RECCOUNT('vnom_articole_nou') = 1, "select vnom_articole pentru articolul " + TRANSFORM(lnIdArt) +SELECT vnom_articole_nou +SCATTER NAME loRec MEMO +loRec.conditii_pastrare = NVL(loRec.conditii_pastrare, '') +USE IN vnom_articole_nou + +PUBLIC gcNumeProgram +gcNumeProgram = 'ROAFACTURARE' +PRIVATE poRec, pnIdAMS +poRec = loRec +pnIdAMS = lnIdArt + +llCrapat = .F. +lcErrMsg = '' +lnErrNo = 0 +TRY + loForm = CREATEOBJECT('frm_catalog_articole_nou', loRec, lnIdArt, 'UPDATE') +CATCH TO loExc + llCrapat = .T. + lnErrNo = loExc.ErrorNo + lcErrMsg = loExc.Message +ENDTRY +DO UiLog WITH " CREATEOBJECT: llCrapat=" + TRANSFORM(llCrapat) + " errno=" + TRANSFORM(lnErrNo) + " mesaj=[" + lcErrMsg + "]" + +gcCaz = "[ui] " +DO Assert WITH !llCrapat AND VARTYPE(loForm) = 'O', "CREATEOBJECT('frm_catalog_articole_nou') trece (errno=" + TRANSFORM(lnErrNo) + ")" + +IF !llCrapat + DO Assert WITH loForm._pageframe1.PageCount = 3, "PageCount=3 (obtinut " + TRANSFORM(loForm._pageframe1.PageCount) + ")" + DO Assert WITH VARTYPE(loForm.oPretNom) = 'O', "Thisform.oPretNom instantiat" + + loPage3 = loForm._pageframe1.Page3 + DO Assert WITH PEMSTATUS(loPage3.Clb_tx_scd, 'Text1', 5), "Page3.Clb_tx_scd.Text1 (analitic debitor) exista" + DO Assert WITH PEMSTATUS(loPage3.Clb_tx_scc, 'Text1', 5), "Page3.Clb_tx_scc.Text1 (analitic creditor) exista" + IF PEMSTATUS(loPage3.Clb_tx_scd, 'Text1', 5) + DO Assert WITH loPage3.Clb_tx_scd.Text1.MaxLength = 4, "Clb_tx_scd.Text1.MaxLength=4 (obtinut " + TRANSFORM(loPage3.Clb_tx_scd.Text1.MaxLength) + ")" + DO Assert WITH loPage3.Clb_tx_scd.Text1.ControlSource = "Thisform.oPretNom.cAscd", "Clb_tx_scd.Text1.ControlSource=[" + TRANSFORM(loPage3.Clb_tx_scd.Text1.ControlSource) + "]" + ENDIF + IF PEMSTATUS(loPage3.Clb_tx_scc, 'Text1', 5) + DO Assert WITH loPage3.Clb_tx_scc.Text1.MaxLength = 4, "Clb_tx_scc.Text1.MaxLength=4 (obtinut " + TRANSFORM(loPage3.Clb_tx_scc.Text1.MaxLength) + ")" + DO Assert WITH loPage3.Clb_tx_scc.Text1.ControlSource = "Thisform.oPretNom.cAscc", "Clb_tx_scc.Text1.ControlSource=[" + TRANSFORM(loPage3.Clb_tx_scc.Text1.ControlSource) + "]" + ENDIF + RELEASE loForm +ENDIF + +gcCaz = "[final] " +IF TYPE('gnHandle') = 'N' AND gnHandle > 0 + SQLEXEC(gnHandle, "ROLLBACK") +ENDIF +DO UiLog WITH "PARTIAL PASS=" + TRANSFORM(gnPass) + " FAIL=" + TRANSFORM(gnFail) +DO UiFinal + +PROCEDURE UiLog + LPARAMETERS tcMsg + STRTOFILE(tcMsg + CHR(13) + CHR(10), gcLog, 1) +ENDPROC + +PROCEDURE UiErr + LPARAMETERS tnErr, tcMsg, tcProg, tnLine + DO UiLog WITH "ERROR " + TRANSFORM(tnErr) + " [" + tcProg + ":" + TRANSFORM(tnLine) + "] " + tcMsg +ENDPROC + +PROCEDURE Assert + LPARAMETERS tlCond, tcMsg + IF tlCond + gnPass = gnPass + 1 + DO UiLog WITH "PASS: " + gcCaz + tcMsg + ELSE + gnFail = gnFail + 1 + DO UiLog WITH "FAIL: " + gcCaz + tcMsg + ENDIF +ENDPROC + +PROCEDURE UiFinal + DO UiLog WITH "REZULTAT: " + TRANSFORM(gnPass) + " PASS / " + TRANSFORM(gnFail) + " FAIL" + DO UiLog WITH "END " + TTOC(DATETIME()) + QUIT +ENDPROC diff --git a/utile/Teste/facturare_unificat/restore_pol41.prg b/utile/Teste/facturare_unificat/restore_pol41.prg new file mode 100644 index 0000000..51ea2aa --- /dev/null +++ b/utile/Teste/facturare_unificat/restore_pol41.prg @@ -0,0 +1,51 @@ +SET SAFETY OFF +SET TALK OFF +SET NOTIFY OFF +CLOSE DATABASES + +PUBLIC gcLog +gcLog = "D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out\restore_pol41.log" +STRTOFILE("START " + TTOC(DATETIME()) + CHR(13) + CHR(10), gcLog) +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 + +SQLEXEC(gnHandle, "select id_pol, nume_lista_preturi, id_nota from crm_politici_preturi where id_pol in (41,43) order by id_pol", "crsbefore") +IF USED('crsbefore') + SCAN + DO AfLog WITH "INainte: id_pol=" + TRANSFORM(crsbefore.id_pol) + " [" + ALLTRIM(NVL(crsbefore.nume_lista_preturi,[])) + "] id_nota=" + TRANSFORM(NVL(crsbefore.id_nota,0)) + ENDSCAN + USE IN crsbefore +ENDIF + +SQLSETPROP(gnHandle, "Transactions", 2) +SQLEXEC(gnHandle, "update crm_politici_preturi set id_nota = 6 where id_pol = 41") +SQLEXEC(gnHandle, "commit") +SQLEXEC(gnHandle, "select id_pol, nume_lista_preturi, id_nota from crm_politici_preturi where id_pol in (41,43) order by id_pol", "crsafter") +IF USED('crsafter') + SCAN + DO AfLog WITH "Dupa: id_pol=" + TRANSFORM(crsafter.id_pol) + " [" + ALLTRIM(NVL(crsafter.nume_lista_preturi,[])) + "] id_nota=" + TRANSFORM(NVL(crsafter.id_nota,0)) + ENDSCAN + USE IN crsafter +ENDIF + +DO Final + +PROCEDURE AfLog + LPARAMETERS tcMsg + STRTOFILE(tcMsg + CHR(13) + CHR(10), gcLog, 1) +ENDPROC + +PROCEDURE AfErr + LPARAMETERS tnErr, tcMsg, tcProg, tnLine + DO AfLog WITH "ERROR " + TRANSFORM(tnErr) + " [" + tcProg + ":" + TRANSFORM(tnLine) + "] " + tcMsg +ENDPROC + +PROCEDURE Final + DO AfLog WITH "END " + TTOC(DATETIME()) + QUIT +ENDPROC