Implose ed esplose le librerie velib01 e velib02
git-svn-id: svn://10.65.10.50/trunk@4509 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
10623dc466
commit
691485d7de
@ -1,93 +0,0 @@
|
|||||||
#ifndef __RIGHEDOC_H
|
|
||||||
#include "righedoc.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __VE0100_H
|
|
||||||
#include "ve0100.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __VERIG_H
|
|
||||||
#include "verig.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __VE0100C_H
|
|
||||||
#include "ve0100c.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __SCONTI_H
|
|
||||||
#include "sconti.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void TRiga_documento_motore::load(TSheet_field & f, TToken_string& row)
|
|
||||||
{
|
|
||||||
put( "STATORIGA", row.get( f.cid2index(FR_STATORIGA) ) );
|
|
||||||
put( "TIPORIGA", row.get( f.cid2index(FR_TIPORIGA )) );
|
|
||||||
TString16 codmag(row.get(f.cid2index(FR_CODMAG)));
|
|
||||||
|
|
||||||
codmag.left_just(3);
|
|
||||||
codmag << row.get( f.cid2index(FR_CODDEP ));
|
|
||||||
put( "CODMAG", codmag);
|
|
||||||
put( "CODART", row.get( f.cid2index(FR_CODART )) );
|
|
||||||
TString s(row.get(f.cid2index(FR_DESCR)));
|
|
||||||
int split_pos = s.find('\n');
|
|
||||||
if (split_pos > 0)
|
|
||||||
{
|
|
||||||
put( "DESCR", s.left(split_pos));
|
|
||||||
put("DESCLUNGA", "X");
|
|
||||||
s.ltrim(split_pos);
|
|
||||||
put("DESCEST", s);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
put("DESCR", s);
|
|
||||||
put("DESCLUNGA", "");
|
|
||||||
zero("DESCEST");
|
|
||||||
}
|
|
||||||
|
|
||||||
put( "PREZZO", row.get( f.cid2index(FR_PREZZO )) );
|
|
||||||
put( "UMQTA", row.get( f.cid2index(FR_UMQTA )) );
|
|
||||||
put( "QTA", row.get( f.cid2index(FR_QTA )) );
|
|
||||||
put( "QTAEVASA", row.get( f.cid2index(FR_QTAEVASA )) );
|
|
||||||
put( "RIGAEVASA", row.get( f.cid2index(FR_RIGAEVASA )) );
|
|
||||||
put( "TARA", row.get( f.cid2index(FR_TARA )) );
|
|
||||||
put( "PNETTO", row.get( f.cid2index(FR_PNETTO )) );
|
|
||||||
put( "NCOLLI", row.get( f.cid2index(FR_NCOLLI )) );
|
|
||||||
put( "DAEVADERE", row.get( f.cid2index(FR_DAEVADERE )) );
|
|
||||||
put( "SCONTO", row.get( f.cid2index(FR_SCONTO )) );
|
|
||||||
put( "PERCPROV", row.get( f.cid2index(FR_PERCPROV )) );
|
|
||||||
put( "IMPFISSO", row.get( f.cid2index(FR_IMPFISSO )) );
|
|
||||||
put( "CODIVA", row.get( f.cid2index(FR_CODIVA )) );
|
|
||||||
put( "ADDIVA", row.get( f.cid2index(FR_ADDIVA )) );
|
|
||||||
put( "ASPBENI", row.get( f.cid2index(FR_ASPBENI )) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void TRiga_documento_motore::save(TSheet_field & f, TToken_string& row )
|
|
||||||
{
|
|
||||||
row.add( get( "STATORIGA" ), f.cid2index(FR_STATORIGA ));
|
|
||||||
row.add( get( "TIPORIGA" ), f.cid2index(FR_TIPORIGA ));
|
|
||||||
const TString codmag(get("CODMAG"));
|
|
||||||
row.add( codmag.left(3), f.cid2index(FR_CODMAG ));
|
|
||||||
row.add( codmag.mid(3), f.cid2index(FR_CODDEP ));
|
|
||||||
row.add( get( "CODART" ), f.cid2index(FR_CODART ));
|
|
||||||
TString s(get("DESCR"));
|
|
||||||
if (get_bool("DESCLUNGA"))
|
|
||||||
s << get("DESCEST");
|
|
||||||
row.add(s, f.cid2index(FR_DESCR ));
|
|
||||||
row.add( get( "UMQTA" ), f.cid2index(FR_UMQTA ));
|
|
||||||
row.add( get( "PREZZO" ), f.cid2index(FR_PREZZO ));
|
|
||||||
row.add( get( "QTA" ), f.cid2index(FR_QTA ));
|
|
||||||
row.add( get( "QTAEVASA" ), f.cid2index(FR_QTAEVASA ));
|
|
||||||
row.add( get( "RIGAEVASA" ), f.cid2index(FR_RIGAEVASA ));
|
|
||||||
row.add( get( "TARA" ), f.cid2index(FR_TARA ));
|
|
||||||
row.add( get( "PNETTO" ), f.cid2index(FR_PNETTO ));
|
|
||||||
row.add( get( "NCOLLI" ), f.cid2index(FR_NCOLLI ));
|
|
||||||
row.add( get( "DAEVADERE" ), f.cid2index(FR_DAEVADERE ));
|
|
||||||
row.add( get( "SCONTO" ), f.cid2index(FR_SCONTO ));
|
|
||||||
row.add( get( "PERCPROV" ), f.cid2index(FR_PERCPROV ));
|
|
||||||
row.add( get( "IMPFISSO" ), f.cid2index(FR_IMPFISSO ));
|
|
||||||
row.add( get( "CODIVA" ), f.cid2index(FR_CODIVA ));
|
|
||||||
row.add( get( "ADDIVA" ), f.cid2index(FR_ADDIVA ));
|
|
||||||
row.add( get( "ASPBENI" ), f.cid2index(FR_ASPBENI ));
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
|||||||
#ifndef __RIGHEDOC_H
|
|
||||||
#define __RIGHEDOC_H
|
|
||||||
// Numero di colonne presenti sullo sheet totale
|
|
||||||
#ifndef __ASSOC_H
|
|
||||||
#include "assoc.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __REAL_H
|
|
||||||
#include "real.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __ISAM_H
|
|
||||||
#include "isam.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __EXPR_H
|
|
||||||
#include "expr.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __TABUTIL_H
|
|
||||||
#include "tabutil.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __VARMASK_H
|
|
||||||
#include "varmask.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __VELIB01_H
|
|
||||||
#include "velib01.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class TRiga_documento_motore : public TRiga_documento
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Carica la riga dalla riga dello sheet
|
|
||||||
void load( TSheet_field& f, TToken_string& row);
|
|
||||||
// Registra la riga sullo sheet
|
|
||||||
void save( TSheet_field& f, TToken_string& row);
|
|
||||||
|
|
||||||
TRiga_documento_motore(TDocumento* doc) : TRiga_documento(doc) { }
|
|
||||||
TRiga_documento_motore(const TRiga_documento& rec, TDocumento* doc) : TRiga_documento(rec, doc) { }
|
|
||||||
|
|
||||||
virtual ~TRiga_documento_motore() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -9,8 +9,8 @@
|
|||||||
#include "tclifor.h"
|
#include "tclifor.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __VELIB01_H
|
#ifndef __VELIB_H
|
||||||
#include "velib01.h"
|
#include "velib.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __CONFIG_H
|
#ifndef __CONFIG_H
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
#include "veini.h"
|
#include "veini.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __VELIB01_H
|
#ifndef __VELIB_H
|
||||||
#include <velib01.h>
|
#include <velib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const TString& TData_picker::get( const TString& table, const TString& codtab, const TString& field )
|
const TString& TData_picker::get( const TString& table, const TString& codtab, const TString& field )
|
||||||
|
@ -81,10 +81,6 @@
|
|||||||
#include "tclifor.h"
|
#include "tclifor.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __RIGHEDOC_H
|
|
||||||
#include "righedoc.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __VARMASK_H
|
#ifndef __VARMASK_H
|
||||||
#include <varmask.h>
|
#include <varmask.h>
|
||||||
#endif
|
#endif
|
||||||
@ -97,8 +93,8 @@
|
|||||||
#include "sconti.h"
|
#include "sconti.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __VELIB01_H
|
#ifndef __VELIB_H
|
||||||
#include "velib01.h"
|
#include "velib.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Definizione della classe dell'applicazione motore
|
// Definizione della classe dell'applicazione motore
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#ifndef __VELIB01_H
|
#ifndef __VELIB_H
|
||||||
#define __VELIB01_H
|
#define __VELIB_H
|
||||||
|
|
||||||
|
|
||||||
#ifndef __RELATION_H
|
#ifndef __RELATION_H
|
||||||
#include <relation.h>
|
#include <relation.h>
|
||||||
@ -20,6 +21,10 @@
|
|||||||
#ifndef __PAGAMENT_H
|
#ifndef __PAGAMENT_H
|
||||||
#include "../cg/pagament.h"
|
#include "../cg/pagament.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __TCLIFOR_H
|
||||||
|
#include "tclifor.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define RIGA_MERCE 'M'
|
#define RIGA_MERCE 'M'
|
||||||
#define RIGA_SPESEDOC 'S'
|
#define RIGA_SPESEDOC 'S'
|
||||||
@ -33,6 +38,7 @@ class TRiga_documento;
|
|||||||
class TCond_vendita;
|
class TCond_vendita;
|
||||||
class TIVA;
|
class TIVA;
|
||||||
|
|
||||||
|
// velib01
|
||||||
real lordo2netto(real& lordo, const TString& codiva, int ndec);
|
real lordo2netto(real& lordo, const TString& codiva, int ndec);
|
||||||
inline real lordo2netto(real& lordo, const TString& codiva, bool is_valuta = FALSE) { return lordo2netto(lordo, codiva, is_valuta ? 3 : 0);}
|
inline real lordo2netto(real& lordo, const TString& codiva, bool is_valuta = FALSE) { return lordo2netto(lordo, codiva, is_valuta ? 3 : 0);}
|
||||||
real netto2lordo(const real& netto, const TString& codiva, int ndec);
|
real netto2lordo(const real& netto, const TString& codiva, int ndec);
|
||||||
@ -76,7 +82,7 @@ class TDocumento_variable_field : public TVariable_field
|
|||||||
~TDocumento_variable_field() {}
|
~TDocumento_variable_field() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TSpesa_prest : public TRectype
|
class TSpesa_prest : public TRectype // velib01
|
||||||
{
|
{
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -102,7 +108,7 @@ public:
|
|||||||
virtual ~TSpesa_prest() {}
|
virtual ~TSpesa_prest() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TIVA : public TRectype
|
class TIVA : public TRectype // velib01
|
||||||
{
|
{
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -122,7 +128,7 @@ public:
|
|||||||
virtual ~TIVA() {}
|
virtual ~TIVA() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TExpr_documento : public TExpression
|
class TExpr_documento : public TExpression // velib01
|
||||||
{
|
{
|
||||||
TDocumento * _doc;
|
TDocumento * _doc;
|
||||||
TRiga_documento * _row;
|
TRiga_documento * _row;
|
||||||
@ -154,7 +160,7 @@ public:
|
|||||||
|
|
||||||
enum TTipo_formula { _documento, _riga };
|
enum TTipo_formula { _documento, _riga };
|
||||||
|
|
||||||
class TFormula_documento : public TRectype
|
class TFormula_documento : public TRectype // velib01
|
||||||
{
|
{
|
||||||
TString16 _tab;
|
TString16 _tab;
|
||||||
TExpr_documento * _expr;
|
TExpr_documento * _expr;
|
||||||
@ -179,8 +185,7 @@ public:
|
|||||||
virtual ~TFormula_documento();
|
virtual ~TFormula_documento();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TTipo_documento : public TRectype // velib03
|
||||||
class TTipo_documento : public TRectype
|
|
||||||
{
|
{
|
||||||
enum { _altro, _fattura, _bolla, _ordine};
|
enum { _altro, _fattura, _bolla, _ordine};
|
||||||
|
|
||||||
@ -232,7 +237,7 @@ public:
|
|||||||
virtual ~TTipo_documento();
|
virtual ~TTipo_documento();
|
||||||
};
|
};
|
||||||
|
|
||||||
class TTipo_riga_documento : public TRectype
|
class TTipo_riga_documento : public TRectype // velib02
|
||||||
{
|
{
|
||||||
|
|
||||||
static TAssoc_array _formule_riga;
|
static TAssoc_array _formule_riga;
|
||||||
@ -270,7 +275,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TRiga_documento : public TAuto_variable_rectype
|
class TRiga_documento : public TAuto_variable_rectype // velib02
|
||||||
{
|
{
|
||||||
TDocumento * _doc;
|
TDocumento * _doc;
|
||||||
static TAssoc_array _tipi;
|
static TAssoc_array _tipi;
|
||||||
@ -337,7 +342,7 @@ public:
|
|||||||
|
|
||||||
enum TTipo_importo { _lordo, _netto, _imposta };
|
enum TTipo_importo { _lordo, _netto, _imposta };
|
||||||
|
|
||||||
class TDocumento : public TAuto_variable_rectype
|
class TDocumento : public TAuto_variable_rectype // velib03
|
||||||
{
|
{
|
||||||
static TAssoc_array _tipi;
|
static TAssoc_array _tipi;
|
||||||
|
|
||||||
@ -446,7 +451,7 @@ public:
|
|||||||
virtual ~TDocumento();
|
virtual ~TDocumento();
|
||||||
};
|
};
|
||||||
|
|
||||||
class TDocumento_mask : public TVariable_mask
|
class TDocumento_mask : public TVariable_mask // velib03
|
||||||
{
|
{
|
||||||
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
|
||||||
@ -465,7 +470,7 @@ public:
|
|||||||
virtual ~TDocumento_mask() { }
|
virtual ~TDocumento_mask() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TLista_documenti : public TObject
|
class TLista_documenti : public TObject // velib04
|
||||||
{
|
{
|
||||||
TArray _documenti;
|
TArray _documenti;
|
||||||
|
|
||||||
@ -491,7 +496,7 @@ public:
|
|||||||
virtual ~TLista_documenti() { }
|
virtual ~TLista_documenti() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TLista_clifo : public TObject
|
class TLista_clifo : public TObject // velib04
|
||||||
{
|
{
|
||||||
class TClifo : public TObject
|
class TClifo : public TObject
|
||||||
{
|
{
|
||||||
@ -545,13 +550,13 @@ public:
|
|||||||
virtual ~TLista_clifo() { }
|
virtual ~TLista_clifo() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TLista_clienti : public TLista_clifo
|
class TLista_clienti : public TLista_clifo
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
virtual char tipo() const { return 'C'; }
|
virtual char tipo() const { return 'C'; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TLista_fornitori : public TLista_clifo
|
class TLista_fornitori : public TLista_clifo
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
virtual char tipo() const { return 'F'; }
|
virtual char tipo() const { return 'F'; }
|
||||||
@ -559,7 +564,7 @@ protected:
|
|||||||
|
|
||||||
enum TTipo_elaborazione {_esterna, _consegna_ordini, _fatturazione_bolle, _contabilizzazione, _copia_documento, _generazione_effetti };
|
enum TTipo_elaborazione {_esterna, _consegna_ordini, _fatturazione_bolle, _contabilizzazione, _copia_documento, _generazione_effetti };
|
||||||
|
|
||||||
class TElaborazione : public TRectype
|
class TElaborazione : public TRectype // velib04
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
int read(const char* cod);
|
int read(const char* cod);
|
||||||
@ -594,7 +599,7 @@ public:
|
|||||||
virtual ~TElaborazione() { }
|
virtual ~TElaborazione() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TEsterna : public TElaborazione
|
class TEsterna : public TElaborazione // velib04
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||||
@ -605,7 +610,7 @@ public:
|
|||||||
virtual ~TEsterna() { }
|
virtual ~TEsterna() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TConsegna_ordini : public TElaborazione
|
class TConsegna_ordini : public TElaborazione // velib05
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||||
@ -616,7 +621,7 @@ public:
|
|||||||
virtual ~TConsegna_ordini() { }
|
virtual ~TConsegna_ordini() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TFatturazione_bolle : public TElaborazione
|
class TFatturazione_bolle : public TElaborazione // velib04
|
||||||
{
|
{
|
||||||
TToken_string _cod_desc;
|
TToken_string _cod_desc;
|
||||||
|
|
||||||
@ -633,7 +638,7 @@ public:
|
|||||||
virtual ~TFatturazione_bolle() { }
|
virtual ~TFatturazione_bolle() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TContabilizzazione : public TElaborazione
|
class TContabilizzazione : public TElaborazione // velib04
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||||
@ -644,7 +649,7 @@ public:
|
|||||||
virtual ~TContabilizzazione() { }
|
virtual ~TContabilizzazione() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TCopia_documento : public TElaborazione
|
class TCopia_documento : public TElaborazione // velib04
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||||
@ -656,7 +661,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TGenerazione_effetti : public TElaborazione
|
class TGenerazione_effetti : public TElaborazione // velib04
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
virtual bool elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||||
@ -667,7 +672,7 @@ public:
|
|||||||
virtual ~TGenerazione_effetti() { }
|
virtual ~TGenerazione_effetti() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TLista_elaborazioni : public TObject
|
class TLista_elaborazioni : public TObject // velib04
|
||||||
{
|
{
|
||||||
TAssoc_array * _elab;
|
TAssoc_array * _elab;
|
||||||
|
|
||||||
@ -682,4 +687,142 @@ public:
|
|||||||
virtual ~TLista_elaborazioni();
|
virtual ~TLista_elaborazioni();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct dec_parm {
|
||||||
|
int pri_lit,
|
||||||
|
pri_val,
|
||||||
|
qta_lit,
|
||||||
|
qta_val, // si lo so non ha senso, ma lo faccio lo stesso
|
||||||
|
imp_lit,
|
||||||
|
imp_val;
|
||||||
|
// 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& prefisso() const { return get("S6"); }
|
||||||
|
const TString& postfisso() const { return get("S7"); }
|
||||||
|
const bool manual_num() 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 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
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class TRiepilogo_Iva : public TObject
|
||||||
|
{
|
||||||
|
real _imp;
|
||||||
|
real _iva;
|
||||||
|
real _ali;
|
||||||
|
byte _tipo;
|
||||||
|
TString16 _cod;
|
||||||
|
TString _des;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
public:
|
||||||
|
real& imp() { return _imp;} // Imponibile
|
||||||
|
real& iva() { return _iva;} // Iva
|
||||||
|
real& ali() { return _ali;} // Aliquota
|
||||||
|
TString& cod() { return _cod;} // Descrizione
|
||||||
|
TString& des() { return _des;} // Descrizione
|
||||||
|
byte& tipo(){ return _tipo;}// Tipo (Vedi opzioni per la selzione di filtro nella validate())
|
||||||
|
void zero(){ _imp = 0.0; _iva = 0.0; _ali = 0.0; _tipo = 0; _cod = ""; _des = ""; }
|
||||||
|
virtual TObject* dup() const { return new TRiepilogo_Iva(*this); }
|
||||||
|
TRiepilogo_Iva& operator = (TRiepilogo_Iva& a);
|
||||||
|
TRiepilogo_Iva() {_imp = 0.0; _iva = 0.0; _ali = 0.0; _tipo = 0;}
|
||||||
|
~TRiepilogo_Iva() {};
|
||||||
|
};
|
||||||
|
|
||||||
|
class TDocumentoEsteso : public TDocumento
|
||||||
|
{
|
||||||
|
// Parametri del documento
|
||||||
|
dec_parm _parm; // Parametri per gli arrotondamenti
|
||||||
|
TTable * _iva; // Tabella codici IVA
|
||||||
|
|
||||||
|
// Totali del documento ricalcolati non appena la tabellina di riepilogo IVA e' completa
|
||||||
|
real _importi_netti, _imposte;
|
||||||
|
|
||||||
|
// membri per il calcolo del riepilogo IVA
|
||||||
|
bool _sum_selected; // TRUE se ha selezionato una riga del riepilogo, funge da semaforo per leggere la prossima
|
||||||
|
int _sum_filter; // Filtro corrente della riga TRiepilogo_Iva in corso di stampa (-1 se non ha ancora calcolato la tabella)
|
||||||
|
TString_array _order_array; // Array di TToken_string contenenti i codici IVA soddisfacenti ad ogni tipo di filtro
|
||||||
|
TAssoc_array _summary_table; // Array dove vengono memorizzate le imposte per aliquota
|
||||||
|
TArray _summary_array; // Array dove vengono memorizzate le imposte/imponibili per riga
|
||||||
|
TRiepilogo_Iva _sum_current; // Riga corrente del riepilogo
|
||||||
|
|
||||||
|
// membri per il calcolo del riepilogo scadenze
|
||||||
|
TString_array _scadenze_array;// Array che contiene le scadenze ("<data>|<importo>")
|
||||||
|
int _scadenze_current; // indice per identificare l'elementi corrente sull'array (-1 se non ha ancora calcolato)
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
// Funzioni per il riepilogo IVA
|
||||||
|
const bool summary_compiled() { return _sum_filter > -1; }
|
||||||
|
void compile_summary(); // Aggiorna la tabella riepilogativa
|
||||||
|
void summary_filter(byte selector); // filtra la tabellina secondo il filtro corrente se non e' gia' stato fatto
|
||||||
|
void summary_reset(bool force=FALSE); // riposiziona l'array dei codici IVA (_order_array). Se il parametro e' TRUE forza il ricalcolo della tabella
|
||||||
|
void summary_set_next(); // seleziona il prossimo elemento del filtro
|
||||||
|
const TRiepilogo_Iva& sum_current() { return _sum_current; } // ritorna la riga corrente del filtro corrente
|
||||||
|
const char * summary_get(const TString& w); // ritorna l'informazione richiesta estratta dall'elemento corrente
|
||||||
|
int summary_items() { return _summary_table.items();} // ritorna il numero di righe in totale della tabellina
|
||||||
|
const TAssoc_array& summary() { return _summary_table; }
|
||||||
|
const TArray& summary_array() { return _summary_array;}
|
||||||
|
|
||||||
|
|
||||||
|
// Funzioni per il ricalcolo delle scadenze
|
||||||
|
void scadenze_reset(); // riposiziona sulla prima scadenza
|
||||||
|
void scadenze_recalc(); // resetta e ricalcola le scadenze
|
||||||
|
void scadenze_set_next(); // seleziona il prossimo elemento dell'array delle scadenze
|
||||||
|
const char * scadenze_get(const TString& w); // reperisce l'informazione richiesta dall'elemento corrente
|
||||||
|
int scadenze_items() { return _scadenze_array.items(); } // restituisce il numero di scadenze
|
||||||
|
TString_array& scadenze() { return _scadenze_array; }
|
||||||
|
|
||||||
|
// Funzioni di totalizzazione
|
||||||
|
real& tot_importi_netti();
|
||||||
|
real& tot_imposte();
|
||||||
|
real tot_spese();
|
||||||
|
real tot_documento();
|
||||||
|
// restituisce tot_imponibili, tot_esenti, tot_nonsoggetti a seconda del selettore:
|
||||||
|
// 1 = regime normale
|
||||||
|
// 2 = da ventilare (non usato)
|
||||||
|
// 4 = esenti
|
||||||
|
// 8 = non imponibili
|
||||||
|
// 16 = non soggetti
|
||||||
|
// pertanto i non imponibili avranno selettore 1 e gli esenti selettore 4.
|
||||||
|
// per avere esenti + non soggetti il selettore sara' 20 e cosi' via.
|
||||||
|
real tot_imponibili(byte selector);
|
||||||
|
|
||||||
|
// Reperisce l'informazione <what> dal campo G1 della testata
|
||||||
|
const char* get_head_info(const TString& what);
|
||||||
|
|
||||||
|
// Funzioni per settare i parametri
|
||||||
|
void set_decimals(dec_parm & parm) { _parm = parm ; }
|
||||||
|
void set_condv(TCliFor * cli); // Cambia le condizioni di vendita
|
||||||
|
TDocumentoEsteso (const TRectype & rec, dec_parm & parm, TCond_vendita * condv = NULL) ;
|
||||||
|
TDocumentoEsteso (const TRectype & rec, TCond_vendita * condv = NULL) ;
|
||||||
|
TDocumentoEsteso () ;
|
||||||
|
~TDocumentoEsteso();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
2464
ve/velib01.cpp
2464
ve/velib01.cpp
File diff suppressed because it is too large
Load Diff
932
ve/velib02.cpp
932
ve/velib02.cpp
@ -1,344 +1,640 @@
|
|||||||
#include "velib02.h"
|
#include "velib.h"
|
||||||
|
#include "vepriv.h"
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
#ifndef __APPLICAT_H
|
||||||
// TCodice_numerazione
|
#include <applicat.h>
|
||||||
/////////////////////////////////////////////////////////////
|
#endif
|
||||||
TCodice_numerazione::TCodice_numerazione(const char* codnum)
|
|
||||||
: TRectype(LF_TABCOM), _status(NOERR)
|
#ifndef __VE0100C_H
|
||||||
|
#include "ve0100c.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __VERIG_H
|
||||||
|
#include "verig.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __SCONTI_H
|
||||||
|
#include "sconti.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// Tipo riga di un documento
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TAssoc_array TTipo_riga_documento::_formule_riga;
|
||||||
|
|
||||||
|
TTipo_riga_documento::TTipo_riga_documento(const char* tiporig)
|
||||||
|
: TRectype(LF_TABCOM), _mask(NULL)
|
||||||
{
|
{
|
||||||
settab("NUM");
|
settab("TRI");
|
||||||
if (codnum && *codnum)
|
_name = "verig";
|
||||||
_status = read(codnum);
|
_name << codice();
|
||||||
|
if (tiporig && *tiporig)
|
||||||
|
read(tiporig);
|
||||||
}
|
}
|
||||||
|
|
||||||
TCodice_numerazione::TCodice_numerazione(const TRectype& rec)
|
TTipo_riga_documento::TTipo_riga_documento(const TRectype& rec)
|
||||||
: TRectype(rec), _status(NOERR)
|
: TRectype(rec), _mask(NULL)
|
||||||
{ }
|
|
||||||
|
|
||||||
TCodice_numerazione::~TCodice_numerazione()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * TCodice_numerazione::complete_num(long num)
|
|
||||||
{
|
{
|
||||||
static TString codnum;
|
_name = "verig";
|
||||||
codnum = prefisso();
|
_name << codice();
|
||||||
codnum << num;
|
read_formule();
|
||||||
codnum << postfisso();
|
|
||||||
return codnum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int TCodice_numerazione::read(const char* codnum)
|
TTipo_riga_documento::~TTipo_riga_documento()
|
||||||
|
{
|
||||||
|
if (_mask) delete _mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TTipo_riga_documento::read(const char* tiporig)
|
||||||
{
|
{
|
||||||
TTable t("%NUM");
|
TTable t("%TRI");
|
||||||
put("CODTAB", codnum);
|
put("CODTAB", tiporig);
|
||||||
int err = TRectype::read(t);
|
int err = TRectype::read(t);
|
||||||
if (err != NOERR)
|
if (err == NOERR)
|
||||||
yesnofatal_box("Codice numerazione errato: %s", codnum);
|
read_formule();
|
||||||
|
else
|
||||||
|
yesnofatal_box("Tipo riga documento errato: %s", tiporig);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
void TTipo_riga_documento::read_formule()
|
||||||
// TRiepilogo IVA
|
|
||||||
/////////////////////////////////////////////////////////////
|
{
|
||||||
TRiepilogo_Iva& TRiepilogo_Iva::operator=(TRiepilogo_Iva& a)
|
TFilename prof(profile_name());
|
||||||
|
|
||||||
|
prof.ext("ini");
|
||||||
|
|
||||||
|
TConfig profile(prof);
|
||||||
|
|
||||||
|
_formule = profile.get("CAMPICALC", "MAIN");
|
||||||
|
_formule.add(profile.get("CALCOLI", "MAIN"));
|
||||||
|
_imponibile = profile.get("IMPONIBILE", "MAIN");
|
||||||
|
if (_imponibile.empty())
|
||||||
|
{
|
||||||
|
_imponibile = "IMPONIBILE";
|
||||||
|
if (_formule.find(_imponibile) < 0)
|
||||||
|
_formule.add("IMPONIBILE=PREZZO()");
|
||||||
|
}
|
||||||
|
if (_imponibile.not_empty() && _formule.find(_imponibile) < 0)
|
||||||
|
{
|
||||||
|
error_box("Campo imponibile (%s) sconosciuto nel tipo riga %s", (const char *) _imponibile, (const char *) codice());
|
||||||
|
_imponibile.cut(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TFormula_documento * TTipo_riga_documento::succ_formula(bool restart)
|
||||||
|
{
|
||||||
|
if (restart)
|
||||||
|
_formule.restart();
|
||||||
|
const TString formula(_formule.get());
|
||||||
|
if (formula.not_empty())
|
||||||
|
{
|
||||||
|
char *expr = NULL;
|
||||||
|
const int p = formula.find("=");
|
||||||
|
if (p > 0)
|
||||||
|
{
|
||||||
|
expr = (char *) (const char *) formula + p;
|
||||||
|
*expr = '\0'; expr++;
|
||||||
|
}
|
||||||
|
TFormula_documento * o = (TFormula_documento*)_formule_riga.objptr(formula);
|
||||||
|
if (o == NULL)
|
||||||
|
{
|
||||||
|
o = new TFormula_documento(_riga, formula, expr);
|
||||||
|
_formule_riga.add(formula, o);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
TVariable_mask * TTipo_riga_documento::mask()
|
||||||
{
|
{
|
||||||
_imp = a.imp(); _iva = a.iva(); _ali = a.ali();
|
if (mask_loaded())
|
||||||
_cod = a.cod(); _tipo = a.tipo(); _des = a.des();
|
return _mask;
|
||||||
|
_mask = new TVariable_mask(mask_name());
|
||||||
|
TFilename proname(profile_name());
|
||||||
|
|
||||||
|
proname.ext( "ini" );
|
||||||
|
|
||||||
|
TConfig pro( proname );
|
||||||
|
int numhandler = pro.get_int( "NHANDLER", "HANDLERS" );
|
||||||
|
|
||||||
|
for( int i = 1; i <= numhandler; i ++ )
|
||||||
|
{
|
||||||
|
TString chiave;
|
||||||
|
chiave.format( "%d", i );
|
||||||
|
TToken_string riga = pro.get( chiave, "HANDLERS" );
|
||||||
|
row_set_handler( *_mask, riga.get_int( 0 ), riga.get_int( 1 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
const int pos = _mask->id2pos(FR_CODART);
|
||||||
|
|
||||||
|
if (pos >= 0)
|
||||||
|
{
|
||||||
|
const TMask_field & f = _mask->field(FR_CODART);
|
||||||
|
if (f.is_edit())
|
||||||
|
{
|
||||||
|
TBrowse * browse = ((TEdit_field &) f).browse();
|
||||||
|
const char tipo_r = tipo();
|
||||||
|
|
||||||
|
if (browse )
|
||||||
|
{
|
||||||
|
const TCursor * cur = browse->cursor();
|
||||||
|
if (cur)
|
||||||
|
{
|
||||||
|
const int num = cur->file().num();
|
||||||
|
if (num == LF_ANAMAG)
|
||||||
|
{
|
||||||
|
_mask->set_handler( FR_CODART, codart_handler );
|
||||||
|
_mask->set_handler( FR_LIV1, liv_handler );
|
||||||
|
_mask->set_handler( FR_LIV2, liv_handler );
|
||||||
|
_mask->set_handler( FR_LIV3, liv_handler );
|
||||||
|
_mask->set_handler( FR_UMQTA, umart_handler );
|
||||||
|
_mask->set_handler( FR_DESCR, descr_handler );
|
||||||
|
_mask->set_handler( FR_QTA, qta_handler );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (tipo_r == RIGA_SPESEDOC || tipo_r == RIGA_PRESTAZIONI)
|
||||||
|
_mask->set_handler( FR_CODART, sppr_handler );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const int posiva = _mask->id2pos(FR_CODIVA);
|
||||||
|
|
||||||
|
if (posiva >= 0)
|
||||||
|
_mask->set_handler( FR_CODIVA, iva_handler );
|
||||||
|
|
||||||
|
return _mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// Riga documento per vendite
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TAssoc_array TRiga_documento::_tipi;
|
||||||
|
TAssoc_array TRiga_documento::_spese;
|
||||||
|
TAssoc_array TRiga_documento::_ive;
|
||||||
|
|
||||||
|
TRiga_documento::TRiga_documento(TDocumento* doc, const char * tipo)
|
||||||
|
: TAuto_variable_rectype(LF_RIGHEDOC), _doc(doc), _iva_calc(FALSE)
|
||||||
|
{
|
||||||
|
if (tipo)
|
||||||
|
set_tipo(tipo);
|
||||||
|
}
|
||||||
|
|
||||||
|
TRiga_documento::TRiga_documento(const TRiga_documento& rec, TDocumento* doc,
|
||||||
|
const char * tipo)
|
||||||
|
: TAuto_variable_rectype(rec), _doc(doc), _iva_calc(FALSE)
|
||||||
|
{
|
||||||
|
if (tipo)
|
||||||
|
set_tipo(tipo);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TTipo_riga_documento& TRiga_documento::tipo() const
|
||||||
|
{
|
||||||
|
const TString16 tiporig(get("TIPORIGA"));
|
||||||
|
CHECK(tiporig.not_empty(), "Tipo riga documento nullo");
|
||||||
|
TTipo_riga_documento* o = (TTipo_riga_documento*)_tipi.objptr(tiporig);
|
||||||
|
if (o == NULL)
|
||||||
|
{
|
||||||
|
if (_tipi.items() == 0)
|
||||||
|
{
|
||||||
|
TTable tri("%TRI"); // Tabella dei tipi riga
|
||||||
|
for (tri.first(); !tri.eof(); tri.next())
|
||||||
|
{
|
||||||
|
const TString16 codice = tri.get("CODTAB");
|
||||||
|
_tipi.add(codice, new TTipo_riga_documento(tri.curr()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
o = (TTipo_riga_documento*)_tipi.objptr(tiporig);
|
||||||
|
if (o == NULL)
|
||||||
|
{
|
||||||
|
o = new TTipo_riga_documento(tiporig);
|
||||||
|
_tipi.add(tiporig, o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *o;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TSpesa_prest & TRiga_documento::spesa() const
|
||||||
|
{
|
||||||
|
const char tipor = tipo().tipo();
|
||||||
|
|
||||||
|
CHECK(tipor == RIGA_SPESEDOC || tipor == RIGA_PRESTAZIONI, "Tipo riga incompatibile con le spese");
|
||||||
|
static long firm = -1;
|
||||||
|
long new_firm = main_app().get_firm();
|
||||||
|
|
||||||
|
if (firm != new_firm)
|
||||||
|
{
|
||||||
|
_spese.destroy();
|
||||||
|
firm = new_firm;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TString16 codice(get("CODART"));
|
||||||
|
TString16 index; index << tipor << codice;
|
||||||
|
|
||||||
|
TSpesa_prest * s = (TSpesa_prest *) _spese.objptr(index);
|
||||||
|
if (s == NULL)
|
||||||
|
{
|
||||||
|
s = new TSpesa_prest(codice, tipor);
|
||||||
|
_spese.add(index, s);
|
||||||
|
}
|
||||||
|
return *s;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TIVA & TRiga_documento::iva(const char *codice)
|
||||||
|
{
|
||||||
|
TIVA * v = (TIVA *) _ive.objptr(codice);
|
||||||
|
if (v == NULL)
|
||||||
|
{
|
||||||
|
v = new TIVA(codice);
|
||||||
|
_ive.add(codice, v);
|
||||||
|
}
|
||||||
|
return *v;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TRiga_documento::sola_descrizione() const
|
||||||
|
{
|
||||||
|
char t = tipo().tipo();
|
||||||
|
if (t <= ' ' && get("QTA").empty() && get("PREZZO").empty())
|
||||||
|
t = RIGA_DESCRIZIONI;
|
||||||
|
return t == RIGA_DESCRIZIONI;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TRiga_documento::forza_sola_descrizione()
|
||||||
|
{
|
||||||
|
// In realta' il test serve anche a caricare la lista dei tipi riga!
|
||||||
|
if (!tipo_valido() || tipo().tipo() != RIGA_DESCRIZIONI)
|
||||||
|
{
|
||||||
|
_tipi.restart();
|
||||||
|
for (const TObject* o = _tipi.get(); o; o = _tipi.get())
|
||||||
|
{
|
||||||
|
const TTipo_riga_documento* trd = (const TTipo_riga_documento*)o;
|
||||||
|
if (trd->tipo() == RIGA_DESCRIZIONI)
|
||||||
|
{
|
||||||
|
put("TIPORIGA", trd->codice());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zero("QTA");
|
||||||
|
zero("PREZZO");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TRectype & TRiga_documento::operator =(const TRectype & r)
|
||||||
|
{
|
||||||
|
TRectype::operator=(r);
|
||||||
|
reset_fields(*this);
|
||||||
|
set_fields(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRectype & TRiga_documento::operator =(const char * r)
|
||||||
|
{
|
||||||
|
TRectype::operator=(r);
|
||||||
|
reset_fields(*this);
|
||||||
|
set_fields(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ritorna TRUE se le due righe del documento possono essere sommate
|
||||||
|
bool TRiga_documento::raggruppabile(const TRiga_documento& r, TToken_string& campi) const
|
||||||
|
{
|
||||||
|
bool ok = TRUE;
|
||||||
|
TString campo;
|
||||||
|
for (const char* c = campi.get(0); c && ok; c = campi.get())
|
||||||
|
{
|
||||||
|
campo = get(c); // Separare le due get!
|
||||||
|
ok &= campo == r.get(c);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRiga_documento& TRiga_documento::operator +=(const TRiga_documento& r)
|
||||||
|
{
|
||||||
|
TToken_string campi("QTA|NCOLLI|QTAEVASA");
|
||||||
|
for (const char* c = campi.get(0); c && ok; c = campi.get())
|
||||||
|
{
|
||||||
|
real num(r.get_real(c));
|
||||||
|
if (!num.is_zero())
|
||||||
|
{
|
||||||
|
num += get_real(c);
|
||||||
|
put(c, num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!get_bool("RIGAEVASA"))
|
||||||
|
{
|
||||||
|
const real qta = get_real("QTA");
|
||||||
|
const real qtaeva = get_real("QTAEVASA");
|
||||||
|
if (qtaeva >= qta)
|
||||||
|
put("RIGAEVASA", "X");
|
||||||
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
void TRiga_documento::set_fields(TAuto_variable_rectype & rec)
|
||||||
//TDocumentoEsteso
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
void TDocumentoEsteso::compile_summary()
|
|
||||||
{
|
|
||||||
_sum_filter = 0;
|
|
||||||
const int items = rows();
|
|
||||||
|
|
||||||
_summary_table.destroy();
|
|
||||||
_summary_array.destroy();
|
|
||||||
_imposte = 0.0;
|
|
||||||
_importi_netti = 0.0;
|
|
||||||
const bool val = in_valuta();
|
|
||||||
// Scorre tutte le righe e compila la tabellina _summary_table, per codice iva,
|
|
||||||
// nonche' il galactic_array _summary_array dove le informazioni sono registrate per singola riga
|
|
||||||
// cio' ad usi generici: porco diavolo!
|
|
||||||
for (int i = 1; i <= items; i++)
|
|
||||||
{
|
|
||||||
TRiga_documento& r = row(i);
|
|
||||||
int nriga = r.get_int("NRIGA");
|
|
||||||
real price = r.get_real("PREZZO");
|
|
||||||
real qta = r.get_real("QTA");
|
|
||||||
real aliquota, sc, imponibile, iva;
|
|
||||||
TString sconto(r.get("SCONTO"));
|
|
||||||
TString codiva(r.get("CODIVA"));
|
|
||||||
_iva->put("CODTAB", codiva);
|
|
||||||
if (_iva->read() != NOERR) continue; // Se non trova il codice salta questa riga
|
|
||||||
|
|
||||||
aliquota = _iva->get_real("R0");
|
|
||||||
price = prezzo_scontato(price, sconto);
|
|
||||||
price.round(val ? _parm.pri_val : _parm.pri_lit); // prezzo scontato
|
|
||||||
qta.round(val ? _parm.qta_val : _parm.qta_lit);
|
|
||||||
imponibile = price * qta;
|
|
||||||
imponibile.round (val? _parm.imp_val : _parm.imp_lit); // imponibile di riga
|
|
||||||
iva = r.iva(val ? _parm.imp_val : _parm.imp_lit);
|
|
||||||
//iva = (imponibile * aliquota) / 100.0;
|
|
||||||
//iva.ceil(val ? _parm.imp_val : _parm.imp_lit); // imposta calcolata
|
|
||||||
|
|
||||||
// Aggiorna o aggiunge l'elemento se non esiste
|
|
||||||
TRiepilogo_Iva riepilogo_tmp,row_riep;
|
|
||||||
const bool exists = _summary_table.is_key(codiva);
|
|
||||||
TRiepilogo_Iva& riepilogo = (exists ? (TRiepilogo_Iva&)_summary_table[codiva] : riepilogo_tmp);
|
|
||||||
// Aggiorna anche il totale importi netti ed il totale imposte
|
|
||||||
_importi_netti += imponibile;
|
|
||||||
_imposte += iva;
|
|
||||||
riepilogo.imp() += imponibile; riepilogo.iva() += iva;
|
|
||||||
row_riep.imp() = imponibile; row_riep.iva() = iva;
|
|
||||||
riepilogo.ali() = aliquota; riepilogo.cod() = codiva;
|
|
||||||
row_riep.ali() = aliquota; row_riep.cod() = codiva;
|
|
||||||
TString16 tipo(_iva->get("S1"));
|
|
||||||
int tipo_i = 1;// Regime IVA normale
|
|
||||||
if (tipo == "VE") tipo = 2;
|
|
||||||
else if (tipo == "ES") tipo = 4;
|
|
||||||
else if (tipo == "NI") tipo = 8;
|
|
||||||
else if (tipo == "NS") tipo= 16;
|
|
||||||
riepilogo.tipo() = tipo_i;
|
|
||||||
row_riep.tipo() = tipo_i;
|
|
||||||
if (riepilogo.tipo() != 1) // Se non e' regime normale salva anche la descrizione
|
|
||||||
{
|
|
||||||
TString s(_iva->get("S0"));
|
|
||||||
riepilogo.des() = s;
|
|
||||||
row_riep.des() = s;
|
|
||||||
}
|
|
||||||
_summary_table.add(codiva,riepilogo,exists);
|
|
||||||
_summary_array.add(row_riep,nriga);
|
|
||||||
}
|
|
||||||
// Inizializza l'array di ordine
|
|
||||||
for (i = 0; i<32;i++)
|
|
||||||
{
|
|
||||||
TToken_string s;
|
|
||||||
_order_array.add(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TDocumentoEsteso::summary_filter(byte selector)
|
|
||||||
{
|
|
||||||
if (_sum_filter == -1) compile_summary(); // Crea la tabella se deve ancora farlo
|
|
||||||
// se ha selezionato una riga in precedenza deve finire di stamparla
|
|
||||||
// ovvero non seleziona il filtro fino a quando non ha ricevuto una summary_set_next()
|
|
||||||
if (_sum_selected) return;
|
|
||||||
//
|
|
||||||
// Procedimento:
|
|
||||||
// Memorizza in un TString_array tante TToken_string quanti sono i filtri possibili
|
|
||||||
// (al massimo 31 [1+2+4+8+16]). Ogni TToken_string contiene i codici IVA
|
|
||||||
// delle righe di TRiepilogo_Iva che soddisfano la condizione di filtro
|
|
||||||
_sum_selected = TRUE;
|
|
||||||
_sum_filter = selector;
|
|
||||||
TToken_string& codici = _order_array.row(_sum_filter-1);
|
|
||||||
if (codici.items() == 0) // Se non c'e' nemmeno un codice IVA allora deve effettuare il filtro
|
|
||||||
{ // ovvero mette in <<codici>> tutti i codici IVA che soddisfano tale filtro
|
|
||||||
// sara' poi la summary_set_next() a selezionare sequenzialmente il giusto codice a seconda del filtro corrente
|
|
||||||
|
|
||||||
// Scorre sequenzialmente la tabella _summary_table e compone la TToken_string con i codici IVA
|
|
||||||
const int items = _summary_table.items();
|
|
||||||
TRiepilogo_Iva* curr = (TRiepilogo_Iva *) _summary_table.first_item();
|
|
||||||
for (int i = 0; i < items && curr != NULL; i++)
|
|
||||||
{
|
|
||||||
if (curr->tipo() & _sum_filter) // se fa parte del filtro selezionato schiaffa il codice nella TToken_string
|
|
||||||
codici.add(curr->cod());
|
|
||||||
curr = (TRiepilogo_Iva*) _summary_table.succ_item();
|
|
||||||
}
|
|
||||||
codici.restart();
|
|
||||||
summary_set_next(); // setta l'elemento corrente
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TDocumentoEsteso::summary_reset(bool force)
|
|
||||||
{
|
|
||||||
const int items = _order_array.items();
|
|
||||||
if (force) _sum_filter = -1;
|
|
||||||
for (int i = 0; i<items; i++)
|
|
||||||
{
|
|
||||||
TToken_string& codici = _order_array.row(i);
|
|
||||||
codici = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TDocumentoEsteso::summary_set_next()
|
|
||||||
{
|
|
||||||
_sum_selected = FALSE;
|
|
||||||
TToken_string& codici = _order_array.row(_sum_filter-1);
|
|
||||||
|
|
||||||
TString16 codiva(codici.get()); // Reperisce il prossimo codice nella lista. (son gia' ordinati per codice)
|
|
||||||
if (codiva.not_empty() && _summary_table.is_key(codiva))
|
|
||||||
{
|
|
||||||
// Estrae da _summary_table i dati relativio al codice corrispondente.
|
|
||||||
TRiepilogo_Iva& riep= (TRiepilogo_Iva&) _summary_table[codiva];
|
|
||||||
_sum_current = riep;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_sum_current.zero(); // se non esiste il codice azzera l'elemento corrente (non stampera' nulla)
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * TDocumentoEsteso::summary_get(const TString& w)
|
|
||||||
{
|
|
||||||
TString ret;
|
|
||||||
if (w == "COD") ret = _sum_current.cod(); // Ritorna il codice IVA
|
|
||||||
if (w == "IMP" && _sum_current.imp() != 0.0) ret = _sum_current.imp().string(); // Ritorna l'imponibile
|
|
||||||
if (w == "IVA" && _sum_current.iva() != 0.0) ret = _sum_current.iva().string(); // Ritorna l'imposta
|
|
||||||
if (w == "ALI" && _sum_current.ali() != 0.0) ret = _sum_current.ali().string(); // Ritorna l'aliquota %
|
|
||||||
if (w == "DES") ret = _sum_current.des(); // Ritorna la descrizione ( se il codice e' regime normale la descr. e' vuota)
|
|
||||||
return (const char *)ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TDocumentoEsteso::scadenze_recalc()
|
|
||||||
{
|
|
||||||
_scadenze_array.destroy();
|
|
||||||
_scadenze_current = -1;
|
|
||||||
TString16 codpag(head().get("CODPAG"));
|
|
||||||
TString16 data(head().get("DATAINSC"));
|
|
||||||
if (data.empty()) data = head().get("DATADOC");
|
|
||||||
TPagamento pag( codpag, data);
|
|
||||||
real totspese = spese();//tot_spese();
|
|
||||||
real totimposte = imposta();//tot_imposte();
|
|
||||||
real totimponibili = totale_doc() - totimposte - totspese;//tot_documento() - totimposte - totspese;
|
|
||||||
const bool valuta = in_valuta();
|
|
||||||
if (valuta)
|
|
||||||
{
|
|
||||||
const real change(cambio());
|
|
||||||
real val1 = totimponibili * change;
|
|
||||||
real val2 = totimposte * change;
|
|
||||||
real val3 = totspese * change;
|
|
||||||
pag.set_total_valuta( totimponibili, totimposte, totspese, change, val1, val2 ,val3);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
pag.set_total( totimponibili, totimposte, totspese );
|
|
||||||
pag.set_rate_auto( );
|
|
||||||
const int numrate = pag.n_rate( );
|
|
||||||
for (int i = 0; i< numrate; i++)
|
|
||||||
{
|
|
||||||
TToken_string t;
|
|
||||||
t.add(pag.data_rata(i));
|
|
||||||
t.add(pag.importo_rata(i,valuta).string());
|
|
||||||
_scadenze_array.add(t);
|
|
||||||
}
|
|
||||||
if (numrate > 0) _scadenze_current++;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char * TDocumentoEsteso::scadenze_get(const TString& w)
|
|
||||||
{
|
|
||||||
TString ret;
|
|
||||||
|
|
||||||
if (_scadenze_current == -1)
|
|
||||||
// calcola le scadenze e le mette in _scadenze_array
|
|
||||||
scadenze_recalc();
|
|
||||||
if (_scadenze_current > -1 && _scadenze_current < _scadenze_array.items())
|
|
||||||
{
|
|
||||||
if (w == "DATA") ret = _scadenze_array.row(_scadenze_current).get(0); // ritorna la data di scadenza
|
|
||||||
if (w == "IMPORTO") ret = _scadenze_array.row(_scadenze_current).get(1); // ritorna l'importo in scadenza
|
|
||||||
}
|
|
||||||
return (const char*)ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TDocumentoEsteso::scadenze_set_next()
|
|
||||||
{
|
|
||||||
if (_scadenze_current < _scadenze_array.items() && _scadenze_current >= 0)
|
|
||||||
_scadenze_current++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TDocumentoEsteso::scadenze_reset()
|
|
||||||
{
|
|
||||||
if (_scadenze_current > 0)
|
|
||||||
_scadenze_current = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
real& TDocumentoEsteso::tot_importi_netti()
|
|
||||||
{
|
|
||||||
if (!summary_compiled()) compile_summary();
|
|
||||||
return _importi_netti;
|
|
||||||
}
|
|
||||||
|
|
||||||
real& TDocumentoEsteso::tot_imposte()
|
|
||||||
{
|
|
||||||
if (!summary_compiled()) compile_summary();
|
|
||||||
return _imposte;
|
|
||||||
}
|
|
||||||
|
|
||||||
real TDocumentoEsteso::tot_spese()
|
|
||||||
{
|
|
||||||
TString16 t("TOTSP");
|
|
||||||
real number(get_head_info(t));
|
|
||||||
return number;
|
|
||||||
}
|
|
||||||
|
|
||||||
real TDocumentoEsteso::tot_documento()
|
|
||||||
{
|
|
||||||
if (!summary_compiled()) compile_summary();
|
|
||||||
real number = _imposte + _importi_netti;
|
|
||||||
return number;
|
|
||||||
}
|
|
||||||
|
|
||||||
real TDocumentoEsteso::tot_imponibili(byte selector)
|
|
||||||
{
|
|
||||||
if (!summary_compiled()) compile_summary();
|
|
||||||
|
|
||||||
real number = 0.0;
|
|
||||||
const int items = _summary_table.items();
|
|
||||||
TRiepilogo_Iva* curr = (TRiepilogo_Iva *) _summary_table.first_item();
|
|
||||||
for (int i = 0; i < items && curr != NULL; i++)
|
|
||||||
{
|
|
||||||
if (curr->tipo() & selector) // se fa parte del filtro selezionato schiaffa il codice nella TToken_string
|
|
||||||
number += curr->imp();
|
|
||||||
curr = (TRiepilogo_Iva*) _summary_table.succ_item();
|
|
||||||
}
|
|
||||||
return number;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char* TDocumentoEsteso::get_head_info(const TString & what)
|
|
||||||
{
|
|
||||||
TToken_string memo(head().get("G1"),'\n'); // prende il campo memo con i totalizzatori. Un totalizzatore per riga nella forma <MACRO>=<VALORE>
|
|
||||||
TString rt;
|
|
||||||
const int items = memo.items();
|
|
||||||
for (int i = 0; i<items; i++) // scorre le righe del memo
|
|
||||||
{
|
|
||||||
TToken_string item(memo.get(),'=');
|
|
||||||
if (what == item.get())
|
|
||||||
{
|
|
||||||
rt = item.get();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (const char*) rt;
|
|
||||||
}
|
|
||||||
|
|
||||||
TDocumentoEsteso::TDocumentoEsteso(const TRectype& rec, TCond_vendita * condv)
|
|
||||||
: TDocumento(rec, condv), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1)
|
|
||||||
{
|
|
||||||
_iva = new TTable("%IVA");
|
|
||||||
// Inizializza i parametri di default
|
|
||||||
_parm.pri_lit = 0; _parm.pri_val = 3;
|
|
||||||
_parm.qta_lit = 3; _parm.qta_val = 3;
|
|
||||||
_parm.imp_lit = 0; _parm.imp_val = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
TDocumentoEsteso::TDocumentoEsteso(const TRectype& rec, dec_parm & parm, TCond_vendita * condv)
|
|
||||||
: TDocumento(rec, condv), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1)
|
|
||||||
{
|
{
|
||||||
_parm = parm;
|
if (get("TIPORIGA").not_empty())
|
||||||
_iva = new TTable("%IVA");
|
{
|
||||||
|
TTipo_riga_documento & tipo_riga = (TTipo_riga_documento &) tipo();
|
||||||
|
|
||||||
|
for (const TFormula_documento * f = tipo_riga.first_formula(); f; f = tipo_riga.succ_formula())
|
||||||
|
{
|
||||||
|
TExpr_documento * exp = f->expr();
|
||||||
|
add_field(new TDocumento_variable_field(f->name(), exp));
|
||||||
|
if (exp)
|
||||||
|
{
|
||||||
|
exp->set_doc(_doc);
|
||||||
|
exp->set_row(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TDocumentoEsteso::TDocumentoEsteso()
|
real TRiga_documento::prezzo(bool scontato, bool lordo, int ndec) const
|
||||||
: TDocumento(), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1)
|
{
|
||||||
|
real prezzo = get_real("PREZZO");
|
||||||
|
if (scontato)
|
||||||
|
prezzo = prezzo_scontato(prezzo, get("SCONTO"));
|
||||||
|
prezzo.round(ndec);
|
||||||
|
if (lordo)
|
||||||
|
prezzo = netto2lordo(prezzo, get("CODIVA"), ndec);
|
||||||
|
prezzo.round(ndec);
|
||||||
|
return prezzo;
|
||||||
|
}
|
||||||
|
|
||||||
|
real TRiga_documento::importo(bool scontato, bool lordo, int ndec) const
|
||||||
{
|
{
|
||||||
_iva = new TTable("%IVA");
|
real importo;
|
||||||
|
|
||||||
|
TTipo_calcolo c = _nessun_calcolo;
|
||||||
|
const char tipor = tipo().tipo();
|
||||||
|
const real qta = get_real("QTA");
|
||||||
|
TString16 field_perc;
|
||||||
|
TCond_vendita cv;
|
||||||
|
|
||||||
|
switch (tipor)
|
||||||
|
{
|
||||||
|
case RIGA_MERCE:
|
||||||
|
c = _qtaprezzo;
|
||||||
|
break;
|
||||||
|
case RIGA_PRESTAZIONI:
|
||||||
|
case RIGA_SPESEDOC:
|
||||||
|
{
|
||||||
|
const TSpesa_prest & s = spesa();
|
||||||
|
|
||||||
|
switch (s.tipo())
|
||||||
|
{
|
||||||
|
case 'Q':
|
||||||
|
c = _qtaprezzo;
|
||||||
|
break;
|
||||||
|
case 'V':
|
||||||
|
c = _valore;
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
c = _percentuale;
|
||||||
|
field_perc = s.field_perc();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RIGA_SCONTI:
|
||||||
|
cv.set_sconto(get("SCONTO"));
|
||||||
|
|
||||||
|
if (cv.get_sconto().not_empty())
|
||||||
|
c = _scontoperc;
|
||||||
|
else
|
||||||
|
c = _scontoimp;
|
||||||
|
break;
|
||||||
|
case RIGA_OMAGGI:
|
||||||
|
if (_iva_calc && get_bool("ADDIVA"))
|
||||||
|
c = _qtaprezzo;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case _qtaprezzo:
|
||||||
|
importo = prezzo(scontato, lordo, ndec) * qta;
|
||||||
|
break;
|
||||||
|
case _valore:
|
||||||
|
importo = prezzo(scontato, lordo, ndec);
|
||||||
|
break;
|
||||||
|
case _percentuale:
|
||||||
|
importo = doc().get_real(field_perc) * get_real("PSPESA") / 100;
|
||||||
|
break;
|
||||||
|
case _scontoimp:
|
||||||
|
importo = -prezzo(FALSE, lordo, ndec);
|
||||||
|
break;
|
||||||
|
case _scontoperc:
|
||||||
|
importo = doc().basesconto() * (cv.sconto_val() - 1.0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
importo.round(ndec);
|
||||||
|
|
||||||
|
return importo;
|
||||||
|
}
|
||||||
|
|
||||||
|
real TRiga_documento::iva(int ndec) const
|
||||||
|
{
|
||||||
|
((TRiga_documento *) this)->_iva_calc = TRUE;
|
||||||
|
real iva(::iva(imponibile(), iva(), ndec));
|
||||||
|
((TRiga_documento *) this)->_iva_calc = FALSE;
|
||||||
|
return iva;
|
||||||
}
|
}
|
||||||
|
|
||||||
TDocumentoEsteso::~TDocumentoEsteso()
|
real TRiga_documento::imponibile() const
|
||||||
{
|
{
|
||||||
if (_iva != NULL) delete _iva;
|
const TString16 field(tipo().imponibile());
|
||||||
|
|
||||||
|
if (field.not_empty())
|
||||||
|
{
|
||||||
|
if (tipo().tipo() == RIGA_OMAGGI && _iva_calc)
|
||||||
|
{
|
||||||
|
TDocumento_variable_field * f = (TDocumento_variable_field *) variable_field(field);
|
||||||
|
CHECKS(f, "Field UNKNOWN : ", field);
|
||||||
|
f->set_dirty(TRUE);
|
||||||
|
const real r = get_real(field);
|
||||||
|
f->set_dirty(TRUE);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return get_real(field);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return importo(TRUE, FALSE, doc().in_valuta() ? 3 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
real TRiga_documento::imposta(bool round) const
|
||||||
|
{
|
||||||
|
return iva(round ? (doc().in_valuta() ? 3 : 0) : 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TRiga_documento::dirty_fields(bool dirty_document)
|
||||||
|
{
|
||||||
|
for (TDocumento_variable_field * f = (TDocumento_variable_field *) first_variable_field();
|
||||||
|
f != NULL; f = (TDocumento_variable_field *) succ_variable_field())
|
||||||
|
f->set_dirty();
|
||||||
|
if (dirty_document)
|
||||||
|
((TDocumento &)doc()).dirty_fields();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TRiga_documento::doc_dependent() const
|
||||||
|
|
||||||
|
{
|
||||||
|
if (tipo_valido())
|
||||||
|
{
|
||||||
|
const char tipor = tipo().tipo();
|
||||||
|
|
||||||
|
if (tipor == RIGA_SPESEDOC)
|
||||||
|
return spesa().tipo() == 'P';
|
||||||
|
else
|
||||||
|
if (tipor == RIGA_SCONTI)
|
||||||
|
return get("SCONTO").not_empty();
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TRiga_documento::put_str(const char* fieldname, const char* val)
|
||||||
|
{
|
||||||
|
TString v(val);
|
||||||
|
if (strcmp(fieldname, "TIPORIGA") == 0 && TRectype::get("TIPORIGA") != v)
|
||||||
|
{
|
||||||
|
TAuto_variable_rectype::put_str(fieldname, v);
|
||||||
|
reset_fields(*this);
|
||||||
|
set_fields(*this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TAuto_variable_rectype::put_str(fieldname, v);
|
||||||
|
dirty_fields();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TRiga_documento::zero(const char * fieldname)
|
||||||
|
{
|
||||||
|
if (strcmp(fieldname, "TIPORIGA") == 0)
|
||||||
|
reset_fields(*this);
|
||||||
|
TAuto_variable_rectype::zero(fieldname);
|
||||||
|
dirty_fields();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TRiga_documento::zero(char c)
|
||||||
|
{
|
||||||
|
reset_fields(*this);
|
||||||
|
TAuto_variable_rectype::zero(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TRiga_documento::autosave(TSheet_field & f)
|
||||||
|
{
|
||||||
|
const int num = numero() - 1;
|
||||||
|
|
||||||
|
if (num >= 0 && num < f.items())
|
||||||
|
{
|
||||||
|
TToken_string & row = f.row(num);
|
||||||
|
|
||||||
|
put( "STATORIGA", row.get( f.cid2index(FR_STATORIGA) ) );
|
||||||
|
put( "TIPORIGA", row.get( f.cid2index(FR_TIPORIGA )) );
|
||||||
|
TString16 codmag(row.get(f.cid2index(FR_CODMAG)));
|
||||||
|
|
||||||
|
codmag.left_just(3);
|
||||||
|
codmag << row.get( f.cid2index(FR_CODDEP ));
|
||||||
|
put( "CODMAG", codmag);
|
||||||
|
put( "CODART", row.get( f.cid2index(FR_CODART )) );
|
||||||
|
put( "LIVELLO",row.get( f.cid2index(FR_LIV1 ))); // da modificare
|
||||||
|
put( "LIVELLO",row.get( f.cid2index(FR_LIV2 )));
|
||||||
|
put( "LIVELLO",row.get( f.cid2index(FR_LIV3 )));
|
||||||
|
put( "LIVELLO",row.get( f.cid2index(FR_LIV4 )));
|
||||||
|
TString s(row.get(f.cid2index(FR_DESCR)));
|
||||||
|
int split_pos = s.find('\n');
|
||||||
|
|
||||||
|
const int descr_len = length("DESCR");
|
||||||
|
if (split_pos < 0 && s.len() > descr_len)
|
||||||
|
split_pos = descr_len;
|
||||||
|
if (split_pos > 0)
|
||||||
|
{
|
||||||
|
put( "DESCR", s.left(split_pos));
|
||||||
|
put("DESCLUNGA", "X");
|
||||||
|
put("DESCEST", s.mid(split_pos));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
put("DESCR", s);
|
||||||
|
put("DESCLUNGA", "");
|
||||||
|
zero("DESCEST");
|
||||||
|
}
|
||||||
|
|
||||||
|
put( "PREZZO", row.get( f.cid2index(FR_PREZZO )) );
|
||||||
|
put( "UMQTA", row.get( f.cid2index(FR_UMQTA )) );
|
||||||
|
TMask * m = ((TTipo_riga_documento &)tipo()).mask();
|
||||||
|
const int pos = m->id2pos(FR_QTA);
|
||||||
|
if (pos >= 0 && m->fld(pos).field()->name() == "PSPESA")
|
||||||
|
put( "PSPESA", row.get( f.cid2index(FR_QTA )) );
|
||||||
|
else
|
||||||
|
put( "QTA", row.get( f.cid2index(FR_QTA )) );
|
||||||
|
put( "QTAEVASA", row.get( f.cid2index(FR_QTAEVASA )) );
|
||||||
|
put( "RIGAEVASA", row.get( f.cid2index(FR_RIGAEVASA )) );
|
||||||
|
put( "TARA", row.get( f.cid2index(FR_TARA )) );
|
||||||
|
put( "PNETTO", row.get( f.cid2index(FR_PNETTO )) );
|
||||||
|
put( "NCOLLI", row.get( f.cid2index(FR_NCOLLI )) );
|
||||||
|
put( "DAEVADERE", row.get( f.cid2index(FR_DAEVADERE )) );
|
||||||
|
put( "SCONTO", row.get( f.cid2index(FR_SCONTO )) );
|
||||||
|
put( "PERCPROV", row.get( f.cid2index(FR_PERCPROV )) );
|
||||||
|
put( "IMPFISSO", row.get( f.cid2index(FR_IMPFISSO )) );
|
||||||
|
put( "CODIVA", row.get( f.cid2index(FR_CODIVA )) );
|
||||||
|
put( "ADDIVA", row.get( f.cid2index(FR_ADDIVA )) );
|
||||||
|
put( "ASPBENI", row.get( f.cid2index(FR_ASPBENI )) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TRiga_documento::autoload(TSheet_field & f)
|
||||||
|
{
|
||||||
|
const int num = numero() - 1;
|
||||||
|
|
||||||
|
TToken_string & row = f.row(num);
|
||||||
|
row.cut(0);
|
||||||
|
|
||||||
|
row.add( get( "STATORIGA" ), f.cid2index(FR_STATORIGA ));
|
||||||
|
row.add( get( "TIPORIGA" ), f.cid2index(FR_TIPORIGA ));
|
||||||
|
const TString codmag(get("CODMAG"));
|
||||||
|
row.add( codmag.left(3), f.cid2index(FR_CODMAG ));
|
||||||
|
row.add( codmag.mid(3), f.cid2index(FR_CODDEP ));
|
||||||
|
row.add( get( "CODART" ), f.cid2index(FR_CODART ));
|
||||||
|
row.add( get( "LIVELLO" ), f.cid2index(FR_LIV1 )); // da modificare
|
||||||
|
row.add( get( "LIVELLO" ), f.cid2index(FR_LIV2 ));
|
||||||
|
row.add( get( "LIVELLO" ), f.cid2index(FR_LIV3 ));
|
||||||
|
row.add( get( "LIVELLO" ), f.cid2index(FR_LIV4 ));
|
||||||
|
TString s(get("DESCR"));
|
||||||
|
if (get_bool("DESCLUNGA"))
|
||||||
|
s << get("DESCEST");
|
||||||
|
row.add(s, f.cid2index(FR_DESCR ));
|
||||||
|
row.add( get( "UMQTA" ), f.cid2index(FR_UMQTA ));
|
||||||
|
row.add( get( "PREZZO" ), f.cid2index(FR_PREZZO ));
|
||||||
|
TMask * m = ((TTipo_riga_documento &)tipo()).mask();
|
||||||
|
const int pos = m->id2pos(FR_QTA);
|
||||||
|
if (pos >= 0 && m->fld(pos).field()->name() == "PSPESA")
|
||||||
|
row.add( get( "PSPESA" ), f.cid2index(FR_QTA ));
|
||||||
|
else
|
||||||
|
row.add( get( "QTA" ), f.cid2index(FR_QTA ));
|
||||||
|
row.add( get( "QTAEVASA" ), f.cid2index(FR_QTAEVASA ));
|
||||||
|
row.add( get( "RIGAEVASA" ), f.cid2index(FR_RIGAEVASA ));
|
||||||
|
row.add( get( "TARA" ), f.cid2index(FR_TARA ));
|
||||||
|
row.add( get( "PNETTO" ), f.cid2index(FR_PNETTO ));
|
||||||
|
row.add( get( "NCOLLI" ), f.cid2index(FR_NCOLLI ));
|
||||||
|
row.add( get( "DAEVADERE" ), f.cid2index(FR_DAEVADERE ));
|
||||||
|
row.add( get( "SCONTO" ), f.cid2index(FR_SCONTO ));
|
||||||
|
row.add( get( "PERCPROV" ), f.cid2index(FR_PERCPROV ));
|
||||||
|
row.add( get( "IMPFISSO" ), f.cid2index(FR_IMPFISSO ));
|
||||||
|
row.add( get( "CODIVA" ), f.cid2index(FR_CODIVA ));
|
||||||
|
row.add( get( "ADDIVA" ), f.cid2index(FR_ADDIVA ));
|
||||||
|
row.add( get( "ASPBENI" ), f.cid2index(FR_ASPBENI ));
|
||||||
|
}
|
||||||
|
|
||||||
|
147
ve/velib02.h
147
ve/velib02.h
@ -1,147 +0,0 @@
|
|||||||
#ifndef __ASSOC_H
|
|
||||||
#include <assoc.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "sconti.h"
|
|
||||||
#include "tclifor.h"
|
|
||||||
#include "velib01.h"
|
|
||||||
#include "..\cg\pagament.h"
|
|
||||||
|
|
||||||
struct dec_parm {
|
|
||||||
int pri_lit,
|
|
||||||
pri_val,
|
|
||||||
qta_lit,
|
|
||||||
qta_val, // si lo so non ha senso, ma lo faccio lo stesso
|
|
||||||
imp_lit,
|
|
||||||
imp_val;
|
|
||||||
// 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& prefisso() const { return get("S6"); }
|
|
||||||
const TString& postfisso() const { return get("S7"); }
|
|
||||||
const bool manual_num() 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 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
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class TRiepilogo_Iva : public TObject
|
|
||||||
{
|
|
||||||
real _imp;
|
|
||||||
real _iva;
|
|
||||||
real _ali;
|
|
||||||
byte _tipo;
|
|
||||||
TString16 _cod;
|
|
||||||
TString _des;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
public:
|
|
||||||
real& imp() { return _imp;} // Imponibile
|
|
||||||
real& iva() { return _iva;} // Iva
|
|
||||||
real& ali() { return _ali;} // Aliquota
|
|
||||||
TString& cod() { return _cod;} // Descrizione
|
|
||||||
TString& des() { return _des;} // Descrizione
|
|
||||||
byte& tipo(){ return _tipo;}// Tipo (Vedi opzioni per la selzione di filtro nella validate())
|
|
||||||
void zero(){ _imp = 0.0; _iva = 0.0; _ali = 0.0; _tipo = 0; _cod = ""; _des = ""; }
|
|
||||||
virtual TObject* dup() const { return new TRiepilogo_Iva(*this); }
|
|
||||||
TRiepilogo_Iva& operator = (TRiepilogo_Iva& a);
|
|
||||||
TRiepilogo_Iva() {_imp = 0.0; _iva = 0.0; _ali = 0.0; _tipo = 0;}
|
|
||||||
~TRiepilogo_Iva() {};
|
|
||||||
};
|
|
||||||
|
|
||||||
class TDocumentoEsteso : public TDocumento
|
|
||||||
{
|
|
||||||
// Parametri del documento
|
|
||||||
dec_parm _parm; // Parametri per gli arrotondamenti
|
|
||||||
TTable * _iva; // Tabella codici IVA
|
|
||||||
|
|
||||||
// Totali del documento ricalcolati non appena la tabellina di riepilogo IVA e' completa
|
|
||||||
real _importi_netti, _imposte;
|
|
||||||
|
|
||||||
// membri per il calcolo del riepilogo IVA
|
|
||||||
bool _sum_selected; // TRUE se ha selezionato una riga del riepilogo, funge da semaforo per leggere la prossima
|
|
||||||
int _sum_filter; // Filtro corrente della riga TRiepilogo_Iva in corso di stampa (-1 se non ha ancora calcolato la tabella)
|
|
||||||
TString_array _order_array; // Array di TToken_string contenenti i codici IVA soddisfacenti ad ogni tipo di filtro
|
|
||||||
TAssoc_array _summary_table; // Array dove vengono memorizzate le imposte per aliquota
|
|
||||||
TArray _summary_array; // Array dove vengono memorizzate le imposte/imponibili per riga
|
|
||||||
TRiepilogo_Iva _sum_current; // Riga corrente del riepilogo
|
|
||||||
|
|
||||||
// membri per il calcolo del riepilogo scadenze
|
|
||||||
TString_array _scadenze_array;// Array che contiene le scadenze ("<data>|<importo>")
|
|
||||||
int _scadenze_current; // indice per identificare l'elementi corrente sull'array (-1 se non ha ancora calcolato)
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
// Funzioni per il riepilogo IVA
|
|
||||||
const bool summary_compiled() { return _sum_filter > -1; }
|
|
||||||
void compile_summary(); // Aggiorna la tabella riepilogativa
|
|
||||||
void summary_filter(byte selector); // filtra la tabellina secondo il filtro corrente se non e' gia' stato fatto
|
|
||||||
void summary_reset(bool force=FALSE); // riposiziona l'array dei codici IVA (_order_array). Se il parametro e' TRUE forza il ricalcolo della tabella
|
|
||||||
void summary_set_next(); // seleziona il prossimo elemento del filtro
|
|
||||||
const TRiepilogo_Iva& sum_current() { return _sum_current; } // ritorna la riga corrente del filtro corrente
|
|
||||||
const char * summary_get(const TString& w); // ritorna l'informazione richiesta estratta dall'elemento corrente
|
|
||||||
int summary_items() { return _summary_table.items();} // ritorna il numero di righe in totale della tabellina
|
|
||||||
const TAssoc_array& summary() { return _summary_table; }
|
|
||||||
const TArray& summary_array() { return _summary_array;}
|
|
||||||
|
|
||||||
|
|
||||||
// Funzioni per il ricalcolo delle scadenze
|
|
||||||
void scadenze_reset(); // riposiziona sulla prima scadenza
|
|
||||||
void scadenze_recalc(); // resetta e ricalcola le scadenze
|
|
||||||
void scadenze_set_next(); // seleziona il prossimo elemento dell'array delle scadenze
|
|
||||||
const char * scadenze_get(const TString& w); // reperisce l'informazione richiesta dall'elemento corrente
|
|
||||||
int scadenze_items() { return _scadenze_array.items(); } // restituisce il numero di scadenze
|
|
||||||
TString_array& scadenze() { return _scadenze_array; }
|
|
||||||
|
|
||||||
// Funzioni di totalizzazione
|
|
||||||
real& tot_importi_netti();
|
|
||||||
real& tot_imposte();
|
|
||||||
real tot_spese();
|
|
||||||
real tot_documento();
|
|
||||||
// restituisce tot_imponibili, tot_esenti, tot_nonsoggetti a seconda del selettore:
|
|
||||||
// 1 = regime normale
|
|
||||||
// 2 = da ventilare (non usato)
|
|
||||||
// 4 = esenti
|
|
||||||
// 8 = non imponibili
|
|
||||||
// 16 = non soggetti
|
|
||||||
// pertanto i non imponibili avranno selettore 1 e gli esenti selettore 4.
|
|
||||||
// per avere esenti + non soggetti il selettore sara' 20 e cosi' via.
|
|
||||||
real tot_imponibili(byte selector);
|
|
||||||
|
|
||||||
// Reperisce l'informazione <what> dal campo G1 della testata
|
|
||||||
const char* get_head_info(const TString& what);
|
|
||||||
|
|
||||||
// Funzioni per settare i parametri
|
|
||||||
void set_decimals(dec_parm & parm) { _parm = parm ; }
|
|
||||||
void set_condv(TCliFor * cli); // Cambia le condizioni di vendita
|
|
||||||
TDocumentoEsteso (const TRectype & rec, dec_parm & parm, TCond_vendita * condv = NULL) ;
|
|
||||||
TDocumentoEsteso (const TRectype & rec, TCond_vendita * condv = NULL) ;
|
|
||||||
TDocumentoEsteso () ;
|
|
||||||
~TDocumentoEsteso();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
1439
ve/velib03.cpp
1439
ve/velib03.cpp
File diff suppressed because it is too large
Load Diff
741
ve/velib04.cpp
Executable file
741
ve/velib04.cpp
Executable file
@ -0,0 +1,741 @@
|
|||||||
|
#include "velib.h"
|
||||||
|
#include <clifo.h>
|
||||||
|
|
||||||
|
#ifndef __EXECP_H
|
||||||
|
#include <execp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// Lista di documenti
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TDate TLista_documenti::num2date(char provv, int anno, const char* codnum, long num) const
|
||||||
|
{
|
||||||
|
TLocalisamfile doc(LF_DOC);
|
||||||
|
CHECK(num > 0, "Numero documento nullo.");
|
||||||
|
TDocumento::set_key(doc.curr(), provv, anno, codnum, num);
|
||||||
|
|
||||||
|
if (doc.read(_isgteq) != NOERR) // In caso d'errore ...
|
||||||
|
doc.last(); // prendi l'ultimo
|
||||||
|
|
||||||
|
return doc.get("DATADOC");
|
||||||
|
}
|
||||||
|
|
||||||
|
int TLista_documenti::read(char provv, char tipocf, long clifo, int anno,
|
||||||
|
TToken_string& tipidoc, TToken_string& statidoc,
|
||||||
|
const TDate& dd, const TDate& ad,
|
||||||
|
const char* codnum, long dn, long an)
|
||||||
|
{
|
||||||
|
CHECK(provv == 'D' || provv == 'P', "Provvisorio o Definitivo?");
|
||||||
|
CHECK(tipocf == 'C' || tipocf == 'F', "Il tipo deve essere Cliente o Fornitore");
|
||||||
|
CHECKD(clifo > 0L, "Codice cliente non valido", clifo);
|
||||||
|
CHECKD(anno > 1900, "Anno non valido: ", anno);
|
||||||
|
CHECK(!tipidoc.empty_items(), "Lista dei tipi documento vuota");
|
||||||
|
CHECK(!statidoc.empty_items(), "Lista degli stati documento vuota");
|
||||||
|
|
||||||
|
TRelation doc(LF_DOC);
|
||||||
|
TRectype start(LF_DOC), stop(LF_DOC);
|
||||||
|
|
||||||
|
start.put("TIPOCF", tipocf);
|
||||||
|
stop.put("TIPOCF", tipocf);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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);
|
||||||
|
const TRectype& head = cur.curr();
|
||||||
|
|
||||||
|
_documenti.destroy();
|
||||||
|
for (cur = 0; cur.ok(); ++cur)
|
||||||
|
{
|
||||||
|
const TString16 tipodoc = head.get("TIPODOC");
|
||||||
|
const TString16 statodoc = head.get("STATO");
|
||||||
|
if (tipidoc.get_pos(tipodoc) >= 0 && statidoc.get_pos(statodoc) >= 0)
|
||||||
|
{
|
||||||
|
TDocumento* d = new TDocumento(head);
|
||||||
|
_documenti.add(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _documenti.items();
|
||||||
|
}
|
||||||
|
|
||||||
|
int TLista_documenti::write(bool re) const
|
||||||
|
{
|
||||||
|
int err = NOERR;
|
||||||
|
for (int i = 0; i < _documenti.items() && err == NOERR; i++)
|
||||||
|
err = doc(i).write(re);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// Cliente/Fornitore per vendite
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TLista_clifo::TClifo::init(const TRectype& rec, const TRectype& ven)
|
||||||
|
{
|
||||||
|
_codice = rec.get_long(CLI_CODCF);
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
TRelation clifo(LF_CLIFO);
|
||||||
|
clifo.add(LF_CFVEN, "TIPOCF=TIPOCF|CODCF=CODCF");
|
||||||
|
|
||||||
|
TRectype& curr = clifo.curr();
|
||||||
|
curr.put(CLI_TIPOCF, tipo);
|
||||||
|
curr.put(CLI_CODCF, cod);
|
||||||
|
if (clifo.read() == NOERR)
|
||||||
|
init(curr, clifo.curr(LF_CFVEN));
|
||||||
|
else
|
||||||
|
zero();
|
||||||
|
|
||||||
|
return ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
TLista_clifo::TClifo::TClifo(const TRectype& rec)
|
||||||
|
{
|
||||||
|
CHECK(rec.num() == LF_CLIFO, "Record non clienti");
|
||||||
|
const char tipo = rec.get_char(CLI_TIPOCF);
|
||||||
|
const long codice = rec.get_long(CLI_CODCF);
|
||||||
|
read(tipo, codice);
|
||||||
|
}
|
||||||
|
|
||||||
|
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, tipo());
|
||||||
|
if (dc > 0)
|
||||||
|
start.put(CLI_CODCF, dc);
|
||||||
|
|
||||||
|
stop.put(CLI_TIPOCF, tipo());
|
||||||
|
if (ac > 0)
|
||||||
|
stop.put(CLI_CODCF, ac);
|
||||||
|
|
||||||
|
TString filter(32);
|
||||||
|
if (da > 0)
|
||||||
|
filter << '(' << LF_CFVEN << "->" << CLI_CODAG << ">=" << da << ')';
|
||||||
|
if (aa > 0)
|
||||||
|
{
|
||||||
|
if (filter.not_empty()) filter << "&&";
|
||||||
|
filter << '(' << LF_CFVEN << "->" << CLI_CODAG << "<=" << aa << ')';
|
||||||
|
}
|
||||||
|
if (dz > 0)
|
||||||
|
{
|
||||||
|
if (filter.not_empty()) filter << "&&";
|
||||||
|
filter << '(' << LF_CFVEN << "->" << CLI_CODZONA << ">=" << dz << ')';
|
||||||
|
}
|
||||||
|
if (az > 0)
|
||||||
|
{
|
||||||
|
if (filter.not_empty()) filter << "&&";
|
||||||
|
filter << '(' << LF_CFVEN << "->" << CLI_CODZONA << "<=" << az << ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
TCursor cur(&clifo, filter, 1, &start, &stop);
|
||||||
|
const TRectype& cli = cur.curr();
|
||||||
|
const TRectype& ven = cur.curr(LF_CFVEN);
|
||||||
|
for (cur = 0; cur.ok(); ++cur)
|
||||||
|
{
|
||||||
|
TClifo* c = new TClifo(cli, ven);
|
||||||
|
_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 _clifo.items();
|
||||||
|
}
|
||||||
|
|
||||||
|
int TLista_clifo::sort_by_code(const TObject** o1, const TObject** 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_clifo::sort_by_agent(const TObject** o1, const TObject** 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_clifo::sort_by_zone(const TObject** o1, const TObject** 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_clifo::ordina_per_codice()
|
||||||
|
{
|
||||||
|
_clifo.sort(sort_by_code);
|
||||||
|
return _clifo.items();
|
||||||
|
}
|
||||||
|
|
||||||
|
int TLista_clifo::ordina_per_agente()
|
||||||
|
{
|
||||||
|
_clifo.sort(sort_by_agent);
|
||||||
|
return _clifo.items();
|
||||||
|
}
|
||||||
|
|
||||||
|
int TLista_clifo::ordina_per_zona()
|
||||||
|
{
|
||||||
|
_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TElaborazione
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TElaborazione::TElaborazione(const char* cod) : TRectype(LF_TABCOM)
|
||||||
|
{
|
||||||
|
settab("ELD");
|
||||||
|
if (cod && *cod)
|
||||||
|
read(cod);
|
||||||
|
}
|
||||||
|
|
||||||
|
int TElaborazione::read(const char* cod)
|
||||||
|
{
|
||||||
|
CHECK(cod && *cod, "Codice elaborazione nullo");
|
||||||
|
TTable eld("%ELD");
|
||||||
|
put("CODTAB", cod);
|
||||||
|
const int err = TRectype::read(eld);
|
||||||
|
if (err != NOERR)
|
||||||
|
yesnofatal_box("Codice elaborazione non valido: %s", cod);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TEsterna
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TEsterna::TEsterna(const char* cod)
|
||||||
|
: TElaborazione(cod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TEsterna::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||||
|
const TDate& data_elab)
|
||||||
|
{
|
||||||
|
CHECK(doc_in.items() == 1, "Si deve specificare uno e un solo documento in entrata");
|
||||||
|
CHECK(doc_out.items() == 1, "Si deve specificare uno e un solo documento in uscita");
|
||||||
|
TFilename name; name.temp("ext");
|
||||||
|
{
|
||||||
|
TConfig c(name);
|
||||||
|
TDocumento & d = doc_in[0];
|
||||||
|
int nfields = d.items();
|
||||||
|
TString par; par.format("%d,0", LF_DOC);
|
||||||
|
|
||||||
|
for (int i = 0; i < nfields; i++)
|
||||||
|
{
|
||||||
|
const TString16 fname(d.fieldname(i));
|
||||||
|
TFieldref f(fname, LF_DOC);
|
||||||
|
|
||||||
|
f.write(c, par, d.get(fname));
|
||||||
|
}
|
||||||
|
for (TVariable_field * v = d.first_variable_field(); v ; v = d.succ_variable_field())
|
||||||
|
c.set(v->name(), v->get(), par);
|
||||||
|
const int rows = d.physical_rows();
|
||||||
|
if (rows > 0)
|
||||||
|
{
|
||||||
|
nfields = d[0].items();
|
||||||
|
|
||||||
|
for (int r = 0; r < rows; r++)
|
||||||
|
{
|
||||||
|
TRiga_documento row = d[r];
|
||||||
|
|
||||||
|
par.format("%d,%d", LF_RIGHEDOC, r + 1);
|
||||||
|
for (int i = 0; i < nfields; i++)
|
||||||
|
{
|
||||||
|
const TString16 fname(row.fieldname(i));
|
||||||
|
TFieldref f(fname, LF_RIGHEDOC);
|
||||||
|
|
||||||
|
f.write(c, par, row.get(fname));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TString command_line(applicazione_esterna()); command_line << " -i " << name;
|
||||||
|
TExternal_app app(command_line);
|
||||||
|
if (app.run() == 0)
|
||||||
|
{
|
||||||
|
TConfig c(name);
|
||||||
|
TDocumento & d = doc_out[0];
|
||||||
|
int nfields = d.items();
|
||||||
|
TString par; par.format("%d,0", LF_DOC);
|
||||||
|
|
||||||
|
for (int i = 0; i < nfields; i++)
|
||||||
|
{
|
||||||
|
const TString16 fname(d.fieldname(i));
|
||||||
|
TFieldref f(fname, LF_DOC);
|
||||||
|
|
||||||
|
d.put(fname, f.read(c, par));
|
||||||
|
}
|
||||||
|
for (TVariable_field * v = d.first_variable_field(); v ; v = d.succ_variable_field())
|
||||||
|
v->put(c.get(v->name(), par));
|
||||||
|
|
||||||
|
TString_array p;
|
||||||
|
|
||||||
|
c.list_paragraphs(p);
|
||||||
|
nfields = d[0].items();
|
||||||
|
d.destroy_rows();
|
||||||
|
int r = 1 ;
|
||||||
|
par.format("%d,%d", LF_RIGHEDOC, r);
|
||||||
|
while (p.find(par) >= 0)
|
||||||
|
{
|
||||||
|
TRiga_documento row = d.new_row();
|
||||||
|
for (int i = 0; i < nfields; i++)
|
||||||
|
{
|
||||||
|
const TString16 fname(row.fieldname(i));
|
||||||
|
TFieldref f(fname, LF_RIGHEDOC);
|
||||||
|
|
||||||
|
row.put(fname, f.read(c, par));
|
||||||
|
}
|
||||||
|
r++;
|
||||||
|
par.format("%d,%d", LF_RIGHEDOC, r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TConsegna ordini
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TConsegna_ordini::TConsegna_ordini(const char* cod)
|
||||||
|
: TElaborazione(cod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TConsegna_ordini::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||||
|
const TDate& data_elab)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TFatturazione bolle
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TFatturazione_bolle::TFatturazione_bolle(const char* cod)
|
||||||
|
: TElaborazione(cod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TFatturazione_bolle::tipi_validi(TToken_string& tipi) const
|
||||||
|
{
|
||||||
|
const TString& s2 = get("S2");
|
||||||
|
tipi.cut(0);
|
||||||
|
TString16 t;
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
t = s2.mid(i*4, 4);
|
||||||
|
t.trim();
|
||||||
|
if (t.not_empty())
|
||||||
|
tipi.add(t);
|
||||||
|
}
|
||||||
|
CHECK(!tipi.empty_items(), "Nessun tipo documento valido");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TFatturazione_bolle::stati_validi(TToken_string& stati) const
|
||||||
|
{
|
||||||
|
const TString& s7 = get("S7");
|
||||||
|
stati.cut(0);
|
||||||
|
TString16 s;
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
s = s7.mid(i*4, 1);
|
||||||
|
s.trim();
|
||||||
|
if (s.not_empty())
|
||||||
|
stati.add(s);
|
||||||
|
}
|
||||||
|
CHECK(!stati.empty_items(), "Nessuno stato documento valido");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TFatturazione_bolle::raggruppa(TDocumento& doc_in, TDocumento& doc_out)
|
||||||
|
{
|
||||||
|
#ifdef DBG
|
||||||
|
const TString tipi = get("S2");
|
||||||
|
const TString& tipodoc = doc_in.tipo().codice();
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
if (tipodoc == tipi.mid(i*4, 4))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i >= 5)
|
||||||
|
{
|
||||||
|
NFCHECK("Tipo documento non valido: '%s'", (const char*)tipodoc);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char stato_finale_in = get_char("S4");
|
||||||
|
doc_in.stato(stato_finale_in);
|
||||||
|
|
||||||
|
const TString& tipo_out = get("S8");
|
||||||
|
doc_out.put("TIPODOC", tipo_out);
|
||||||
|
|
||||||
|
const char stato_finale_out = get_char("S9");
|
||||||
|
doc_out.stato(stato_finale_out);
|
||||||
|
|
||||||
|
if (gestione_riferimenti())
|
||||||
|
{
|
||||||
|
// Determina ed eventualmente crea la riga di riferimento
|
||||||
|
const int riga_rif = riferimenti_in_testa() ? 1 : doc_out.rows()+1;
|
||||||
|
if (riga_rif > doc_out.rows())
|
||||||
|
{
|
||||||
|
TRiga_documento& rout = doc_out.new_row();
|
||||||
|
rout.forza_sola_descrizione();
|
||||||
|
}
|
||||||
|
|
||||||
|
TRiga_documento& rout = doc_out[riga_rif];
|
||||||
|
|
||||||
|
// Costruisce la stringa di riferimento
|
||||||
|
TString riferimento(80);
|
||||||
|
riferimento = doc_in.tipo().riferimento();
|
||||||
|
if (riferimento.empty())
|
||||||
|
riferimento = doc_in.tipo().descrizione();
|
||||||
|
riferimento << " n. " << doc_in.numero();
|
||||||
|
riferimento << " del " << doc_in.data().string();
|
||||||
|
|
||||||
|
// Setta la descrizione se vuota
|
||||||
|
if (rout.get("DESCR").empty())
|
||||||
|
rout.put("DESCR", riferimento);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Altrimenti aggiungi il riferimento al memo
|
||||||
|
TString memo(1024);
|
||||||
|
memo = rout.get("DESCEST");
|
||||||
|
if (memo.empty())
|
||||||
|
rout.put("DESCLUNGA", "X");
|
||||||
|
else
|
||||||
|
memo << '\n';
|
||||||
|
memo << riferimento;
|
||||||
|
rout.put("DESCEST", memo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool ignora_desc = ignora_descrizioni();
|
||||||
|
|
||||||
|
TToken_string campi_riga(80);
|
||||||
|
const bool ragg_rig = raggruppa_righe();
|
||||||
|
if (ragg_rig)
|
||||||
|
{
|
||||||
|
campi_riga = "CODART|UMQTA"; // Uguali sempre
|
||||||
|
// Uguali opzionalmente
|
||||||
|
if (riga_uguale(0)) campi_riga.add("CODMAG");
|
||||||
|
if (riga_uguale(1)) campi_riga.add("CODIVA");
|
||||||
|
if (riga_uguale(2)) campi_riga.add("PREZZO|SCONTO");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int r = 1; r <= doc_in.rows(); r++)
|
||||||
|
{
|
||||||
|
const TRiga_documento& rin = doc_in[r];
|
||||||
|
const bool rindesc = rin.sola_descrizione(); // La riga di input e' descrittiva
|
||||||
|
if (ignora_desc && rindesc)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bool elaborata = FALSE;
|
||||||
|
|
||||||
|
// Raggruppo le righe se e' settato il falg di raggruppamento e
|
||||||
|
// se la riga non contiene solo una descrizione
|
||||||
|
if (ragg_rig && !rindesc) // Se devo raggruppare le righe ...
|
||||||
|
{
|
||||||
|
const int last = doc_out.rows();
|
||||||
|
for (int o = 1; o <= last; o++) // ... cerca una riga compatibile
|
||||||
|
{
|
||||||
|
TRiga_documento& rout = doc_out[o];
|
||||||
|
if (rout.sola_descrizione()) // Ignora le righe descrittive
|
||||||
|
continue;
|
||||||
|
if (rin.raggruppabile(rout, campi_riga)) // Se esiste una riga compatibile ...
|
||||||
|
{
|
||||||
|
rout += rin; // ... sommaci la quantita' ecc.
|
||||||
|
elaborata = TRUE; // Ricorda di averla gia' elaborata
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!elaborata) // Se la riga non e' stata gia' sommata ...
|
||||||
|
{
|
||||||
|
TRiga_documento& rout = doc_out.new_row(); // ... crea una riga nuova e ...
|
||||||
|
doc_out.copy_data(rout, rin); // ... copiaci tutti i campi della riga sorgente.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TFatturazione_bolle::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||||
|
const TDate& data_elab)
|
||||||
|
{
|
||||||
|
bool ok = TRUE;
|
||||||
|
|
||||||
|
TToken_string campi_doc(128); // Lista di campi che devono essere uguali
|
||||||
|
campi_doc = "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 };
|
||||||
|
for (int u = 0; cond[u]; u++)
|
||||||
|
if (doc_uguale(u)) campi_doc.add(cond[u]);
|
||||||
|
|
||||||
|
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()) // Se il documento ha il flag di raggruppabilita' ...
|
||||||
|
{
|
||||||
|
for (od = 0; od < tot; od++) // ... cerca un documento compatibile.
|
||||||
|
{
|
||||||
|
if (campione.raggruppabile(doc_out[od], campi_doc))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (od >= tot) // Se non ho trovato un documento compatibile ...
|
||||||
|
{ // ... creane uno nuovo (certamente compatibile)
|
||||||
|
const char provv = tipo_numerazione();
|
||||||
|
const int anno = campione.anno();
|
||||||
|
const TString codnum = codice_numerazione_finale();
|
||||||
|
TDocumento* new_doc = new TDocumento(provv, anno, codnum, -1);
|
||||||
|
// Copia i dati della testata
|
||||||
|
TDocumento::copy_data(new_doc->head(), campione.head());
|
||||||
|
|
||||||
|
new_doc->put("DATADOC", data_elab);
|
||||||
|
|
||||||
|
// Aggiungilo alla lista dei documenti in uscita
|
||||||
|
od = doc_out.add(new_doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
ok = raggruppa(campione, doc_out[od]);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TContabilizzazione
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TContabilizzazione::TContabilizzazione(const char* cod)
|
||||||
|
: TElaborazione(cod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TContabilizzazione::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||||
|
const TDate& data_elab)
|
||||||
|
{
|
||||||
|
CHECK(doc_in.items() == 1, "Si deve specificare uno e un solo documento in entrata");
|
||||||
|
CHECK(doc_out.items() == 1, "Si deve specificare uno e un solo documento in uscita");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TCopia_documento
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TCopia_documento::TCopia_documento(const char* cod)
|
||||||
|
: TElaborazione(cod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TCopia_documento::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||||
|
const TDate& data_elab)
|
||||||
|
{
|
||||||
|
CHECK(doc_in.items() == 1, "Si deve specificare uno e un solo documento in entrata");
|
||||||
|
CHECK(doc_out.items() == 1, "Si deve specificare uno e un solo documento in uscita");
|
||||||
|
TDocumento & doc_src = doc_in[0];
|
||||||
|
TDocumento & doc_dest = doc_out[0];
|
||||||
|
|
||||||
|
doc_dest.copy_contents(doc_src);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TGenerazione_effetti
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TGenerazione_effetti::TGenerazione_effetti(const char* cod)
|
||||||
|
: TElaborazione(cod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TGenerazione_effetti::elabora(TLista_documenti& doc_in, TLista_documenti& doc_out,
|
||||||
|
const TDate& data_elab)
|
||||||
|
{
|
||||||
|
CHECK(doc_in.items() == 1, "Si deve specificare uno e un solo documento in entrata");
|
||||||
|
CHECK(doc_out.items() == 1, "Si deve specificare uno e un solo documento in uscita");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// TLista_elaborazioni
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TLista_elaborazioni::read()
|
||||||
|
{
|
||||||
|
if (_elab == NULL)
|
||||||
|
{
|
||||||
|
_elab = new TAssoc_array();
|
||||||
|
|
||||||
|
TTable eld("%ELD");
|
||||||
|
|
||||||
|
for (int err = eld.first(); err == NOERR; err = eld.next())
|
||||||
|
{
|
||||||
|
TElaborazione * el = NULL;
|
||||||
|
switch (eld.curr().get_int("I0"))
|
||||||
|
{
|
||||||
|
case _esterna :
|
||||||
|
el = new TEsterna(eld.curr());
|
||||||
|
break;
|
||||||
|
case _consegna_ordini:
|
||||||
|
el = new TConsegna_ordini(eld.curr());
|
||||||
|
break;
|
||||||
|
case _fatturazione_bolle :
|
||||||
|
el = new TFatturazione_bolle(eld.curr());
|
||||||
|
break;
|
||||||
|
case _contabilizzazione :
|
||||||
|
el = new TContabilizzazione(eld.curr());
|
||||||
|
break;
|
||||||
|
case _copia_documento :
|
||||||
|
el = new TCopia_documento(eld.curr());
|
||||||
|
break;
|
||||||
|
case _generazione_effetti :
|
||||||
|
el = new TGenerazione_effetti(eld.curr());
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_elab->add(el->codice(), el);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int TLista_elaborazioni::select(TString_array & result, bool interattivo, bool insert_mode, const char * tipo_iniziale, const char * stato_iniziale, const char * tipo_finale, const char * stato_finale)
|
||||||
|
{
|
||||||
|
read();
|
||||||
|
_elab->restart();
|
||||||
|
result.destroy();
|
||||||
|
for (TElaborazione * el = (TElaborazione *)_elab->get(); el ; el = (TElaborazione *) _elab->get())
|
||||||
|
{
|
||||||
|
bool ok = TRUE;
|
||||||
|
if (tipo_iniziale && stato_iniziale)
|
||||||
|
{
|
||||||
|
bool found = FALSE;
|
||||||
|
for (int i = 0; !found && i < 5; i++)
|
||||||
|
found = el->tipo_iniziale(i) == tipo_iniziale && el->stato_iniziale(i) == *stato_iniziale;
|
||||||
|
ok = found;
|
||||||
|
}
|
||||||
|
ok &= (tipo_finale && stato_finale && el->tipo_finale() == tipo_finale && el->stato_finale() == *stato_finale);
|
||||||
|
if (ok && (!interattivo || interattivo == el->interattivo()) &&
|
||||||
|
(!insert_mode || insert_mode == el->insert_mode()))
|
||||||
|
result.add(el->codice());
|
||||||
|
}
|
||||||
|
return result.items();
|
||||||
|
}
|
||||||
|
|
||||||
|
TElaborazione & TLista_elaborazioni::operator [](const char * key) const
|
||||||
|
{
|
||||||
|
((TLista_elaborazioni *)this)->read();
|
||||||
|
return (TElaborazione &) (*_elab)[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
void TLista_elaborazioni::update()
|
||||||
|
{
|
||||||
|
delete _elab; _elab = NULL;
|
||||||
|
read();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TLista_elaborazioni::~TLista_elaborazioni()
|
||||||
|
{
|
||||||
|
if (_elab)
|
||||||
|
delete _elab;
|
||||||
|
}
|
344
ve/velib05.cpp
Executable file
344
ve/velib05.cpp
Executable file
@ -0,0 +1,344 @@
|
|||||||
|
#include "velib02.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
// TCodice_numerazione
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
TCodice_numerazione::TCodice_numerazione(const char* codnum)
|
||||||
|
: TRectype(LF_TABCOM), _status(NOERR)
|
||||||
|
{
|
||||||
|
settab("NUM");
|
||||||
|
if (codnum && *codnum)
|
||||||
|
_status = read(codnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
TCodice_numerazione::TCodice_numerazione(const TRectype& rec)
|
||||||
|
: TRectype(rec), _status(NOERR)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
TCodice_numerazione::~TCodice_numerazione()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * TCodice_numerazione::complete_num(long num)
|
||||||
|
{
|
||||||
|
static TString codnum;
|
||||||
|
codnum = prefisso();
|
||||||
|
codnum << num;
|
||||||
|
codnum << postfisso();
|
||||||
|
return codnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TCodice_numerazione::read(const char* codnum)
|
||||||
|
{
|
||||||
|
TTable t("%NUM");
|
||||||
|
put("CODTAB", codnum);
|
||||||
|
int err = TRectype::read(t);
|
||||||
|
if (err != NOERR)
|
||||||
|
yesnofatal_box("Codice numerazione errato: %s", codnum);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
// TRiepilogo IVA
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
TRiepilogo_Iva& TRiepilogo_Iva::operator=(TRiepilogo_Iva& a)
|
||||||
|
{
|
||||||
|
_imp = a.imp(); _iva = a.iva(); _ali = a.ali();
|
||||||
|
_cod = a.cod(); _tipo = a.tipo(); _des = a.des();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
//TDocumentoEsteso
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
void TDocumentoEsteso::compile_summary()
|
||||||
|
{
|
||||||
|
_sum_filter = 0;
|
||||||
|
const int items = rows();
|
||||||
|
|
||||||
|
_summary_table.destroy();
|
||||||
|
_summary_array.destroy();
|
||||||
|
_imposte = 0.0;
|
||||||
|
_importi_netti = 0.0;
|
||||||
|
const bool val = in_valuta();
|
||||||
|
// Scorre tutte le righe e compila la tabellina _summary_table, per codice iva,
|
||||||
|
// nonche' il galactic_array _summary_array dove le informazioni sono registrate per singola riga
|
||||||
|
// cio' ad usi generici: porco diavolo!
|
||||||
|
for (int i = 1; i <= items; i++)
|
||||||
|
{
|
||||||
|
TRiga_documento& r = row(i);
|
||||||
|
int nriga = r.get_int("NRIGA");
|
||||||
|
real price = r.get_real("PREZZO");
|
||||||
|
real qta = r.get_real("QTA");
|
||||||
|
real aliquota, sc, imponibile, iva;
|
||||||
|
TString sconto(r.get("SCONTO"));
|
||||||
|
TString codiva(r.get("CODIVA"));
|
||||||
|
_iva->put("CODTAB", codiva);
|
||||||
|
if (_iva->read() != NOERR) continue; // Se non trova il codice salta questa riga
|
||||||
|
|
||||||
|
aliquota = _iva->get_real("R0");
|
||||||
|
price = prezzo_scontato(price, sconto);
|
||||||
|
price.round(val ? _parm.pri_val : _parm.pri_lit); // prezzo scontato
|
||||||
|
qta.round(val ? _parm.qta_val : _parm.qta_lit);
|
||||||
|
imponibile = price * qta;
|
||||||
|
imponibile.round (val? _parm.imp_val : _parm.imp_lit); // imponibile di riga
|
||||||
|
iva = r.iva(val ? _parm.imp_val : _parm.imp_lit);
|
||||||
|
//iva = (imponibile * aliquota) / 100.0;
|
||||||
|
//iva.ceil(val ? _parm.imp_val : _parm.imp_lit); // imposta calcolata
|
||||||
|
|
||||||
|
// Aggiorna o aggiunge l'elemento se non esiste
|
||||||
|
TRiepilogo_Iva riepilogo_tmp,row_riep;
|
||||||
|
const bool exists = _summary_table.is_key(codiva);
|
||||||
|
TRiepilogo_Iva& riepilogo = (exists ? (TRiepilogo_Iva&)_summary_table[codiva] : riepilogo_tmp);
|
||||||
|
// Aggiorna anche il totale importi netti ed il totale imposte
|
||||||
|
_importi_netti += imponibile;
|
||||||
|
_imposte += iva;
|
||||||
|
riepilogo.imp() += imponibile; riepilogo.iva() += iva;
|
||||||
|
row_riep.imp() = imponibile; row_riep.iva() = iva;
|
||||||
|
riepilogo.ali() = aliquota; riepilogo.cod() = codiva;
|
||||||
|
row_riep.ali() = aliquota; row_riep.cod() = codiva;
|
||||||
|
TString16 tipo(_iva->get("S1"));
|
||||||
|
int tipo_i = 1;// Regime IVA normale
|
||||||
|
if (tipo == "VE") tipo = 2;
|
||||||
|
else if (tipo == "ES") tipo = 4;
|
||||||
|
else if (tipo == "NI") tipo = 8;
|
||||||
|
else if (tipo == "NS") tipo= 16;
|
||||||
|
riepilogo.tipo() = tipo_i;
|
||||||
|
row_riep.tipo() = tipo_i;
|
||||||
|
if (riepilogo.tipo() != 1) // Se non e' regime normale salva anche la descrizione
|
||||||
|
{
|
||||||
|
TString s(_iva->get("S0"));
|
||||||
|
riepilogo.des() = s;
|
||||||
|
row_riep.des() = s;
|
||||||
|
}
|
||||||
|
_summary_table.add(codiva,riepilogo,exists);
|
||||||
|
_summary_array.add(row_riep,nriga);
|
||||||
|
}
|
||||||
|
// Inizializza l'array di ordine
|
||||||
|
for (i = 0; i<32;i++)
|
||||||
|
{
|
||||||
|
TToken_string s;
|
||||||
|
_order_array.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TDocumentoEsteso::summary_filter(byte selector)
|
||||||
|
{
|
||||||
|
if (_sum_filter == -1) compile_summary(); // Crea la tabella se deve ancora farlo
|
||||||
|
// se ha selezionato una riga in precedenza deve finire di stamparla
|
||||||
|
// ovvero non seleziona il filtro fino a quando non ha ricevuto una summary_set_next()
|
||||||
|
if (_sum_selected) return;
|
||||||
|
//
|
||||||
|
// Procedimento:
|
||||||
|
// Memorizza in un TString_array tante TToken_string quanti sono i filtri possibili
|
||||||
|
// (al massimo 31 [1+2+4+8+16]). Ogni TToken_string contiene i codici IVA
|
||||||
|
// delle righe di TRiepilogo_Iva che soddisfano la condizione di filtro
|
||||||
|
_sum_selected = TRUE;
|
||||||
|
_sum_filter = selector;
|
||||||
|
TToken_string& codici = _order_array.row(_sum_filter-1);
|
||||||
|
if (codici.items() == 0) // Se non c'e' nemmeno un codice IVA allora deve effettuare il filtro
|
||||||
|
{ // ovvero mette in <<codici>> tutti i codici IVA che soddisfano tale filtro
|
||||||
|
// sara' poi la summary_set_next() a selezionare sequenzialmente il giusto codice a seconda del filtro corrente
|
||||||
|
|
||||||
|
// Scorre sequenzialmente la tabella _summary_table e compone la TToken_string con i codici IVA
|
||||||
|
const int items = _summary_table.items();
|
||||||
|
TRiepilogo_Iva* curr = (TRiepilogo_Iva *) _summary_table.first_item();
|
||||||
|
for (int i = 0; i < items && curr != NULL; i++)
|
||||||
|
{
|
||||||
|
if (curr->tipo() & _sum_filter) // se fa parte del filtro selezionato schiaffa il codice nella TToken_string
|
||||||
|
codici.add(curr->cod());
|
||||||
|
curr = (TRiepilogo_Iva*) _summary_table.succ_item();
|
||||||
|
}
|
||||||
|
codici.restart();
|
||||||
|
summary_set_next(); // setta l'elemento corrente
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TDocumentoEsteso::summary_reset(bool force)
|
||||||
|
{
|
||||||
|
const int items = _order_array.items();
|
||||||
|
if (force) _sum_filter = -1;
|
||||||
|
for (int i = 0; i<items; i++)
|
||||||
|
{
|
||||||
|
TToken_string& codici = _order_array.row(i);
|
||||||
|
codici = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TDocumentoEsteso::summary_set_next()
|
||||||
|
{
|
||||||
|
_sum_selected = FALSE;
|
||||||
|
TToken_string& codici = _order_array.row(_sum_filter-1);
|
||||||
|
|
||||||
|
TString16 codiva(codici.get()); // Reperisce il prossimo codice nella lista. (son gia' ordinati per codice)
|
||||||
|
if (codiva.not_empty() && _summary_table.is_key(codiva))
|
||||||
|
{
|
||||||
|
// Estrae da _summary_table i dati relativio al codice corrispondente.
|
||||||
|
TRiepilogo_Iva& riep= (TRiepilogo_Iva&) _summary_table[codiva];
|
||||||
|
_sum_current = riep;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_sum_current.zero(); // se non esiste il codice azzera l'elemento corrente (non stampera' nulla)
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * TDocumentoEsteso::summary_get(const TString& w)
|
||||||
|
{
|
||||||
|
TString ret;
|
||||||
|
if (w == "COD") ret = _sum_current.cod(); // Ritorna il codice IVA
|
||||||
|
if (w == "IMP" && _sum_current.imp() != 0.0) ret = _sum_current.imp().string(); // Ritorna l'imponibile
|
||||||
|
if (w == "IVA" && _sum_current.iva() != 0.0) ret = _sum_current.iva().string(); // Ritorna l'imposta
|
||||||
|
if (w == "ALI" && _sum_current.ali() != 0.0) ret = _sum_current.ali().string(); // Ritorna l'aliquota %
|
||||||
|
if (w == "DES") ret = _sum_current.des(); // Ritorna la descrizione ( se il codice e' regime normale la descr. e' vuota)
|
||||||
|
return (const char *)ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TDocumentoEsteso::scadenze_recalc()
|
||||||
|
{
|
||||||
|
_scadenze_array.destroy();
|
||||||
|
_scadenze_current = -1;
|
||||||
|
TString16 codpag(head().get("CODPAG"));
|
||||||
|
TString16 data(head().get("DATAINSC"));
|
||||||
|
if (data.empty()) data = head().get("DATADOC");
|
||||||
|
TPagamento pag( codpag, data);
|
||||||
|
real totspese = spese();//tot_spese();
|
||||||
|
real totimposte = imposta();//tot_imposte();
|
||||||
|
real totimponibili = totale_doc() - totimposte - totspese;//tot_documento() - totimposte - totspese;
|
||||||
|
const bool valuta = in_valuta();
|
||||||
|
if (valuta)
|
||||||
|
{
|
||||||
|
const real change(cambio());
|
||||||
|
real val1 = totimponibili * change;
|
||||||
|
real val2 = totimposte * change;
|
||||||
|
real val3 = totspese * change;
|
||||||
|
pag.set_total_valuta( totimponibili, totimposte, totspese, change, val1, val2 ,val3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pag.set_total( totimponibili, totimposte, totspese );
|
||||||
|
pag.set_rate_auto( );
|
||||||
|
const int numrate = pag.n_rate( );
|
||||||
|
for (int i = 0; i< numrate; i++)
|
||||||
|
{
|
||||||
|
TToken_string t;
|
||||||
|
t.add(pag.data_rata(i));
|
||||||
|
t.add(pag.importo_rata(i,valuta).string());
|
||||||
|
_scadenze_array.add(t);
|
||||||
|
}
|
||||||
|
if (numrate > 0) _scadenze_current++;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * TDocumentoEsteso::scadenze_get(const TString& w)
|
||||||
|
{
|
||||||
|
TString ret;
|
||||||
|
|
||||||
|
if (_scadenze_current == -1)
|
||||||
|
// calcola le scadenze e le mette in _scadenze_array
|
||||||
|
scadenze_recalc();
|
||||||
|
if (_scadenze_current > -1 && _scadenze_current < _scadenze_array.items())
|
||||||
|
{
|
||||||
|
if (w == "DATA") ret = _scadenze_array.row(_scadenze_current).get(0); // ritorna la data di scadenza
|
||||||
|
if (w == "IMPORTO") ret = _scadenze_array.row(_scadenze_current).get(1); // ritorna l'importo in scadenza
|
||||||
|
}
|
||||||
|
return (const char*)ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TDocumentoEsteso::scadenze_set_next()
|
||||||
|
{
|
||||||
|
if (_scadenze_current < _scadenze_array.items() && _scadenze_current >= 0)
|
||||||
|
_scadenze_current++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TDocumentoEsteso::scadenze_reset()
|
||||||
|
{
|
||||||
|
if (_scadenze_current > 0)
|
||||||
|
_scadenze_current = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
real& TDocumentoEsteso::tot_importi_netti()
|
||||||
|
{
|
||||||
|
if (!summary_compiled()) compile_summary();
|
||||||
|
return _importi_netti;
|
||||||
|
}
|
||||||
|
|
||||||
|
real& TDocumentoEsteso::tot_imposte()
|
||||||
|
{
|
||||||
|
if (!summary_compiled()) compile_summary();
|
||||||
|
return _imposte;
|
||||||
|
}
|
||||||
|
|
||||||
|
real TDocumentoEsteso::tot_spese()
|
||||||
|
{
|
||||||
|
TString16 t("TOTSP");
|
||||||
|
real number(get_head_info(t));
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
real TDocumentoEsteso::tot_documento()
|
||||||
|
{
|
||||||
|
if (!summary_compiled()) compile_summary();
|
||||||
|
real number = _imposte + _importi_netti;
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
real TDocumentoEsteso::tot_imponibili(byte selector)
|
||||||
|
{
|
||||||
|
if (!summary_compiled()) compile_summary();
|
||||||
|
|
||||||
|
real number = 0.0;
|
||||||
|
const int items = _summary_table.items();
|
||||||
|
TRiepilogo_Iva* curr = (TRiepilogo_Iva *) _summary_table.first_item();
|
||||||
|
for (int i = 0; i < items && curr != NULL; i++)
|
||||||
|
{
|
||||||
|
if (curr->tipo() & selector) // se fa parte del filtro selezionato schiaffa il codice nella TToken_string
|
||||||
|
number += curr->imp();
|
||||||
|
curr = (TRiepilogo_Iva*) _summary_table.succ_item();
|
||||||
|
}
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* TDocumentoEsteso::get_head_info(const TString & what)
|
||||||
|
{
|
||||||
|
TToken_string memo(head().get("G1"),'\n'); // prende il campo memo con i totalizzatori. Un totalizzatore per riga nella forma <MACRO>=<VALORE>
|
||||||
|
TString rt;
|
||||||
|
const int items = memo.items();
|
||||||
|
for (int i = 0; i<items; i++) // scorre le righe del memo
|
||||||
|
{
|
||||||
|
TToken_string item(memo.get(),'=');
|
||||||
|
if (what == item.get())
|
||||||
|
{
|
||||||
|
rt = item.get();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (const char*) rt;
|
||||||
|
}
|
||||||
|
|
||||||
|
TDocumentoEsteso::TDocumentoEsteso(const TRectype& rec, TCond_vendita * condv)
|
||||||
|
: TDocumento(rec, condv), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1)
|
||||||
|
{
|
||||||
|
_iva = new TTable("%IVA");
|
||||||
|
// Inizializza i parametri di default
|
||||||
|
_parm.pri_lit = 0; _parm.pri_val = 3;
|
||||||
|
_parm.qta_lit = 3; _parm.qta_val = 3;
|
||||||
|
_parm.imp_lit = 0; _parm.imp_val = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
TDocumentoEsteso::TDocumentoEsteso(const TRectype& rec, dec_parm & parm, TCond_vendita * condv)
|
||||||
|
: TDocumento(rec, condv), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1)
|
||||||
|
{
|
||||||
|
_parm = parm;
|
||||||
|
_iva = new TTable("%IVA");
|
||||||
|
}
|
||||||
|
|
||||||
|
TDocumentoEsteso::TDocumentoEsteso()
|
||||||
|
: TDocumento(), _sum_filter(-1), _sum_selected(FALSE), _scadenze_current(-1)
|
||||||
|
{
|
||||||
|
_iva = new TTable("%IVA");
|
||||||
|
}
|
||||||
|
|
||||||
|
TDocumentoEsteso::~TDocumentoEsteso()
|
||||||
|
{
|
||||||
|
if (_iva != NULL) delete _iva;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
420
ve/velib06.cpp
Executable file
420
ve/velib06.cpp
Executable file
@ -0,0 +1,420 @@
|
|||||||
|
#include <relapp.h>
|
||||||
|
#include <utility.h>
|
||||||
|
#include <tabutil.h>
|
||||||
|
#include <msksheet.h>
|
||||||
|
#include <recarray.h>
|
||||||
|
#include <assoc.h>
|
||||||
|
#include <checks.h>
|
||||||
|
#include <defmask.h>
|
||||||
|
#include <varrec.h>
|
||||||
|
#include "..\ve\velib01.h"
|
||||||
|
#include "..\ve\sconti.h"
|
||||||
|
#include "..\ve\velib03.h"
|
||||||
|
#include "..\ve\veconf.h"
|
||||||
|
|
||||||
|
|
||||||
|
const real CENTO=real(100.0);
|
||||||
|
|
||||||
|
|
||||||
|
bool TCondizione_vendita:: ricerca(const char * codice, const real & qta)
|
||||||
|
{
|
||||||
|
int tiporic;
|
||||||
|
switch (_condv.get_char("TIPO")) {
|
||||||
|
case 'L':
|
||||||
|
tiporic=A_LISTINI;
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
tiporic=A_CONTRATTI;
|
||||||
|
break;
|
||||||
|
case 'O':
|
||||||
|
tiporic=A_OFFERTE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return cerca(tiporic,codice, qta);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool TCondizione_vendita::cerca( int tiporicerca, const char * codriga , const real & qta)
|
||||||
|
{
|
||||||
|
if( config_ditta().get_bool( "GES", "ve", tiporicerca ) )
|
||||||
|
{
|
||||||
|
_condv.setkey( 1 );
|
||||||
|
|
||||||
|
if (_condv.get("COD").empty())
|
||||||
|
return FALSE;
|
||||||
|
switch( tiporicerca )
|
||||||
|
{
|
||||||
|
case A_CONTRATTI:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case A_LISTINI:
|
||||||
|
{
|
||||||
|
_condv.put("TIPOCF", "");
|
||||||
|
_condv.put("CODCF", "");
|
||||||
|
if( !config_ditta().get_bool("GESLISCV", "ve"))
|
||||||
|
_condv.put("CATVEN", "");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case A_OFFERTE:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if( _condv.read( ) == NOERR )
|
||||||
|
{
|
||||||
|
// si posiziona sulla riga
|
||||||
|
const bool gest_scagl = _condv.get_bool("GESTSCAGL");
|
||||||
|
const TString16 seqricrighe( _condv.get( "SEQRIC" ) );
|
||||||
|
bool found = FALSE;
|
||||||
|
|
||||||
|
for( int i = 0; !found && i < seqricrighe.len( ); i ++ )
|
||||||
|
{
|
||||||
|
_rcondv.zero( );
|
||||||
|
_rcondv.put( "TIPO", _condv.get( "TIPO"));
|
||||||
|
_rcondv.put( "CATVEN", _condv.get( "CATVEN"));
|
||||||
|
_rcondv.put( "TIPOCF", _condv.get( "TIPOCF"));
|
||||||
|
_rcondv.put( "CODCF", _condv.get( "CODCF"));
|
||||||
|
_rcondv.put("COD", _condv.get("COD"));
|
||||||
|
if (gest_scagl)
|
||||||
|
_rcondv.put("NSCAGL", 1);
|
||||||
|
|
||||||
|
char ricerca = seqricrighe[ i ];
|
||||||
|
_rcondv.put( "TIPORIGA", ricerca );
|
||||||
|
switch( ricerca )
|
||||||
|
{
|
||||||
|
case 'A':
|
||||||
|
{
|
||||||
|
_rcondv.put( "CODRIGA", codriga);
|
||||||
|
if (_rcondv.read() != NOERR &&
|
||||||
|
_rcondv.prev() == NOERR &&
|
||||||
|
_rcondv.get("TIPORIGA")[0] == 'A')
|
||||||
|
{
|
||||||
|
const TString cod_found(_rcondv.get("CODRIGA"));
|
||||||
|
return cod_found.compare(codriga, cod_found.len()) == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
_rcondv.put("CODRIGA", anamag().get( "RAGGFIS"));
|
||||||
|
_rcondv.read();
|
||||||
|
break;
|
||||||
|
case 'S':
|
||||||
|
{
|
||||||
|
_rcondv.put( "CODRIGA", anamag().get("GRMERC"));
|
||||||
|
_rcondv.read( );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'G':
|
||||||
|
{
|
||||||
|
_rcondv.put( "CODRIGA", anamag().get("GRMERC").left(3));
|
||||||
|
_rcondv.read( );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
found = _rcondv.good();
|
||||||
|
}
|
||||||
|
// individua lo scaglione corretto in base alla quantita'
|
||||||
|
if (found && gest_scagl)
|
||||||
|
{
|
||||||
|
TRectype rec(_rcondv.curr());
|
||||||
|
int last_scagl = 0;
|
||||||
|
int scagl = _rcondv.get_int("NSCAGL");
|
||||||
|
real qta_lim(_rcondv.get_real("QLIM"));
|
||||||
|
while (_rcondv.good() && scagl > last_scagl && qta_lim > ZERO && qta > qta_lim)
|
||||||
|
{
|
||||||
|
if (_rcondv.next() == NOERR)
|
||||||
|
{
|
||||||
|
last_scagl = scagl;
|
||||||
|
scagl = _rcondv.get_int("NSCAGL");
|
||||||
|
qta_lim =_rcondv.get_real("QLIM");
|
||||||
|
rec = _rcondv.curr();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_rcondv.read(rec);
|
||||||
|
}
|
||||||
|
_prezzo = _rcondv.get_real("PREZZO");
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ricerca fallita
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*void TCondizione_vendita::ricerca(bool load_um_only, bool load_scagl_only)
|
||||||
|
{
|
||||||
|
TString codart = anamag().get( "CODART" );
|
||||||
|
const TString codriga = riga().get( FR_CODART );
|
||||||
|
|
||||||
|
_ivarid = _clifo->get_bool(LF_CFVEN, "IVARID");
|
||||||
|
_load_mask = !load_um_only && !load_scagl_only;
|
||||||
|
|
||||||
|
if(anamag().bad() || codriga != codart )
|
||||||
|
{
|
||||||
|
anamag().setkey(1);
|
||||||
|
anamag().put("CODART", codriga);
|
||||||
|
if (anamag().read() != NOERR)
|
||||||
|
{
|
||||||
|
set _prezzo(ZERO);
|
||||||
|
set_sconto("");
|
||||||
|
set_iva("");
|
||||||
|
set_provv(ZERO);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
codart = umart().get( "CODART" );
|
||||||
|
const TString16 umriga(riga().get(FR_UMQTA));
|
||||||
|
const TString16 um(umart().get("UM"));
|
||||||
|
if (umart().bad() || codart != codriga || um != umriga)
|
||||||
|
{
|
||||||
|
umart().setkey(2);
|
||||||
|
umart().put("CODART", codriga);
|
||||||
|
umart().put("UM", um);
|
||||||
|
if (umart().read != NOERR)
|
||||||
|
umart().zero();
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool found_condv = cerca(A_CONTRATTI) || cerca(A_OFFERTE) || cerca(A_LISTINI);
|
||||||
|
const bool cv_scagl = get_bool("GESTSCAGL");
|
||||||
|
const bool cv_um = get_bool("GESTUM");
|
||||||
|
|
||||||
|
if (found_condv)
|
||||||
|
{
|
||||||
|
_load_mask |= load_scagl_only && cv_scagl;
|
||||||
|
_load_mask |= load_um_only && cv_um;
|
||||||
|
set_prezzo(_rcondv.get_real("PREZZO"), get("CODVAL"));
|
||||||
|
_load_mask = !load_um_only && !load_scagl_only;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// if (full_load)
|
||||||
|
set_prezzo(umart().get_real("PREZZO"));
|
||||||
|
|
||||||
|
|
||||||
|
// if (full_load)
|
||||||
|
// {
|
||||||
|
if (_ivarid)
|
||||||
|
set_iva(anamag().get("CODIVAR"));
|
||||||
|
else
|
||||||
|
set_iva(anamag().get("CODIVA"));
|
||||||
|
// }
|
||||||
|
|
||||||
|
const char gestione = config_ditta().get_char( "GESSCORIGA", "ve" );
|
||||||
|
const bool sco_scagl = config_ditta().get_bool("GESCOSCA", "ve");
|
||||||
|
const bool sco_um_gest = config_ditta().get_bool("GESSCORIGAUM", "ve");
|
||||||
|
|
||||||
|
// if (!full_load && gestione != 'A' && !sco_scagl)
|
||||||
|
// {
|
||||||
|
// if (gestione == 'L' && found_condv)
|
||||||
|
// set_sconto(_rcondv.get("SCONTO"));
|
||||||
|
//}
|
||||||
|
// else
|
||||||
|
{
|
||||||
|
switch (gestione)
|
||||||
|
{
|
||||||
|
case 'N':
|
||||||
|
// Sconti di riga non gestiti
|
||||||
|
set_sconto("");
|
||||||
|
break;
|
||||||
|
case 'L':
|
||||||
|
// Percentuale su contratti/offerte/listini/anagrafica
|
||||||
|
if (found_condv)
|
||||||
|
{
|
||||||
|
_load_mask |= load_scagl_only && cv_scagl;
|
||||||
|
_load_mask |= load_um_only && cv_um;
|
||||||
|
set_sconto(_rcondv.get("SCONTO"));
|
||||||
|
_load_mask = !load_um_only && !load_scagl_only;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
set_sconto(anamag().get("SCONTO"));
|
||||||
|
break;
|
||||||
|
case 'A':
|
||||||
|
{
|
||||||
|
// Posiziono l'anagrafica
|
||||||
|
const char rigakey = config_ditta().get_char( "SCORIGAKEY", "ve" );
|
||||||
|
|
||||||
|
_sconti.setkey(1);
|
||||||
|
_sconti.put("TIPO", "R");
|
||||||
|
if( config_ditta().get_bool("GESSCORIGACV", "ve"))
|
||||||
|
_sconti.put("CODCAT", clifo().get(LF_CFVEN, "CATVEN"));
|
||||||
|
if (sco_um_gest)
|
||||||
|
_sconti.put("UM", riga().get( FR_UMQTA));
|
||||||
|
_sconti.put("TIPORIGA", rigakey);
|
||||||
|
|
||||||
|
if (sco_scagl)
|
||||||
|
_sconti.put("NSCAGL", 1);
|
||||||
|
|
||||||
|
switch (rigakey)
|
||||||
|
{
|
||||||
|
case 'A':
|
||||||
|
_sconti.put("CODART", codriga);
|
||||||
|
_sconti.read();
|
||||||
|
break;
|
||||||
|
case 'R':
|
||||||
|
_sconti.put("CODART", anamag().get("RAGGFIS"));
|
||||||
|
_sconti.read();
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
{
|
||||||
|
_sconti.put( "CODART", anamag().get("GRMERC"));
|
||||||
|
_sconti.read( );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'L':
|
||||||
|
{
|
||||||
|
_sconti.put("CODART", anamag().get("GRMERC").left(3));
|
||||||
|
_sconti.read();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error_box("Tipo di chiave righe sconti '%c' non valida!", rigakey);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool found = _sconti.good();
|
||||||
|
|
||||||
|
if (found && sco_scagl)
|
||||||
|
{
|
||||||
|
TRectype rec(_sconti.curr());
|
||||||
|
int last_scagl = 0;
|
||||||
|
int scagl = _sconti.get_int("NSCAGL");
|
||||||
|
const real qta(riga().get_real(FR_QTA));
|
||||||
|
real qta_lim(_sconti.get_real("QLIM"));
|
||||||
|
|
||||||
|
while (_sconti.good() && scagl > last_scagl && qta_lim > ZERO && qta > qta_lim)
|
||||||
|
{
|
||||||
|
if (_sconti.next() == NOERR)
|
||||||
|
{
|
||||||
|
last_scagl = scagl;
|
||||||
|
scagl = _sconti.get_int("NSCAGL");
|
||||||
|
qta_lim =_sconti.get_real("QLIM");
|
||||||
|
rec = _sconti.curr();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_rcondv.read(rec);
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
_sconti.zero();
|
||||||
|
_load_mask |= load_scagl_only && sco_scagl;
|
||||||
|
_load_mask |= load_scagl_only && sco_um_gest;
|
||||||
|
set_sconto(_sconti.get("SCONTO"));
|
||||||
|
_load_mask = !load_um_only && !load_scagl_only;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
set_sconto(clifo().get(LF_CFVEN, "SCONTO"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error_box("Tipo di gestione sconti '%c' non valido!", gestione );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (riga() && riga().get("PERCPROVV") >= 0 && riga().field(FR_PERCPROV).active())
|
||||||
|
{
|
||||||
|
const TString16 codage(testa().get(f_CODAG));
|
||||||
|
|
||||||
|
if (codage.not_empty())
|
||||||
|
{
|
||||||
|
TTable age("AGE");
|
||||||
|
|
||||||
|
age.put("CODTAB", codage);
|
||||||
|
if (age.read() == NOERR)
|
||||||
|
{
|
||||||
|
char tipoprovv = age.get("S6")[0];
|
||||||
|
|
||||||
|
if (tipoprovv <= ' ')
|
||||||
|
tipoprovv = config_ditta().get_char( "AGETIPOPERC", "ve" );
|
||||||
|
|
||||||
|
// if (!full_load)
|
||||||
|
// {
|
||||||
|
// if (tipoprovv == 'L' && found_condv)
|
||||||
|
// set_provv(_rcondv.get_real("PERCPROVV"));
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
{
|
||||||
|
switch (tipoprovv)
|
||||||
|
{
|
||||||
|
case 'A':
|
||||||
|
set_provv(age.get_real("R0"));
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
set_provv(real(clifo().get(LF_CFVEN, "PERCPROVV")));
|
||||||
|
break;
|
||||||
|
case 'L':
|
||||||
|
if (found_condv)
|
||||||
|
{
|
||||||
|
_load_mask |= load_scagl_only && sco_scagl;
|
||||||
|
_load_mask |= load_scagl_only && sco_um_gest;
|
||||||
|
set_provv(_rcondv.get_real("PERCPROVV"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
set_provv(anamag().get_real("PERCPROVV"));
|
||||||
|
break;
|
||||||
|
case 'V':
|
||||||
|
{
|
||||||
|
TString16 catven(testa().get("CATVEN"));
|
||||||
|
|
||||||
|
if (catven.empty())
|
||||||
|
catven = clifo().get(LF_CFVEN, "CATVEN");
|
||||||
|
|
||||||
|
if (catven.not_empty())
|
||||||
|
{
|
||||||
|
TTable cve("CVE");
|
||||||
|
|
||||||
|
cve.put("CODART", codage);
|
||||||
|
if (cve.read() == NOERR)
|
||||||
|
set_provv(cve.get_real("R0"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error_box("Tipo di gestione provvigioni '%c' non valido!", tipoprovv );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void TCondizione_vendita::put_condv(const char *tipocv,const char *codicecv,const char *catven,const char *tipocf,const char *codcf)
|
||||||
|
{
|
||||||
|
_condv.put("TIPO",tipocv);
|
||||||
|
_condv.put("CATVEN",catven);
|
||||||
|
_condv.put("TIPOCF",tipocf);
|
||||||
|
_condv.put("CODCF",codcf);
|
||||||
|
_condv.put("COD",codicecv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TCondizione_vendita::put_listino(const char * codlist,const char *catven)
|
||||||
|
{
|
||||||
|
if( !config_ditta().get_bool("GESLISCV", "ve"))
|
||||||
|
put_condv("L",codlist,"","","");
|
||||||
|
else
|
||||||
|
put_condv("L",codlist,catven,"","");
|
||||||
|
}
|
||||||
|
void TCondizione_vendita::put_contratto(const char * codcontr,const char *tipocf,const char *codcf)
|
||||||
|
{
|
||||||
|
put_condv("C",codcontr,"",tipocf,codcf);
|
||||||
|
}
|
||||||
|
void TCondizione_vendita::put_offerta(const char * codoff)
|
||||||
|
{
|
||||||
|
put_condv("C",codoff,"","","");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TCondizione_vendita::TCondizione_vendita(TConfig * ditta,
|
||||||
|
TLocalisamfile * anamag, TLocalisamfile * umart)
|
||||||
|
: _condv(LF_CONDV), _rcondv(LF_RCONDV),
|
||||||
|
_sconti( LF_SCONTI ),
|
||||||
|
_anamag(anamag), _umart(umart), _config_ditta(ditta), _ivarid(FALSE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
9
ve/vepriv.h
Executable file
9
ve/vepriv.h
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
enum _formule {_somma, _bolli, _bolli_int, _spinc, _prezzo, _importo, _sconto, _iva, _provv, _tipo, _imponibili, _imposte};
|
||||||
|
enum TTipo_calcolo { _nessun_calcolo, _qtaprezzo, _valore, _percentuale, _scontoimp, _scontoperc};
|
||||||
|
|
||||||
|
void row_set_handler( TMask& m, const int field, const int index );
|
||||||
|
bool liv_handler( TMask_field& f, KEY key );
|
||||||
|
bool sppr_handler( TMask_field& f, KEY key );
|
||||||
|
bool iva_handler( TMask_field& f, KEY key );
|
||||||
|
void sppr_calc(TRectype & rec, const TString & valuta_doc, const real & cambio, real & prezzo);
|
Loading…
x
Reference in New Issue
Block a user