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
303 lines
13 KiB
Plaintext
303 lines
13 KiB
Plaintext
* test_s3c_1_paritate_sursa.prg
|
|
* Headless: paritatea lui oDateFactura.Init cu/ fara parametrul optional de sursa (comanda/contract).
|
|
* Dovedeste ca apelul vechi (fara sursa) citeste din goComanda/goContract ca inainte (fallback), iar
|
|
* apelul nou (cu toSursa obiect) citeste din parametru chiar si cand globala e populata diferit.
|
|
* Nu instantiaza niciun formular: doar oDateFactura + functiile .prg, cu goExecutor inlocuit de
|
|
* oExecutorMockS3c (intercepteaza DOAR cursorele crsCtrTemp/crsComTemp din cele doua ramuri de sursa).
|
|
* Rulare: vfp9.exe -A -T "D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\test_s3c_1_paritate_sursa.prg"
|
|
* Log: D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out\test_s3c_1_paritate_sursa.log
|
|
|
|
SET SAFETY OFF
|
|
SET TALK OFF
|
|
SET NOTIFY OFF
|
|
PUBLIC gcLog, gnFail, gnPass, gcCaz, gcErr
|
|
PUBLIC goComanda, goContract
|
|
PUBLIC gnMockIdCtr, gnMockIdSectie, goExecutorReal
|
|
gcLog = "D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat\out\test_s3c_1_paritate_sursa.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
|
|
gcCaz = ""
|
|
gcErr = ""
|
|
gnMockIdCtr = 0
|
|
gnMockIdSectie = 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
|
|
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;])
|
|
gnScadereStoc = 1
|
|
DO AfLog WITH "ENV OK, gnAn=" + TRANSFORM(gnAn) + " gnLuna=" + TRANSFORM(gnLuna)
|
|
|
|
goExecutorReal = goExecutor
|
|
goExecutor = CREATEOBJECT("oExecutorMockS3c")
|
|
goExecutor.oReal = goExecutorReal
|
|
|
|
DO CazTipParam
|
|
DO CazComandaFallback
|
|
DO CazComandaParam
|
|
DO CazContractFallback
|
|
DO CazContractParam
|
|
DO CazContractTip52Fallback
|
|
DO CazTip1FaraSursa
|
|
DO CazTip1GlobalMurdar
|
|
|
|
DO Final
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
PROCEDURE CazTipParam
|
|
gcCaz = "[S3C0_TIP_PARAM] "
|
|
DO AfLog WITH "PAS: " + gcCaz
|
|
DO Assert WITH ProbaTipParam(1) == 'L', "Type(param nepasat) = 'L' (nu 'U')"
|
|
DO Assert WITH ProbaTipParam(1) <> 'U', "Type(param nepasat) NU e 'U'"
|
|
DO Assert WITH ProbaTipParam(1, 2, CREATEOBJECT('Custom')) == 'O', "Type(param obiect pasat) = 'O'"
|
|
ENDPROC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
PROCEDURE CazComandaFallback
|
|
gcCaz = "[COMANDA_FALLBACK] "
|
|
DO AfLog WITH "PAS: " + gcCaz
|
|
goComanda = CreSursaComanda(101, "COMANDA GLOBAL", "CF-G", 1001, "NR-G", 11)
|
|
LOCAL lo
|
|
lo = CREATEOBJECT("oDateFactura", 25012, 3)
|
|
DO Assert WITH VARTYPE(lo) = 'O', "Createobject oDateFactura(tip 3, fara sursa)"
|
|
DO Assert WITH lo.id_client = 101, "id_client din goComanda"
|
|
DO Assert WITH ALLTRIM(lo.nume_client) == "COMANDA GLOBAL", "nume_client din goComanda"
|
|
DO Assert WITH ALLTRIM(lo.cod_fiscal) == "CF-G", "cod_fiscal din goComanda"
|
|
DO Assert WITH lo.listaid = 1001, "listaid din goComanda"
|
|
DO Assert WITH ALLTRIM(lo.descriere) == "NR-G", "descriere din goComanda"
|
|
DO Assert WITH lo.id_sectie = 11, "id_sectie din goComanda"
|
|
DO Assert WITH ALLTRIM(lo.sectie) == "SECTIE 11", "sectie derivata din goComanda.id_sectie"
|
|
ENDPROC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
PROCEDURE CazComandaParam
|
|
gcCaz = "[COMANDA_PARAM] "
|
|
DO AfLog WITH "PAS: " + gcCaz
|
|
goComanda = CreSursaComanda(101, "COMANDA GLOBAL", "CF-G", 1001, "NR-G", 11)
|
|
LOCAL loSursa, lo
|
|
loSursa = CreSursaComanda(201, "COMANDA PARAM", "CF-P", 2001, "NR-P", 22)
|
|
lo = CREATEOBJECT("oDateFactura", 25012, 3, loSursa)
|
|
DO Assert WITH VARTYPE(lo) = 'O', "Createobject oDateFactura(tip 3, cu sursa)"
|
|
DO Assert WITH lo.id_client = 201, "id_client din toSursa (nu globala)"
|
|
DO Assert WITH ALLTRIM(lo.nume_client) == "COMANDA PARAM", "nume_client din toSursa"
|
|
DO Assert WITH ALLTRIM(lo.cod_fiscal) == "CF-P", "cod_fiscal din toSursa"
|
|
DO Assert WITH lo.listaid = 2001, "listaid din toSursa"
|
|
DO Assert WITH ALLTRIM(lo.descriere) == "NR-P", "descriere din toSursa"
|
|
DO Assert WITH lo.id_sectie = 22, "id_sectie din toSursa"
|
|
DO Assert WITH ALLTRIM(lo.sectie) == "SECTIE 22", "sectie derivata din toSursa.id_sectie"
|
|
ENDPROC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
PROCEDURE CazContractFallback
|
|
gcCaz = "[CONTRACT_FALLBACK] "
|
|
DO AfLog WITH "PAS: " + gcCaz
|
|
goContract = CreSursaContract(301, "CONTRACT GLOBAL", "CF-CG", 3001, "CTR-G", 33, "SEC-G", 331, "RESP-G", 1, "RON")
|
|
LOCAL lo
|
|
lo = CREATEOBJECT("oDateFactura", 25011, 2)
|
|
DO Assert WITH VARTYPE(lo) = 'O', "Createobject oDateFactura(tip 2, fara sursa)"
|
|
DO Assert WITH lo.id_client = 301, "id_client din goContract"
|
|
DO Assert WITH ALLTRIM(lo.nume_client) == "CONTRACT GLOBAL", "nume_client din goContract"
|
|
DO Assert WITH ALLTRIM(lo.cod_fiscal) == "CF-CG", "cod_fiscal din goContract"
|
|
DO Assert WITH lo.listaid = 3001, "listaid din goContract"
|
|
DO Assert WITH ALLTRIM(lo.descriere) == "CTR-G", "descriere din goContract"
|
|
DO Assert WITH lo.id_sectie = 33, "id_sectie din goContract"
|
|
DO Assert WITH ALLTRIM(lo.sectie) == "SEC-G", "sectie din goContract"
|
|
DO Assert WITH lo.id_responsabil = 331, "id_responsabil din goContract"
|
|
DO Assert WITH ALLTRIM(lo.responsabil) == "RESP-G", "responsabil din goContract"
|
|
DO Assert WITH lo.id_valuta = 1, "id_valuta din goContract"
|
|
DO Assert WITH ALLTRIM(lo.nume_valuta) == "RON", "nume_valuta din goContract"
|
|
DO Assert WITH gnMockIdCtr = 3001, "SQL fact_vcontracte foloseste goContract.id_ctr"
|
|
ENDPROC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
PROCEDURE CazContractParam
|
|
gcCaz = "[CONTRACT_PARAM] "
|
|
DO AfLog WITH "PAS: " + gcCaz
|
|
goContract = CreSursaContract(301, "CONTRACT GLOBAL", "CF-CG", 3001, "CTR-G", 33, "SEC-G", 331, "RESP-G", 1, "RON")
|
|
LOCAL loSursa, lo
|
|
loSursa = CreSursaContract(401, "CONTRACT PARAM", "CF-CP", 4001, "CTR-P", 44, "SEC-P", 441, "RESP-P", 2, "EUR")
|
|
lo = CREATEOBJECT("oDateFactura", 25011, 2, loSursa)
|
|
DO Assert WITH VARTYPE(lo) = 'O', "Createobject oDateFactura(tip 2, cu sursa)"
|
|
DO Assert WITH lo.id_client = 401, "id_client din toSursa (nu globala)"
|
|
DO Assert WITH ALLTRIM(lo.nume_client) == "CONTRACT PARAM", "nume_client din toSursa"
|
|
DO Assert WITH ALLTRIM(lo.cod_fiscal) == "CF-CP", "cod_fiscal din toSursa"
|
|
DO Assert WITH lo.listaid = 4001, "listaid din toSursa"
|
|
DO Assert WITH ALLTRIM(lo.descriere) == "CTR-P", "descriere din toSursa"
|
|
DO Assert WITH lo.id_sectie = 44, "id_sectie din toSursa"
|
|
DO Assert WITH ALLTRIM(lo.sectie) == "SEC-P", "sectie din toSursa"
|
|
DO Assert WITH lo.id_responsabil = 441, "id_responsabil din toSursa"
|
|
DO Assert WITH ALLTRIM(lo.responsabil) == "RESP-P", "responsabil din toSursa"
|
|
DO Assert WITH lo.id_valuta = 2, "id_valuta din toSursa"
|
|
DO Assert WITH ALLTRIM(lo.nume_valuta) == "EUR", "nume_valuta din toSursa"
|
|
DO Assert WITH gnMockIdCtr = 4001, "SQL fact_vcontracte foloseste toSursa.id_ctr"
|
|
ENDPROC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
PROCEDURE CazContractTip52Fallback
|
|
gcCaz = "[CONTRACT_TIP52_FALLBACK] "
|
|
DO AfLog WITH "PAS: " + gcCaz
|
|
goContract = CreSursaContract(301, "CONTRACT GLOBAL", "CF-CG", 3001, "CTR-G", 33, "SEC-G", 331, "RESP-G", 1, "RON")
|
|
LOCAL lo
|
|
lo = CREATEOBJECT("oDateFactura", 25061, 52)
|
|
DO Assert WITH VARTYPE(lo) = 'O', "Createobject oDateFactura(tip 52, fara sursa)"
|
|
DO Assert WITH lo.id_client = 301, "id_client din goContract (INLIST acopera tip 52)"
|
|
DO Assert WITH lo.listaid = 3001, "listaid din goContract (tip 52)"
|
|
ENDPROC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
PROCEDURE CazTip1FaraSursa
|
|
gcCaz = "[TIP1_FARA_SURSA] "
|
|
DO AfLog WITH "PAS: " + gcCaz
|
|
RELEASE goComanda, goContract
|
|
gcErr = ""
|
|
LOCAL lo
|
|
lo = CREATEOBJECT("oDateFactura", 25010, 1)
|
|
DO Assert WITH VARTYPE(lo) = 'O', "Createobject oDateFactura(tip 1) fara eroare"
|
|
DO Assert WITH EMPTY(gcErr), "nicio eroare pe tip 1 - " + gcErr
|
|
DO Assert WITH ISNULL(lo.id_client), "id_client ramane Null (nicio precompletare)"
|
|
DO Assert WITH EMPTY(lo.nume_client), "nume_client ramane gol (nicio precompletare)"
|
|
ENDPROC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
PROCEDURE CazTip1GlobalMurdar
|
|
gcCaz = "[TIP1_GLOBAL_MURDAR] "
|
|
DO AfLog WITH "PAS: " + gcCaz
|
|
goComanda = CreSursaComanda(101, "COMANDA GLOBAL", "CF-G", 1001, "NR-G", 11)
|
|
gcErr = ""
|
|
LOCAL lo
|
|
lo = CREATEOBJECT("oDateFactura", 25010, 1)
|
|
DO Assert WITH VARTYPE(lo) = 'O', "Createobject oDateFactura(tip 1) cu globala murdara"
|
|
DO Assert WITH EMPTY(gcErr), "nicio eroare pe tip 1 cu globala murdara - " + gcErr
|
|
DO Assert WITH ISNULL(lo.id_client), "id_client ramane Null (garda tnTip=3 nu se declanseaza)"
|
|
ENDPROC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
FUNCTION ProbaTipParam
|
|
LPARAMETERS tnA, tnB, toC
|
|
RETURN TYPE('toC')
|
|
ENDFUNC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
FUNCTION CreSursaComanda
|
|
LPARAMETERS tnIdPart, tcNume, tcCodFiscal, tnIdComanda, tcNrComanda, tnIdSectie
|
|
CREATE CURSOR _cs (id_part N(10), nume C(50), cod_fiscal C(20), id_comanda N(10), nr_comanda C(20), id_sectie N(10))
|
|
INSERT INTO _cs VALUES (tnIdPart, tcNume, tcCodFiscal, tnIdComanda, tcNrComanda, tnIdSectie)
|
|
LOCAL loS
|
|
SCATTER NAME loS MEMO
|
|
USE IN _cs
|
|
RETURN loS
|
|
ENDFUNC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
FUNCTION CreSursaContract
|
|
LPARAMETERS tnIdPart, tcDenumire, tcCodFiscal, tnIdCtr, tcContract, tnIdSectie, tcSectie, tnIdResp, tcResp, tnIdVal, tcVal
|
|
CREATE CURSOR _cc (id_part N(10), denumire C(50), cod_fiscal C(20), id_ctr N(10), contract C(30), id_sectie N(10), ;
|
|
sectie C(30), id_responsabil N(10), responsabil C(30), id_valuta N(10), nume_val C(10))
|
|
INSERT INTO _cc VALUES (tnIdPart, tcDenumire, tcCodFiscal, tnIdCtr, tcContract, tnIdSectie, tcSectie, tnIdResp, tcResp, tnIdVal, tcVal)
|
|
LOCAL loS
|
|
SCATTER NAME loS MEMO
|
|
USE IN _cc
|
|
RETURN loS
|
|
ENDFUNC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
DEFINE CLASS oExecutorMockS3c AS oexecutor
|
|
oReal = NULL
|
|
|
|
PROCEDURE oExecute
|
|
LPARAMETERS tcSql, tcCursor, tlProgress, tcTitluProgress, tnHandle, tlShowError, tlQuitOnError, tlReconnect
|
|
LOCAL lcCur, lcSql, lnPos
|
|
lcCur = UPPER(ALLTRIM(TRANSFORM(tcCursor)))
|
|
lcSql = TRANSFORM(tcSql)
|
|
IF lcCur == 'CRSCTRTEMP'
|
|
lnPos = AT('id_ctr =', lcSql)
|
|
IF lnPos > 0
|
|
gnMockIdCtr = VAL(SUBSTR(lcSql, lnPos + LEN('id_ctr =')))
|
|
ENDIF
|
|
DO CreeazaCtrTemp
|
|
RETURN 1
|
|
ENDIF
|
|
IF lcCur == 'CRSCOMTEMP'
|
|
lnPos = AT('id_sectie =', lcSql)
|
|
IF lnPos > 0
|
|
gnMockIdSectie = VAL(SUBSTR(lcSql, lnPos + LEN('id_sectie =')))
|
|
ENDIF
|
|
DO CreeazaComTemp WITH gnMockIdSectie
|
|
RETURN 1
|
|
ENDIF
|
|
RETURN This.oReal.oExecute(tcSql, tcCursor)
|
|
ENDPROC
|
|
|
|
FUNCTION oPrelucrareEroare
|
|
RETURN "MOCK eroare Oracle"
|
|
ENDFUNC
|
|
ENDDEFINE
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
PROCEDURE CreeazaCtrTemp
|
|
IF USED('crsCtrTemp')
|
|
USE IN crsCtrTemp
|
|
ENDIF
|
|
CREATE CURSOR crsCtrTemp (scadenta_incasare N(6), afisare_scadenta N(1), opt_facturare N(1))
|
|
RETURN
|
|
ENDPROC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
PROCEDURE CreeazaComTemp
|
|
LPARAMETERS tnIdSectie
|
|
IF USED('crsComTemp')
|
|
USE IN crsComTemp
|
|
ENDIF
|
|
CREATE CURSOR crsComTemp (sectie C(100))
|
|
INSERT INTO crsComTemp VALUES ("SECTIE " + ALLTRIM(STR(tnIdSectie)))
|
|
RETURN
|
|
ENDPROC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
PROCEDURE Assert
|
|
LPARAMETERS tlCond, tcMsg
|
|
IF tlCond
|
|
gnPass = gnPass + 1
|
|
DO AfLog WITH "PASS: " + gcCaz + tcMsg
|
|
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
|
|
gcErr = gcErr + TRANSFORM(tnErr) + " " + tcMsg + " (" + TRANSFORM(tcProg) + ":" + TRANSFORM(tnLine) + ")" + CHR(13) + CHR(10)
|
|
gnFail = gnFail + 1
|
|
DO AfLog WITH "ERROR " + TRANSFORM(tnErr) + " [" + tcProg + ":" + TRANSFORM(tnLine) + "] " + tcMsg
|
|
ENDPROC
|
|
|
|
*----------------------------------------------------------------------------------------
|
|
PROCEDURE Final
|
|
IF TYPE('goExecutorReal') = 'O'
|
|
goExecutor = goExecutorReal
|
|
ENDIF
|
|
DO AfLog WITH "TOTAL pass=" + TRANSFORM(gnPass) + " fail=" + TRANSFORM(gnFail)
|
|
DO AfLog WITH "END " + TTOC(DATETIME())
|
|
QUIT
|
|
ENDPROC
|