Continua lo strenuo sviluppo delle mistiche vendite.
git-svn-id: svn://10.65.10.50/trunk@3377 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
0bf0fca649
commit
b9bf46a327
@ -62,7 +62,7 @@ BEGIN
|
||||
PROMPT 2 7 "Codice numerazione "
|
||||
FLAGS "U"
|
||||
FIELD S5
|
||||
USE NUM
|
||||
USE %NUM
|
||||
INPUT CODTAB F_CODNUM_I
|
||||
DISPLAY "Codice" CODTAB
|
||||
DISPLAY "Descrizione@50" S0
|
||||
@ -126,7 +126,6 @@ BEGIN
|
||||
PROMPT 2 9 "Stato iniziale "
|
||||
FLAGS "U"
|
||||
FIELD S7[1,1]
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "E' necessario specificare un valore"
|
||||
END
|
||||
|
||||
@ -159,7 +158,6 @@ BEGIN
|
||||
FLAGS "U"
|
||||
FIELD S7[2,2]
|
||||
WARNING "E' necessario specificare un valore"
|
||||
VALIDATE REQIF_FUNC 1 F_TIPODOC_I_2
|
||||
END
|
||||
|
||||
STRING F_TIPODOC_I_3 4
|
||||
@ -182,7 +180,6 @@ BEGIN
|
||||
FLAGS "U"
|
||||
FIELD S7[3,3]
|
||||
WARNING "E' necessario specificare un valore"
|
||||
VALIDATE REQIF_FUNC 1 F_TIPODOC_I_3
|
||||
END
|
||||
|
||||
STRING F_TIPODOC_I_4 4
|
||||
@ -205,7 +202,6 @@ BEGIN
|
||||
FLAGS "U"
|
||||
FIELD S7[4,4]
|
||||
WARNING "E' necessario specificare un valore"
|
||||
VALIDATE REQIF_FUNC 1 F_TIPODOC_I_4
|
||||
END
|
||||
|
||||
STRING F_TIPODOC_I_5 4
|
||||
@ -228,7 +224,6 @@ BEGIN
|
||||
FLAGS "U"
|
||||
FIELD S7[5,5]
|
||||
WARNING "E' necessario specificare un valore"
|
||||
VALIDATE REQIF_FUNC 1 F_TIPODOC_I_5
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 78 6
|
||||
@ -262,8 +257,8 @@ STRING F_CODNUM_F 4
|
||||
BEGIN
|
||||
PROMPT 2 15 "Codice numerazione "
|
||||
FLAGS "U"
|
||||
FIELD S5
|
||||
USE NUM
|
||||
FIELD S6
|
||||
USE %NUM
|
||||
INPUT CODTAB F_CODNUM_F
|
||||
DISPLAY "Codice" CODTAB
|
||||
DISPLAY "Descrizione@50" S0
|
||||
@ -285,7 +280,7 @@ BEGIN
|
||||
PROMPT 42 13 "Tipo numerazione"
|
||||
ITEM "D|Definitiva"
|
||||
ITEM "P|Provvisioria"
|
||||
FIELD S6
|
||||
FIELD S3
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
@ -25,7 +25,7 @@ PAGE "Numerazione documenti" -1 -1 60 14
|
||||
PROMPT 2 2 "Cod. numerazione "
|
||||
FIELD CODTAB
|
||||
HELP "Codice numerazione"
|
||||
USE NUM
|
||||
USE %NUM
|
||||
CHECKTYPE REQUIRED
|
||||
INPUT CODTAB F_CODTAB
|
||||
DISPLAY "Codice" CODTAB
|
||||
@ -41,7 +41,7 @@ PAGE "Numerazione documenti" -1 -1 60 14
|
||||
PROMPT 2 4 "Descrizione "
|
||||
FIELD S0
|
||||
HELP "Descrizione numerazione"
|
||||
USE NUM KEY 2
|
||||
USE %NUM KEY 2
|
||||
CHECKTYPE REQUIRED
|
||||
INPUT S0 F_DESNUM
|
||||
DISPLAY "Codice" CODTAB
|
||||
|
@ -6,28 +6,31 @@
|
||||
|
||||
#include "ve6000.h"
|
||||
|
||||
class TFatturazione_bolle : public TApplication
|
||||
class TFatturazione_bolle_app : public TApplication
|
||||
{
|
||||
protected: // TApplication
|
||||
virtual bool create();
|
||||
virtual bool menu(MENU_TAG mt);
|
||||
|
||||
public:
|
||||
TFatturazione_bolle() { }
|
||||
virtual ~TFatturazione_bolle() { }
|
||||
TFatturazione_bolle_app() { }
|
||||
virtual ~TFatturazione_bolle_app() { }
|
||||
};
|
||||
|
||||
bool TFatturazione_bolle::create()
|
||||
bool TFatturazione_bolle_app::create()
|
||||
{
|
||||
dispatch_e_menu(MENU_ITEM(1));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TFatturazione_bolle::menu(MENU_TAG)
|
||||
bool TFatturazione_bolle_app::menu(MENU_TAG)
|
||||
{
|
||||
TMask m("ve6000");
|
||||
while (m.run() == K_ENTER)
|
||||
{
|
||||
const TDate data_elab = m.get(F_DATA_ELAB);
|
||||
const int anno = data_elab.year();
|
||||
|
||||
const long dc = m.get_long(F_CODICE_CLIFO_DA);
|
||||
const long ac = m.get_long(F_CODICE_CLIFO_A);
|
||||
const long da = m.get_long(F_CODICE_AGENTE_DA);
|
||||
@ -35,15 +38,30 @@ bool TFatturazione_bolle::menu(MENU_TAG)
|
||||
const long dz = m.get_long(F_CODICE_ZONA_DA);
|
||||
const long az = m.get_long(F_CODICE_ZONA_A);
|
||||
|
||||
const TDate dd = m.get(F_DATA_DOCUMENTO_DA);
|
||||
const TDate ad = m.get(F_DATA_DOCUMENTO_A);
|
||||
const TString& codnum = m.get(F_CODICE_NUMERAZIONE);
|
||||
const long dn = m.get_long(F_NUMERO_DOCUMENTO_DA);
|
||||
const long an = m.get_long(F_NUMERO_DOCUMENTO_A);
|
||||
|
||||
TFatturazione_bolle eld(m.get(F_CODICE_ELAB));
|
||||
|
||||
TLista_clienti clienti;
|
||||
clienti.leggi(dc, ac, da, aa, dz, az);
|
||||
const int tot_cli = clienti.leggi(dc, ac, da, aa, dz, az);
|
||||
for (int c = 0; c < tot_cli; c++)
|
||||
{
|
||||
TLista_documenti din, dout;
|
||||
din.read('C', clienti[c], anno, dd, ad, codnum, dn, an);
|
||||
const bool ok = eld.elabora(din, dout);
|
||||
if (!ok) break;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int ve6200 (int argc, char **argv)
|
||||
{
|
||||
TFatturazione_bolle a;
|
||||
TFatturazione_bolle_app a;
|
||||
a.run (argc, argv, "Fatturazione Bolle");
|
||||
return TRUE;
|
||||
}
|
||||
|
364
ve/velib01.cpp
364
ve/velib01.cpp
@ -1,10 +1,7 @@
|
||||
#include <clifo.h>
|
||||
|
||||
// Togliere quando si toglie il metodo mask()
|
||||
#include <varmask.h>
|
||||
|
||||
#include <tabutil.h>
|
||||
|
||||
#include <clifo.h>
|
||||
|
||||
#include "velib01.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -69,20 +66,18 @@ real netto2lordo(const real& netto, const real& iva, bool is_valuta)
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TTipo_documento::TTipo_documento(const char* tipodoc)
|
||||
: _rec(LF_TABCOM), _mask(NULL)
|
||||
: _rec(LF_TABCOM)
|
||||
{
|
||||
if (tipodoc && *tipodoc)
|
||||
read(tipodoc);
|
||||
}
|
||||
|
||||
TTipo_documento::TTipo_documento(const TRectype& rec)
|
||||
: _rec(rec), _mask(NULL)
|
||||
: _rec(rec)
|
||||
{ }
|
||||
|
||||
TTipo_documento::~TTipo_documento()
|
||||
{
|
||||
if (_mask != NULL)
|
||||
delete _mask;
|
||||
}
|
||||
|
||||
int TTipo_documento::read(const char* tipodoc)
|
||||
@ -109,22 +104,71 @@ TDocumento::TDocumento()
|
||||
TDocumento::TDocumento(char provv, int anno, const char* codnum, long numdoc)
|
||||
: _head(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA")
|
||||
{
|
||||
read(provv, anno, codnum, numdoc);
|
||||
if (numdoc <= 0)
|
||||
{
|
||||
numdoc = get_next_key(provv, anno, codnum);
|
||||
set_key(_head, provv, anno, codnum, numdoc);
|
||||
|
||||
TRectype* key = new TRectype(LF_RIGHEDOC);
|
||||
set_key(*key, provv, anno, codnum, numdoc);
|
||||
_rows.set_key(key);
|
||||
#ifdef DBG
|
||||
TLocalisamfile doc(LF_DOC);
|
||||
TRectype test(_head);
|
||||
if (test.read(doc) != NOERR)
|
||||
yesnofatal_box("Documento gia' esistente: %c %d %s %l", provv, anno, codnum, numdoc);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
read(provv, anno, codnum, numdoc);
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
CHECK(provv == 'D' || provv == 'P', "Provvisorio o Definitivo?");
|
||||
CHECKD(anno > 1900, "Anno non valido: ", anno);
|
||||
CHECK(*codnum, "Codice numerazione nullo");
|
||||
CHECK(numdoc > 0, "Numero documento nullo");
|
||||
|
||||
rec.put("PROVV", provv);
|
||||
rec.put("ANNO", anno);
|
||||
rec.put("CODNUM", codnum);
|
||||
rec.put("NDOC", numdoc);
|
||||
}
|
||||
|
||||
// Funzione statica utile a tutti gli utenti di LF_DOC e LF_RIGHEDOC
|
||||
void TDocumento::copy_data(TRectype& dst, const TRectype& src)
|
||||
{
|
||||
const char provv = dst.get_char("PROVV");
|
||||
const int anno = dst.get_int("ANNO");
|
||||
const TString16 codnum = dst.get("CODNUM");
|
||||
const long numdoc = dst.get_long("NDOC");
|
||||
dst = src;
|
||||
set_key(dst, provv, anno, codnum, numdoc);
|
||||
}
|
||||
|
||||
|
||||
TDocumento::TDocumento(const TRectype& rec)
|
||||
: _head(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA")
|
||||
{
|
||||
read(rec);
|
||||
}
|
||||
|
||||
int TDocumento::read(const TRectype& rec)
|
||||
{
|
||||
_head = rec; // Inizializza i campi chiave in ogni caso
|
||||
|
||||
TRectype* key = new TRectype(LF_RIGHEDOC);
|
||||
|
||||
key->put("CODNUM", _head.get("CODNUM"));
|
||||
key->put("ANNO", _head.get("ANNO"));
|
||||
key->put("PROVV", _head.get("PROVV"));
|
||||
key->put("NDOC", _head.get("NDOC"));
|
||||
_head = rec;
|
||||
|
||||
TRectype* key = new TRectype(LF_RIGHEDOC);
|
||||
const char pr = tipo_numerazione();
|
||||
const int an = anno();
|
||||
const TString16 cn = numerazione();
|
||||
const long nu = numero();
|
||||
set_key(*key, pr, an, cn, nu);
|
||||
|
||||
TLocalisamfile doc(LF_DOC);
|
||||
int err = _head.read(doc);
|
||||
|
||||
if (err == NOERR)
|
||||
_rows.read(key);
|
||||
else
|
||||
@ -137,17 +181,8 @@ int TDocumento::read(const TRectype& rec)
|
||||
|
||||
int TDocumento::read(char provv, int anno, const char* codnum, long numdoc)
|
||||
{
|
||||
CHECK(codnum && *codnum && anno > 0 && (provv == 'D' || provv == 'P') && numdoc > 0,
|
||||
"Codice documento non valido");
|
||||
|
||||
TRectype rec(_head);
|
||||
|
||||
rec.zero();
|
||||
rec.put("CODNUM", codnum);
|
||||
rec.put("ANNO", anno);
|
||||
rec.put("PROVV", provv);
|
||||
rec.put("NDOC", numdoc);
|
||||
|
||||
TRectype rec(LF_DOC);
|
||||
set_key(rec, provv, anno, codnum, numdoc);
|
||||
return read(rec);
|
||||
}
|
||||
|
||||
@ -186,6 +221,27 @@ int TDocumento::remove() const
|
||||
return err;
|
||||
}
|
||||
|
||||
long TDocumento::get_next_key(char provv, int anno, const char* codnum) const
|
||||
{
|
||||
TLocalisamfile doc(LF_DOC);
|
||||
TRectype& curr = doc.curr();
|
||||
set_key(curr, provv, anno, codnum, 9999999L);
|
||||
|
||||
const int err = doc.read(_isgreat);
|
||||
|
||||
long n = 1;
|
||||
if (err != _isemptyfile)
|
||||
{
|
||||
if (err == NOERR)
|
||||
doc.prev();
|
||||
if (curr.get_char("PROVV") == provv &&
|
||||
curr.get_int("ANNO") == anno &&
|
||||
curr.get("CODNUM") == codnum)
|
||||
n = curr.get_long("NDOC") + 1;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
const TTipo_documento& TDocumento::tipo() const
|
||||
{
|
||||
const TString16 tipodoc(_head.get("TIPODOC"));
|
||||
@ -197,38 +253,157 @@ const TTipo_documento& TDocumento::tipo() const
|
||||
_tipi.add(tipodoc, o);
|
||||
}
|
||||
return *o;
|
||||
}
|
||||
|
||||
bool TDocumento::raggruppabile(const TDocumento& doc) const
|
||||
{
|
||||
if (!raggruppabile() || !doc.raggruppabile())
|
||||
return FALSE;
|
||||
|
||||
TToken_string campi(128);
|
||||
campi = "TIPOCF|CODCF|CODVAL|CODLIN"; // Uguali sempre
|
||||
|
||||
// Uguali opzionalmente
|
||||
const char* cond[] = { "CAMBIO", "SCONTO", "TIPODOC", "CODNUM",
|
||||
"CODPAG", "CODABIA|CODCABA", "CODLIST", "CODAG",
|
||||
"CODSPMEZZO", "CODPORTO", "CAUSTRASP", "CODVETT1|CODVETT2|CODVETT3",
|
||||
NULL };
|
||||
const TTipo_documento& tipodoc = tipo();
|
||||
for (int u = 0; cond[u]; u++)
|
||||
{
|
||||
if (tipodoc.uguale(u))
|
||||
campi.add(cond[u]);
|
||||
}
|
||||
|
||||
const TRectype& other = doc.head();
|
||||
|
||||
bool ok = TRUE;
|
||||
for (const char* c = campi.get(0); c && ok; c = campi.get())
|
||||
ok &= _head.get(c) == other.get(c);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Lista di documenti
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
int TLista_documenti::leggi(char tipo, long clifo,
|
||||
const TDate& dd, const TDate& ad)
|
||||
{
|
||||
_documenti.destroy();
|
||||
TDate TLista_documenti::num2date(char provv, int anno, const char* codnum, long num) const
|
||||
{
|
||||
TLocalisamfile doc(LF_DOC);
|
||||
|
||||
TRectype& curr = doc.curr();
|
||||
TDocumento::set_key(curr, provv, anno, codnum, num);
|
||||
|
||||
TDate d;
|
||||
if (doc.read() == NOERR)
|
||||
d = curr.get("DATADOC");
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
TString filter(256);
|
||||
filter << '(' << CLI_TIPOCF << '=' << tipo << ")&&("
|
||||
<< CLI_CODCF << '=' << clifo << ")";
|
||||
if (dd.ok() && dd > botime)
|
||||
filter << "&&(ANSI(DATADOC)>=" << dd.string(ANSI) << ')';
|
||||
if (ad.ok() && ad < eotime)
|
||||
filter << "&&(ANSI(DATADOC)<=" << ad.string(ANSI) << ')';
|
||||
int TLista_documenti::read(char tipo, long clifo, int anno,
|
||||
const TDate& dd, const TDate& ad,
|
||||
const char* codnum, long dn, long an,
|
||||
char provv)
|
||||
{
|
||||
CHECK(tipo == 'C' || tipo == 'F', "Il tipo deve essere Cliente o Fornitore");
|
||||
CHECK(clifo > 0L, "Codice cliente non valido");
|
||||
CHECK(provv == 'D' || provv == 'P', "Provvisorio o Definitivo?");
|
||||
CHECKD(anno > 1900, "Anno non valido: ", anno);
|
||||
|
||||
TRelation doc(LF_DOC);
|
||||
TRectype start(LF_DOC), stop(LF_DOC);
|
||||
|
||||
start.put("TIPOCF", tipo);
|
||||
stop.put("TIPOCF", tipo);
|
||||
|
||||
start.put("CODCF", clifo);
|
||||
stop.put("CODCF", clifo);
|
||||
|
||||
start.put("PROVV", provv);
|
||||
stop.put("PROVV", provv);
|
||||
|
||||
start.put("ANNO", anno);
|
||||
stop.put("ANNO", anno);
|
||||
|
||||
if (dn > 0)
|
||||
{
|
||||
start.put("DATADOC", num2date(provv, anno, codnum, dn));
|
||||
start.put("NDOC", dn);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dd.ok() && dd > botime)
|
||||
start.put("DATADOC", dd);
|
||||
}
|
||||
|
||||
if (an > 0)
|
||||
{
|
||||
stop.put("DATADOC", num2date(provv, anno, codnum, an));
|
||||
stop.put("NDOC", an);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ad.ok() && ad < eotime)
|
||||
stop.put("DATADOC", ad);
|
||||
}
|
||||
|
||||
TString filter(16);
|
||||
if (codnum && *codnum)
|
||||
{
|
||||
bool numfilter = FALSE;
|
||||
|
||||
return 0;
|
||||
if (start.get("DATADOC").empty())
|
||||
numfilter = TRUE;
|
||||
else
|
||||
start.put("CODNUM", codnum);
|
||||
|
||||
if (stop.get("DATADOC").empty())
|
||||
numfilter = TRUE;
|
||||
else
|
||||
stop.put("CODNUM", codnum);
|
||||
|
||||
if (numfilter)
|
||||
filter << "CODNUM=" << codnum;
|
||||
}
|
||||
|
||||
TCursor cur(&doc, filter, 2, &start, &stop);
|
||||
|
||||
_documenti.destroy();
|
||||
for (cur = 0; cur.ok(); ++cur)
|
||||
{
|
||||
TDocumento* d = new TDocumento(cur.curr());
|
||||
_documenti.add(d);
|
||||
}
|
||||
|
||||
return _documenti.items();
|
||||
}
|
||||
|
||||
int TLista_documenti::write(bool re) const
|
||||
{
|
||||
int err = NOERR;
|
||||
for (int i = _documenti.items()-1; i >= 0 && err == NOERR; i--)
|
||||
err = doc(i).write(re);
|
||||
return err;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Cliente/Fornitore per vendite
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
void TLista_clifo::TClifo::init(const TRectype& rec)
|
||||
void TLista_clifo::TClifo::init(const TRectype& rec, const TRectype& ven)
|
||||
{
|
||||
CHECK(rec.num() == LF_CFVEN, "E' necessario un cliente per vendite");
|
||||
_codice = rec.get_long(CLI_CODCF);
|
||||
_agente = rec.get_long(CLI_CODAG);
|
||||
_zona = rec.get_long(CLI_CODZONA);
|
||||
CHECK(_codice > 0, "Codice cliente nullo");
|
||||
|
||||
if (!ven.empty())
|
||||
{
|
||||
_agente = ven.get_long(CLI_CODAG);
|
||||
_zona = ven.get_long(CLI_CODZONA);
|
||||
}
|
||||
else
|
||||
_agente = _zona = 0;
|
||||
}
|
||||
|
||||
bool TLista_clifo::TClifo::read(char tipo, long cod)
|
||||
@ -236,20 +411,21 @@ 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, tipo);
|
||||
clifo.curr().put(CLI_CODCF, cod);
|
||||
TRectype& curr = clifo.curr();
|
||||
curr.put(CLI_TIPOCF, tipo);
|
||||
curr.put(CLI_CODCF, cod);
|
||||
if (clifo.read() == NOERR)
|
||||
init(clifo.curr(LF_CFVEN));
|
||||
init(curr, clifo.curr(LF_CFVEN));
|
||||
else
|
||||
zero();
|
||||
|
||||
return ok();
|
||||
}
|
||||
|
||||
TLista_clifo::TClifo::TClifo(const TRectype& rec)
|
||||
TLista_clifo::TClifo::TClifo(const TRectype& rec, const TRectype& ven)
|
||||
{
|
||||
if (rec.num() == LF_CFVEN)
|
||||
init(rec);
|
||||
if (!ven.empty())
|
||||
init(rec, ven);
|
||||
else
|
||||
{
|
||||
const char tipo = rec.get_char(CLI_TIPOCF);
|
||||
@ -295,7 +471,7 @@ int TLista_clifo::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)
|
||||
{
|
||||
TClifo* c = new TClifo(cur.curr(LF_CFVEN));
|
||||
TClifo* c = new TClifo(cur.curr(), cur.curr(LF_CFVEN));
|
||||
_clifo.add(c);
|
||||
}
|
||||
|
||||
@ -366,3 +542,87 @@ int TLista_clifo::add(long cod)
|
||||
return pos;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TElaborazione
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TElaborazione::TElaborazione(const char* cod) : _rec(LF_TAB)
|
||||
{
|
||||
if (cod && *cod)
|
||||
read(cod);
|
||||
}
|
||||
|
||||
int TElaborazione::read(const char* cod)
|
||||
{
|
||||
CHECK(cod && *cod, "Codice elaborazione nullo");
|
||||
TTable eld("%ELD");
|
||||
eld.put("CODTAB", cod);
|
||||
const int err = eld.read();
|
||||
if (err == NOERR)
|
||||
_rec = eld.curr();
|
||||
else
|
||||
yesnofatal_box("Codice elaborazione non valido: %s", cod);
|
||||
return err;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TFatturazione bolle
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
bool TFatturazione_bolle::raggruppa(TDocumento& doc_in, TDocumento& doc_out)
|
||||
{
|
||||
const TString tipi = _rec.get("S2");
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (doc_in.tipo() == tipi.mid(i*4, 4))
|
||||
break;
|
||||
}
|
||||
CHECK(i < 5, "Tipo documento non valido");
|
||||
|
||||
const char stato_finale_in = _rec.get("S7")[i];
|
||||
doc_in.stato(stato_finale_in);
|
||||
|
||||
const char stato_finale_out = _rec.get_char("S9");
|
||||
doc_out.stato(stato_finale_out);
|
||||
|
||||
for (i = 1; i <= doc_in.rows(); i++)
|
||||
{
|
||||
TRectype& nr = doc_out.new_row();
|
||||
doc_out.copy_data(nr, doc_in[i]);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
for (int id = 0; id < doc_in.items() && ok; id++)
|
||||
{
|
||||
TDocumento& campione = doc_in[id];
|
||||
const int tot = doc_out.items();
|
||||
|
||||
int od = tot;
|
||||
if (campione.raggruppabile())
|
||||
{
|
||||
for (od = 0; od < tot; od++)
|
||||
{
|
||||
if (campione.raggruppabile(doc_out[od]))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (od >= tot)
|
||||
{
|
||||
const char provv = _rec.get_char("S3");
|
||||
const int anno = campione.anno();
|
||||
const TString codnum = _rec.get("S5");
|
||||
TDocumento* new_doc = new TDocumento(provv, anno, codnum, -1);
|
||||
new_doc->copy_data(new_doc->head(), campione.head());
|
||||
od = doc_out.add(new_doc);
|
||||
}
|
||||
ok = raggruppa(campione, doc_out[od]);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
86
ve/velib01.h
86
ve/velib01.h
@ -15,7 +15,6 @@ class TMask;
|
||||
class TTipo_documento : public TObject
|
||||
{
|
||||
TRectype _rec;
|
||||
TMask* _mask;
|
||||
|
||||
protected:
|
||||
int read(const char* tipodoc);
|
||||
@ -24,17 +23,14 @@ public:
|
||||
TObject* dup() const { return new TTipo_documento(codice()); }
|
||||
|
||||
public:
|
||||
enum TCondizione_uguaglianza
|
||||
{ cambio, sconto, tipo_documento, numerazione,
|
||||
pagamento, banca_appoggio, listino, agente,
|
||||
spedizione, porto, causale_trasporto, vettori };
|
||||
|
||||
const TString & profile_name() const { return _rec.get("S4");}
|
||||
const TString & mask_name() const { return _rec.get("S4");}
|
||||
const TString& profile_name() const { return _rec.get("S4");}
|
||||
const TString& mask_name() const { return _rec.get("S4");}
|
||||
|
||||
const TString& codice() const { return _rec.get("CODTAB");}
|
||||
|
||||
bool uguale(TCondizione_uguaglianza u) const { return _rec.get("S2")[(int)u]; }
|
||||
bool uguale(int u) const { return _rec.get("S2")[(int)u]; }
|
||||
|
||||
bool operator ==(const char* cod) const { return codice() == cod; }
|
||||
|
||||
TTipo_documento(const char* tipodoc = NULL);
|
||||
TTipo_documento(const TRectype& rec);
|
||||
@ -47,7 +43,10 @@ class TDocumento : public TObject
|
||||
|
||||
TRectype _head; // Record di testata
|
||||
TRecord_array _rows; // Array di TRectype per le righe documenti di vendita.
|
||||
|
||||
|
||||
protected:
|
||||
long get_next_key(char provv, int anno, const char* codnum) const;
|
||||
|
||||
public:
|
||||
int rows() const { return _rows.rows(); }
|
||||
|
||||
@ -55,7 +54,7 @@ public:
|
||||
TRectype & head() { return _head; } // Ritorna la testata del documento
|
||||
const TRectype & operator[](int index) const { return _rows.row(index); } // Ritorna la riga n-esima del documento
|
||||
TRectype & operator[](int index) { return _rows.row(index, FALSE); }
|
||||
TRectype& add_row() { return _rows.row(-1, TRUE); }
|
||||
TRectype& new_row() { return _rows.row(-1, TRUE); }
|
||||
bool destroy_row(int n) { return _rows.destroy_row(n); }
|
||||
void destroy_rows() { _rows.destroy_rows(); }
|
||||
|
||||
@ -66,16 +65,26 @@ public:
|
||||
int rewrite() const { return write(TRUE); }
|
||||
int remove() const;
|
||||
|
||||
const TTipo_documento & tipo() const;
|
||||
const TString & tipodoc() { return _head.get("TIPODOC"); }
|
||||
const TDate & data() const { return _head.get_date("DATADOC"); }
|
||||
const TString & numerazione() const { return _head.get("CODNUM"); }
|
||||
int anno() const { return _head.get_int("ANNO"); }
|
||||
char tipo_numerazione() const { return _head.get_int("PROVV"); }
|
||||
int anno() const { return _head.get_int("ANNO"); }
|
||||
const TString& numerazione() { return _head.get("CODNUM"); }
|
||||
long numero() const { return _head.get_long("NDOC"); }
|
||||
const TDate& data() const { return _head.get_date("DATADOC"); }
|
||||
// const TString& tipodoc() { return _head.get("TIPODOC"); }
|
||||
const TTipo_documento& tipo() const;
|
||||
|
||||
char stato() const { return _head.get_char("STATO"); }
|
||||
void stato(char s) { _head.put("STATO", s); }
|
||||
|
||||
bool raggruppabile() const { return _head.get_bool("RAGGR"); }
|
||||
bool raggruppabile(const TDocumento& doc) const;
|
||||
|
||||
static void set_key(TRectype& rec, char provv, int anno, const char* codnum, long numdoc);
|
||||
static void copy_data(TRectype& dst, const TRectype& src);
|
||||
|
||||
TDocumento ();
|
||||
TDocumento(char provv, int anno, const char* codnum, long numdoc);
|
||||
TDocumento(const TRectype& doc);
|
||||
virtual ~TDocumento() { }
|
||||
};
|
||||
|
||||
@ -83,10 +92,19 @@ class TLista_documenti : public TObject
|
||||
{
|
||||
TArray _documenti;
|
||||
|
||||
protected:
|
||||
const TDocumento& doc(int n) const { return (const TDocumento&)_documenti[n]; }
|
||||
TDate num2date(char provv, int anno, const char* codnum, long num) const;
|
||||
|
||||
public:
|
||||
int leggi(char tipo, long clifo, const TDate& dd, const TDate& ad);
|
||||
int read(char tipo, long clifo, int anno, const TDate& dd, const TDate& ad,
|
||||
const char* codnum = "", long dn = 0L, long an = 0L, char provv = 'D');
|
||||
int write(bool re = FALSE) const;
|
||||
int rewrite() const { return write(TRUE); }
|
||||
|
||||
const TDocumento& operator[] (int n) const { return (const TDocumento&)_documenti[n]; }
|
||||
int add(TDocumento* doc) { return _documenti.add(doc); }
|
||||
|
||||
const TDocumento& operator[] (int n) const { return doc(n); }
|
||||
TDocumento& operator[] (int n) { return (TDocumento&)_documenti[n]; }
|
||||
int items() const { return _documenti.items(); }
|
||||
|
||||
@ -104,7 +122,7 @@ class TLista_clifo : public TObject
|
||||
|
||||
protected:
|
||||
void zero() { _codice = _agente = _zona = 0L; }
|
||||
void init(const TRectype& rec);
|
||||
void init(const TRectype& rec, const TRectype& ven);
|
||||
bool read(char tipo, long cod);
|
||||
|
||||
public: // TObject
|
||||
@ -117,7 +135,7 @@ class TLista_clifo : public TObject
|
||||
|
||||
TClifo() { zero(); }
|
||||
TClifo(char tipo, long cod) { read(tipo, cod); }
|
||||
TClifo(const TRectype& rec);
|
||||
TClifo(const TRectype& rec, const TRectype& ven);
|
||||
virtual ~TClifo() { }
|
||||
};
|
||||
|
||||
@ -159,4 +177,32 @@ protected:
|
||||
virtual char tipo() const { return 'F'; }
|
||||
};
|
||||
|
||||
class TElaborazione : public TObject
|
||||
{
|
||||
protected:
|
||||
TRectype _rec;
|
||||
|
||||
protected:
|
||||
int read(const char* cod);
|
||||
|
||||
public:
|
||||
const TString& codice() const { return _rec.get("CODTAB"); }
|
||||
|
||||
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out) pure;
|
||||
|
||||
TElaborazione(const char* cod);
|
||||
TElaborazione(const TRectype& rec) : _rec(rec) { }
|
||||
virtual ~TElaborazione() { }
|
||||
};
|
||||
|
||||
class TFatturazione_bolle : public TElaborazione
|
||||
{
|
||||
public:
|
||||
virtual bool raggruppa(TDocumento& din, TDocumento& dout);
|
||||
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out);
|
||||
|
||||
TFatturazione_bolle(const char* cod) : TElaborazione(cod) { }
|
||||
virtual ~TFatturazione_bolle() { }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user