teste storno eFactura: e2e runda 2-5, diagnostic ANAF 1814 (E1-E4: validare /prod/ inainte de upload /test/), Raspunsuri (nimic) (test6-8)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WsxyCHJYL6W9MZ6FPnH8ax
This commit is contained in:
124
utile/Teste/storno/test5_1814_e2.prg
Normal file
124
utile/Teste/storno/test5_1814_e2.prg
Normal file
@@ -0,0 +1,124 @@
|
||||
* test5_1814_e2.prg
|
||||
* E2 (docs\storno_eroare_1814_diagnostic.md), DOAR daca E1 a primit din nou 1814: storno SSS 1156-S identic
|
||||
* cu fisierul din E1, minus blocul cac:BillingReference (singura diferenta). Acelasi numar, o singura variabila.
|
||||
* Un singur upload. Garzi: sha1 fisier, lTest, token, CIF - inainte de TrimiteFacturaXML.
|
||||
*
|
||||
* Rulare: powershell -ExecutionPolicy Bypass -File D:\ROA\ROACONT\COMUN\utile\Teste\watchdog_vfp.ps1 -Script D:\ROA\ROACONT\COMUN\utile\Teste\storno\test5_1814_e2.prg -AutoDismiss -TimeoutSec 240
|
||||
* Iesire: test5_1814_e2_log.txt (+ test5_1814_e2_golog.txt cu liniile SendEFactura), acelasi folder
|
||||
|
||||
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, gcDir
|
||||
gcDir = "D:\ROA\ROACONT\COMUN\utile\Teste\storno\"
|
||||
gcUILog = gcDir + "test5_1814_e2_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\ROACONT\COMUN\utile\Teste\test_init_env_auto.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 initializat, gnHandle=' + TRANSFORM(gnHandle)
|
||||
|
||||
* SendEFactura scrie URL-ul si raspunsul prin goLog; Log_Mesaje nu scrie daca fisierul lipseste
|
||||
goLog.cLogFile = gcDir + "test5_1814_e2_golog.txt"
|
||||
STRTOFILE('', goLog.cLogFile)
|
||||
|
||||
LOCAL lcFile, lcSha1Asteptat, lcSha1
|
||||
lcFile = gcDir + "out\test5_e2_storno_SSS1156-S_fara_billingref.xml"
|
||||
lcSha1Asteptat = 'fb9b05149316c056b61f0cdbe3a2c7612f06812b'
|
||||
|
||||
IF !FILE(lcFile)
|
||||
DO PrLogLocal WITH 'BLOCAT: nu exista fisierul: ' + lcFile
|
||||
QUIT
|
||||
ENDIF
|
||||
lcSha1 = Sha1Fisier(lcFile)
|
||||
DO PrLogLocal WITH 'fisier=' + lcFile + ' len=' + TRANSFORM(LEN(FILETOSTR(lcFile))) + ' sha1=' + lcSha1
|
||||
IF !(lcSha1 == lcSha1Asteptat)
|
||||
DO PrLogLocal WITH 'BLOCAT: sha1 diferit de ' + lcSha1Asteptat + ' - fisierul E2 a fost modificat, opresc'
|
||||
QUIT
|
||||
ENDIF
|
||||
|
||||
LOCAL loAnaf As 'AnafeFacturaServer'
|
||||
loAnaf = CREATEOBJECT('AnafeFacturaServer', .F., '', gcS, '')
|
||||
loAnaf.lTest = .T.
|
||||
loAnaf.RefreshTokenAuto()
|
||||
DO PrLogLocal WITH 'CIF=' + loAnaf.cCodFiscal + ' lTest=' + TRANSFORM(loAnaf.lTest) + ' tokenExp=' + DTOC(loAnaf.dTokenExpdate) + ' tokenGol=' + TRANSFORM(EMPTY(loAnaf.cToken))
|
||||
|
||||
* garzi finale, imediat inainte de upload
|
||||
IF VARTYPE(loAnaf.lTest) <> 'L' OR !loAnaf.lTest
|
||||
DO PrLogLocal WITH 'BLOCAT: lTest nu e .T.'
|
||||
QUIT
|
||||
ENDIF
|
||||
IF EMPTY(loAnaf.cToken) OR loAnaf.dTokenExpdate <= DATE()
|
||||
DO PrLogLocal WITH 'BLOCAT: token gol sau expirat'
|
||||
QUIT
|
||||
ENDIF
|
||||
IF !(ALLTRIM(loAnaf.cCodFiscal) == '1879855')
|
||||
DO PrLogLocal WITH 'BLOCAT: CIF neasteptat: ' + loAnaf.cCodFiscal
|
||||
QUIT
|
||||
ENDIF
|
||||
IF !FILE(lcFile) OR !(Sha1Fisier(lcFile) == lcSha1Asteptat)
|
||||
DO PrLogLocal WITH 'BLOCAT: fisierul lipseste sau s-a schimbat chiar inainte de upload'
|
||||
QUIT
|
||||
ENDIF
|
||||
|
||||
DO PrLogLocal WITH '=== UPLOAD 1/1: storno SSS 1156-S FARA BillingReference pe TEST ==='
|
||||
LOCAL loRet
|
||||
loRet = loAnaf.TrimiteFacturaXML(lcFile, .F., .F., .F., .F., .F.)
|
||||
DO PrLogLocal WITH 'upload: lSucces=' + TRANSFORM(loRet.lSucces) + ' status=' + TRANSFORM(loRet.nStatus) + ' idIncarcare=' + ALLTRIM(NVL(loRet.cIdIncarcare,'')) + ' mesaj=[' + ALLTRIM(NVL(loRet.cMesaj,'')) + ']'
|
||||
DO PrLogLocal WITH 'raspuns brut: ' + NVL(loRet.cResponse,'')
|
||||
DO PrLogLocal WITH 'TOTAL: test terminat fara exceptie'
|
||||
CATCH TO loEx
|
||||
DO PrLogLocal WITH 'EXCEPTIE: ' + loEx.Message + ' (' + TRANSFORM(loEx.LineNo) + ') ' + loEx.Procedure
|
||||
ENDTRY
|
||||
|
||||
QUIT
|
||||
|
||||
**********************************************************
|
||||
* sha1 prin certutil (sincron, fereastra ascunsa)
|
||||
FUNCTION Sha1Fisier
|
||||
LPARAMETERS tcFile
|
||||
LOCAL loSh, lcOut, lcTxt, lcHash, lnI
|
||||
lcOut = ADDBS(SYS(2023)) + 'test5_sha1_' + SYS(2015) + '.txt'
|
||||
loSh = CREATEOBJECT('WScript.Shell')
|
||||
loSh.Run('cmd /c certutil -hashfile "' + tcFile + '" SHA1 > "' + lcOut + '"', 0, .T.)
|
||||
lcHash = ''
|
||||
IF FILE(lcOut)
|
||||
lcTxt = FILETOSTR(lcOut)
|
||||
DELETE FILE (lcOut)
|
||||
FOR lnI = 1 TO GETWORDCOUNT(lcTxt, CHR(13) + CHR(10))
|
||||
IF LEN(CHRTRAN(GETWORDNUM(lcTxt, lnI, CHR(13) + CHR(10)), ' ', '')) = 40
|
||||
lcHash = LOWER(CHRTRAN(GETWORDNUM(lcTxt, lnI, CHR(13) + CHR(10)), ' ', ''))
|
||||
EXIT
|
||||
ENDIF
|
||||
ENDFOR
|
||||
ENDIF
|
||||
RETURN lcHash
|
||||
ENDFUNC
|
||||
|
||||
**********************************************************
|
||||
PROCEDURE PrLogLocal
|
||||
LPARAMETERS tcMsg
|
||||
LOCAL lcL
|
||||
SET SAFETY OFF
|
||||
lcL = IIF(FILE(gcUILog), FILETOSTR(gcUILog), '')
|
||||
STRTOFILE(lcL + TTOC(DATETIME()) + ' ' + TRANSFORM(tcMsg) + CHR(13) + CHR(10), gcUILog)
|
||||
ENDPROC
|
||||
|
||||
**********************************************************
|
||||
PROCEDURE PrErrLocal
|
||||
LPARAMETERS tnError, tcMessage, tcProgram, tnLineNo
|
||||
DO PrLogLocal WITH 'EROARE ' + TRANSFORM(tnError) + ' ' + TRANSFORM(tcMessage) + ' in ' + TRANSFORM(tcProgram) + ' linia ' + TRANSFORM(tnLineNo)
|
||||
ENDPROC
|
||||
Reference in New Issue
Block a user