Modifiche al 01/02/97 per Beta4
git-svn-id: svn://10.65.10.50/trunk@4113 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
1ea856efbb
commit
c6e62a9f9e
@ -19,3 +19,5 @@
|
||||
#define F_CONTOA 119
|
||||
#define F_SOTTOA 120
|
||||
#define F_DESCRCONTOA 121
|
||||
#define F_TIPORIGA 122
|
||||
#define F_DESCRRIGA 123
|
||||
|
@ -159,7 +159,7 @@ END
|
||||
STRING F_NCAMPOCAL1 50
|
||||
BEGIN
|
||||
PROMPT 17 13 ""
|
||||
USE %FRD
|
||||
USE %FRD KEY 2
|
||||
INPUT S0 F_NCAMPOCAL1
|
||||
DISPLAY "Descrizione@50" S0
|
||||
DISPLAY "Codice " CODTAB
|
||||
@ -295,4 +295,27 @@ BEGIN
|
||||
ADD RUN CG0 -0
|
||||
END
|
||||
|
||||
STRING F_TIPORIGA 4
|
||||
BEGIN
|
||||
PROMPT 2 19 "Tipo riga "
|
||||
FIELD S8
|
||||
FLAGS "U"
|
||||
USE %TRI SELECT S7=="S"
|
||||
INPUT CODTAB F_TIPORIGA
|
||||
DISPLAY "Codice" CODTAB
|
||||
DISPLAY "Descrizione@50" S0
|
||||
OUTPUT F_TIPORIGA CODTAB
|
||||
OUTPUT F_DESCRRIGA S0
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
STRING F_DESCRRIGA 50
|
||||
BEGIN
|
||||
PROMPT 17 20 ""
|
||||
USE %TRI KEY 2 SELECT S7=="S"
|
||||
INPUT S0 F_DESCRRIGA
|
||||
COPY DISPLAY F_TIPORIGA
|
||||
COPY OUTPUT F_TIPORIGA
|
||||
END
|
||||
|
||||
ENDMASK
|
||||
|
@ -6,3 +6,4 @@
|
||||
#define F_DESCAUS 106
|
||||
#define F_NCOPIE 107
|
||||
#define F_RIFERIMENTO 108
|
||||
#define F_SPESEAUT 109
|
||||
|
@ -98,6 +98,11 @@ BEGIN
|
||||
CHECKTYPE NORMAL
|
||||
END
|
||||
|
||||
BOOLEAN F_SPESEAUT
|
||||
BEGIN
|
||||
PROMPT 2 15 "Addebito automatico spese cliente"
|
||||
FIELD B0
|
||||
END
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
||||
|
369
ve/sconti.cpp
369
ve/sconti.cpp
@ -26,6 +26,9 @@
|
||||
#include <tabutil.h>
|
||||
#endif
|
||||
|
||||
#ifndef __VEINI_H
|
||||
#include "veini.h"
|
||||
#endif
|
||||
HIDDEN const real CENTO(100.0);
|
||||
|
||||
bool TCond_vendita::set_sconto( const char * exp, bool signal )
|
||||
@ -319,13 +322,10 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only)
|
||||
anamag().put("CODART", codriga);
|
||||
if (anamag().read() != NOERR)
|
||||
{
|
||||
// if (full_load)
|
||||
// {
|
||||
set_prezzo(ZERO);
|
||||
set_sconto("");
|
||||
set_iva("");
|
||||
set_provv(ZERO);
|
||||
// }
|
||||
set_prezzo(ZERO);
|
||||
set_sconto("");
|
||||
set_iva("");
|
||||
set_provv(ZERO);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -353,128 +353,116 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only)
|
||||
_load_mask = !load_um_only && !load_scagl_only;
|
||||
}
|
||||
else
|
||||
// if (full_load)
|
||||
set_prezzo(umart().get_real("PREZZO"));
|
||||
|
||||
|
||||
// if (full_load)
|
||||
// {
|
||||
if (_ivarid)
|
||||
set_iva(anamag().get("CODIVAR"));
|
||||
else
|
||||
set_iva(anamag().get("CODIVA"));
|
||||
// }
|
||||
if (_ivarid)
|
||||
set_iva(anamag().get("CODIVAR"));
|
||||
else
|
||||
set_iva(anamag().get("CODIVA"));
|
||||
|
||||
const char gestione = config_ditta().get_char( "GESSCORIGA", "ve" );
|
||||
const bool sco_scagl = config_ditta().get_bool("GESCOSCA", "ve");
|
||||
const bool sco_um_gest = config_ditta().get_bool("GESSCORIGAUM", "ve");
|
||||
|
||||
// if (!full_load && gestione != 'A' && !sco_scagl)
|
||||
// {
|
||||
// if (gestione == 'L' && found_condv)
|
||||
// set_sconto(_rcondv.get("SCONTO"));
|
||||
//}
|
||||
// else
|
||||
switch (gestione)
|
||||
{
|
||||
switch (gestione)
|
||||
{
|
||||
case 'N':
|
||||
// Sconti di riga non gestiti
|
||||
set_sconto("");
|
||||
break;
|
||||
case 'L':
|
||||
// Percentuale su contratti/offerte/listini/anagrafica
|
||||
if (found_condv)
|
||||
{
|
||||
_load_mask |= load_scagl_only && cv_scagl;
|
||||
_load_mask |= load_um_only && cv_um;
|
||||
set_sconto(_rcondv.get("SCONTO"));
|
||||
_load_mask = !load_um_only && !load_scagl_only;
|
||||
}
|
||||
else
|
||||
set_sconto(anamag().get("SCONTO"));
|
||||
break;
|
||||
case 'A':
|
||||
{
|
||||
// Posiziono l'anagrafica
|
||||
const char rigakey = config_ditta().get_char( "SCORIGAKEY", "ve" );
|
||||
case 'N':
|
||||
// Sconti di riga non gestiti
|
||||
set_sconto("");
|
||||
break;
|
||||
case 'L':
|
||||
// Percentuale su contratti/offerte/listini/anagrafica
|
||||
if (found_condv)
|
||||
{
|
||||
_load_mask |= load_scagl_only && cv_scagl;
|
||||
_load_mask |= load_um_only && cv_um;
|
||||
set_sconto(_rcondv.get("SCONTO"));
|
||||
_load_mask = !load_um_only && !load_scagl_only;
|
||||
}
|
||||
else
|
||||
set_sconto(anamag().get("SCONTO"));
|
||||
break;
|
||||
case 'A':
|
||||
{
|
||||
// Posiziono l'anagrafica
|
||||
const char rigakey = config_ditta().get_char( "SCORIGAKEY", "ve" );
|
||||
|
||||
_sconti.setkey(1);
|
||||
_sconti.put("TIPO", "R");
|
||||
if( config_ditta().get_bool("GESSCORIGACV", "ve"))
|
||||
_sconti.put("CODCAT", clifo().get(LF_CFVEN, "CATVEN"));
|
||||
if (sco_um_gest)
|
||||
_sconti.put("UM", riga().get( FR_UMQTA));
|
||||
_sconti.put("TIPORIGA", rigakey);
|
||||
_sconti.setkey(1);
|
||||
_sconti.put("TIPO", "R");
|
||||
if( config_ditta().get_bool("GESSCORIGACV", "ve"))
|
||||
_sconti.put("CODCAT", clifo().get(LF_CFVEN, "CATVEN"));
|
||||
if (sco_um_gest)
|
||||
_sconti.put("UM", riga().get( FR_UMQTA));
|
||||
_sconti.put("TIPORIGA", rigakey);
|
||||
|
||||
if (sco_scagl)
|
||||
_sconti.put("NSCAGL", 1);
|
||||
if (sco_scagl)
|
||||
_sconti.put("NSCAGL", 1);
|
||||
|
||||
switch (rigakey)
|
||||
{
|
||||
case 'A':
|
||||
_sconti.put("CODART", codriga);
|
||||
_sconti.read();
|
||||
break;
|
||||
case 'R':
|
||||
_sconti.put("CODART", anamag().get("RAGGFIS"));
|
||||
_sconti.read();
|
||||
break;
|
||||
case 'C':
|
||||
{
|
||||
_sconti.put( "CODART", anamag().get("GRMERC"));
|
||||
_sconti.read( );
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
{
|
||||
_sconti.put("CODART", anamag().get("GRMERC").left(3));
|
||||
_sconti.read();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error_box("Tipo di chiave righe sconti '%c' non valida!", rigakey);
|
||||
break;
|
||||
}
|
||||
|
||||
const bool found = _sconti.good();
|
||||
|
||||
if (found && sco_scagl)
|
||||
{
|
||||
TRectype rec(_sconti.curr());
|
||||
int last_scagl = 0;
|
||||
int scagl = _sconti.get_int("NSCAGL");
|
||||
const real qta(_riga->get_real(FR_QTA));
|
||||
real qta_lim(_sconti.get_real("QLIM"));
|
||||
|
||||
while (_sconti.good() && scagl > last_scagl && qta_lim > ZERO && qta > qta_lim)
|
||||
{
|
||||
if (_sconti.next() == NOERR)
|
||||
{
|
||||
last_scagl = scagl;
|
||||
scagl = _sconti.get_int("NSCAGL");
|
||||
qta_lim =_sconti.get_real("QLIM");
|
||||
rec = _sconti.curr();
|
||||
}
|
||||
switch (rigakey)
|
||||
{
|
||||
case 'A':
|
||||
_sconti.put("CODART", codriga);
|
||||
_sconti.read();
|
||||
break;
|
||||
case 'R':
|
||||
_sconti.put("CODART", anamag().get("RAGGFIS"));
|
||||
_sconti.read();
|
||||
break;
|
||||
case 'C':
|
||||
{
|
||||
_sconti.put( "CODART", anamag().get("GRMERC"));
|
||||
_sconti.read( );
|
||||
}
|
||||
_rcondv.read(rec);
|
||||
}
|
||||
if (!found)
|
||||
_sconti.zero();
|
||||
_load_mask |= load_scagl_only && sco_scagl;
|
||||
_load_mask |= load_scagl_only && sco_um_gest;
|
||||
set_sconto(_sconti.get("SCONTO"));
|
||||
_load_mask = !load_um_only && !load_scagl_only;
|
||||
}
|
||||
break;
|
||||
case 'C':
|
||||
set_sconto(clifo().get(LF_CFVEN, "SCONTO"));
|
||||
break;
|
||||
default:
|
||||
error_box("Tipo di gestione sconti '%c' non valido!", gestione );
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
{
|
||||
_sconti.put("CODART", anamag().get("GRMERC").left(3));
|
||||
_sconti.read();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error_box("Tipo di chiave righe sconti '%c' non valida!", rigakey);
|
||||
break;
|
||||
}
|
||||
|
||||
const bool found = _sconti.good();
|
||||
|
||||
if (found && sco_scagl)
|
||||
{
|
||||
TRectype rec(_sconti.curr());
|
||||
int last_scagl = 0;
|
||||
int scagl = _sconti.get_int("NSCAGL");
|
||||
const real qta(_riga->get_real(FR_QTA));
|
||||
real qta_lim(_sconti.get_real("QLIM"));
|
||||
|
||||
while (_sconti.good() && scagl > last_scagl && qta_lim > ZERO && qta > qta_lim)
|
||||
{
|
||||
if (_sconti.next() == NOERR)
|
||||
{
|
||||
last_scagl = scagl;
|
||||
scagl = _sconti.get_int("NSCAGL");
|
||||
qta_lim =_sconti.get_real("QLIM");
|
||||
rec = _sconti.curr();
|
||||
}
|
||||
}
|
||||
_rcondv.read(rec);
|
||||
}
|
||||
if (!found)
|
||||
_sconti.zero();
|
||||
_load_mask |= load_scagl_only && sco_scagl;
|
||||
_load_mask |= load_scagl_only && sco_um_gest;
|
||||
set_sconto(_sconti.get("SCONTO"));
|
||||
_load_mask = !load_um_only && !load_scagl_only;
|
||||
}
|
||||
break;
|
||||
case 'C':
|
||||
set_sconto(clifo().get(LF_CFVEN, "SCONTO"));
|
||||
break;
|
||||
default:
|
||||
error_box("Tipo di gestione sconti '%c' non valido!", gestione );
|
||||
break;
|
||||
}
|
||||
|
||||
if (_riga && _riga->id2pos(FR_PERCPROV) >= 0 && _riga->field(FR_PERCPROV).active())
|
||||
{
|
||||
@ -492,59 +480,122 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only)
|
||||
if (tipoprovv <= ' ')
|
||||
tipoprovv = config_ditta().get_char( "AGETIPOPERC", "ve" );
|
||||
|
||||
// if (!full_load)
|
||||
// {
|
||||
// if (tipoprovv == 'L' && found_condv)
|
||||
// set_provv(_rcondv.get_real("PERCPROVV"));
|
||||
// }
|
||||
// else
|
||||
switch (tipoprovv)
|
||||
{
|
||||
switch (tipoprovv)
|
||||
{
|
||||
case 'A':
|
||||
set_provv(age.get_real("R0"));
|
||||
break;
|
||||
case 'C':
|
||||
set_provv(real(clifo().get(LF_CFVEN, "PERCPROVV")));
|
||||
break;
|
||||
case 'L':
|
||||
if (found_condv)
|
||||
{
|
||||
_load_mask |= load_scagl_only && sco_scagl;
|
||||
_load_mask |= load_scagl_only && sco_um_gest;
|
||||
set_provv(_rcondv.get_real("PERCPROVV"));
|
||||
}
|
||||
else
|
||||
set_provv(anamag().get_real("PERCPROVV"));
|
||||
break;
|
||||
case 'V':
|
||||
{
|
||||
TString16 catven(testa().get(F_CATVEN));
|
||||
case 'A':
|
||||
set_provv(age.get_real("R0"));
|
||||
break;
|
||||
case 'C':
|
||||
set_provv(real(clifo().get(LF_CFVEN, "PERCPROVV")));
|
||||
break;
|
||||
case 'L':
|
||||
if (found_condv)
|
||||
{
|
||||
_load_mask |= load_scagl_only && sco_scagl;
|
||||
_load_mask |= load_scagl_only && sco_um_gest;
|
||||
set_provv(_rcondv.get_real("PERCPROVV"));
|
||||
}
|
||||
else
|
||||
set_provv(anamag().get_real("PERCPROVV"));
|
||||
break;
|
||||
case 'V':
|
||||
{
|
||||
TString16 catven(testa().get(F_CATVEN));
|
||||
|
||||
if (catven.empty())
|
||||
catven = clifo().get(LF_CFVEN, "CATVEN");
|
||||
if (catven.empty())
|
||||
catven = clifo().get(LF_CFVEN, "CATVEN");
|
||||
|
||||
if (catven.not_empty())
|
||||
{
|
||||
TTable cve("CVE");
|
||||
if (catven.not_empty())
|
||||
{
|
||||
TTable cve("CVE");
|
||||
|
||||
cve.put("CODART", codage);
|
||||
if (cve.read() == NOERR)
|
||||
set_provv(cve.get_real("R0"));
|
||||
}
|
||||
cve.put("CODART", codage);
|
||||
if (cve.read() == NOERR)
|
||||
set_provv(cve.get_real("R0"));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error_box("Tipo di gestione provvigioni '%c' non valido!", tipoprovv );
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
error_box("Tipo di gestione provvigioni '%c' non valido!", tipoprovv );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found_condv)
|
||||
update_omaggi(load_scagl_only);
|
||||
}
|
||||
|
||||
TCond_vendita::TCond_vendita(TCliFor * clifo, TConfig * ditta, TMask * testa, TMask * riga,
|
||||
void TCond_vendita::update_omaggi(bool full)
|
||||
{
|
||||
static TString16 tipo_riga("_");
|
||||
TSheet_field & sh = (TSheet_field &) testa().field(F_SHEET);
|
||||
const int current_doc_row = sh.selected() + 1;
|
||||
TDocumento & doc = testa().doc();
|
||||
bool update = FALSE;
|
||||
|
||||
if (doc[current_doc_row].tipo().tipo() == RIGA_OMAGGI)
|
||||
return;
|
||||
|
||||
if (current_doc_row < doc.rows())
|
||||
{
|
||||
TRiga_documento & r = doc[current_doc_row + 1];
|
||||
|
||||
if (r.tipo().tipo() == RIGA_OMAGGI && r.generata())
|
||||
{
|
||||
doc.destroy_row(current_doc_row + 1, TRUE);
|
||||
sh.destroy(current_doc_row, FALSE);
|
||||
update = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
real qta = _riga->get(FR_QTA);
|
||||
|
||||
if (full || qta != ZERO)
|
||||
{
|
||||
const TString80 codart_omaggio(_rcondv.get("CODARTOM"));
|
||||
|
||||
if (tipo_riga[0] == '_')
|
||||
{
|
||||
TConfig cnf(CONFIG_STUDIO, "ve");
|
||||
tipo_riga = cnf.get("TROMAGGI");
|
||||
}
|
||||
|
||||
if (codart_omaggio.not_empty() && tipo_riga.not_empty())
|
||||
{
|
||||
TRiga_documento & r = doc.insert_row(current_doc_row + 1, tipo_riga);
|
||||
r.set_generata();
|
||||
TString16 codmag(_riga->get(FR_CODMAG)); codmag << _riga->get(FR_CODDEP);
|
||||
r.put("CODMAG", codmag);
|
||||
r.put("CODART", codart_omaggio);
|
||||
anamag().setkey(1);
|
||||
anamag().put("CODART", codart_omaggio);
|
||||
if (anamag().read() == NOERR)
|
||||
r.put("DESCR", anamag().get("DESCR"));
|
||||
r.put("UMQTA", _rcondv.get("UMOM"));
|
||||
|
||||
qta /= _rcondv.get_real("QBASE");
|
||||
qta.floor();
|
||||
qta *= _rcondv.get_real("QOM");
|
||||
r.put("QTA", qta);
|
||||
r.put("PREZZO", _rcondv.get("PROMAGGIO"));
|
||||
const TString16 codiva_cli(_clifo->get(LF_CFVEN, "ASSFIS"));
|
||||
if (codiva_cli.not_empty())
|
||||
r.put("CODIVA", codiva_cli);
|
||||
else
|
||||
r.put("CODIVA", _rcondv.get("CODIVA"));
|
||||
r.put("ADDIVA", _rcondv.get("ADDIVA"));
|
||||
sh.insert(current_doc_row, FALSE);
|
||||
r.autoload(sh);
|
||||
sh.check_row(current_doc_row);
|
||||
update = TRUE;
|
||||
}
|
||||
}
|
||||
if (update)
|
||||
sh.force_update();
|
||||
}
|
||||
|
||||
TCond_vendita::TCond_vendita(TCliFor * clifo, TConfig * ditta, TDocumento_mask * testa, TMask * riga,
|
||||
TLocalisamfile * anamag, TLocalisamfile * umart)
|
||||
: _clifo(clifo), _testa(testa), _riga(riga),
|
||||
_condv( LF_CONDV ), _rcondv( LF_RCONDV ), _sconti( LF_SCONTI ),
|
||||
|
13
ve/sconti.h
13
ve/sconti.h
@ -9,8 +9,8 @@
|
||||
#include "tclifor.h"
|
||||
#endif
|
||||
|
||||
#ifndef __MASK_H
|
||||
#include <mask.h>
|
||||
#ifndef __VELIB01_H
|
||||
#include "velib01.h"
|
||||
#endif
|
||||
|
||||
#ifndef __CONFIG_H
|
||||
@ -32,7 +32,7 @@ class TCond_vendita : public TObject
|
||||
TLocalisamfile _sconti;
|
||||
TLocalisamfile * _umart;
|
||||
TConfig * _config_ditta;
|
||||
TMask * _testa;
|
||||
TDocumento_mask * _testa;
|
||||
TMask * _riga;
|
||||
bool _load_mask;
|
||||
|
||||
@ -42,9 +42,10 @@ protected:
|
||||
void set_prezzo(const real & prezzo,const char * val_rif = "");
|
||||
void set_provv(const real & provv);
|
||||
void set_iva(const TString & codiva);
|
||||
void update_omaggi(bool full);
|
||||
|
||||
TConfig & config_ditta() const { CHECK(_config_ditta, "Configurazione ditta non inizializzata"); return * _config_ditta; }
|
||||
TMask & testa() const { CHECK(_testa, "Maschera testata non inizializzata"); return * _testa; }
|
||||
TDocumento_mask & testa() const { CHECK(_testa, "Maschera testata non inizializzata"); return * _testa; }
|
||||
TMask & riga() const { CHECK(_testa, "Maschera testata non inizializzata"); return * _riga; }
|
||||
TLocalisamfile & anamag() const { CHECK(_anamag, "Anagrafica di magazzino non inizializzata") ; return *_anamag; }
|
||||
TLocalisamfile & umart() const { CHECK(_umart, "Anagrafica di unita' di misura magazzino non inizializzata") ; return *_umart; }
|
||||
@ -59,14 +60,14 @@ public:
|
||||
const TString & get_iva() const { return _codiva; }
|
||||
|
||||
void set_config( TConfig * ditta){ _config_ditta = ditta; }
|
||||
void set_testa( TMask * testa ){ _testa = testa; }
|
||||
void set_testa( TDocumento_mask * testa ){ _testa = testa; }
|
||||
void set_riga( TMask * riga ){ _riga = riga; }
|
||||
void set_anamag(TLocalisamfile & anamag) { _anamag = &anamag; }
|
||||
void set_umart(TLocalisamfile & umart) { _umart = &umart; }
|
||||
void ricerca(bool load_um_only = FALSE, bool load_scagl_only = FALSE);
|
||||
bool gestum() const { return _condv.get_bool("GESTUM"); }
|
||||
|
||||
TCond_vendita(TCliFor * clifo = NULL, TConfig * _ditta = NULL, TMask * testa = NULL, TMask * riga = NULL,
|
||||
TCond_vendita(TCliFor * clifo = NULL, TConfig * _ditta = NULL, TDocumento_mask * testa = NULL, TMask * riga = NULL,
|
||||
TLocalisamfile * anamag = NULL, TLocalisamfile * umart = NULL);
|
||||
~TCond_vendita() {}
|
||||
};
|
||||
|
@ -21,6 +21,14 @@
|
||||
|
||||
#ifndef __TABUTIL_H
|
||||
#include <tabutil.h>
|
||||
#endif
|
||||
|
||||
#ifndef __VEINI_H
|
||||
#include "veini.h"
|
||||
#endif
|
||||
|
||||
#ifndef __VELIB01_H
|
||||
#include <velib01.h>
|
||||
#endif
|
||||
|
||||
const TString& TData_picker::get( const TString& table, const TString& codtab, const TString& field )
|
||||
@ -182,7 +190,6 @@ void TCliForVendite::update_mask( TMask& m, bool onload )
|
||||
stato = get( LF_CLIFO, "STATOCF" );
|
||||
m.set( F_STATOCF, stato );
|
||||
}
|
||||
// m.set( F_DESSTATOCF, get( "%STA", stato, "S0" ) );
|
||||
const TString16 newcodval(m.get(F_CODVAL));
|
||||
const TString16 newdatacambio(m.get(F_DATACAMBIO1));
|
||||
|
||||
@ -227,10 +234,12 @@ void TCliForVendite::update_mask( TMask& m, bool onload )
|
||||
m.enable(F_CODCONT1, contr_enabled && gescontr);
|
||||
m.enable(F_CODCONT, contr_enabled && gescontr);
|
||||
|
||||
// imposta_dati_comune( m );
|
||||
imposta_indirizzo_spedizione( m );
|
||||
imposta_sconto_testa( m );
|
||||
// imposta_valuta( m );
|
||||
if (!onload)
|
||||
{
|
||||
imposta_indirizzo_spedizione( m );
|
||||
imposta_sconto_testa( m );
|
||||
imposta_spese(m);
|
||||
}
|
||||
}
|
||||
|
||||
void TCliFor::edita_occasionale( )
|
||||
@ -259,26 +268,6 @@ bool TCliFor::occas_code_handler(TMask_field& f, KEY key)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TCliForVendite::imposta_dati_comune( TMask& m )
|
||||
{
|
||||
TLocalisamfile comuni(LF_COMUNI);
|
||||
comuni.setkey( 1 );
|
||||
if( occasionale( ) )
|
||||
{
|
||||
comuni.put( "COM", occas_mask( ).get( O_COMUNE ));
|
||||
comuni.put( "STATO", occas_mask( ).get( O_STATO ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
comuni.put( "COM", get( LF_CLIFO, "COMCF" ));
|
||||
comuni.put( "STATO", get( LF_CLIFO, "STATOCF" ) );
|
||||
}
|
||||
if (comuni.read() != NOERR)
|
||||
comuni.zero();
|
||||
m.set( F_DENCOM, comuni.get( "DENCOM" ) );
|
||||
m.set( F_PROVCOM, comuni.get( "PROVCOM" ) );
|
||||
}
|
||||
|
||||
void TCliForVendite::imposta_indirizzo_spedizione( TMask& m )
|
||||
{
|
||||
TString16 stato;
|
||||
@ -360,36 +349,22 @@ void TCliForVendite::imposta_sconto_testa( TMask& m )
|
||||
return;
|
||||
}
|
||||
|
||||
void TCliForVendite::imposta_valuta( TMask& m )
|
||||
void TCliForVendite::imposta_spese( TMask& m )
|
||||
{
|
||||
|
||||
TConfig & ditta = app().config_ditta();
|
||||
|
||||
if( ditta.get_bool( "GESVALAC", "ve" ) )
|
||||
{
|
||||
TTable cambi( "CAM" );
|
||||
cambi.zero( );
|
||||
TString16 val( m.get( F_CODVAL ) );
|
||||
TString16 codtab( ( const char * ) val );
|
||||
codtab << m.get( F_DATADOC );
|
||||
cambi.put( "CODTAB", codtab );
|
||||
const int result = cambi.read( _isgteq );
|
||||
if( result == _iseof )
|
||||
cambi.prev( );
|
||||
codtab = cambi.get( "CODTAB" );
|
||||
if ( codtab.sub( 0, 2 ) == val )
|
||||
{
|
||||
m.set( F_CAMBIO, cambi.get( "R10" ) );
|
||||
m.set( F_DATACAMBIO1, cambi.get( "D0" ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
TTable valuta( "%VAL" );
|
||||
valuta.zero( );
|
||||
valuta.put( "CODTAB", m.get( F_CODVAL ) );
|
||||
if( valuta.read( ) == NOERR )
|
||||
{
|
||||
m.set( F_CAMBIO, valuta.get( "R10" ) );
|
||||
m.set( F_DATACAMBIO, valuta.get( "D0" ) );
|
||||
}
|
||||
}
|
||||
TSheet_field & sh = (TSheet_field &) m.field(F_SHEET);
|
||||
TDocumento & doc = app().doc();
|
||||
|
||||
TString16 name("CODSP0");
|
||||
TString_array spese;
|
||||
for (int i = 1; i <= 4; i++)
|
||||
{
|
||||
name.rtrim(1); name << i;
|
||||
const TString16 s(get(LF_CFVEN, name));
|
||||
|
||||
if (s.not_empty())
|
||||
spese.add(s);
|
||||
}
|
||||
m.autosave(*app().get_relation());
|
||||
doc.update_spese_aut(spese, FALSE, &sh);
|
||||
sh.force_update();
|
||||
}
|
||||
|
@ -55,10 +55,9 @@ class TCliForVendite : public TCliFor
|
||||
public:
|
||||
|
||||
void update_mask( TMask& m, bool onload = FALSE );
|
||||
void imposta_dati_comune( TMask& m );
|
||||
void imposta_valuta( TMask& m );
|
||||
void imposta_indirizzo_spedizione( TMask& m );
|
||||
void imposta_sconto_testa( TMask& m );
|
||||
void imposta_spese( TMask& m );
|
||||
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,7 @@ void TMotore_application::init_query_mode( TMask& m )
|
||||
void TMotore_application::init_insert_mode( TMask& m )
|
||||
{
|
||||
TString tipocf( "A" );
|
||||
tipocf[ 0 ] = app().tipocf();
|
||||
tipocf[ 0 ] = app().tipocf();
|
||||
|
||||
const TString16 codnum(m.get(F_CODNUM));
|
||||
const int anno = m.get_int(F_ANNO);
|
||||
@ -51,10 +51,10 @@ void TMotore_application::init_insert_mode( TMask& m )
|
||||
const int pos = m.id2pos( F_DATACAMBIO1);
|
||||
|
||||
if (pos >= 0 && m.fld(pos).active())
|
||||
m.fld(pos).set(data_doc);
|
||||
m.fld(pos).set(data_doc);
|
||||
m.disable(DLG_PRINT);
|
||||
clifo( ).occas_mask( ).reset( );
|
||||
const int ndefaults = pro( ).get_int( "NDEFAULTS", "DEFAULT" ); // prof
|
||||
TMask & emask = edit_mask();
|
||||
|
||||
for( int i = 1; i <= ndefaults; i++ )
|
||||
{
|
||||
@ -63,10 +63,15 @@ void TMotore_application::init_insert_mode( TMask& m )
|
||||
TToken_string valore( pro( ).get( chiave, "DEFAULT" ) );
|
||||
int campo( valore.get_int( 0 ) );
|
||||
TString default_val( valore.get( 1 ) );
|
||||
emask.set( campo, default_val, TRUE );
|
||||
m.set( campo, default_val, TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
void TMotore_application::init_modify_mode( TMask& m )
|
||||
{
|
||||
m.enable(DLG_PRINT);
|
||||
}
|
||||
|
||||
void TMotore_application::update_profile()
|
||||
{
|
||||
TFilename fn(_doc->tipo().profile_name());
|
||||
@ -132,25 +137,40 @@ bool TMotore_application::ss_handler( TSheet_field& ss, int r, KEY key )
|
||||
riga.autosave(ss);
|
||||
}
|
||||
else
|
||||
if ( key == K_DEL ) // Cancellazione
|
||||
if ( key == K_DEL ) // Cancellazione
|
||||
{
|
||||
app()._doc->destroy_row(r + 1, TRUE);
|
||||
if (r < app()._doc->rows())
|
||||
{
|
||||
TRiga_documento & riga = (*(app()._doc))[r + 1];
|
||||
if (riga.tipo().tipo() == RIGA_OMAGGI && riga.generata())
|
||||
{
|
||||
ss.destroy(r + 1);
|
||||
app()._doc->destroy_row(r + 1, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (key == K_INS) // Inserimento
|
||||
{
|
||||
if (r < app()._doc->rows())
|
||||
{
|
||||
TRiga_documento & riga = (*(app()._doc))[r + 1];
|
||||
if (riga.tipo().tipo() == RIGA_OMAGGI && riga.generata())
|
||||
return FALSE;
|
||||
}
|
||||
TMask & emask = app().edit_mask();
|
||||
|
||||
app()._doc->insert_row(r + 1, emask.get( F_LBTIPORIGA ));
|
||||
}
|
||||
else
|
||||
else
|
||||
if (key == K_CTRL + K_INS)
|
||||
{
|
||||
TRiga_documento & riga = (*(app()._doc))[r + 1];
|
||||
|
||||
TString16 s(app()._clifor->get(LF_CFVEN, "CODMAG"));
|
||||
|
||||
|
||||
s << app()._clifor->get(LF_CFVEN, "CODDEP");
|
||||
riga.put("CODMAG", s);
|
||||
riga.autoload(ss);
|
||||
riga.autoload(ss);
|
||||
ss.select(r);
|
||||
}
|
||||
return TRUE;
|
||||
@ -225,6 +245,28 @@ bool TMotore_application::elabora_handler( TMask_field& f, KEY key )
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TMotore_application::print_handler( TMask_field& f, KEY key )
|
||||
|
||||
{
|
||||
if (key == K_SPACE)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
|
||||
if (app().save(TRUE)) // Registra il record corrente
|
||||
{
|
||||
TString commandline("ve1 -0 ");
|
||||
|
||||
commandline << m.get( F_CODNUM ) << " " << m.get( F_ANNO ) << " ";
|
||||
commandline << m.get( F_PROVV )<< " " << m.get( F_NDOC );
|
||||
|
||||
TExternal_app interattivo( commandline );
|
||||
|
||||
interattivo.run( );
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool TMotore_application::occas_handler( TMask_field& f, KEY key )
|
||||
@ -407,7 +449,9 @@ TMask* TMotore_application::get_mask( int mode )
|
||||
msk1->set_handler( F_CODPAG, condpag_hndl );
|
||||
msk1->set_handler( F_DATAINSC, condpag_hndl );
|
||||
msk1->set_handler( F_CODNOTE, note_hndl );
|
||||
// _msk1->set_handler( 99, elabora_handler );
|
||||
msk1->set_handler( F_DATADOC, data_hndl );
|
||||
msk1->set_handler( 99, elabora_handler );
|
||||
msk1->set_handler( DLG_PRINT, print_handler );
|
||||
int numhandler = pro( ).get_int( "NHANDLER", "HANDLERS" ); // prof
|
||||
for ( i = 1; i <= numhandler; i ++ )
|
||||
{
|
||||
@ -509,14 +553,6 @@ void TMotore_application::set_descr( int i, const char * dfi )
|
||||
r.add( dfi, 0 );
|
||||
}
|
||||
|
||||
void TMotore_application::carica_righe_libere( int from )
|
||||
{
|
||||
if ( from < 0 ) from = ss( ).items( );
|
||||
for ( int i = from; i < 20; i++ )
|
||||
set_descr( i, "" );
|
||||
ss( ).force_update( );
|
||||
}
|
||||
|
||||
const char* TMotore_application::get_next_key( )
|
||||
{
|
||||
TToken_string key;
|
||||
@ -572,12 +608,14 @@ int TMotore_application::read( TMask& m )
|
||||
f.destroy( );
|
||||
const int rows = _doc->rows();
|
||||
for (int i = 1; i <= rows; i++)
|
||||
{
|
||||
{
|
||||
f.insert(-1, FALSE);
|
||||
TToken_string & r = f.row(i -1);
|
||||
TRiga_documento & rec = (*_doc)[i];
|
||||
|
||||
rec.autoload(f);
|
||||
f.post_insert(i - 1);
|
||||
rec.autoload(f);
|
||||
f.check_row(i - 1);
|
||||
// f.post_insert(i - 1);
|
||||
}
|
||||
}
|
||||
return err;
|
||||
|
13
ve/ve0100.h
13
ve/ve0100.h
@ -149,6 +149,7 @@ class TMotore_application : public TRelation_application
|
||||
virtual bool changing_mask( int mode );
|
||||
virtual void init_query_mode(TMask& m);
|
||||
virtual void init_insert_mode( TMask& m );
|
||||
virtual void init_modify_mode( TMask& m );
|
||||
virtual int read( TMask& m );
|
||||
virtual bool remove( void );
|
||||
virtual int write( const TMask& m );
|
||||
@ -177,16 +178,9 @@ protected:
|
||||
void read_rdoc( TMask& m );
|
||||
void update_profile();
|
||||
|
||||
|
||||
// formato dipendente dallo sheet ( sono le varie colonne )
|
||||
// void load_riga( TSheet_field& f, int numrig, TRectype& r );
|
||||
|
||||
void save( TRelation* r ) const;
|
||||
void set_descr ( int numrig, const char* descr );
|
||||
void carica_righe_libere( int from = -1 );
|
||||
|
||||
// Procedure e funzioni per la gestione degli stati
|
||||
// void setta_stato_corrente( int nuovostato );
|
||||
const char* nome_sezione( int op );
|
||||
int stato_corrente( );
|
||||
int stato_finale( int operazione );
|
||||
@ -209,14 +203,11 @@ protected:
|
||||
static bool clifo_handler( TMask_field& f, KEY key );
|
||||
static bool occas_handler( TMask_field& f, KEY key );
|
||||
static bool elabora_handler( TMask_field& f, KEY key );
|
||||
static bool print_handler( TMask_field& f, KEY key );
|
||||
|
||||
// Configurazione dello sheet dato il profilo
|
||||
void configura_sheet( TSheet_field& sheet, TConfig& config );
|
||||
|
||||
// Funzione per la sostituzione delle variabili nella decodifica
|
||||
// delle espressioni di una riga
|
||||
void carica_variabile( TExpression& e, const char * varname, TRectype r );
|
||||
|
||||
public:
|
||||
|
||||
virtual TRelation* get_relation( ) const { return _rel;}
|
||||
|
@ -184,4 +184,31 @@ END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Gestione omaggi" 1 1 60 14
|
||||
|
||||
STRING F_TIPORIGAOM 4
|
||||
BEGIN
|
||||
PROMPT 2 2 "Tipo riga per omaggi "
|
||||
FIELD TROMAGGI
|
||||
FLAGS "U"
|
||||
USE %TRI SELECT S7=="O"
|
||||
INPUT CODTAB F_TIPORIGAOM
|
||||
DISPLAY "Codice" CODTAB
|
||||
DISPLAY "Descrizione@50" S0
|
||||
OUTPUT F_TIPORIGAOM CODTAB
|
||||
OUTPUT F_DESCRRIGAOM S0
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
STRING F_DESCRRIGAOM 50
|
||||
BEGIN
|
||||
PROMPT 23 3 ""
|
||||
USE %TRI KEY 2 SELECT S7=="O"
|
||||
INPUT S0 F_DESCRRIGAOM
|
||||
COPY DISPLAY F_TIPORIGAOM
|
||||
COPY OUTPUT F_TIPORIGAOM
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
||||
|
@ -1162,7 +1162,7 @@ void TMask_generator::genera( const TString& profilo )
|
||||
_m->control( T_BOTTONE, DLG_PRINT, 1002 );
|
||||
_m->begin( );
|
||||
_m->prompt( -45, -1 );
|
||||
_m->message( "EXIT,346" );
|
||||
_m->message( "EXIT,20082" );
|
||||
_m->end( );
|
||||
|
||||
_m->control( T_BOTTONE, DLG_CANCEL, 1002 );
|
||||
|
@ -5,7 +5,7 @@
|
||||
extern int ve1100(int argc, char* argv[]); // stampa documenti di vendita tramite form derivati
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int rt= -1;
|
||||
int rt= -1;
|
||||
const int r= (argc>1)?(atoi(&argv[1][1])):(-1);
|
||||
|
||||
switch (r) {
|
||||
|
@ -941,7 +941,7 @@ public:
|
||||
TDocumento_form& form() { return *_form; }
|
||||
void print_documento();
|
||||
void print_selected();
|
||||
TStampaDoc_application() {};
|
||||
TStampaDoc_application() : _key(BY_NUM_KEY) {};
|
||||
virtual ~TStampaDoc_application() {};
|
||||
};
|
||||
|
||||
@ -1146,29 +1146,40 @@ bool TStampaDoc_application::create()
|
||||
_firmrel->add(LF_UNLOC,"CODDITTA=CODDITTA"); // si posiziona sulla prima unita' locale della ditta
|
||||
_firmrel->add(LF_COMUNI, "COM=STATORES+COMRES", 1, LF_ANAG, 100+LF_COMUNI);
|
||||
_firmrel->add(LF_COMUNI, "COM=STATORES+COMRF", 1, LF_ANAG, 200+LF_COMUNI);
|
||||
int argc = TApplication::argc();
|
||||
if (argc>2 && (argc == 8 || argc == 9))
|
||||
const int argc = TApplication::argc();
|
||||
|
||||
if (argc>2)
|
||||
{ // lettura dei parametri iniziali dalla linea di comando
|
||||
_codnum= argv(2); // il primo parametro è il codice di numerazione
|
||||
_anno= atoi(argv(3)); // il secondo è l'anno
|
||||
_provv= argv(4)[0]; // il terzo è il flag di numerazione provvisoria
|
||||
_dalnum= atol(argv(5)); // il quarto è il numero di documento di partenza
|
||||
_alnum= atol(argv(6)); // il quinto è il numero di documento di fine
|
||||
_definitiva= (strcmp(argv(7), "D")==0); // il sesto è se la stampa è definitiva (rinumerazione dei documenti)
|
||||
_ncopie = argc == 9 ? atoi(argv(8)) : 1;
|
||||
_alnum = _dalnum;
|
||||
_definitiva = FALSE;
|
||||
_ncopie = 1;
|
||||
_interattivo= FALSE;
|
||||
print_selected();
|
||||
}
|
||||
else if (argc == 2)
|
||||
{ // oppure lancio della maschera
|
||||
_interattivo= TRUE;
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
error_box(Usage);
|
||||
if (argc > 6)
|
||||
{
|
||||
_alnum= atol(argv(6)); // il quinto è il numero di documento di fine
|
||||
if (argc > 7)
|
||||
{
|
||||
_definitiva= (strcmp(argv(7), "D")==0); // il sesto è se la stampa è definitiva (rinumerazione dei documenti)
|
||||
if (argc > 8)
|
||||
_ncopie = atoi(argv(8));
|
||||
}
|
||||
else _interattivo = TRUE;
|
||||
}
|
||||
print_selected();
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
if (argc == 2)
|
||||
{ // oppure lancio della maschera
|
||||
_interattivo= TRUE;
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
}
|
||||
else
|
||||
return error_box(Usage);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ bool TRighe_condizioni_vendita::handle_cod(TMask_field &fld, KEY k) {
|
||||
|
||||
const bool enable_gift = _gest_so && condv.get_bool("GESTSCO");
|
||||
_msk->enable(-1,enable_gift); // abilita il gruppo di campi relativi all'omaggio
|
||||
_msk->enable(F_R_UMOM, enable_gift && _gest_um); // abilita il campo "unità di misura art. omaggio"
|
||||
_msk->enable(F_R_UMOM, enable_gift); // abilita il campo "unità di misura art. omaggio"
|
||||
|
||||
const int mode = _msk->mode();
|
||||
if (mode == MODE_QUERY || mode == MODE_QUERYINS) // Sostituisce il listbox solo in ricerca...
|
||||
|
@ -112,6 +112,8 @@
|
||||
#define F_SPBOIMP6 121
|
||||
#define F_SPBOSCA7 122
|
||||
#define F_SPBOIMP7 123
|
||||
#define F_TIPORIGAOM 124
|
||||
#define F_DESCRRIGAOM 125
|
||||
|
||||
|
||||
#endif
|
||||
|
353
ve/velib01.cpp
353
ve/velib01.cpp
@ -51,13 +51,13 @@
|
||||
#endif
|
||||
|
||||
#ifndef __SCONTI_H
|
||||
#include "sconti.h"
|
||||
#include "sconti.h"
|
||||
#endif
|
||||
|
||||
TSpesa_prest::TSpesa_prest(const char* codice, char tipo)
|
||||
: TRectype(LF_TAB)
|
||||
{
|
||||
settab(tipo == 'S' ? "SPP" : "PRS");
|
||||
settab(tipo == RIGA_SPESE ? "SPP" : "PRS");
|
||||
if (codice && *codice)
|
||||
read(codice);
|
||||
}
|
||||
@ -195,6 +195,39 @@ bool note_hndl( TMask_field& f, KEY key )
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Handler per il calcolo delle date di pagamento
|
||||
bool data_hndl( TMask_field& field, KEY key )
|
||||
{
|
||||
TDocumento_mask& m = (TDocumento_mask &) field.mask( );
|
||||
if (key == K_ENTER && field.dirty())
|
||||
{
|
||||
TLocalisamfile doc(LF_DOC);
|
||||
const TDate datadoc(m.get(F_DATADOC));
|
||||
|
||||
doc.curr() = m.doc().head();
|
||||
const TString16 codnum(doc.get("CODNUM"));
|
||||
const int anno = doc.get_int("ANNO");
|
||||
const char tipo_num = doc.get_char("PROVV");
|
||||
|
||||
if (doc.read(_isgreat) == NOERR &&
|
||||
codnum == doc.get("CODNUM") &&
|
||||
anno == doc.get_int("ANNO") &&
|
||||
tipo_num == doc.get_char("PROVV") &&
|
||||
datadoc > doc.get_date("DATADOC"))
|
||||
return field.error_box("Data documento superiore alla data del documento successivo");
|
||||
|
||||
doc.curr() = m.doc().head();
|
||||
doc.read();
|
||||
if (doc.prev() == NOERR &&
|
||||
codnum == doc.get("CODNUM") &&
|
||||
anno == doc.get_int("ANNO") &&
|
||||
tipo_num == doc.get_char("PROVV") &&
|
||||
datadoc < doc.get_date("DATADOC"))
|
||||
return field.error_box("Data documento inferiore alla data del documento precedente");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// handler delle righe
|
||||
|
||||
HIDDEN void row_set_handler( TMask& m, const int field, const int index )
|
||||
@ -228,10 +261,10 @@ HIDDEN bool iva_handler( TMask_field& f, KEY key )
|
||||
|
||||
HIDDEN bool codart_handler( TMask_field& f, KEY key )
|
||||
{
|
||||
// Se qualcuno cerca di modificare la maschera
|
||||
if ( key == K_TAB && f.focusdirty())
|
||||
TMask& row_mask = f.mask();
|
||||
|
||||
if (key == K_TAB && (f.focusdirty() || row_mask.get(FR_DESCR).empty()))
|
||||
{
|
||||
TMask& row_mask = f.mask();
|
||||
TDocumento_mask & mask = (TDocumento_mask &) row_mask.get_sheet()->mask();
|
||||
TCond_vendita & condv = mask.condv();
|
||||
|
||||
@ -321,7 +354,7 @@ HIDDEN bool umart_handler( TMask_field& f, KEY key )
|
||||
condv.set_anamag(anamag);
|
||||
condv.set_umart(umart);
|
||||
condv.ricerca(TRUE);
|
||||
|
||||
|
||||
const TString16 um(f.get());
|
||||
real fc(1.0);
|
||||
|
||||
@ -388,12 +421,32 @@ HIDDEN bool qta_handler( TMask_field& f, KEY key )
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
HIDDEN void sppr_calc(TRectype & rec, const TString & valuta_doc, const real & cambio, real & prezzo)
|
||||
{
|
||||
const TString16 sppr_valuta(rec.get("S4"));
|
||||
|
||||
if (sppr_valuta != valuta_doc && cambio != 0.0)
|
||||
{
|
||||
TTable val("%VAL");
|
||||
|
||||
val.put("CODTAB", sppr_valuta);
|
||||
if (val.read() == NOERR)
|
||||
{
|
||||
const real sppr_cambio = val.get_real("R10");
|
||||
if (sppr_cambio != ZERO)
|
||||
prezzo *= sppr_cambio;
|
||||
}
|
||||
prezzo /= cambio;
|
||||
}
|
||||
}
|
||||
|
||||
HIDDEN bool sppr_handler( TMask_field& f, KEY key )
|
||||
{
|
||||
if (key == K_TAB && f.focusdirty())
|
||||
TMask& row_mask = f.mask();
|
||||
|
||||
if (key == K_TAB && (f.focusdirty() || !row_mask.get(FR_DESCR).empty()))
|
||||
{
|
||||
TMask& row_mask = f.mask( );
|
||||
const int pos = row_mask.id2pos(FR_PREZZO);
|
||||
|
||||
if (pos >= 0)
|
||||
@ -401,30 +454,16 @@ HIDDEN bool sppr_handler( TMask_field& f, KEY key )
|
||||
TMask & mask = row_mask.get_sheet()->mask();
|
||||
TRectype & spprrec = ((TEdit_field &) row_mask.field(FR_CODART)).browse()->cursor()->file().curr();
|
||||
|
||||
if (spprrec.get("CODTAB") == row_mask.get(FR_CODART) && spprrec.get_char("S6") != 'P')
|
||||
if (spprrec.get("CODTAB") == row_mask.get(FR_CODART) && spprrec.get_char("S6") != 'P')
|
||||
{
|
||||
real cambio = mask.get(F_CAMBIO);
|
||||
const real cambio = mask.get(F_CAMBIO);
|
||||
real prezzo = row_mask.get(FR_PREZZO);
|
||||
const TString16 doc_valuta(mask.get(F_CODVAL));
|
||||
const TString16 sppr_valuta(spprrec.get("S4"));
|
||||
|
||||
if (sppr_valuta != doc_valuta && cambio != 0.0)
|
||||
{
|
||||
TTable val("%VAL");
|
||||
|
||||
val.put("CODTAB", sppr_valuta);
|
||||
if (val.read() == NOERR)
|
||||
{
|
||||
const real sppr_cambio = val.get_real("R10");
|
||||
if (sppr_cambio != ZERO)
|
||||
prezzo *= sppr_cambio;
|
||||
}
|
||||
prezzo /= mask.get_real(F_CAMBIO);
|
||||
}
|
||||
sppr_calc(spprrec, doc_valuta, cambio, prezzo);
|
||||
row_mask.set(FR_PREZZO, prezzo);
|
||||
const int pos =row_mask.id2pos(FR_CODIVA);
|
||||
if (pos >= 0)
|
||||
iva_handler(row_mask.fld(pos), 0);
|
||||
const int posiva = row_mask.id2pos(FR_CODIVA);
|
||||
if (posiva >= 0)
|
||||
iva_handler(row_mask.fld(posiva), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -517,10 +556,13 @@ real iva(real imponibile, const TIVA & iva,int ndec)
|
||||
{
|
||||
real val = imponibile * iva.aliquota() / 100.0;
|
||||
|
||||
if (val <ZERO)
|
||||
val.floor(ndec);
|
||||
else
|
||||
val.ceil(ndec);
|
||||
if (ndec < 20)
|
||||
{
|
||||
if (val < ZERO)
|
||||
val.floor(ndec);
|
||||
else
|
||||
val.ceil(ndec);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
@ -902,7 +944,7 @@ void TExpr_documento::evaluate_user_func(int index, int nparms, TEval_stack & st
|
||||
real & val = stack.peek_real();
|
||||
if (_row)
|
||||
{
|
||||
if (_row->tipo().tipo() == 'C')
|
||||
if (_row->tipo().tipo() == RIGA_SCONTI)
|
||||
val = -_row->importo(FALSE, FALSE, ndec);
|
||||
else
|
||||
val = _row->importo(FALSE, FALSE, ndec) - _row->importo(TRUE, FALSE, ndec);
|
||||
@ -1253,7 +1295,7 @@ TVariable_mask * TTipo_riga_documento::mask()
|
||||
_mask->set_handler( FR_QTA, qta_handler );
|
||||
}
|
||||
else
|
||||
if (tipo_r == 'S' || tipo_r == 'P')
|
||||
if (tipo_r == RIGA_SPESE || tipo_r == RIGA_PRESTAZIONI)
|
||||
_mask->set_handler( FR_CODART, sppr_handler );
|
||||
}
|
||||
}
|
||||
@ -1276,7 +1318,7 @@ TAssoc_array TRiga_documento::_spese;
|
||||
TAssoc_array TRiga_documento::_ive;
|
||||
|
||||
TRiga_documento::TRiga_documento(TDocumento* doc, const char * tipo)
|
||||
: TAuto_variable_rectype(LF_RIGHEDOC), _doc(doc)
|
||||
: TAuto_variable_rectype(LF_RIGHEDOC), _doc(doc), _iva_calc(FALSE)
|
||||
{
|
||||
if (tipo)
|
||||
set_tipo(tipo);
|
||||
@ -1284,7 +1326,7 @@ TRiga_documento::TRiga_documento(TDocumento* doc, const char * tipo)
|
||||
|
||||
TRiga_documento::TRiga_documento(const TRiga_documento& rec, TDocumento* doc,
|
||||
const char * tipo)
|
||||
: TAuto_variable_rectype(rec), _doc(doc)
|
||||
: TAuto_variable_rectype(rec), _doc(doc), _iva_calc(FALSE)
|
||||
{
|
||||
if (tipo)
|
||||
set_tipo(tipo);
|
||||
@ -1320,7 +1362,7 @@ const TSpesa_prest & TRiga_documento::spesa() const
|
||||
{
|
||||
const char tipor = tipo().tipo();
|
||||
|
||||
CHECK(tipor == 'S' || tipor == 'P', "Tipo riga incompatibile con le spese");
|
||||
CHECK(tipor == RIGA_SPESE || tipor == RIGA_PRESTAZIONI, "Tipo riga incompatibile con le spese");
|
||||
static long firm = -1;
|
||||
long new_firm = main_app().get_firm();
|
||||
|
||||
@ -1357,20 +1399,20 @@ bool TRiga_documento::sola_descrizione() const
|
||||
{
|
||||
char t = tipo().tipo();
|
||||
if (t <= ' ' && get("QTA").empty() && get("PREZZO").empty())
|
||||
t = 'D';
|
||||
return t == 'D';
|
||||
t = RIGA_DESCRIZIONI;
|
||||
return t == RIGA_DESCRIZIONI;
|
||||
}
|
||||
|
||||
void TRiga_documento::forza_sola_descrizione()
|
||||
{
|
||||
// In realta' il test serve anche a caricare la lista dei tipi riga!
|
||||
if (!tipo_valido() || tipo().tipo() != 'D')
|
||||
if (!tipo_valido() || tipo().tipo() != RIGA_DESCRIZIONI)
|
||||
{
|
||||
_tipi.restart();
|
||||
for (const TObject* o = _tipi.get(); o; o = _tipi.get())
|
||||
{
|
||||
const TTipo_riga_documento* trd = (const TTipo_riga_documento*)o;
|
||||
if (trd->tipo() == 'D')
|
||||
if (trd->tipo() == RIGA_DESCRIZIONI)
|
||||
{
|
||||
put("TIPORIGA", trd->codice());
|
||||
break;
|
||||
@ -1464,7 +1506,7 @@ real TRiga_documento::prezzo(bool scontato, bool lordo, int ndec) const
|
||||
return prezzo;
|
||||
}
|
||||
|
||||
real TRiga_documento::importo(bool scontato, bool lordo, int ndec, bool iva_calc) const
|
||||
real TRiga_documento::importo(bool scontato, bool lordo, int ndec) const
|
||||
{
|
||||
real importo;
|
||||
|
||||
@ -1476,11 +1518,11 @@ real TRiga_documento::importo(bool scontato, bool lordo, int ndec, bool iva_calc
|
||||
|
||||
switch (tipor)
|
||||
{
|
||||
case 'M':
|
||||
case RIGA_MERCE:
|
||||
c = _qtaprezzo;
|
||||
break;
|
||||
case 'P':
|
||||
case 'S':
|
||||
case RIGA_PRESTAZIONI:
|
||||
case RIGA_SPESE:
|
||||
{
|
||||
const TSpesa_prest & s = spesa();
|
||||
|
||||
@ -1501,7 +1543,7 @@ real TRiga_documento::importo(bool scontato, bool lordo, int ndec, bool iva_calc
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'C':
|
||||
case RIGA_SCONTI:
|
||||
cv.set_sconto(get("SCONTO"));
|
||||
|
||||
if (cv.get_sconto().not_empty())
|
||||
@ -1509,8 +1551,8 @@ real TRiga_documento::importo(bool scontato, bool lordo, int ndec, bool iva_calc
|
||||
else
|
||||
c = _scontoimp;
|
||||
break;
|
||||
case 'O':
|
||||
if (iva_calc)
|
||||
case RIGA_OMAGGI:
|
||||
if (_iva_calc && get_bool("ADDIVA"))
|
||||
c = _qtaprezzo;
|
||||
default:
|
||||
break;
|
||||
@ -1539,6 +1581,14 @@ real TRiga_documento::importo(bool scontato, bool lordo, int ndec, bool iva_calc
|
||||
|
||||
return importo;
|
||||
}
|
||||
|
||||
real TRiga_documento::iva(int ndec) const
|
||||
{
|
||||
((TRiga_documento *) this)->_iva_calc = TRUE;
|
||||
real iva(::iva(imponibile(), iva(), ndec));
|
||||
((TRiga_documento *) this)->_iva_calc = FALSE;
|
||||
return iva;
|
||||
}
|
||||
|
||||
real TRiga_documento::imponibile() const
|
||||
{
|
||||
@ -1550,14 +1600,14 @@ real TRiga_documento::imponibile() const
|
||||
return importo(TRUE, FALSE, doc().in_valuta() ? 3 : 0);
|
||||
}
|
||||
|
||||
real TRiga_documento::imposta() const
|
||||
real TRiga_documento::imposta(bool round) const
|
||||
{
|
||||
const TString16 field(tipo().imposta());
|
||||
|
||||
if (field.not_empty())
|
||||
return get_real(field);
|
||||
else
|
||||
return iva(doc().in_valuta() ? 3 : 0);
|
||||
else
|
||||
return iva(round ? (doc().in_valuta() ? 3 : 0) : 20);
|
||||
}
|
||||
|
||||
void TRiga_documento::dirty_fields(bool dirty_document)
|
||||
@ -1576,10 +1626,10 @@ bool TRiga_documento::doc_dependent() const
|
||||
{
|
||||
const char tipor = tipo().tipo();
|
||||
|
||||
if (tipor == 'S')
|
||||
if (tipor == RIGA_SPESE)
|
||||
return spesa().tipo() == 'P';
|
||||
else
|
||||
if (tipor == 'C')
|
||||
if (tipor == RIGA_SCONTI)
|
||||
return get("SCONTO").not_empty();
|
||||
}
|
||||
return FALSE;
|
||||
@ -1677,41 +1727,38 @@ void TRiga_documento::autoload(TSheet_field & f)
|
||||
{
|
||||
const int num = numero() - 1;
|
||||
|
||||
if (num >= 0 && num < f.items())
|
||||
{
|
||||
TToken_string & row = f.row(num);
|
||||
TToken_string & row = f.row(num);
|
||||
|
||||
row.add( get( "STATORIGA" ), f.cid2index(FR_STATORIGA ));
|
||||
row.add( get( "TIPORIGA" ), f.cid2index(FR_TIPORIGA ));
|
||||
const TString codmag(get("CODMAG"));
|
||||
row.add( codmag.left(3), f.cid2index(FR_CODMAG ));
|
||||
row.add( codmag.mid(3), f.cid2index(FR_CODDEP ));
|
||||
row.add( get( "CODART" ), f.cid2index(FR_CODART ));
|
||||
TString s(get("DESCR"));
|
||||
if (get_bool("DESCLUNGA"))
|
||||
s << get("DESCEST");
|
||||
row.add(s, f.cid2index(FR_DESCR ));
|
||||
row.add( get( "UMQTA" ), f.cid2index(FR_UMQTA ));
|
||||
row.add( get( "PREZZO" ), f.cid2index(FR_PREZZO ));
|
||||
TMask * m = ((TTipo_riga_documento &)tipo()).mask();
|
||||
const int pos = m->id2pos(FR_QTA);
|
||||
if (pos >= 0 && m->fld(pos).field()->name() == "PSPESA")
|
||||
row.add( get( "PSPESA" ), f.cid2index(FR_QTA ));
|
||||
else
|
||||
row.add( get( "QTA" ), f.cid2index(FR_QTA ));
|
||||
row.add( get( "QTAEVASA" ), f.cid2index(FR_QTAEVASA ));
|
||||
row.add( get( "RIGAEVASA" ), f.cid2index(FR_RIGAEVASA ));
|
||||
row.add( get( "TARA" ), f.cid2index(FR_TARA ));
|
||||
row.add( get( "PNETTO" ), f.cid2index(FR_PNETTO ));
|
||||
row.add( get( "NCOLLI" ), f.cid2index(FR_NCOLLI ));
|
||||
row.add( get( "DAEVADERE" ), f.cid2index(FR_DAEVADERE ));
|
||||
row.add( get( "SCONTO" ), f.cid2index(FR_SCONTO ));
|
||||
row.add( get( "PERCPROV" ), f.cid2index(FR_PERCPROV ));
|
||||
row.add( get( "IMPFISSO" ), f.cid2index(FR_IMPFISSO ));
|
||||
row.add( get( "CODIVA" ), f.cid2index(FR_CODIVA ));
|
||||
row.add( get( "ADDIVA" ), f.cid2index(FR_ADDIVA ));
|
||||
row.add( get( "ASPBENI" ), f.cid2index(FR_ASPBENI ));
|
||||
}
|
||||
row.add( get( "STATORIGA" ), f.cid2index(FR_STATORIGA ));
|
||||
row.add( get( "TIPORIGA" ), f.cid2index(FR_TIPORIGA ));
|
||||
const TString codmag(get("CODMAG"));
|
||||
row.add( codmag.left(3), f.cid2index(FR_CODMAG ));
|
||||
row.add( codmag.mid(3), f.cid2index(FR_CODDEP ));
|
||||
row.add( get( "CODART" ), f.cid2index(FR_CODART ));
|
||||
TString s(get("DESCR"));
|
||||
if (get_bool("DESCLUNGA"))
|
||||
s << get("DESCEST");
|
||||
row.add(s, f.cid2index(FR_DESCR ));
|
||||
row.add( get( "UMQTA" ), f.cid2index(FR_UMQTA ));
|
||||
row.add( get( "PREZZO" ), f.cid2index(FR_PREZZO ));
|
||||
TMask * m = ((TTipo_riga_documento &)tipo()).mask();
|
||||
const int pos = m->id2pos(FR_QTA);
|
||||
if (pos >= 0 && m->fld(pos).field()->name() == "PSPESA")
|
||||
row.add( get( "PSPESA" ), f.cid2index(FR_QTA ));
|
||||
else
|
||||
row.add( get( "QTA" ), f.cid2index(FR_QTA ));
|
||||
row.add( get( "QTAEVASA" ), f.cid2index(FR_QTAEVASA ));
|
||||
row.add( get( "RIGAEVASA" ), f.cid2index(FR_RIGAEVASA ));
|
||||
row.add( get( "TARA" ), f.cid2index(FR_TARA ));
|
||||
row.add( get( "PNETTO" ), f.cid2index(FR_PNETTO ));
|
||||
row.add( get( "NCOLLI" ), f.cid2index(FR_NCOLLI ));
|
||||
row.add( get( "DAEVADERE" ), f.cid2index(FR_DAEVADERE ));
|
||||
row.add( get( "SCONTO" ), f.cid2index(FR_SCONTO ));
|
||||
row.add( get( "PERCPROV" ), f.cid2index(FR_PERCPROV ));
|
||||
row.add( get( "IMPFISSO" ), f.cid2index(FR_IMPFISSO ));
|
||||
row.add( get( "CODIVA" ), f.cid2index(FR_CODIVA ));
|
||||
row.add( get( "ADDIVA" ), f.cid2index(FR_ADDIVA ));
|
||||
row.add( get( "ASPBENI" ), f.cid2index(FR_ASPBENI ));
|
||||
}
|
||||
|
||||
TDocumento_mask::TDocumento_mask(const char* name, TDocumento * doc, int num,
|
||||
@ -1766,7 +1813,7 @@ TAssoc_array TDocumento::_tipi;
|
||||
|
||||
TDocumento::TDocumento()
|
||||
: TAuto_variable_rectype(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA"), _nuovo(TRUE),
|
||||
_condv(NULL), _rel(NULL), _sconto(NULL)
|
||||
_condv(NULL), _rel(NULL), _sconto(NULL), _esenzione(NULL)
|
||||
{
|
||||
set_memo_fld("G1");
|
||||
}
|
||||
@ -1774,7 +1821,7 @@ TDocumento::TDocumento()
|
||||
TDocumento::TDocumento(char provv, int anno, const char* codnum, long numdoc,
|
||||
TCond_vendita * condv, TRelation * rel)
|
||||
: TAuto_variable_rectype(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA"), _nuovo(TRUE),
|
||||
_condv(condv), _rel(rel), _sconto(NULL)
|
||||
_condv(condv), _rel(rel), _sconto(NULL), _esenzione(NULL)
|
||||
{
|
||||
set_memo_fld("G1");
|
||||
if (numdoc <= 0)
|
||||
@ -1790,6 +1837,21 @@ TDocumento::TDocumento(char provv, int anno, const char* codnum, long numdoc,
|
||||
read(provv, anno, codnum, numdoc);
|
||||
}
|
||||
|
||||
TDocumento::TDocumento(const TRectype& rec, TCond_vendita * condv, TRelation * rel)
|
||||
: TAuto_variable_rectype(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA"), _nuovo(FALSE),
|
||||
_condv(condv), _rel(rel), _sconto(NULL), _esenzione(NULL)
|
||||
{
|
||||
set_memo_fld("G1");
|
||||
read(rec);
|
||||
}
|
||||
|
||||
TDocumento::~TDocumento()
|
||||
|
||||
{
|
||||
if (_sconto != NULL) delete _sconto;
|
||||
if (_esenzione != NULL) delete _esenzione;
|
||||
}
|
||||
|
||||
// Funzione statica utile a tutti gli utenti di LF_DOC e LF_RIGHEDOC
|
||||
void TDocumento::set_key(TRectype& rec, char provv, int anno, const char* codnum, long numdoc)
|
||||
{
|
||||
@ -1821,14 +1883,6 @@ void TDocumento::copy_data(TRectype& dst, const TRectype& src)
|
||||
dst.put("NRIGA", nriga);
|
||||
}
|
||||
|
||||
TDocumento::TDocumento(const TRectype& rec, TCond_vendita * condv, TRelation * rel)
|
||||
: TAuto_variable_rectype(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA"), _nuovo(FALSE),
|
||||
_condv(condv), _rel(rel), _sconto(NULL)
|
||||
{
|
||||
set_memo_fld("G1");
|
||||
read(rec);
|
||||
}
|
||||
|
||||
TRiga_documento& TDocumento::insert_row(int row, const char *tipo)
|
||||
{
|
||||
TRiga_documento * r = new TRiga_documento((const TRiga_documento &) _rows.key(), this); // ok
|
||||
@ -1931,6 +1985,10 @@ void TDocumento::set_riga_sconto()
|
||||
}
|
||||
}
|
||||
|
||||
void TDocumento::set_riga_esenzione()
|
||||
{
|
||||
}
|
||||
|
||||
void TDocumento::dirty_fields()
|
||||
{
|
||||
for (TDocumento_variable_field * f = (TDocumento_variable_field *) first_variable_field();
|
||||
@ -2009,13 +2067,22 @@ const bool TDocumento::in_valuta() const
|
||||
TRiga_documento & TDocumento::row(int index)
|
||||
{
|
||||
const int nrows = _rows.rows();
|
||||
TRiga_documento * r = NULL;
|
||||
|
||||
if (index <= nrows)
|
||||
return (TRiga_documento &) _rows.row(index, FALSE);
|
||||
r = &((TRiga_documento &) _rows.row(index, FALSE));
|
||||
else
|
||||
{
|
||||
CHECKD(index == nrows + 1 &&_sconto != NULL, "Riga documento non esistente ", index);
|
||||
return *_sconto;
|
||||
}
|
||||
CHECKD((index == nrows + 1 && (_sconto != NULL || _esenzione != NULL)) || (index == nrows + 2 && _sconto != NULL && _esenzione != NULL),
|
||||
"Riga documento non esistente ", index);
|
||||
if (index == nrows + 1)
|
||||
{
|
||||
r = _sconto != NULL ? _sconto : _esenzione;
|
||||
}
|
||||
if (index == nrows + 2)
|
||||
r = _esenzione;
|
||||
}
|
||||
return *r;
|
||||
}
|
||||
|
||||
long TDocumento::get_next_key(char provv, int anno, const char* codnum) const
|
||||
@ -2241,6 +2308,87 @@ TRectype & TDocumento::operator =(const char * r)
|
||||
set_fields(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void TDocumento::update_spese_aut(TString_array & spese_aut, bool preserve_old, TSheet_field * sh)
|
||||
|
||||
{
|
||||
const bool interactive = sh != NULL;
|
||||
if (tipo().spese_aut())
|
||||
{
|
||||
const int nrows = _rows.rows();
|
||||
for (int i = nrows; i > 0; i--)
|
||||
{
|
||||
TRiga_documento & r = row(i);
|
||||
|
||||
if (r.tipo().tipo() == RIGA_SPESE && r.generata())
|
||||
{
|
||||
if (preserve_old)
|
||||
return;
|
||||
destroy_row(i, TRUE);
|
||||
if (interactive)
|
||||
sh->destroy(i - 1);
|
||||
}
|
||||
}
|
||||
TString16 cod_iva_cli;
|
||||
const int nspese = spese_aut.items();
|
||||
if (nspese > 0)
|
||||
{
|
||||
TLocalisamfile cfven(LF_CFVEN);
|
||||
cfven.put("TIPOCF", get("TIPOCF"));
|
||||
cfven.put("CODCF", get("CODCF"));
|
||||
if (cfven.read() == NOERR)
|
||||
cod_iva_cli = cfven.get("ASSFIS");
|
||||
for (i = 0; i < nspese; i++)
|
||||
{
|
||||
const TString & s = spese_aut.row(i);
|
||||
|
||||
TSpesa_prest sp(s);
|
||||
TString16 tipo(sp.tipo_riga());
|
||||
TRiga_documento & riga = new_row(tipo);
|
||||
|
||||
riga.put("CODART", s);
|
||||
riga.set_generata();
|
||||
riga.put("DESCR", sp.descrizione());
|
||||
switch (sp.tipo())
|
||||
{
|
||||
case 'Q':
|
||||
{
|
||||
real qta = sp.qta();
|
||||
|
||||
if (qta == ZERO)
|
||||
qta = 1.0;
|
||||
riga.put("QTA", qta);
|
||||
}
|
||||
case 'V':
|
||||
{
|
||||
const real cambio = get_real("CAMBIO");
|
||||
const TString16 valuta = get("CODVAL");
|
||||
real prezzo = sp.prezzo();
|
||||
|
||||
sppr_calc(sp, valuta, cambio, prezzo);
|
||||
riga.put("PREZZO", prezzo);
|
||||
riga.put("UMQTA", sp.um());
|
||||
}
|
||||
break;
|
||||
case 'P':
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (cod_iva_cli.empty())
|
||||
riga.put("CODIVA", sp.cod_iva());
|
||||
else
|
||||
riga.put("CODIVA", cod_iva_cli);
|
||||
if (interactive)
|
||||
{
|
||||
const int nrow = sh->insert(-1, FALSE);
|
||||
riga.autoload(*sh);
|
||||
sh->check_row(nrow);
|
||||
// sh->post_insert(nrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Lista di documenti
|
||||
@ -2728,3 +2876,4 @@ bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& do
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
45
ve/velib01.h
45
ve/velib01.h
@ -21,6 +21,13 @@
|
||||
#include "../cg/pagament.h"
|
||||
#endif
|
||||
|
||||
#define RIGA_MERCE 'M'
|
||||
#define RIGA_SPESE 'S'
|
||||
#define RIGA_PRESTAZIONI 'P'
|
||||
#define RIGA_SCONTI 'C'
|
||||
#define RIGA_OMAGGI 'O'
|
||||
#define RIGA_DESCRIZIONI 'D'
|
||||
|
||||
class TDocumento;
|
||||
class TRiga_documento;
|
||||
class TCond_vendita;
|
||||
@ -42,6 +49,7 @@ bool codcli_hndl(TMask_field& field, KEY key);
|
||||
bool dummy_hndl(TMask_field& field, KEY key);
|
||||
bool condpag_hndl(TMask_field& field, KEY key);
|
||||
bool note_hndl(TMask_field& field, KEY key);
|
||||
bool data_hndl(TMask_field& field, KEY key);
|
||||
|
||||
class TDocumento_variable_field : public TVariable_field
|
||||
{
|
||||
@ -67,7 +75,7 @@ class TDocumento_variable_field : public TVariable_field
|
||||
// @ cmember Distruttore
|
||||
~TDocumento_variable_field() {}
|
||||
};
|
||||
|
||||
|
||||
class TSpesa_prest : public TRectype
|
||||
{
|
||||
|
||||
@ -80,8 +88,13 @@ public:
|
||||
public:
|
||||
const TString& codice() const { return get("CODTAB");}
|
||||
const TString& descrizione() const { return get("S0"); }
|
||||
const TString& field_perc() const { return get("S5"); }
|
||||
const TString& field_perc() const { return get("S5"); }
|
||||
const TString & um() const { return get("S7"); }
|
||||
const TString& cod_iva() const { return get("S3"); }
|
||||
real prezzo() const { return get_real("R0"); }
|
||||
real qta() const { return get_real("R1"); }
|
||||
char tipo() const { return get_char("S6"); }
|
||||
const TString & tipo_riga() const { return get("S8"); }
|
||||
char genere() const { return get("COD") == "SPP" ? 'S' : 'P'; }
|
||||
|
||||
TSpesa_prest(const char* codice = NULL, char tipo = 'S');
|
||||
@ -205,12 +218,13 @@ public:
|
||||
TFormula_documento * succ_formula(bool restart = FALSE);
|
||||
|
||||
const int ncopie() const { return get_int("I0"); }
|
||||
bool spese_aut() const { return get_bool("B0"); }
|
||||
|
||||
TTipo_documento(const char* tipodoc = NULL);
|
||||
TTipo_documento(const TRectype& rec);
|
||||
virtual ~TTipo_documento();
|
||||
};
|
||||
|
||||
|
||||
class TTipo_riga_documento : public TRectype
|
||||
{
|
||||
|
||||
@ -254,7 +268,8 @@ class TRiga_documento : public TAuto_variable_rectype
|
||||
TDocumento * _doc;
|
||||
static TAssoc_array _tipi;
|
||||
static TAssoc_array _spese;
|
||||
static TAssoc_array _ive;
|
||||
static TAssoc_array _ive;
|
||||
bool _iva_calc;
|
||||
|
||||
|
||||
protected:
|
||||
@ -269,6 +284,8 @@ public:
|
||||
bool doc_dependent() const;
|
||||
int numero() const { return get_int("NRIGA");}
|
||||
void set_numero(int numero) { put("NRIGA", numero);}
|
||||
bool generata() const { return get_bool("GENERATA");}
|
||||
void set_generata(bool on = TRUE) { put("GENERATA", on);}
|
||||
// @cmember Assegna il documento corrente
|
||||
void set_doc(TDocumento * doc) { _doc = doc; }
|
||||
const TDocumento & doc() const { CHECK(_doc, "Documento nullo"); return *_doc;}
|
||||
@ -300,10 +317,10 @@ public:
|
||||
void set_fields(TAuto_variable_rectype & rec);
|
||||
|
||||
real prezzo(bool scontato, bool lordo, int ndec) const ;
|
||||
real importo(bool scontato, bool lordo, int ndec, bool iva_calc = FALSE) const ;
|
||||
real iva(int ndec) const {return ::iva(imponibile(), iva(), ndec);}
|
||||
real importo(bool scontato, bool lordo, int ndec) const ;
|
||||
real iva(int ndec) const;
|
||||
real imponibile() const;
|
||||
real imposta() const;
|
||||
real imposta(bool round = TRUE) const;
|
||||
|
||||
TRiga_documento(TDocumento* doc, const char * tipo = NULL);
|
||||
TRiga_documento(const TRiga_documento& rec, TDocumento* doc,
|
||||
@ -322,6 +339,7 @@ class TDocumento : public TAuto_variable_rectype
|
||||
TCond_vendita * _condv;
|
||||
TPagamento _pag;
|
||||
TRiga_documento * _sconto; // Riga per lo sconto di testata
|
||||
TRiga_documento * _esenzione; // Riga per l' esenzione iva
|
||||
|
||||
protected:
|
||||
TRiga_documento & row(int index);
|
||||
@ -329,6 +347,7 @@ protected:
|
||||
virtual void put_str(const char* fieldname, const char* val);
|
||||
long renum(long numdoc = 0);
|
||||
void set_riga_sconto();
|
||||
void set_riga_esenzione();
|
||||
|
||||
public:
|
||||
void dirty_fields();
|
||||
@ -345,14 +364,14 @@ public:
|
||||
virtual void zero(const char * fieldname);
|
||||
virtual void zero(char c = '\0');
|
||||
|
||||
int rows() const { return _rows.rows() + ((_sconto != NULL) ? 1 : 0); }
|
||||
int rows() const { return _rows.rows() + ((_sconto != NULL) ? 1 : 0) + ((_esenzione != NULL) ? 1 : 0); }
|
||||
const TRiga_documento& operator[](int index) const { return (const TRiga_documento&)((TDocumento *)this)->row(index); }
|
||||
TRiga_documento& operator[](int index) { return (TRiga_documento&)row(index); }
|
||||
|
||||
TRiga_documento& insert_row(int row, const char *tipo = NULL);
|
||||
TRiga_documento& new_row(const char *tipo = NULL);
|
||||
bool destroy_row(int n, bool pack = FALSE) { return _rows.destroy_row(n, pack); }
|
||||
void destroy_rows() { _rows.destroy_rows(); }
|
||||
void destroy_rows() { _rows.destroy_rows(); }
|
||||
|
||||
int read(char provv, int anno, const char* codnum, long numdoc);
|
||||
int read(const TRectype& rec);
|
||||
@ -397,14 +416,16 @@ public:
|
||||
real spese() const;
|
||||
|
||||
TPagamento & pagamento();
|
||||
|
||||
|
||||
void update_spese_aut(TString_array & spese, bool preserve_old = FALSE, TSheet_field * sh = NULL);
|
||||
|
||||
TDocumento ();
|
||||
TDocumento(char provv, int anno, const char* codnum, long numdoc,
|
||||
TCond_vendita * condv = NULL, TRelation * rel = NULL);
|
||||
TDocumento(const TRectype& doc, TCond_vendita * condv = NULL,
|
||||
TRelation * rel = NULL);
|
||||
virtual ~TDocumento() { if (_sconto != NULL) delete _sconto;}
|
||||
};
|
||||
virtual ~TDocumento();
|
||||
};
|
||||
|
||||
class TDocumento_mask : public TVariable_mask
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user