sync SVN r18107

This commit is contained in:
2026-09-15 23:13:08 +03:00
parent af31776357
commit a2d309da4b
20 changed files with 5767 additions and 7 deletions

View File

@@ -64,6 +64,17 @@
*!* prelucreaza_facturacrs + vpretctva/vdiscountctva in lista de insert (pretul si discountul
*!* unitar in valuta cu TVA inclus, care plecau 0 la Oracle la reemiterea documentelor in valuta)
*!* 14.09.2026
*!* agent
*!* + clasa cus_pret_nomenclator - politica de stoc pe pagina Vanzare din fisa articolului (plan #12b, S6b)
*!* + incarca_nota_politica/salveaza_nota_politica - nota implicita (cont debitor/creditor) a politicii
*!* de stoc, editabila din optiunile de facturare (plan #12b, S7b)
*!* 15.09.2026
*!* marius.mutu
*!* + verifica_cont_venit_linie - verificare prietenoasa a contului de venit rezolvat pentru o linie
*!* de factura, la adaugarea articolului
***************************************************************************************************************
**** Clase:
**** oDateFactura
@@ -76,6 +87,14 @@
**** scrieAtasamente
**** oDateGestiune
**** Reset
**** cus_pret_nomenclator
**** asigura_politica
**** incarca
**** valideaza
**** salveaza
**** recalculeaza_pret
**** incarca_nota_politica
**** salveaza_nota_politica
**** Functii:
**** actualizeaza_document
**** actualizeaza_partener_fact
@@ -819,6 +838,44 @@ Function deriva_cont_venit_fara_pol
Endfunc && deriva_cont_venit_fara_pol
*********************************************************************************************************
*********************************************************************************************************
* verificare prietenoasa D10 la adaugarea liniei; intoarce [] daca linia are cont de venit rezolvat, altfel mesajul de afisat
Function verifica_cont_venit_linie
Lparameters tnIdArticol, tnIdPol
Local lcSql, lnSucces, lcMesaj, lcIdPolStoc, lcIdPol, lcIdArt
lcMesaj = []
If Isnull(tnIdArticol) Or Isnull(tnIdPol)
Return lcMesaj
Endif
* fisa poate ajunge aici fara sa fi trecut prin optiunile facturarii - globalul nu exista inca
lcIdPolStoc = Iif(Type('gnId_pol_pret_stoc')='N',Alltrim(Str(gnId_pol_pret_stoc)),'0')
lcIdPol = Alltrim(Str(tnIdPol))
lcIdArt = Alltrim(Str(tnIdArticol))
* replica exacta a rezolvarii din pack_facturare.contabilizeaza_articol.cursor_articol: deducerea
* cont_venit_articol_stoc are prioritate doar pe politica de stoc si doar fara nota pe rand
lcSql = [select nom_articole.denumire, b.nume_lista_preturi, ] + ;
[nvl(case when a.id_pol = ] + lcIdPolStoc + [ and a.id_nota is null then pack_facturare.cont_venit_articol_stoc(] + lcIdArt + [) end, d.scc) as scc_rezolvat ] + ;
[from nom_articole ] + ;
[left join crm_politici_pret_art a on a.id_pol = ] + lcIdPol + [ and a.id_articol = nom_articole.id_articol ] + ;
[join crm_politici_preturi b on b.id_pol = ] + lcIdPol + [ ] + ;
[left join crm_note_vanzari c on c.id_nota = (case when ] + lcIdPol + [ = ] + lcIdPolStoc + [ then nvl(a.id_nota, b.id_nota) else b.id_nota end) ] + ;
[left join note_contabile d on d.id_set = c.id_set ] + ;
[where nom_articole.id_articol = ] + lcIdArt
If Used('crsverifcontvenit')
Use In crsverifcontvenit
Endif
lnSucces = goExecutor.oExecute(lcSql,[crsverifcontvenit])
If lnSucces >= 0 And Used('crsverifcontvenit') And Reccount('crsverifcontvenit') > 0 And Isnull(crsverifcontvenit.scc_rezolvat)
lcMesaj = [Articolul ] + Alltrim(Nvl(crsverifcontvenit.denumire,[])) + ;
[ nu are cont de venit configurat pe politica ] + Alltrim(Nvl(crsverifcontvenit.nume_lista_preturi,[])) + ;
[ - completati contul articolului sau nota contabila a politicii!]
Endif
If Used('crsverifcontvenit')
Use In crsverifcontvenit
Endif
Return lcMesaj
Endfunc && verifica_cont_venit_linie
*********************************************************************************************************
*********************************************************************************************************
*!* Function recalculeaza_pret_vanzare_lei_set
*!* Lparameters tcTabel,tnCurs
*!* Local llReturn
@@ -2304,3 +2361,249 @@ Function scrie_legatura_proforma
Endfunc && scrie_legatura_proforma
******************************* SFARSIT: scrie_legatura_proforma *****************************************
*********************************************************************************************************
*********************************************************************************************************
****************************************** INCEPUT: cus_pret_nomenclator ***************************************
Define Class cus_pret_nomenclator As Custom
nIdArticol = 0
nIdPolitica = 0
lIncarcat = .F.
lPreturiCuTva = .F.
nPretFtva = 0
nPretCtva = 0
nProcTvav = 1
nIdVenchelt = .NULL.
nIdNota = .NULL.
cScd = []
cScc = []
cContDedus = []
cEroare = []
* asigura politica de stoc (o creeaza daca lipseste); intoarce id politica, 0 la esec
Procedure asigura_politica
Local lcSql, lnSucces
Private pnIdUtil, pnIdPolitica
pnIdUtil = gnIdUtil
pnIdPolitica = 0
lcSql = [begin pack_preturi.asigura_politica_stoc(?pnIdUtil,?@pnIdPolitica); end;]
lnSucces = goExecutor.oExecute(lcSql)
If lnSucces < 0
AMESSAGEBOX(goExecutor.oPrelucrareEroare(),16,"Eroare")
This.nIdPolitica = 0
Else
This.nIdPolitica = Nvl(pnIdPolitica,0)
Endif
Release pnIdUtil, pnIdPolitica
Return This.nIdPolitica
Endproc && asigura_politica
* citeste randul politicii de stoc pentru articol, contul dedus si conturile notei asociate
Procedure incarca
Lparameters tnIdArticol
Local lcSql, lnSucces
This.nIdArticol = tnIdArticol
This.lIncarcat = .F.
This.nPretFtva = 0
This.nPretCtva = 0
This.nProcTvav = (GetProcTvaStandard()+100)/100
This.lPreturiCuTva = .F.
This.nIdVenchelt = .NULL.
This.nIdNota = .NULL.
This.cScd = []
This.cScc = []
This.cContDedus = []
If This.asigura_politica() <= 0
Return .F.
Endif
lcSql = [select nvl(preturi_cu_tva,0) as preturi_cu_tva from crm_politici_preturi where id_pol = ] + Alltrim(Str(This.nIdPolitica))
If Used('crspreturi')
Use In crspreturi
Endif
lnSucces = goExecutor.oExecute(lcSql,[crspreturi])
If lnSucces >= 0 And Reccount('crspreturi') > 0
This.lPreturiCuTva = (crspreturi.preturi_cu_tva = 1)
Endif
If Used('crspreturi')
Use In crspreturi
Endif
lcSql = [select pretftva, pretctva, proc_tvav, id_venchelt, id_nota from crm_politici_pret_art ] + ;
[where id_pol = ] + Alltrim(Str(This.nIdPolitica)) + [ and id_articol = ] + Alltrim(Str(tnIdArticol))
If Used('crspolart')
Use In crspolart
Endif
lnSucces = goExecutor.oExecute(lcSql,[crspolart])
If lnSucces < 0
AMESSAGEBOX(goExecutor.oPrelucrareEroare(),16,"Eroare")
Return .F.
Endif
If Reccount('crspolart') > 0
This.nPretFtva = Nvl(crspolart.pretftva,0)
This.nPretCtva = Nvl(crspolart.pretctva,0)
This.nProcTvav = crspolart.proc_tvav
If !Isnull(crspolart.id_venchelt)
This.nIdVenchelt = crspolart.id_venchelt
Endif
If !Isnull(crspolart.id_nota)
This.nIdNota = crspolart.id_nota
Endif
Endif
If Used('crspolart')
Use In crspolart
Endif
If !Isnull(This.nIdNota)
lcSql = [select n.scd, n.scc from crm_note_vanzari v, note_contabile n ] + ;
[where v.id_nota = ] + Alltrim(Str(This.nIdNota)) + [ and n.id_set = v.id_set]
If Used('crsnotapol')
Use In crsnotapol
Endif
lnSucces = goExecutor.oExecute(lcSql,[crsnotapol])
If lnSucces >= 0 And Reccount('crsnotapol') > 0
This.cScd = Alltrim(Nvl(crsnotapol.scd,[]))
This.cScc = Alltrim(Nvl(crsnotapol.scc,[]))
Endif
If Used('crsnotapol')
Use In crsnotapol
Endif
Endif
lcSql = [select pack_facturare.cont_venit_articol_stoc(] + Alltrim(Str(tnIdArticol)) + [) as cont_dedus from dual]
If Used('crscontded')
Use In crscontded
Endif
lnSucces = goExecutor.oExecute(lcSql,[crscontded])
If lnSucces >= 0 And Reccount('crscontded') > 0
This.cContDedus = Alltrim(Nvl(crscontded.cont_dedus,[]))
Endif
If Used('crscontded')
Use In crscontded
Endif
This.lIncarcat = .T.
Return .T.
Endproc && incarca
* valideaza conturile si pretul curente; mesaj + .F. la refuz
Procedure valideaza
This.cEroare = []
If (!Empty(This.cScd) And Empty(This.cScc)) Or (Empty(This.cScd) And !Empty(This.cScc))
This.cEroare = [Trebuie completate ambele conturi (debit si credit) sau niciunul.]
Else
If This.nPretFtva < 0 Or This.nPretCtva < 0
This.cEroare = [Pretul nu poate fi negativ.]
Endif
Endif
If !Empty(This.cEroare)
AMESSAGEBOX(This.cEroare,0+48,"Atentie")
Return .F.
Endif
Return .T.
Endproc && valideaza
* scrie pretul si, daca sunt conturi, nota de vanzare aferenta; fara tranzactie proprie
Procedure salveaza
Lparameters tnIdArticol
Local lcSql, lnSucces
Private pnIdArticol, pnPretFtva, pnPretCtva, pnProcTvav, pnIdVenchelt, pnIdNota, pnScrieNota
If !This.valideaza()
Return .F.
Endif
If !Empty(This.cScd) And !Empty(This.cScc)
Private pcScd, pcScc, pnIdUtil
pcScd = This.cScd
pcScc = This.cScc
pnIdUtil = gnIdUtil
pnIdNota = 0
lcSql = [begin pack_preturi.gaseste_sau_creeaza_nota_vanzare(?pcScd,?pcScc,?pnIdUtil,?@pnIdNota); end;]
lnSucces = goExecutor.oExecute(lcSql)
Release pcScd, pcScc, pnIdUtil
If lnSucces < 0
AMESSAGEBOX(goExecutor.oPrelucrareEroare(),16,"Eroare")
Release pnIdArticol, pnPretFtva, pnPretCtva, pnProcTvav, pnIdVenchelt, pnIdNota, pnScrieNota
Return .F.
Endif
This.nIdNota = Nvl(pnIdNota,0)
Else
This.nIdNota = .NULL.
Endif
pnIdArticol = tnIdArticol
pnPretFtva = This.nPretFtva
pnPretCtva = This.nPretCtva
pnProcTvav = This.nProcTvav
pnIdVenchelt = This.nIdVenchelt
pnIdNota = This.nIdNota
pnScrieNota = Iif(This.lIncarcat, 1, 0)
lcSql = [begin pack_preturi.salveaza_pret_nomenclator(?pnIdArticol,?pnPretFtva,?pnPretCtva,?pnProcTvav,?pnIdVenchelt,?pnIdNota,?pnScrieNota); end;]
lnSucces = goExecutor.oExecute(lcSql)
If lnSucces < 0
AMESSAGEBOX(goExecutor.oPrelucrareEroare(),16,"Eroare")
Endif
Release pnIdArticol, pnPretFtva, pnPretCtva, pnProcTvav, pnIdVenchelt, pnIdNota, pnScrieNota
Return (lnSucces >= 0)
Endproc && salveaza
* recalculeaza pretul opus (cu/fara TVA) dupa proc_tvav curent
Procedure recalculeaza_pret
Lparameters tnPret, tlSpreCuTva
Local lnProcTvav
lnProcTvav = Iif(Isnull(This.nProcTvav), (GetProcTvaStandard()+100)/100, This.nProcTvav)
If tlSpreCuTva
Return Round(tnPret * lnProcTvav, gnPc)
Endif
Return Round(tnPret / lnProcTvav, gnPc)
Endproc && recalculeaza_pret
* citeste scd/scc din nota curenta a politicii date (goala daca politica nu are nota)
Procedure incarca_nota_politica
Lparameters tnIdPol
Local lcSql, lnSucces
This.cScd = []
This.cScc = []
lcSql = [select n.scd, n.scc from crm_politici_preturi p, crm_note_vanzari v, note_contabile n ] + ;
[where p.id_pol = ] + Alltrim(Str(tnIdPol)) + [ and v.id_nota = p.id_nota and n.id_set = v.id_set]
If Used('crsnotapolstoc')
Use In crsnotapolstoc
Endif
lnSucces = goExecutor.oExecute(lcSql,[crsnotapolstoc])
If lnSucces >= 0 And Reccount('crsnotapolstoc') > 0
This.cScd = Alltrim(Nvl(crsnotapolstoc.scd,[]))
This.cScc = Alltrim(Nvl(crsnotapolstoc.scc,[]))
Endif
If Used('crsnotapolstoc')
Use In crsnotapolstoc
Endif
Return !Empty(This.cScd) And !Empty(This.cScc)
Endproc && incarca_nota_politica
* valideaza (ambele conturi sau niciunul) si scrie nota implicita a politicii date
Procedure salveaza_nota_politica
Lparameters tnIdPol, tcScd, tcScc
Local lcSql, lnSucces
If (!Empty(tcScd) And Empty(tcScc)) Or (Empty(tcScd) And !Empty(tcScc))
This.cEroare = [Trebuie completate ambele conturi (debit si credit) sau niciunul.]
AMESSAGEBOX(This.cEroare,0+48,"Atentie")
Return .F.
Endif
If Empty(tcScd) And Empty(tcScc)
Return .T.
Endif
Private pcScd, pcScc, pnIdUtil, pnIdNota, pnIdPol
pcScd = tcScd
pcScc = tcScc
pnIdUtil = gnIdUtil
pnIdNota = 0
lcSql = [begin pack_preturi.gaseste_sau_creeaza_nota_vanzare(?pcScd,?pcScc,?pnIdUtil,?@pnIdNota); end;]
lnSucces = goExecutor.oExecute(lcSql)
If lnSucces < 0
AMESSAGEBOX(goExecutor.oPrelucrareEroare(),16,"Eroare")
Release pcScd, pcScc, pnIdUtil, pnIdNota, pnIdPol
Return .F.
Endif
pnIdPol = tnIdPol
lcSql = [begin pack_preturi.seteaza_nota_politica_stoc(?pnIdPol,?pnIdNota); end;]
lnSucces = goExecutor.oExecute(lcSql)
If lnSucces < 0
AMESSAGEBOX(goExecutor.oPrelucrareEroare(),16,"Eroare")
Endif
Release pcScd, pcScc, pnIdUtil, pnIdNota, pnIdPol
Return (lnSucces >= 0)
Endproc && salveaza_nota_politica
Enddefine
****************************************** SFARSIT: cus_pret_nomenclator ****************************************
*********************************************************************************************************