Gestione lettere di esenzione

Ristrutturato oggetto cliente !!!!!!
Errori vari da Pg e Roberto


git-svn-id: svn://10.65.10.50/trunk@4637 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1997-06-12 16:26:22 +00:00
parent f8f4b4a93e
commit a1a4d6f19b
15 changed files with 810 additions and 767 deletions

View File

@ -38,7 +38,7 @@ STATIVALIDI=1,2,3,4,5
STATOFINALE=N STATOFINALE=N
[CANCELLAZIONE] [CANCELLAZIONE]
STATIVALIDI = 6,7 STATIVALIDI = 1,2,3,4,5
STATOFINALE = 4 STATOFINALE = 4
REMOVE = 0 REMOVE = 0

413
ve/clifor.cpp Executable file
View File

@ -0,0 +1,413 @@
#include "clifor.h"
#ifndef __CONFIG_H
#include "config.h"
#endif
#ifndef __VE0100_H
#include "ve0100.h"
#endif
#ifndef __VE0100O_H
#include "ve0100o.h"
#endif
#ifndef __VEINI_H
#include "veini.h"
#endif
#ifndef __VELIB_H
#include "velib.h"
#endif
TOccasionale::TOccasionale() : TRectype(LF_OCCAS)
{
_cod = new TRecfield(*this, OCC_CFPI);
}
TOccasionale::TOccasionale(const TRectype& r) : TRectype(r)
{
_cod = new TRecfield(*this, OCC_CFPI);
}
TRectype & TOccasionale::operator = (const TRectype& r)
{
return TRectype::operator=(r);
}
TOccasionale::~TOccasionale()
{
delete _cod;
}
int TCli_for::write_rewrite(TBaseisamfile& f, bool re) const
{
int err = TMultiple_rectype::write_rewrite(f, re);
if (err == NOERR)
{
TLocalisamfile v(LF_CFVEN);
TRectype & v_rec = vendite();
err = v.write(v_rec);
if (err == _isreinsert)
err = v.write(v_rec);
}
return err;
}
TRectype & TCli_for::vendite() const
{
const char t = tipo();
const long c = codice();
if (_ven_rec.empty() || t != *(const char *) (*_ven_tipo) || c != (long) *_ven_codice)
{
TLocalisamfile v(LF_CFVEN);
((TCli_for *)this)->_ven_rec.zero();
((TCli_for *)this)->_ven_rec.put(CFV_TIPOCF,t);
((TCli_for *)this)->_ven_rec.put(CFV_CODCF, c);
TRectype v_rec(_ven_rec);
if (((TCli_for *)this)->_ven_rec.read(v) != NOERR)
((TCli_for *)this)->_ven_rec = v_rec;
}
return (TRectype &) _ven_rec;
}
int TCli_for::read(TRectype & rec, word op, word lockop)
{
int err = TMultiple_rectype::read(rec, op, lockop);
_ven_rec.zero();
return err;
}
int TCli_for::read(char tipo, long codice, word op, word lockop)
{
zero();
put(CLI_TIPOCF, tipo);
put(CLI_CODCF, codice);
return TMultiple_rectype::read(op, lockop);
}
int TCli_for::remove(TBaseisamfile& f) const
{
TLocalisamfile v(LF_CFVEN);
const int err = vendite().remove(v);
if (err != NOERR && err != _iskeynotfound)
return err;
return TMultiple_rectype:: remove(f);
}
TCli_for::TCli_for(char tipo, long codice) : TMultiple_rectype( LF_CLIFO ), _ven_rec(LF_CFVEN)
{
_tipo = new TRecfield(*this, CLI_TIPOCF);
_codice = new TRecfield(*this, CLI_CODCF);
_ven_tipo = new TRecfield(_ven_rec, CFV_TIPOCF);
_ven_codice = new TRecfield(_ven_rec, CFV_CODCF);
add_file(LF_INDSP, IND_CODIND);
read(tipo, codice);
}
TCli_for::TCli_for(const TRectype & rec) : TMultiple_rectype(rec), _ven_rec(LF_CFVEN)
{
_tipo = new TRecfield(*this, CLI_TIPOCF);
_codice = new TRecfield(*this, CLI_CODCF);
_ven_tipo = new TRecfield(_ven_rec, CFV_TIPOCF);
_ven_codice = new TRecfield(_ven_rec, CFV_CODCF);
add_file(LF_INDSP, IND_CODIND);
read((TRectype &) rec);
}
TCli_for::TCli_for(const TCli_for & c) : TMultiple_rectype(c), _ven_rec(c._ven_rec)
{
_tipo = new TRecfield(*this, CLI_TIPOCF);
_codice = new TRecfield(*this, CLI_CODCF);
_ven_tipo = new TRecfield(_ven_rec, CFV_TIPOCF);
_ven_codice = new TRecfield(_ven_rec, CFV_CODCF);
}
TCli_for::~TCli_for()
{
delete _tipo;
delete _codice;
delete _ven_tipo;
delete _ven_codice;
}
/* void TCli_for_vendite::update_mask( TMask& m, TMask & occas_mask, bool onload )
{
const TString16 codval(m.get(F_CODVAL));
const TString16 datacambio(m.get(F_DATACAMBIO1));
// Setta i campi che appartengono al file LF_CLIFO
const bool occas = occasionale();
m.show(F_OCCASEDIT, occas);
// In forse per l'Occasionale, sicuri per il Normale
m.show(F_COFI, !occas);
m.show(F_STATOPAIVA, !occas);
m.show(F_PAIVA, !occas);
m.set(F_RAGSOC, get(CLI_RAGSOC));
m.enable(F_RAGSOC, !occas);
const TRectype & ven_rec = vendite();
if(!onload)
{
short pos = m.id2pos(F_CODVAL);
const TString & codval = get(CLI_CODVAL);
if (pos >= 0 && m.fld(pos).active())
m.fld(pos).set(codval);
pos = m.id2pos(F_CODVAL1);
if (pos >= 0 && m.fld(pos).active())
m.fld(pos).set(codval);
pos = m.id2pos(F_CODLIN);
if (pos >= 0 && m.fld(pos).active())
m.fld(pos).set(get(CLI_CODLIN));
m.set(F_CODPAG, get(CLI_CODPAG));
m.set(F_CODABIA, get(CLI_CODABI));
m.set(F_CODCABA, get(CLI_CODCAB));
// Setta i campi che appartengono al file LF_CFVEN
m.set(F_CODABIP, ven_rec.get(CFV_CODABIPR));
m.set(F_CODCABP, ven_rec.get(CFV_CODCABPR));
m.set(F_RAGGR, ven_rec.get(CFV_RAGGDOC));
m.set(F_CODINDSP, ven_rec.get(CFV_CODINDSP));
m.set(F_CODAG, ven_rec.get(CFV_CODAG));
m.set(F_CODSPMEZZO, ven_rec.get(CFV_CODSPMEZZO));
m.set(F_CODPORTO, ven_rec.get(CFV_CODPORTO));
m.set(F_CODNOTESP1, ven_rec.get(CFV_CODNOTESP1));
m.set(F_CODNOTESP2, ven_rec.get(CFV_CODNOTESP2));
m.set(F_CODNOTE, ven_rec.get(CFV_CODNOTE));
m.set(F_CODVETT1, ven_rec.get(CFV_CODVETT1));
m.set(F_CODVETT2, ven_rec.get(CFV_CODVETT2));
m.set(F_CODVETT3, ven_rec.get(CFV_CODVETT3));
m.set(F_SPESEINC, ven_rec.get(CFV_PERCSPINC));
m.set(F_ADDBOLLI, ven_rec.get(CFV_ADDBOLLI));
m.set(F_CATVEN, ven_rec.get(CFV_CATVEN));
pos = m.id2pos(F_CODLIST);
const TString & codlist = ven_rec.get(CFV_CODLIST);
if (pos >= 0 && m.fld(pos).active())
m.fld(pos).set(codlist);
pos = m.id2pos(F_CODLIST1);
if (pos >= 0 && m.fld(pos).active())
m.fld(pos).set(codlist);
if (m.id2pos(F_CODAG) >= 0 && m.field(F_CODAG).active())
m.set(F_CODAG, ven_rec.get(CFV_CODAG));
m.set(F_CODZON, ven_rec.get(CFV_CODZONA));
m.set(F_RAGGR, ven_rec.get(CFV_RAGGDOC));
}
if (occas)
{
m.reset(F_COFI);
m.reset(F_PAIVA);
m.reset(F_LOCALITACF);
m.set( F_OCFPI, occas_mask.get(O_CODICE));
m.set( F_RAGSOC, occas_mask.get(O_RAGSOC));
m.set( F_INDCF, occas_mask.get(O_INDIRIZZO));
m.set( F_CIVCF, occas_mask.get(O_NUMERO));
m.set( F_CAPCF, occas_mask.get(O_CAP));
m.set( F_COMCF, occas_mask.get(O_COMUNE));
m.set( F_STATOCF, occas_mask.get(O_STATO));
}
else
{
occas_mask.reset();
m.set(F_COFI, get(CLI_COFI));
m.set(F_INDCF, get(CLI_INDCF));
m.set(F_CIVCF, get(CLI_CIVCF));
m.set(F_STATOPAIVA, get(CLI_STATOPAIV));
m.set(F_PAIVA, get(CLI_PAIV));
m.set(F_LOCALITACF, get(CLI_LOCCF));
m.set(F_CAPCF, get(CLI_CAPCF));
m.set(F_COMCF, get(CLI_COMCF));
m.set(F_STATOCF, get(CLI_STATOCF));
}
const TString16 newcodval(m.get(F_CODVAL));
const TString16 newdatacambio(m.get(F_DATACAMBIO1));
short pos = m.id2pos(F_CAMBIO);
if ((pos >= 0) && (newcodval.empty() || newdatacambio.empty()))
m.fld(F_CAMBIO).reset();
pos = m.id2pos(F_CODVAL);
if (pos >= 0 && m.fld(pos).active())
m.fld(pos).check();
pos = m.id2pos(F_CODVAL1);
if (pos >= 0 && m.fld(pos).active())
m.fld(pos).check();
pos = m.id2pos(F_DATACAMBIO1);
if (pos >= 0 && m.field(pos).active() &&
(codval != newcodval || datacambio != newdatacambio))
m.fld(pos).check();
m.check_field(F_COMCF);
m.check_field(F_STATOCF);
m.check_field( F_CODPAG );
pos = m.id2pos(F_CODLIN);
if (pos >= 0 && m.fld(pos).active())
m.fld(pos).check();
m.check_field( F_CODCABA );
pos = m.id2pos(F_CODLIST);
if (pos >= 0 && m.fld(pos).active())
m.fld(pos).check();
pos = m.id2pos(F_CODLIST1);
if (pos >= 0 && m.fld(pos).active())
m.fld(pos).check();
m.check_field( F_CODCABP );
m.check_field( F_CODINDSP );
pos = m.id2pos(F_CODAG);
if (pos >= 0 && m.fld(pos).active())
m.fld(pos).check();
m.check_field( F_CODSPMEZZO );
m.check_field( F_CODPORTO );
m.check_field( F_CODNOTESP1 );
m.check_field( F_CODNOTESP2 );
m.check_field( F_CODNOTE );
m.check_field( F_CODVETT1 );
m.check_field( F_CODVETT2 );
m.check_field( F_CODVETT3 );
m.check_field( F_CATVEN );
m.check_field( F_CODZON );
const bool gescontr = app().config_ditta().get_bool("GES", "ve", 2);
const bool contr_enabled = ven_rec.get_bool(CFV_GESTCONTR);
m.enable(F_CODCONT1, contr_enabled && gescontr);
m.enable(F_CODCONT, contr_enabled && gescontr);
if (!onload)
{
imposta_indirizzo_spedizione(m, occas_mask);
imposta_sconto_testa(m);
imposta_spese(m);
}
}
void TCli_for::edita_occasionale( )
{
CHECK( occasionale( ), "Impossibile editare come occasionale un cliente non occasionale!" );
_occas_mask.run( );
};
bool TCli_for::occas_code_handler(TMask_field& f, KEY key)
{
if (key == K_TAB)
{
const char* code = f.get();
if (*code)
{
TRelation occas(LF_OCCAS);
occas.lfile().put("CFPI", code);
if (occas.read(_isequal) == NOERR)
{
f.mask().autoload(occas);
f.mask().send_key(K_TAB, O_COMUNE); // Forza decodifica comuni
f.mask().send_key(K_TAB, O_COMUNENAS);
}
}
}
return TRUE;
}
void TCli_for_vendite::imposta_indirizzo_spedizione(TMask& m, TMask & occas_mask)
{
const bool occas = occasionale();
m.enable( F_CODINDSP , !occas);
if (occas)
{
m.reset( F_CODINDSP);
m.set( F_RAGSOCSP, occas_mask.get(O_RAGSOC));
m.set( F_INDSP, occas_mask.get(O_INDIRIZZO));
m.set( F_CIVSP, occas_mask.get(O_NUMERO));
// Sugli occasionali non c'è la località
m.reset( F_LOCALITASP);
m.set( F_CAPSP, occas_mask.get(O_CAP));
m.set( F_COMSP, occas_mask.get(O_COMUNE));
m.check_field(F_COMSP);
m.set( F_STATOSP, occas_mask.get(O_STATO));
m.check_field(F_STATOSP);
}
}
void TCli_for_vendite::imposta_sconto_testa( TMask& m )
{
TConfig & ditta = app().config_ditta();
const char tipogestione = ditta.get("GESSCO", "ve")[ 0 ];
switch( tipogestione )
{
case 'N': // Sconti non gestiti: pussa via!
break;
case 'P': // Percentuale su anagrafica cliente
m.set( F_SCONTOPERC, get(CLI_SCONTO));
break;
case 'T': // Gestione tabella sconti
{
const TString16 codsconto(vendite().get(CFV_CODSCC));
if (codsconto.not_empty())
{
TTable sconti("%SCC");
sconti.setkey(1);
sconti.zero();
sconti.put("CODTAB", codsconto);
if (sconti.read( ) == NOERR)
m.set(F_SCONTOPERC, sconti.get("S1"));
}
}
break;
case 'A': // Gestione archivio sconti
{
TString16 cod;
const TRectype & ven_rec = vendite();
TLocalisamfile sconti(LF_SCONTI );
sconti.setkey(1);
sconti.zero();
sconti.put("TIPO", "I");
if(ditta.get_bool("SCOKEY", "ve", 1))
sconti.put("CODCAT", ven_rec.get(CFV_CATVEN));
if(ditta.get_bool("SCOKEY", "ve", 2))
cod = ven_rec.get(CFV_CODSCC);
else
cod = " ";
if( ditta.get_bool("SCOKEY", "ve", 3))
cod << ven_rec.get(CFV_CODZONA);
else
cod << " ";
if( ditta.get_bool("SCOKEY", "ve", 4))
cod << get(CLI_CODPAG);
sconti.put("CODART", cod);
if(sconti.read() == NOERR)
m.set(F_SCONTOPERC, sconti.get( "SCONTO"));
}
break;
default:
break;
}
return;
}
void TCli_for_vendite::imposta_spese( TMask& m )
{
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(name));
if (s.not_empty())
spese.add(s);
}
m.autosave(*app().get_relation());
doc.update_spese_aut(spese, FALSE, &sh);
sh.force_update();
}
*/

81
ve/clifor.h Executable file
View File

@ -0,0 +1,81 @@
#ifndef __CLIFOR_H
#define __CLIFOR_H
#ifndef __MULTIREC_H
#include <multirec.h>
#endif
#ifndef __MASK_H
#include <mask.h>
#endif
#ifndef __LFFILES_H
#include <lffiles.h>
#endif
#ifndef __CLIFO_H
#include <clifo.h>
#endif
#ifndef __CFVEN_H
#include <cfven.h>
#endif
#ifndef __INDSP_H
#include <indsp.h>
#endif
#ifndef __OCCAS_H
#include <occas.h>
#endif
class TOccasionale : public TRectype
{
TRecfield * _cod;
public:
const char * codice() const { return (const char *) *_cod;}
TRectype & operator = (const TRectype& r);
TOccasionale();
TOccasionale(const TRectype& r);
virtual ~TOccasionale();
};
class TCli_for : public TMultiple_rectype
{
TRecfield * _tipo;
TRecfield * _codice;
TRecfield * _ven_tipo;
TRecfield * _ven_codice;
TRectype _ven_rec;
protected:
virtual int write_rewrite(TBaseisamfile& f, bool re = FALSE) const;
public:
bool occasionale() const { return get_bool(CLI_OCCAS ); };
TRectype & vendite() const;
// TMask& occas_mask( ){ return _occas_mask; };
// static bool occas_code_handler(TMask_field& f, KEY key);
// int write_occas( );
// void edita_occasionale( );
char tipo() const { return *(const char *) (*_tipo); }
long codice() const { return (long) *_codice; }
bool ok() const { return !empty();}
virtual int read(TRectype & rec, word op = _isequal, word lockop = _nolock);
int read(char tipo, long codice, word op = _isequal, word lockop = _nolock);
virtual int remove(TBaseisamfile& f) const;
// int remove() const { return TMultiple_rectype::remove();}
TCli_for(char tipo = ' ', long codice = 0L);
TCli_for(const TRectype & rec);
TCli_for(const TCli_for & c);
virtual ~TCli_for();
};
#endif

View File

@ -10,10 +10,6 @@
#include "verig.h" #include "verig.h"
#endif #endif
#ifndef __TCLIFOR_H
#include "tclifor.h"
#endif
#ifndef __CONFIG_H #ifndef __CONFIG_H
#include "config.h" #include "config.h"
#endif #endif
@ -187,8 +183,8 @@ bool TCond_vendita::cerca( int tiporicerca )
_condv.put("TIPO", "C"); _condv.put("TIPO", "C");
if(config_ditta().get_bool("GESCONCC", "ve")) if(config_ditta().get_bool("GESCONCC", "ve"))
{ {
_condv.put("TIPOCF", clifo().tipocf()); _condv.put("TIPOCF", clifo().tipo());
_condv.put("CODCF", clifo().codcf()); _condv.put("CODCF", clifo().codice());
} }
_condv.put("COD", codcont); _condv.put("COD", codcont);
} }
@ -313,7 +309,7 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only)
TString codart = anamag().get( "CODART" ); TString codart = anamag().get( "CODART" );
const TString codriga = riga().get( FR_CODART ); const TString codriga = riga().get( FR_CODART );
_ivarid = _clifo->get_bool(LF_CFVEN, "IVARID"); _ivarid = clifo().vendite().get_bool(CFV_IVARID);
_load_mask = !load_um_only && !load_scagl_only; _load_mask = !load_um_only && !load_scagl_only;
if(anamag().bad() || codriga != codart ) if(anamag().bad() || codriga != codart )
@ -391,7 +387,7 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only)
_sconti.setkey(1); _sconti.setkey(1);
_sconti.put("TIPO", "R"); _sconti.put("TIPO", "R");
if( config_ditta().get_bool("GESSCORIGACV", "ve")) if( config_ditta().get_bool("GESSCORIGACV", "ve"))
_sconti.put("CODCAT", clifo().get(LF_CFVEN, "CATVEN")); _sconti.put("CODCAT", clifo().vendite().get(CFV_CATVEN));
if (sco_um_gest) if (sco_um_gest)
_sconti.put("UM", riga().get( FR_UMQTA)); _sconti.put("UM", riga().get( FR_UMQTA));
_sconti.put("TIPORIGA", rigakey); _sconti.put("TIPORIGA", rigakey);
@ -422,8 +418,9 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only)
} }
break; break;
default: default:
error_box("Tipo di chiave righe sconti '%c' non valida!", rigakey); _sconti.put("CODART", codriga);
break; _sconti.read();
break;
} }
const bool found = _sconti.good(); const bool found = _sconti.good();
@ -457,10 +454,10 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only)
} }
break; break;
case 'C': case 'C':
set_sconto(clifo().get(LF_CFVEN, "SCONTO")); set_sconto(clifo().vendite().get(CFV_SCONTO));
break; break;
default: default:
error_box("Tipo di gestione sconti '%c' non valido!", gestione ); set_sconto("");
break; break;
} }
@ -486,7 +483,7 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only)
set_provv(age.get_real("R0")); set_provv(age.get_real("R0"));
break; break;
case 'C': case 'C':
set_provv(real(clifo().get(LF_CFVEN, "PERCPROVV"))); set_provv(real(clifo().vendite().get(CFV_PERCPROVV)));
break; break;
case 'L': case 'L':
if (found_condv) if (found_condv)
@ -503,20 +500,20 @@ void TCond_vendita::ricerca(bool load_um_only, bool load_scagl_only)
TString16 catven(testa().get(F_CATVEN)); TString16 catven(testa().get(F_CATVEN));
if (catven.empty()) if (catven.empty())
catven = clifo().get(LF_CFVEN, "CATVEN"); catven = clifo().vendite().get(CFV_CATVEN);
if (catven.not_empty()) if (catven.not_empty())
{ {
TTable cve("CVE"); TTable cve("CVE");
cve.put("CODART", codage); cve.put("CODTAB", catven);
if (cve.read() == NOERR) if (cve.read() == NOERR)
set_provv(cve.get_real("R0")); set_provv(cve.get_real("R0"));
} }
} }
break; break;
default: default:
error_box("Tipo di gestione provvigioni '%c' non valido!", tipoprovv ); set_provv("");
break; break;
} }
} }
@ -579,7 +576,7 @@ void TCond_vendita::update_omaggi(bool full)
qta *= _rcondv.get_real("QOM"); qta *= _rcondv.get_real("QOM");
r.put("QTA", qta); r.put("QTA", qta);
r.put("PREZZO", _rcondv.get("PROMAGGIO")); r.put("PREZZO", _rcondv.get("PROMAGGIO"));
const TString16 codiva_cli(_clifo->get(LF_CFVEN, "ASSFIS")); const TString16 codiva_cli(clifo().vendite().get(CFV_ASSFIS));
if (codiva_cli.not_empty()) if (codiva_cli.not_empty())
r.put("CODIVA", codiva_cli); r.put("CODIVA", codiva_cli);
else else
@ -595,7 +592,7 @@ void TCond_vendita::update_omaggi(bool full)
sh.force_update(); sh.force_update();
} }
TCond_vendita::TCond_vendita(TCliFor * clifo, TConfig * ditta, TDocumento_mask * testa, TMask * riga, TCond_vendita::TCond_vendita(TCli_for * clifo, TConfig * ditta, TDocumento_mask * testa, TMask * riga,
TLocalisamfile * anamag, TLocalisamfile * umart) TLocalisamfile * anamag, TLocalisamfile * umart)
: _clifo(clifo), _testa(testa), _riga(riga), : _clifo(clifo), _testa(testa), _riga(riga),
_condv( LF_CONDV ), _rcondv( LF_RCONDV ), _sconti( LF_SCONTI ), _condv( LF_CONDV ), _rcondv( LF_RCONDV ), _sconti( LF_SCONTI ),

View File

@ -6,7 +6,7 @@
#endif #endif
#ifndef __TCLIFOR_H #ifndef __TCLIFOR_H
#include "tclifor.h" #include "clifor.h"
#endif #endif
#ifndef __VELIB_H #ifndef __VELIB_H
@ -25,7 +25,7 @@ class TCond_vendita : public TObject
real _prezzo; real _prezzo;
real _provv; real _provv;
real _molt_sconto; real _molt_sconto;
TCliFor * _clifo; TCli_for * _clifo;
TLocalisamfile _condv; TLocalisamfile _condv;
TLocalisamfile _rcondv; TLocalisamfile _rcondv;
TLocalisamfile * _anamag; TLocalisamfile * _anamag;
@ -51,7 +51,7 @@ protected:
TLocalisamfile & umart() const { CHECK(_umart, "Anagrafica di unita' di misura magazzino non inizializzata") ; return *_umart; } TLocalisamfile & umart() const { CHECK(_umart, "Anagrafica di unita' di misura magazzino non inizializzata") ; return *_umart; }
public: public:
TCliFor & clifo() const { CHECK(_clifo, "Cliente/fornitore non inizializzato"); return * _clifo; } TCli_for & clifo() const { CHECK(_clifo, "Cliente/fornitore non inizializzato"); return * _clifo; }
bool set_sconto( const char * exp, bool signal = FALSE ); bool set_sconto( const char * exp, bool signal = FALSE );
const TString& get_sconto() const { return _sconto; } const TString& get_sconto() const { return _sconto; }
real sconto_val() const { return _molt_sconto;} real sconto_val() const { return _molt_sconto;}
@ -59,7 +59,8 @@ public:
real get_provv() const { return _provv; } real get_provv() const { return _provv; }
const TString & get_iva() const { return _codiva; } const TString & get_iva() const { return _codiva; }
void set_config( TConfig * ditta){ _config_ditta = ditta; } void set_clifo( TCli_for * clifo) { _clifo = clifo; }
void set_config( TConfig * ditta) { _config_ditta = ditta; }
void set_testa( TDocumento_mask * testa ){ _testa = testa; } void set_testa( TDocumento_mask * testa ){ _testa = testa; }
void set_riga( TMask * riga ){ _riga = riga; } void set_riga( TMask * riga ){ _riga = riga; }
void set_anamag(TLocalisamfile & anamag) { _anamag = &anamag; } void set_anamag(TLocalisamfile & anamag) { _anamag = &anamag; }
@ -67,7 +68,7 @@ public:
void ricerca(bool load_um_only = FALSE, bool load_scagl_only = FALSE); void ricerca(bool load_um_only = FALSE, bool load_scagl_only = FALSE);
bool gestum() const { return _condv.get_bool("GESTUM"); } bool gestum() const { return _condv.get_bool("GESTUM"); }
TCond_vendita(TCliFor * clifo = NULL, TConfig * _ditta = NULL, TDocumento_mask * testa = NULL, TMask * riga = NULL, TCond_vendita(TCli_for * clifo = NULL, TConfig * _ditta = NULL, TDocumento_mask * testa = NULL, TMask * riga = NULL,
TLocalisamfile * anamag = NULL, TLocalisamfile * umart = NULL); TLocalisamfile * anamag = NULL, TLocalisamfile * umart = NULL);
~TCond_vendita() {} ~TCond_vendita() {}
}; };

View File

@ -1,374 +0,0 @@
#ifndef __TCLIFOR_H
#include "tclifor.h"
#endif
#ifndef __CONFIG_H
#include "config.h"
#endif
#ifndef __VEUML1_H
#include "veuml1.h"
#endif
#ifndef __VE0100_H
#include "ve0100.h"
#endif
#ifndef __VE0100O_H
#include "ve0100o.h"
#endif
#ifndef __TABUTIL_H
#include <tabutil.h>
#endif
#ifndef __VEINI_H
#include "veini.h"
#endif
#ifndef __VELIB_H
#include <velib.h>
#endif
const TString& TData_picker::get( const TString& table, const TString& codtab, const TString& field )
{
TTable tab(table);
tab.zero();
tab.put( "CODTAB", codtab);
if (tab.read() != NOERR)
tab.zero();
return tab.get( field );
};
const TString& TData_picker::get( const int file, const TString& fieldname )
{
return lfile( file ).get( fieldname );
}
int TData_picker::get_int( const int file, const TString& fieldname )
{
return lfile( file ).get_int( fieldname );
}
long TData_picker::get_long( const int file, const TString& fieldname )
{
return lfile( file ).get_long( fieldname );
}
bool TData_picker::get_bool( const int file, const TString& fieldname )
{
return lfile( file ).get_bool( fieldname );
}
int TCliFor::write_occas( )
{
int err = NOERR;
if(occasionale())
{
TRelation occas( LF_OCCAS );
occas_mask( ).autosave( occas );
err = occas.write( );
if (err == _isreinsert)
err = occas.rewrite();
}
return err;
}
TCliFor::TCliFor( ) : TData_picker( LF_CLIFO ), _occas_mask( "ve0100o" ),
_tipocf(' '), _codcf(0L)
{
_occas_mask.set_handler( O_CODICE, occas_code_handler );
add( LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF" );
}
bool TCliFor::load( const char tipocf, const long codcf, const TString& ocfpi )
{
_valid = FALSE;
_tipocf = tipocf;
_codcf = codcf;
zero( );
if (tipocf == ' ' || codcf == 0L)
return TRUE;
curr( ).put( "TIPOCF", tipocf );
curr( ).put( "CODCF", codcf );
lfile( ).setkey( 1 );
if( read( ) == NOERR )
{
_occas = curr().get_bool( "OCCAS" );
if ( occasionale( ) )
{
TRelation occrel( LF_OCCAS );
occrel.curr().zero();
occrel.curr().put( "CFPI", ocfpi );
if (occrel.read(_isequal) != NOERR)
occrel.curr().zero();
occas_mask().autoload( occrel );
}
_valid = TRUE;
}
return _valid;
}
void TCliForVendite::update_mask( TMask& m, bool onload )
{
TString16 stato;
const TString16 codval(m.get(F_CODVAL));
const TString16 datacambio(m.get(F_DATACAMBIO1));
// Setta i campi che appartengono al file LF_CLIFO
// const bool occas = app().config_ditta().get_bool("GESOCCAS") && occasionale();
const bool occas = occasionale();
m.show(F_OCCASEDIT, occas);
// In forse per l'Occasionale, sicuri per il Normale
m.show(F_COFI, !occas);
m.show(F_STATOPAIVA, !occas);
m.show(F_PAIVA, !occas);
set(m, F_RAGSOC, LF_CLIFO, "RAGSOC" );
m.enable(F_RAGSOC, !occas);
if(!onload)
{
if (m.id2pos(F_CODVAL) >= 0 && m.field(F_CODVAL).active())
set( m, F_CODVAL, LF_CLIFO, "CODVAL" );
if (m.id2pos(F_CODVAL1) >= 0 && m.field(F_CODVAL1).active())
set( m, F_CODVAL1, LF_CLIFO, "CODVAL" );
if (m.id2pos(F_CODLIN) >= 0 && m.field(F_CODLIN).active())
set( m, F_CODLIN, LF_CLIFO, "CODLIN" );
set( m, F_CODPAG, LF_CLIFO, "CODPAG" );
set( m, F_CODABIA, LF_CLIFO, "CODABI" );
set( m, F_CODCABA, LF_CLIFO, "CODCAB" );
// Setta i campi che appartengono al file LF_CFVEN
set( m, F_CODABIP, LF_CFVEN, "CODABIPR" );
set( m, F_CODCABP, LF_CFVEN, "CODCABPR" );
set( m, F_RAGGR, LF_CFVEN, "RAGGDOC" );
set( m, F_CODINDSP, LF_CFVEN, "CODINDSP" );
set( m, F_CODAG, LF_CFVEN, "CODAG" );
set( m, F_CODSPMEZZO, LF_CFVEN, "CODSPMEZZO" );
set( m, F_CODPORTO, LF_CFVEN, "CODPORTO" );
set( m, F_CODNOTESP1, LF_CFVEN, "CODNOTESP1" );
set( m, F_CODNOTESP2, LF_CFVEN, "CODNOTESP2" );
set( m, F_CODNOTE, LF_CFVEN, "CODNOTE" );
set( m, F_CODVETT1, LF_CFVEN, "CODVETT1" );
set( m, F_CODVETT2, LF_CFVEN, "CODVETT2" );
set( m, F_CODVETT3, LF_CFVEN, "CODVETT3" );
set( m, F_SPESEINC, LF_CFVEN, "PERCSPINC" );
set( m, F_ADDBOLLI, LF_CFVEN, "ADDBOLLI" );
set(m, F_CATVEN, LF_CFVEN, "CATVEN");
if (m.id2pos(F_CODLIST) >= 0 && m.field(F_CODLIST).active())
set(m, F_CODLIST, LF_CFVEN, "CODLIST");
if (m.id2pos(F_CODLIST1) >= 0 && m.field(F_CODLIST1).active())
set(m, F_CODLIST1, LF_CFVEN, "CODLIST");
if (m.id2pos(F_CODAG) >= 0 && m.field(F_CODAG).active())
set(m, F_CODAG, LF_CFVEN, "CODAG");
set(m, F_CODZON, LF_CFVEN, "CODZONA");
set(m, F_RAGGR, LF_CFVEN, "RAGGDOC");
}
// if ( occasionale ( ) )
TMask & occ_mask = occas_mask();
if (occas)
{
m.set( F_COFI, "" );
m.set( F_PAIVA, "" );
m.set( F_LOCALITACF, "");
m.set( F_OCFPI, occ_mask.get( O_CODICE ) );
m.set( F_RAGSOC, occ_mask.get( O_RAGSOC ) );
m.set( F_INDCF, occ_mask.get( O_INDIRIZZO ) );
m.set( F_CIVCF, occ_mask.get( O_NUMERO ) );
m.set( F_CAPCF, occ_mask.get( O_CAP ) );
m.set( F_COMCF, occ_mask.get( O_COMUNE ) );
m.set( F_STATOCF, stato = occ_mask.get( O_STATO ) );
}
else
{
occ_mask.reset();
set( m, F_COFI, LF_CLIFO, "COFI" );
set( m, F_INDCF, LF_CLIFO, "INDCF" );
set( m, F_CIVCF, LF_CLIFO, "CIVCF" );
set( m, F_STATOPAIVA, LF_CLIFO, "STATOPAIV" );
set( m, F_PAIVA, LF_CLIFO, "PAIV" );
set( m, F_LOCALITACF, LF_CLIFO, "LOCALITACF" );
set( m, F_CAPCF, LF_CLIFO, "CAPCF" );
set( m, F_COMCF, LF_CLIFO, "COMCF" );
stato = get( LF_CLIFO, "STATOCF" );
m.set( F_STATOCF, stato );
}
const TString16 newcodval(m.get(F_CODVAL));
const TString16 newdatacambio(m.get(F_DATACAMBIO1));
if ((m.id2pos(F_CAMBIO) >= 0) && (newcodval.empty() || newdatacambio.empty()))
m.reset(F_CAMBIO);
if (m.id2pos(F_CODVAL) >= 0 && m.field(F_CODVAL).active())
m.check_field(F_CODVAL);
if (m.id2pos(F_CODVAL1) >= 0 && m.field(F_CODVAL1).active())
m.check_field(F_CODVAL1);
if (m.id2pos(F_DATACAMBIO1) >= 0 && m.field(F_DATACAMBIO1).active() &&
(codval != newcodval || datacambio != newdatacambio))
m.check_field(F_DATACAMBIO1);
m.check_field(F_COMCF);
m.check_field(F_STATOCF);
m.check_field( F_CODPAG );
if (m.id2pos(F_CODLIN) >= 0 && m.field(F_CODLIN).active())
m.check_field( F_CODLIN );
// m.check_field( F_CODABIA );
m.check_field( F_CODCABA );
// m.check_field( F_CODABIP );
if (m.id2pos(F_CODLIST) >= 0 && m.field(F_CODLIST).active())
m.check_field( F_CODLIST );
if (m.id2pos(F_CODLIST1) >= 0 && m.field(F_CODLIST1).active())
m.check_field( F_CODLIST1);
m.check_field( F_CODCABP );
m.check_field( F_CODINDSP );
if (m.id2pos(F_CODAG) >= 0 && m.field(F_CODAG).active())
m.check_field( F_CODAG );
m.check_field( F_CODSPMEZZO );
m.check_field( F_CODPORTO );
m.check_field( F_CODNOTESP1 );
m.check_field( F_CODNOTESP2 );
m.check_field( F_CODNOTE );
m.check_field( F_CODVETT1 );
m.check_field( F_CODVETT2 );
m.check_field( F_CODVETT3 );
m.check_field( F_CATVEN );
m.check_field( F_CODZON );
const bool gescontr = app().config_ditta().get_bool("GES", "ve", 2);
const bool contr_enabled = get_bool(LF_CFVEN, "GESTCONTR");
m.enable(F_CODCONT1, contr_enabled && gescontr);
m.enable(F_CODCONT, contr_enabled && gescontr);
if (!onload)
{
imposta_indirizzo_spedizione( m );
imposta_sconto_testa( m );
imposta_spese(m);
}
}
void TCliFor::edita_occasionale( )
{
CHECK( occasionale( ), "Impossibile editare come occasionale un cliente non occasionale!" );
_occas_mask.run( );
};
bool TCliFor::occas_code_handler(TMask_field& f, KEY key)
{
if (key == K_TAB)
{
const char* code = f.get();
if (*code)
{
TRelation occas(LF_OCCAS);
occas.lfile().put("CFPI", code);
if (occas.read(_isequal) == NOERR)
{
f.mask().autoload(occas);
f.mask().send_key(K_TAB, O_COMUNE); // Forza decodifica comuni
f.mask().send_key(K_TAB, O_COMUNENAS);
}
}
}
return TRUE;
}
void TCliForVendite::imposta_indirizzo_spedizione( TMask& m )
{
TString16 stato;
const bool occas = occasionale();
m.enable( F_CODINDSP , !occas);
if( occas )
{
m.set( F_CODINDSP, "" );
m.set( F_RAGSOCSP, occas_mask( ).get( O_RAGSOC ) );
m.set( F_INDSP, occas_mask( ).get( O_INDIRIZZO ) );
m.set( F_CIVSP, occas_mask( ).get( O_NUMERO ) );
// Sugli occasionali non c'è la località
m.set( F_LOCALITASP, "" );
m.set( F_CAPSP, occas_mask( ).get( O_CAP ) );
m.set( F_COMSP, occas_mask( ).get( O_COMUNE ) );
m.check_field(F_COMSP);
m.set( F_STATOSP, stato = occas_mask( ).get( O_STATO ) );
m.check_field(F_STATOSP);
}
}
void TCliForVendite::imposta_sconto_testa( TMask& m )
{
TConfig & ditta = app().config_ditta();
const char tipogestione = ditta.get("GESSCO", "ve")[ 0 ];
switch( tipogestione )
{
case 'N': // Sconti non gestiti: pussa via!
break;
case 'P': // Percentuale su anagrafica cliente
m.set( F_SCONTOPERC, get( LF_CFVEN, "SCONTO" ) );
break;
case 'T': // Gestione tabella sconti
{
const TString16 codsconto(get(LF_CFVEN, "CODSCC"));
if (codsconto.not_empty())
{
TTable sconti("%SCC");
sconti.setkey(1);
sconti.zero();
// sconti.put( "TIPO", "D" );
sconti.put("CODTAB", codsconto);
if (sconti.read( ) == NOERR)
m.set(F_SCONTOPERC, sconti.get("S1"));
}
}
break;
case 'A': // Gestione archivio sconti
{
TString16 codart;
TLocalisamfile sconti( LF_SCONTI );
sconti.setkey(1);
sconti.zero();
sconti.put("TIPO", "I");
if(ditta.get_bool("SCOKEY", "ve", 1))
sconti.put("CODCAT", get( LF_CFVEN, "CATVEN"));
if(ditta.get_bool("SCOKEY", "ve", 2))
codart = get( LF_CFVEN, "CODSCC" );
else
codart = " ";
if( ditta.get_bool("SCOKEY", "ve", 3))
codart << get(LF_CFVEN, "CODZONA");
else
codart << " ";
if( ditta.get_bool("SCOKEY", "ve", 4))
codart << get(LF_CLIFO, "CODPAG");
sconti.put("CODART", codart);
if(sconti.read() == NOERR)
m.set(F_SCONTOPERC, sconti.get( "SCONTO"));
}
break;
default:
break;
}
return;
}
void TCliForVendite::imposta_spese( TMask& m )
{
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();
}

View File

@ -1,64 +0,0 @@
#ifndef __TCLIFOR_H
#define __TCLIFOR_H
#ifndef __RELATION_H
#include <relation.h>
#endif
#ifndef __VARMASK_H
#include <varmask.h>
#endif
class TData_picker : public TRelation
{
public:
TData_picker( const int mainfile ) : TRelation ( mainfile ) { }
virtual ~TData_picker() {}
const TString& get( const TString& table, const TString& codtab, const TString& field );
const TString& get( const int file, const TString& fieldname );
int get_int( const int file, const TString& fieldname );
long get_long( const int file, const TString& fieldname );
bool get_bool( const int file, const TString& fieldname );
void set( TMask& m, const int mskfield, const int file, const TString& filefield ){ m.set( mskfield, get( file, filefield ) ); };
};
class TCliFor : public TData_picker
{
private:
bool _occas;
TMask _occas_mask;
bool _valid;
protected:
char _tipocf;
long _codcf;
public:
TCliFor( );
bool load( const char tipocf, const long codcf, const TString& ocfpi );
bool occasionale( ){ return get_bool( LF_CLIFO, "OCCAS" ); };
TMask& occas_mask( ){ return _occas_mask; };
static bool occas_code_handler(TMask_field& f, KEY key);
int write_occas( );
void edita_occasionale( );
char tipocf( ){ return _tipocf; }
long codcf( ){ return _codcf; }
bool ok() { return _valid;}
};
class TCliForVendite : public TCliFor
{
public:
void update_mask( TMask& m, bool onload = FALSE );
void imposta_indirizzo_spedizione( TMask& m );
void imposta_sconto_testa( TMask& m );
void imposta_spese( TMask& m );
};
#endif

View File

@ -10,8 +10,8 @@
#include "veini.h" #include "veini.h"
#endif #endif
#ifndef __MGLIB01_H #ifndef __MGLIB_H
#include "..\mg\mglib01.h" #include "..\mg\mglib.h"
#endif #endif
#ifndef __UTILITY_H #ifndef __UTILITY_H
@ -57,7 +57,7 @@ void TMotore_application::init_insert_mode( TMask& m )
if (pos >= 0 && m.fld(pos).active()) if (pos >= 0 && m.fld(pos).active())
m.fld(pos).set(data_doc); m.fld(pos).set(data_doc);
m.disable(DLG_PRINT); m.disable(DLG_PRINT);
clifo( ).occas_mask( ).reset( ); _occas_mask->reset( );
const int ndefaults = pro( ).get_int( "NDEFAULTS", "DEFAULT" ); // prof const int ndefaults = pro( ).get_int( "NDEFAULTS", "DEFAULT" ); // prof
for( int i = 1; i <= ndefaults; i++ ) for( int i = 1; i <= ndefaults; i++ )
@ -90,16 +90,16 @@ void TMotore_application::update_profile()
_pro = new TConfig( fn ); _pro = new TConfig( fn );
} }
int TMotore_application::user_function( int index ) int TMotore_application::user_function(int index)
{ {
switch( index ) switch(index)
{ {
case 1: case 1:
break; break;
default: default:
yesnofatal_box( "Chiamata ad una procedura utente non definita: %d", index ); yesnofatal_box( "Chiamata ad una procedura utente non definita: %d", index );
return NOERR; return NOERR;
break; break;
} }
return NOERR; return NOERR;
} }
@ -176,9 +176,10 @@ bool TMotore_application::ss_handler( TSheet_field& ss, int r, KEY key )
if (key == K_CTRL + K_INS) if (key == K_CTRL + K_INS)
{ {
TRiga_documento & riga = (*(app()._doc))[r + 1]; TRiga_documento & riga = (*(app()._doc))[r + 1];
TString16 s(app()._clifor->get(LF_CFVEN, "CODMAG")); TRectype & ven_rec = app().doc().clifor().vendite();
TString16 s(ven_rec.get(CFV_CODMAG));
s << app()._clifor->get(LF_CFVEN, "CODDEP"); s << ven_rec.get(CFV_CODDEP);
riga.put("CODMAG", s); riga.put("CODMAG", s);
riga.autoload(ss); riga.autoload(ss);
ss.check_row(r); ss.check_row(r);
@ -271,16 +272,54 @@ bool TMotore_application::print_handler( TMask_field& f, KEY key )
return TRUE; return TRUE;
} }
bool TMotore_application::occas_code_handler(TMask_field& f, KEY key)
{
if (key == K_TAB && f.focusdirty())
{
const char* code = f.get();
if (*code)
{
TRelation occas(LF_OCCAS);
occas.lfile().put("CFPI", code);
if (occas.read(_isequal) == NOERR)
{
f.mask().autoload(occas);
f.mask().send_key(K_TAB, O_COMUNE); // Forza decodifica comuni
f.mask().send_key(K_TAB, O_COMUNENAS);
}
}
}
return TRUE;
}
bool TMotore_application::occas_handler( TMask_field& f, KEY key ) bool TMotore_application::occas_handler( TMask_field& f, KEY key )
{ {
TMask & m = f.mask(); TDocumento_mask & m = (TDocumento_mask &)f.mask();
if ( key == K_SPACE && m.is_running( ) ) if ( key == K_SPACE && m.is_running( ) )
{ {
TMask& om = app( ).clifo( ). occas_mask( ); TDocumento & doc = app().doc();
if (om.run( ) != K_ESC) TMask * occ_m = app()._occas_mask;
app().clifo().update_mask(m); TOccasionale & occ = doc.occas();
TCli_for & cli_for = doc.clifor();
for (int i = occ_m->fields() - 1; i >= 0; i--)
{
TMask_field & f = occ_m->fld(i);
const TFieldref * c = f.field();
if (c)
f.set(c->read(occ));
}
if (occ_m->run() != K_ESC)
{
doc.put("OCFPI", occ_m->get(O_CODICE));
for (int i = occ_m->fields() - 1; i >= 0; i--)
{
TMask_field & f = occ_m->fld(i);
TFieldref * c = (TFieldref *) f.field();
if (c)
c->write(f.get(), occ);
}
m.occ2mask(occ);
}
f.set_focus( ); f.set_focus( );
} }
return TRUE; return TRUE;
@ -328,29 +367,29 @@ bool TMotore_application::tip_handler( TMask_field& f, KEY key )
bool TMotore_application::clifo_handler( TMask_field& f, KEY key ) bool TMotore_application::clifo_handler( TMask_field& f, KEY key )
{ {
if (key == K_ENTER) if (key != K_ENTER && f.to_check(key, TRUE))
return TRUE;
if (f.to_check(key, TRUE))
{ {
const char cf = app().tipocf(); TDocumento & d = app().doc();
TMask& m = f.mask(); TDocumento_mask & m = (TDocumento_mask &) f.mask();
TLocalisamfile& clifo = ((TEdit_field&)f).browse()->cursor()->file(); const TString & val = f.get();
const long codcf = atol(f.get());
if ( clifo.get_bool("SOSPESO") ) d.put("TIPOCF", app().tipocf());
return f.error_box( "Il codice '%ld' e' sospeso e non puo' essere utilizzato", codcf ); d.put("CODCF", atol(val));
const TString80 occas_cod(app().clifo().occas_mask().get(O_CODICE));
if (app().clifo().load( cf, codcf, occas_cod)) app().doc().clifor().put(CLI_CODCF, ""); // force reload
TCli_for & cli_for = app().doc().clifor();
TOccasionale & occas = app().doc().occas();
if ( cli_for.get_bool("SOSPESO") )
return f.error_box( "Il codice '%ld' e' sospeso e non puo' essere utilizzato", atol(val) );
m.cli2mask(cli_for, occas, *(app()._config_ditta));
if (cli_for.occasionale())
{ {
app().clifo().update_mask(m, !m.is_running()); if(m.id2pos(F_OCCASEDIT) > 0 && f.to_check(key) && *(occas.codice()) == '\0')
if( f.mask().id2pos(F_OCCASEDIT) > 0 && f.to_check(key)) m.send_key( K_SPACE, F_OCCASEDIT ); // Lancia maschera occasionali
{
if ( app().clifo().occasionale() && app().clifo().occas_mask().get(O_CODICE).empty() )
m.send_key( K_SPACE, F_OCCASEDIT ); // Lancia maschera occasionali
}
} }
else else
return FALSE; app().doc().zero("OCFPI");
} }
return TRUE; return TRUE;
} }
@ -612,19 +651,14 @@ const char* TMotore_application::get_next_key( )
int TMotore_application::read( TMask& m ) int TMotore_application::read( TMask& m )
{ {
const int err = _doc->read(_doc->head()); // const int err = _doc->read(_doc->head());
if ( err == NOERR ) // if ( err == NOERR )
{ // {
m.autoload(*_rel); m.autoload(*_rel);
_codnum = m.get(F_CODNUM); _codnum = m.get(F_CODNUM);
_tipodoc = m.get(F_TIPODOC); _tipodoc = m.get(F_TIPODOC);
const char tipocf = _doc->get("TIPOCF")[0]; ((TDocumento_mask &)m).cli2mask(app().doc().clifor(), app().doc().occas(), *(app()._config_ditta));
const long codcf = _doc->get_long("CODCF");
const TString occas_cod(_doc->get("OCFPI"));
clifo().load( tipocf, codcf, occas_cod);
clifo().update_mask( ( TVariable_mask& ) m, TRUE );
TSheet_field& f = ( TSheet_field& ) m.field( F_SHEET ); TSheet_field& f = ( TSheet_field& ) m.field( F_SHEET );
@ -639,8 +673,9 @@ int TMotore_application::read( TMask& m )
rec.autoload(f); rec.autoload(f);
f.check_row(i - 1); f.check_row(i - 1);
} }
} // }
return err; // return err;
return NOERR;
} }
int TMotore_application::write( const TMask& m ) // C 90 int TMotore_application::write( const TMask& m ) // C 90
@ -650,14 +685,8 @@ int TMotore_application::write( const TMask& m ) // C 90
if (err == NOERR) if (err == NOERR)
{ {
m.field(F_STATO).set( _pro->get( "STATOFINALE", "INSERIMENTO" ) ); m.field(F_STATO).set( _pro->get( "STATOFINALE", "INSERIMENTO" ) );
if ( m.id2pos( F_OCCASEDIT) > 0 ) m.autosave(*_rel);
err = app().clifo().write_occas(); err = _doc->write( );
if ( err == NOERR )
{
m.autosave(*_rel);
_doc->put("OCFPI", app().clifo().occas_mask().get(O_CODICE));
err = _doc->write( );
}
if (err == NOERR) if (err == NOERR)
_rel->read(); // per posizionare correttamente la relazione _rel->read(); // per posizionare correttamente la relazione
} }
@ -673,14 +702,8 @@ int TMotore_application::rewrite( const TMask& m ) // C 90
if (err == NOERR) if (err == NOERR)
{ {
if ( m.id2pos( F_OCCASEDIT) > 0 ) m.autosave(*_rel);
err = app( ).clifo( ).write_occas( ); err = _doc->rewrite( );
if ( err == NOERR )
{
m.autosave(*_rel);
_doc->put("OCFPI", app().clifo().occas_mask().get(O_CODICE));
err = _doc->rewrite( );
}
} }
return err; return err;
} }
@ -722,24 +745,24 @@ bool TMotore_application::user_create( )
// Metto in relazione testata e righe // Metto in relazione testata e righe
_rel = new TRelation( LF_DOC ); _rel = new TRelation( LF_DOC );
open_files(LF_RIGHEDOC, LF_CONDV, LF_RCONDV, LF_ANAMAG, LF_SCONTI, LF_UMART, LF_TAB, LF_TABCOM, 0); open_files(LF_RIGHEDOC, LF_CONDV, LF_RCONDV, LF_ANAMAG, LF_SCONTI, LF_UMART, LF_TAB, LF_TABCOM, LF_CLIFO,
LF_CFVEN, LF_INDSP, LF_OCCAS, 0);
_doc = new TDocumento; _doc = new TDocumento;
_rel->lfile().set_curr(_doc); _rel->lfile().set_curr(_doc);
_doc->set_relation(_rel); _doc->set_relation(_rel);
_clifor = new TCliForVendite( ); _condv = new TCond_vendita(&doc().clifor(), _config_ditta);
_condv = new TCond_vendita(_clifor, _config_ditta);
_doc->set_condv(_condv); _doc->set_condv(_condv);
_msk = new TMask( "ve0100a" ); _msk = new TMask("ve0100a");
query_mask( ).set_handler( F_CODNUM, num_handler ); query_mask( ).set_handler( F_CODNUM, num_handler );
query_mask( ).set_handler( F_TIPODOC, tip_handler ); _occas_mask = new TMask("ve0100o");
_occas_mask->set_handler( O_CODICE, occas_code_handler );
TConfig utente( CONFIG_USER ); TConfig utente( CONFIG_USER );
_codnum = utente.get("CODNUM"); _codnum = utente.get("CODNUM");
_tipodoc = utente.get("TIPODOC"); _tipodoc = utente.get("TIPODOC");
// _msk->set(F_CODNUM, utente.get("CODNUM"));
// _msk->set(F_TIPODOC, utente.get("TIPODOC"));
// La maschera di inserimento/modifica per ora non la so! // La maschera di inserimento/modifica per ora non la so!
// Viene letta dal profilo non appena trovato il record // Viene letta dal profilo non appena trovato il record

View File

@ -77,10 +77,6 @@
#include "ve0100d.h" #include "ve0100d.h"
#endif #endif
#ifndef __TCLIFOR_H
#include "tclifor.h"
#endif
#ifndef __VARMASK_H #ifndef __VARMASK_H
#include <varmask.h> #include <varmask.h>
#endif #endif
@ -111,6 +107,7 @@ class TMotore_application : public TRelation_application
// Puntatore alla maschera di ricerca // Puntatore alla maschera di ricerca
TMask * _msk; TMask * _msk;
TMask * _occas_mask;
// puntatore alla relazione // puntatore alla relazione
TRelation * _rel; TRelation * _rel;
@ -119,7 +116,7 @@ class TMotore_application : public TRelation_application
TSheet_field * _sheet; TSheet_field * _sheet;
// Oggetto cliente per il motore // Oggetto cliente per il motore
TCliForVendite * _clifor; // TCli_for_vendite * _clifor;
TCond_vendita * _condv; TCond_vendita * _condv;
@ -190,6 +187,7 @@ protected:
static bool ndoc_handler( TMask_field& f, KEY key ); static bool ndoc_handler( TMask_field& f, KEY key );
static bool num_handler( TMask_field& f, KEY key ); static bool num_handler( TMask_field& f, KEY key );
static bool tip_handler( TMask_field& f, KEY key ); static bool tip_handler( TMask_field& f, KEY key );
static bool occas_code_handler(TMask_field& f, KEY key);
// Handler per la maschera di modifica // Handler per la maschera di modifica
static bool clifo_handler( TMask_field& f, KEY key ); static bool clifo_handler( TMask_field& f, KEY key );
@ -212,7 +210,6 @@ public:
TMask & edit_mask() { return (TMask &) _doc_masks[_doc->tipo().codice()]; } TMask & edit_mask() { return (TMask &) _doc_masks[_doc->tipo().codice()]; }
TRelation & rel() { CHECK( _rel, "Relazione nulla!" ); return *_rel; } TRelation & rel() { CHECK( _rel, "Relazione nulla!" ); return *_rel; }
TSheet_field & sheet() { CHECK( _sheet, "Sheet nullo!" ); return *_sheet; } TSheet_field & sheet() { CHECK( _sheet, "Sheet nullo!" ); return *_sheet; }
TCliForVendite & clifo() { CHECK( _clifor, "Oggetto cliente nullo!" ); return *_clifor; }
TCond_vendita & condv() { return *_condv; } TCond_vendita & condv() { return *_condv; }
TConfig & config_ditta() {return *_config_ditta; } TConfig & config_ditta() {return *_config_ditta; }
TLista_elaborazioni & elab() { return _elab; } TLista_elaborazioni & elab() { return _elab; }

View File

@ -75,8 +75,7 @@ class TDocumento_form : public TForm
TTable *_tip; TTable *_tip;
TRelation &_firmrel; // relazione di gestione dei dati della ditta corrente TRelation &_firmrel; // relazione di gestione dei dati della ditta corrente
TString _module; // codice del modulo di carta associato a questo al form TString _module; // codice del modulo di carta associato a questo al form
TCliFor *_cliente; // oggetto per le informazioni sul cliente TCond_vendita * _condv;
TCond_vendita *_condv; //
TString_array _exclude_array; // array di coppie tipo/articolo da escludere dalla stampa TString_array _exclude_array; // array di coppie tipo/articolo da escludere dalla stampa
TDocumentoEsteso * _doc; // Documento da stampare TDocumentoEsteso * _doc; // Documento da stampare
int _final_status; // stato finale del documento int _final_status; // stato finale del documento
@ -173,12 +172,13 @@ TDocumento_form::TDocumento_form(TRectype&/*TDocumentoEsteso**/ doc, TRelation&
read(nomeform); read(nomeform);
_cliente= new TCliFor;
_cli_loaded= FALSE; _cli_loaded= FALSE;
_is_lista = FALSE; _is_lista = FALSE;
_condv = new TCond_vendita(_cliente); _condv = new TCond_vendita(_cliente);
_doc = new TDocumentoEsteso(doc,_condv); // istanzia TDocumentoEsteso _condv = new TCond_vendita(NULL);
_doc = new TDocumentoEsteso(doc, _condv); // istanzia TDocumentoEsteso
_condv->set_clifo(&_doc->clifor());
_docfile = new TDocisamfile(_doc); _docfile = new TDocisamfile(_doc);
_rdocfile = new TRDocisamfile(_doc); _rdocfile = new TRDocisamfile(_doc);
relation()->replace(_docfile,0); relation()->replace(_docfile,0);
@ -223,7 +223,6 @@ TDocumento_form::TDocumento_form(const char* form, TRelation& rel): TForm(form),
_rdocfile=NULL; _rdocfile=NULL;
_tip = new TTable("%TIP"); _tip = new TTable("%TIP");
_tab = new TLocalisamfile(LF_TAB); _tab = new TLocalisamfile(LF_TAB);
_cliente= new TCliFor;
_cli_loaded= FALSE; _cli_loaded= FALSE;
_doc = new TDocumentoEsteso; _doc = new TDocumentoEsteso;
_docfile = new TDocisamfile(_doc); _docfile = new TDocisamfile(_doc);
@ -232,7 +231,6 @@ TDocumento_form::TDocumento_form(const char* form, TRelation& rel): TForm(form),
TDocumento_form::~TDocumento_form() TDocumento_form::~TDocumento_form()
{ {
delete _cliente;
//if (_doc) delete _doc; //if (_doc) delete _doc;
if (_tip) delete _tip; if (_tip) delete _tip;
if (_tab) delete _tab; if (_tab) delete _tab;
@ -656,7 +654,8 @@ bool TDocumento_form::validate(TForm_item &cf, TToken_string &s) {
return (TRUE); return (TRUE);
} // fine _DITTA } // fine _DITTA
if (code== "_CLIENTE") { if (code== "_CLIENTE")
{
// lettura dei dati del cliente // lettura dei dati del cliente
// sintassi: _CLIENTE,{<campo relazione>|<macro>} // sintassi: _CLIENTE,{<campo relazione>|<macro>}
// dove: <campo relazione> è un riferimento alla relazione di gestione dei dati del cliente // dove: <campo relazione> è un riferimento alla relazione di gestione dei dati del cliente
@ -678,73 +677,61 @@ bool TDocumento_form::validate(TForm_item &cf, TToken_string &s) {
// !TEL2 secondo numero di telefono (con prefisso) // !TEL2 secondo numero di telefono (con prefisso)
// !TEL3 terzo numero di telefono (con prefisso) // !TEL3 terzo numero di telefono (con prefisso)
// !FAX numero di fax (con prefisso) // !FAX numero di fax (con prefisso)
// nota: la relazione del cliente è così strutturata: TCli_for & cli_for = _doc->clifor();
// CLIFO (20) Clienti/fornitori
// + CFVEN (17) Clienti/fornitori per vendite
// + %COMUNI (113@) Comune di residenza
// + %COMUNI (213@) Comune di nascita
TLocalisamfile &doc= (cursor())->file(LF_DOC);
TString16 tipocf= doc.get("TIPOCF"), codcf= doc.get("CODCF"), ocfpi= doc.get("OCFPI");
if (!_cli_loaded || _is_lista) { // il cliente è sulla testata del documento di vendita, quindi può essere caricato una volta sola per tutte
_cliente->load(tipocf[0], atol(codcf), ocfpi);
_cliente->add(LF_COMUNI, "COM=STATOCF+COMCF", 1, LF_CLIFO, 100+LF_COMUNI);
_cliente->add(LF_COMUNI, "COM=STATONASC+COMNASC", 1, LF_CLIFO, 200+LF_COMUNI);
_cli_loaded= TRUE;
}
TString in(s.get()); // prende la macro o il fieldref TString in(s.get()); // prende la macro o il fieldref
if (in[0]=='!') { if (in[0] != '!')
valore = cli_for.get(s.get());
else
{
in.ltrim(1); in.ltrim(1);
if (in=="RAGSOC") if (in=="INDNUM")
{ {
valore = _cliente->get(LF_CLIFO, "RAGSOC"); valore = cli_for.get(CLI_INDCF);
valore.strip_d_spaces(); valore << " " << cli_for.get(CLI_CIVCF);
} }
if (in=="IND") else
valore = _cliente->get(LF_CLIFO, "INDCF"); if (in.find("COM") == 0)
if (in=="NUM") {
valore = _cliente->get(LF_CLIFO, "CIVCF"); in.ltrim(3);
if (in=="INDNUM") { TLocalisamfile com(LF_COMUNI);
valore = _cliente->get(LF_CLIFO, "INDCF"); const bool nascita = in[0] == 'N';
valore << " " << _cliente->get(LF_CLIFO,"CIVCF"); if (nascita)
} {
if (in=="LOC") in.ltrim(3);
valore = _cliente->get(LF_CLIFO, "LOCALITACF"); com.put("STATO", cli_for.get(CLI_STATOCF));
if (in=="CAP") com.put("COM", cli_for.get(CLI_COMCF));
valore = _cliente->get(LF_CLIFO, "CAPCF"); }
if (in=="COM") else
valore = _cliente->get(-(100+LF_COMUNI), "DENCOM"); {
if (in=="PROV") in.ltrim(2);
valore = _cliente->get(-(100+LF_COMUNI), "PROVCOM"); com.put("STATO", cli_for.get(CLI_STATONASC));
if (in=="IVA") com.put("COM", cli_for.get(CLI_COMNASC));
valore = _cliente->get(LF_CLIFO, "PAIV"); }
if (in=="CF") if (com.read() == NOERR)
valore = _cliente->get(LF_CLIFO, "COFI"); valore = com.get(in);
if (in=="PERS") }
valore = _cliente->get(LF_CLIFO, "TIPOPERS"); else
if (in=="DATANAS") if (in.find("TEL") == 0)
valore = _cliente->get(LF_CLIFO, "DATANASC"); {
if (in=="COMNAS") if (in.len() == 3)
valore = _cliente->get(-(200+LF_COMUNI), "DENCOM"); in << "1";
if (in=="TEL") { const TString num(cli_for.get(in));
valore = _cliente->get(LF_CLIFO, "PTEL"); in.insert("P");
valore << "/" << _cliente->get(LF_CLIFO, "TEL"); valore = cli_for.get(in);
} valore << "/" << num;
if (in=="TEL2") { }
valore = _cliente->get(LF_CLIFO, "PTEL2"); else
valore << "/" << _cliente->get(LF_CLIFO, "TEL2"); if (in=="FAX")
} {
if (in=="TEL3") { valore = cli_for.get("PFAX");
valore = _cliente->get(LF_CLIFO, "PTEL3"); valore << "/" << cli_for.get("FAX");
valore << "/" << _cliente->get(LF_CLIFO, "TEL3"); }
} else
if (in=="FAX") { if (in=="RAGSOC")
valore = _cliente->get(LF_CLIFO, "PFAX"); {
valore << "/" << _cliente->get(LF_CLIFO, "FAX"); valore = cli_for.get(in);
} valore.strip_d_spaces();
} else { }
TFieldref fref(s.get(), 0);
// l'oggetto cliente è figlio della TRelation, quindi lo passo al fieldref semplicemente con un typecast
valore = fref.read(*_cliente);
} }
cf.put_paragraph(valore); cf.put_paragraph(valore);
return (TRUE); return (TRUE);

View File

@ -74,7 +74,7 @@ class TGenerazioneEffetti_app : public TApplication
TTable *_cpg; // tabella condizioni di pagamento TTable *_cpg; // tabella condizioni di pagamento
TDocumento *_doc; // documento corrente TDocumento *_doc; // documento corrente
TCond_vendita *_condv; // Condizioni di vendita TCond_vendita *_condv; // Condizioni di vendita
TCliFor *_clifor; // Cliente // TCliFor *_clifor; // Cliente
TPagamento *_pagamento; // pagamento corrente, ricalcolato prima di scrivere le scadenze TPagamento *_pagamento; // pagamento corrente, ricalcolato prima di scrivere le scadenze
TBit_array _valid_array; // array dei tipi di pagamento validi per la generazione di effetti TBit_array _valid_array; // array dei tipi di pagamento validi per la generazione di effetti
TArray_sheet *_num_sheet; // Array sheet selezionabile dei codici numerazione TArray_sheet *_num_sheet; // Array sheet selezionabile dei codici numerazione
@ -280,9 +280,11 @@ bool TGenerazioneEffetti_app::create()
_efffile = new TLocalisamfile(LF_EFFETTI); _efffile = new TLocalisamfile(LF_EFFETTI);
_refffile = new TLocalisamfile(LF_REFFETTI); _refffile = new TLocalisamfile(LF_REFFETTI);
_cessfile = new TLocalisamfile(LF_CESS); _cessfile = new TLocalisamfile(LF_CESS);
_clifor = new TCliFor(); // _clifor = new TCliFor();
_condv = new TCond_vendita(_clifor); // _condv = new TCond_vendita(_clifor);
_condv = new TCond_vendita(NULL);
_doc = new TDocumento(); _doc = new TDocumento();
_condv->set_clifo(&_doc->clifor());
_doc->set_condv(_condv); _doc->set_condv(_condv);
_cpg = new TTable("%CPG"); _cpg = new TTable("%CPG");
_tab = new TLocalisamfile(LF_TAB); _tab = new TLocalisamfile(LF_TAB);

View File

@ -1,7 +1,6 @@
#ifndef __VELIB_H #ifndef __VELIB_H
#define __VELIB_H #define __VELIB_H
#ifndef __RELATION_H #ifndef __RELATION_H
#include <relation.h> #include <relation.h>
#endif #endif
@ -18,12 +17,16 @@
#include <varmask.h> #include <varmask.h>
#endif #endif
#ifndef __PAGAMENT_H #ifndef __MULTIREC_H
#include "../cg/pagament.h" #include <multirec.h>
#endif #endif
#ifndef __TCLIFOR_H #ifndef __CLIFOR_H
#include "tclifor.h" #include "clifor.h"
#endif
#ifndef __PAGAMENT_H
#include "../cg/pagament.h"
#endif #endif
#define RIGA_MERCE 'M' #define RIGA_MERCE 'M'
@ -344,6 +347,9 @@ enum TTipo_importo { _lordo, _netto, _imposta };
class TDocumento : public TAuto_variable_rectype // velib03 class TDocumento : public TAuto_variable_rectype // velib03
{ {
TRecfield *_tipocf;
TRecfield *_codcf;
TRecfield *_cod_occas;
static TAssoc_array _tipi; static TAssoc_array _tipi;
TRecord_array _rows; // Array di TRectype per le righe documenti di vendita. TRecord_array _rows; // Array di TRectype per le righe documenti di vendita.
@ -351,6 +357,8 @@ class TDocumento : public TAuto_variable_rectype // velib03
TRelation * _rel; TRelation * _rel;
TCond_vendita * _condv; TCond_vendita * _condv;
TCli_for _cli_for;
TOccasionale _occas;
TPagamento _pag; TPagamento _pag;
TRiga_documento * _sconto; // Riga per lo sconto di testata TRiga_documento * _sconto; // Riga per lo sconto di testata
TRiga_documento * _esenzione; // Riga per l' esenzione iva TRiga_documento * _esenzione; // Riga per l' esenzione iva
@ -362,6 +370,7 @@ protected:
long renum(long numdoc = 0); long renum(long numdoc = 0);
void set_riga_sconto(); void set_riga_sconto();
void set_riga_esenzione(); void set_riga_esenzione();
int write_rewrite(TBaseisamfile & f, bool re) const;
public: public:
void dirty_fields(); void dirty_fields();
@ -369,6 +378,8 @@ public:
TAuto_variable_rectype& head() { return *this; } // Ritorna la testata del documento TAuto_variable_rectype& head() { return *this; } // Ritorna la testata del documento
TCond_vendita & condv() const {CHECK(_condv, "Condizioni di vendita nulle"); return *_condv;} TCond_vendita & condv() const {CHECK(_condv, "Condizioni di vendita nulle"); return *_condv;}
TCli_for & clifor() const;
TOccasionale & occas() const;
TRelation & get_relation() const {CHECK(_rel, "Relazione nulla"); return *_rel;} TRelation & get_relation() const {CHECK(_rel, "Relazione nulla"); return *_rel;}
void set_condv(TCond_vendita * condv) { _condv = condv; } void set_condv(TCond_vendita * condv) { _condv = condv; }
void set_relation(TRelation * rel) { _rel = rel; } void set_relation(TRelation * rel) { _rel = rel; }
@ -388,13 +399,18 @@ public:
TRiga_documento& new_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); } 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(); }
virtual int read(TBaseisamfile& f, word op = _isequal, word lockop = _nolock);
virtual int write(TBaseisamfile& f) const { return write_rewrite(f, FALSE); }
virtual int rewrite(TBaseisamfile& f) const { return write_rewrite(f, TRUE); }
virtual int remove(TBaseisamfile& f) const;
int read(char provv, int anno, const char* codnum, long numdoc); int read(char provv, int anno, const char* codnum, long numdoc, word op = _isequal, word lockop = _nolock);
int read(const TRectype& rec); int read(const TRectype& rec, word op = _isequal, word lockop = _nolock) { *this = rec; return read(op, lockop); }
int read(word op = _isequal, word lockop = _nolock) { TLocalisamfile f(LF_DOC); return read(f, op, lockop);}
int write(bool re = FALSE) const; int write(bool re = FALSE) const { TLocalisamfile f(LF_DOC); return write_rewrite(f, re);}
int rewrite() const { return write(TRUE); } int rewrite() const { return write(TRUE); }
int remove() const; int remove() const { TLocalisamfile f(LF_DOC); return remove(f);}
char tipo_numerazione() const { return get_char("PROVV"); } char tipo_numerazione() const { return get_char("PROVV"); }
int anno() const { return get_int("ANNO"); } int anno() const { return get_int("ANNO"); }
@ -414,6 +430,9 @@ public:
bool raggruppabile() const { return get_bool("RAGGR"); } bool raggruppabile() const { return get_bool("RAGGR"); }
bool raggruppabile(const TDocumento& doc, TToken_string& campi) const; bool raggruppabile(const TDocumento& doc, TToken_string& campi) const;
char tipocf() const {return *(const char *) (*_tipocf);}
long codcf() const {return (long) *_codcf;}
const char * cod_occas() const { return (const char *) *_cod_occas; }
static void set_key(TRectype& rec, char provv, int anno, const char* codnum, long numdoc); static void set_key(TRectype& rec, char provv, int anno, const char* codnum, long numdoc);
static void copy_data(TRectype& dst, const TRectype& src); static void copy_data(TRectype& dst, const TRectype& src);
void copy_contents(const TDocumento & src); void copy_contents(const TDocumento & src);
@ -451,7 +470,7 @@ public:
virtual ~TDocumento(); virtual ~TDocumento();
}; };
class TDocumento_mask : public TVariable_mask // velib03 class TDocumento_mask : public TVariable_mask // velib06
{ {
int _progs_page; // pagina in cui cominciano i progressivi int _progs_page; // pagina in cui cominciano i progressivi
int _last_prog; // numero dell'ultimo progressivo int _last_prog; // numero dell'ultimo progressivo
@ -459,12 +478,16 @@ class TDocumento_mask : public TVariable_mask // velib03
protected: protected:
virtual void next_page(int p); virtual void next_page(int p);
void sconto_testa2mask( TCli_for & c, TConfig & ditta );
void spese2mask(TCli_for & c);
public: public:
virtual bool on_key(KEY key); virtual bool on_key(KEY key);
TDocumento & doc() const {CHECK(_doc, "Documento nullo"); return *_doc;} TDocumento & doc() const {CHECK(_doc, "Documento nullo"); return *_doc;}
TCond_vendita & condv() const {CHECK(_doc, "Documento nullo"); return _doc->condv();} TCond_vendita & condv() const {CHECK(_doc, "Documento nullo"); return _doc->condv();}
TRelation & get_relation() const {CHECK(_doc, "Documento nullo"); return _doc->get_relation();} TRelation & get_relation() const {CHECK(_doc, "Documento nullo"); return _doc->get_relation();}
void cli2mask( TCli_for & c, TOccasionale & o, TConfig & ditta);
void occ2mask(TOccasionale & o);
TDocumento_mask(const char* name, TDocumento * _doc, int num = 0, int max = MAX_PAGES); TDocumento_mask(const char* name, TDocumento * _doc, int num = 0, int max = MAX_PAGES);
virtual ~TDocumento_mask() { } virtual ~TDocumento_mask() { }
@ -817,7 +840,7 @@ public:
// Funzioni per settare i parametri // Funzioni per settare i parametri
void set_decimals(dec_parm & parm) { _parm = parm ; } void set_decimals(dec_parm & parm) { _parm = parm ; }
void set_condv(TCliFor * cli); // Cambia le condizioni di vendita void set_condv(TCli_for * cli); // Cambia le condizioni di vendita
TDocumentoEsteso (const TRectype & rec, dec_parm & parm, TCond_vendita * condv = NULL) ; TDocumentoEsteso (const TRectype & rec, dec_parm & parm, TCond_vendita * condv = NULL) ;
TDocumentoEsteso (const TRectype & rec, TCond_vendita * condv = NULL) ; TDocumentoEsteso (const TRectype & rec, TCond_vendita * condv = NULL) ;
TDocumentoEsteso () ; TDocumentoEsteso () ;

View File

@ -224,7 +224,7 @@ bool iva_handler( TMask_field& f, KEY key )
if (key == 0 || (key == K_ENTER && f.get().empty())) if (key == 0 || (key == K_ENTER && f.get().empty()))
{ {
TDocumento_mask & mask = (TDocumento_mask &) f.mask().get_sheet()->mask(); TDocumento_mask & mask = (TDocumento_mask &) f.mask().get_sheet()->mask();
const TString16 codiva = mask.condv().clifo().get(LF_CFVEN, "ASSFIS"); const TString16 codiva = mask.condv().clifo().vendite().get(CFV_ASSFIS);
if (codiva.not_empty()) if (codiva.not_empty())
f.set(codiva); f.set(codiva);

View File

@ -140,50 +140,6 @@ TFormula_documento * TTipo_documento::succ_formula(bool restart)
return NULL; return NULL;
} }
TDocumento_mask::TDocumento_mask(const char* name, TDocumento * doc, int num,
int max)
: TVariable_mask(name, num, max), _progs_page(-1), _last_prog(-1),
_doc(doc)
{
const int pos = id2pos(BASE_PIEDE + 1);
if (pos >= 0)
{
_progs_page = find_parent_page(fld(pos));
_last_prog = 0;
while (id2pos(BASE_PIEDE + _last_prog + 1) >= 0)
_last_prog++;
}
}
void TDocumento_mask::next_page(int p)
{
TMask::next_page(p);
if (curr_page() == _progs_page)
{
begin_wait();
autosave(get_relation());
for (int i = _last_prog; i > 0; i--)
{
const short id = BASE_PIEDE + i;
const TString16 name(field(id).field()->name());
set(id , doc().get(name));
}
end_wait();
}
}
bool TDocumento_mask::on_key(KEY key)
{
if (key == K_SHIFT + K_F12)
{
field(F_STATO).enable(!field(F_STATO).enabled());
return TRUE;
}
return TVariable_mask::on_key(key);
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Documento per vendite // Documento per vendite
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -194,6 +150,9 @@ TDocumento::TDocumento()
: TAuto_variable_rectype(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA"), _nuovo(TRUE), : TAuto_variable_rectype(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA"), _nuovo(TRUE),
_condv(NULL), _rel(NULL), _sconto(NULL), _esenzione(NULL) _condv(NULL), _rel(NULL), _sconto(NULL), _esenzione(NULL)
{ {
_tipocf = new TRecfield(*this, "TIPOCF");
_codcf = new TRecfield(*this, "CODCF");
_cod_occas = new TRecfield(*this, "OCFPI");
set_memo_fld("G1"); set_memo_fld("G1");
} }
@ -202,6 +161,9 @@ TDocumento::TDocumento(char provv, int anno, const char* codnum, long numdoc,
: TAuto_variable_rectype(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA"), _nuovo(TRUE), : TAuto_variable_rectype(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA"), _nuovo(TRUE),
_condv(condv), _rel(rel), _sconto(NULL), _esenzione(NULL) _condv(condv), _rel(rel), _sconto(NULL), _esenzione(NULL)
{ {
_tipocf = new TRecfield(*this, "TIPOCF");
_codcf = new TRecfield(*this, "CODCF");
_cod_occas = new TRecfield(*this, "OCFPI");
set_memo_fld("G1"); set_memo_fld("G1");
if (numdoc <= 0) if (numdoc <= 0)
{ {
@ -220,6 +182,9 @@ TDocumento::TDocumento(const TRectype& rec, TCond_vendita * condv, TRelation * r
: TAuto_variable_rectype(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA"), _nuovo(FALSE), : TAuto_variable_rectype(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA"), _nuovo(FALSE),
_condv(condv), _rel(rel), _sconto(NULL), _esenzione(NULL) _condv(condv), _rel(rel), _sconto(NULL), _esenzione(NULL)
{ {
_tipocf = new TRecfield(*this, "TIPOCF");
_codcf = new TRecfield(*this, "CODCF");
_cod_occas = new TRecfield(*this, "OCFPI");
set_memo_fld("G1"); set_memo_fld("G1");
read(rec); read(rec);
} }
@ -227,6 +192,9 @@ TDocumento::TDocumento(const TRectype& rec, TCond_vendita * condv, TRelation * r
TDocumento::~TDocumento() TDocumento::~TDocumento()
{ {
delete _tipocf;
delete _codcf;
delete _cod_occas;
if (_sconto != NULL) delete _sconto; if (_sconto != NULL) delete _sconto;
if (_esenzione != NULL) delete _esenzione; if (_esenzione != NULL) delete _esenzione;
} }
@ -480,43 +448,45 @@ TRiga_documento& TDocumento::new_row(const char *tipo)
return r; return r;
} }
int TDocumento::read(const TRectype& rec) int TDocumento::read(TBaseisamfile& f, word op, word lockop)
{ {
head() = rec;
TRiga_documento* key = new TRiga_documento(this); TRiga_documento* key = new TRiga_documento(this);
TRectype rec(*this);
const char pr = tipo_numerazione(); const char pr = tipo_numerazione();
const int an = anno(); const int an = anno();
const TString16 cn = numerazione(); const TString16 cn = numerazione();
const long nu = numero(); const long nu = numero();
CHECK(nu > 0, "Numero documento nullo."); CHECK(nu > 0, "Numero documento nullo.");
set_key(*key, pr, an, cn, nu); set_key(*key, pr, an, cn, nu);
TLocalisamfile doc(LF_DOC); int err = TRectype::read(f);
int err = TRectype::read(doc); _cli_for.zero();
if (err == NOERR) _occas.zero();
{
_nuovo = FALSE; if (err != NOERR && op == _isequal)
_rows.read(key); //ok
}
else
{ {
_nuovo = TRUE; _nuovo = TRUE;
head() = rec; head() = rec;
destroy_rows(); destroy_rows();
_rows.set_key(key); // ok _rows.set_key(key); // ok
} }
else
{
_nuovo = FALSE;
_rows.read(key); //ok
}
set_riga_sconto(); set_riga_sconto();
if (is_fattura()) if (is_fattura())
set_riga_esenzione(); set_riga_esenzione();
return err; return err;
} }
int TDocumento::read(char provv, int anno, const char* codnum, long numdoc) int TDocumento::read(char provv, int anno, const char* codnum, long numdoc, word op, word lockop)
{ {
TRectype rec(LF_DOC);
CHECK(numdoc > 0, "Numero documento nullo."); CHECK(numdoc > 0, "Numero documento nullo.");
set_key(rec, provv, anno, codnum, numdoc); set_key(*this, provv, anno, codnum, numdoc);
return read(rec); return read(op, lockop);
} }
long TDocumento::renum(long numdoc) long TDocumento::renum(long numdoc)
@ -564,17 +534,17 @@ void TDocumento::set_riga_sconto()
void TDocumento::set_riga_esenzione() void TDocumento::set_riga_esenzione()
{ {
TCliFor & c = condv().clifo(); TCli_for & c = clifor();
const char tipo = get_char("TIPOCF"); // const char tipo = get_char("TIPOCF");
const long cod = get_long("CODCF"); // const long cod = get_long("CODCF");
const TString80 occ(get("OCFPI")); // const TString80 occ(get("OCFPI"));
c.load(tipo, cod, occ); // c.load(tipo, cod, occ);
const TIVA codes(c.get(LF_CFVEN, CLI_ASSFIS)); const TIVA codes(c.vendite().get(CFV_ASSFIS));
const TString16 v_esenzione(c.get(LF_CFVEN, CLI_VSPROT)); const TString16 v_esenzione(c.vendite().get(CFV_VSPROT));
const TString16 v_data_esenzione(c.get(LF_CFVEN, CLI_VSDATAREG)); const TString16 v_data_esenzione(c.vendite().get(CFV_VSDATAREG));
// const TString16 ufficio_IVA; ?? // const TString16 ufficio_IVA; ??
const TString16 n_registrazione(c.get(LF_CFVEN, CLI_NSPROT)); const TString16 n_registrazione(c.vendite().get(CFV_NSPROT));
const TString16 n_data_registrazione(c.get(LF_CFVEN, CLI_NSDATAREG)); const TString16 n_data_registrazione(c.vendite().get(CFV_NSDATAREG));
bool esente = codes.tipo().not_empty() && v_esenzione.not_empty() && bool esente = codes.tipo().not_empty() && v_esenzione.not_empty() &&
v_data_esenzione.not_empty() && n_registrazione.not_empty() && v_data_esenzione.not_empty() && n_registrazione.not_empty() &&
n_data_registrazione.not_empty(); n_data_registrazione.not_empty();
@ -634,22 +604,24 @@ void TDocumento::dirty_fields()
} }
} }
int TDocumento::write(bool re) const int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
{ {
const bool nuovo = _nuovo || numero() <= 0; // E' nuovo di zecca! const bool nuovo = _nuovo || numero() <= 0; // E' nuovo di zecca!
if (nuovo && re) // quindi ... if (nuovo && re) // quindi ...
re = FALSE; // ... non fare la rewrite re = FALSE; // ... non fare la rewrite
TLocalisamfile doc(LF_DOC);
int err = NOERR; int err = NOERR;
const TString80 occ_code(occas().get(OCC_CFPI));
((TDocumento *)this)->put("OCFPI", occ_code);
if (re) if (re)
{ {
err = _rows.write(re); err = _rows.write(re);
if (err == NOERR) if (err == NOERR)
{ {
err = TRectype::rewrite(doc); err = TRectype::rewrite(f);
if (err != NOERR) if (err != NOERR)
err = TRectype::write(doc); err = TRectype::write(f);
} }
} }
else else
@ -661,7 +633,7 @@ int TDocumento::write(bool re) const
myself.renum(); myself.renum();
do do
{ {
err = TRectype::write(doc); err = TRectype::write(f);
if (err == _isreinsert) if (err == _isreinsert)
myself.renum(); myself.renum();
} while (err == _isreinsert); } while (err == _isreinsert);
@ -669,23 +641,30 @@ int TDocumento::write(bool re) const
} }
else else
{ {
err = TRectype::write(doc); err = TRectype::write(f);
if (err != NOERR) if (err != NOERR)
err = TRectype::rewrite(doc); err = TRectype::rewrite(f);
} }
if (err == NOERR) if (err == NOERR)
err = _rows.write(re); err = _rows.write(re);
} }
if (err == NOERR && clifor().occasionale() && occ_code.not_empty())
{
TLocalisamfile o(LF_OCCAS);
err = _occas.write(o);
if (err == _isreinsert)
err = _occas.rewrite(o);
}
return err; return err;
} }
int TDocumento::remove() const int TDocumento::remove(TBaseisamfile& f) const
{ {
TLocalisamfile doc(LF_DOC);
int err = _rows.remove(); int err = _rows.remove();
if (err == NOERR) if (err == NOERR)
err = TRectype::remove(doc); err = TRectype::remove(f);
return err; return err;
} }
@ -970,6 +949,34 @@ void TDocumento::zero(char c)
destroy_rows(); destroy_rows();
} }
TCli_for & TDocumento::clifor() const
{
const char tipo = tipocf();
const long codice = codcf();
if (_cli_for.empty() || _cli_for.tipo() != tipo || _cli_for.codice() != codice)
((TDocumento *) this)->_cli_for.read(tipo, codice);
return (TCli_for &)_cli_for;
}
TOccasionale & TDocumento::occas() const
{
const TString80 occ_code(cod_occas());
if (_occas.empty() || strcmp(_occas.codice(), occ_code) != 0)
{
TLocalisamfile o(LF_OCCAS);
((TDocumento *) this)->_occas.zero();
((TDocumento *) this)->_occas.put(OCC_CFPI, occ_code);
TRectype oc(_occas);
if (((TDocumento *) this)->_occas.read(o) != NOERR)
((TDocumento *) this)->_occas = oc;
}
return (TOccasionale &) _occas;
}
TDocumento & TDocumento::operator =(const TDocumento & d) TDocumento & TDocumento::operator =(const TDocumento & d)
{ {
zero(); zero();

View File

@ -1,50 +0,0 @@
#include "..\ve\sconti.h"
class TCondizione_vendita : public TObject
{
TString80 _sconto;
TString16 _codiva;
bool _ivarid;
real _prezzo;
real _provv;
real _molt_sconto;
TCliFor * _clifo;
TLocalisamfile _condv;
TLocalisamfile _rcondv;
TLocalisamfile _sconti;
TLocalisamfile * _anamag; // file passato e posizionato esternamente
TLocalisamfile * _umart; // file passato e posizionato esternamente
TConfig * _config_ditta;
bool _load_mask;
bool cerca(int tiporicerca,const char * cod, const real & qta);
protected:
TRectype & testa() const { return (_condv.curr()); }
TRectype & riga() const { return (_rcondv.curr()); }
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; }
public:
real get_prezzo() const { return _prezzo; }
TConfig &config_ditta() const { return *_config_ditta; }
void set_config( TConfig & ditta){ _config_ditta = &ditta; }
void set_anamag(TLocalisamfile & anamag) { _anamag = &anamag; }
void set_umart(TLocalisamfile & umart) { _umart = &umart; }
bool gestum() const { return _condv.get_bool("GESTUM"); }
// prepara la ricerca
void put_condv(const char *tipocv,const char * codcv,const char *catven,const char *tipocf,const char *codcf);
void put_listino(const char * codlist,const char *catven);
void put_contratto(const char * codcontr,const char *tipocf,const char *codcf);
void put_offerta(const char * codoff);
// ricerca il codice
bool ricerca(const char * cod,const real & qta=0) ;
TCondizione_vendita(TConfig * _ditta = NULL, TLocalisamfile * anamag = NULL, TLocalisamfile * umart = NULL);
~TCondizione_vendita() {}
};