Continua il clamoroso lavoro di sviluppo della librerie delle vendite

git-svn-id: svn://10.65.10.50/trunk@3347 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-08-08 15:57:44 +00:00
parent a33589e81b
commit 5ca00d943d
9 changed files with 344 additions and 155 deletions

View File

@ -22,3 +22,5 @@
#define F_DOC3 153
#define F_DOC4 154
#define F_DOC5 155
#define F_ATTIVA_PROVVISORIO 160
#define F_PROVVISORIO 161

View File

@ -231,7 +231,7 @@ BEGIN
VALIDATE REQIF_FUNC 1 F_TIPODOC_I_5
END
GROUPBOX DLG_NULL 78 5
GROUPBOX DLG_NULL 78 6
BEGIN
PROMPT 1 12 "@bDocumento finale"
END
@ -239,6 +239,7 @@ END
STRING F_TIPODOC_F 4
BEGIN
PROMPT 2 13 "Tipo documento "
FLAGS "U"
FIELD S8
CHECKTYPE REQUIRED
WARNING "E' necessario specificare un valore"
@ -260,16 +261,33 @@ END
STRING F_CODNUM_F 4
BEGIN
PROMPT 2 15 "Codice numerazione "
FLAGS "U"
FIELD S5
USE NUM
INPUT CODTAB F_CODNUM_F
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT F_CODNUM_F CODTAB
OUTPUT F_ATTIVA_PROVVISORIO B0
CHECKTYPE REQUIRED
WARNING "E' necessario specificare un codice di numerazione"
END
BOOLEAN F_ATTIVA_PROVVISORIO
BEGIN
FLAGS "HG"
MESSAGE FALSE CLEAR,F_PROVVISORIO
MESSAGE TRUE ENABLE,F_PROVVISORIO
END
RADIOBUTTON F_PROVVISORIO 20
BEGIN
PROMPT 42 13 "Tipo numerazione"
ITEM "D|Definitiva"
ITEM "P|Provvisioria"
FIELD S6
END
ENDPAGE
ENDMASK

View File

@ -2,3 +2,15 @@
#define F_DESNUM 102
#define F_PROFILO 103
#define F_PSTAMPA 104
#define F_CAMBIO 105
#define F_SCONTO 106
#define F_TIPODOC 107
#define F_CODNUM 108
#define F_CONDPAG 109
#define F_BANCA 110
#define F_LISTINO 111
#define F_AGENTE 112
#define F_SPEDIZIONE 113
#define F_PORTO 114
#define F_TRASPORTO 115
#define F_VETTORI 116

View File

@ -2,7 +2,7 @@
TOOLBAR "" 0 20 60 2
#include "toolbar.h"
#include "toolbar.h"
ENDPAGE
@ -14,49 +14,127 @@ BEGIN
FLAG "R"
END
STRING F_CODTAB 4
BEGIN
PROMPT 2 2 "Cod. tipo docum. "
FIELD CODTAB
HELP "Codice tipo documento"
USE %TIP
CHECKTYPE REQUIRED
INPUT CODTAB F_CODTAB
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT F_CODTAB CODTAB
OUTPUT F_DESNUM S0
KEY 1
FLAG "UZ"
END
STRING F_CODTAB 4
BEGIN
PROMPT 2 2 "Cod. tipo docum. "
FIELD CODTAB
HELP "Codice tipo documento"
USE %TIP
CHECKTYPE REQUIRED
INPUT CODTAB F_CODTAB
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT F_CODTAB CODTAB
OUTPUT F_DESNUM S0
KEY 1
FLAG "UZ"
END
STRING F_DESNUM 50
BEGIN
PROMPT 2 4 "Descrizione "
FIELD S0
HELP "Descrizione tipo documento"
USE %TIP KEY 2
CHECKTYPE REQUIRED
INPUT S0 F_DESNUM
DISPLAY "Descrizione@40" S0
DISPLAY "Codice" CODTAB
COPY OUTPUT F_CODTAB
KEY 2
END
STRING F_DESNUM 50
BEGIN
PROMPT 2 4 "Descrizione "
FIELD S0
HELP "Descrizione tipo documento"
USE %TIP KEY 2
CHECKTYPE REQUIRED
INPUT S0 F_DESNUM
DISPLAY "Descrizione@40" S0
DISPLAY "Codice" CODTAB
COPY OUTPUT F_CODTAB
KEY 2
END
STRING F_PROFILO 8
BEGIN
PROMPT 2 8 "Profilo documento "
FIELD S4
CHECKTYPE REQUIRED
END
STRING F_PROFILO 8
BEGIN
PROMPT 2 7 "Profilo documento "
FIELD S4
CHECKTYPE REQUIRED
END
STRING F_PSTAMPA 8
BEGIN
PROMPT 2 10 "Profilo stampa documento "
FIELD S5
CHECKTYPE REQUIRED
END
STRING F_PSTAMPA 8
BEGIN
PROMPT 2 9 "Profilo stampa documento "
FIELD S5
CHECKTYPE REQUIRED
END
GROUPBOX DLG_NULL 75 8
BEGIN
PROMPT 1 11 "Condizioni per raggruppamento"
FLAG "R"
END
BOOLEAN F_CAMBIO
BEGIN
PROMPT 2 12 "Cambio"
FIELD S2[1,1]
END
BOOLEAN F_SCONTO
BEGIN
PROMPT 2 13 "Sconto"
FIELD S2[2,2]
END
BOOLEAN F_TIPODOC
BEGIN
PROMP 2 14 "Tipo documento"
FIELD S2[3,3]
END
BOOLEAN F_CODNUM
BEGIN
PROMP 2 15 "Codice numerazione"
FIELD S2[4,4]
END
BOOLEAN F_SPEDIZIONE
BEGIN
PROMPT 2 16 "Modalita' di spedizione"
FIELD S2[9,9]
END
BOOLEAN F_PORTO
BEGIN
PROMPT 2 17 "Porto"
FIELD S2[10,10]
END
BOOLEAN F_CONDPAG
BEGIN
PROMP 40 12 "Condizione di pagamento"
FIELD S2[5,5]
END
BOOLEAN F_BANCA
BEGIN
PROMPT 40 13 "Banca di appoggio"
FIELD S2[6,6]
END
BOOLEAN F_LISTINO
BEGIN
PROMPT 40 14 "Listino"
FIELD S2[7,7]
END
BOOLEAN F_AGENTE
BEGIN
PROMP 40 15 "Agente"
FIELD S2[8,8]
END
BOOLEAN F_TRASPORTO
BEGIN
PROMPT 40 16 "Causale di trasporto"
FIELD S2[11,11]
END
BOOLEAN F_VETTORI
BEGIN
PROMPT 40 17 "Vettore"
FIELD S2[12,12]
END
ENDPAGE

View File

@ -1,19 +1,10 @@
#ifndef __TCLIFOR_H
#define __TCLIFOR_H
#ifndef __CHECKS_H
#include <checks.h>
#endif
#ifndef __RELATION_H
#include <relation.h>
#endif
#ifndef __TABUTIL_H
#include <tabutil.h>
#endif
#ifndef __VARMASK_H
#include <varmask.h>
#endif

View File

@ -2,33 +2,6 @@
#include "ve0100.h"
#endif
TTipo_documento::TTipo_documento(const char * tipodoc)
: _tipodoc(tipodoc), _mask(NULL)
{
TTable t("%TIP");
t.zero();
t.put("CODTAB", _tipodoc);
if (t.bad())
fatal_box("Non esiste il tipo documento %s", _tipodoc);
_profile = t.get("S4");
_profile_file = _profile;
_profile_file.ext("ini");
TConfig * p = create_profile();
_mask = new TVariable_mask( p->get( "MSKFILE", "MAIN" ) );
delete p;
}
TTipo_documento::~TTipo_documento()
{
if (_mask != NULL)
delete _mask;
}
TMotore_application& app( ) { return ( TMotore_application& ) main_app( ); }
void TMotore_application::init_query_mode( TMask& m )

View File

@ -18,7 +18,7 @@
#define F_MEMORIGA 501
#define BASE_PIEDE 600
#define CHANGE_MESSAGE "Sono state effettuate modifiche alla configurazione.\nPrima di eseguire la gestione documenti occorrer` rigenerare le maschere.\nDesideri farlo ora ?"
#define CHANGE_MESSAGE "Sono state effettuate modifiche alla configurazione.\nPrima di eseguire la gestione documenti occorre rigenerare le maschere.\nDesideri farlo ora ?"
// Modifiche pianificate per il dopo/cattolica:
// Rorganizzazione del codice come:
@ -34,7 +34,7 @@
#define NPIEDI 40
#include <xvt_defs.h>
// #include <xvt_defs.h>
#ifndef __CHECKS_H
#include <checks.h>
@ -124,25 +124,9 @@
#include "sconti.h"
#endif
class TTipo_documento : public TObject
{
TString16 _tipodoc;
TString16 _profile;
TFilename _profile_file;
TMask * _mask;
protected:
const char * profile_name() {return _profile; }
const char * profile_file() {return _profile_file; }
public:
const char * tipodoc() { return _tipodoc;}
TConfig * create_profile() { return new TConfig(_profile_file);}
TMask & mask() { return *_mask;}
TTipo_documento(const char * tipodoc);
virtual ~TTipo_documento();
};
#ifndef __VELIB01_H
#include "velib01.h"
#endif
// Definizione della classe dell'applicazione motore
class TMotore_application : public TRelation_application

View File

@ -1,23 +1,71 @@
#include <clifo.h>
// Togliere quando si toglie il metodo mask()
#include <varmask.h>
#include <tabutil.h>
#include "velib01.h"
///////////////////////////////////////////////////////////
// Tipo documento
///////////////////////////////////////////////////////////
TTipo_documento::TTipo_documento(const char* tipodoc)
: _rec(LF_TABCOM), _mask(NULL)
{
if (tipodoc && *tipodoc)
read(tipodoc);
}
TTipo_documento::TTipo_documento(const TRectype& rec)
: _rec(rec), _mask(NULL)
{ }
TTipo_documento::~TTipo_documento()
{
if (_mask != NULL)
delete _mask;
}
int TTipo_documento::read(const char* tipodoc)
{
TTable t("%TIP");
t.put("CODTAB", tipodoc);
int err = t.read();
if (err == NOERR)
_rec = t.curr();
return err;
}
TMask& TTipo_documento::mask()
{
if (_mask == NULL)
{
TFilename profile_file = _rec.get("S4");
profile_file.ext("ini");
TConfig p(profile_file);
_mask = new TVariable_mask(p.get("MSKFILE", "MAIN"));
}
return *_mask;
}
///////////////////////////////////////////////////////////
// Documento per vendite
///////////////////////////////////////////////////////////
TDocumento_vendita::TDocumento_vendita()
: _head(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA")
TDocumento::TDocumento()
: _head(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA")
{
}
TDocumento_vendita::TDocumento_vendita(const char* codnum, int anno, char provv, long numdoc)
: _head(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA")
TDocumento::TDocumento(const char* codnum, int anno, char provv, long numdoc)
: _head(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA")
{
read(codnum, anno, provv, numdoc);
}
int TDocumento_vendita::read(const TRectype& rec)
int TDocumento::read(const TRectype& rec)
{
_head = rec; // Inizializza i campi chiave in ogni caso
@ -36,7 +84,7 @@ int TDocumento_vendita::read(const TRectype& rec)
return err;
}
int TDocumento_vendita::read(const char* codnum, int anno, char provv, long numdoc)
int TDocumento::read(const char* codnum, int anno, char provv, long numdoc)
{
CHECK(codnum && *codnum && anno > 0 && (provv == 'D' || provv == 'P') && numdoc > 0,
"Codice documento non valido");
@ -50,7 +98,7 @@ int TDocumento_vendita::read(const char* codnum, int anno, char provv, long numd
return read(_head);
}
int TDocumento_vendita::write(bool re) const
int TDocumento::write(bool re) const
{
TLocalisamfile doc(LF_DOC);
int err = re ? _head.rewrite(doc) : _head.write(doc);
@ -61,7 +109,7 @@ int TDocumento_vendita::write(bool re) const
return err;
}
int TDocumento_vendita::remove() const
int TDocumento::remove() const
{
TLocalisamfile doc(LF_DOC);
int err = _head.remove(doc);
@ -70,11 +118,25 @@ int TDocumento_vendita::remove() const
return err;
}
const TTipo_documento& TDocumento::tipo() const
{
const char* tipodoc = _head.get("TIPODOC");
CHECK(*tipodoc, "Tipo documento nullo");
TTipo_documento* o = (TTipo_documento*)_tipi.objptr(tipodoc);
if (o == NULL)
{
o = new TTipo_documento(tipodoc);
_tipi.add(tipodoc, o);
}
return *o;
}
///////////////////////////////////////////////////////////
// Cliente per vendite
// Cliente/Fornitore per vendite
///////////////////////////////////////////////////////////
void TLista_clienti::TCliente::init(const TRectype& rec)
void TLista_clifo::TClifo::init(const TRectype& rec)
{
CHECK(rec.num() == LF_CFVEN, "E' necessario un cliente per vendite");
_codice = rec.get_long(CLI_CODCF);
@ -82,12 +144,12 @@ void TLista_clienti::TCliente::init(const TRectype& rec)
_zona = rec.get_long(CLI_CODZONA);
}
bool TLista_clienti::TCliente::read(long cod)
bool TLista_clifo::TClifo::read(char tipo, long cod)
{
TRelation clifo(LF_CLIFO);
clifo.add(LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF");
clifo.curr().put(CLI_TIPOCF, "C");
clifo.curr().put(CLI_TIPOCF, tipo);
clifo.curr().put(CLI_CODCF, cod);
if (clifo.read() == NOERR)
init(clifo.curr(LF_CFVEN));
@ -97,30 +159,30 @@ bool TLista_clienti::TCliente::read(long cod)
return ok();
}
TLista_clienti::TCliente::TCliente(const TRectype& rec)
TLista_clifo::TClifo::TClifo(const TRectype& rec)
{
if (rec.num() == LF_CFVEN)
init(rec);
else
{
_codice = rec.get_long(CLI_CODCF);
read(_codice);
const char tipo = rec.get_char(CLI_TIPOCF);
const long codice = rec.get_long(CLI_CODCF);
read(tipo, codice);
}
}
int TLista_clienti::leggi(long dc, long ac, long da, long aa, long dz, long az)
int TLista_clifo::leggi(long dc, long ac, long da, long aa, long dz, long az)
{
TRelation clifo(LF_CLIFO);
clifo.add(LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF");
TRectype start(LF_CLIFO), stop(LF_CLIFO);
start.put(CLI_TIPOCF, 'C');
stop.put(CLI_TIPOCF, 'C');
start.put(CLI_TIPOCF, tipo());
if (dc > 0)
start.put(CLI_CODCF, dc);
stop.put(CLI_TIPOCF, tipo());
if (ac > 0)
stop.put(CLI_CODCF, ac);
@ -146,56 +208,74 @@ int TLista_clienti::leggi(long dc, long ac, long da, long aa, long dz, long az)
TCursor cur(&clifo, filter, 1, &start, &stop);
for (cur = 0; cur.ok(); ++cur)
{
TCliente* c = new TCliente(cur.curr(LF_CFVEN));
_clienti.add(c);
TClifo* c = new TClifo(cur.curr(LF_CFVEN));
_clifo.add(c);
}
if (dc > 0 || ac > 0) ordina_per_codice(); else
if (da > 0 || aa > 0) ordina_per_agente(); else
if (dz > 0 || az > 0) ordina_per_zona();
return _clienti.items();
return _clifo.items();
}
int TLista_clienti::sort_by_code(const TObject** o1, const TObject** o2)
int TLista_clifo::sort_by_code(const TObject** o1, const TObject** o2)
{
TLista_clienti::TCliente* c1 = (TLista_clienti::TCliente*)*o1;
TLista_clienti::TCliente* c2 = (TLista_clienti::TCliente*)*o2;
TLista_clifo::TClifo* c1 = (TLista_clifo::TClifo*)*o1;
TLista_clifo::TClifo* c2 = (TLista_clifo::TClifo*)*o2;
const long d = c1->codice() - c2->codice();
return d == 0L ? 0 : (d > 0 ? +1 : -1);
}
int TLista_clienti::sort_by_agent(const TObject** o1, const TObject** o2)
int TLista_clifo::sort_by_agent(const TObject** o1, const TObject** o2)
{
TLista_clienti::TCliente* c1 = (TLista_clienti::TCliente*)*o1;
TLista_clienti::TCliente* c2 = (TLista_clienti::TCliente*)*o2;
TLista_clifo::TClifo* c1 = (TLista_clifo::TClifo*)*o1;
TLista_clifo::TClifo* c2 = (TLista_clifo::TClifo*)*o2;
const long d = c1->agente() - c2->agente();
return d == 0L ? 0 : (d > 0 ? +1 : -1);
}
int TLista_clienti::sort_by_zone(const TObject** o1, const TObject** o2)
int TLista_clifo::sort_by_zone(const TObject** o1, const TObject** o2)
{
TLista_clienti::TCliente* c1 = (TLista_clienti::TCliente*)*o1;
TLista_clienti::TCliente* c2 = (TLista_clienti::TCliente*)*o2;
TLista_clifo::TClifo* c1 = (TLista_clifo::TClifo*)*o1;
TLista_clifo::TClifo* c2 = (TLista_clifo::TClifo*)*o2;
const long d = c1->zona() - c2->zona();
return d == 0L ? 0 : (d > 0 ? +1 : -1);
}
int TLista_clienti::ordina_per_codice()
int TLista_clifo::ordina_per_codice()
{
_clienti.sort(sort_by_code);
return _clienti.items();
_clifo.sort(sort_by_code);
return _clifo.items();
}
int TLista_clienti::ordina_per_agente()
int TLista_clifo::ordina_per_agente()
{
_clienti.sort(sort_by_agent);
return _clienti.items();
_clifo.sort(sort_by_agent);
return _clifo.items();
}
int TLista_clienti::ordina_per_zona()
int TLista_clifo::ordina_per_zona()
{
_clienti.sort(sort_by_zone);
return _clienti.items();
_clifo.sort(sort_by_zone);
return _clifo.items();
}
int TLista_clifo::find(long cod) const
{
for (int i = items()-1; i >= 0; i--)
if (clifo(i).codice() == cod) break;
return i;
}
int TLista_clifo::add(long cod)
{
int pos = find(cod);
if (pos < 0)
{
TClifo* c = new TClifo(tipo(), cod);
pos = _clifo.add(c);
}
return pos;
}

View File

@ -5,8 +5,39 @@
#include <relation.h>
#endif
class TDocumento_vendita : public TObject
class TMask;
class TTipo_documento : public TObject
{
TRectype _rec;
TMask* _mask;
protected:
int read(const char* tipodoc);
public:
TObject* dup() const { return new TTipo_documento(tipodoc()); }
public:
enum TCondizione_uguaglianza
{ cambio, sconto, tipo_documento, numerazione,
pagamento, banca_appoggio, listino, agente,
spedizione, porto, causale_trasporto, vettori };
const TString& tipodoc() const { return _rec.get("CODTAB");}
TMask& mask();
bool uguale(TCondizione_uguaglianza u) const { return _rec.get("S2")[(int)u]; }
TTipo_documento(const char* tipodoc = NULL);
TTipo_documento(const TRectype& rec);
virtual ~TTipo_documento();
};
class TDocumento : public TObject
{
static TAssoc_array _tipi;
TRectype _head; // Record di testata
TRecord_array _rows; // Array di TRectype per le righe documenti di vendita.
@ -24,15 +55,19 @@ public:
int write(bool re = FALSE) const;
int rewrite() const { return write(TRUE); }
int remove() const;
const TTipo_documento& tipo() const;
const TDate& data() const { return _head.get_date("DATADOC"); }
long numero() const { return _head.get_long("NDOC"); }
TDocumento_vendita ();
TDocumento_vendita(const char* codnum, int anno, char provv, long numdoc);
virtual ~TDocumento_vendita() { }
TDocumento ();
TDocumento(const char* codnum, int anno, char provv, long numdoc);
virtual ~TDocumento() { }
};
class TLista_clienti : public TObject
class TLista_clifo : public TObject
{
class TCliente : public TObject
class TClifo : public TObject
{
long _codice;
long _agente;
@ -41,7 +76,7 @@ class TLista_clienti : public TObject
protected:
void zero() { _codice = _agente = _zona = 0L; }
void init(const TRectype& rec);
bool read(long cod);
bool read(char tipo, long cod);
public: // TObject
virtual bool ok() const { return _codice > 0; }
@ -51,16 +86,17 @@ class TLista_clienti : public TObject
long agente() const { return _agente; }
long zona() const { return _zona; }
TCliente() { zero(); }
TCliente(long cod) { read(cod); }
TCliente(const TRectype& rec);
virtual ~TCliente() { }
TClifo() { zero(); }
TClifo(char tipo, long cod) { read(tipo, cod); }
TClifo(const TRectype& rec);
virtual ~TClifo() { }
};
TArray _clienti;
TArray _clifo;
protected:
const TCliente& cliente(int n) const { return (TCliente&)_clienti[n]; }
virtual char tipo() const pure;
const TClifo& clifo(int n) const { return (TClifo&)_clifo[n]; }
static int sort_by_code(const TObject** o1, const TObject** o2);
static int sort_by_agent(const TObject** o1, const TObject** o2);
@ -73,10 +109,25 @@ public:
int leggi(long dc, long ac, long da = 0, long aa = 0, long dz = 0, long az = 0);
long operator[] (int n) const { return cliente(n).codice(); }
long operator[] (int n) const { return clifo(n).codice(); }
int items() const { return _clifo.items(); }
int find(long cod) const;
int add(long cod);
TLista_clienti() { }
virtual ~TLista_clienti() { }
TLista_clifo() { }
virtual ~TLista_clifo() { }
};
class TLista_clienti : public TLista_clifo
{
protected:
virtual char tipo() const { return 'C'; }
};
class TLista_fornitori : public TLista_clifo
{
protected:
virtual char tipo() const { return 'F'; }
};
#endif