Inrolare ROACONTRACTE conform COMUN\docs\inrolare-proiect-git-text.md: - .gitignore/.gitattributes dupa modelul ROACONT (COMUN/ exclus, are repo propriu) - 439 texte FoxBin2Prg generate in arbore (vc2/sc2/fr2/mn2/pj2/db2) - Clase\registry.vcx ramane binar: memo .vct corupt (Error 41), nu se poate converti - Clase\ferestre_contracte.vcx: text generat, roundtrip scutit (fara write-back) - CLAUDE.md, docs/README.md, roa_sync.bat Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RYbiinqXxdEqXi53x4Ro7K
1815 lines
55 KiB
Plaintext
1815 lines
55 KiB
Plaintext
Procedure viz_contracte
|
|
|
|
Private poCtr
|
|
Store '' To poCtr
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
*!* lcSchema1 = [id_ctr N(5), id_part N(10), nume C(30), nr_ctr N(10), data_ctr D(8), obiect C(200), tip N(1), durata N(3), valftva N(20,4), proc_tva N(5,2), avans N(20,4), proc_avans N(5,2),]+;
|
|
*!* [val_finant N(20,4), proc_finant N(5,2), dobanda N(20,4), proc_dobanda N(5,2), val_rezid N(20,4), proc_rezid N(5,2), ]+;
|
|
*!* [rata N(20,4), comision N(20,4), proc_comision N(5,2), proc_asigurare N(5,2), val_asigurare N(20,4), val_ctr N(20,4), id_valuta N(5), nume_val C(4), curs N(10,4), zi_plata N(2), incetat N(1), sters N(1) ]
|
|
*!*
|
|
*!* lcSelect1 = [select c.id_ctr, c.id_part, p.nume, c.nr_ctr, c.data_ctr, c.obiect, c.tip, c.durata, c.valftva, c.proc_tva, c.avans, c.proc_avans, ]+;
|
|
*!* [c.val_finant, c.proc_finant, c.dobanda, c.proc_dobanda, c.val_rezid, c.proc_rezid, ]+;
|
|
*!* [c.rata, c.comision, c.proc_comision, c.proc_asigurare, c.val_asigurare, c.val_ctr, c.id_valuta, v.nume_val, c.curs, c.zi_plata, c.incetat, c.sters from ] + gcS + ;
|
|
*!* [.cf_contracte c join ] + gcS + [.nom_parteneri p on p.id_part = c.id_part]+;
|
|
*!* [ join ] + gcS + [.nom_valute v on c.id_valuta = v.id_valuta]
|
|
lcSelect1 = [select * from ] + gcS + [.vcontracte]
|
|
lcOrder1 = []
|
|
lcgroup = []
|
|
lcFiltru1 = [1=2]
|
|
lcFiltruOriginal = []
|
|
llModParam = .T.
|
|
llAfiseaza = .F.
|
|
|
|
gencursor('poCtr','cContracte', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal)
|
|
poCtr.ca_baza1.afisare()
|
|
|
|
Select cContracte
|
|
|
|
lovcL = Createobject("frm_contracte")
|
|
lovcL.lb_titlu_alb_b121.Caption = "CONTRACTE CLIENTI"
|
|
lovcL.Show(1)
|
|
|
|
Release poCtr
|
|
|
|
Endproc && viz_contracte
|
|
***-----------------------------------------------------------------------------------------------------------------------------
|
|
Procedure adauga_contract
|
|
Parameters tcAlias
|
|
|
|
Local lcAlias
|
|
lcAlias = tcAlias
|
|
|
|
Private pnId_ctr, pcNr_ctr
|
|
Store 0 To pnId_ctr
|
|
Store '' To pcNr_ctr
|
|
|
|
|
|
Local lnTip, lnCurs_ctr, lnNr_rate
|
|
Local lcId_tipc, lcId_tipc, lcId_tipcurs, lcValvaluta, lcvalctva, lcZi_fact, lcziscad, lcId_responsabil, lcId_sectie, lcId_venchelt, lcCoef_pen, lcDescriere
|
|
|
|
Store "" To lcId_tipc, lcId_tipc, lcId_tipcurs, lcValvaluta, lcvalctva, lcZi_fact, lcziscad, lcId_responsabil, lcId_sectie, lcId_venchelt, lcCoef_pen, lcDescriere
|
|
Store '1' To lcZi_fact
|
|
|
|
Select (lcAlias) && cContracte
|
|
Scatter Name poRec Blank
|
|
poRec.data_ctr = Datetime()
|
|
poRec.zi_fact = 1
|
|
poRec.proc_tva = 19
|
|
**---------------------
|
|
|
|
lcSql = [begin pack_crm.next_id_ctr(?gcS, ?@pnId_ctr); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.next_id_ctr'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
**---------------------
|
|
poRec.id_ctr = pnId_ctr
|
|
**---------------------
|
|
*!* pcTabel = "crm_nrcontr"
|
|
*!* pcCamp = "nrcontr"
|
|
*!* lcSql = [begin pack_crm.read_nr(?gcS, ?pcTabel, ?pcCamp, ?@pnNr_ctr); end;]
|
|
*!* lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
*!* If lnSucces < 0
|
|
*!* Messagebox('pack_crm.read_nr'+goExecutor.cEroare,0+16,"Eroare")
|
|
*!* Return
|
|
*!* Endif
|
|
*!* **---------------------
|
|
*!* poRec.nr_ctr = pnNr_ctr
|
|
*!* **---------------------
|
|
|
|
lcSql = [begin pack_crm.next_nr_ctr(?gcS, ?@pcNr_ctr); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.next_nr_ctr'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
**---------------------
|
|
poRec.nr_ctr = pcNr_ctr
|
|
**---------------------
|
|
|
|
Private poTipc
|
|
Store '' To poTipc
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select id_tipc, tipc from ] + gcS + [.crm_tipc where 1=2']
|
|
lcOrder1 = [id_tipc]
|
|
lcFiltru1 = []
|
|
llAfiseaza = .F.
|
|
gencursor('poTipc','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poTipc.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cNom_tipc Readwrite
|
|
Release poTipc
|
|
|
|
Select cNom_tipc
|
|
Go Top
|
|
Scatter Name poTipc
|
|
poRec.id_tipc = cNom_tipc.id_tipc
|
|
**---------------------
|
|
Private poPrestatii
|
|
Store '' To poPrestatii
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vcrm_contracte_articole where 1=2']
|
|
lcOrder1 = []
|
|
lcFiltru1 = [ id_ctr=] + Alltrim(Str(poRec.id_ctr))
|
|
llAfiseaza = .F.
|
|
gencursor('poPrestatii','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poPrestatii.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cArticoleCtr Readwrite
|
|
Select cArticoleCtr
|
|
Release poPrestatii
|
|
**---------------------
|
|
Create Cursor cScadentar (id_ctr N(5), id_rata N(10), nr_rata N(10), den_rata C(30), data_rata D, procent N(4,2), valrata N(20,4), valfact N(20,4), id_valuta N(5), nume_val C(4))
|
|
Select cScadentar
|
|
**---------------------
|
|
Private poDocumente
|
|
Store '' To poDocumente
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vcrm_contracte_documente where 1=2']
|
|
lcOrder1 = []
|
|
lcFiltru1 = [ id_ctr=] + Alltrim(Str(poRec.id_ctr))
|
|
llAfiseaza = .F.
|
|
gencursor('poDocumente','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poDocumente.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cLinkuri Readwrite
|
|
Select cLinkuri
|
|
Release poDocumente
|
|
**---------------------
|
|
llNou = .T.
|
|
locnC = Createobject("frm_contract_nou",pnId_ctr, llNou)
|
|
locnC.Show(1)
|
|
|
|
**---------------------
|
|
If Used("cNom_tipc")
|
|
Use In cNom_tipc
|
|
Endif
|
|
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
|
|
*!* **---------------------
|
|
*!* pcTabel = "crm_nrcontr"
|
|
*!* pcCamp = "nrcontr"
|
|
*!* lcSql = [begin pack_crm.write_nr(?gcS, ?pcTabel, ?pcCamp, ?pnNr_ctr); end;]
|
|
*!* lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
*!* If lnSucces < 0
|
|
*!* Messagebox('pack_crm.write_nr'+goExecutor.cEroare,0+16,"Eroare")
|
|
*!* Return
|
|
*!* Endif
|
|
*!* **---------------------
|
|
*!* pdData_ctr = Nvl(poRec.data_ctr, {//})
|
|
*!* pcObiect = poRec.obiect
|
|
|
|
*!* pnDurata = Nvl(poRec.durata,0)
|
|
*!* pnProc_tva = Nvl(poRec.proc_tva,0)
|
|
*!* pnId_valuta = Nvl(poRec.id_valuta,0)
|
|
*!* pnZi_plata = Nvl(poRec.zi_plata,0)
|
|
*!* pnCurs = Nvl(poRec.Curs,0)
|
|
*!* pnIncetat = Nvl(poRec.Incetat,0)
|
|
*!* pnId_tipc = poRec.id_tipc
|
|
*!* pnId_tipcurs = poRec.id_tipcurs
|
|
*!* pnValvaluta = poRec.valvaluta
|
|
*!* pnvalctva = poRec.valctva
|
|
*!* pnziscad = poRec.ziscad
|
|
*!* pnId_responsabil = poRec.id_responsabil
|
|
*!* pnId_sectie = poRec.id_sectie
|
|
*!* pnId_venchelt = poRec.id_venchelt
|
|
*!* pnCoef_pen = poRec.coef_pen
|
|
*!* pcDescriere = poRec.descriere
|
|
|
|
*!* lcSql = [begin pack_crm.adauga_contract(?gcS, ?pnId_ctr, ?pnId_part, ?pnNr_ctr, ?pdData_ctr, ?pcObiect, ?pnDurata,]+;
|
|
*!* [ ?pnProc_tva, ?pnId_valuta, ?pnZi_plata, ?pnCurs, ?pnIncetat, ?pnId_tipc, ?pnId_tipcurs, ?pnValvaluta, ?pnvalctva, ]+;
|
|
*!* [?pnziscad, ?pnId_responsabil, ?pnId_sectie, ?pnId_venchelt, ?pnCoef_pen, ?pcDescriere, ?gnIdUtil); end;]
|
|
*!* lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
lcId_ctr = Alltrim(Str(pnId_ctr))
|
|
lnId_part = poRec.id_part
|
|
lcId_part = Alltrim(Str(lnId_part))
|
|
lcNr_ctr = Alltrim(poRec.nr_ctr)
|
|
ldData_ctr = Dtos(poRec.data_ctr)
|
|
lcObiect = Alltrim(poRec.obiect)
|
|
|
|
lcDurata = Alltrim(Str(poRec.durata))
|
|
lcProc_tva = Alltrim(Str(poRec.proc_tva))
|
|
lcId_valuta = Alltrim(Str(poRec.id_valuta))
|
|
|
|
If poRec.zi_fact = 99
|
|
lcZi_fact = '-1'
|
|
Else
|
|
lcZi_fact = Alltrim(Str(poRec.zi_fact))
|
|
Endif
|
|
lcCurs = Alltrim(Str(poRec.Curs))
|
|
lcIncetat = Alltrim(Str(poRec.Incetat))
|
|
lcId_tipc = Alltrim(Str(poRec.id_tipc))
|
|
lcId_categ_ctr = ALLTRIM(STR(porec.id_categ_ctr))
|
|
lcId_tipcurs = Alltrim(Str(poRec.id_tipcurs))
|
|
lcValvaluta = Alltrim(Str(poRec.valvaluta,20,gnPA))
|
|
lcvalctva = Alltrim(Str(poRec.valctva,20,gnPA))
|
|
lcziscad = Alltrim(Str(poRec.ziscad))
|
|
lcId_responsabil = Alltrim(Str(poRec.id_responsabil))
|
|
lcId_sectie = Alltrim(Str(poRec.id_sectie))
|
|
lcId_venchelt = Alltrim(Str(poRec.id_venchelt))
|
|
lcCoef_pen = Alltrim(Str(poRec.coef_pen))
|
|
lcDescriere = Alltrim(poRec.descriere)
|
|
lcId_art_fact = Alltrim(Str(poRec.id_art_fact))
|
|
lcIdUtil = Alltrim(Str(gnIdUtil))
|
|
|
|
lcSql = [begin pack_crm.adauga_contract('] + gcS + [',] + lcId_ctr + [,] + lcId_part + [,'] + lcNr_ctr + ;
|
|
[', TO_DATE(]+Iif(!Empty(ldData_ctr),[']+ldData_ctr+['],[NULL])+[,'YYYY-MM-DD'),']+;
|
|
lcObiect + [',] + lcDurata + [,] + ;
|
|
lcProc_tva + [,] + lcId_valuta + [,] + lcZi_fact + [,] + lcCurs + [,] + lcIncetat + [,] + ;
|
|
lcId_tipc + [,] + lcId_categ_ctr + [,] + ;
|
|
lcId_tipcurs + [,] + lcValvaluta + [,] + lcvalctva + [,] + ;
|
|
lcziscad + [,] + lcId_responsabil + [,] + lcId_sectie + [,] + lcId_venchelt + [,] + lcCoef_pen + [,'] + lcDescriere + [',] + ;
|
|
lcId_art_fact + [,] + lcIdUtil +[); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
Strtofile(lcSql,"c:\sql.txt")
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.adauga_contract'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
**---------------------
|
|
&& lcTabelArticole = locnF.grid_articole.RecordSource
|
|
|
|
Select cArticoleCtr
|
|
Replace All id_ctr With pnId_ctr
|
|
Do update_ctr_art With "cArticoleCtr" In oproceduri_roaClienti.prg
|
|
If Used("cArticoleCtr")
|
|
Use In cArticoleCtr
|
|
Endif
|
|
**---------------------
|
|
lnId_tipc = poRec.id_tipc
|
|
If lnId_tipc = 1
|
|
*!* lcSql = [begin pack_crm.adauga_rate(?gcS, ?pnId_ctr, ?pnDurata, ?pnValvaluta, ?pnId_valuta, ?pdData_ctr, ?pnZi_plata); end;]
|
|
lcSql = [begin pack_crm.adauga_rate('] + gcS + [',] + lcId_ctr + [,] + lcDurata + [,] + lcValvaluta + [,] + lcId_valuta + ;
|
|
[, TO_DATE(]+Iif(!Empty(ldData_ctr),[']+ldData_ctr+['],[NULL])+[,'YYYY-MM-DD'),]+;
|
|
lcZi_fact + [); end;]
|
|
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.adauga_rate'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
ENDIF
|
|
|
|
If poRec.id_tipc = 2 && mentenanta
|
|
lcSql = [begin pack_crm.mentenanta(] + ALLTRIM(STR(gnAn)) + [,] + ALLTRIM(STR(gnLuna)) + [,] + lcId_ctr + [); end;]
|
|
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.mentenanta'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
Endif
|
|
|
|
*!* IF pnId_tipc <> 3
|
|
*!* Do viz_rate With pocontract
|
|
*!* Endif
|
|
**---------------------
|
|
If Used("cScadentar")
|
|
Use In cScadentar
|
|
Endif
|
|
**---------------------
|
|
|
|
Return pnId_ctr
|
|
Endproc && adauga_contract
|
|
***-----------------------------------------------------------------------------------------------------------------------------
|
|
Procedure modifica_contract
|
|
Parameters toContract
|
|
|
|
poRec = toContract
|
|
|
|
Private pnId_ctr, pnId_part, pnNr_ctr, pdData_ctr, pcObiect, pnDurata, pnProc_tva, pnId_valuta, pnZi_fact, pnId_art_fact
|
|
Private pnCurs, pnIncetat, pnVal_ctr, pnVal_ctr_f
|
|
**---------------------
|
|
*!* If poRec.zi_fact = -1
|
|
*!* poRec.zi_fact = 99
|
|
*!* Endif
|
|
|
|
*!* Private poTipc
|
|
*!* Store '' To poTipc
|
|
|
|
*!* Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
*!* lcSchema1 = ['']
|
|
*!* lcSelect1 = ['select id_tipc, tipc from ] + gcS + [.crm_tipc where 1=2']
|
|
*!* lcOrder1 = [id_tipc]
|
|
*!* lcFiltru1 = []
|
|
*!* llAfiseaza = .F.
|
|
*!* gencursor('poTipc','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
*!* poTipc.ca_baza1.afisare()
|
|
|
|
*!* Select * From cIntermediar Into Cursor cNom_tipc Readwrite
|
|
*!* Release poTipc
|
|
|
|
*!* Select cNom_tipc
|
|
*!* Locate For id_tipc = poRec.id_tipc
|
|
*!* Scatter Name poTipc
|
|
*!* poRec.id_tipc = cNom_tipc.id_tipc
|
|
**---------------------
|
|
Private poCtr_art
|
|
Store '' To poCtr_art
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ctr_articole where 1=2']
|
|
lcOrder1 = []
|
|
lcFiltru1 = [ id_ctr=] + Alltrim(Str(poRec.id_ctr))
|
|
llAfiseaza = .F.
|
|
gencursor('poCtr_art','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poCtr_art.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cCtrArt Readwrite
|
|
Select cCtrArt
|
|
Release poCtr_art
|
|
**---------------------
|
|
*!* Private poScadentar
|
|
*!* Store '' To poScadentar
|
|
|
|
*!* Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
*!* lcSchema1 = ['id_ctr n(5), id_rata n(10), nr_rata N(10), den_rata C(30), data_rata D, procent n(4,2), valrata n(20,4), valfact n(20,4), id_valuta n(5), nume_val C(4)']
|
|
|
|
*!* lcSelect1 = ['select id_ctr, id_rata, nr_rata, den_rata, data_rata, procent, valrata, valfact, id_valuta, nume_val from ] + gcS + [.vcrm_rate where 1=2']
|
|
*!* lcOrder1 = [nr_rata]
|
|
|
|
*!* lcFiltru1 = [id_ctr=] + Alltrim(Str(poRec.id_ctr))
|
|
*!* llAfiseaza = .F.
|
|
*!* gencursor('poScadentar','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
*!* poScadentar.ca_baza1.afisare()
|
|
|
|
*!* Select * From cIntermediar Into Cursor cScadentar Readwrite
|
|
*!* Release poScadentar
|
|
|
|
*!* Select cScadentar
|
|
**---------------------
|
|
**---------------------
|
|
*!* Private poDocumente
|
|
*!* Store '' To poDocumente
|
|
|
|
*!* Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
*!* lcSchema1 = ['']
|
|
*!* lcSelect1 = ['select * from ] + gcS + [.vcrm_contracte_documente where 1=2']
|
|
*!* lcOrder1 = []
|
|
*!* lcFiltru1 = [ id_ctr=] + Alltrim(Str(poRec.id_ctr))
|
|
*!* llAfiseaza = .F.
|
|
*!* gencursor('poDocumente','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
*!* poDocumente.ca_baza1.afisare()
|
|
|
|
*!* Select * From cIntermediar Into Cursor cLinkuri Readwrite
|
|
*!* Select cLinkuri
|
|
*!* Release poDocumente
|
|
**---------------------
|
|
|
|
locnF = Createobject("frm_contract_nou",poRec.id_ctr)
|
|
locnF.Show(1)
|
|
**---------------------
|
|
If Used("cNom_tipc")
|
|
Use In cNom_tipc
|
|
Endif
|
|
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
**---------------------
|
|
pcId_ctr = Alltrim(Str(poRec.id_ctr))
|
|
pcId_part = Alltrim(Str(poRec.id_part))
|
|
pcNr_ctr = Alltrim(poRec.numar)
|
|
*pcObiect = Nvl(Alltrim(poRec.obiect),"")
|
|
|
|
* pcDurata = Nvl(Alltrim(Str(poRec.durata)),"")
|
|
pcProc_tva = Nvl(Alltrim(Str(poRec.proc_tva)),"")
|
|
pcId_valuta = Nvl(Alltrim(Str(poRec.id_valuta)),"")
|
|
*!* If poRec.zi_fact = 99
|
|
*!* pcZi_fact = '-1'
|
|
*!* Else
|
|
*!* pcZi_fact = Alltrim(Str(poRec.zi_fact))
|
|
*!* Endif
|
|
|
|
* pcCurs = Nvl(Alltrim(Str(poRec.Curs)),"0")
|
|
pcIncetat = Nvl(Alltrim(Str(poRec.Incetat)),"")
|
|
pcId_tipc = Nvl(Alltrim(Str(poRec.id_tip_ctr)),"")
|
|
|
|
pcValftva = Nvl(Alltrim(Str(poRec.valftva,20,gnPA)),"")
|
|
pcvalctva = Nvl(Alltrim(Str(poRec.valctva,20,gnPA)),"")
|
|
pcziscad = Nvl(Alltrim(Str(poRec.ziscad)),"0")
|
|
pcId_responsabil = Nvl(Alltrim(Str(poRec.id_responsabil)),"0")
|
|
pcId_sectie = Nvl(Alltrim(Str(poRec.id_sectie)),"0")
|
|
pcId_venchelt = Nvl(Alltrim(Str(poRec.id_venchelt)),"0")
|
|
pcCoef_pen = Nvl(Alltrim(Str(poRec.coef_pen,6,gnPA)),"0")
|
|
pcDescriere = Nvl(Alltrim(poRec.descriere),"")
|
|
pcId_art_fact = Nvl(Alltrim(Str(poRec.id_art_fact)),"0")
|
|
|
|
ldData_ctr = Dtos(poRec.data_ctr)
|
|
lcIdUtil = Alltrim(Str(gnIdUtil))
|
|
|
|
lcSql = [begin pack_crm.modifica_contract('] + gcS + [',] + pcId_ctr + [,] + pcId_part + [,'] + pcNr_ctr +;
|
|
[', TO_DATE(]+Iif(!Empty(ldData_ctr),[']+ldData_ctr+['],[NULL])+[,'YYYY-MM-DD'),']+;
|
|
pcObiect + [',] + pcDurata +[,]+;
|
|
pcProc_tva + [,] + pcId_valuta + [,] + pcZi_fact + [,] + pcCurs +;
|
|
[,] + pcIncetat + [,] + pcId_tipc + [,] + pcId_categ_ctr + [,] + pcId_tipcurs + [,] + pcValvaluta + [,] + pcvalctva + [,] +;
|
|
pcziscad + [,]+ pcId_responsabil + [,] + pcId_sectie + [,] + pcId_venchelt + [,] + pcCoef_pen + [,'] + ;
|
|
pcDescriere + [',] + pcId_art_fact + [,] + lcIdUtil +[); end;]
|
|
|
|
Strtofile(lcSql,"c:\sql.txt")
|
|
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.modifica_contract'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
**---------------------
|
|
&& lcTabelArticole = locnF.grid_articole.RecordSource
|
|
|
|
Select cArticoleCtr
|
|
Replace All id_ctr With poRec.id_ctr
|
|
Do update_ctr_art With "cArticoleCtr" In oproceduri_roaClienti.prg
|
|
If Used("cArticoleCtr")
|
|
Use In cArticoleCtr
|
|
Endif
|
|
**---------------------
|
|
**---------------------
|
|
Do update_ctr_doc With "cLinkuri" In oproceduri_roaClienti.prg
|
|
If Used("cLinkuri")
|
|
Use In cLinkuri
|
|
Endif
|
|
**---------------------
|
|
|
|
Endproc && modifica_contract
|
|
***-----------------------------------------------------------------------------------------------------------------------------
|
|
Procedure update_ctr_art
|
|
Parameters tcTabelArticole
|
|
|
|
Local lcTabelArticole
|
|
lcTabelArticole = tcTabelArticole
|
|
|
|
Private pnGasit, pnId_ctr_art, pnId_ctr, pnId_art, pnPret_unitar, pnCant, pnValoare,pnDiscount, pnValcdiscount, pcUM, pnId_valuta_art
|
|
Store 0 To pnGasit, pnId_ctr_art, pnId_ctr, pnId_art, pnPret_unitar, pnCant, pnValoare, pnDiscount, pnValcdiscount, pnId_valuta_art
|
|
Store "" To pcUM
|
|
|
|
&& update articole
|
|
lcDeleted = Set("Deleted")
|
|
Set Deleted Off
|
|
|
|
Select (lcTabelArticole)
|
|
Scan
|
|
pnId_ctr_art = id_ctr_art
|
|
pnId_ctr = id_ctr
|
|
pnId_art = id_art
|
|
pnPret_unitar = pret_unitar
|
|
pnCant = cant
|
|
pnValoare = valoare
|
|
pnDiscount = discount
|
|
pnValcdiscount = valcdiscount
|
|
pcUM = Alltrim(um)
|
|
pnId_valuta_art = id_valuta
|
|
|
|
If Deleted()
|
|
llsters = .T.
|
|
Else
|
|
llsters = .F.
|
|
Endif
|
|
|
|
lcSql = [begin pack_crm.cauta_ctr_art(?gcS, ?pnId_ctr, ?pnId_art, ?@pnGasit); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.cauta_ctr_art'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
|
|
If pnGasit = 0
|
|
lcSql = [begin pack_crm.adauga_ctr_art(?gcS, ?pnId_ctr, ?pnId_art, ?pnPret_unitar, ?pnCant, ?pnValoare, ?pnDiscount, ?pnValcdiscount, ?pcUM, ?pnId_valuta_art); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.adauga_ctr_art'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
Else
|
|
If llsters && sterge_rata
|
|
lcSql = [begin pack_crm.sterge_ctr_art(?gcS, ?pnId_ctr_art); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.sterge_ctr_art'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
Else
|
|
lcSql = [begin pack_crm.modifica_ctr_art(?gcS, ?pnId_ctr_art, ?pnId_ctr, ?Id_art, ?pnPret_unitar, ?pnCant, ?pnValoare, ?pnDiscount, ?pnValcdiscount, ?pcUM, ?pnId_valuta_art); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.modifica_ctr_art'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
Endif
|
|
Endif
|
|
Select (lcTabelArticole)
|
|
Endscan
|
|
|
|
Set Deleted &lcDeleted
|
|
|
|
Endproc && update_ctr_art
|
|
***-----------------------------------------------------------------------------------------------------------------------------
|
|
***-----------------------------------------------------------------------------------------------------------------------------
|
|
Procedure update_ctr_doc
|
|
Parameters tcTabelDocumente
|
|
|
|
Local lcTabelDocumente
|
|
lcTabelDocumente = tcTabelDocumente
|
|
|
|
Private pnGasit, pnId_ctr_doc, pnId_ctr, pcDenumire, pcLink
|
|
Store 0 To pnGasit, pnId_ctr_doc, pnId_ctr
|
|
Store "" To pcDenumire, pcLink
|
|
|
|
&& update documente
|
|
lcDeleted = Set("Deleted")
|
|
Set Deleted Off
|
|
|
|
Select (lcTabelDocumente)
|
|
Scan
|
|
pnId_ctr_doc = id_ctr_doc
|
|
pnId_ctr = id_ctr
|
|
pcDenumire = denumire
|
|
pcLink = Link
|
|
|
|
If Deleted()
|
|
llsters = .T.
|
|
Else
|
|
llsters = .F.
|
|
Endif
|
|
|
|
lcSql = [begin pack_crm.cauta_ctr_doc(?gcS, ?pnId_ctr_doc, ?@pnGasit); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.cauta_ctr_doc'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
|
|
If pnGasit = 0
|
|
lcSql = [begin pack_crm.adauga_ctr_doc(?gcS, ?pnId_ctr, ?pcDenumire, ?pcLink); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.adauga_ctr_doc'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
Else
|
|
If llsters && sterge_doc
|
|
lcSql = [begin pack_crm.sterge_ctr_doc(?gcS, ?pnId_ctr_doc); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.sterge_ctr_doc'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
Else
|
|
lcSql = [begin pack_crm.modifica_ctr_doc(?gcS, ?pnId_ctr_doc, ?pnId_ctr, ?pcDenumire, ?pcLink); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.modifica_ctr_doc'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
Endif
|
|
Endif
|
|
Select (lcTabelDocumente)
|
|
Endscan
|
|
|
|
Set Deleted &lcDeleted
|
|
|
|
Endproc && update_ctr_doc
|
|
***-----------------------------------------------------------------------------------------------------------------------------
|
|
Procedure factura
|
|
Parameters tnId_ctr, tnId_part, tlProforma
|
|
|
|
If Empty(tnId_ctr) And Empty(tnId_part)
|
|
Return
|
|
Endif
|
|
|
|
Local llProforma
|
|
llProforma = tlProforma
|
|
|
|
Private pcMasina
|
|
Store "" To pcMasina
|
|
|
|
Private pnId_ctr, pnId_part
|
|
pnId_ctr = tnId_ctr
|
|
pnId_part = tnId_part
|
|
|
|
Private pnpretuval, pnId_fact, pnId_proforma
|
|
Store 0 To pnpretuval, pnId_fact, pnId_proforma && valoarea cu care intru pe factura (pentru contractele in rate)
|
|
|
|
**---------------
|
|
If !Empty(pnId_ctr)
|
|
Private poCtr
|
|
Store '' To poCtr
|
|
|
|
Private pnNr_fact
|
|
Store 0 To pnNr_fact
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vcrm_contracte where 1=2']
|
|
lcOrder1 = []
|
|
lcFiltru1 = [ id_ctr=]+Alltrim(Str(pnId_ctr))
|
|
llAfiseaza = .F.
|
|
gencursor('poCtr','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poCtr.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cCtr Readwrite
|
|
Release poCtr
|
|
|
|
Select cCtr
|
|
Scatter Name poContract
|
|
Use In cCtr
|
|
|
|
Endif
|
|
**---------------
|
|
Private poClient
|
|
Store '' To poClient
|
|
|
|
Private pnNr_fact
|
|
Store 0 To pnNr_fact
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vnom_parteneri where 1=2']
|
|
lcOrder1 = []
|
|
If !Empty(pnId_ctr)
|
|
lcFiltru1 = [ id_part=]+Alltrim(Str(poContract.id_part))
|
|
Else
|
|
lcFiltru1 = [ id_part=]+Alltrim(Str(pnId_part))
|
|
Endif
|
|
llAfiseaza = .F.
|
|
gencursor('poClient','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poClient.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cPartener Readwrite
|
|
Release poClient
|
|
**--
|
|
Select cPartener
|
|
Scatter Name poClient
|
|
Use In cPartener
|
|
**---------------
|
|
Private poFact
|
|
Store '' To poFact
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vcrm_facturi where 1=2']
|
|
lcOrder1 = []
|
|
lcFiltru1 = [1=2]
|
|
llAfiseaza = .F.
|
|
gencursor('poFact','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poFact.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cFact Readwrite
|
|
Release poFact
|
|
|
|
Select cFact
|
|
Scatter Name poFactura Blank
|
|
Use In cFact
|
|
**---------------
|
|
If !Empty(pnId_ctr)
|
|
poFactura.id_ctr = poContract.id_ctr
|
|
poFactura.id_valuta = poContract.id_valuta
|
|
poFactura.nume_val = poContract.nume_val
|
|
poFactura.proc_tva = poContract.proc_tva
|
|
Else
|
|
poFactura.proc_tva = 19
|
|
Endif
|
|
poFactura.id_part = poClient.id_part
|
|
poFactura.data_fact = Date()
|
|
poFactura.data_curs = {//}
|
|
**---------------------
|
|
|
|
If llProforma
|
|
lcSql = [begin pack_crm.next_id_proforma(?gcS, ?@pnId_proforma); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.next_id_proforma'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
|
|
AddProperty(poFactura,"id_proforma",pnId_proforma)
|
|
Else
|
|
lcSql = [begin pack_crm.next_id_fact(?gcS, ?@pnId_fact); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.next_id_fact'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
|
|
poFactura.id_fact = pnId_fact
|
|
Endif
|
|
**---------------------
|
|
|
|
poFactura.data_ireg = poFactura.data_fact
|
|
If Year(poFactura.data_ireg) * 12 + Month(poFactura.data_ireg) <> gnAn*12 + gnLuna
|
|
ldData = Date(gnAn, gnLuna, 1)
|
|
ldData = Gomonth(ldData,1)-1
|
|
poFactura.data_ireg = ldData
|
|
Endif
|
|
|
|
*!* poFactura.data_scad = poFactura.data_fact + poContract.ziscad
|
|
*!* If poContract.id_tipcurs=1
|
|
*!* poFactura.data_curs = poFactura.data_fact
|
|
*!* Else
|
|
*!* pzlc = "1/" + Alltrim(Str(Month(poFactura.data_fact))) + "/" + Alltrim(Str(Year(poFactura.data_fact)))
|
|
*!* data1 = Ctod(pzlc)
|
|
*!* uzlt = Dtoc(data1-1)
|
|
|
|
*!* poFactura.data_curs = uzlt
|
|
*!* Endif
|
|
**---------------------
|
|
If llProforma
|
|
pcTabel = "nrproforme"
|
|
pcCamp = "nrproforma"
|
|
Else
|
|
pcTabel = "nrfact"
|
|
pcCamp = "nrfact"
|
|
Endif
|
|
|
|
lcSql = [begin pack_crm.read_nr(?gcS, ?pcTabel, ?pcCamp, ?@pnNr_fact); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.read_nr'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
**---------------------
|
|
poFactura.nr_fact = pnNr_fact
|
|
**---------------------
|
|
Private poRespons
|
|
Store '' To poRespons
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vnom_responsabili where 1=2']
|
|
lcOrder1 = [nume]
|
|
If !Empty(pnId_ctr) And !Isnull(poContract.id_responsabil)
|
|
lcFiltru1 = [id_responsabil=] + Alltrim(Str(poContract.id_responsabil))
|
|
Else
|
|
lcFiltru1 = [1=2]
|
|
Endif
|
|
llAfiseaza = .F.
|
|
gencursor('poRespons','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poRespons.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cNom_Responsabili Readwrite
|
|
Release poRespons
|
|
|
|
Select cNom_Responsabili
|
|
Scatter Name poResponsabil
|
|
Use In cNom_Responsabili
|
|
**---------------------
|
|
Private poDeleg
|
|
Store '' To poDeleg
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vnom_delegati where 1=2']
|
|
lcOrder1 = [nume]
|
|
lcFiltru1 = [id_part =] + Alltrim(Str(poClient.id_part))
|
|
llAfiseaza = .F.
|
|
gencursor('poDeleg','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poDeleg.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cNom_Delegati Readwrite
|
|
Release poDeleg
|
|
|
|
Select cNom_Delegati
|
|
Scatter Name poDelegat
|
|
Use In cNom_Delegati
|
|
***---------------------------------------
|
|
Private poSect
|
|
Store '' To poSect
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vnom_sectii where 1=2']
|
|
lcOrder1 = [sectie]
|
|
If !Empty(pnId_ctr) And !Isnull(poContract.id_sectie)
|
|
lcFiltru1 = [id_sectie =] + Alltrim(Str(poContract.id_sectie))
|
|
Else
|
|
lcFiltru1 = [1=2]
|
|
Endif
|
|
llAfiseaza = .F.
|
|
gencursor('poSect','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poSect.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cNom_Sectii Readwrite
|
|
Release poSect
|
|
|
|
Select cNom_Sectii
|
|
Scatter Name poSectie
|
|
Use In cNom_Sectii
|
|
***---------------------------------------
|
|
Private poVenChe
|
|
Store '' To poVenChe
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vnom_venchel where 1=2']
|
|
lcOrder1 = [explicatie]
|
|
If !Empty(pnId_ctr) And !Isnull(poContract.id_venchelt)
|
|
lcFiltru1 = [id_venchelt =] + Alltrim(Str(poContract.id_venchelt))
|
|
Else
|
|
lcFiltru1 = [1=2]
|
|
Endif
|
|
llAfiseaza = .F.
|
|
gencursor('poVenChe','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poVenChe.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cNom_VenChel Readwrite
|
|
Release poVenChe
|
|
|
|
Select cNom_VenChel
|
|
Scatter Name poVenChel
|
|
Use In cNom_VenChel
|
|
***---------------------------------------
|
|
Private poLucr
|
|
Store '' To poLucr
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vnom_lucrari where 1=2']
|
|
lcOrder1 = [nrord]
|
|
If !Empty(pnId_ctr)
|
|
lcFiltru1 = [ nrord = '] + Alltrim(poContract.nr_ctr)+"/"+Alltrim(Dtoc(poContract.data_ctr)) + [']
|
|
Else
|
|
lcFiltru1 = [1=2]
|
|
Endif
|
|
llAfiseaza = .F.
|
|
gencursor('poLucr','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poLucr.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cNom_Lucrari Readwrite
|
|
Release poLucr
|
|
|
|
Select cNom_Lucrari
|
|
Scatter Name poLucrare
|
|
Use In cNom_Lucrari
|
|
***---------------------------------------
|
|
Private poFDocument
|
|
Store '' To poFDocument
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vnom_fdoc where 1=2']
|
|
lcOrder1 = [fel_document]
|
|
lcFiltru1 = [ UPPER(fel_document) = 'FACTURA']
|
|
llAfiseaza = .F.
|
|
gencursor('poFDocument','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poFDocument.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cNom_FDoc Readwrite
|
|
Release poFDocument
|
|
|
|
Select cNom_FDoc
|
|
Scatter Name poFDoc
|
|
Use In cNom_FDoc
|
|
***---------------------------------------
|
|
If !Empty(pnId_ctr)
|
|
lcSql = [begin pack_crm.calculeaza_val_next_factura(?gcS, ?pocontract.id_ctr, ?@pnpretuval); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.calculeaza_val_next_factura'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
Endif
|
|
***---------------------------------------
|
|
Private poFact_elem
|
|
Store '' To poFact_elem
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = [select fe.*, 000 as nrcrt,'Denumire articol' as den_articol, ' ' as scd, ' ' as scc, ' ' as ascd, ' ' as ascc from ] + gcS + [.fact_elem fe where 1=2]
|
|
* [ left join vnom_articole_crm a on a.id_articol = fe.id_articol where 1=2']
|
|
lcOrder1 = []
|
|
lcFiltru1 = [1=2]
|
|
llAfiseaza = .F.
|
|
gencursor('poFact_elem','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poFact_elem.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor tFactura Readwrite
|
|
Release poFact_elem
|
|
|
|
If !Empty(pnId_ctr)
|
|
If !Empty(poContract.id_art_fact) And !Isnull(poContract.id_art_fact)
|
|
Private poArt_Fact
|
|
Store '' To poArt_Fact
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = [select id_articol, denumire, scd, scc, ascd, ascc from ] + gcS + [.vcrm_articole_note where 1=2]
|
|
lcOrder1 = []
|
|
lcFiltru1 = [id_articol=]+Alltrim(Str(poContract.id_art_fact))
|
|
llAfiseaza = .F.
|
|
gencursor('poArt_Fact','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poArt_Fact.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor tArt_fact Readwrite
|
|
Release poArt_Fact
|
|
Else && toate articolele contractate
|
|
Private poArt_Fact
|
|
Store '' To poArt_Fact
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = [select id_art as id_articol, denumire, scd, scc, ascd, ascc from ] + gcS + [.vcrm_contracte_articole_note where 1=2]
|
|
lcOrder1 = []
|
|
lcFiltru1 = [id_ctr=]+Alltrim(Str(poContract.id_ctr))
|
|
llAfiseaza = .F.
|
|
gencursor('poArt_Fact','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poArt_Fact.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor tArt_fact Readwrite
|
|
Release poArt_Fact
|
|
Endif
|
|
|
|
Select tArt_fact
|
|
Scan
|
|
Select tFactura
|
|
Append Blank
|
|
Replace denumire With Alltrim(tArt_fact.denumire) + " CONFORM CONTRACTULUI", ;
|
|
den_articol With Alltrim(tArt_fact.denumire), ;
|
|
id_articol With tArt_fact.id_articol, ;
|
|
scd With tArt_fact.scd, ;
|
|
scc With tArt_fact.scc, ;
|
|
ascd With tArt_fact.ascd, ;
|
|
ascc With tArt_fact.ascc, ;
|
|
CANTITATE With 1, ;
|
|
um With "BUC", ;
|
|
nrcrt With 1, ;
|
|
pretuval With pnpretuval
|
|
|
|
Select tArt_fact
|
|
Endscan
|
|
Endif
|
|
|
|
Select tFactura
|
|
Go Top
|
|
|
|
**---------------
|
|
lovf = Createobject("frm_factura",llProforma)
|
|
lovf.Show(1)
|
|
**---------------------
|
|
If buton = 2
|
|
Use In tFactura
|
|
Return
|
|
Endif
|
|
**---------------------
|
|
If llProforma
|
|
lcSql = [begin pack_crm.in_proforme(?gcS, ?gnLuna, ?gnAn, ?pofactura.id_proforma, ?pofactura.id_part,NULL,?pofactura.nr_fact, ]+;
|
|
[?pofactura.data_fact, ?pofactura.data_ireg, ?pofactura.data_scad, ?pofactura.valftva, ?pofactura.valtva, ?pofactura.valctva, ]+;
|
|
[?pofactura.valval, ?pofactura.tvaval, ?pofactura.totval, ?poFactura.id_valuta, ?pofactura.curs, ?pofactura.data_curs, ?pofactura.cod, ?pofactura.proc_tva, ]+;
|
|
[?pofactura.explcont, ?gnIdUtil); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.in_proforme'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
**---------------------
|
|
Do in_proforme_elem In oproceduri_roaClienti.prg
|
|
**---------------------
|
|
Else
|
|
pcTabel = "nrfact"
|
|
pcCamp = "nrfact"
|
|
lcSql = [begin pack_crm.write_nr(?gcS, ?pcTabel, ?pcCamp, ?pnNr_fact); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.write_nr'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
**---------------------
|
|
Select tFactura
|
|
If !Empty(pnId_ctr)
|
|
Do make_actactan With poFactura, poClient, poResponsabil, poContract
|
|
Else
|
|
Do make_actactan With poFactura, poClient, poResponsabil
|
|
Endif
|
|
|
|
Select actactan
|
|
Do Form verificare With .T.
|
|
|
|
If buton=2
|
|
Use In actactan
|
|
Return
|
|
Endif
|
|
|
|
Select actactan
|
|
Do oscrie_in_fisiere
|
|
|
|
**---------------------
|
|
If !Empty(pnId_ctr)
|
|
lcSql = [begin pack_crm.in_facturi(?gcS, ?gnLuna, ?gnAn, ?pofactura.id_fact, ?pofactura.id_part, ?pocontract.id_ctr, ?pofactura.nr_fact, ]+;
|
|
[?pofactura.data_fact, ?pofactura.data_ireg, ?pofactura.data_scad, ?pofactura.valftva, ?pofactura.valtva, ?pofactura.valctva, ]+;
|
|
[?pofactura.valval, ?pofactura.tvaval, ?pofactura.totval, ?poFactura.id_valuta, ?pofactura.curs, ?pofactura.data_curs, ?pofactura.cod, ?pofactura.proc_tva, ]+;
|
|
[?pofactura.explcont, ?gnIdUtil); end;]
|
|
Else
|
|
lcSql = [begin pack_crm.in_facturi(?gcS, ?gnLuna, ?gnAn, ?pofactura.id_fact, ?pofactura.id_part,NULL,?pofactura.nr_fact, ]+;
|
|
[?pofactura.data_fact, ?pofactura.data_ireg, ?pofactura.data_scad, ?pofactura.valftva, ?pofactura.valtva, ?pofactura.valctva, ]+;
|
|
[?pofactura.valval, ?pofactura.tvaval, ?pofactura.totval, ?poFactura.id_valuta, ?pofactura.curs, ?pofactura.data_curs, ?pofactura.cod, ?pofactura.proc_tva, ]+;
|
|
[?pofactura.explcont, ?gnIdUtil); end;]
|
|
Endif
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.in_facturi'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
**---------------------
|
|
Do in_factelem In oproceduri_roaClienti.prg
|
|
**---------------------
|
|
If !Empty(pnId_ctr)
|
|
lcSql = [begin pack_crm.in_rate(?gcS, ?pocontract.id_ctr, ?pofactura.id_fact, ?pofactura.valval); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.in_rate'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
Endif
|
|
**---------------------
|
|
Endif
|
|
|
|
Use In tFactura
|
|
**---------------------
|
|
|
|
Endproc && factura
|
|
***-----------------------------------------------------------------------------------------------------------------------------
|
|
***-----------------------------------------------------------------------------------------------------------------------------
|
|
Procedure make_actactan
|
|
Parameters tofactura, toclient, toresponsabil, toContract
|
|
|
|
Local lcscd, lcscc, lcascd, lcascc, lcacronim
|
|
Store '' To lcscd, lcscc, lcascd, lcascc, lcacronim
|
|
|
|
* actactan = gcTempPath + "actactan.dbf"
|
|
***-----
|
|
Private poAct
|
|
Store '' To poAct
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.act where 1=2']
|
|
lcOrder1 = []
|
|
lcFiltru1 = [1=2]
|
|
llAfiseaza = .F.
|
|
gencursor('poAct','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poAct.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor actactan Readwrite
|
|
Release poAct
|
|
|
|
***-----
|
|
*!* Select act
|
|
*!* Copy To (actactan) With Cdx
|
|
*!* Sele 0
|
|
*!* Use (actactan) Excl Alias actactan
|
|
*!* Sele actactan
|
|
*!* Zap
|
|
|
|
Local lcid_set
|
|
lnid_set = 50000
|
|
|
|
*!* Select optiuni_program
|
|
*!* Locate For Upper(Alltrim(varname))="ID_SET"
|
|
*!* If Found()
|
|
*!* lnid_set=Eval(varvalue)
|
|
*!* Endif
|
|
|
|
****
|
|
If gnInreg_fact_linii = 1 && pun atatea linii cate prestatii am (eventual cu liniile de TVA corespunzatoare)
|
|
Select tFactura
|
|
Scan
|
|
Scatter Name loelem Memo
|
|
Select actactan
|
|
Scatter Name loact Blank
|
|
With loact
|
|
.COD = tofactura.COD
|
|
.dataireg = tofactura.data_ireg
|
|
.id_fdoc = poFDoc.id_fdoc
|
|
.dataact = tofactura.data_fact
|
|
.nract = tofactura.nr_fact
|
|
.id_partd = toclient.id_part
|
|
.explicatia = tofactura.explcont
|
|
.scd = loelem.scd && "411"
|
|
.scc = loelem.scc && "704"
|
|
.ascd = loelem.ascd && ""
|
|
.ascc = loelem.ascc && ""
|
|
.suma = Round(loelem.valftva, gnPC)
|
|
*!* If glfact_extern && facturile extern
|
|
*!* .suma_2 = Round(loelem.valval,pnvalvalfact_tot)
|
|
*!* .suma_3 = Round(tofactura.Curs, pncurs_zecimale)
|
|
*!* Endif
|
|
.datascad = tofactura.data_scad
|
|
.id_sectie = poSectie.id_sectie
|
|
.id_venchelt = poVenChel.id_venchelt
|
|
.id_lucrare = poLucrare.id_lucrare
|
|
.proc_tva = (100 + loelem.proc_tva)/100
|
|
*CASE pnCalcTVA = 2
|
|
*.proc_tva = (100 + tofactura.proc_tva)/100
|
|
*ENDCASE
|
|
|
|
.dataora = Datetime()
|
|
.id_fact = tofactura.id_fact
|
|
.id_responsabil = toresponsabil.id_responsabil
|
|
.id_set = lnid_set
|
|
|
|
Select actactan
|
|
Append Blank
|
|
Gather Name loact
|
|
|
|
If loelem.valtva <> 0
|
|
.suma = Round(loelem.valtva, gnPC)
|
|
.scc="4427"
|
|
.ascc=""
|
|
Select actactan
|
|
Append Blank
|
|
Gather Name loact
|
|
Endif
|
|
|
|
Endwith
|
|
Select tFactura
|
|
Endscan
|
|
Else && inregistrez o singura linie pt toata factura (grupuri de scd)
|
|
Select Distinct scd, ascd, scc, ascc, ;
|
|
ROUND(Sum(valftva), gnPC) As valftva, ;
|
|
proc_tva ;
|
|
FROM tFactura ;
|
|
GROUP By scd, ascd, scc, ascc, proc_tva ;
|
|
INTO Cursor tConturi
|
|
|
|
Select tConturi
|
|
Scan
|
|
Select actactan
|
|
Scatter Name loact Blank
|
|
|
|
With loact
|
|
.COD = tofactura.COD
|
|
.dataireg = tofactura.data_ireg
|
|
.id_fdoc = poFDoc.id_fdoc
|
|
.dataact = tofactura.data_fact
|
|
|
|
.nract = tofactura.nr_fact
|
|
.id_partd = toclient.id_part
|
|
.explicatia = tofactura.explcont
|
|
|
|
.scd = tConturi.scd
|
|
.scc= tConturi.scc
|
|
.ascd = tConturi.ascd
|
|
.ascc = tConturi.ascc
|
|
.suma = Round(tConturi.valftva,gnPC)
|
|
|
|
*!* If glfact_extern && facturile extern
|
|
*!* .suma_2 = Round(tofactura.valval,pnvalvalfact_tot)
|
|
*!* .suma_3 = Round(tofactura.Curs,pncurs_zecimale)
|
|
*!* Endif
|
|
|
|
.datascad = tofactura.data_scad
|
|
.id_sectie = poSectie.id_sectie
|
|
.id_venchelt = poVenChel.id_venchelt
|
|
.id_lucrare = poLucrare.id_lucrare
|
|
.proc_tva = (100 + tConturi.proc_tva) / 100
|
|
.dataora = Datetime()
|
|
.id_fact = tofactura.id_fact
|
|
.id_responsabil = toresponsabil.id_responsabil
|
|
.id_set = lnid_set
|
|
|
|
Select actactan
|
|
Append Blank
|
|
Gather Name loact
|
|
|
|
Endwith
|
|
|
|
Select tConturi
|
|
Endscan
|
|
|
|
If Used("tConturi")
|
|
Use In tConturi
|
|
Endif
|
|
|
|
&& scrie linia cu TVA
|
|
Select Distinct scd, ascd, proc_tva, ;
|
|
ROUND(Sum(valtva), gnPC) As valtva ;
|
|
FROM tFactura ;
|
|
GROUP By scd, ascd, proc_tva ;
|
|
INTO Cursor tCoteTva
|
|
|
|
Select tCoteTva
|
|
Scan For valtva <> 0
|
|
With loact
|
|
.suma = Round(tCoteTva.valtva, gnPC)
|
|
.proc_tva = (100 + tCoteTva.proc_tva) / 100
|
|
.scc = "4427"
|
|
.ascc = ""
|
|
Endwith
|
|
|
|
Select actactan
|
|
Append Blank
|
|
Gather Name loact
|
|
|
|
Select tCoteTva
|
|
Endscan
|
|
|
|
If Used("tCoteTva")
|
|
Use In tCoteTva
|
|
Endif
|
|
Endif
|
|
|
|
Return .T.
|
|
Endproc && make_actactan
|
|
***--------------------------------------------------------------------------------------
|
|
Procedure viz_facturi
|
|
Parameters tlProforme
|
|
|
|
Local llProforme
|
|
llProforme = tlProforme
|
|
|
|
Private poFacturi
|
|
Store '' To poFacturi
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
|
|
If llProforme
|
|
lcId_tip = [id_proforma N(20),]
|
|
lcId = [id_proforma, ]
|
|
lcView = [.vcrm_proforme]
|
|
Else
|
|
lcId_tip = [id_fact N(20),]
|
|
lcId = [id_fact, ]
|
|
lcView = [.vcrm_facturi]
|
|
Endif
|
|
lcSchemaComun = [id_ctr N(5), nr_fact N(10), data_fact D(8), data_ireg D(8), data_scad D(8), valftva N(20,4), valtva N(20,4), valctva N(20,4),]+;
|
|
[valval N(20,4), tvaval N(20,4), totval N(20,4), curs N(10,4), data_curs D(8), cod N(10), proc_tva N(2), explcont C(30),]+;
|
|
[sters N(1), id_util N(8), dataora T, id_part N(10), an N(4), luna N(2), id_valuta N(5),]+;
|
|
[nume C(70), nr_ctr C(20), nume_val C(20)]
|
|
|
|
lcSchema1 = lcId_tip + lcSchemaComun
|
|
lcSelectComun = [id_ctr, nr_fact, data_fact, data_ireg, data_scad, valftva, valtva, valctva, ]+;
|
|
[valval, tvaval, totval, curs, data_curs, cod, proc_tva, explcont, ]+;
|
|
[sters, id_util, dataora, id_part, an, luna, id_valuta, ]+;
|
|
[nume, nr_ctr, nume_val]+;
|
|
[ from ] + gcS
|
|
|
|
lcSelect1 = [select ] + lcId + lcSelectComun + lcView
|
|
lcOrder1 = [data_fact]
|
|
lcgroup = []
|
|
lcFiltru1 = [1=2]
|
|
lcFiltruOriginal = []
|
|
llModParam = .T.
|
|
llAfiseaza = .F.
|
|
|
|
gencursor('poFacturi','tFacturi', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal)
|
|
poFacturi.ca_baza1.afisare()
|
|
|
|
Select tFacturi
|
|
loff = Createobject("frm_viz_facturi",llProforme)
|
|
loff.Show(1)
|
|
|
|
Release poFacturi
|
|
|
|
Endproc && viz_facturi
|
|
***--------------------------------------------------------------------------------------
|
|
Procedure in_factelem
|
|
|
|
Private pnId_fact, pnId_articol, pcDenumire, pcUM, pnCantitate, pnPretUnitar, pnvalftva, pnvaltva, pnvalctva, pnpretuval, pnvalval, pntvaval, pntotval, pnProc_tva
|
|
Store 0 To pnId_fact, pnId_articol, pnCantitate, pnPretUnitar, pnvalftva, pnvaltva, pnvalctva, pnpretuval, pnvalval, pntvaval, pntotval, pnProc_tva
|
|
Store "" To pcDenumire, pcUM
|
|
|
|
Select tFactura
|
|
Scan
|
|
pnId_fact = poFactura.id_fact
|
|
pnId_articol = id_articol
|
|
pcDenumire = denumire
|
|
pcUM = um
|
|
pnCantitate = CANTITATE
|
|
pnPretUnitar = pretUnitar
|
|
pnvalftva = valftva
|
|
pnvaltva = valtva
|
|
pnvalctva = valctva
|
|
pnpretuval = pretuval
|
|
pnvalval = valval
|
|
pntotval = totval
|
|
pnProc_tva = proc_tva
|
|
|
|
lcSql = [begin pack_crm.in_factelem(?gcS, ?gnLuna, ?gnAn, ?pnid_fact, ?pnId_articol, ?pcDenumire, ?pcUm, ?pnCantitate, ?pnPretUnitar, ]+;
|
|
[?pnvalftva, ?pnvaltva, ?pnvalctva, ?pnpretuval, ]+;
|
|
[?pnvalval, ?pntvaval, ?pntotval, ?pnproc_tva, ?gnIdUtil); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.in_factelem'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
|
|
Select tFactura
|
|
Endscan
|
|
|
|
Endproc && in_factelem
|
|
***--------------------------------------------------------------------------------------
|
|
Procedure listfactura
|
|
Parameters tnId_fact, tlProforma
|
|
|
|
Local llProforma
|
|
llProforma = tlProforma
|
|
|
|
Private pnId_fact
|
|
pnId_fact = tnId_fact && id_fact / id_proforma
|
|
**---------------
|
|
Private poFact
|
|
Store '' To poFact
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
If llProforma
|
|
lcSelect1 = ['select * from ] + gcS + [.proforme where 1=2']
|
|
lcFiltru1 = [id_proforma=]+Alltrim(Str(pnId_fact))
|
|
Else
|
|
lcSelect1 = ['select * from ] + gcS + [.facturi where 1=2']
|
|
lcFiltru1 = [id_fact=]+Alltrim(Str(pnId_fact))
|
|
Endif
|
|
lcOrder1 = []
|
|
llAfiseaza = .F.
|
|
gencursor('poFact','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poFact.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cFact Readwrite
|
|
Release poFact
|
|
|
|
Select cFact
|
|
Scatter Name poFactura
|
|
**---------------
|
|
**---------------
|
|
Private poClie
|
|
Store '' To poClie
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vnom_parteneri where 1=2']
|
|
lcOrder1 = []
|
|
lcFiltru1 = [id_part=]+Alltrim(Str(poFactura.id_part))
|
|
llAfiseaza = .F.
|
|
gencursor('poClie','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poClie.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cClienti Readwrite
|
|
Release poClie
|
|
|
|
Select cClienti
|
|
Scatter Name poClient
|
|
**---------------
|
|
**---------------
|
|
Private poVal
|
|
Store '' To poVal
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.nom_valute where 1=2']
|
|
lcOrder1 = []
|
|
If !Empty(poFactura.id_valuta) And !Isnull(poFactura.id_valuta)
|
|
lcFiltru1 = [id_valuta=]+Alltrim(Str(poFactura.id_valuta))
|
|
Else
|
|
lcFiltru1 = []
|
|
Endif
|
|
llAfiseaza = .F.
|
|
gencursor('poVal','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poVal.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cValute Readwrite
|
|
Release poVal
|
|
|
|
Select cValute
|
|
Scatter Name poValuta
|
|
**---------------
|
|
**---------------------
|
|
Private poRespons
|
|
Store '' To poRespons
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vnom_responsabili where 1=2']
|
|
lcOrder1 = [nume]
|
|
lcFiltru1 = [ales=1]
|
|
llAfiseaza = .F.
|
|
gencursor('poRespons','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poRespons.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cNom_Responsabili Readwrite
|
|
If Used("cIntermediar")
|
|
Use In cIntermediar
|
|
Endif
|
|
|
|
Select cNom_Responsabili
|
|
Scatter Name poResponsabil
|
|
|
|
Release poRespons
|
|
**---------------------
|
|
Private poDeleg
|
|
Store '' To poDeleg
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vnom_responsabili where 1=2']
|
|
lcOrder1 = [nume]
|
|
* lcFiltru1 = [id_partener =] + Alltrim(Str(poFactura.id_part))
|
|
lcFiltru1 = []
|
|
llAfiseaza = .F.
|
|
gencursor('poDeleg','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poDeleg.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cNom_Delegati Readwrite
|
|
Select cNom_Delegati
|
|
Scatter Name poDelegat
|
|
|
|
Release poDeleg
|
|
***---------------------------------------
|
|
***---------------------------------------
|
|
Private poFact_elem
|
|
Store '' To poFact_elem
|
|
|
|
Private pcMasina
|
|
Store "" To pcMasina
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
If llProforma
|
|
lcSelect1 = ['select pe.*, 000 as nrcrt from ] + gcS + [.proforme_elem pe where 1=2']
|
|
lcFiltru1 = [id_proforma=]+Alltrim(Str(poFactura.id_proforma))
|
|
Else
|
|
lcSelect1 = ['select fe.*, 000 as nrcrt from ] + gcS + [.fact_elem fe where 1=2']
|
|
lcFiltru1 = [id_fact=]+Alltrim(Str(poFactura.id_fact))
|
|
Endif
|
|
lcOrder1 = []
|
|
llAfiseaza = .F.
|
|
gencursor('poFact_elem','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poFact_elem.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor tFactura Readwrite
|
|
Release poFact_elem
|
|
***---------------------------------------
|
|
Select tFactura
|
|
Replace All nrcrt With Recno()
|
|
|
|
If llProforma
|
|
Report Form proforma_a4 To Printer Prompt Preview
|
|
Else
|
|
lcmenu="\Factura A4;\Factura Fanfold - Tractor;\Factura A4 - RMS - lei;\Factura A4 - RMS - valuta fara TVA;\-;\<Factura A5;\Factura A5 - fara antet"
|
|
lnx=xmenu(lcmenu)
|
|
|
|
Do Case
|
|
Case lnx=1
|
|
Report Form factura_a4 To Printer Prompt Preview && Romfast
|
|
Case lnx=2
|
|
Report Form factura_a4_tractor To Printer Prompt Preview
|
|
Case lnx=3
|
|
Report Form factura_a4_RMS_lei To Printer Prompt Preview
|
|
Case lnx = 4
|
|
Report Form factura_a4_RMS_valuta_faraTVA To Printer Prompt Preview
|
|
Case lnx=6
|
|
Report Form factura_a5 To Printer Prompt Preview
|
|
Case lnx=7
|
|
Report Form factura_a5_faraAntet To Printer Prompt Preview
|
|
Endcase
|
|
Endif
|
|
|
|
Use In tFactura
|
|
|
|
|
|
Endproc && listfactura
|
|
***--------------------------------------------------------------------------------------
|
|
|
|
******************************************************************************************************************
|
|
Procedure lista_facturi
|
|
|
|
lcSel = [{call pack_crm.lista_facturi(']+gcS+[')}]
|
|
lnSucces = goExecutor.oExecute(lcSel)
|
|
If lnSucces < 0
|
|
Messagebox('Call pack_crm.lista_facturi' + Chr(13) + goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
|
|
Select sqlResult && azi
|
|
Select sqlResult1 && panaAzi
|
|
Select sqlResult2 && saptViit
|
|
|
|
lofa = Createobject("frm_viz_facturiazi")
|
|
lofa.Show(1)
|
|
|
|
Use In sqlResult
|
|
Use In sqlResult1
|
|
Use In sqlResult2
|
|
|
|
Endproc && lista_facturi
|
|
***--------------------------------------------------------------------------------------
|
|
Procedure sterg_factura
|
|
Endproc && sterg_factura
|
|
***--------------------------------------------------------------------------------------
|
|
Procedure in_proforme_elem
|
|
|
|
Private pnId_proforma, pnId_articol, pcDenumire, pcUM, pnCantitate, pnPretUnitar, pnvalftva, pnvaltva, pnvalctva, pnpretuval, pnvalval, pntvaval, pntotval, pnProc_tva
|
|
Store 0 To pnId_proforma, pnId_articol, pnCantitate, pnPretUnitar, pnvalftva, pnvaltva, pnvalctva, pnpretuval, pnvalval, pntvaval, pntotval, pnProc_tva
|
|
Store "" To pcDenumire, pcUM
|
|
|
|
Select tFactura
|
|
Scan
|
|
pnId_proforma = poFactura.id_proforma
|
|
pnId_articol = id_articol
|
|
pcDenumire = denumire
|
|
pcUM = um
|
|
pnCantitate = CANTITATE
|
|
pnPretUnitar = pretUnitar
|
|
pnvalftva = valftva
|
|
pnvaltva = valtva
|
|
pnvalctva = valctva
|
|
pnpretuval = pretuval
|
|
pnvalval = valval
|
|
pntotval = totval
|
|
pnProc_tva = proc_tva
|
|
|
|
lcSql = [begin pack_crm.in_proforme_elem(?gcS, ?gnLuna, ?gnAn, ?pnId_proforma, ?pnId_articol, ?pcDenumire, ?pcUm, ?pnCantitate, ?pnPretUnitar, ]+;
|
|
[?pnvalftva, ?pnvaltva, ?pnvalctva, ?pnpretuval, ]+;
|
|
[?pnvalval, ?pntvaval, ?pntotval, ?pnproc_tva, ?gnIdUtil); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.in_proforme_elem'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
|
|
Select tFactura
|
|
Endscan
|
|
|
|
Endproc && in_proforme_elem
|
|
***--------------------------------------------------------------------------------------
|
|
Procedure viz_rate
|
|
Parameters tnId_ctr
|
|
|
|
Private pnId_rata, pnId_ctr, pnNr_rata, pdData_rata, pnGasit, pnValrata, pnValfact
|
|
|
|
Store 0 To pnId_rata, pnId_ctr, pnNr_rata, pcDen_rata, pnId_rata, pnGasit, pnValrata, pnValfact
|
|
Store {//} To pdDataact, pdData_rata
|
|
Store "" To pcDen_rata
|
|
|
|
Local lcTabel, lcId_ctr, lcNr_ctr, lcData_ctr
|
|
lnId_ctr = tnId_ctr
|
|
|
|
&& gen_cursor din vcrm_contracte
|
|
Private poContract
|
|
Store '' To poContract
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select * from ] + gcS + [.vcrm_contracte where 1=2']
|
|
lcOrder1 = []
|
|
lcFiltru1 = [id_ctr=] + Alltrim(Str(lnId_ctr))
|
|
llAfiseaza = .F.
|
|
gencursor('poContract','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poContract.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cContract Readwrite
|
|
Release poContract
|
|
***-------------
|
|
|
|
If _Tally = 0
|
|
Return
|
|
Endif
|
|
|
|
*!* lcId_ctr = Nvl(Alltrim(Str(id_ctr)),"0")
|
|
lcNr_ctr = Nvl(Alltrim(cContract.nr_ctr),"")
|
|
lcData_ctr = Nvl(Dtoc(cContract.data_ctr),"") && Nvl(Dtoc(data_ctr),{//})
|
|
lnId_valuta = cContract.id_valuta
|
|
|
|
If Used("cContract")
|
|
Use In cContract
|
|
Endif
|
|
|
|
Private poScadentar
|
|
Store '' To poScadentar
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
|
|
lcSelect1 = ['select * from ] + gcS + [.vcrm_rate where 1=2']
|
|
lcOrder1 = [nr_rata]
|
|
|
|
lcFiltru1 = [id_ctr=] + Alltrim(Str(lnId_ctr))
|
|
llAfiseaza = .F.
|
|
gencursor('poScadentar','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poScadentar.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cScadentar Readwrite
|
|
Release poScadentar
|
|
|
|
Select cScadentar
|
|
|
|
Private poValute
|
|
Store '' To poValute
|
|
|
|
Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
|
|
lcSchema1 = ['']
|
|
lcSelect1 = ['select nume_val, id_valuta from ] + gcS + [.vnom_valute where 1=2']
|
|
lcOrder1 = [nume_val]
|
|
lcFiltru1 = []
|
|
llAfiseaza = .F.
|
|
gencursor('poValute','cIntermediar', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza)
|
|
poValute.ca_baza1.afisare()
|
|
|
|
Select * From cIntermediar Into Cursor cNom_valute Readwrite
|
|
Release poValute
|
|
|
|
Select cNom_valute
|
|
|
|
Select cScadentar
|
|
lofs = Createobject("frm_rate", lnId_ctr, lnId_valuta)
|
|
lofs.lb_titlu_alb_b121.Caption = "Contractul nr " + lcNr_ctr + " din " + lcData_ctr
|
|
lofs.Show(1)
|
|
|
|
If Used("cNom_valute")
|
|
Use In cNom_valute
|
|
Endif
|
|
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
|
|
Do update_rate With "cScadentar"
|
|
|
|
Endproc && viz_rate
|
|
***--------------------------------------------------------------------------------------
|
|
Procedure update_rate
|
|
Parameters tcTabel
|
|
|
|
Local lcTabel
|
|
lcTabel = tcTabel
|
|
|
|
lcDeleted = Set("Deleted")
|
|
Set Deleted Off
|
|
|
|
Select cScadentar
|
|
Scan
|
|
Scatter Name loRata
|
|
If Deleted()
|
|
llsters = .T.
|
|
Else
|
|
llsters = .F.
|
|
Endif
|
|
pnId_rata = id_rata
|
|
lcSql = [begin pack_crm.cauta_rata(?gcS, ?pnId_rata, ?@pnGasit); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.cauta_rata'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
|
|
pnId_ctr = id_ctr
|
|
pnNr_rata = nr_rata
|
|
pcDen_rata = den_rata
|
|
pdData_rata = data_rata
|
|
pnValrata = valrata
|
|
pnValfact = valfact
|
|
pnId_valuta = id_valuta
|
|
pnId_act = id_act
|
|
*pnCurs = Curs
|
|
|
|
If pnGasit = 0
|
|
lcSql = [begin pack_crm.adauga_rata(?gcS, ?pnId_ctr, ?pnNr_rata, ?pcDen_rata, ?pdData_rata, ?pnValRata, ?pnValfact, ?pnId_valuta, ?pnId_act); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.adauga_rata'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
Else
|
|
If llsters && sterge_rata
|
|
lcSql = [begin pack_crm.sterge_rata(?gcS, ?pnId_rata); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.sterge_rata'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
Else
|
|
lcSql = [begin pack_crm.modifica_rata(?gcS, ?pnId_rata, ?pnNr_rata, ?pcDen_rata, ?pdData_rata, ?pnValrata, ?pnValfact, ?pnId_act, ?pnId_valuta); end;]
|
|
lnSucces = goExecutor.oExecute(lcSql)
|
|
|
|
If lnSucces < 0
|
|
Messagebox('pack_crm.modifica_rata'+goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
Endif && llsters
|
|
Endif && pnGasit = 0
|
|
|
|
Select cScadentar
|
|
Endscan
|
|
|
|
Set Deleted &lcDeleted
|
|
|
|
If Used("cScadentar")
|
|
Use In cScadentar
|
|
Endif
|
|
|
|
|
|
Endproc && update_rate
|
|
***--------------------------------------------------------------------------------------
|
|
***-------------------------------------------------------------------------------------------
|
|
Procedure viz_rate2
|
|
Parameters tnId_part, tnId_ctr
|
|
|
|
*** calculeaza procentele
|
|
lcSel = [{call pack_crm.make_tazi(?tnId_part, ?tnId_ctr)}]
|
|
lcCursor = 'tAzi'
|
|
lnSucces = goExecutor.oExecute(lcSel,lcCursor)
|
|
If lnSucces < 0
|
|
amessage('Call pack_crm.make_tazi' + Chr(13) + goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
|
|
Select tazi
|
|
Go Top
|
|
|
|
lor2 = Createobject("frm_rate2")
|
|
* lor2.titlu_alb1.Caption = Alltrim(lcnume)+" contract "+Alltrim(Str(lnnrcontr))
|
|
lor2.Show(1)
|
|
|
|
If Used("tAzi")
|
|
Use In tazi
|
|
Endif
|
|
|
|
Endproc && viz_rate2
|
|
***-------------------------------------------------------------------------------------------
|
|
*****************************************************************************
|
|
Function cauta_politica_preturi
|
|
Lparameters tnIdPol,tcNumePolitica,tnIdValuta,tcNumeValuta
|
|
Local locauta,llReturn
|
|
Store "" To locauta
|
|
Store .F. To llReturn
|
|
pcselect = ["select id_pol, nume_lista_preturi, datai, datas, id_valuta, nume_val from ] + gcS + [.vcrm_politici_preturi"]
|
|
pcfiltru = [1=2]
|
|
pcschema = ['']
|
|
pcorder = [2]
|
|
pccoloane = [nume_lista_preturi, datai, datas, nume_val]
|
|
pcTitlu = [Politici de preturi actuale]
|
|
pcTitluColoane = [Nume lista preturi,Data inceput,Data sfarsit,Valuta]
|
|
locauta = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,"")
|
|
If !Empty(locauta.id_pol)
|
|
tnIdPol=locauta.id_pol
|
|
tcNumePolitica=Alltrim(locauta.nume_lista_preturi)
|
|
tnIdValuta=locauta.id_valuta
|
|
tcNumeValuta=Alltrim(locauta.nume_val)
|
|
llReturn=.T.
|
|
Endif
|
|
Return llReturn
|
|
Endfunc && cauta_politica_preturi
|
|
*****************************************************************************
|
|
*****************************************************************************
|
|
Procedure update_articole_politica_pret
|
|
Lparameters tnIdPol
|
|
If Used('crsarticole')
|
|
Use In crsarticole
|
|
Endif
|
|
lcSql=[select id_articol, id_pol_art, nume_articol, um, pret, nume_val, id_valuta, 0 as ales from ] + gcS + [.vcrm_politici_pret_art ]+;
|
|
[where id_pol=]+Alltrim(Str(tnIdPol))+[ order by 2]
|
|
lnSucces=goExecutor.oExecute(lcSql,'crsarticole')
|
|
If lnSucces < 0
|
|
Messagebox(goExecutor.cEroare,0+16,'Eroare')
|
|
Endif
|
|
goExecutor.oReset()
|
|
Return lnSucces
|
|
|
|
Endproc && update_articole_politica_pret
|
|
*****************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
|