*** Note contabile pentru reglarea diferentelor provenite din denominare 01-07-2005

IF gnAn * 12 + gnLuna # 2005*12 + 7	
	aMESSAGEBOX('Notele de reglare denominare se pot face doar in luna 07-2005',0+48,'Atentie')
	RETURN
ENDIF 
	
lnButon = lans(77770)
IF lnButon <> 1
	IF USED('actactan')
		USE IN actactan
	ENDIF
	RETURN
ENDIF 

lcContDenominare = gcCont_Denominare
lcAcontDenominare = gcAnalitic_Denominare

SELECT actactan
SCATTER NAME loact
ZAP 
*** REGLARE FACTURI-BALANTA PARTENERI ***
lcSel = [{call pack_denominare_reglari.ireg_vs_bal_parteneri(?gcS,?gnAn,?gnLuna)}]
lcCursor = 'crsDifParteneri'
lnSucces = goExecutor.oExecute(lcSel,lcCursor)

IF lnSucces < 0
	amessagebox(goExecutor.cEroare,0+16,"Eroare")
	RETURN
ENDIF

SELECT actactan
APPEND FROM DBF(lcCursor)
IF USED(lcCursor)
	USE IN (lcCursor)
ENDIF 
SELECT actactan
REPLACE ALL id_set WITH 77771, explicatia WITH loact.explicatia, explicatia4 WITH 'REGLARE FACTURI-BALANTA PARTENERI'
REPLACE ALL id_fdoc WITH loact.id_fdoc, nract WITH loact.nract, dataact WITH loact.dataact, dataireg WITH loact.dataireg
REPLACE ALL scd WITH lcContDenominare, ascd WITH lcAcontDenominare FOR EMPTY(scd) OR ISNULL(scd)
REPLACE ALL scc WITH lcContDenominare, ascc WITH lcAcontDenominare FOR EMPTY(scc) OR ISNULL(scc)

IF RECCOUNT('actactan') <> 0
	oscrie_in_fisiere(0)
ELSE 
	amessagebox('REGLARE FACTURI cu BALANTA PARTENERI' + Chr(10)+Chr(13)+Chr(10)+Chr(13) + 'Nu sunt diferente.' + CHR(13) + 'Nu s-a inregistrat nota contabila.',0+64,'Info')
ENDIF 


*** REGLARE BALANTA PARTENERI-BALANTA ANALITICA ***
lcSel = [{call pack_denominare_reglari.bal_part_vs_bal_ana(?gcS,?gnAn,?gnLuna)}]
lcCursor = 'crsDifBalante'
lnSucces = goExecutor.oExecute(lcSel,lcCursor)

IF lnSucces < 0
	amessagebox(goExecutor.cEroare,0+16,"Eroare")
	RETURN
ENDIF

SELECT actactan
ZAP 
APPEND FROM DBF(lcCursor)
IF USED(lcCursor)
	USE IN (lcCursor)
ENDIF 
SELECT actactan
REPLACE ALL id_set WITH 77772, explicatia WITH loact.explicatia, explicatia4 WITH 'REGLARE BALANTA PARTENERI-BALANTA ANALITICA'
REPLACE ALL id_fdoc WITH loact.id_fdoc, nract WITH loact.nract, dataact WITH loact.dataact, dataireg WITH loact.dataireg
REPLACE ALL scd WITH lcContDenominare, ascd WITH lcAcontDenominare FOR EMPTY(scd) OR ISNULL(scd)
REPLACE ALL scc WITH lcContDenominare, ascc WITH lcAcontDenominare FOR EMPTY(scc) OR ISNULL(scc)

IF RECCOUNT('actactan') <> 0
	oscrie_in_fisiere(0)
ELSE 
	amessagebox('REGLARE BALANTA PARTENERI cu BALANTA DE VERIFICARE ANALITICA' + Chr(10)+Chr(13)+Chr(10)+Chr(13) +'Nu sunt diferente.' + CHR(13) + 'Nu s-a inregistrat nota contabila.',0+64,'Info')
ENDIF 


*** REGLARE BALANTA ANALITICA-SINTETICA ***
lcSel = [{call pack_denominare_reglari.bal_ana_vs_bal_sint(?gcS,?gnAn,?gnLuna)}]
lcCursor = 'crsDifBal'
lnSucces = goExecutor.oExecute(lcSel,lcCursor)

IF lnSucces < 0
	amessagebox(goExecutor.cEroare,0+16,"Eroare")
	RETURN
ENDIF

SELECT actactan
ZAP 
APPEND FROM DBF(lcCursor)
IF USED(lcCursor)
	USE IN (lcCursor)
ENDIF 
SELECT actactan
REPLACE ALL id_set WITH 77773, explicatia WITH loact.explicatia, explicatia4 WITH 'REGLARE BALANTA ANALITICA-SINTETICA'
REPLACE ALL id_fdoc WITH loact.id_fdoc, nract WITH loact.nract, dataact WITH loact.dataact, dataireg WITH loact.dataireg
REPLACE ALL scd WITH lcContDenominare, ascd WITH lcAcontDenominare FOR EMPTY(scd) OR ISNULL(scd)
REPLACE ALL scc WITH lcContDenominare, ascc WITH lcAcontDenominare FOR EMPTY(scc) OR ISNULL(scc)

IF RECCOUNT('actactan') <> 0
	oscrie_in_fisiere(0)
ELSE 
	amessagebox('REGLARE BALANTA ANALITICA cu BALANTA SINTETICA' + Chr(10)+Chr(13)+Chr(10)+Chr(13) + 'Nu sunt diferente.' + CHR(13) + 'Nu s-a inregistrat nota contabila.',0+64,'Info')
ENDIF 
 

*** REGLARE SOLDURI BALANTA SINTETICA *** 
lcSel = [{call pack_denominare_reglari.bal_sintetica_total(?gcS,?gnAn,?gnLuna)}]
lcCursor = 'crsDifBal'
lnSucces = goExecutor.oExecute(lcSel,lcCursor)

IF lnSucces < 0
	amessagebox(goExecutor.cEroare,0+16,"Eroare")
	RETURN
ENDIF

SELECT (lcCursor)
lnSumaD = debit
lnSumaC = credit

IF USED(lcCursor)
	USE IN (lcCursor)
ENDIF 

SELECT actactan
ZAP
IF lnSumaD <> 0
	APPEND BLANK
	REPLACE scd WITH lcContDenominare, ascd WITH lcAcontDenominare, suma WITH lnSumaD
ENDIF 
IF lnSumaC <> 0
	APPEND BLANK 
	REPLACE scc WITH lcContDenominare, ascc WITH lcAcontDenominare, suma WITH lnSumaC
ENDIF 

REPLACE ALL id_set WITH 77774, explicatia WITH loact.explicatia, explicatia4 WITH 'REGLARE SOLDURI BALANTA SINTETICA'
REPLACE ALL id_fdoc WITH loact.id_fdoc, nract WITH loact.nract, dataact WITH loact.dataact, dataireg WITH loact.dataireg

IF RECCOUNT('actactan') <> 0
	oscrie_in_fisiere(0)
ELSE 
	amessagebox('REGLARE SOLDURI BALANTA SINTETICA' + Chr(10)+Chr(13)+Chr(10)+Chr(13) + 'Nu sunt diferente.' + CHR(13) + 'Nu s-a inregistrat nota contabila.',0+64,'Info')
ENDIF 

IF USED('actactan')
	USE IN actactan
ENDIF 