2409 lines
91 KiB
Plaintext
2409 lines
91 KiB
Plaintext
*!* 30.12.2010
|
|
*!* marius.mutu
|
|
*!* viz_frm_facturi - export xls + goExport.export2frx foxypreview
|
|
|
|
*!* 15.07.2011
|
|
*!* marius.mutu
|
|
*!* parteneri_cu_sold_final - facea raportul doar pentru contul 4111
|
|
|
|
|
|
*!* 27.06.2013
|
|
*!* marius.mutu
|
|
*!* sold_fact_pe_vechimi
|
|
*!* la sold facturi pe vechimi 4111 fata de data emitere am acelasi raport ca la ALTII/ACTIV
|
|
|
|
*!* 16.10.2020
|
|
*!* marius.mutu
|
|
*!* viz_frm_facturi - redirectionez catre orap_terti_comun.prg
|
|
|
|
*_________________________________________________________*
|
|
* *
|
|
* proceduri utilizate pentru generarea rapoartelor din: *
|
|
* Terti->Furnizori *
|
|
* ->Clienti *
|
|
* ->Alti *
|
|
*_________________________________________________________*
|
|
|
|
* PROCEDURE viz_frm_facturi( tntip )
|
|
* Date : 19/11/2004, 14:36:36
|
|
* author : lavinia.viziru
|
|
* description:
|
|
|
|
****** PARAMETER BLOCK **************
|
|
* Parameters : 1
|
|
* Parameter 1:
|
|
*
|
|
******************************************* INCEPUT:viz_frm_facturi *******************************************
|
|
Procedure viz_frm_facturi_old
|
|
Parameters tntip, tccont
|
|
DO viz_frm_facturi IN orap_terti_comun.prg WITH tntip, tccont
|
|
RETURN
|
|
|
|
Local lcFileXLS
|
|
lcFileXLS = ""
|
|
Private pocauta, pnlunai, pnani, pnlunaf, pnanf, pccont, plemise, pcperioada, pctitlu, pcpartener
|
|
Store '' To pocauta, pcperioada, pctitlu, pcpartener
|
|
Store 0 To pnlunai, pnani, pnlunaf, pnanf
|
|
|
|
plemise = Iif(tntip = 2, .T., .F.)
|
|
plActiv = .T.
|
|
pccont = Iif(!Empty(tccont), tccont, [])
|
|
If !Empty(pccont)
|
|
pcexec = [select NVL(fel_cont,0) as fel_cont from ] + gcs + [.vcoresp_tip_cont where cont=?pcCont]
|
|
pcCursor = [felCont_cursor]
|
|
pnsucces = goExecutor.oExecute(pcexec, pcCursor)
|
|
If pnsucces > 0 And _Tally > 0
|
|
Select felCont_cursor
|
|
Locate
|
|
plActiv = Iif(felCont_cursor.fel_cont = 0, .T., .F.)
|
|
Use In felCont_cursor
|
|
Endif
|
|
Endif
|
|
|
|
gnButon = 1
|
|
Do While gnButon = 1
|
|
ofrm = Createobject('frm_facturi')
|
|
With ofrm
|
|
.lcCont = pccont
|
|
.lcContInitial = pccont
|
|
.llActiv = plActiv
|
|
.clb_tx_simplu1.text_simplu1.Value = pccont
|
|
.lb_titlu_alb_b121.Caption = [Facturi ] + Iif(!Empty(pccont), pccont, [])
|
|
.opt_perioada.Value = tntip
|
|
.lhide = .T.
|
|
Endwith
|
|
ofrm.Show(1)
|
|
pccont = ofrm.lcCont
|
|
plemise = Iif(ofrm.opt_perioada.Value = 1, .F., .T.)
|
|
pnIdPart = ofrm.lnIdPart
|
|
plActiv = ofrm.llActiv
|
|
pnani = ofrm.Caut_anluna1.nan
|
|
pnanf = ofrm.Caut_anluna2.nan
|
|
pnlunai = ofrm.Caut_anluna1.nluna
|
|
pnlunaf = ofrm.Caut_anluna2.nluna
|
|
pnCuAnalitic = ofrm.ncu_analitic
|
|
pcAnalitic = ofrm.lcAcont
|
|
pnCuValuta = ofrm.ncu_valuta
|
|
pnIdValuta = ofrm.lnIdValuta
|
|
pnCuVechime = ofrm.ncu_vechime
|
|
pcValuta = ofrm.txt_valuta.Value
|
|
ofrm.Release
|
|
|
|
If gnButon = 1
|
|
|
|
pcperioada = [Perioada: ] + Alltrim(Str(pnlunai)) + [/] + Alltrim(Str(pnani)) + ;
|
|
[ - ] + Alltrim(Str(pnlunaf)) + [/] + Alltrim(Str(pnanf))
|
|
|
|
lcCursor = situatie_facturi(Alltrim(pccont), plActiv, plemise, pnIdPart, pnani, pnlunai, pnanf, pnlunaf, pnCuAnalitic, pcAnalitic, pnCuValuta, pnIdValuta, pnCuVechime)
|
|
|
|
Do Case
|
|
Case Empty(lcCursor)
|
|
amessagebox("Nu a fost generata selectia pentru listare!", 0 + 48, "Atentie")
|
|
Case Reccount(lcCursor) = 0
|
|
amessagebox("Nu exista inregistrari pentru listare!", 0 + 48, "Atentie")
|
|
Use In (lcCursor)
|
|
Otherwise
|
|
Do Case
|
|
Case Alltrim(pccont) = [401]
|
|
pcpartener = [Furnizor: ]
|
|
lcTitlu = [Situatia facturilor de cumparari]
|
|
Case Alltrim(pccont) = [4111]
|
|
pcpartener = [Client: ]
|
|
lcTitlu = [Situatia facturilor de vanzari]
|
|
Otherwise && pccont = [411]
|
|
pcpartener = [Partener: ]
|
|
lcTitlu = [Situatia facturilor]
|
|
Endcase
|
|
If pnCuVechime = 0
|
|
lcRaport = [rap_facturi]
|
|
Else
|
|
lcRaport = [rap_facturi_vechime]
|
|
Endif
|
|
|
|
If pnCuAnalitic = 0
|
|
pcGrupAcont = [EOF()]
|
|
Else
|
|
pcGrupAcont = [acont]
|
|
Endif
|
|
If !Empty(pnIdValuta)
|
|
lcTitlu = lcTitlu + Chr(13) + [Valuta ] + Alltrim(pcValuta)
|
|
Endif
|
|
pctitlu = lcTitlu
|
|
*!* pctitlu = ceretitlu_rap('Titlul Raportului',lctitlu)
|
|
*!* pcDataOra = Get_Ora(2)
|
|
*!* Select (lcCursor)
|
|
*!* Report Form &lcRaport To Printer Prompt Preview
|
|
*!* 30.12.2010
|
|
*!* goExport.export2frx(lcCursor,lcRaport,.T.)
|
|
goExport.export2frx(lcCursor, lcRaport, .T., , , , , .T.)
|
|
If Messagebox('Doriti sa exportati in XLS?', 4 + 32, _Screen.Caption) = 6
|
|
lcFileXLS = Putfile("Salvati fisierul XLS", "Facturi.xls", "xls")
|
|
If !Empty(lcFileXLS)
|
|
Select (lcCursor)
|
|
Copy To (lcFileXLS) Type Xl5
|
|
open_default_app(lcFileXLS)
|
|
Endif
|
|
Endif
|
|
*!* 30.12.2010 ^
|
|
|
|
Use In (lcCursor)
|
|
Endcase
|
|
|
|
Endif
|
|
Enddo
|
|
Endproc
|
|
****************************************** SFARSIT: viz_frm_facturi ****************************
|
|
* PROCEDURE situatie_facturi
|
|
* Date : 10/04/2006, 16:10:03
|
|
* author : georgiana.voicu
|
|
* description: preluare facturi pentru conturi cu inregistrari
|
|
|
|
****** PARAMETER BLOCK **************
|
|
* Parameters : 3
|
|
* Parameter 1: tlemise
|
|
* Description: tipul facturilor preluate
|
|
* (.t.-facturi emise intr-o perioada determinata
|
|
* .f.-facturi cu sold dintr-o perioada determinata)
|
|
* Parameter 2: tccont
|
|
* Description: contul partenerului(411-client, 401- furnizor)
|
|
* Parameter 3: topartener
|
|
* Description: obiectul care contine datele partenerului(client/furnizor) selectat:nume + id_part
|
|
* (daca numele partenerului=<TOATE INREGISTRARILE> atunci se iau in considerare
|
|
* toti partenerii- clienti sau furnizori)
|
|
* Parameter 4,5,6,7 : perioada
|
|
******************************************* INCEPUT:situatie_facturi *******************************************
|
|
Procedure situatie_facturi_old
|
|
Parameters tccont, tlActiv, tlemise, tnIdPart, tnAnI, tnLunaI, tnAnF, tnLunaF, tnCuAnalitic, tcAnalitic, tnCuValuta, tnIdValuta, tnCuVechime
|
|
|
|
Private lnrlunii, lnrlunif, lnNrPrimaL
|
|
|
|
lnnrlunii = tnLunaI + 12 * tnAnI
|
|
lnnrlunif = tnLunaF + 12 * tnAnF
|
|
|
|
*!* IF tlemise
|
|
lnNrPrimaL = lnnrlunii
|
|
*!* ELSE
|
|
*!* lnNrPrimaL = lnnrlunii -1
|
|
*!* ENDIF
|
|
|
|
If tnIdPart = 0
|
|
lcCondId_part = [1=1]
|
|
Else
|
|
lcCondId_part = [id_part = ] + Alltrim(Str(tnIdPart))
|
|
Endif
|
|
|
|
lcSql = [select * from ] + gcs + [.exceptii_ireg where invers = 1 and debit = ] + Iif(tlActiv, [1], [0]) + ;
|
|
[ and cont = ] + tccont
|
|
lcCursor = [ex_debit]
|
|
lnSucces = goExecutor.oExecute(lcSql, lcCursor)
|
|
lcExceptii = [-1]
|
|
If lnSucces > 0
|
|
Select ex_debit
|
|
Scan
|
|
lcExceptii = lcExceptii + ',' + Alltrim(cont_c)
|
|
Endscan
|
|
Use In ex_debit
|
|
Endif
|
|
|
|
If !tlActiv && - furnizori
|
|
lcTotctva = Iif(tnCuValuta = 0, [credit + preccred], [valcredit + precvalcred])
|
|
*!* modificare v 2.0.46
|
|
lcTotctvaPrec = Iif(tnCuValuta = 0, [preccred], [precvalcred]) && am nevoie pentru calcularea soldului prec.
|
|
*!* modificare v 2.0.46 ^
|
|
lcSoldPrec = Iif(tnCuValuta = 0, [preccred - precdeb], [precvalcred - precvaldeb])
|
|
*lcAchitat = [debit + precdeb]
|
|
lcAchitat = Iif(tnCuValuta = 0, [precdeb], [precvaldeb])
|
|
lcPereche = [pereched]
|
|
lcIdPereche = [id_factd]
|
|
lcPartener = [partd]
|
|
lcIdPartener = [id_partd]
|
|
lcContIncPl = [scd]
|
|
lcAcontIncPl = [ascd]
|
|
lcCondExclud = [(to_number(scc) not in (] + lcExceptii + [))]
|
|
Else && - clienti
|
|
lcTotctva = Iif(tnCuValuta = 0, [debit + precdeb], [valdebit + precvaldeb])
|
|
*!* modificare v 2.0.46
|
|
lcTotctvaPrec = Iif(tnCuValuta = 0, [precdeb], [precvaldeb])
|
|
*!* modificare v 2.0.46 ^
|
|
lcSoldPrec = Iif(tnCuValuta = 0, [precdeb - preccred], [precvaldeb - precvalcred])
|
|
*lcAchitat = [credit + preccred]
|
|
lcAchitat = Iif(tnCuValuta = 0, [preccred], [precvalcred])
|
|
lcPereche = [perechec]
|
|
lcIdPereche = [id_factc]
|
|
lcPartener = [partc]
|
|
lcIdPartener = [id_partc]
|
|
lcContIncPl = [scc]
|
|
lcAcontIncPl = [ascc]
|
|
lcCondExclud = [(to_number(scd) not in (] + lcExceptii + [))]
|
|
Endif
|
|
|
|
lcCondPerioada = [((luna + 12*an) between ?lnNrPrimaL and ?lnnrlunif)]
|
|
lcCondData = [(to_number(to_char(dataireg,'MM'),'99') + 12*to_number(to_char(dataireg,'YYYY'),'9999'))]
|
|
lcCondPrimaLuna = [(luna + 12*an = ?lnNrPrimaL)]
|
|
If tnCuAnalitic = 1
|
|
lcCondAnalitic = Iif(!Empty(tcAnalitic), [acont = ?tcAnalitic], [1=1])
|
|
Else
|
|
lcCondAnalitic = [1=1]
|
|
Endif
|
|
If tnCuValuta = 1
|
|
lcCondvaluta = Iif(!Empty(tnIdValuta), [id_valuta = ?tnIdValuta], [id_valuta<>0])
|
|
Else
|
|
lcCondvaluta = [1=1]
|
|
Endif
|
|
pcExplicatie = [Din Precedent]
|
|
|
|
|
|
*!* lcSelect = [select an, luna, id_fact, id_part, nume, acont, dataact, nract,] + lcTotctva + [ as totctva,?pcExplicatie as fdoc,] + ;
|
|
*!* IIF(tlemise,[0],[(case when ] + lcCondPrimaLuna +[ then ] + lcAchitat + [ else 0 end)]) + [ as achitat] + ;
|
|
*!* [ from ] + gcS + [.vireg_parteneri ] + ;
|
|
*!* [where cont = ?tccont and ] + lcCondId_part + [ and ] + lcCondPerioada + ;
|
|
*!* [ and (luna + 12*an =] + IIF(tlemise,lcCondData,[(case when ] + lcCondPrimaLuna +;
|
|
*!* [ then luna + 12*an else ] + lcCondData + [ end)]) + [)] + ;
|
|
*!* [ order by an, luna, nume, dataact, nract]
|
|
lcSelect = [select an, luna, id_fact, id_part, nume, cod_fiscal, ] + Iif(tnCuAnalitic = 1, [acont], ['xxxx']) + [ as acont, dataact, serie_act, nract,] + Iif(tnCuValuta = 1, [id_valuta,nume_val,], []) + ;
|
|
[(case when precdeb <> 0 or preccred <> 0 then 1 else 0 end) as precedent,SUM(] + lcTotctva + [) as totctva,?pcExplicatie as fdoc,] + ;
|
|
[Sum(] + lcTotctvaPrec + [) as totctvaprec,] + ; && modificare v 2.0.46
|
|
[SUM(] + Iif(tlemise, [0], [(case when ] + lcCondPrimaLuna + [ then ] + lcAchitat + [ else 0 end)]) + [) as achitat] + ;
|
|
[ from ] + gcs + [.vireg_parteneri ] + ;
|
|
[ where cont = ?tccont and ] + lcCondId_part + [ and ] + lcCondPerioada + [ and ] + lcCondAnalitic + ;
|
|
[ and ] + lcCondvaluta + gcCondSucursala + ;
|
|
[ and (luna + 12*an =] + Iif(tlemise, lcCondData, [(case when ] + lcCondPrimaLuna + ;
|
|
[ then luna + 12*an else ] + lcCondData + [ end)]) + [)] + ;
|
|
[ group by an, luna, id_fact, id_part, nume, cod_fiscal, ] + Iif(tnCuAnalitic = 1, [acont,], []) + [ dataact, serie_act, nract] + Iif(tnCuValuta = 1, [,id_valuta,nume_val], []) + [,(case when precdeb <> 0 or preccred <> 0 then 1 else 0 end)] + ;
|
|
[ order by an, luna, nume, cod_fiscal, ] + Iif(tnCuValuta = 1, [id_valuta,], []) + Iif(tnCuAnalitic = 1, [acont,], []) + [dataact, serie_act, nract]
|
|
lcCursor = [cFacturi]
|
|
|
|
If Used(lcCursor)
|
|
Use In (lcCursor)
|
|
Endif
|
|
|
|
lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return ''
|
|
Endif
|
|
Select (lcCursor)
|
|
Replace All dataact With {} For Isnull(dataact)
|
|
|
|
&& 27.05.2008
|
|
&& soldurile initiale pentru facturile emise in perioada nu se pot obtine din facturile din cFacturi (nu am precdeb/preccred <> 0)
|
|
&& trebuie sa le selectez din ireg_parteneri separat
|
|
If tlemise
|
|
lcSelect = [select an, luna, id_part, cont, acont, Sum(] + lcSoldPrec + [) as soldprec ] + ;
|
|
[ from ireg_parteneri ] + ;
|
|
[ where cont = ?tccont and ] + lcCondId_part + [ and ] + lcCondAnalitic + ;
|
|
[ and ] + lcCondvaluta + gcCondSucursala + ;
|
|
[ and ] + lcCondPrimaLuna + ;
|
|
[ group by an, luna, id_part, cont, acont]
|
|
|
|
lcCursor = [cSoldParteneri]
|
|
|
|
If Used(lcCursor)
|
|
Use In (lcCursor)
|
|
Endif
|
|
|
|
lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return ''
|
|
Endif
|
|
Endif
|
|
&& soldurile initiale pentru facturile emise in perioada ^
|
|
|
|
&& iau in considerare doar incasarile inregistrate in perioada data
|
|
|
|
lcCondPerioada = [((luna + 12*an) between ?lnNrLuniI and ?lnNrLuniF)]
|
|
If tnIdPart = 0
|
|
lcCondId_part = [1=1]
|
|
Else
|
|
lcCondId_part = lcIdPartener + [ = ] + Alltrim(Str(tnIdPart))
|
|
Endif
|
|
If tnCuAnalitic = 1
|
|
lcCondAnalitic = Iif(!Empty(tcAnalitic), lcAcontIncPl + [ = ?tcAnalitic], [1=1])
|
|
Else
|
|
lcCondAnalitic = [1=1]
|
|
Endif
|
|
If tnCuValuta = 1
|
|
lcCondvaluta = Iif(!Empty(tnIdValuta), [id_valuta = ?tnIdValuta and suma_val<>0], [id_valuta<>0 and suma_val<>0])
|
|
Else
|
|
lcCondvaluta = [1=1]
|
|
Endif
|
|
|
|
*!* modificare v 2.0.46
|
|
If tccont = '4111'
|
|
lcConditieSupl = [ OR (SCD = '4111' ] + Iif(!Empty(tcAnalitic), [AND ASCD = ?tcAnalitic ], []) + ;
|
|
[AND SCC = '4427' ] + Iif(tnIdPart = 0, [], [AND ID_PARTD = ] + Alltrim(Str(tnIdPart)) + [ ]) + ;
|
|
[AND (NVL(PERECHED,0) <> 0 OR NVL(ID_FACTD,0)<>0))]
|
|
lcSelect1 = [Select (case when scc = '4427' then id_partd else id_partc end) as id_part,] + ;
|
|
[(case when scc = '4427' then partd else partc end) as nume,fdoc,dataact as datadoc,] + ;
|
|
[serie_act as serie_doc,nract as nrdoc,] + ;
|
|
Iif(tnCuAnalitic = 1, [(case when scc='4427' then ascd else ascc end)], ['xxxx']) + [ as acont,] + ;
|
|
[(case when scc = '4427' then pereched else perechec end) as pereche,] + ;
|
|
[(case when scc = '4427' then id_factd else id_factc end) as id_fact,] + ;
|
|
[(case when scc = '4427' then (-1)*] + Iif(tnCuValuta = 0, [suma else suma], [suma_val else suma_val]) + [ end) as suma,] + ;
|
|
[ id_valuta, luna as luna_inc, an as an_inc ] + ;
|
|
[ from ] + gcs + [.vact ] + ;
|
|
[ where ((] + lcContIncPl + [ = ] + tccont + [ and ] + lcCondId_part + [ and ] + lcCondAnalitic + [ and (] + lcPereche + [ <> 0 or ] + lcIdPereche + [ <>0))] + ;
|
|
lcConditieSupl + [)] + ;
|
|
[ and ] + lcCondExclud + [ and ] + lcCondPerioada + ;
|
|
[ and ] + lcCondvaluta + gcCondSucursala + ;
|
|
[ order by serie_act, nract, dataact]
|
|
Else
|
|
lcSelect1 = [select ] + lcIdPartener + [ as id_part,] + lcPartener + [ as nume,fdoc,dataact as datadoc,serie_act as serie_doc,nract as nrdoc,] + ;
|
|
Iif(tnCuAnalitic = 1, lcAcontIncPl, ['xxxx']) + [ as acont,] + lcPereche + [ as pereche,] + lcIdPereche + [ as id_fact,] + ;
|
|
Iif(tnCuValuta = 0, [suma], [suma_val]) + [ as suma,] + ;
|
|
[ id_valuta, luna as luna_inc, an as an_inc ] + ;
|
|
[ from ] + gcs + [.vact ] + ;
|
|
[ where ] + lcContIncPl + [ = ] + tccont + [ and ] + lcCondId_part + [ and ] + lcCondvaluta + [ and ] + lcCondAnalitic + ;
|
|
[ and ] + lcCondExclud + [ and (] + lcPereche + [ <> 0 or ] + lcIdPereche + [ <>0) and ] + lcCondPerioada + ;
|
|
gcCondSucursala + ;
|
|
[ order by serie_act, nract, dataact]
|
|
Endif
|
|
*!* modificare v 2.0.46 ^
|
|
lcCursor1 = [cIncasari_temp]
|
|
|
|
If Used(lcCursor1)
|
|
Use In (lcCursor1)
|
|
Endif
|
|
|
|
lnSucces1 = goExecutor.oExecute(lcSelect1, lcCursor1)
|
|
If lnSucces1 < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return ''
|
|
Endif
|
|
|
|
Select cIncasari_temp
|
|
Replace All datadoc With {} For Isnull(datadoc)
|
|
|
|
Select an, luna, id_fact, id_part, nume, cod_fiscal, acont, Nvl(Ttod(dataact), {}) As datafact, Nvl(serie_act, []) As serie_fact, ;
|
|
id_ctr, contract, ;
|
|
nract As nrfact, totctva, ;
|
|
Padr(fdoc, 30, ' ') As fdoc, {//} As datadoc, 00000000000000 As nrdoc, precedent, ;
|
|
achitat As suma, 00000000000000000000.0000 As sold, ;
|
|
00000000000000000000.0000 As soldcumulat, 0 As tip, 00 As luna_inc, 0000 As an_inc, 0 As sold_final, ;
|
|
00000000000000000000.0000 As vechime_1, 00000000000000000000.0000 As vechime_2, 00000000000000000000.0000 As vechime_3, 00000000000000000000.0000 As vechime_4 ;
|
|
From cFacturi ;
|
|
Where totctva - achitat <> 0 ;
|
|
Order By nume, id_part, acont, dataact, serie_act, nract ;
|
|
Into Cursor cFactInc Readwrite
|
|
|
|
|
|
|
|
* adaug platile / incasarile
|
|
Select cIncasari_temp
|
|
Scan
|
|
Scatter Name oInc
|
|
Select cFactInc
|
|
*!* modificare v 2.0.50
|
|
*!* Locate For id_fact = oInc.id_fact And id_part = oInc.id_part And Nvl(acont,[xxxx]) = Nvl(oInc.acont,[xxxx]) And tip = 0
|
|
Locate For id_fact = oInc.id_fact And id_part = oInc.id_part And Nvl(acont, [xxxx]) = Nvl(oInc.acont, [xxxx])
|
|
*!* If !Found() Or suma <> 0
|
|
Do Case
|
|
Case !Found() && nu exista factura pentru incasare
|
|
*!* modificare v 2.0.50 ^
|
|
*!* modificare v 2.0.46
|
|
*!* Append blank
|
|
*!* caut incasarea neimperecheata
|
|
If Used('crstempireg')
|
|
Use In crstempireg
|
|
Endif
|
|
lcSql = [select 1 as precedent,id_fact,id_part,serie_act as serie_fact,nract as nrfact,dataact as datafact,] + ;
|
|
[pack_sesiune.suma_ron((-1)*] + ;
|
|
Iif(!tlActiv, Iif(tnCuValuta = 0, [debit], [valdebit]), Iif(tnCuValuta = 0, [credit], [valcredit])) + ;
|
|
[,Nvl(dataact,to_date(an||luna,'YYYYMM'))) as totctvaprec ] + ;
|
|
[from ireg_parteneri ] + ;
|
|
[where id_fact = ] + Alltrim(Str(oInc.id_fact)) + [ and id_part = ] + Alltrim(Str(oInc.id_part)) + [ ] + ;
|
|
[and ] + Iif(tnCuValuta = 0, [precdeb=0 and preccred=0], [precvaldeb=0 and precvalcred=0]) + [ and ] + ;
|
|
Iif(!tlActiv, Iif(tnCuValuta = 0, [credit], [valcredit]), Iif(tnCuValuta = 0, [debit], [valdebit])) + [=0]
|
|
lnSucces = goExecutor.oExecute(lcSql, [crstempireg])
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 16, "Eroare")
|
|
Return
|
|
Else
|
|
If Reccount('crstempireg') > 0
|
|
Select crstempireg
|
|
Scatter Name oComplet
|
|
AddProperty(oComplet, "totctva", oComplet.totctvaprec)
|
|
Use In crstempireg
|
|
Select cFacturi
|
|
Locate For id_fact = oComplet.id_fact && verificare daca mai exista deja
|
|
If !Found()
|
|
Append Blank
|
|
Gather Name oComplet Fields id_part, totctva, totctvaprec, precedent
|
|
Select cFactInc
|
|
Append Blank
|
|
Gather Name oComplet
|
|
Else
|
|
Select cFactInc
|
|
Append Blank
|
|
Endif
|
|
Else
|
|
Select cFactInc
|
|
Append Blank
|
|
Endif
|
|
Endif
|
|
*!* modificare v 2.0.50
|
|
Case Found() And ((tip = 1) Or (tip = 0 And suma <> 0)) && daca mai exista deja o incasare pe factura sau are achitat din precedent
|
|
Scatter Name objFactInc
|
|
Append Blank
|
|
Gather Name objFactInc
|
|
Replace totctva With 0
|
|
Case Found() And tip = 0 && daca nu mai exista incasare pe factura
|
|
&& completez dupa case
|
|
Otherwise && adaug incasarea
|
|
Append Blank
|
|
Endcase
|
|
*!* Endif
|
|
*!* modificare v 2.0.50 ^
|
|
*!* modificare v 2.0.46 ^
|
|
Gather Name oInc
|
|
Replace tip With 1
|
|
Select cIncasari_temp
|
|
Endscan
|
|
* calculez soldurile (initial, cumulat, pe factura)
|
|
* ordonez datele pentru grupare
|
|
*!* SELECT id_part, SUM(totctva-achitat) as soldi_part FROM cFacturi WHERE an*12 + luna = lnNrPrimaL INTO CURSOR cSoldiPart GROUP BY id_part
|
|
*!* SELECT id_part,acont, SUM(totctva-achitat) as soldi_ana FROM cFacturi WHERE an*12 + luna = lnNrPrimaL INTO CURSOR cSoldiAna GROUP BY id_part, acont
|
|
|
|
&& 27.05.2008
|
|
&& soldurile initiale pentru facturile emise in perioada nu se pot obtine din facturile din cFacturi (nu am precdeb/preccred <> 0)
|
|
If tlemise
|
|
Select id_part, Sum(soldprec) As soldi_part From cSoldParteneri Into Cursor cSoldiPart Group By id_part
|
|
Select id_part, Nvl(acont, Space(4)) As acont, Sum(soldprec) As soldi_ana From cSoldParteneri Into Cursor cSoldiAna Group By id_part, acont Readwrite
|
|
Else
|
|
*!* modificare v 2.0.46
|
|
*!* Select id_part, Sum(totctva-achitat) As soldi_part From cFacturi Where precedent = 1 Into Cursor cSoldiPart Group By id_part
|
|
*!* Select id_part,Nvl(acont,Space(4)) As acont, Sum(totctva-achitat) As soldi_ana From cFacturi Where precedent = 1 Into Cursor cSoldiAna Group By id_part, acont Readwrite
|
|
Select id_part, Sum(totctvaprec - achitat) As soldi_part From cFacturi Where precedent = 1 Into Cursor cSoldiPart Group By id_part
|
|
Select id_part, Nvl(acont, Space(4)) As acont, Sum(totctvaprec - achitat) As soldi_ana From cFacturi Where precedent = 1 Into Cursor cSoldiAna Group By id_part, acont Readwrite
|
|
*!* modificare v 2.0.46 ^
|
|
Endif
|
|
&& 27.05.2008 ^
|
|
|
|
*!* modificare v 2.0.50 : am adaugat NVL(...,0)
|
|
*!* modificare v 2.0.82 : am adaugat NVL(...,0.0000)
|
|
Select c.*, Nvl(p.soldi_part, 0.0000) As soldi_part, Nvl(a.soldi_ana, 0.0000) As soldi_ana From cFactInc c ;
|
|
Left Join cSoldiPart p On c.id_part = p.id_part ;
|
|
Left Join cSoldiAna a On c.id_part = a.id_part And Nvl(c.acont, '') = Nvl(a.acont, '') ;
|
|
Into Cursor cFactIncO Order By c.nume, c.id_part, c.acont, c.datafact, c.serie_fact, c.nrfact, c.id_fact Readwrite
|
|
If Used('cSoldiPart')
|
|
Use In cSoldiPart
|
|
Endif
|
|
If Used('cSoldiAna')
|
|
Use In cSoldiAna
|
|
Endif
|
|
* soldul cumulat
|
|
**** pt vechime (temporar) aflu ultima zi a perioadei , consider data de referinta
|
|
ldDataVechime = Gomonth(Date(tnAnF, tnLunaF, 1), 1) - 1
|
|
****
|
|
|
|
Select cFactIncO
|
|
Locate
|
|
lnIdFact = id_fact
|
|
lnIdPart = id_part
|
|
lnSoldFact = Nvl(totctva, 0)
|
|
lnSoldPart = Nvl(soldi_part, 0)
|
|
*ldDataFactura = NVL(TTOD(datafact),{})
|
|
ldDataFactura = Nvl(datafact, {})
|
|
Scan
|
|
Scatter Name osold
|
|
lnNrRand = Recno()
|
|
If lnIdFact <> osold.id_fact
|
|
Select cFactIncO
|
|
If tnCuVechime = 1
|
|
Go lnNrRand - 1
|
|
Replace sold_final With 1
|
|
lnNrZile = ldDataVechime - ldDataFactura
|
|
If Empty(ldDataFactura)
|
|
lnNrZile = 400 && peste 1 An
|
|
Else
|
|
lnNrZile = ldDataVechime - ldDataFactura
|
|
Endif
|
|
Do Case
|
|
Case Between(lnNrZile, 0, 30)
|
|
Replace vechime_1 With sold
|
|
Case Between(lnNrZile, 31, 90)
|
|
Replace vechime_2 With sold
|
|
Case Between(lnNrZile, 91, 365)
|
|
Replace vechime_3 With sold
|
|
Otherwise
|
|
Replace vechime_4 With sold
|
|
Endcase
|
|
|
|
Select cFactIncO
|
|
Go lnNrRand
|
|
Endif
|
|
*ldDataFactura = NVL(TTOD(datafact),{})
|
|
ldDataFactura = Nvl(datafact, {})
|
|
lnIdFact = osold.id_fact
|
|
lnSoldFact = Nvl(osold.totctva, 0)
|
|
Endif
|
|
If lnIdPart <> osold.id_part
|
|
lnIdPart = osold.id_part
|
|
lnSoldPart = Nvl(osold.soldi_part, 0)
|
|
Endif
|
|
lnSoldFact = lnSoldFact - Nvl(osold.suma, 0)
|
|
* lnSoldPart = lnSoldPart + IIF(osold.an*12+osold.luna >=lnnrlunii, NVL(osold.totctva,0), 0) - IIF(osold.an_inc*12+osold.luna_inc >=lnnrlunii, NVL(osold.suma,0), 0)
|
|
lnSoldPart = lnSoldPart + Iif(osold.precedent = 0, Nvl(osold.totctva, 0), 0) - Iif(osold.an_inc * 12 + osold.luna_inc >= lnnrlunii, Nvl(osold.suma, 0), 0)
|
|
Replace sold With lnSoldFact, soldcumulat With lnSoldPart
|
|
Select cFactIncO
|
|
Endscan
|
|
|
|
If tnCuVechime = 1
|
|
Select cFactIncO
|
|
Go Bottom
|
|
Replace sold_final With 1
|
|
*ldDataFactura = NVL(TTOD(datafact),{})
|
|
ldDataFactura = Nvl(datafact, {})
|
|
If Empty(ldDataFactura)
|
|
lnNrZile = 400 && peste 1 An
|
|
Else
|
|
lnNrZile = ldDataVechime - ldDataFactura
|
|
Endif
|
|
Do Case
|
|
Case Between(lnNrZile, 0, 30)
|
|
Replace vechime_1 With sold
|
|
Case Between(lnNrZile, 31, 90)
|
|
Replace vechime_2 With sold
|
|
Case Between(lnNrZile, 91, 365)
|
|
Replace vechime_3 With sold
|
|
Otherwise
|
|
Replace vechime_4 With sold
|
|
Endcase
|
|
Endif
|
|
|
|
*!* SELECT cFactIncO
|
|
*!* DELETE from cFactIncO WHERE id_fact IN (select id_fact from cFactIncO where sold_final = 1 AND NVL(vechime_1,0) = 0 AND NVL(vechime_2,0) = 0 AND NVL(vechime_3,0) = 0 AND NVL(vechime_4,0) = 0)
|
|
|
|
If Used('cFacturi')
|
|
Use In cFacturi
|
|
Endif
|
|
If Used('cIncasari_temp')
|
|
Use In cIncasari_temp
|
|
Endif
|
|
If Used('cFactInc')
|
|
Use In cFactInc
|
|
Endif
|
|
|
|
Return "cFactIncO"
|
|
Endproc
|
|
******************************************* SFARSIT: situatie_facturi *******************************************
|
|
|
|
*!* * PROCEDURE situatie_facturi
|
|
*!* * Date : 24/11/2004, 16:10:03
|
|
*!* * author : lavinia.viziru
|
|
*!* * description: preluare facturi pentru clienti/furnizori
|
|
|
|
*!* ****** PARAMETER BLOCK **************
|
|
*!* * Parameters : 3
|
|
*!* * Parameter 1: tlemise
|
|
*!* * Description: tipul facturilor preluate
|
|
*!* * (.t.-facturi emise intr-o perioada determinata
|
|
*!* * .f.-facturi cu sold dintr-o perioada determinata)
|
|
*!* * Parameter 2: tccont
|
|
*!* * Description: contul partenerului(411-client, 401- furnizor)
|
|
*!* * Parameter 3: topartener
|
|
*!* * Description: obiectul care contine datele partenerului(client/furnizor) selectat:nume + id_part
|
|
*!* * (daca numele partenerului=<TOATE INREGISTRARILE> atunci se iau in considerare
|
|
*!* * toti partenerii- clienti sau furnizori)
|
|
*!* ******************************************* INCEPUT:situatie_facturi *******************************************
|
|
*!* PROCEDURE situatie_facturi
|
|
*!* PARAMETERS tccont,tlemise,topartener,tnani,tnlunai,tnanf,tnlunaf
|
|
|
|
*!* LOCAL lnrlunii,lnrlunif
|
|
*!* lnnrlunii = tnlunai + 12*tnani
|
|
*!* lnnrlunif = tnlunaf + 12*tnanf
|
|
|
|
*!* IF UPPER(ALLTRIM(topartener.nume)) = [<TOATE INREGISTRARILE>]
|
|
*!* lcCondId_part = [1=1]
|
|
*!* ELSE
|
|
*!* lcCondId_part = [id_part = ] + STR(topartener.id_part)
|
|
*!* ENDIF
|
|
|
|
*!* IF ALLTRIM(tccont) = [401] && furnizori
|
|
*!* lcTotctva = [credit + preccred as totctva]
|
|
*!* lcPereche = [pereched]
|
|
*!* lcPartener = [partd]
|
|
*!* lcCondExclud = [(SUBSTR(scd,1,3) <> '767')]
|
|
*!* ELSE && [411] - clienti
|
|
*!* lcTotctva = [debit + precdeb as totctva]
|
|
*!* lcPereche = [perechec]
|
|
*!* lcPartener = [partc]
|
|
*!* lcCondExclud = [(SUBSTR(scc,1,3) not in ('667','622'))]
|
|
*!* ENDIF
|
|
|
|
*!* lcCondPerioada = [((luna + 12*an) between ] + ALLTRIM(STR(lnnrlunii)) + [ and ] + ALLTRIM(STR(lnnrlunif)) + [)]
|
|
*!* lcCondData = [(to_number(to_char(dataireg,'MM'),'99') + 12*to_number(to_char(dataireg,'YYYY'),'9999'))]
|
|
*!* lcCondPrimaLuna = [(luna + 12*an = ] + ALLTRIM(STR(lnnrlunii)) + [)]
|
|
|
|
*!* lcSelect = [select nume,dataact,nract,] + lcTotctva + ;
|
|
*!* [ from ] + gcS + [.vireg_parteneri ] + ;
|
|
*!* [where cont = '] + tccont + [' and ] + lcCondId_part + [ and ] + lcCondPerioada + ;
|
|
*!* [ and (luna + 12*an =] + IIF(tlemise,lcCondData,[(case when ] + lcCondPrimaLuna +;
|
|
*!* [ then luna + 12*an else ] + lcCondData + [ end)]) + [)]
|
|
*!* lcCursor = [cFacturi]
|
|
|
|
*!* IF USED(lcCursor)
|
|
*!* USE IN (lcCursor)
|
|
*!* ENDIF
|
|
|
|
*!* lnSucces = goExecutor.oExecute(lcSelect,lcCursor)
|
|
*!* IF lnSucces < 0
|
|
*!* MESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
|
|
*!* RETURN
|
|
*!* ENDIF
|
|
*!*
|
|
*!* && iau in considerare doar incasarile inregistrate pana la sfarsitul perioadei date
|
|
*!* lcCondDataIreg = [extract(month from dataireg)+12*extract( year from dataireg) <= ] + ;
|
|
*!* ALLTRIM(STR(lnnrlunif))
|
|
*!*
|
|
*!* lcSelect1 = [select ] + lcPartener + [ as nume,fdoc,dataact,nract,] + lcPereche + [ as pereche,suma ] +;
|
|
*!* [ from ] + gcS+ [.vact ] + ;
|
|
*!* [ where SUBSTR(] + IIF(ALLTRIM(tccont) = '401',[scd],[scc]) + [,1,3) = ] + tccont + ;
|
|
*!* [ and ] + lcCondExclud + [ and ] + lcPereche + [ <> 0 and ] + lcCondDataIreg
|
|
*!* lcCursor1 = [cIncasari_temp]
|
|
|
|
*!* IF USED(lcCursor1)
|
|
*!* USE IN (lcCursor1)
|
|
*!* ENDIF
|
|
|
|
*!* lnSucces1 = goExecutor.oExecute(lcSelect1,lcCursor1)
|
|
|
|
*!* IF lnSucces1 < 0
|
|
*!* MESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
|
|
*!* RETURN
|
|
*!* ENDIF
|
|
|
|
*!* SELECT *,.f. as bifat FROM cIncasari_temp ;
|
|
*!* WHERE nume+"/"+STR(pereche,14) IN (SELE nume+"/"+STR(nract,14) FROM cFacturi) ;
|
|
*!* INTO CURSOR cIncasari READWRITE ORDER BY nume, pereche, dataact
|
|
|
|
*!* *!* CREATE CURSOR cFactInc ;
|
|
*!* *!* (id_fact N(10), nume C(50), datafact D(8), nrfact N(14), totctva N(20,4),
|
|
*!* *!* fdoc C(30), datadoc D(8), nrdoc N(14), suma N(20,4), tip N(1), sold N(20,4))
|
|
|
|
*!* SELECT 0000000000 AS id_fact, nume, dataact AS datafact, nract AS nrfact, totctva, ;
|
|
*!* SPACE(20) AS fdoc, {//} AS datadoc, 00000000000000 AS nrdoc, ;
|
|
*!* 00000000000000000000.0000 AS suma, 0 AS tip, 00000000000000000000.0000 AS sold, ;
|
|
*!* 00000000000000000000.0000 AS soldcumul ;
|
|
*!* FROM cFacturi ;
|
|
*!* INTO CURSOR cFactInc READWRITE ORDER BY nume
|
|
|
|
*!* SELECT cFactInc
|
|
*!* REPLACE ALL id_fact WITH RECNO()
|
|
|
|
*!* GO top
|
|
*!* lcNume = nume
|
|
*!* lnId_fact = id_fact
|
|
*!* lnSoldCumul = 0
|
|
|
|
*!* SCAN FOR tip = 0
|
|
*!*
|
|
*!* IF UPPER(ALLTRIM(lcNume)) <> UPPER(ALLTRIM(nume))
|
|
*!* lcNume = nume
|
|
*!* lnSoldCumul = 0
|
|
*!* ENDIF
|
|
*!*
|
|
*!* lnId_fact = id_fact
|
|
*!* ldDatafact = datafact
|
|
*!* lnNrfact = nrfact
|
|
*!* lnTotctva = totctva
|
|
*!*
|
|
*!* lnSold = totctva
|
|
*!* lnSoldCumul = lnSoldCumul + totctva
|
|
*!* lnAchitat = 0
|
|
*!* SELECT cIncasari
|
|
*!* LOCATE FOR UPPER(ALLTRIM(nume)) = UPPER(ALLTRIM(lcNume)) AND pereche = lnNrfact ;
|
|
*!* AND dataact >= ldDatafact AND !bifat
|
|
*!* IF FOUND()
|
|
*!* llprim = .T.
|
|
*!* DO WHILE .t.
|
|
*!* lcFdoc = NVL(fdoc,[])
|
|
*!* lnNrdoc = NVL(nract,0)
|
|
*!* ldDatadoc = NVL(dataact,{})
|
|
*!* lnAchitat = NVL(suma,0)
|
|
*!* lnSold = lnSold - lnAchitat
|
|
*!* lnSoldCumul = lnSoldCumul - lnAchitat
|
|
*!* IF llprim
|
|
*!* llprim = .F.
|
|
*!* REPLACE fdoc WITH lcFdoc, datadoc WITH ldDatadoc, nrdoc WITH lnNrdoc, ;
|
|
*!* suma WITH lnAchitat, sold WITH lnSold,soldcumul WITH lnSoldCumul ;
|
|
*!* IN cFactInc
|
|
*!* ELSE
|
|
*!* SELECT cFactInc
|
|
*!* lnPos = RECNO()
|
|
*!* INSERT INTO cFactInc VALUES (lnId_fact, lcNume, ldDatafact, lnNrfact, ;
|
|
*!* lnTotctva, lcFdoc, ldDatadoc, lnNrdoc, lnAchitat, 1, lnSold, lnSoldCumul)
|
|
*!* GOTO lnPos
|
|
*!* ENDIF
|
|
*!*
|
|
*!* SELECT cIncasari
|
|
*!* REPLACE bifat WITH .t.
|
|
*!* SKIP
|
|
*!* IF UPPER(ALLTRIM(nume)) <> UPPER(ALLTRIM(lcNume)) OR pereche <> lnNrfact
|
|
*!* EXIT
|
|
*!* ENDIF
|
|
*!* ENDDO
|
|
*!* ELSE
|
|
*!* replace sold WITH lnSold, soldcumul WITH lnSoldCumul IN cFactInc
|
|
*!* ENDIF
|
|
*!* SELECT cFactInc
|
|
*!* ENDSCAN
|
|
|
|
*!* *ordonez datele pentru grupare
|
|
*!* SELECT * FROM cFactInc INTO CURSOR cFactIncO ORDER BY nume, id_fact, tip
|
|
|
|
*!* USE IN cFacturi
|
|
*!* USE IN cIncasari
|
|
*!* USE IN cFactInc
|
|
|
|
*!* RETURN "cFactIncO"
|
|
*!* ENDPROC
|
|
*!* ******************************************* SFARSIT: situatie_facturi *******************************************
|
|
|
|
* PROCEDURE list_facturi_neachitate
|
|
* Date : 01/12/2004, 11:31:42
|
|
* author : lavinia.viziru
|
|
* description:
|
|
|
|
****** PARAMETER BLOCK **************
|
|
* Parameters : 1
|
|
* Parameter 1: tccont
|
|
* Parameter 1 description: contul partenerului (401 - furnizor/411 - client)
|
|
**************************** INCEPUT:list_facturi_neachitate ********************************
|
|
Procedure list_facturi_neachitate
|
|
Parameters tccont, tlgrupate, tlanalitic
|
|
|
|
Local lcCont, lopartener
|
|
|
|
Private pctitlu, pcpartener, plgrupate, pcperioada, planalitic, pctitlu_analitic
|
|
Store '' To pctitlu, pcpartener, pcperioada, pctitlu_analitic
|
|
|
|
planalitic = tlanalitic
|
|
plgrupate = tlgrupate
|
|
lcCont = Alltrim(tccont)
|
|
lcAcont = []
|
|
|
|
|
|
If planalitic
|
|
&& cauta analitic
|
|
lcselect0 = [select cont,acont,explicatie from vplcont_analitic]
|
|
lcfiltru0 = []
|
|
lcschema0 = []
|
|
lcorder0 = [acont]
|
|
lccoloane0 = [cont,acont,explicatie]
|
|
lcTitlu0 = [Alegeti simbolul analitic]
|
|
lcTitluColoane0 = [Cont,Acont,Explicatie]
|
|
*!* 30.05.2008
|
|
*!* ?gnAn doar analiticele din anul curent
|
|
lcFiltruOriginal0 = [an = ?gnAn and cont = '] + lcCont + [' ]
|
|
*!* 30.05.2008 ^
|
|
loanalitic = cauta_alfa(lcselect0, lcfiltru0, lcschema0, lcorder0, lccoloane0, lcTitlu0, lcTitluColoane0, "", .F., lcFiltruOriginal0) && 11.07.2007
|
|
lcAcont = Alltrim(loanalitic.acont)
|
|
If Empty(lcAcont)
|
|
planalitic = .F.
|
|
Else
|
|
pctitlu_analitic = [Analitic: ] + lcCont + [.] + lcAcont + [ - ] + loanalitic.explicatie
|
|
Endif
|
|
Endif
|
|
|
|
If lcCont = [401] && furnizori
|
|
lcTitlu = 'Alegeti numele furnizorului'
|
|
lcTotctva = [credit + preccred as totctva]
|
|
lcAchitat = [debit + precdeb as achitat]
|
|
lctitlu_rap = [Situatie - Facturi de achizitii neachitate] + ;
|
|
Iif(tlgrupate, [(pe furnizori)], [(in ordinea emiterii)])
|
|
pcpartener = [Furnizor: ]
|
|
Else && clienti
|
|
lcTitlu = 'Alegeti numele clientului'
|
|
lcTotctva = [debit + precdeb as totctva]
|
|
lcAchitat = [credit + preccred as achitat]
|
|
lctitlu_rap = [Situatie - Facturi de vanzari neincasate] + ;
|
|
Iif(tlgrupate, [(pe clienti)], [(in ordinea emiterii)])
|
|
pcpartener = [Client: ]
|
|
Endif
|
|
|
|
lopartener = caut_parteneri(lcCont, lcTitlu, .T.)
|
|
If Empty(lopartener.denumire)
|
|
Return
|
|
Endif
|
|
|
|
If Upper(Alltrim(lopartener.denumire)) = [<TOATE INREGISTRARILE>]
|
|
lcCondId_part = [1=1]
|
|
Else
|
|
lcCondId_part = [id_part = ] + Str(lopartener.id_part)
|
|
Endif
|
|
|
|
*!* 30.05.2008
|
|
*!* lcCondNeachitat - nu voia sa afiseze facturile cu sold < 1000 ROL :)
|
|
*!* lcCondNeachitat=[( !(abs(totctva-achitat)<1000 or ABS(totctva)<ABS(achitat)) OR totctva<0)]
|
|
lcCondNeachitat = [.T.]
|
|
*!* 30.05.2008 ^
|
|
*!* 27aug2008 - la order by era doar: [ order by ] + Iif(plgrupate,[nume],[dataact])
|
|
lcSelect = [select nume,dataact,serie_act,nract,datascad,] + lcTotctva + [,] + lcAchitat + ;
|
|
[ from ] + gcs + [.vireg_parteneri ] + ;
|
|
[where cont = '] + tccont + [' and ] + lcCondId_part + [ and an = ] + Alltrim(Str(gnAn)) + ;
|
|
[ and luna = ] + Alltrim(Str(gnLuna)) + ;
|
|
[ and ] + Iif(Empty(lcAcont), [1=1], [acont = '] + lcAcont + [']) + gcCondSucursala + ;
|
|
[ order by ] + Iif(plgrupate, [nume,dataact,nract], [dataact])
|
|
lcCursor = [cFact_temp]
|
|
*!* 27aug2008 ^
|
|
|
|
|
|
*STRTOFILE(lcSelect,'c:\sel.txt')
|
|
|
|
*!* IF USED(lcCursor)
|
|
*!* USE IN (lcCursor)
|
|
*!* ENDIF
|
|
|
|
lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return
|
|
Endif
|
|
|
|
lcSel = [SELECT * from cFact_temp into cursor cFactNeachit WHERE ] + lcCondNeachitat
|
|
&lcSel
|
|
|
|
Select cFactNeachit
|
|
|
|
|
|
*!* If Reccount('cFactNeachit')>0
|
|
pcperioada = [Luna: ] + Alltrim(Str(gnLuna)) + [/] + Alltrim(Str(gnAn))
|
|
lcRaport = [rap_facturi_neachit]
|
|
pctitlu = lctitlu_rap
|
|
*!* pctitlu = ceretitlu_rap('Titlul Raportului',lctitlu_rap)
|
|
*!* pcDataOra = Get_Ora(2)
|
|
goExport.export2frx([cFactNeachit], lcRaport)
|
|
*!* Select cFactNeachit
|
|
*!* Report Form (lcRaport) To Printer Prompt Preview
|
|
*!* Else
|
|
*!* amessagebox("Nu exista inregistrari pentru listare!",48,"Atentie")
|
|
*!* Endif
|
|
|
|
Use In (lcCursor)
|
|
|
|
Endproc
|
|
**************************** SFARSIT:list_facturi_neachitate ********************************
|
|
|
|
* PROCEDURE list_facturi_scadente( )
|
|
* Date : 02/12/2004, 15:40:57
|
|
* author : lavinia.viziru
|
|
* description:
|
|
|
|
****** PARAMETER BLOCK **************
|
|
* Parameters : 0
|
|
*
|
|
******************************** INCEPUT:list_facturi_scadente ******************************
|
|
Procedure list_facturi_scadente
|
|
Parameters tccont
|
|
|
|
Private pctitlu, pcperioada, planalitic, plgrupate && ,pcDataOra
|
|
Store '' To pctitlu, pcperioada && ,pcDataOra
|
|
Store .F. To planalitic, plgrupate
|
|
|
|
Private pddataref, pddatascad_max, pnnrluni
|
|
Store 0 To pnnrluni
|
|
pddataref = Date()
|
|
pddatascad_max = Date()
|
|
|
|
ofrmscad = Createobject('frm_facturi_scadente')
|
|
ofrmscad.txt_dataref.ControlSource = [pddataref]
|
|
ofrmscad.txt_datamax.ControlSource = [pddatascad_max]
|
|
ofrmscad.Show(1)
|
|
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
|
|
lcCont = Alltrim(tccont)
|
|
If lcCont = [401]
|
|
lcTotctva = [credit + preccred as totctva]
|
|
lcAchitat = [debit + precdeb as achitat]
|
|
Else && lccont = 411
|
|
lcTotctva = [debit + precdeb as totctva]
|
|
lcAchitat = [credit + preccred as achitat]
|
|
Endif
|
|
|
|
lccondScad = [(datascad < to_date('] + Dtos(pddatascad_max) + [','yyyymmdd'))]
|
|
lcCondNeachit = [(ABS(totctva)>ABS(achitat))]
|
|
|
|
lcSelect = [select nume,dataact,serie_act,nract,datascad,] + lcTotctva + [,] + lcAchitat + ;
|
|
[ from ] + gcs + [.vireg_parteneri ] + ;
|
|
[where cont = '] + tccont + [' and an = ] + Alltrim(Str(gnAn)) + ;
|
|
[ and luna = ] + Alltrim(Str(gnLuna)) + [ and ] + lccondScad + ;
|
|
gcCondSucursala + ;
|
|
[ order by datascad ]
|
|
lcCursor = [cFactScad_temp]
|
|
|
|
lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return
|
|
Endif
|
|
|
|
lcSel = [SELECT * from cFactScad_temp into cursor cFactScad WHERE ] + lcCondNeachit
|
|
&lcSel
|
|
|
|
pctitlu = 'Facturi de achizitii scadente, cu data scadenta mai veche de ' + Alltrim(Dtoc(pddatascad_max))
|
|
pcperioada = [Luna: ] + Alltrim(Str(gnLuna)) + [/] + Alltrim(Str(gnAn))
|
|
lcRaport = [rap_facturi_neachit]
|
|
goExport.export2frx([cFactScad], lcRaport, .T.)
|
|
*!* Select cFactScad
|
|
*!* If Reccount() = 0
|
|
*!* && afiseaza mesaj
|
|
*!* amessagebox("Nu exista facturi neachitate atat de vechi!",48,"Atentie")
|
|
*!* *!* ostop=CREATEOBJECT('stop')
|
|
*!* *!* ostop.image1.PICTURE = 'd:\contafin_oracle\cont2003\grafice\point04.ico'
|
|
*!* *!* ostop.label3.VISIBLE = .F.
|
|
*!* *!* ostop.label2.CAPTION = [Nu exista facturi neachitate atat de vechi!]
|
|
*!* *!* ostop.label2.FONTNAME = 'Arial Narrow'
|
|
*!* *!* ostop.SHOW(1)
|
|
*!* Else
|
|
|
|
*!* lctitlu='Facturi de achizitii scadente, cu data scadenta mai veche de ' + ;
|
|
*!* ALLTRIM(Dtoc(pddatascad_max))
|
|
|
|
*!* *!* DO CASE
|
|
*!* *!* CASE pnnrluni = 0
|
|
*!* *!* lctitlu='Facturi de achizitii scadente cu data scadenta mai veche de ' + ;
|
|
*!* *!* ALLTRIM(DTOC(pddatascad_max))
|
|
*!* *!* CASE pnnrluni = 1
|
|
*!* *!* lctitlu='Facturi de achizitii a caror data scadenta este depasita '+ ;
|
|
*!* *!* 'cu cel putin o luna fata de data '+ALLTRIM(DTOC(pddataref))
|
|
*!* *!* OTHERW
|
|
*!* *!* lctitlu='Facturi de achizitii a caror data scadenta este depasita '+ ;
|
|
*!* *!* 'cu cel putin ' + ALLT(STR(pnnrluni))+' luni fata de data '+ALLTRIM(DTOC(pddataref))
|
|
*!* *!* ENDCASE
|
|
*!* pctitlu = ceretitlu_rap('Titlul Raportului',lctitlu)
|
|
|
|
*!* pcperioada = [Luna: ] + Alltrim(Str(gnLuna)) + [/] + Alltrim(Str(gnAn))
|
|
*!* lcRaport = [rap_facturi_neachit]
|
|
*!* pcDataOra = Get_Ora(2)
|
|
|
|
*!* Select cFactScad
|
|
*!* Report Form (lcRaport) To Printer Prompt Preview
|
|
*!* Endif
|
|
|
|
Use In (lcCursor)
|
|
Use In cFactScad
|
|
Release pctitlu
|
|
Endproc
|
|
******************************** SFARSIT:list_facturi_scadente ******************************
|
|
|
|
* PROCEDURE facturi_furnizor_client( )
|
|
* Date : 06/12/2004, 10:17:25
|
|
* author : lavinia.viziru
|
|
* description:
|
|
|
|
****** PARAMETER BLOCK **************
|
|
* Parameters : 0
|
|
*
|
|
******************************* INCEPUT:facturi_furnizor_client *****************************
|
|
Procedure facturi_furnizor_client
|
|
|
|
Private pctitlu && ,pcDataOra
|
|
Store '' To pctitlu && ,pcDataOra
|
|
|
|
*!* lcSelect = [select distinct nume,cod_fiscal,id_part,inactiv from ] + gcs + [.Vcoresp_tip_part p ] +;
|
|
*!* [join ] + gcs + [.Vcoresp_tip_cont c on p.id_tip_part = c.id_tip_part]
|
|
*!* lcfiltru = [c.cont = '401' and p.id_part in (select distinct id_part from ] + gcs +;
|
|
*!* [.Vcoresp_tip_part p join ] + gcs + [.vcoresp_tip_cont c on ] + ;
|
|
*!* [p.id_tip_part = c.id_tip_part where c.cont = '4111')]
|
|
*!* lcschema = ['']
|
|
*!* lcorder = [nume]
|
|
*!* lccoloane = [Nume,cod_fiscal,inactiv,id_part]
|
|
*!* lctitlu = [Alegeti un partener (furnizor-client)]
|
|
*!* lcTitluColoane = [Nume,Cod fiscal,Inactiv,ID]
|
|
*!* lopartener = cauta_alfa(lcSelect,lcfiltru,lcschema,lcorder,lccoloane,lctitlu,lcTitluColoane,"",.F.)
|
|
lopartener = CautPartenerContabilitate(GetHash([cTitlu=>Alegeti un partener (furnizor-client)??cCont=>401] + ;
|
|
[??cFiltruOrig=>a.id_part in (select distinct id_part from ] + gcs + ;
|
|
[.Vcoresp_tip_part p join ] + gcs + [.vcoresp_tip_cont c on ] + ;
|
|
[p.id_tip_part = c.id_tip_part where c.cont = '4111')]))
|
|
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
|
|
lcnume = Alltrim(lopartener.nume)
|
|
lnid_part = lopartener.id_part
|
|
|
|
If Empty(lcnume)
|
|
lcCondPart = [1=1]
|
|
Else
|
|
lcCondPart = [id_part = ] + Alltrim(Str(lnid_part))
|
|
Endif
|
|
|
|
lcCondPart = [id_part = ] + Alltrim(Str(lnid_part))
|
|
|
|
lcCondLunaC = [ an = ] + Alltrim(Str(gnAn)) + [ and luna = ] + Alltrim(Str(gnLuna))
|
|
lcCondN = [(cont='401' and ((totctva>achitat and achitat>=0) or (totctva<achitat and totctva<0))) or cont='4111']
|
|
|
|
lcTotctva = [(case when cont='401' then credit + preccred else debit + precdeb end) as totctva]
|
|
lcAchitat = [(case when cont='401' then debit + precdeb else credit + preccred end) as achitat]
|
|
|
|
lcSelect = [select * from (select nume,nract,serie_act,dataact,datascad,cont,] + lcTotctva + [,] + lcAchitat + ;
|
|
[ from ] + gcs + [.vireg_parteneri where cont in ('401','4111') and ] + ;
|
|
lcCondPart + [ and ] + lcCondLunaC + gcCondSucursala + [)] + [ where ] + lcCondN + ;
|
|
[ order by cont,dataact,serie_act,nract]
|
|
lcCursor = [cFactFurnCli]
|
|
|
|
lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return
|
|
Endif
|
|
|
|
*!* If Reccount(lcCursor)>0
|
|
pctitlu = [Situatia facturilor de incasat/platit/compensat]
|
|
*!* lctitlu='Situatia facturilor de incasat/platit/compensat'
|
|
*!* pctitlu = ceretitlu_rap('Titlul Raportului',lctitlu)
|
|
pcperioada = [Luna: ] + Alltrim(Str(gnLuna)) + [/] + Alltrim(Str(gnAn))
|
|
goExport.export2frx(lcCursor, [rap_facturi_furncli], .T.)
|
|
*!* pcDataOra= Get_Ora(2)
|
|
*!* Select (lcCursor)
|
|
*!* Report Form rap_facturi_furncli To Printer Prompt Preview
|
|
*!* Else
|
|
*!* amessagebox("Nu exista inregistrari pentru listare!",48,"Atentie")
|
|
*!* Endif
|
|
|
|
Use In (lcCursor)
|
|
|
|
Endproc
|
|
******************************** SFARSIT: facturi_furnizor_client ***************************
|
|
|
|
|
|
* PROCEDURE incasari_facturi_lunac
|
|
* Date : 07/12/2004, 15:16:30
|
|
* author : lavinia.viziru
|
|
* description:
|
|
|
|
****** PARAMETER BLOCK **************
|
|
* Parameters : 0
|
|
*
|
|
|
|
* PROCEDURE listare_registru_vanzcump
|
|
* Date : 09/12/2004, 11:57:13
|
|
* author : lavinia.viziru
|
|
* description:
|
|
|
|
****** PARAMETER BLOCK **************
|
|
* Parameters : 1
|
|
* Parameter 1: tccont
|
|
* contul : 401 - furnizori /411 - clienti
|
|
* Parameter 2: tctip
|
|
* tipul raportului : NORMAL , SIMPLIFICAT, CONDENSAT
|
|
* Parameter 3: tlrecap
|
|
* cu/fara recapitulatii pe lunile dintr-o perioada
|
|
********************************** INCEPUT:listare_registru_vanzcump ***************************
|
|
Procedure listare_registru_vanzcump
|
|
Parameters tccont, tctip, tlrecap
|
|
|
|
lcCont = Alltrim(tccont)
|
|
lctip = Upper(Alltrim(tctip))
|
|
|
|
Private pnan, pnluna, pctitlu
|
|
Store 0 To pnan, pnluna
|
|
Store '' To pctitlu
|
|
|
|
lcvizualizare = Iif(lcCont = [401], [vcump], [vvanz])
|
|
lcTitlu = Iif(lcCont = [401], [JURNAL PENTRU CUMPARARI], [JURNAL PENTRU VANZARI])
|
|
|
|
If tlrecap
|
|
lcRaport = Iif(lcCont = [401], [rap_regcump_recap], [rap_regvanz_recap])
|
|
&& selectare luna initiala
|
|
locaut = Createobject('frm_caut_anluna')
|
|
locaut.Show(1)
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
lcnrlunii = Alltrim(Str(pnluna + 12 * pnan))
|
|
lcnrlunif = Alltrim(Str(gnLuna + 12 * gnAn))
|
|
lcSelect = [select * from (] + ;
|
|
[( select 'A' as tip,an,luna,dataact,nract,nume,cod_fiscal,totctva,neimpozab,] + ;
|
|
[totftvam,tvam,totftvai,tvai,scutit from ] + gcs + [.] + lcvizualizare + ;
|
|
[ where an = ] + Alltrim(Str(gnAn)) + [ and luna = ] + Alltrim(Str(gnLuna)) + [)] + ;
|
|
[ union ] + ;
|
|
[( select 'B' as tip,an,luna,to_date('','ddmmyyyy') as dataact,000000000 as nract,] + ;
|
|
[ (select numeluna from lunilean where nrluna = luna) as nume,' ' as cod_fiscal,] + ;
|
|
[sum(totctva) as totctva,sum(neimpozab) as neimpozab,] + ;
|
|
[sum(totftvam) as totftvam,sum(tvam) as tvam,sum(totftvai) as totftvai,sum(tvai) as tvai,scutit from ] + ;
|
|
gcs + [.] + lcvizualizare + ;
|
|
[ group by an,luna,scutit having (luna + 12*an between ] + lcnrlunii + [ and ] + lcnrlunif + [)) ] + ;
|
|
[) order by tip,dataact,nract]
|
|
*STRTOFILE(lcSelect,[c:\select_recap.txt])
|
|
Else
|
|
Do Case
|
|
Case lctip = [NORMAL]
|
|
lcRaport = Iif(lcCont = [401], [registru_cumparari_rpt1], [registru_vanzari_rpt1])
|
|
Case lctip = [SIMPLIFICAT]
|
|
lcRaport = [rap_regvanz_simplu]
|
|
Case lctip = [CONDENSAT]
|
|
lcRaport = [registru_vanzari_rpt1]
|
|
Endcase
|
|
If (lctip = [NORMAL]) Or (lctip = [SIMPLIFICAT])
|
|
lcSelect = [select dataact,nract,nume,cod_fiscal,totctva,neimpozab,totftvam,tvam, ] + ;
|
|
[totftvai,tvai,scutit from ] + gcs + [.] + lcvizualizare + ;
|
|
[ where an = ] + Alltrim(Str(gnAn)) + [ and luna = ] + Alltrim(Str(gnLuna)) + ;
|
|
[order by dataact]
|
|
|
|
Else && CONDENSAT
|
|
lcSelect = [select * from (] + ;
|
|
[( select 'A' as tip,dataireg,dataireg as dataact,000000000 as nract,'BON FISCAL' as nume,' ' as cod_fiscal,] + ;
|
|
[sum(totctva) as totctva,sum(neimpozab) as neimpozab,sum(totftvai) as totftvai,] + ;
|
|
[sum(tvai) as tvai,sum(totftvam) as totftvam,sum(tvam) as tvam,' ' as fdoc,scutit] + ;
|
|
[ from ] + gcs + [.] + lcvizualizare + ;
|
|
[ where UPPER(TRIM(fdoc)) = 'BON FISCAL' and an = ] + Alltrim(Str(gnAn)) + ;
|
|
[ and luna = ] + Alltrim(Str(gnLuna)) + [group by dataireg,scutit)] + ;
|
|
[ union ] + ;
|
|
[( select 'B' as tip,dataireg,dataact,nract,nume,cod_fiscal,totctva,] + ;
|
|
[neimpozab,totftvai,tvai,totftvam,tvam,fdoc,scutit from ] + ;
|
|
gcs + [.] + lcvizualizare + [ where ] + ;
|
|
[ UPPER(TRIM(fdoc)) <> 'BON FISCAL' and an = ] + Alltrim(Str(gnAn)) + ;
|
|
[ and luna = ] + Alltrim(Str(gnLuna)) + [)] + ;
|
|
[) order by dataireg,tip]
|
|
Endif
|
|
Endif
|
|
|
|
lcCursor = [cvanzcump]
|
|
lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return
|
|
Endif
|
|
|
|
pctitlu = lcTitlu
|
|
goExport.export2frx(lcCursor, lcRaport, .T.)
|
|
*!* If Reccount(lcCursor)>0
|
|
*!* pctitlu = ceretitlu_rap('Titlul Raportului',lctitlu)
|
|
*!* pcDataOra = Get_Ora(2)
|
|
*!* Select (lcCursor)
|
|
*!* Report Format (lcRaport) To Printer Prompt Preview
|
|
*!* Else
|
|
*!* amessagebox("Nu exista inregistrari pentru listare!",48,"Atentie")
|
|
*!* Endif
|
|
|
|
Use In (lcCursor)
|
|
Endproc
|
|
********************************** SFARSIT: listare_registru_vanzcump **************************
|
|
********************************** INCEPUT:listare_registru_vanzcump_2007 ***************************
|
|
Procedure listare_registru_vanzcump_2007
|
|
Parameters tcVC, tcTipRapRC
|
|
|
|
Local lcCursor, lcRaport
|
|
Private pctitlu, pcSubtitlu, tip && pcDataOra
|
|
Private pcschema, pcselect, pcfiltru, pcorder, povanz, pocump
|
|
Store "" To pcSubtitlu, povanz, pocump, lcCursor, lcRaport
|
|
*!* pcDataOra = Get_Ora(2)
|
|
|
|
If Empty(tcTipRapRC)
|
|
tip = 0
|
|
Else
|
|
tip = 1
|
|
Endif
|
|
|
|
If Used('ACTCV')
|
|
Use In actcv
|
|
Endif
|
|
|
|
Do Case
|
|
Case tcVC = 'V'
|
|
lcCursor = [actcv]
|
|
pcschema = ['id_jv n(4),an n(4),luna n(2),cod n(20),dataact d,cod_fiscal c(30),serie_act c(10),nract N(20),'+] + ;
|
|
['id_part n(20),id_fdoc n(20),totctva n(20,4),ro19b n(20,4),ro19t n(20,4),ro9b n(20,4),'+] + ;
|
|
['ro9t n(20,4),roti n(20,4),cescdd1 n(20,4),cescdd2 n(20,4),wrscdd n(20,4),fodd n(20,4),'+] + ;
|
|
['fofdd n(20,4),wrscfdd n(20,4),wrn n(20,4),'] + ;
|
|
['ceoptr n(20,4),cesvdd n(20,4),cesvfdd n(20,4),cesvfs n(20,4),'] + ;
|
|
['fel_document c(30),denumire c(70),sucursala c(100)']
|
|
pcselect = ['select id_jv,an,luna,cod,dataact,cod_fiscal,serie_act,nract,'+] + ;
|
|
['id_part,id_fdoc,totctva,ro19b,ro19t,ro9b,'+] + ;
|
|
['ro9t,roti,cescdd1,cescdd2,wrscdd,fodd,'+] + ;
|
|
['fofdd,wrscfdd,wrn,'] + ;
|
|
['ceoptr,cesvdd,cesvfdd,cesvfs,'] + ;
|
|
['fel_document,denumire,sucursala from vjv2007 where 1=2']
|
|
pcfiltru = [luna=] + Alltrim(Str(gnLuna)) + [ and an=] + Alltrim(Str(gnAn)) + gcCondSucursala
|
|
pcorder = [dataact,nract]
|
|
llAfisare = .F.
|
|
gencursor('povanz', lcCursor, pcselect, pcfiltru, pcschema, pcorder, llAfisare)
|
|
povanz.ca_baza1.afisare()
|
|
|
|
*!* If Reccount('actcv')>0
|
|
*!* pctitlu = "JURNAL DE VANZARI"
|
|
*!* Select actcv
|
|
*!* Report Form registru_vanzari_jtva2007 To Printer Prompt Preview
|
|
*!* Else
|
|
*!* amessagebox("Nu exista inregistrari pentru listare!",48,"Atentie")
|
|
*!* Endif
|
|
lcRaport = [registru_vanzari_jtva2007]
|
|
|
|
Case tcVC = 'C'
|
|
lcCursor = [cListRC]
|
|
pctitlu = "Registru cumparari"
|
|
|
|
pcschema = ['id_jc n(4),an n(4),luna n(2),totctva n(20,4),id_part n(20),id_fdoc n(20),dataact d,'+] + ;
|
|
['serie_act c(10),nract N(20),ro19bcb n(20,4),ro19bct n(20,4),ro19bvb n(20,4),ro19bvt n(20,4),ro19bfb n(20,4),'+] + ;
|
|
['ro19bft n(20,4),ro09bcb n(20,4),ro09bct n(20,4),ro09bvb n(20,4),ro09bvt n(20,4),ro09bfb n(20,4),'+] + ;
|
|
['ro09bft n(20,4),roscn n(20,4),fo19bcb n(20,4),fo19bct n(20,4),fo19bvb n(20,4),fo19bvt n(20,4),'+] + ;
|
|
['fo19bfb n(20,4),fo19bft n(20,4),fo09bcb n(20,4),fo09bct n(20,4),fo09bvb n(20,4),fo09bvt n(20,4),'+] + ;
|
|
['fo09bfb n(20,4),fo09bft n(20,4),foscn n(20,4),cebcb n(20,4),cebct n(20,4),cebvb n(20,4),cebvt n(20,4),'+] + ;
|
|
['cebvsc n(20,4),cebvn n(20,4),cebfb n(20,4),cebft n(20,4),cebfsc n(20,4),cebfn n(20,4),ti19bcb n(20,4),'+] + ;
|
|
['ti19bct n(20,4),ti19bvb n(20,4),ti19bvt n(20,4),ti19bfb n(20,4),ti19bft n(20,4),ti09bvb n(20,4),'+] + ;
|
|
['ti09bvt n(20,4),ti09bfb n(20,4),ti09bft n(20,4),cod n(20),fel_document c(30),denumire c(70),cod_fiscal c(30),sucursala c(100)']
|
|
pcselect = ['select id_jc, an, luna, totctva, id_part, id_fdoc, dataact, serie_act, nract, ro19bcb, ro19bct, ro19bvb,'+] + ;
|
|
['ro19bvt, ro19bfb, ro19bft, ro09bcb, ro09bct, ro09bvb, ro09bvt, ro09bfb, ro09bft, roscn, fo19bcb, fo19bct,'+] + ;
|
|
['fo19bvb, fo19bvt, fo19bfb, fo19bft, fo09bcb, fo09bct, fo09bvb, fo09bvt, fo09bfb, fo09bft, foscn, cebcb,'+] + ;
|
|
['cebct, cebvb, cebvt, cebvsc, cebvn, cebfb, cebft, cebfsc, cebfn, ti19bcb, ti19bct, ti19bvb, ti19bvt,'+] + ;
|
|
['ti19bfb, ti19bft, ti09bvb, ti09bvt, ti09bfb, ti09bft, cod, fel_document, denumire, cod_fiscal, sucursala '+] + ;
|
|
['from vjc2007 where 1=2']
|
|
pcfiltru = [luna=] + Alltrim(Str(gnLuna)) + [ and an=] + Alltrim(Str(gnAn)) + gcCondSucursala
|
|
pcorder = [dataact,serie_act,nract]
|
|
llAfisare = .F.
|
|
gencursor('pocump', 'actcv', pcselect, pcfiltru, pcschema, pcorder, llAfisare)
|
|
pocump.ca_baza1.afisare()
|
|
|
|
Do Case
|
|
Case Alltrim(Upper(tcTipRapRC)) = 'RO'
|
|
pcSubtitlu = "Achizitii de bunuri si prestari de sevicii taxabile din tara"
|
|
Select * ;
|
|
From actcv ;
|
|
Where ro19bcb <> 0 Or ro19bct <> 0 Or ro19bvb <> 0 Or ro19bvt <> 0 Or ro19bfb <> 0 Or ro19bft <> 0 Or ;
|
|
ro09bvb <> 0 Or ro09bvt <> 0 Or ro09bfb <> 0 Or ro09bft <> 0 Or roscn <> 0 Order By dataact, serie_act, nract ;
|
|
Into Cursor (lcCursor)
|
|
|
|
*!* If Reccount('cListRc')>0
|
|
*!* Select cListRC
|
|
*!* Report Form registru_cumparari_jtva2007_ro To Printer Prompt Preview
|
|
*!* Else
|
|
*!* amessagebox("Nu exista inregistrari pentru listare!",48,"Atentie")
|
|
*!* Endif
|
|
lcRaport = [registru_cumparari_jtva2007_ro]
|
|
Case Alltrim(Upper(tcTipRapRC)) = 'FO'
|
|
pcSubtitlu = "Achizitii de bunuri si prestari de sevicii taxabile din import"
|
|
Select * ;
|
|
From actcv ;
|
|
Where fo19bcb <> 0 Or fo19bct <> 0 Or fo19bvb <> 0 Or fo19bvt <> 0 Or fo19bfb <> 0 Or fo19bft <> 0 Or ;
|
|
fo09bvb <> 0 Or fo09bvt <> 0 Or fo09bfb <> 0 Or fo09bft <> 0 Or foscn <> 0 Order By dataact, serie_act, nract ;
|
|
Into Cursor (lcCursor)
|
|
|
|
*!* If Reccount('cListRc')>0
|
|
*!* Select cListRC
|
|
*!* Report Form registru_cumparari_jtva2007_fo To Printer Prompt Preview
|
|
*!* Else
|
|
*!* amessagebox("Nu exista inregistrari pentru listare!",48,"Atentie")
|
|
*!* Endif
|
|
lcRaport = [registru_cumparari_jtva2007_fo]
|
|
Case Alltrim(Upper(tcTipRapRC)) = 'CE'
|
|
pcSubtitlu = "Achizitii intracomunitare de bunuri"
|
|
Select * ;
|
|
From actcv ;
|
|
Where cebcb <> 0 Or cebct <> 0 Or cebvb <> 0 Or cebvt <> 0 Or cebvsc <> 0 Or cebvn <> 0 Or ;
|
|
cebfb <> 0 Or cebft <> 0 Or cebfsc <> 0 Or cebfn <> 0 Order By dataact, serie_act, nract ;
|
|
Into Cursor (lcCursor)
|
|
|
|
*!* If Reccount('cListRC')>0
|
|
*!* Select cListRC
|
|
*!* Report Form registru_cumparari_jtva2007_ce To Printer Prompt Preview
|
|
*!* Else
|
|
*!* amessagebox("Nu exista inregistrari pentru listare!",48,"Atentie")
|
|
*!* Endif
|
|
lcRaport = [registru_cumparari_jtva2007_ce]
|
|
Case Alltrim(Upper(tcTipRapRC)) = 'TI'
|
|
pcSubtitlu = "Bunuri si Sevicii pentru care cumparatorul este obligat la plata taxei (din Tara, Import si Servicii UE) - Taxare Inversa"
|
|
Select * ;
|
|
From actcv ;
|
|
Where ti19bcb <> 0 Or ti19bct <> 0 Or ti19bvb <> 0 Or ti19bvt <> 0 Or ti19bfb <> 0 Or ti19bft <> 0 Or ;
|
|
ti09bvb <> 0 Or ti09bvt <> 0 Or ti09bfb <> 0 Or ti09bft <> 0 Order By dataact, serie_act, nract ;
|
|
Into Cursor (lcCursor)
|
|
|
|
*!* If Reccount('cListRC')>0
|
|
*!* Select cListRC
|
|
*!* Report Form registru_cumparari_jtva2007_ti To Printer Prompt Preview
|
|
*!* Else
|
|
*!* amessagebox("Nu exista inregistrari pentru listare!",48,"Atentie")
|
|
*!* Endif
|
|
lcRaport = [registru_cumparari_jtva2007_ti]
|
|
Endcase
|
|
|
|
If Used('ACTCV')
|
|
Use In actcv
|
|
Endif
|
|
*!* If Used('cListRC')
|
|
*!* Use In cListRC
|
|
*!* Endif
|
|
Endcase
|
|
|
|
goExport.export2frx(lcCursor, lcRaport)
|
|
*!* If Used('ACTCV')
|
|
*!* Use In actcv
|
|
*!* Endif
|
|
If Used(lcCursor)
|
|
Use In (lcCursor)
|
|
Endif
|
|
|
|
Endproc && listare_registru_vanzcump_2007
|
|
********************************** SFARSIT: listare_registru_vanzcump_2007 **************************
|
|
********************************** INCEPUT:rap_facturi_emise_pe_zile***************************
|
|
Procedure rap_facturi_emise_pe_zile
|
|
|
|
Private pctitlu, pddata_emisi, pddata_emisf && pcDataOra
|
|
Store '' To pctitlu && ,pcDataOra
|
|
|
|
pddata_emisi = Date()
|
|
pddata_emisf = Date()
|
|
|
|
|
|
Do Form frm_filtru_numar Name ofrm_filtru Linked With [a.dataact], [Data incasarii], 1, 1, 'D', [], 0 To lcFiltruData Noshow
|
|
ofrm_filtru.text1.SetFocus()
|
|
ofrm_filtru.text1.ControlSource = [pddata_emisi]
|
|
ofrm_filtru.text2.ControlSource = [pddata_emisf]
|
|
ofrm_filtru.Show(1)
|
|
|
|
pcperioada = [Perioada: ] + Alltrim(Dtoc(pddata_emisi)) + [-] + Alltrim(Dtoc(pddata_emisf))
|
|
|
|
lcOrdonare = [dataact,serie_act,nract]
|
|
|
|
lcSelect = [select dataact,serie_act,nract, nume, debit + precdeb as totctva from ] + gcs + [.vireg_parteneri ] + ;
|
|
[where dataact >= ?pddata_emisi and dataact <= ?pddata_emisf and cont = '4111' ] + ;
|
|
[and an = ?gnAn and luna = ?gnLuna ] + gcCondSucursala + ;
|
|
[ order by ] + lcOrdonare
|
|
lcCursor = [cFacturi]
|
|
lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return
|
|
Endif
|
|
|
|
*!* If Reccount(lcCursor)>0
|
|
pctitlu = [Facturi emise in perioada ] + Alltrim(Dtoc(pddata_emisi)) + [-] + Alltrim(Dtoc(pddata_emisf))
|
|
*!* lctitlu = [Facturi emise in perioada ] + Alltrim(Dtoc(pddata_emisi)) + [-] + Alltrim(Dtoc(pddata_emisf))
|
|
*!* pctitlu = ceretitlu_rap('Titlul Raportului',lctitlu)
|
|
*!* pcDataOra = Get_Ora(2)
|
|
goExport.export2frx(lcCursor, [rap_facturi_emise], .T.)
|
|
*!* Select (lcCursor)
|
|
*!* Report Format rap_facturi_emise To Printer Prompt Preview
|
|
*!* Else
|
|
*!* amessagebox("Nu exista inregistrari pentru listare!",48,"Atentie")
|
|
*!* Endif
|
|
|
|
Use In (lcCursor)
|
|
|
|
Endproc
|
|
********************************** SFARSIT: rap_facturi_emise_pe_zile**************************
|
|
|
|
|
|
********************************** INCEPUT: rap_facturi_grupat_pe_lucari_parteneri **************************
|
|
Procedure rap_fact_grup_pe_lucari_parteneri
|
|
Parameters tccont, tlActiv, tnShowForm
|
|
|
|
Private pnIdLucrare, pccont
|
|
pnIdLucrare = 0
|
|
|
|
If Empty(tccont)
|
|
pccont = []
|
|
Else
|
|
pccont = Alltrim(tccont)
|
|
Endif
|
|
plActiv = tlActiv
|
|
|
|
If tnShowForm = 1 Or Empty(pccont)
|
|
ofrm = Createobject('frm_facturi_grupat')
|
|
With ofrm
|
|
.lcCont = pccont
|
|
.llActiv = plActiv
|
|
.lcTitlu = [Situatie facturi ] + pccont
|
|
.clb_tx_simplu1.text_simplu1.Value = pccont
|
|
.lhide = .T.
|
|
Endwith
|
|
ofrm.Show(1)
|
|
pccont = ofrm.lcCont
|
|
pnIdLucrare = ofrm.lnIdLucrare
|
|
plActiv = ofrm.llActiv
|
|
pctitlu = ofrm.lcTitlu
|
|
ofrm.Release
|
|
Else
|
|
pcselect = [select id_lucrare, nrord from vlucrari_validat]
|
|
pcfiltru = [1=2]
|
|
pcschema = []
|
|
pcorder = [nrord]
|
|
pccoloane = [nrord]
|
|
pctitlu = [Alegeti lucrarea/contractul]
|
|
pcFiltruOriginal = [validat = 0 and inactiv = 0]
|
|
locauta = cauta_alfa(pcselect, pcfiltru, pcschema, pcorder, pccoloane, pctitlu, pctitlu, [], .T., pcFiltruOriginal) && 11.07.2007
|
|
pnIdLucrare = Iif(Empty(locauta.id_lucrare), 0, locauta.id_lucrare)
|
|
Endif
|
|
|
|
If gnButon = 2
|
|
Return
|
|
Endif
|
|
|
|
pcCondLucrare = Iif(Empty(pnIdLucrare), [1=1], [id_lucrare = ?pnIdLucrare])
|
|
|
|
lcSelect = [select dataact,datascad, serie_act, nract, nume, id_part,id_lucrare,nrord,SUM(] + Iif(plActiv, [debit + precdeb], [credit + preccred]) + [) as tot_fact, ] + ;
|
|
[SUM(] + Iif(plActiv, [credit + preccred], [debit + precdeb]) + [) as tot_achit, ] + ;
|
|
[00000000000000.0000 as sold_lucrare, 00000000000000.0000 as sold_part ] + ;
|
|
[from ] + gcs + [.vireg_parteneri ] + ;
|
|
[where cont = ?pcCont and ] + pcCondLucrare + ;
|
|
[ and an = ?gnAn and luna = ?gnLuna ] + gcCondSucursala + [ ] + ;
|
|
[group by dataact, datascad, serie_act, nract, nume, id_part, id_lucrare, nrord ] + ;
|
|
[order by nrord, id_lucrare, nume, id_part, dataact, serie_act, nract]
|
|
lcCursor = [cFacturi]
|
|
lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return
|
|
Endif
|
|
|
|
**** calcul sold cumulat
|
|
*!* lnIdLucrare = 0
|
|
*!* lnIdPart = 0
|
|
*!* lnSoldLucrare = 0
|
|
*!* lnSoldPart = 0
|
|
*!* SELECT cFacturi
|
|
*!* SCAN
|
|
*!* SCATTER NAME osold
|
|
*!* lnNrRand = RECNO()
|
|
*!* IF lnIdLucrare <> osold.id_lucrare
|
|
*!* lnIdLucrare = osold.id_Lucrare
|
|
*!* lnSoldLucrare = 0
|
|
*!* ENDIF
|
|
*!* IF lnIdPart <> osold.id_part
|
|
*!* lnIdPart = osold.id_part
|
|
*!* lnSoldPart = 0
|
|
*!* ENDIF
|
|
*!* lnSoldLucrare = lnSoldLucrare + NVL(osold.tot_fact,0) - NVL(osold.tot_achit,0)
|
|
*!* lnSoldPart = lnSoldPart + NVL(osold.tot_fact,0) - NVL(osold.tot_achit,0)
|
|
*!* REPLACE sold_lucrare WITH lnSoldLucrare, sold_part WITH lnSoldPart
|
|
*!* SELECT cFacturi
|
|
*!* ENDSCAN
|
|
****
|
|
|
|
*!* If Reccount(lcCursor)>0
|
|
If tnShowForm = 0
|
|
lcTitlu = [Facturi ] + pccont
|
|
pctitlu = ceretitlu_rap('Titlul Raportului', lcTitlu)
|
|
Endif
|
|
*!* pcDataOra = Get_Ora(2)
|
|
goExport.export2frx(lcCursor, [ireg_parteneri_rpt4])
|
|
*!* Select (lcCursor)
|
|
*!* Report Form ireg_parteneri_rpt4.frx To Printer Prompt Preview
|
|
*!* Else
|
|
*!* amessagebox("Nu exista inregistrari pentru listare!",48,"Atentie")
|
|
*!* Endif
|
|
If Used(lcCursor)
|
|
Use In &lcCursor
|
|
Endif
|
|
|
|
Endproc && rap_fact_grup_pe_lucari_parteneri
|
|
|
|
********************************** SFARSIT: rap_facturi_grupat_pe_lucari_parteneri **************************
|
|
*!* modificare v 2.0.77
|
|
Procedure sold_fact_pe_vechimi
|
|
Lparameters tctip, tlEmitere
|
|
*** tcTip: C (clienti 4111,4118); F (furnizori 401); A (activ se alege contul)
|
|
*** tlEmitere: .T. vechime fata de data emiterii sau .F. fata de data scadenta
|
|
|
|
Local loFrm, lcExplicatie, lcSql, lcRaport, loFrmPerioada
|
|
Private pdData
|
|
|
|
pdData = Date(gnAn, gnLuna, 1)
|
|
loFrm = Createobject("frm_data")
|
|
loFrm.lb_titlu_alb_b121.Caption = "Data referinta"
|
|
loFrm.Show(1)
|
|
|
|
Private pnEActiv
|
|
Local lcString, lcCont
|
|
Store "" To lcCont, lcString
|
|
Store .F. To pnEActiv
|
|
|
|
If tctip = [A]
|
|
Do Alege_Cont With lcCont, pnEActiv
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
Endif
|
|
|
|
*** la sold facturi pe vechimi 4111 fata de data emitere am acelasi raport ca la ALTII/ACTIV
|
|
If m.tctip = [C] And tlEmitere = .T.
|
|
tctip = [A]
|
|
lcCont = [4111]
|
|
pnEActiv = .T.
|
|
Endif
|
|
|
|
lcSelect = [SELECT varname,varvalue FROM optiuni where varname like 'VECHIME%']
|
|
lcCursor = [crsOptiuni]
|
|
lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return
|
|
Endif
|
|
If Reccount('crsOptiuni') = 0
|
|
amessagebox("Baza de date nu a fost actualizata!", 48, "Atentie")
|
|
Else
|
|
Select crsOptiuni
|
|
Scan
|
|
lcnume = Alltrim(varname)
|
|
lnValoare = Val(Alltrim(varvalue))
|
|
gn&lcnume. = lnValoare
|
|
Endscan
|
|
loFrmPerioada = Createobject("frm_alegeperioada", m.tctip, m.lcCont, m.tlEmitere)
|
|
loFrmPerioada.lb_titlu_alb_b121.Caption = "Alegeti perioada"
|
|
loFrmPerioada.Show(1)
|
|
*!* modificare v 2.0.77 ^
|
|
Endif
|
|
Release pctitlu, pdData, loFrm, lcExplicatie, lcSql, lcRaport
|
|
Endproc && sold_fact_pe_vechimi
|
|
*************************************************************************************************************
|
|
Procedure proc_scadentar
|
|
Lparameters tctip, tccont
|
|
*tcCont - completez doar pentru furnizori
|
|
Local loFrm, lcExplicatie, lcSql, lcRaport
|
|
Private pdData, pctitlu
|
|
|
|
pdData = Date(gnAn, gnLuna, 1)
|
|
loFrm = Createobject("frm_data")
|
|
loFrm.lb_titlu_alb_b121.Caption = "Data referinta"
|
|
loFrm.Show(1)
|
|
|
|
If gnButon = 1
|
|
If tctip = [C]
|
|
lcExplicatie = [CLIENTI]
|
|
|
|
lcSql = [select a.id_part,b.denumire,Sum(a.sold) As sold,] + ;
|
|
[SUM(case when NVL(datascad,add_months(dataact,1))< = ?pdData And ] + ;
|
|
[ a.incert = 0 then a.sold else 0.00 end) As rest_30, ] + ;
|
|
[ nract,dataact,datascad, to_char(nract)||'/'||to_char(dataact,'DD.MM.YYYY') as expli] + ;
|
|
[ from ] + ;
|
|
[ (Select id_part, NVL(datascad, dataact + 30) as datascad,nract,dataact, ] + ;
|
|
[ sum((precdeb + debit) - (preccred + credit)) As sold, ] + ;
|
|
[ (case when cont = '4118' then 1 else 0 end) As incert ] + ;
|
|
[ FROM ireg_parteneri ] + ;
|
|
[ WHERE ] + ;
|
|
[ (precdeb + debit) - (preccred + credit) <> 0 ] + ;
|
|
[ and luna = ?gnLuna ] + ;
|
|
[ and an = ?gnAn ] + ;
|
|
gcCondSucursala + ;
|
|
[ and cont in ('4111', '4118') group by id_part,datascad,nract,dataact,cont) a ] + ;
|
|
[ left join nom_parteneri b on a.id_part = b.id_part ] + ;
|
|
[ GROUP By a.id_part, b.denumire, a.nract,a.dataact,a.datascad ] + ;
|
|
[ order by b.denumire]
|
|
|
|
|
|
Else
|
|
lcExplicatie = [FURNIZORI]
|
|
lcSql = [Select a.id_part,b.denumire,Sum(a.sold) As sold,] + ;
|
|
[SUM(case when NVL(datascad,add_months(dataact,1)) < = ?pdData then a.sold else 0.00 end) As rest_30, ] + ;
|
|
[ nract,dataact,datascad, to_char(nract)||'/'||to_char(dataact,'DD.MM.YYYY') as expli] + ;
|
|
[ from ] + ;
|
|
[ (Select id_part, NVL(datascad, dataact + 30) as datascad,nract,dataact, ] + ;
|
|
[ (preccred + credit) - (precdeb + debit) As sold ] + ;
|
|
[ FROM ireg_parteneri ] + ;
|
|
[ WHERE ] + ;
|
|
[ (preccred + credit) - (precdeb + debit) <> 0 ] + ;
|
|
[ and luna = ?gnLuna ] + ;
|
|
[ and an = ?gnAn ] + ;
|
|
gcCondSucursala + ;
|
|
[ and cont =] + tccont + [) a ] + ;
|
|
[ left join nom_parteneri b on a.id_part = b.id_part ] + ;
|
|
[ GROUP By a.id_part, b.denumire, a.nract,a.dataact,a.datascad ] + ;
|
|
[ order by b.denumire]
|
|
|
|
Endif
|
|
|
|
lnSucces = goExecutor.oExecute(lcSql, [crsdaterap])
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 16, "Eroare")
|
|
Else
|
|
Select Distinct id_part, denumire, Sum(sold) As sold, Sum(rest_30) As rest_30, Cast('' As Memo) As listaf;
|
|
From crsDateRap Group By id_part, denumire Order By denumire ;
|
|
Into Cursor crsScadentar Readwrite
|
|
Local lcMemo
|
|
Select crsScadentar
|
|
Scan
|
|
Scatter Name ocrs
|
|
|
|
Select * From crsDateRap Where id_part = ocrs.id_part And Nvl(datascad, Gomonth(dataact, 1)) <= pdData Into Cursor crsTmp
|
|
lcMemo = []
|
|
lcMemo = cursor2lista('crsTmp', 'expli', ', ')
|
|
Select crsScadentar
|
|
Replace listaf With lcMemo
|
|
If Used('crsTmp')
|
|
Use In crsTmp
|
|
Endif
|
|
Select crsScadentar
|
|
Endscan
|
|
|
|
|
|
lcRaport = [rap_scadentar]
|
|
Select crsScadentar
|
|
pctitlu = [RAPORT SCADENTAR ] + lcExplicatie
|
|
goExport.export2frx([crsScadentar], lcRaport)
|
|
IF RECCOUNT('crsScadentar') > 0 AND AMESSAGEBOX('Doriti salvare in fisier xlsx?',4+32,_screen.Caption)=6
|
|
goExport.export2xlsx([crsScadentar], 'scadentar')
|
|
ENDIF
|
|
Endif
|
|
|
|
Use In (SELECT('crsDateRap'))
|
|
Use In (SELECT('crsScadentar'))
|
|
Endif
|
|
|
|
Release pctitlu, pdData, loFrm, lcExplicatie, lcSql, lcRaport
|
|
Endproc && proc_scadentar
|
|
*************************************************************************************************************
|
|
Procedure parteneri_cu_sold_final
|
|
Lparameters tlInValuta, tccont, tlEActiv, tlCumulat && modificare v 2.1.11 : tlCumulat
|
|
Local lcCont, llEActiv, llParametri, llInValuta, lcRaport
|
|
llInValuta = tlInValuta
|
|
If !Empty(tccont)
|
|
lcCont = Alltrim(tccont)
|
|
llParametri = .T.
|
|
Else
|
|
lcCont = ''
|
|
llParametri = .F.
|
|
Endif
|
|
|
|
If Pcount() >= 3
|
|
llEActiv = tlEActiv
|
|
Else
|
|
If !Empty(tccont)
|
|
lcSql = [select fel_cont from ] + gcs + [.config_cont_ireg where cont = '] + Alltrim(lcCont) + [']
|
|
lnSucces = goExecutor.oExecute(lcSql, [crsfelcont])
|
|
If lnSucces < 0
|
|
llEActiv = .F.
|
|
Else
|
|
If Reccount('crsfelcont') > 0
|
|
Select crsfelcont
|
|
llEActiv = Iif(fel_cont = 0, .T., .F.)
|
|
Else
|
|
llEActiv = .F.
|
|
Endif
|
|
Use In crsfelcont
|
|
Endif
|
|
Else
|
|
llEActiv = .F.
|
|
Endif
|
|
Endif
|
|
|
|
Private plActiv, eActiv, pctitlu, t1, t2, t3, t4
|
|
Store .T. To plActiv, eActiv
|
|
If !llParametri
|
|
Private polista, pcschema1, pcselect1, pcfiltru1, pcorder1
|
|
Store "" To polista
|
|
If Used('clista')
|
|
Use In clista
|
|
Endif
|
|
pcschema1 = ['cont c(4),acont c(4),explicatie c(50),fel_cont n(1)']
|
|
pcselect1 = ['select cont,rpad(CHR(32),4,CHR(32)) as acont,explicatie,fel_cont from ] + gcs + [.config_cont_ireg where 1=2']
|
|
pcfiltru1 = [cu_inregistrari=1]
|
|
pcorder1 = [cont]
|
|
llAfisare = .F.
|
|
gencursor('polista', 'clista', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfisare)
|
|
polista.ca_baza1.afisare()
|
|
|
|
Select clista
|
|
loCont = myscatter('blank')
|
|
|
|
Ol = Createobject("frm_sel_cont")
|
|
With Ol
|
|
.lb_titlu_alb_b121.Caption = 'Selectati contul'
|
|
If Empty(.cboCont.RowSource)
|
|
.cboCont.RowSource = "clista.cont,explicatie"
|
|
.cboCont.ColumnWidths = '40,150'
|
|
Endif
|
|
.ocont = loCont
|
|
If Empty(.cAlias)
|
|
.cAlias = Left(.cboCont.RowSource, At(".", .cboCont.RowSource) - 1)
|
|
Endif
|
|
.Height = 190
|
|
.lhide = .T.
|
|
Endwith
|
|
Ol.Show(1)
|
|
llEActiv = Iif(Ol.nFel_Cont = 0, .T., .F.)
|
|
Ol.Release
|
|
|
|
If gnButon = 2
|
|
Use In clista
|
|
Release plActiv, eActiv, pctitlu
|
|
Return
|
|
Else
|
|
lcCont = Alltrim(loCont.Cont)
|
|
llEActiv = plActiv
|
|
Endif
|
|
Endif
|
|
eActiv = llEActiv
|
|
lcSql = [select a.id_ireg_part,a.an,a.luna,a.id_fact,a.id_part,a.cont,a.id_valuta,a.precdeb,a.preccred,a.precvaldeb,a.precvalcred,] + ;
|
|
[a.debit,a.credit,a.valdebit,a.valcredit,a.nract,a.serie_act,a.dataact,a.datascad,a.curs,a.cod,a.explicatia,a.explicatia4,] + ;
|
|
[a.explicatia5,a.id_fdoc,a.id_lucrare,a.id_ctr,a.id_sucursala,b.denumire as nume,c.nume_val,d.fel_document as fdoc,e.nrord,] + ;
|
|
[nvl2(f.numar, f.numar || '/', '') || to_char(f.data, 'dd.mm.yyyy') as contract from ] + ;
|
|
[(SELECT ID_IREG_PART,AN,LUNA,ID_FACT,ID_PART,CONT,ID_VALUTA,PRECDEB,PRECCRED,PRECVALDEB,PRECVALCRED,] + ;
|
|
[DEBIT,CREDIT,VALDEBIT,VALCREDIT,NRACT,SERIE_ACT,DATAACT,DATASCAD,CURS,COD,EXPLICATIA,EXPLICATIA4,] + ;
|
|
[EXPLICATIA5,ID_FDOC,ID_LUCRARE,ID_CTR,ID_SUCURSALA,] + ;
|
|
[sum(] + Iif(llEActiv, [(precdeb + debit) - (preccred + credit)], [(preccred + credit) - (precdeb + debit)]) + ;
|
|
[) over(partition by an, luna, id_part) as sold_final ] + ;
|
|
[FROM ] + gcs + [.IREG_PARTENERI WHERE cont ='] + m.lcCont + [' and luna = ?gnLuna and an = ?gnAn) a ] + ;
|
|
[left join ] + gcs + [.nom_parteneri b on a.id_part = b.id_part ] + ;
|
|
[left join ] + gcs + [.nom_valute c on a.id_valuta = c.id_valuta ] + ;
|
|
[left join ] + gcs + [.nom_fdoc d on a.id_fdoc = d.id_fdoc ] + ;
|
|
[left join ] + gcs + [.vnom_lucrari e on a.id_lucrare = e.id_lucrare ] + ;
|
|
[left join ] + gcs + [.contracte f on a.id_ctr = f.id_ctr ] + ;
|
|
[where a.sold_final <> 0 and ] + Iif(llEActiv, [(a.precdeb+a.debit)-(a.preccred+a.credit)], [(a.preccred+a.credit)-(a.precdeb+a.debit)]) + [ <> 0 ] + ;
|
|
[ORDER BY b.denumire, a.id_part, a.dataact, a.serie_act, a.nract]
|
|
lnSucces = goExecutor.oExecute(lcSql, [crslistare])
|
|
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 16, "Eroare")
|
|
Else
|
|
If llInValuta
|
|
lcRaport = [ireg_parteneri_rpt2]
|
|
pctitlu = [Inregistrari parteneri cont ] + Alltrim(lcCont) + [ cu sold final - in lei si valuta] && modificare v 2.1.11
|
|
Else
|
|
*!* modificare v 2.1.11
|
|
*!* lcRaport = [ireg_parteneri_rpt2lei]
|
|
If tlCumulat
|
|
lcRaport = [ireg_parteneri_rpt2lei_cum]
|
|
pctitlu = [Inregistrari parteneri cont ] + Alltrim(lcCont) + [ cu sold final - in lei (cu sold cumulat)]
|
|
Else
|
|
lcRaport = [ireg_parteneri_rpt2lei]
|
|
pctitlu = [Inregistrari parteneri cont ] + Alltrim(lcCont) + [ cu sold final - in lei]
|
|
Endif
|
|
*!* modificare v 2.1.11 ^
|
|
Endif
|
|
|
|
*!* pctitlu = [Inregistrari parteneri cont ] + Alltrim(lcCont) + [ cu sold final - in lei ] + Iif(tlInValuta,[si valuta],[]) && modificare v 2.1.11
|
|
t1 = [Total ] + Iif(llEActiv, [debit], [credit])
|
|
t2 = [Total ] + Iif(llEActiv, [credit], [debit])
|
|
t3 = [Total ] + Iif(llEActiv, [debit], [credit]) + [ valuta]
|
|
t4 = [Total ] + Iif(llEActiv, [credit], [debit]) + [ valuta]
|
|
|
|
goExport.export2frx([crslistare], lcRaport, .T., , , , , .T.)
|
|
Endif
|
|
If Used('crslistare')
|
|
Use In crslistare
|
|
Endif
|
|
Release plActiv, eActiv, pctitlu
|
|
|
|
Endproc && parteneri_cu_sold_final
|
|
|
|
*************************************************************************************************************
|
|
Procedure istoric_clienti
|
|
Local locauta, loFrm, loFrmPerioada, lcCursor, lcCursor1
|
|
Local lcCursor2, lcExceptii, lcPerioada, lcSelect, lcSelect1, lcSql, lcTitlu, lnAn1, lnAn2, lnFinal
|
|
Local lnInit, lnLuna1, lnLuna2, lnSucces, lnSucces1
|
|
*:Global oInc
|
|
Private pcondper
|
|
Store "" To pcondper
|
|
locauta = caut_parteneri('4111', 'Alegeti clientul')
|
|
If gnButon = 1
|
|
|
|
loFrmPerioada = Createobject('frm_perioada_luni')
|
|
loFrmPerioada.Show(1)
|
|
|
|
If gnButon = 2
|
|
Return
|
|
Endif
|
|
|
|
If At('_', pcondper) > 0
|
|
lnAn1 = Val(Substr(pcondper, 3, 4))
|
|
lnLuna1 = Val(Substr(pcondper, 1, 2))
|
|
lnAn2 = Val(Substr(pcondper, 10, 4))
|
|
lnLuna2 = Val(Substr(pcondper, 8, 2))
|
|
|
|
lcPerioada = Substr(pcondper, 1, 2) + '/' + Substr(pcondper, 3, 4) + ' - ' + Substr(pcondper, 8, 2) + '/' + Substr(pcondper, 10, 4)
|
|
Else
|
|
lnAn1 = Val(Substr(pcondper, 3, 4))
|
|
lnLuna1 = Val(Substr(pcondper, 1, 2))
|
|
lnAn2 = Val(Substr(pcondper, 3, 4))
|
|
lnLuna2 = Val(Substr(pcondper, 1, 2))
|
|
|
|
lcPerioada = Substr(pcondper, 1, 2) + '/' + Substr(pcondper, 3, 4) + ' - ' + Substr(pcondper, 1, 2) + '/' + Substr(pcondper, 3, 4)
|
|
Endif
|
|
lnInit = lnAn1 * 12 + lnLuna1
|
|
lnFinal = lnAn2 * 12 + lnLuna2
|
|
|
|
Local loTherm
|
|
loTherm = Newobject("_thermometer", "_therm", "", "Istoric clienti...")
|
|
loTherm.Show()
|
|
|
|
lcSql = [select * from ] + gcs + [.exceptii_ireg where invers = 1 and debit = 1 and cont = '4111']
|
|
lcCursor = [ex_debit]
|
|
lnSucces = goExecutor.oExecute(lcSql, lcCursor)
|
|
lcExceptii = [-1]
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return
|
|
Else
|
|
Select (lcCursor)
|
|
Scan
|
|
lcExceptii = lcExceptii + ',' + Alltrim(cont_c)
|
|
Endscan
|
|
Use In (lcCursor)
|
|
Endif
|
|
|
|
*!* facturile
|
|
loTherm.Update(15, "Culegere date facturi...")
|
|
lcSelect = [select a.an,a.luna,a.cod,a.id_fact,a.data_factura,a.serie_factura,a.nr_factura,a.id_valuta,a.nume_val,a.suma_factura,a.suma_val_Factura,] + ;
|
|
[Nvl(b.nr,0) as nratasamente from ] + ;
|
|
[(select an,luna,cod,id_fact,dataact as data_factura,serie_act as serie_factura,nract as nr_factura,id_valuta,nume_val,] + ;
|
|
[sum(debit + precdeb) as suma_factura,] + ;
|
|
[Sum(valdebit + precvaldeb) as suma_val_factura ] + ;
|
|
[ from ] + gcs + [.vireg_parteneri ] + ;
|
|
[ where cont = '4111' and id_part = ] + Alltrim(Str(locauta.id_part)) + ;
|
|
[ and luna+12*an between ] + Alltrim(Str(lnInit)) + [ and ] + Alltrim(Str(lnFinal)) + [ ] + gcCondSucursala + ;
|
|
[ and (luna + 12*an =to_number(to_char(dataireg,'MM'),'99') + 12*to_number(to_char(dataireg,'YYYY'),'9999')) ] + ;
|
|
[ group by an, luna, cod, id_fact, dataact, serie_act, nract,id_valuta,nume_val) a ] + ;
|
|
[left join ] + ;
|
|
[(select count(*) as nr,cod from vatasamente_vanzari group by cod) b on a.cod = b.cod ] + ;
|
|
[order by a.an,a.luna,a.id_valuta,a.data_factura,a.serie_factura,a.nr_factura]
|
|
lcCursor = [cFacturi]
|
|
If Used(lcCursor)
|
|
Use In (lcCursor)
|
|
Endif
|
|
lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return
|
|
Endif
|
|
Select (lcCursor)
|
|
Replace All data_factura With {} For Isnull(data_factura)
|
|
|
|
*!* incasarile
|
|
If Reccount(lcCursor) <> 0
|
|
loTherm.Update(45, "Culegere date incasari...")
|
|
lcSelect1 = [Select a.dataact as data_incasare,] + ;
|
|
[a.serie_act as serie_incasare,a.nract as nr_incasare,] + ;
|
|
[(case when a.scc = '4427' then a.pereched else a.perechec end) as nr_factura,] + ;
|
|
[(case when a.scc = '4427' then a.id_factd else a.id_factc end) as id_fact,] + ;
|
|
[(case when a.scc = '4427' then (-1)*a.suma else a.suma end) as incasat,] + ;
|
|
[(case when a.scc = '4427' then (-1)*a.suma_val else a.suma_val end) as incasat_val,] + ;
|
|
[a.id_valuta as id_valuta_inc,b.nume_val as nume_val_inc ] + ;
|
|
[ from ] + gcs + [.act a ] + ;
|
|
[left join ] + gcs + [.nom_valute b on a.id_valuta = b.id_valuta ] + ;
|
|
[ where a.sters = 0 and ((a.scc = '4111' and a.id_partc = ] + Alltrim(Str(locauta.id_part)) + [ and (a.perechec <> 0 or a.id_factc <>0))] + ;
|
|
[ OR (a.SCD = '4111' AND a.SCC = '4427' AND a.id_partd = ] + Alltrim(Str(locauta.id_part)) + [ ] + ;
|
|
[AND (NVL(a.PERECHED,0) <> 0 OR NVL(a.ID_FACTD,0)<>0)))] + ;
|
|
[ and (to_number(a.scd) not in (] + lcExceptii + [)) and a.luna+12*a.an between ] + Alltrim(Str(lnInit)) + [ and ] + Alltrim(Str(lnFinal)) + ;
|
|
Strtran(gcCondSucursala, [id_sucursala], [a.id_sucursala]) + ;
|
|
[ order by a.serie_act, a.nract, a.dataact]
|
|
lcCursor1 = [crsincasari]
|
|
If Used(lcCursor1)
|
|
Use In (lcCursor1)
|
|
Endif
|
|
lnSucces1 = goExecutor.oExecute(lcSelect1, lcCursor1)
|
|
If lnSucces1 < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return
|
|
Endif
|
|
|
|
Select (lcCursor1)
|
|
Replace All data_incasare With {} For Isnull(data_incasare)
|
|
|
|
loTherm.Update(75, "Imperechere facturi - incasari...")
|
|
lcCursor2 = [crsistoric]
|
|
Create Cursor (lcCursor2) (id_fact N(20), cod N(20), id_valuta N(10), nume_val c(4), id_valuta_inc N(10), nume_val_inc c(4), ;
|
|
data_factura d, serie_factura c(10), nr_factura N(14), suma_factura N(18, 4), suma_val_factura N(18, 4), incasat N(18, 4), ;
|
|
sold N(18, 4), sold_val N(18, 4), nratasamente N(10))
|
|
Insert Into (lcCursor2) (id_fact, cod, id_valuta, nume_val, ;
|
|
data_factura, serie_factura, nr_factura, suma_factura, suma_val_factura, sold, sold_val, nratasamente) ;
|
|
Select id_fact, cod, id_valuta, nume_val, Nvl(Ttod(data_factura), {}) As data_factura, Nvl(serie_factura, []) As serie_factura, ;
|
|
nr_factura, suma_factura, suma_val_factura, ;
|
|
suma_factura As sold, suma_val_factura As sold_val, nratasamente From (lcCursor) Order By data_factura, serie_factura, nr_factura
|
|
|
|
Select (lcCursor1)
|
|
Scan
|
|
Scatter Name oInc
|
|
Select (lcCursor2)
|
|
Locate For id_fact = oInc.id_fact
|
|
If Found()
|
|
Replace incasat With incasat + oInc.incasat, ;
|
|
sold With sold - oInc.incasat, ;
|
|
sold_val With Iif(id_valuta = oInc.id_valuta_inc And id_valuta <> 0 And suma_val_factura <> 0, sold_val - oInc.incasat_val, sold_val)
|
|
Endif
|
|
Select (lcCursor1)
|
|
Endscan
|
|
Endif
|
|
|
|
loTherm.Complete()
|
|
Release loTherm
|
|
|
|
If Reccount(lcCursor) = 0
|
|
amessagebox("Nu exista facturi pentru " + Alltrim(locauta.denumire) + " (" + lcPerioada + ") !", 64, "Istoric facturi clienti")
|
|
Else
|
|
lcTitlu = [Istoric facturi] + Iif(locauta.id_part <> -1, [ ] + Alltrim(locauta.denumire), []) + [ (] + lcPerioada + [)]
|
|
loFrm = Createobject('frm_istoric_clienti', lcTitlu)
|
|
loFrm.Show(1)
|
|
|
|
If Used(lcCursor1)
|
|
Use In (lcCursor1)
|
|
Endif
|
|
If Used(lcCursor2)
|
|
Use In (lcCursor2)
|
|
Endif
|
|
Endif
|
|
|
|
If Used(lcCursor)
|
|
Use In (lcCursor)
|
|
Endif
|
|
|
|
Endif
|
|
|
|
ENDPROC && istoric_clienti
|
|
|
|
*************************************************
|
|
*** Tabel facturi si incasari
|
|
*** Facturi din inregistrari parteneri, Incasari din act
|
|
*** !!!! in lucru, trebuie terminat. a fost inceput, dar neterminat
|
|
*************************************************
|
|
Procedure istoric_terti
|
|
LPARAMETERS tcCont, tcTipCont
|
|
* tcCont (optional) cont
|
|
* tcTipCont (optional) A/P pentru selectia incasarilor/platilor din reg. jurnal de pe debit/credit
|
|
|
|
LOCAL loCont, lcTipCont
|
|
PRIVATE pcCont
|
|
Local locauta, loFrm, loFrmPerioada, lcCursor, lcCursor1
|
|
Local lcCursor2, lcExceptii, lcPerioada, lcSelect, lcSelect1, lcSql, lcTitlu, lnAn1, lnAn2, lnFinal
|
|
Local lnInit, lnLuna1, lnLuna2, lnSucces, lnSucces1
|
|
*:Global oInc
|
|
Private pcondper
|
|
Store "" To pcondper
|
|
|
|
IF !EMPTY(m.tcCont)
|
|
pcCont = ALLTRIM(m.tcCont)
|
|
lcTipCont = IIF(!EMPTY(m.tcTipCont), UPPER(ALLTRIM(m.tcTipCont)), 'A') && Activ/Pasiv/Bifunctional
|
|
ELSE
|
|
loCont=ret_cont("Selectati contul",'4')
|
|
IF TYPE('loCont') # 'O' OR buton = 2
|
|
RELEASE loCont
|
|
RETURN
|
|
ENDIF
|
|
pcCont = locont.cont
|
|
lcTipCont = UPPER(ALLTRIM(NVL(loCont.tip_cont, ''))) && A/P/B
|
|
ENDIF
|
|
IF EMPTY(m.pcCont)
|
|
RETURN
|
|
ENDIF
|
|
lcTipCont = IIF(!INLIST(m.lcTipCont, 'A', 'P'), 'A', m.lcTipCont)
|
|
|
|
locauta = caut_parteneri(m.pcCont, 'Alegeti partenerul ' + m.pcCont)
|
|
If m.gnButon = 2
|
|
RETURN
|
|
ENDIF
|
|
loFrmPerioada = Createobject('frm_perioada_luni')
|
|
loFrmPerioada.Show(1)
|
|
|
|
If m.gnButon = 2
|
|
Return
|
|
Endif
|
|
|
|
If At('_', pcondper) > 0
|
|
lnAn1 = Val(Substr(pcondper, 3, 4))
|
|
lnLuna1 = Val(Substr(pcondper, 1, 2))
|
|
lnAn2 = Val(Substr(pcondper, 10, 4))
|
|
lnLuna2 = Val(Substr(pcondper, 8, 2))
|
|
|
|
lcPerioada = Substr(pcondper, 1, 2) + '/' + Substr(pcondper, 3, 4) + ' - ' + Substr(pcondper, 8, 2) + '/' + Substr(pcondper, 10, 4)
|
|
Else
|
|
lnAn1 = Val(Substr(pcondper, 3, 4))
|
|
lnLuna1 = Val(Substr(pcondper, 1, 2))
|
|
lnAn2 = Val(Substr(pcondper, 3, 4))
|
|
lnLuna2 = Val(Substr(pcondper, 1, 2))
|
|
|
|
lcPerioada = Substr(pcondper, 1, 2) + '/' + Substr(pcondper, 3, 4) + ' - ' + Substr(pcondper, 1, 2) + '/' + Substr(pcondper, 3, 4)
|
|
Endif
|
|
lnInit = lnAn1 * 12 + lnLuna1
|
|
lnFinal = lnAn2 * 12 + lnLuna2
|
|
|
|
Local loTherm
|
|
loTherm = Newobject("_thermometer", "_therm", "", "Istoric ...")
|
|
loTherm.Show()
|
|
|
|
*!* Facturi din ireg_parteneri
|
|
loTherm.Update(15, "Culegere date facturi...")
|
|
TEXT TO lcSelect TEXTMERGE NOSHOW
|
|
select a.an,
|
|
a.luna,
|
|
a.cod,
|
|
a.nume,
|
|
a.cod_fiscal,
|
|
a.contract,
|
|
a.nrord,
|
|
a.venchelt,
|
|
a.explicatia,
|
|
a.fdoc,
|
|
a.id_fact,
|
|
a.data_factura,
|
|
a.serie_factura,
|
|
a.nr_factura,
|
|
a.id_valuta,
|
|
a.nume_val,
|
|
a.prec_suma_factura,
|
|
a.prec_suma_val_factura,
|
|
a.suma_factura,
|
|
a.suma_val_factura,
|
|
Nvl(b.nr, 0) as nratasamente
|
|
from (select an,
|
|
luna,
|
|
cod,
|
|
nume,
|
|
cod_fiscal,
|
|
contract,
|
|
nrord,
|
|
venchelt,
|
|
explicatia,
|
|
id_fact,
|
|
dataact as data_factura,
|
|
serie_act as serie_factura,
|
|
nract as nr_factura,
|
|
id_valuta,
|
|
nume_val,
|
|
SUM(case an*12+luna when <<m.lnInit>> then <<IIF(m.lcTipCont = 'A', 'precdeb', 'preccred')>> else 0 end) as prec_suma_factura,
|
|
SUM(case an*12+luna when <<m.lnInit>> then <<IIF(m.lcTipCont = 'A', 'precvaldeb', 'precvalcred')>> else 0 end) as prec_suma_val_factura,
|
|
SUM(<<IIF(m.lcTipCont = 'A', 'debit', 'credit')>>) as suma_factura,
|
|
Sum(<<IIF(m.lcTipCont = 'A', 'valdebit', 'valcredit')>>) as suma_val_factura
|
|
from vireg_parteneri
|
|
where cont = ?pcCont
|
|
and id_part = <<locauta.id_part>>
|
|
and an*12+luna between <<lnInit>> and <<lnFinal>> <<gcCondSucursala>>
|
|
group by an,
|
|
luna,
|
|
cod,
|
|
nume,
|
|
cod_fiscal,
|
|
contract,
|
|
nrord,
|
|
venchelt,
|
|
explicatia,
|
|
id_fact,
|
|
dataact as data_factura,
|
|
serie_act as serie_factura,
|
|
nract as nr_factura,
|
|
id_valuta,
|
|
nume_val) a
|
|
left join (select count(*) as nr, cod
|
|
from vatasamente_vanzari
|
|
group by cod) b on a.cod = b.cod
|
|
ENDTEXT
|
|
|
|
Use In (SELECT('cFacturi'))
|
|
lnSucces = goExecutor.oExecute(lcSelect, [cFacturi])
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return
|
|
ENDIF
|
|
|
|
If Reccount('cFacturi') = 0
|
|
amessagebox("Nu exista facturi pentru " + Alltrim(locauta.denumire) + " (" + lcPerioada + ") !", 64, "Istoric facturi clienti")
|
|
USE IN (SELECT('cFacturi'))
|
|
RETURN
|
|
ENDIF
|
|
|
|
*!* Incasari/plati
|
|
loTherm.Update(45, "Culegere date incasari/plati...")
|
|
|
|
TEXT TO lcSelect TEXTMERGE NOSHOW
|
|
Select a.dataact as data_incasare,
|
|
a.serie_act as serie_incasare,
|
|
a.nract as nr_incasare,
|
|
a.pereche as nr_factura,
|
|
CAST(null as date) as data_factura,
|
|
CAST(null as varchar2) as serie_factura,
|
|
a.id_fact,
|
|
a.suma as incasat,
|
|
a.suma_val as incasat_val,
|
|
a.id_valuta as id_valuta_inc,
|
|
b.nume_val as nume_val_inc,
|
|
p.denumire as nume,
|
|
p.cod_fiscal
|
|
from (select dataact, serie_act, nract, id_part, id_fact, pereche, suma, suma_val, id_valuta
|
|
from (select dataact, serie_act, nract, id_partc as id_part, id_factc as id_fact, perechec as pereche, suma, suma_val, id_valuta
|
|
from act
|
|
where sters = 0
|
|
and (scc = ?pcCont <<IIF(m.lcTipCont = 'A', '', 'and 1=2')>> and id_partc = <<locauta.id_part>> and id_factc <> 0)
|
|
and (scd not in (select cont_c from exceptii_ireg where cont = ?pcCont and invers = 1))
|
|
and an*12 + luna between <<lnInit>> and <<lnFinal>> <<gcCondSucursala>>)
|
|
union all
|
|
(select dataact, serie_act, nract, id_partd as id_part, id_factd as id_fact, pereched as pereche, suma, suma_val, id_valuta
|
|
from act
|
|
where sters = 0
|
|
and (scd = ?pcCont <<IIF(m.lcTipCont = 'P', '', 'and 1=2')>> and id_partd = <<locauta.id_part>> and id_factd <> 0)
|
|
and (scc not in (select cont_c from exceptii_ireg where cont = ?pcCont and invers = 1))
|
|
and an*12+luna between <<lnInit>> and <<lnFinal>> <<gcCondSucursala>>)) a
|
|
left join nom_valute b on a.id_valuta = b.id_valuta
|
|
left join nom_parteneri c on a.id_part = c.id_part
|
|
ENDTEXT
|
|
|
|
Use In (SELECT('crsIncasari'))
|
|
|
|
lnSucces = goExecutor.oExecute(m.lcSelect, 'crsIncasari')
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare, 0 + 16, 'Eroare')
|
|
Return
|
|
Endif
|
|
|
|
loTherm.Update(75, "Imperechere facturi - incasari...")
|
|
|
|
Create Cursor crsIstoric (tip C(1), id_fact N(20), cod N(20), nume C(100), cod_fiscal C(20), contract C(100), nrord C(100), venchelt C(100), explicatia C(100),;
|
|
id_valuta N(10), nume_val c(4), id_valuta_inc N(10), nume_val_inc c(4), ;
|
|
data_factura d, serie_factura c(10), nr_factura N(14), ;
|
|
prec_suma_factura N(18, 4), prec_suma_val_factura N(18, 4), suma_factura N(18, 4), suma_val_factura N(18, 4), ;
|
|
incasat N(18, 4), incasat_val N(18, 4), sold N(18, 4), sold_val N(18, 4), nratasamente N(10), ;
|
|
data_incasare D, serie_incasare C(10), nr_incasare N(14))
|
|
|
|
* Adaug Facturile in istoric
|
|
*!* Insert Into crsIstoric (tip, id_fact, cod, id_valuta, nume_val, data_factura, serie_factura, nr_factura, suma_factura, suma_val_factura, sold, sold_val, nratasamente) ;
|
|
*!* Select 'F' as tip, id_fact, cod, id_valuta, nume_val, Nvl(Ttod(data_factura), {}) As data_factura, Nvl(serie_factura, []) As serie_factura, ;
|
|
*!* nr_factura, suma_factura, suma_val_factura, ;
|
|
*!* suma_factura As sold, suma_val_factura As sold_val, nratasamente ;
|
|
*!* From cFacturi Order By data_factura, serie_factura, nr_factura
|
|
|
|
*!* USE IN (SELECT('cFacturi'))
|
|
|
|
*!* * Completez total incasat pe facturi in istoric
|
|
*!* SELECT crsIstoric
|
|
*!* INDEX on id_fact TAG id_fact
|
|
*!* Select crsIncasari
|
|
*!* Scan
|
|
*!* Scatter Name oInc
|
|
*!* Select crsIstoric
|
|
*!* IF SEEK(oInc.id_fact)
|
|
*!* Replace incasat With incasat + oInc.incasat, ;
|
|
*!* sold With sold - oInc.incasat, ;
|
|
*!* incasat_val WITH Iif(id_valuta = oInc.id_valuta_inc And id_valuta <> 0 And suma_val_factura <> 0, incasat_val + oInc.incasat_val, incasat_val), ;
|
|
*!* sold_val With Iif(id_valuta = oInc.id_valuta_inc And id_valuta <> 0 And suma_val_factura <> 0, sold_val - oInc.incasat_val, sold_val)
|
|
*!* ENDIF
|
|
*!* ENDSCAN
|
|
|
|
*!* * Adaug incasarile in istoric
|
|
*!* Insert Into crsIstoric (tip, id_fact, cod, id_valuta, nume_val, nr_factura, data_incasare, serie_incasare, nr_incasare, incasat, incasat_val) ;
|
|
*!* Select 'A' as tip, id_fact, 0 as cod, id_valuta_inc as id_valuta, nume_val_inc as nume_val, nr_factura, data_incasare, serie_incasare, nr_incasare, incasat, incasat_val ;
|
|
*!* From crsIncasari order by id_fact, data_incasare, serie_incasare, nr_incasare
|
|
SELECT cFacturi
|
|
INDEX on id_fact TAG id_fact
|
|
Replace All data_incasare With {} For Isnull(data_incasare)
|
|
Replace All data_factura With {} For Isnull(data_factura) IN cFacturi
|
|
|
|
SELECT crsIncasari
|
|
SCAN
|
|
lnIdFact = id_fact
|
|
IF SEEK(m.lnIdFact,'cFacturi','id_fact')
|
|
REPLACE data_factura WITH cFacturi.data_factura, serie_factura WITH cFacturi.serie_factura
|
|
ENDIF
|
|
ENDSCAN
|
|
|
|
|
|
Select 'F' as tip, id_fact, cod, nume, cod_fiscal, contract, nrord, venchelt, explicatia, id_valuta, nume_val, Ttod(data_factura) As data_factura, serie_factura, ;
|
|
nr_factura, suma_factura, suma_val_factura, suma_factura As sold, suma_val_factura As sold_val, nratasamente ;
|
|
From cFacturi ;
|
|
UNION ;
|
|
Select 'A' as tip, id_fact, 0 as cod, id_valuta_inc as id_valuta, nume_val_inc as nume_val, nr_factura, data_incasare, serie_incasare, nr_incasare, incasat, incasat_val ;
|
|
From crsIncasari ;
|
|
ORDER BY data_factura, serie_factura, nr_factura ;
|
|
INTO CURSOR crsIstoric
|
|
|
|
loTherm.Complete()
|
|
Release loTherm
|
|
|
|
SELECT crsIstoric
|
|
SET ORDER TO
|
|
GO TOP
|
|
Select crsIncasari
|
|
GO TOP
|
|
lcTitlu = [Istoric facturi] + Iif(locauta.id_part <> -1, [ ] + Alltrim(locauta.denumire), []) + [ (] + lcPerioada + [)]
|
|
loFrm = Createobject('frm_istoric_clienti', lcTitlu)
|
|
loFrm.Show(1)
|
|
|
|
Use In (SELECT('crsIncasari'))
|
|
USE IN (SELECT('crsIstoric'))
|
|
|
|
ENDPROC && istoric_terti
|
|
|
|
***--------------------------------------------------------------------------------------------------------
|
|
Procedure pondere_clienti
|
|
Do pondere_clienti_furnizori With "CLIENTI"
|
|
Endproc && pondere_clienti
|
|
|
|
***--------------------------------------------------------------------------------------------------------
|
|
Procedure pondere_furnizori
|
|
Do pondere_clienti_furnizori With "FURNIZORI"
|
|
Endproc && pondere_clienti
|
|
|
|
***--------------------------------------------------------------------------------------------------------
|
|
*** <summary>
|
|
*** pondere clienti/furnizori
|
|
*** </summary>
|
|
*** <param name="tcTip">CLIENTI/FURNIZORI</param>
|
|
*** <remarks></remarks>
|
|
*** liana.neagu
|
|
*** 19.10.2015
|
|
Procedure pondere_clienti_furnizori
|
|
Lparameters tctip
|
|
|
|
Local lctip, llRON
|
|
lctip = Iif(Type('tcTip') = 'C', Upper(m.tctip), 'CLIENTI')
|
|
|
|
Private pcli, pcai, pclf, pcaf, plActiv
|
|
Private pnSold_Initial, pnDebit, pnCredit, pnSold_Final
|
|
|
|
Store m.pcnl To pcli, pclf
|
|
Store m.pcan To pcai, pcaf
|
|
plActiv = (m.lctip = 'CLIENTI') && pentru schimbarea caption-urilor in grid, raport
|
|
|
|
pnSold_Initial = 0
|
|
pnDebit = 0
|
|
pnCredit = 0
|
|
pnSold_Final = 0
|
|
|
|
llRON = .F.
|
|
|
|
pcondper = ""
|
|
ofrmperioada = Createobject('frm_perioada_luni')
|
|
ofrmperioada.Show(1)
|
|
If gnButon = 2
|
|
Return
|
|
Endif
|
|
|
|
plPerioada = .F.
|
|
lnPoz = At('_', pcondper)
|
|
If lnPoz > 0
|
|
plPerioada = .T.
|
|
Endif
|
|
|
|
|
|
If plPerioada
|
|
lnAn1 = Val(Substr(pcondper, 3, 4))
|
|
lnLuna1 = Val(Substr(pcondper, 1, 2))
|
|
lnAn2 = Val(Substr(pcondper, 10, 4))
|
|
lnLuna2 = Val(Substr(pcondper, 8, 2))
|
|
|
|
lnnrlunii = lnAn1 * 12 + lnLuna1
|
|
lnnrlunif = lnAn2 * 12 + lnLuna2
|
|
lcPerioada = Substr(pcondper, 1, 2) + '/' + Substr(pcondper, 3, 4) + ' - ' + Substr(pcondper, 8, 2) + '/' + Substr(pcondper, 10, 4)
|
|
Else
|
|
lnAn1 = Val(Substr(pcondper, 3, 4))
|
|
lnLuna1 = Val(Substr(pcondper, 1, 2))
|
|
lnAn2 = Val(Substr(pcondper, 3, 4))
|
|
lnLuna2 = Val(Substr(pcondper, 1, 2))
|
|
|
|
lnnrlunii = lnAn1 * 12 + lnLuna1
|
|
lnnrlunif = lnAn2 * 12 + lnLuna2
|
|
lcPerioada = Substr(pcondper, 1, 2) + '/' + Substr(pcondper, 3, 4) + ' - ' + Substr(pcondper, 1, 2) + '/' + Substr(pcondper, 3, 4)
|
|
Endif
|
|
|
|
*!* podif = Createobject("frm_datai_dataf")
|
|
*!* podif.Show(1)
|
|
*!* If buton = 2
|
|
*!* Return
|
|
*!* Endif
|
|
|
|
*!* lnnrlunii = Val(pcai) * 12 + Val(pcli)
|
|
*!* lnnrlunif = Val(pcaf) * 12 + Val(pclf)
|
|
*!* SELECT calendar
|
|
*!* BROWSE
|
|
*!* RETURN
|
|
*!* Select nl, an From calendar ;
|
|
*!* Where Between(Val(an) * 12 + Val(nl), lnnrlunii, lnnrlunif) ;
|
|
*!* Into Cursor cCalendar
|
|
lcSql = [SELECT nl, an from calendar where an*12+luna between ] + Alltrim(Str(lnnrlunii)) + [ and ] + Alltrim(Str(lnnrlunif)) + [ order by an, luna]
|
|
|
|
lnSucces = goExecutor.oExecute(lcSql, [cCalendar])
|
|
If lnSucces < 0
|
|
Return
|
|
Endif
|
|
Select cCalendar
|
|
If _Tally = 0
|
|
*!* Do mesaj With "Nu exista nici o luna deschisa in perioada", pcli + ' ' + pcai + ' - ' + pclf + ' ' + pcaf
|
|
amessagebox("Nu exista nici o luna deschisa in perioada " + Padl(Alltrim(Str(lnLuna1)), '0') + '/' + Alltrim(Str(lnAn1)) + ' - ' + Padl(Alltrim(Str(lnLuna2 )), '0') + '/' + Alltrim(Str(lnAn2)), 0 + 16, "Atentie!")
|
|
Return
|
|
Endif
|
|
|
|
Select cCalendar
|
|
Go Top
|
|
lcprimaluna = nl
|
|
lcprimulan = an
|
|
Go Bottom
|
|
lcultimaluna = nl
|
|
lcultimulan = an
|
|
Private pcperioada
|
|
pcperioada = "Perioada " + Padl(lcprimaluna, 2, '0') + '/' + lcprimulan + ' - ' + Padl(lcultimaluna, 2, '0') + '/' + lcultimulan
|
|
|
|
llprimaluna = .T.
|
|
|
|
Private pobalpartfc
|
|
Store "" To pobalpartfc
|
|
Local lcSelect, lcFiltru, lcSchema, lcOrder, llAfisare, lcGroup, llModParam, lcFiltruOriginal
|
|
If m.lctip = 'CLIENTI'
|
|
lcSelect = [select an,luna,id_part, nume,cod_fiscal,acont, ] + ;
|
|
[(bcredit-bdebit) as avans,debit,credit,precdeb,preccred, ] + ;
|
|
[(debit-credit-(bcredit-bdebit)) as soldcur,(bpreccred-bprecdeb) as precavans, ] + ;
|
|
[ id_sucursala, sucursala from vbalanta_4111_419 ]
|
|
|
|
Else
|
|
lcSelect = [select an,luna,id_part, nume,cod_fiscal,acont, ] + ;
|
|
[(bdebit-bcredit) as avans,debit,credit,precdeb,preccred, ] + ;
|
|
[(credit-debit-(bdebit-bcredit)) as soldcur,(bprecdeb-bpreccred) as precavans, ] + ;
|
|
[id_sucursala, sucursala from vbalanta_401_409 ]
|
|
Endif
|
|
lcOrder = [nume,acont]
|
|
lcFiltru = [1=1]
|
|
llAfisare = .F.
|
|
llModParam = .T.
|
|
lcFiltruOriginal = [ an*12+LUNA between ] + Alltrim(Str(lnnrlunii)) + [ and ] + Alltrim(Str(lnnrlunif))
|
|
|
|
If !Isnull(gnIdSucursala)
|
|
lcFiltruOriginal = lcFiltruOriginal + gcCondSucursala
|
|
Endif
|
|
|
|
gencursor('pobalpartfc', 'cPondere', lcSelect, lcFiltru, lcSchema, lcOrder, llAfisare, lcGroup, llModParam, lcFiltruOriginal)
|
|
pobalpartfc.ca_baza1.afisare()
|
|
Select cPondere
|
|
Replace All precAVANS With 0, precdeb With 0, preccred With 0 In cPondere For !(an = lnAn1 And luna = lnLuna1)
|
|
|
|
lnSign = Iif(m.lctip = 'CLIENTI', 1, -1)
|
|
|
|
Select nume, acont As analitic, Sum(avans) As avans, Sum(debit) As debit, Sum(credit) As credit, ;
|
|
Sum(precdeb) As precdeb, Sum(preccred) As preccred, Sum(precAVANS) As precAVANS, ;
|
|
Sum(m.lnSign * (precdeb - preccred) - precAVANS) As sold_initial, Sum(m.lnSign * (precdeb - preccred + debit - credit) - (precAVANS + avans)) As sold_final, ;
|
|
Cast(0 As N(10, 2)) As pondere_debit, Cast(0 As N(10, 2)) As pondere_credit, Cast(0 As N(10, 2)) As pondere_sold_final ;
|
|
From cPondere ;
|
|
Group By nume, acont ;
|
|
Into Cursor cPondereF Readwrite
|
|
|
|
Use In (Select('cPondere'))
|
|
|
|
Calculate Sum(avans), Sum(sold_initial), Sum(debit), Sum(credit), Sum(sold_final) ;
|
|
To pnAvans, pnSold_Initial, pnDebit, pnCredit, pnSold_Final
|
|
|
|
Select cPondereF
|
|
If pnDebit = 0
|
|
Replace All pondere_debit With 0.00
|
|
Else
|
|
Replace All pondere_debit With Round(debit / m.pnDebit * 100, 2)
|
|
Endif
|
|
If pnCredit = 0
|
|
Replace All pondere_credit With 0.00
|
|
Else
|
|
Replace All pondere_credit With Round(credit / m.pnCredit * 100, 2)
|
|
Endif
|
|
Replace All pondere_sold_final With sold_final / pnSold_Final * 100
|
|
|
|
Select cPondereF
|
|
Go Top
|
|
|
|
popc = Createobject("frm_pondere_clienti_furnizori") && contabilitate_rapoarte.vcx
|
|
With popc.gridb1
|
|
.column3.header1.Caption = Iif(m.plActiv, "Rulaj debit", "Rulaj credit")
|
|
.column3.ControlSource = Iif(m.plActiv, "debit", "credit")
|
|
.column4.header1.Caption = Iif(m.plActiv, "Rulaj credit", "Rulaj debit")
|
|
.column4.ControlSource = Iif(m.plActiv, "credit", "debit")
|
|
|
|
.column7.header1.Caption = Iif(m.plActiv, "Pondere debit (%)", "Pondere credit (%)")
|
|
.column7.ControlSource = Iif(m.plActiv, "pondere_debit", "pondere_credit")
|
|
.column8.header1.Caption = Iif(m.plActiv, "Pondere credit (%)", "Pondere debit (%)")
|
|
.column8.ControlSource = Iif(m.plActiv, "pondere_credit", "pondere_debit")
|
|
Endwith
|
|
popc.titlufrumos1.Caption = "Pondere " + Lower(m.lctip) + " - " + Alltrim(m.pcperioada)
|
|
popc.Show(1)
|
|
|
|
Use In (Select('cPondereF'))
|
|
|
|
Endproc && pondere_clienti_furnizori
|