Patch level : 10.0 256

Files correlati     :  ve0.exe ve1.exe ve5.exe ve6.exe profili documento delle vendite e delle lavanderie
Ricompilazione Demo : [ ]
Commento            :

Gestione del secondo agente nei documenti


git-svn-id: svn://10.65.10.50/trunk@18476 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2009-03-10 14:31:20 +00:00
parent a32a73a8f3
commit bd981811e2
24 changed files with 339 additions and 214 deletions

@ -179,12 +179,13 @@ Col(11)=FR_SCONTO
Col(12)=FR_PERCPROV
Col(13)=FR_IMPFISUN
Col(14)=FR_IMPFISSO
Col(15)=FR_CODIVA
Col(16)=FR_ADDIVA
Col(17)=FR_CAUS
Col(18)=FR_CODMAGC
Col(19)=FR_CODDEPC
Col(20)=FR_TIPORIGA
Col(15)=FR_PERCPROV1
Col(16)=FR_CODIVA
Col(17)=FR_ADDIVA
Col(18)=FR_CAUS
Col(19)=FR_CODMAGC
Col(20)=FR_CODDEPC
Col(21)=FR_TIPORIGA
[RIGHE]

@ -104,10 +104,10 @@ STATOSP = S_DISABILITATO //900
DESSTATOSP = S_DISABILITATO //900
DATADOCRIF = S_NORMALE //1000
NUMDOCRIF = S_NOCHECK //1000
CODAGVIS = S_NASCOSTO //1110
DESAGVIS = S_NASCOSTO //1110
CODAG = S_NORMALE //1100
DESAG = S_NORMALE //1100
CODAGVIS = S_NORMALE //1100
DESAGVIS = S_NORMALE //1100
CODZON = S_NORMALE //1100
DESZON = S_NORMALE //1100
CODSPMEZZO = S_OBBLIGATORIO //1200
@ -179,15 +179,16 @@ Col(11)=FR_SCONTO
Col(12)=FR_PERCPROV
Col(13)=FR_IMPFISUN
Col(14)=FR_IMPFISSO
Col(15)=FR_CODIVA
Col(16)=FR_ADDIVA
Col(17)=FR_NCOLLI
Col(18)=FR_PNETTO
Col(19)=FR_TARA
Col(20)=FR_CAUS
Col(21)=FR_CODMAGC
Col(22)=FR_CODDEPC
Col(23)=FR_TIPORIGA
Col(15)=FR_PERCPROV1
Col(16)=FR_CODIVA
Col(17)=FR_ADDIVA
Col(18)=FR_NCOLLI
Col(19)=FR_PNETTO
Col(20)=FR_TARA
Col(21)=FR_CAUS
Col(22)=FR_CODMAGC
Col(23)=FR_CODDEPC
Col(24)=FR_TIPORIGA
[RIGHE]

@ -91,6 +91,8 @@ DESCAMP = S_DISABILITATO //820
SCONTOPERC = S_NORMALE //830
DATADOCRIF = S_NORMALE //1000
NUMDOCRIF = S_NOCHECK //1000
CODAGVIS = S_NORMALE //1110
DESAGVIS = S_NORMALE //1110
CODAG = S_NORMALE //1100
DESAG = S_NORMALE //1100
CODZON = S_NORMALE //1100
@ -139,12 +141,13 @@ Col(11) = FR_SCONTO
Col(12) = FR_PERCPROV
Col(13) = FR_IMPFISUN
Col(14) = FR_IMPFISSO
Col(15) = FR_CODIVA
Col(16) = FR_ADDIVA
Col(17) = FR_CAUS
Col(18) = FR_CODMAGC
Col(19) = FR_CODDEPC
Col(20)=FR_TIPORIGA
Col(15) = FR_PERCPROV1
Col(16) = FR_CODIVA
Col(17) = FR_ADDIVA
Col(18) = FR_CAUS
Col(19) = FR_CODMAGC
Col(20) = FR_CODDEPC
Col(21) = FR_TIPORIGA
[RIGHE]

@ -104,8 +104,8 @@ STATOSP = S_DISABILITATO //900
DESSTATOSP = S_DISABILITATO //900
DATADOCRIF = S_NORMALE //1000
NUMDOCRIF = S_NOCHECK //1000
CODAGVIS = S_NASCOSTO //1110
DESAGVIS = S_NASCOSTO //1110
CODAGVIS = S_NORMALE //1110
DESAGVIS = S_NORMALE //1110
CODAG = S_NORMALE //1100
DESAG = S_NORMALE //1100
CODZON = S_NORMALE //1100
@ -179,15 +179,16 @@ Col(12) = FR_SCONTO
Col(13) = FR_PERCPROV
Col(14) = FR_IMPFISUN
Col(15) = FR_IMPFISSO
Col(16) = FR_CODIVA
Col(17) = FR_ADDIVA
Col(18) = FR_NCOLLI
Col(19) = FR_PNETTO
Col(20) = FR_TARA
Col(21) = FR_CAUS
Col(22) = FR_CODMAGC
Col(23) = FR_CODDEPC
Col(24)=FR_TIPORIGA
Col(16) = FR_PERCPROV1
Col(17) = FR_CODIVA
Col(18) = FR_ADDIVA
Col(19) = FR_NCOLLI
Col(20) = FR_PNETTO
Col(21) = FR_TARA
Col(22) = FR_CAUS
Col(23) = FR_CODMAGC
Col(24) = FR_CODDEPC
Col(25) = FR_TIPORIGA
[RIGHE]

@ -100,6 +100,8 @@ STATOSP = S_DISABILITATO //900
DESSTATOSP = S_DISABILITATO //900
DATADOCRIF = S_NORMALE //1000
NUMDOCRIF = S_NOCHECK //1000
CODAGVIS = S_NORMALE //1110
DESAGVIS = S_NORMALE //1110
CODAG = S_NORMALE //1100
DESAG = S_NORMALE //1100
CODZON = S_NORMALE //1100
@ -156,12 +158,13 @@ Col(11)=FR_SCONTO
Col(12)=FR_PERCPROV
Col(13)=FR_IMPFISUN
Col(14)=FR_IMPFISSO
Col(15)=FR_CODIVA
Col(16)=FR_ADDIVA
Col(17)=FR_CAUS
Col(18)=FR_CODMAGC
Col(19)=FR_CODDEPC
Col(20)=FR_TIPORIGA
Col(15)=FR_PERCPROV1
Col(16)=FR_CODIVA
Col(17)=FR_ADDIVA
Col(18)=FR_CAUS
Col(19)=FR_CODMAGC
Col(20)=FR_CODDEPC
Col(21)=FR_TIPORIGA
[RIGHE]

@ -106,8 +106,8 @@ STATOSP = S_DISABILITATO //900
DESSTATOSP = S_DISABILITATO //900
DATADOCRIF = S_NASCOSTO //1000
NUMDOCRIF = S_NASCOSTO //1000
CODAGVIS = S_NASCOSTO //1110
DESAGVIS = S_NASCOSTO //1110
CODAGVIS = S_NORMALE //1110
DESAGVIS = S_NORMALE //1110
CODAG = S_NORMALE //1100
DESAG = S_NORMALE //1100
CODZON = S_NORMALE //1100
@ -180,12 +180,13 @@ Col(11) = FR_SCONTO
Col(12) = FR_PERCPROV
Col(13) = FR_IMPFISUN
Col(14) = FR_IMPFISSO
Col(15) = FR_CODIVA
Col(16) = FR_ADDIVA
Col(17) = FR_CAUS
Col(18) = FR_CODMAGC
Col(19) = FR_CODDEPC
Col(20) = FR_TIPORIGA
Col(15) = FR_PERCPROV1
Col(16) = FR_CODIVA
Col(17) = FR_ADDIVA
Col(18) = FR_CAUS
Col(19) = FR_CODMAGC
Col(20) = FR_CODDEPC
Col(21) = FR_TIPORIGA
[RIGHE]

@ -111,6 +111,8 @@ STATOSP = S_DISABILITATO //900
DESSTATOSP = S_DISABILITATO //900
DATADOCRIF = S_NORMALE //1000
NUMDOCRIF = S_NOCHECK //1000
CODAGVIS = S_NORMALE //1110
DESAGVIS = S_NORMALE //1110
CODAG = S_NORMALE //1100
DESAG = S_NORMALE //1100
CODZON = S_NORMALE //1100
@ -177,12 +179,13 @@ Col(15) = FR_SCONTO
Col(16) = FR_PERCPROV
Col(17) = FR_IMPFISUN
Col(18) = FR_IMPFISSO
Col(19) = FR_CODIVA
Col(20) = FR_ADDIVA
Col(21) = FR_CAUS
Col(22) = FR_CODMAGC
Col(23) = FR_CODDEPC
Col(24) = FR_TIPORIGA
Col(19) = FR_PERCPROV1
Col(20) = FR_CODIVA
Col(21) = FR_ADDIVA
Col(22) = FR_CAUS
Col(23) = FR_CODMAGC
Col(24) = FR_CODDEPC
Col(25) = FR_TIPORIGA
[RIGHE]

@ -110,8 +110,8 @@ STATOSP = S_DISABILITATO //900
DESSTATOSP = S_DISABILITATO //900
DATADOCRIF = S_NASCOSTO //1000
NUMDOCRIF = S_NASCOSTO //1000
CODAGVIS = S_NASCOSTO //1110
DESAGVIS = S_NASCOSTO //1110
CODAGVIS = S_NORMALE //1110
DESAGVIS = S_NORMALE //1110
CODAG = S_NORMALE //1100
DESAG = S_NORMALE //1100
CODSPMEZZO = S_OBBLIGATORIO //1200
@ -180,12 +180,13 @@ Col(14) = FR_SCONTO
Col(15) = FR_PERCPROV
Col(16) = FR_IMPFISUN
Col(17) = FR_IMPFISSO
Col(18) = FR_CODIVA
Col(19) = FR_ADDIVA
Col(20) = FR_CAUS
Col(21) = FR_CODMAGC
Col(22) = FR_CODDEPC
Col(23) = FR_TIPORIGA
Col(18) = FR_PERCPROV1
Col(19) = FR_CODIVA
Col(20) = FR_ADDIVA
Col(21) = FR_CAUS
Col(22) = FR_CODMAGC
Col(23) = FR_CODDEPC
Col(24) = FR_TIPORIGA
[DEFAULT]

@ -1,5 +1,6 @@
#include <config.h>
#include <tabutil.h>
#include <utility.h>
#include "sconti.h"
@ -90,6 +91,14 @@ void TCond_vendita::set_provv(const real & provv)
_riga->set(FR_PERCPROV, _provv);
}
void TCond_vendita::set_provv1(const real & provv)
{
_provv1 = provv;
if (_load_mask && _riga && _riga->id2pos(FR_PERCPROV1) >= 0 && _riga->field(FR_PERCPROV1).active())
_riga->set(FR_PERCPROV1, _provv1);
}
void TCond_vendita::set_iva(const TString & codiva)
{
@ -238,7 +247,7 @@ bool TCond_vendita::cerca( int tiporicerca )
return FALSE;
}
real TCond_vendita::get_percprovv(char tipoprovv, const TString & codpr, TLocalisamfile & age) const
real TCond_vendita::get_percprovv(char tipoprovv, const TString & codpr, bool first, const TRectype & age) const
{
real val = ZERO;
@ -251,7 +260,7 @@ real TCond_vendita::get_percprovv(char tipoprovv, const TString & codpr, TLocali
val = _anamag.get_real(ANAMAG_PERCPROVV);
break;
case 'C':
val = clifo().vendite().get_real(CFV_PERCPROVV);
val = clifo().vendite().get_real(first ? CFV_PERCPROVV : CFV_PERCPROVV1);
break;
case 'V':
{
@ -542,59 +551,87 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only)
break;
}
TString16 codric;
if (_riga && _riga->id2pos(FR_PERCPROV) >= 0 && _riga->field(FR_PERCPROV).active())
{
const TString16 codage(_testa->get(F_CODAG));
const TString & codage = _testa->get(F_CODAG);
if (codage.not_empty())
if (codage.full())
{
TLocalisamfile age(LF_AGENTI);
const TRectype & age = cache().get(LF_AGENTI, codage);
age.put(AGE_CODAGE, codage);
if (age.read() == NOERR)
if (!age.empty())
{
TString16 seqric(age.get(AGE_SEQRIC));
TString16 fcodpr;
TString16 codpr;
real percprovv = ZERO;
real percprovv;
if (seqric[0] == '-')
seqric = config_ditta.get( "AGETIPOPERC", "ve" );
int len = seqric.len();
int i;
_load_mask |= load_scagl_only && cv_scagl;
_load_mask |= load_scagl_only && cv_um;
int i;
for (i = 0; percprovv == ZERO && i < len && seqric[i] != '-'; i++)
{
for (i = 0; percprovv.is_zero() && seqric[i] != '\0' && seqric[i] != '-'; i++)
{
if (isdigit(seqric[i]))
{
fcodpr.format("CODRICPR%d", i+1);
codpr = age.get(fcodpr);
}
else
codpr.cut(0);
percprovv = get_percprovv(seqric[i], codpr, age);
}
real percalt = ZERO;
const TString codric = age.get(format("CODRICPR%d", i+1));
percprovv = get_percprovv(seqric[i], codric, true, age);
}
real percalt;
seqric = age.get(AGE_SEQALT);
for (i = 0; percalt == ZERO && i < len && seqric[i] != '-'; i++)
{
for (i = 0; percalt.is_zero() && seqric[i] != '\0' && seqric[i] != '-'; i++)
{
if (isdigit(seqric[i]))
{
fcodpr.format("CODALTPR%d", i+1);
codpr = age.get(fcodpr);
}
else
codpr.cut(0);
percalt = get_percprovv(seqric[i], codpr, age);
}
const TString & codric = age.get(format("CODALTPR%d", i+1));
percalt = get_percprovv(seqric[i], codric, true, age);
}
percprovv += percalt;
set_provv(percprovv);
}
}
}
if (_riga && _riga->id2pos(FR_PERCPROV1) >= 0 && _riga->field(FR_PERCPROV1).active())
{
const TString & codage = _testa->get(F_CODAGVIS);
if (codage.full())
{
const TRectype & age = cache().get(LF_AGENTI, codage);
if (!age.empty())
{
TString16 seqric(age.get(AGE_SEQRIC));
real percprovv;
if (seqric[0] == '-')
seqric = config_ditta.get( "AGETIPOPERC", "ve" );
int len = seqric.len();
int i;
_load_mask |= load_scagl_only && cv_scagl;
_load_mask |= load_scagl_only && cv_um;
for (i = 0; percprovv.is_zero() && seqric[i] != '\0' && seqric[i] != '-'; i++)
{
if (isdigit(seqric[i]))
const TString & codric = age.get(format("CODRICPR%d", i+1));
percprovv = get_percprovv(seqric[i], codric, false, age);
}
real percalt;
seqric = age.get(AGE_SEQALT);
for (i = 0; percalt.is_zero() && seqric[i] != '\0' && seqric[i] != '-'; i++)
{
if (isdigit(seqric[i]))
const TString & codric = age.get(format("CODALTPR%d", i+1));
percalt = get_percprovv(seqric[i], codric, false, age);
}
percprovv += percalt;
set_provv1(percprovv);
}
}
}
if (found_condv && _testa->is_running())
update_omaggi(load_scagl_only);
}

@ -19,6 +19,7 @@ class TCond_vendita : public TObject
TString16 _codiva;
real _prezzo;
real _provv;
real _provv1;
real _molt_sconto;
TDocumento_mask* _testa;
@ -39,6 +40,7 @@ class TCond_vendita : public TObject
protected:
void set_prezzo(const real & prezzo, const char * val_rif = "");
void set_provv(const real & provv);
void set_provv1(const real & provv);
void set_iva(const TString & codiva);
void update_omaggi(bool full);
@ -52,7 +54,7 @@ public:
real sconto_val() const { return _molt_sconto;}
real get_prezzo() const { return _prezzo; }
real get_provv() const { return _provv; }
real get_percprovv(char tipoprovv, const TString & codpr, TLocalisamfile & age) const;
real get_percprovv(char tipoprovv, const TString & codpr, bool first, const TRectype & age) const;
const TString & get_iva() const { return _codiva; }
// void set_clifo( TCli_for * clifo) { _clifo = clifo; }

@ -760,6 +760,8 @@ void TMotore_application::ini2mask(TConfig& ini, TMask& msk, bool query)
msk.set(F_CODINDSP, ven_rec.get(CFV_CODINDSP), true);
if (!ini.exist(DOC_CODAG))
msk.set(F_CODAG, ven_rec.get(CFV_CODAG));
if (!ini.exist(DOC_CODAGVIS))
msk.set(F_CODAG, ven_rec.get(CFV_CODAG1));
if (!ini.exist(DOC_CODSPMEZZO))
msk.set(F_CODSPMEZZO, ven_rec.get(CFV_CODSPMEZZO), true);
if (!ini.exist(DOC_CODPORTO))

@ -1016,10 +1016,40 @@ DISPLAY="Descrizione@50" RAGSOC~"Codice" CODAGE
OUTPUT=F_CODAG CODAGE~F_DESAG RAGSOC
SPECIAL=ADD RU pr0 -4
[CODZON]
[CODAGVIS]
GROUP=1100
X=2
Y=1
FIELDNAME=CODAGVIS
MSKID=F_CODAGVIS
TYPE=T_STRINGA
PROMPT="2o Agente "
SIZE=5
FLAG=UZ
USE=LF_AGENTI
INPUT=CODAGE F_CODAGVIS
DISPLAY="Codice" CODAGE~"Ragione Sociale@50" RAGSOC
OUTPUT=F_CODAGVIS CODAGE~F_DESAGVIS RAGSOC
SPECIAL=CH NORMAL~ADD RU pr0 -4
[DESAGVIS]
GROUP=1100
X=24
Y=1
MSKID=F_DESAGVIS
TYPE=T_STRINGA
PROMPT=""
SIZE=50
USE=LF_AGENTI KEY 2
INPUT=RAGSOC F_DESAGVIS
DISPLAY="Ragione Sociale@50" RAGSOC~"Codice" CODAGE
OUTPUT=F_CODAGVIS CODAGE~F_DESAGVIS RAGSOC
SPECIAL=ADD RU pr0 -4
[CODZON]
GROUP=1100
X=2
Y=2
FIELDNAME=ZONA
MSKID=F_CODZON
TYPE=T_STRINGA
@ -1035,7 +1065,7 @@ SPECIAL=CH NORMAL
[DESZON]
GROUP=1100
X=24
Y=1
Y=2
MSKID=F_DESZON
TYPE=T_STRINGA
PROMPT=""
@ -1045,36 +1075,6 @@ INPUT=S0 F_DESZON
DISPLAY="Descrizione@50" S0~"Codice" CODTAB
OUTPUT=F_CODZON CODTAB~F_DESZON S0
[CODAGVIS]
GROUP=1110
X=2
Y=0
FIELDNAME=CODAGVIS
MSKID=F_CODAGVIS
TYPE=T_STRINGA
PROMPT="Agente da vis. "
SIZE=5
FLAG=UZ
USE=LF_AGENTI
INPUT=CODAGE F_CODAGVIS
DISPLAY="Codice" CODAGE~"Descrizione@50" RAGSOC
OUTPUT=F_CODAGVIS CODAGE~F_DESAGVIS RAGSOC
SPECIAL=CH NORMAL~ADD RU pr0 -4
[DESAGVIS]
GROUP=1110
X=24
Y=0
MSKID=F_DESAGVIS
TYPE=T_STRINGA
PROMPT=""
SIZE=50
USE=LF_AGENTI KEY 2
INPUT=RAGSOC F_DESAGVIS
DISPLAY="Descrizione@50" RAGSOC~"Codice" CODAGE
OUTPUT=F_CODAGVIS CODAGE~F_DESAGVIS RAGSOC
SPECIAL=ADD RU pr0 -4
[CODSPMEZZO]
GROUP=1200
X=2

@ -63,3 +63,4 @@ JOLLY8|2|20|Jolly|20
JOLLY9|2|20|Jolly|20
JOLLY10|2|20|Jolly|20
RIDPREZZO|3|18|Riduzione prezzo|18
PERCPROV|3|502|2a Perc.\nProvv.|5

@ -217,6 +217,7 @@ class TTipo_documento : public TRectype // velib03
TString16 _basesconto;
TString16 _spese;
TString16 _totprovv;
TString16 _totprovv1;
TString16 _valore;
TString16 _totvalres;
TString16 _totvalore;
@ -283,6 +284,7 @@ public:
const TString & basesconto() const { return _basesconto;}
const TString & spese() const { return _spese;}
const TString & totprovv() const { return _totprovv;}
const TString & totprovv1() const { return _totprovv1;}
const TString & valore() const { return _valore;}
const TString & totvalres() const { return _totvalres;}
const TString & totvalore() const { return _totvalore;}
@ -390,6 +392,7 @@ class TTipo_riga_documento : public TRectype // velib02
TString16 _valres;
TString16 _field_provv;
TString16 _field_provv1;
TString16 _field_qta, _field_qtaevasa; // Veri campi Quantità e Quantità Evasa
TString16 _field_qta_mag, _field_qtaevasa_mag; // Veri campi Quantità e Quantità Evasa per magazzino
@ -428,8 +431,8 @@ public:
const TString& quantevasa() const { return _quantevasa;}
const TString& field_qta() const { return _field_qta;}
const TString& field_qtaevasa() const { return _field_qtaevasa;}
const TString& field_qta_mag() const { return _field_qta_mag;}
const TString& field_qtaevasa_mag() const { return _field_qtaevasa_mag;}
const TString& field_qta_mag() const { return _field_qta_mag;}
const TString& field_qtaevasa_mag() const { return _field_qtaevasa_mag;}
const int search_years() const { return _search_years;}
const TToken_string& search_nums() const { return _search_nums;}
@ -442,6 +445,7 @@ public:
bool select_clifo() const { return _select_clifo;}
const TString& provv() const { return _field_provv;}
const TString& provv1() const { return _field_provv1;}
const int incr_perc_prezzo() const { return _incrp;}
const int decr_perc_prezzo() const { return _decrp;}
TToken_string * genconf(int i) const { return (TToken_string *) _genconf.objptr(i);}
@ -552,7 +556,7 @@ public:
real imponibile_omaggio(int iva_calc_mode = 1) const;
real iva_omaggio(int ndec, int iva_calc_mode = 1) const;
real imposta(bool round = true) const;
real provvigione(int ndec = AUTO_DECIMALS) const;
real provvigione(bool first = true, int ndec = AUTO_DECIMALS) const;
real ritenuta(const char tipor = '\0', bool lordo = false, int ndec = AUTO_DECIMALS) const;
const TString& field_qta() const;
@ -640,8 +644,8 @@ class TDocumento : public TMultiple_rectype // velib03
TPagamento _pag;
TAssoc_array _tabella_iva; // tabella di imponibili ed imposte
TProvvigioni_agente* _provv_agente;
TString16 _old_agente; // Agente originale
TString8 _old_agente; // Agente originale
TString8 _old_agente1; // Secondo Agente originale
TRiga_documento * _sconto; // Riga per lo sconto di testata
TRiga_documento * _esenzione; // Riga per l' esenzione iva
@ -667,6 +671,9 @@ protected:
virtual void put_str(const char* fieldname, const char* val);
virtual const TString & get_str(const char* fieldname) const ;
int update_provvigione(bool remove, const bool first = true);
int update_provvigioni(bool remove);
virtual bool key_complete() { return numero() > 0; }
void set_riga_sconto();
int write_rewrite(TBaseisamfile & f, bool re) const;
@ -695,7 +702,7 @@ public:
TAssoc_array & tabella_iva(bool solo_imponibili = false) { update_tabella_iva(solo_imponibili); return _tabella_iva; }
TCli_for & clifor() const;
TOccasionale & occas() const;
const TAgente & agente() const;
const TAgente & agente(bool first = true) const;
const TString & riferimento(TString& rif) const { return tipo().riferimento(*this, rif); }
virtual TRecord_array& body(int logicnum = 0) const;
@ -729,8 +736,7 @@ public:
void flush_rows();
TProvvigioni_agente& calc_provvigioni(const bool generata = true);
int write_provvigioni();
void calc_provvigione(TProvvigioni_agente & provv, const TString & key, bool first = true, bool generata = true);
char tipo_numerazione() const { return get_char("PROVV"); }
int anno() const { return get_int("ANNO"); }
@ -788,7 +794,7 @@ public:
real basesconto() const;
real spese() const;
real ritenute(const char tipo = '\0', bool lordo = false, int ndec = AUTO_DECIMALS) const;
real provvigione(int ndec = AUTO_DECIMALS) const;
real provvigione(bool first = true, int ndec = AUTO_DECIMALS) const;
real valore(bool totale, bool lordo = false, int ndec = AUTO_DECIMALS) const;
TPagamento & pagamento();

@ -99,6 +99,7 @@ void TTipo_riga_documento::read_formule()
_formule.add(calcoli);
_field_provv = profile.get("PROVV");
_field_provv1 = profile.get("PROVV1");
_field_qta = profile.get("QTA"); // Non dare un default: ingannerebbe il tipo documento
_field_qtaevasa = profile.get("QTAEVASA"); // Non dare un default: ingannerebbe il tipo documento
_field_qta_mag = profile.get("QTA_MAG");
@ -659,13 +660,13 @@ real TRiga_documento::imposta(bool round) const
return iva(round ? doc().decimals() : 20);
}
real TRiga_documento::provvigione(int ndec) const
real TRiga_documento::provvigione(bool first, int ndec) const
{
real val;
if (ndec == AUTO_DECIMALS)
ndec = doc().decimals();
const TString & field = tipo().provv();
const TString & field = first ? tipo().provv() : tipo().provv1();
if (field.not_empty())
val = get_real(field);
else
@ -682,7 +683,7 @@ real TRiga_documento::provvigione(int ndec) const
val *= netto_testa;
}
val *= get_real(RDOC_PERCPROV) / CENTO;
val *= get_real(first ? RDOC_PERCPROV : RDOC_PERCPROV1) / CENTO;
}
val.round(ndec);
return val;
@ -1005,6 +1006,7 @@ void TRiga_documento::autosave(TSheet_field& f)
put( RDOC_CODAGG1, row.get( f.cid2index(FR_CODAGG1)) );
put( RDOC_CODAGG2, row.get( f.cid2index(FR_CODAGG2)) );
put( RDOC_RIDPREZZO, row.get( f.cid2index(FR_RIDPREZZO)) );
put( RDOC_PERCPROV1, row.get( f.cid2index(FR_PERCPROV1 )) );
for (short cdcid = FR_CDC1; cdcid <= FR_CDC12; cdcid++)
{
@ -1151,6 +1153,7 @@ void TRiga_documento::autoload(TSheet_field & f)
row.add( get( RDOC_CODAGG1) , f.cid2index(FR_CODAGG1));
row.add( get( RDOC_CODAGG2) , f.cid2index(FR_CODAGG2));
row.add( get( RDOC_RIDPREZZO) , f.cid2index(FR_RIDPREZZO));
row.add( get( RDOC_PERCPROV1 ), f.cid2index(FR_PERCPROV1 ));
const TMask& m = f.sheet_row_mask(num);

@ -233,7 +233,6 @@ void TDocumento::init()
_tipocf = new TRecfield(*this, DOC_TIPOCF);
_codcf = new TRecfield(*this, DOC_CODCF);
_cod_occas = new TRecfield(*this, DOC_OCFPI);
_provv_agente = new TProvvigioni_agente;
_sconto = _esenzione = NULL;
@ -282,7 +281,6 @@ TDocumento::~TDocumento()
delete _codcf;
delete _cod_occas;
if (_provv_agente != NULL) delete _provv_agente;
if (_sconto != NULL) delete _sconto;
if (_esenzione != NULL) delete _esenzione;
}
@ -793,10 +791,13 @@ int TDocumento::read(TBaseisamfile& f, word op, word lockop)
_docs_to_agg.remove(key);
}
if (err == NOERR && _has_provv)
_old_agente.cut(0);
_old_agente1.cut(0);
if (err == NOERR && _has_provv)
{
_old_agente = get(DOC_CODAG);
else
_old_agente.cut(0);
_old_agente1 = get(DOC_CODAGVIS);
}
return err;
}
@ -1274,24 +1275,7 @@ int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
}
}
if (_has_provv && tipo().provvigioni() && tipo().stato_provvigioni() <= stato())
{
const TString16 agente = get(DOC_CODAG);
if (agente != _old_agente)
{
if (_old_agente.not_empty())
{
const int anno = get_int(DOC_ANNO);
const TString16 codnum = get(DOC_CODNUM);
const long numdoc = get_long(DOC_NDOC);
TProvvigioni_agente provv;
if (provv.read(_old_agente, anno, codnum, numdoc) == NOERR)
provv.remove();
}
myself._old_agente = agente;
}
if (agente.not_empty())
myself.write_provvigioni();
}
myself.update_provvigioni(false);
if (tipo().statistiche() && _has_stat_ven)
{
TString80 key(get(DOC_PROVV)); key << get(DOC_ANNO); key << get(DOC_CODNUM); key << get(DOC_NDOC);
@ -1366,15 +1350,9 @@ int TDocumento::remove(TBaseisamfile& f) const
}
if (_has_provv && tipo().provvigioni())
{
const TString8 agente(get(DOC_CODAG));
const int anno = TDocumento::anno();
const TString4 codnum(numerazione());
const long ndoc = numero();
// Legge le provvigioni per questo documento
_provv_agente->read(agente, anno,codnum,ndoc);
// Le rimuove
_provv_agente->remove();
TDocumento& myself = *((TDocumento *)this);
myself.update_provvigioni(true);
}
}
return TMultiple_rectype::remove(f);
@ -1393,29 +1371,23 @@ void TDocumento::flush_rows()
remove_body(LF_RIGHEDOC);
}
TProvvigioni_agente& TDocumento::calc_provvigioni(const bool generata)
void TDocumento::calc_provvigione(TProvvigioni_agente & provv, const TString & key, bool first, bool generata)
{
CHECK (_provv_agente, "Bad TProvvigione_agente object");
TString16 agente(get(DOC_CODAG));
const int anno = TDocumento::anno();
TString16 codnum(numerazione());
const TString4 codnum = numerazione();
const long ndoc = numero();
TDate datadoc(data());
const TDate datadoc(data());
while (_provv_agente->read(agente, anno,codnum,ndoc) == _islocked) // Legge le provvigioni per questo documento
if (!yesno_box("Dati agente %s in uso da un altro utente. Riprovare?", (const char*) agente))
return *_provv_agente;
while (provv.read(key, anno, codnum, ndoc) == _islocked) // Legge le provvigioni per questo documento
if (!yesno_box("Dati agente %s in uso da un altro utente. Riprovare?", (const char *) key))
return ;
const TString16 codval(TDocumento::valuta());
const real change(cambio());
const real perc = _provv_agente->perc_fatt();
const real perc = provv.perc_fatt();
TCurrency_documento tot_doc(totale_doc(), *this);
TCurrency_documento tot_netto(totale_netto(), *this);
TCurrency_documento tot_provv(provvigione(), *this);
TCurrency_documento tot_provv(provvigione(first), *this);
TCurrency_documento provv_fat((tot_provv.get_num() / 100.0) * perc, *this); // Provvigione sul fatturato (rata 0)
// const int ndec = decimals();
// provv_fat.round(ndec);
TCurrency_documento provv_pag = tot_provv - provv_fat; // Provvigione sul pagato (da suddivere secondo il pagamento)
const bool valuta = in_valuta();
@ -1465,7 +1437,6 @@ TProvvigioni_agente& TDocumento::calc_provvigioni(const bool generata)
TCurrency zero(ZERO);
if (valuta)
{
//real val1 = totimponibili * change;
TCurrency_documento val2(pagtotimposte); val2.change_to_firm_val();
TCurrency_documento val3(pagtotspese); val3.change_to_firm_val();
TCurrency_documento val1(tot_doc); val1.change_to_firm_val(); val1 -= val2 - val3;
@ -1508,8 +1479,8 @@ TProvvigioni_agente& TDocumento::calc_provvigioni(const bool generata)
}
// Crea le nuove rate provvigionali
const bool isnew = _provv_agente->items() == 0; // Il documento non ha righe provvigionali
TRate_doc& rd = _provv_agente->rate(anno, codnum, ndoc, isnew ? TRUE : FALSE);
const bool isnew = provv.items() == 0; // Il documento non ha righe provvigionali
TRate_doc& rd = provv.rate(anno, codnum, ndoc, isnew ? TRUE : FALSE);
// A questo punto rd e' vuoto: settiamo i dati del documento:
TToken_string t;
@ -1543,8 +1514,7 @@ TProvvigioni_agente& TDocumento::calc_provvigioni(const bool generata)
TRata& rt = rd.row(0,TRUE);
rt.set_rata(0); rt.set_datascad(datadoc); rt.set_tipopag(1);
rt.set_imprata(anticipo.get_num()); rt.set_impprovv(provv_fat.get_num());
if (generata)
rt.set_generata();
rt.set_generata(generata);
}
// Setta le rate rimanenti
@ -1562,8 +1532,7 @@ TProvvigioni_agente& TDocumento::calc_provvigioni(const bool generata)
rt.set_tipopag(pag1.tipo_rata(index));
rt.set_imprata(pag1.importo_rata(index,valuta ? TRUE : FALSE));
rt.set_impprovv(pag2->importo_rata(i-1,valuta ? TRUE : FALSE));
if (generata)
rt.set_generata();
rt.set_generata(generata);
}
// Rimuove eventuali righe in eccesso
@ -1571,11 +1540,45 @@ TProvvigioni_agente& TDocumento::calc_provvigioni(const bool generata)
for (i = first_rata_ok ? nrate+1 : nrate; i < rd_items; i++)
rd.remove_rata(i);
delete pag2;
return *_provv_agente;
}
int TDocumento::write_provvigioni()
{ return calc_provvigioni().write(); }
int TDocumento::update_provvigione(bool remove, const bool first)
{
TProvvigioni_agente provv;
const TString8 old = first ? _old_agente : _old_agente1;
const TString8 agente = first ? get(DOC_CODAG) : get(DOC_CODAGVIS);
const int anno = TDocumento::anno();
const TString & codnum = numerazione();
const long ndoc = numero();
const TDate datadoc(data());
int err = NOERR;
if (remove || old != agente)
{
while (provv.read(old, anno, codnum, ndoc) == _islocked) // Legge le provvigioni per questo documento
if (!yesno_box("Dati agente %s in uso da un altro utente. Riprovare?", (const char *) old))
return err;
if (err != NOERR)
return err;
err = provv.remove();
if (remove)
return err;
}
if (agente.blank())
return NOERR;
calc_provvigione(provv, agente, first);
return provv.write();
}
int TDocumento::update_provvigioni(bool remove)
{
int err;
if ((err = update_provvigione(remove)) == NOERR)
err = update_provvigione(remove, false);
return err;
}
bool TDocumento::in_valuta() const
{
@ -2257,11 +2260,11 @@ TPagamento& TDocumento::pagamento()
return _pag;
}
real TDocumento::provvigione(int ndec) const
real TDocumento::provvigione(bool first, int ndec) const
{
TString16 field = agente().campoprovv();
TString16 field = agente(first).campoprovv();
if (field.empty())
field = tipo().totprovv();
field = first ? tipo().totprovv() : tipo().totprovv1();
real val;
if (field.not_empty())
@ -2271,7 +2274,7 @@ real TDocumento::provvigione(int ndec) const
if (ndec == AUTO_DECIMALS)
ndec = decimals();
for (int i = rows(); i > 0; i--)
val += ((TRiga_documento &) ((TDocumento *)this)->row(i)).provvigione(ndec);
val += ((TRiga_documento &) ((TDocumento *)this)->row(i)).provvigione(first, ndec);
}
return val;
}
@ -2367,11 +2370,11 @@ TOccasionale& TDocumento::occas() const
return (TOccasionale&)_occas;
}
const TAgente & TDocumento::agente() const
const TAgente & TDocumento::agente(bool first) const
{
if (_agenti == NULL)
_agenti = new TAgenti_cache;
return _agenti->agente(get(DOC_CODAG));
return _agenti->agente(first ? get(DOC_CODAG) : get(DOC_CODAGVIS));
}
TDocumento & TDocumento::copy(const TDocumento & d)

@ -348,6 +348,23 @@ void TTipo_documento::read_formule()
_formule.add(campo);
_formule.add(_totprovv);
_formule_documento.add(campo, new TFormula_documento(_documento, campo, "TOTPROVV()"), TRUE);
campo = prof.get("TOTPROVV1");
if (campo.empty())
campo = "TOTPROVV1";
const TRectype& frd1 = cache().get("%FRD", campo);
_totprovv1 = "_";
_totprovv1 << campo;
expr = frd1.get("S1");
if (expr.empty())
expr = "SOMMA(\"PROVV(-883,0)\")";
_formule_documento.add(_totprovv1, new TFormula_documento(_documento, _totprovv1, expr));
if (_formule.find(campo) < 0)
_formule.add(campo);
_formule.add(_totprovv1);
_formule_documento.add(campo, new TFormula_documento(_documento, campo, "TOTPROVV(-883,0)"));
}
_totale_cont = prof.get("TOTALECONT");
@ -461,7 +478,7 @@ int TExpr_documento::parse_user_func(const char * name, int nparms) const
if (strcmp(name, "IVA") == 0)
return nparms == 0 ? _iva : -1;
if (strcmp(name, "PROVV") == 0)
return nparms < 2 ? _provv : -1;
return nparms < 3 ? _provv : -1;
if (strcmp(name, "QUANT") == 0)
return nparms < 2 ? _quant : -1;
if (strcmp(name, "QUANTEVASA") == 0)
@ -689,7 +706,11 @@ void TExpr_documento::evaluate_user_func(int index, int nparms, TEval_stack & st
{
int ndec = AUTO_DECIMALS;
if (nparms > 0)
bool first = true;
if (nparms > 1)
first = !stack.peek_real().is_zero();
if (nparms > 0)
ndec = (int) stack.peek_real().integer();
else
stack.push(ZERO);
@ -697,7 +718,7 @@ void TExpr_documento::evaluate_user_func(int index, int nparms, TEval_stack & st
real & val = stack.peek_real();
if (_row)
val = _row->provvigione(ndec);
val = _row->provvigione(first, ndec);
else
val = ZERO;
}
@ -807,13 +828,17 @@ void TExpr_documento::evaluate_user_func(int index, int nparms, TEval_stack & st
{
int ndec = AUTO_DECIMALS;
bool first = true;
if (nparms > 1)
first = !stack.peek_real().is_zero();
if (nparms > 0)
ndec = (int) stack.peek_real().integer();
else
stack.push(ZERO);
real & val = stack.peek_real();
val = _doc->provvigione(ndec);
val = _doc->provvigione(first, ndec);
}
break;
case _pscontot:

@ -65,9 +65,9 @@ void TFatturazione_bolle::campi_raggruppamento(TToken_string& campi) const
// Uguali opzionalmente
const char* cond[] = { "CAMBIO", "SCONTO", "TIPODOC", "CODNUM",
"CODPAG", "CODABIA|CODCABA", "CODLIST", "CODAG",
"CODPAG", "CODABIA|CODCABA", "CODLIST", "CODAG|CODAGVIS",
"CODSPMEZZO", "CODPORTO", "CAUSTRASP", "CODVETT1|CODVETT2|CODVETT3",
"CODINDSP", "CODCMS",
"CODINDSP", "CODCMS",
NULL };
for (int u = 0; cond[u]; u++)

@ -785,6 +785,7 @@ void TDocumento_mask::cli2mask()
set(F_RAGGREFF, ven_rec.get(CFV_RAGGEFF));
set(F_CODINDSP, ven_rec.get(CFV_CODINDSP));
set(F_CODAG, ven_rec.get(CFV_CODAG));
set(F_CODAGVIS, ven_rec.get(CFV_CODAG1));
set(F_CODSPMEZZO, ven_rec.get(CFV_CODSPMEZZO));
set(F_CODPORTO, ven_rec.get(CFV_CODPORTO));
set(F_CODNOTESP1, ven_rec.get(CFV_CODNOTESP1));
@ -815,9 +816,9 @@ void TDocumento_mask::cli2mask()
f.check();
f.on_hit();
}
pos = id2pos(F_CODAG);
/* pos = id2pos(F_CODAG);
if (pos >= 0 && fld(pos).active())
fld(pos).set(ven_rec.get(CFV_CODAG));
fld(pos).set(ven_rec.get(CFV_CODAG)); */
set(F_CODZON, ven_rec.get(CFV_CODZONA), 0x3);
set(F_RAGGR, ven_rec.get(CFV_RAGGDOC));
sconto_testa2mask();
@ -865,6 +866,9 @@ void TDocumento_mask::cli2mask()
fld(pos).check();
check_field( F_CODCABP );
pos = id2pos(F_CODAG);
if (pos >= 0 && fld(pos).active())
fld(pos).check();
pos = id2pos(F_CODAGVIS);
if (pos >= 0 && fld(pos).active())
fld(pos).check();
@ -3315,7 +3319,7 @@ bool TDocumento_mask::codcont_handler( TMask_field& f, KEY key )
{
if (key == K_TAB && f.focusdirty())
{
TDocumento_mask& m = (TDocumento_mask&)f.mask();
TDocumento_mask& m = (TDocumento_mask&)f.mask();
TLocalisamfile & cont = ((TEdit_field &) f).browse()->cursor()->file();
const TDate datadoc(f.mask().get(F_DATADOC));
const TDate datascad(cont.get_date("VALFIN"));

@ -105,9 +105,10 @@
#define FR_JOLLY10 164
#define FR_RIDPREZZO 165
#define FR_PERCPROV1 166
// Ultimo campo fittizio
#define FR_END 166
#define FR_END 167
#define MAX_COLUMNS FR_END-FR_LORDO

@ -1230,7 +1230,7 @@ BEGIN
IFDEF(X_PERCPROV)
PROMPT X_PERCPROV Y_PERCPROV PR_PERCPROV
ELSEIF
PROMPT 42 13 "Perc.Provv. "
PROMPT 42 13 "Provvigione 1 "
ENDIF
IFDEF(FL_PERCPROV)
FLAGS FL_PERCPROV
@ -1245,6 +1245,27 @@ ENDIF
END
ENDIF
IFDEF(FLD_PERCPROV1)
NUMBER FR_PERCPROV1 5 2
BEGIN
IFDEF(X_PERCPROV1)
PROMPT X_PERCPROV1 Y_PERCPROV1 PR_PERCPROV1
ELSEIF
PROMPT 65 13 "2 "
ENDIF
IFDEF(FL_PERCPROV1)
FLAGS FL_PERCPROV1
ENDIF
IFDEF(MS_PERCPROV1)
MESSAGE MS_PERCPROV1
ENDIF
IFDEF(NC_PERCPROV1)
NUM_CALC NC_PERCPROV1
ENDIF
FIELD PERCPROV1
END
ENDIF
IFDEF(FLD_IMPFISUN)
BOOLEAN FR_IMPFISUN
BEGIN
@ -1515,6 +1536,7 @@ ENDIF
#ifdef USR_PAGE_1
#include USR_PAGE_1
#endif
#ifdef PAGE_2
ENDPAGE

@ -20,6 +20,7 @@ DEFINE_FIELD(NCOLLI)
DEFINE_FIELD(DAEVADERE)
DEFINE_FIELD(SCONTO)
DEFINE_FIELD(PERCPROV)
DEFINE_FIELD(PERCPROV1)
DEFINE_FIELD(IMPFISSO)
DEFINE_FIELD(IMPFISUN)
DEFINE_FIELD(CODIVA)

@ -28,7 +28,9 @@ F_POS(PREZZO, 42, 9,"Prezzo " )
DEFINE_FIELD(SCONTO)
F_POS(SCONTO, 2, 11,"Sconto " )
DEFINE_FIELD(PERCPROV)
F_POS(PERCPROV, 42, 11,"Provvigione" )
F_POS(PERCPROV, 42, 11,"Provvigione 1 " )
DEFINE_FIELD(PERCPROV1)
F_POS(PERCPROV1, 65, 11,"2 " )
DEFINE_FIELD(CODIVA)
DEFINE_FIELD(DESIVA)
DEFINE_FIELD(CAUS)

@ -27,7 +27,9 @@ F_POS(PREZZO, 42, 9,"Prezzo " )
DEFINE_FIELD(SCONTO)
F_POS(SCONTO, 2, 11,"Sconto " )
DEFINE_FIELD(PERCPROV)
F_POS(PERCPROV, 42, 11,"Provvigione" )
F_POS(PERCPROV, 42, 11,"Provvigione 1 " )
DEFINE_FIELD(PERCPROV1)
F_POS(PERCPROV1, 65, 11,"2 " )
DEFINE_FIELD(CODIVA)
DEFINE_FIELD(DESIVA)
DEFINE_FIELD(CAUS)