batbfrd.h Aggiunto campo importo
batbfrd.uml Aggiunto campo importo batbfrr.uml Aggiunto campo importo velib.h Aggiunto codice_numerazione() ai documenti velib0?.cpp Implementazione codice_numerazione e gestione decimali automatici git-svn-id: svn://10.65.10.50/trunk@5068 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
a3737ab83a
commit
99bfabf560
@ -2,4 +2,5 @@
|
||||
#define F_DES 102
|
||||
#define F_PICTURE 103
|
||||
#define F_TIPO 104
|
||||
#define F_FORMULA 105
|
||||
#define F_IMPORTO 105
|
||||
#define F_FORMULA 106
|
||||
|
@ -44,7 +44,7 @@ END
|
||||
|
||||
STRING F_PICTURE 20
|
||||
BEGIN
|
||||
PROMPT 2 7 "Picture di pres. "
|
||||
PROMPT 2 7 "Formato di presentazione "
|
||||
FIELD S3
|
||||
END
|
||||
|
||||
@ -52,6 +52,14 @@ BOOLEAN F_TIPO
|
||||
BEGIN
|
||||
PROMPT 2 9 "Formula numerica"
|
||||
FIELD B0
|
||||
MESSAGE TRUE ENABLE,F_IMPORTO
|
||||
MESSAGE FALSE CLEAR,F_IMPORTO
|
||||
END
|
||||
|
||||
BOOLEAN F_IMPORTO
|
||||
BEGIN
|
||||
PROMPT 2 10 "Importo"
|
||||
FIELD B1
|
||||
END
|
||||
|
||||
STRING F_FORMULA 70 50
|
||||
|
@ -44,7 +44,7 @@ END
|
||||
|
||||
STRING F_PICTURE 20
|
||||
BEGIN
|
||||
PROMPT 2 7 "Picture di pres. "
|
||||
PROMPT 2 7 "Formato di presentazione "
|
||||
FIELD S3
|
||||
END
|
||||
|
||||
@ -52,8 +52,17 @@ BOOLEAN F_TIPO
|
||||
BEGIN
|
||||
PROMPT 2 9 "Formula numerica"
|
||||
FIELD B0
|
||||
MESSAGE TRUE ENABLE,F_IMPORTO
|
||||
MESSAGE FALSE CLEAR,F_IMPORTO
|
||||
END
|
||||
|
||||
BOOLEAN F_IMPORTO
|
||||
BEGIN
|
||||
PROMPT 2 10 "Importo"
|
||||
FIELD B1
|
||||
END
|
||||
|
||||
|
||||
STRING F_FORMULA 70 50
|
||||
BEGIN
|
||||
PROMPT 2 11 "Formula "
|
||||
|
16
ve/clifor.h
16
ve/clifor.h
@ -5,13 +5,13 @@
|
||||
#include <multirec.h>
|
||||
#endif
|
||||
|
||||
#ifndef __MASK_H
|
||||
#include <mask.h>
|
||||
#endif
|
||||
//#ifndef __MASK_H
|
||||
//#include <mask.h>
|
||||
//#endif
|
||||
|
||||
#ifndef __LFFILES_H
|
||||
#include <lffiles.h>
|
||||
#endif
|
||||
//#ifndef __LFFILES_H
|
||||
//#include <lffiles.h>
|
||||
//#endif
|
||||
|
||||
#ifndef __CLIFO_H
|
||||
#include <clifo.h>
|
||||
@ -56,9 +56,9 @@ protected:
|
||||
virtual int write_rewrite(TBaseisamfile& f, bool re = FALSE) const;
|
||||
|
||||
public:
|
||||
bool occasionale() const { return get_bool(CLI_OCCAS ); };
|
||||
bool occasionale() const { return get_bool(CLI_OCCAS); }
|
||||
TRectype & vendite() const;
|
||||
// TMask& occas_mask( ){ return _occas_mask; };
|
||||
// TMask& occas_mask( ){ return _occas_mask; }
|
||||
// static bool occas_code_handler(TMask_field& f, KEY key);
|
||||
// int write_occas( );
|
||||
// void edita_occasionale( );
|
||||
|
86
ve/velib.h
86
ve/velib.h
@ -43,8 +43,14 @@
|
||||
#define RIGA_SCONTI 'C'
|
||||
#define RIGA_OMAGGI 'O'
|
||||
#define RIGA_DESCRIZIONI 'D'
|
||||
|
||||
#define MAX_TIPI_DOC 10
|
||||
|
||||
#define NO_DECIMALS 0
|
||||
#define STD_DECIMALS 3
|
||||
#define ALL_DECIMALS 883
|
||||
#define AUTO_DECIMALS -883
|
||||
|
||||
class TDocumento;
|
||||
class TRiga_documento;
|
||||
class TCond_vendita;
|
||||
@ -238,6 +244,7 @@ public:
|
||||
const TString & basesconto() const { return _basesconto;}
|
||||
const TString & spese() const { return _spese;}
|
||||
bool mov_mag() const { return get_bool("B1"); }
|
||||
bool statistiche() const { return get_bool("B2"); }
|
||||
const TString & stato_mov_iniziale() const {return get("S7"); }
|
||||
const TString & stato_mov_finale() const {return get("S8"); }
|
||||
const TString & caus_mov() const {return get("S9"); }
|
||||
@ -254,6 +261,31 @@ public:
|
||||
virtual ~TTipo_documento();
|
||||
};
|
||||
|
||||
class TCodice_numerazione : public TRectype
|
||||
{
|
||||
int _status;
|
||||
|
||||
public:
|
||||
TObject* dup() const { return new TCodice_numerazione(codice()); }
|
||||
|
||||
public:
|
||||
int read(const char * cod);
|
||||
const TString& codice() const { return get("CODTAB"); }
|
||||
const TString& descrizione() const { return get("S0"); }
|
||||
const TString& prefisso() const { return get("S6"); }
|
||||
const TString& postfisso() const { return get("S7"); }
|
||||
const bool num_provv() const { return get_bool("B0"); }
|
||||
const bool auto_num() const { return get_bool("B1"); }
|
||||
const TString & tipo_doc(int i) const { CHECK(i < MAX_TIPI_DOC, "Impossibbile tipo documento"); return ((TString& ) get("S2").mid(i << 2, 4)).trim();}
|
||||
int ntipi_doc() const {const int l = get("S2").len(); return l ? (((l - 1) >> 2) + 1) : 0;}
|
||||
|
||||
const char * complete_num (long num);
|
||||
int status() { return _status; }
|
||||
TCodice_numerazione(const char* codnum = NULL);
|
||||
TCodice_numerazione(const TRectype& rec);
|
||||
virtual ~TCodice_numerazione();
|
||||
};
|
||||
|
||||
class TTipo_riga_documento : public TRectype // velib02
|
||||
{
|
||||
|
||||
@ -356,8 +388,8 @@ public:
|
||||
void reset_fields(TAuto_variable_rectype& rec) { rec.remove_field(); }
|
||||
void set_fields(TAuto_variable_rectype& rec);
|
||||
|
||||
real prezzo(bool scontato, bool lordo, int ndec) const ;
|
||||
real importo(bool scontato , bool lordo, int ndec) const ;
|
||||
real prezzo(bool scontato, bool lordo, int ndec = AUTO_DECIMALS) const ;
|
||||
real importo(bool scontato , bool lordo, int ndec = AUTO_DECIMALS) const ;
|
||||
real iva(int ndec) const;
|
||||
real imponibile() const;
|
||||
real imposta(bool round = TRUE) const;
|
||||
@ -380,6 +412,8 @@ class TDocumento : public TAuto_variable_rectype // velib03
|
||||
TRecfield *_codcf;
|
||||
TRecfield *_cod_occas;
|
||||
static TAssoc_array _tipi;
|
||||
static TAssoc_array _numerazioni;
|
||||
|
||||
int _liv_len[4];
|
||||
|
||||
TRecord_array _rows; // Array di TRectype per le righe documenti di vendita.
|
||||
@ -429,6 +463,7 @@ public:
|
||||
bool destroy_row(int n, bool pack = FALSE) { return _rows.destroy_row(n, pack); }
|
||||
void destroy_rows() { _rows.destroy_rows(); }
|
||||
virtual int read(TBaseisamfile& f, word op = _isequal, word lockop = _nolock);
|
||||
virtual int readat(TBaseisamfile& f, TRecnotype nrec, 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;
|
||||
@ -443,19 +478,20 @@ public:
|
||||
|
||||
char tipo_numerazione() const { return get_char("PROVV"); }
|
||||
int anno() const { return get_int("ANNO"); }
|
||||
const TString& numerazione() { return get("CODNUM"); }
|
||||
const TString& numerazione() const { return get("CODNUM"); }
|
||||
long numero() const { return get_long("NDOC"); }
|
||||
TDate data() const { return get_date("DATADOC"); }
|
||||
const bool in_valuta() const;
|
||||
bool in_valuta() const;
|
||||
const TString& valuta() const { return get("CODVAL"); }
|
||||
const real cambio() const { return get_real("CAMBIO"); }
|
||||
real cambio() const { return get_real("CAMBIO"); }
|
||||
bool tipo_valido() const { return get("TIPODOC").not_empty(); }
|
||||
static const TTipo_documento& tipo(const char * tipodoc);
|
||||
const TTipo_documento& tipo() const;
|
||||
const TCodice_numerazione& codice_numerazione() const;
|
||||
void set_tipo(const char * tipo) { head().put("TIPODOC", tipo);}
|
||||
void set_liv_giac_len(int liv, int len) { _liv_len[liv - 1] = len;}
|
||||
int liv_giac_len(int liv) const { return _liv_len[liv - 1];}
|
||||
|
||||
bool provvisorio() const { return get_char("PROVV") == 'P'; }
|
||||
char stato() const { return get_char("STATO"); }
|
||||
void stato(char s) { put("STATO", s); }
|
||||
|
||||
@ -472,13 +508,11 @@ public:
|
||||
void reset_fields(TAuto_variable_rectype & rec) { rec.remove_field(); }
|
||||
void set_fields(TAuto_variable_rectype & rec);
|
||||
|
||||
|
||||
real spese_incasso(real & imp, int ndec, TTipo_importo netto = _lordo) const ;
|
||||
real bolli(real & imp, int ndec, TTipo_importo netto = _lordo) const ;
|
||||
real descrizione() const;
|
||||
real riferimento() const;
|
||||
real imponibile(bool spese = FALSE, int ndec = 100) const;
|
||||
real imposta(bool spese = FALSE, int ndec = 100) const;
|
||||
|
||||
real imponibile(bool spese = FALSE, int ndec = AUTO_DECIMALS) const;
|
||||
real imposta(bool spese = FALSE, int ndec = AUTO_DECIMALS) const;
|
||||
real totale_doc() const;
|
||||
real totale_netto() const;
|
||||
real basesconto() const;
|
||||
@ -908,36 +942,6 @@ struct dec_parm {
|
||||
// add other groups here
|
||||
};
|
||||
|
||||
class TCodice_numerazione : public TRectype
|
||||
{
|
||||
int _status;
|
||||
public:
|
||||
TObject* dup() const { return new TCodice_numerazione(codice()); }
|
||||
|
||||
public:
|
||||
int read(const char * cod);
|
||||
const TString& codice() const { return get("CODTAB"); }
|
||||
const TString& descrizione() const { return get("S0"); }
|
||||
const TString& prefisso() const { return get("S6"); }
|
||||
const TString& postfisso() const { return get("S7"); }
|
||||
// const bool manual_num() const { return get_bool("B0"); }
|
||||
const bool num_provv() const { return get_bool("B0"); }
|
||||
const bool auto_num() const { return get_bool("B1"); }
|
||||
// const TString& tipo_doc1() { return get("S2").mid(0,4);}
|
||||
// const TString& tipo_doc2() { return get("S2").mid(4,4);}
|
||||
// const TString& tipo_doc3() { return get("S2").mid(8,4);}
|
||||
// const TString& tipo_doc4() { return get("S2").mid(12,4);}
|
||||
// const TString& tipo_doc5() { return get("S2").mid(16,4);}
|
||||
const TString & tipo_doc(int i) const { CHECK(i < MAX_TIPI_DOC, "Impossibbile tipo documento"); return ((TString& ) get("S2").mid(i << 2, 4)).trim();}
|
||||
int ntipi_doc() const {const int l = get("S2").len(); return l ? (((l - 1) >> 2) + 1) : 0;}
|
||||
|
||||
const char * complete_num (long num);
|
||||
int status() { return _status; }
|
||||
TCodice_numerazione(const char* codnum = NULL);
|
||||
TCodice_numerazione(const TRectype& rec);
|
||||
virtual ~TCodice_numerazione();
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// classe TDocumentoEsteso: oggetto che ha come finalita' il calcolo dei riepiloghi IVA
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -372,6 +372,9 @@ void TRiga_documento::set_fields(TAuto_variable_rectype & rec)
|
||||
|
||||
real TRiga_documento::prezzo(bool scontato, bool lordo, int ndec) const
|
||||
{
|
||||
if (ndec == AUTO_DECIMALS)
|
||||
ndec = doc().in_valuta() ? 3 : 0;
|
||||
|
||||
real prezzo = get_real("PREZZO");
|
||||
if (scontato)
|
||||
prezzo = prezzo_scontato(prezzo, get("SCONTO"));
|
||||
@ -384,6 +387,9 @@ real TRiga_documento::prezzo(bool scontato, bool lordo, int ndec) const
|
||||
|
||||
real TRiga_documento::importo(bool scontato, bool lordo, int ndec) const
|
||||
{
|
||||
if (ndec == AUTO_DECIMALS)
|
||||
ndec = doc().in_valuta() ? 3 : 0;
|
||||
|
||||
real importo;
|
||||
|
||||
TTipo_calcolo c = _nessun_calcolo;
|
||||
@ -460,10 +466,13 @@ real TRiga_documento::importo(bool scontato, bool lordo, int ndec) const
|
||||
|
||||
real TRiga_documento::iva(int ndec) const
|
||||
{
|
||||
if (ndec == AUTO_DECIMALS)
|
||||
ndec = doc().in_valuta() ? 3 : 0;
|
||||
|
||||
((TRiga_documento *) this)->_iva_calc = TRUE;
|
||||
real iva(::iva(imponibile(), iva(), ndec));
|
||||
real zanicchi = ::iva(imponibile(), iva(), ndec);
|
||||
((TRiga_documento *) this)->_iva_calc = FALSE;
|
||||
return iva;
|
||||
return zanicchi;
|
||||
}
|
||||
|
||||
real TRiga_documento::imponibile() const
|
||||
|
@ -195,6 +195,7 @@ TFormula_documento * TTipo_documento::succ_formula(bool restart)
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TAssoc_array TDocumento::_tipi;
|
||||
TAssoc_array TDocumento::_numerazioni;
|
||||
|
||||
TDocumento::TDocumento()
|
||||
: TAuto_variable_rectype(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA"), _nuovo(TRUE),
|
||||
@ -510,17 +511,18 @@ TRiga_documento& TDocumento::new_row(const char *tipo)
|
||||
|
||||
int TDocumento::read(TBaseisamfile& f, word op, word lockop)
|
||||
{
|
||||
TRiga_documento* key = new TRiga_documento(this);
|
||||
TRectype rec(*this);
|
||||
const TRectype rec(*this); // vecchia testata
|
||||
|
||||
int err = TRectype::read(f, op, lockop);
|
||||
|
||||
const char pr = tipo_numerazione();
|
||||
const int an = anno();
|
||||
const TString16 cn = numerazione();
|
||||
const long nu = numero();
|
||||
|
||||
CHECK(nu > 0, "Numero documento nullo.");
|
||||
TRiga_documento* key = new TRiga_documento(this);
|
||||
set_key(*key, pr, an, cn, nu);
|
||||
|
||||
int err = TRectype::read(f);
|
||||
_cli_for.zero();
|
||||
_occas.zero();
|
||||
|
||||
@ -549,6 +551,32 @@ int TDocumento::read(char provv, int anno, const char* codnum, long numdoc, word
|
||||
return read(op, lockop);
|
||||
}
|
||||
|
||||
// Guy: Mancava! Copio bovinamente tanto verra presto rimpiazzata da i Multirectype
|
||||
int TDocumento::readat(TBaseisamfile& f, TRecnotype nrec, word lockop)
|
||||
{
|
||||
int err = TRectype::readat(f, nrec, lockop);
|
||||
|
||||
_cli_for.zero();
|
||||
_occas.zero();
|
||||
|
||||
const char pr = tipo_numerazione();
|
||||
const int an = anno();
|
||||
const TString16 cn = numerazione();
|
||||
const long nu = numero();
|
||||
CHECK(nu > 0, "Numero documento nullo.");
|
||||
TRiga_documento* key = new TRiga_documento(this);
|
||||
set_key(*key, pr, an, cn, nu);
|
||||
|
||||
_nuovo = FALSE;
|
||||
_rows.read(key); //ok
|
||||
|
||||
set_riga_sconto();
|
||||
if (is_fattura())
|
||||
set_riga_esenzione();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
long TDocumento::renum(long numdoc)
|
||||
{
|
||||
if (numdoc <= 0)
|
||||
@ -898,7 +926,7 @@ int TDocumento::remove(TBaseisamfile& f) const
|
||||
return err;
|
||||
}
|
||||
|
||||
const bool TDocumento::in_valuta() const
|
||||
bool TDocumento::in_valuta() const
|
||||
{
|
||||
const TString& val = valuta();
|
||||
return (val.not_empty() && val != "LIT");
|
||||
@ -910,7 +938,10 @@ TRiga_documento & TDocumento::row(int index)
|
||||
TRiga_documento * r = NULL;
|
||||
|
||||
if (index <= nrows)
|
||||
{
|
||||
r = &((TRiga_documento &) _rows.row(index, FALSE));
|
||||
CHECKD(r, "Riga documento non esistente ", index);
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECKD((index == nrows + 1 && (_sconto != NULL || _esenzione != NULL)) || (index == nrows + 2 && _sconto != NULL && _esenzione != NULL),
|
||||
@ -970,6 +1001,19 @@ const TTipo_documento& TDocumento::tipo() const
|
||||
return tipo(tipodoc);
|
||||
}
|
||||
|
||||
const TCodice_numerazione& TDocumento::codice_numerazione() const
|
||||
{
|
||||
const TString16 key(numerazione());
|
||||
TCodice_numerazione* o = (TCodice_numerazione*)_numerazioni.objptr(key);
|
||||
if (o == NULL)
|
||||
{
|
||||
o = new TCodice_numerazione(key);
|
||||
_numerazioni.add(key, o);
|
||||
}
|
||||
return *o;
|
||||
}
|
||||
|
||||
|
||||
bool TDocumento::raggruppabile(const TDocumento& doc, TToken_string& campi) const
|
||||
{
|
||||
bool ok = raggruppabile() && doc.raggruppabile();
|
||||
@ -1037,7 +1081,7 @@ void TDocumento::set_fields(TAuto_variable_rectype & rec)
|
||||
real TDocumento::imponibile(bool spese, int ndec) const
|
||||
{
|
||||
real val;
|
||||
if (ndec > 99)
|
||||
if (ndec == AUTO_DECIMALS)
|
||||
ndec = in_valuta() ? 3 : 0;
|
||||
|
||||
for (int i = rows(); i > 0; i--)
|
||||
@ -1057,7 +1101,7 @@ real TDocumento::imposta(bool spese, int ndec) const
|
||||
{
|
||||
TAssoc_array ive;
|
||||
|
||||
if (ndec > 99)
|
||||
if (ndec == AUTO_DECIMALS)
|
||||
ndec = in_valuta() ? 3 : 0;
|
||||
|
||||
for (int i = rows(); i > 0; i--)
|
||||
|
Loading…
x
Reference in New Issue
Block a user