Files
comun/utile/Teste/facturare_unificat/probe_cont_667.prg
2026-09-17 11:19:54 +03:00

146 lines
5.6 KiB
Plaintext

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