fc22ece6d4
git-svn-id: svn://10.65.10.50/branches/R_10_00@22752 c028cbd2-c16b-5b4b-a496-9718f37d4682
1989 lines
55 KiB
C++
Executable File
1989 lines
55 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <form.h>
|
|
#include <printer.h>
|
|
#include <progind.h>
|
|
#include <textset.h>
|
|
|
|
#include "ps0925.h"
|
|
#include "ps0925100a.h"
|
|
#include "../sc/sc2101.h"
|
|
#include "../sc/sc2102.h"
|
|
|
|
#include "../sc/sc2100a.h"
|
|
#include "../sc/sc21pec.h"
|
|
|
|
#include "../cg/cgsaldac.h"
|
|
#include "../pr/agenti.h"
|
|
|
|
#include <cfven.h>
|
|
#include <causali.h>
|
|
#include <mov.h>
|
|
|
|
class TEC_recordset : public TAS400_recordset
|
|
{
|
|
public:
|
|
TEC_recordset();
|
|
};
|
|
|
|
TEC_recordset::TEC_recordset() : TAS400_recordset("AS400(255,0,0)")
|
|
{
|
|
create_field("Ditta", 0, 6, _longfld);
|
|
create_field("Cliente", 6, 6, _longfld);
|
|
create_field("RagioneSociale", -1, 50);
|
|
create_field("Valuta", -1, 3);
|
|
create_field("Causale", -1, 3);
|
|
create_field("Descrizione", -1, 60);
|
|
create_field("DataDoc", -1, 10, _datefld);
|
|
create_field("NumDoc" , -1, 7);
|
|
create_field("ProtIVA", -1, 6, _intfld);
|
|
create_field("DataPag", -1, 10, _datefld);
|
|
create_field("Dare", -1, 15, _realfld);
|
|
create_field("Avere", -1, 15, _realfld);
|
|
create_field("Scaduto", -1, 15, _realfld);
|
|
create_field("Esposto", -1, 15, _realfld);
|
|
create_field("SBF", -1, 1);
|
|
create_field("TotDoc", -1, 15, _realfld);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TEC_form
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TEC_form : public TForm
|
|
{
|
|
friend class TEC_row;
|
|
|
|
static TEC_form* _form;
|
|
TEC_recordset* _recordset;
|
|
|
|
enum { MAXTOT = 16 };
|
|
|
|
TCursor* _cursore;
|
|
TTotalizer _totali;
|
|
|
|
TString _lingua; // Codice lingua del form
|
|
TDate _dlo, _dls, _dir; // Data limite operazione, scaduto e inizio rischio
|
|
int _giorni_rischio; // Numero giorni rischio nella maschera di selezione
|
|
bool _in_valuta; // Il form e' in valuta
|
|
int _fincatura; // 0 = nessuna, 1 = testo, 2 = grafica
|
|
word _num_rip; // Numero di righe usate per i riporti
|
|
word _total_rows; // Numero di righe usate per i totali
|
|
word _maxtot; // Numero massimo di totali da stampare
|
|
bool _stampa_saldo; // Stampa il saldo di ogni partita
|
|
|
|
protected:
|
|
void init_header(const TMask& m);
|
|
word ordina_totali_per_valuta(THash_object* tot[MAXTOT]);
|
|
|
|
int find_magic(TString& s, TString& magic1, TString& magic2) const;
|
|
void change_magic_body(const TEC_row& o, TString& s);
|
|
void change_magic_footer(const THash_object& o, TString& s);
|
|
void print_total(int riga, const THash_object& o);
|
|
|
|
void stampa_testata(TPrinter& p);
|
|
void stampa_pedata();
|
|
void stampa_riporti(TPrinter& p);
|
|
|
|
static void ec_header_handler(TPrinter& p);
|
|
static void ec_footer_handler(TPrinter& p);
|
|
|
|
public:
|
|
TTotalizer& totali() { return _totali; }
|
|
|
|
const TDate& data_limite_operazione() const { return _dlo; }
|
|
const TDate& data_limite_scaduto() const { return _dls; }
|
|
int giorni_rischio() const { return _giorni_rischio; }
|
|
const TDate& data_inizio_rischio() const { return _dir; }
|
|
|
|
const TString& lingua() const { return _lingua; }
|
|
bool in_valuta() const { return _in_valuta; }
|
|
const TString& describe(short id, char sez = 'H', pagetype pt = last_page) const;
|
|
|
|
void azzera_totali();
|
|
void ultima_pagina();
|
|
bool print_game(const TPartita& game);
|
|
bool stampa_saldo() const { return _stampa_saldo; }
|
|
void stampa_saldo(bool ss) { _stampa_saldo = ss; }
|
|
|
|
void set_agente(const TString& codag);
|
|
|
|
bool printing() const { return _recordset == NULL; }
|
|
bool exporting() const { return _recordset != NULL; }
|
|
void export_total();
|
|
|
|
TEC_recordset& recordset() const { CHECK(exporting(),"Not exporting"); return *_recordset; }
|
|
|
|
TEC_form(const TEC_mask& m, bool gesval, bool excel);
|
|
virtual ~TEC_form();
|
|
};
|
|
|
|
TEC_form* TEC_form::_form = NULL;
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TEC_row
|
|
// Rappresenta una singola riga di stampa
|
|
///////////////////////////////////////////////////////////
|
|
|
|
static char __ltipocf;
|
|
static long __lcodcf;
|
|
|
|
class TEC_row : public TSortable
|
|
{
|
|
TDate _data; // Data scadenza o pagamento
|
|
int _riga; // Riga della fattura
|
|
int _rata; // Numero rata o progressivo
|
|
|
|
TString _causale; // Codice causale
|
|
TString _descrizione; // Sua descrizione
|
|
|
|
char _tipocf;
|
|
long _codcf;
|
|
|
|
TDate _data_doc; // Data del documento
|
|
TString _num_doc; // Numero documento
|
|
long _num_prot; // Protocollo IVA
|
|
long _num_reg; // Numero registrazione
|
|
TImporto _importo; // Importo in valuta
|
|
real _importo_euro; // Importo in lire
|
|
real _scaduto; // Importo scaduto
|
|
real _esposto; // Importo esposto
|
|
bool _salvo_buon_fine; // Importo esposto salvo buon fine
|
|
real _totale; // Totale documento
|
|
TValuta _valuta; // Codice valuta, data cambio e cambio
|
|
bool _bloccata; // Rata bloccata
|
|
|
|
protected: // TSortable
|
|
virtual int compare(const TSortable& s) const;
|
|
void set_imp(TForm_item& fi, const real& imp, const char* codval) const;
|
|
|
|
TEC_form& form() const;
|
|
|
|
public:
|
|
int riga() const { return _riga; }
|
|
int rata() const { return _rata; }
|
|
|
|
void reset_uguali();
|
|
void descrizione(const char* s) { _descrizione = s; }
|
|
void importo(const TImporto& i) { _importo = i; }
|
|
void importo_euro(const real& i) { _importo_euro = i; }
|
|
void scaduto(const real& s) { _scaduto = s; }
|
|
void esposto(const real& e) { _esposto = e; }
|
|
void salvo_buon_fine(bool sbf) { _salvo_buon_fine = sbf; }
|
|
void rata_bloccata(bool rb) { _bloccata = rb; }
|
|
|
|
const TString& causale() const { return _causale; }
|
|
const TString& descrizione() const { return _descrizione; }
|
|
long num_reg() const { return _num_reg; }
|
|
const TDate& data() const { return _data; }
|
|
const TImporto& importo() const { return _importo; }
|
|
const real& importo_euro() const { return _importo_euro; }
|
|
const real& scaduto() const { return _scaduto; }
|
|
const real& esposto() const { return _esposto; }
|
|
const TValuta& valuta() const { return _valuta; }
|
|
bool in_valuta() const { return _valuta.in_valuta(); }
|
|
|
|
void print_on(TPrint_section& body);
|
|
void export_to(TEC_recordset& set);
|
|
|
|
TEC_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata);
|
|
TEC_row(const char* desc, const TImporto& imp, const TValuta& val);
|
|
virtual ~TEC_row() {}
|
|
};
|
|
|
|
TEC_row::TEC_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata)
|
|
: _salvo_buon_fine(false), _bloccata(false)
|
|
{
|
|
_riga = row.get_int(PART_NRIGA);
|
|
_rata = rata;
|
|
_data = data;
|
|
_causale = row.get(PART_CODCAUS);
|
|
_data_doc = row.get(PART_DATADOC);
|
|
_num_doc = row.get(PART_NUMDOC);
|
|
_num_prot = row.get_long(PART_PROTIVA);
|
|
_num_reg = row.get_long(PART_NREG);
|
|
_importo = imp; _importo.normalize();
|
|
_descrizione = row.get(PART_DESCR);
|
|
if (_descrizione.empty())
|
|
_descrizione = cache().get(LF_CAUSALI, _causale).get(CAU_DESCR);
|
|
_valuta.get(row);
|
|
|
|
const bool valuta = form().in_valuta() && _valuta.in_valuta();
|
|
const char* const field = valuta ? PART_IMPTOTVAL : PART_IMPTOTDOC;
|
|
_totale = row.get_real(field);
|
|
__ltipocf = _tipocf = row.get_char(PART_TIPOCF);
|
|
__lcodcf = _codcf = row.get_long(PART_SOTTOCONTO);
|
|
}
|
|
|
|
TEC_row::TEC_row(const char* desc, const TImporto& imp, const TValuta& val)
|
|
: _riga(9999), _rata(9999), _num_doc(0),
|
|
_num_prot(0), _num_reg(0), _salvo_buon_fine(false), _bloccata(false)
|
|
{
|
|
_descrizione = desc;
|
|
_importo = imp; _importo.normalize();
|
|
_valuta = val;
|
|
_tipocf = __ltipocf;
|
|
_codcf = __lcodcf;
|
|
}
|
|
|
|
// Le righe dell'estratto conto sono ordinate per data, riga partita, numero rata o
|
|
// posizione iniziale nell'array (in caso di uguaglianza di tutto il resto)
|
|
int TEC_row::compare(const TSortable& s) const
|
|
{
|
|
const TEC_row& r = (const TEC_row&)s;
|
|
int c = 0;
|
|
if (_data == r._data)
|
|
{
|
|
c = _riga - r._riga;
|
|
if (c == 0)
|
|
c = _rata - r._rata;
|
|
}
|
|
else
|
|
c = _data > r._data ? +1 : -1;
|
|
return c;
|
|
}
|
|
|
|
// Annulla i campi uguali alla riga precedente
|
|
void TEC_row::reset_uguali()
|
|
{
|
|
_num_doc = "";
|
|
_data_doc = botime;
|
|
_num_prot = 0;
|
|
_totale = ZERO;
|
|
}
|
|
|
|
void TEC_row::set_imp(TForm_item& fi, const real& imp, const char* cod_val) const
|
|
{
|
|
const TCurrency cur(imp, cod_val);
|
|
fi.set(cur.get_num().string());
|
|
}
|
|
|
|
TEC_form& TEC_row::form() const
|
|
{
|
|
TEC_form* f = TEC_form::_form;
|
|
CHECK(f, "NULL form");
|
|
return *f;
|
|
}
|
|
|
|
void TEC_row::print_on(TPrint_section& body)
|
|
{
|
|
TEC_form& form = (TEC_form&)body.form();
|
|
|
|
const bool show_value = form.in_valuta() && in_valuta();
|
|
const TString & cod_valuta = (show_value ? valuta().codice() : EMPTY_STRING); // Stampa nella valuta della ditta
|
|
|
|
TForm_item& campo_valuta = body.find_field(PEC_VALUTA);
|
|
campo_valuta.set(cod_valuta);
|
|
|
|
TForm_item& causale = body.find_field(PEC_CODCAUS);
|
|
causale.set(_causale);
|
|
|
|
TForm_item& descr = body.find_field(PEC_DESCR);
|
|
|
|
// Riga di partita vera e propria (non totale parziale)
|
|
if (rata() < RIGA_PAGAMENTO)
|
|
{
|
|
TString256 s = descr.prompt();
|
|
TEC_form::_form->change_magic_body(*this, s);
|
|
descr.set(s);
|
|
}
|
|
else
|
|
descr.set(_descrizione);
|
|
|
|
TForm_item& datadoc = body.find_field(PEC_DATADOC);
|
|
datadoc.set(_data_doc.string());
|
|
|
|
TForm_item& numdoc = body.find_field(PEC_NUMDOC);
|
|
numdoc.set(_num_doc);
|
|
|
|
TForm_item& numprot = body.find_field(PEC_PROTIVA);
|
|
TString8 protiva; protiva << _num_prot;
|
|
numprot.set(protiva);
|
|
|
|
TForm_item& datapag = body.find_field(PEC_DATAPAG);
|
|
datapag.set(_data.string());
|
|
|
|
const real& imp = _importo.valore();
|
|
TForm_item& dare = body.find_field(PEC_DARE);
|
|
TForm_item& avere = body.find_field(PEC_AVERE);
|
|
|
|
if (_importo.sezione() == 'D')
|
|
{
|
|
set_imp(dare, imp, cod_valuta);
|
|
avere.set("");
|
|
}
|
|
else
|
|
{
|
|
set_imp(avere, imp, cod_valuta);
|
|
dare.set("");
|
|
}
|
|
|
|
TForm_item& scaduto = body.find_field(PEC_SCADUTO);
|
|
set_imp(scaduto, _scaduto, cod_valuta);
|
|
|
|
TForm_item& esposto = body.find_field(PEC_ESPOSTO);
|
|
set_imp(esposto, _esposto, cod_valuta);
|
|
esposto.set_prompt(_salvo_buon_fine ? "*" : " ");
|
|
|
|
TForm_item& totdoc = body.find_field(PEC_TOTDOC);
|
|
set_imp(totdoc, _totale, cod_valuta);
|
|
|
|
TForm_item& euro = body.find_field(PEC_IMPEURO);
|
|
set_imp(euro, _importo_euro, ""); // In generale va espresso nella valuta della ditta
|
|
|
|
TForm_item& cambio = body.find_field(PEC_CAMBIO);
|
|
cambio.set(_valuta.cambio().string());
|
|
|
|
TForm_item& datacambio = body.find_field(PEC_DATACAM);
|
|
datacambio.set(_valuta.data().string());
|
|
|
|
TForm_item& bloccata = body.find_field(PEC_BLOCCATA);
|
|
bloccata.set(_bloccata ? "X" : "");
|
|
|
|
const TString80 old_prompt(descr.prompt());
|
|
descr.set_prompt(""); // Nasconde temporaneamente il prompt per non stampare i <magic>
|
|
|
|
body.update(); // Crea vera riga di stampa
|
|
|
|
esposto.set_prompt(" "); // Ripristina il vecchio prompt
|
|
descr.set_prompt(old_prompt);
|
|
}
|
|
|
|
void TEC_row::export_to(TEC_recordset& r)
|
|
{
|
|
r.new_rec();
|
|
r.set("Cliente", TVariant(_codcf));
|
|
TString key; key.format("%c|%ld", _tipocf, _codcf);
|
|
const TString & ragsoc = cache().get(LF_CLIFO, key, CLI_RAGSOC);
|
|
|
|
r.set("Ditta", TVariant(prefix().get_codditta()));
|
|
r.set("RagioneSociale", TVariant(ragsoc));
|
|
r.set("Valuta", TVariant(_valuta.codice()));
|
|
r.set("Causale", TVariant(_causale));
|
|
r.set("Descrizione", TVariant(_descrizione));
|
|
r.set("DataDoc", TVariant(_data_doc));
|
|
r.set("NumDoc", TVariant(_num_doc));
|
|
r.set("ProtIVA", TVariant(_num_prot));
|
|
r.set("DataPag", TVariant(_data));
|
|
r.set(_importo.sezione() == 'D' ? "Dare" : "Avere", _importo.valore());
|
|
r.set("Scaduto", TVariant(_scaduto));
|
|
r.set("Esposto", TVariant(_esposto));
|
|
r.set("SBF", TVariant(_salvo_buon_fine ? "*" : " "));
|
|
r.set("TotDoc", TVariant(_totale));
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TEC_array
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TEC_array : public TArray
|
|
{
|
|
TArray _scaduto; // Array di importi scaduti
|
|
|
|
const TEC_form* _form; // Form che contiene l'array di righe
|
|
|
|
protected:
|
|
TEC_row& new_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata = 0);
|
|
void add_row(const TRiga_partite& row);
|
|
|
|
const TEC_form& form() const { return *_form; }
|
|
real calcola_scaduto(const TRiga_scadenze& rata, bool valuta);
|
|
|
|
TImporto* importo_riga_scaduto_ptr(int n) const { return (TImporto*)_scaduto.objptr(n); }
|
|
TImporto& importo_riga_scaduto(int n);
|
|
|
|
TImporto importo(const TPartita& game, const TRectype& pag, bool valuta) const;
|
|
|
|
static TPartita* _sort_game;
|
|
static int ordina_pag(const void* pag1, const void* pag2);
|
|
void arrange_scaduto(const TPartita& game);
|
|
|
|
public:
|
|
TEC_row& row(int r) const { return (TEC_row&)operator[](r); }
|
|
|
|
TEC_array(const TPartita& game, const TEC_form* f);
|
|
virtual ~TEC_array() {}
|
|
};
|
|
|
|
TPartita* TEC_array::_sort_game = NULL;
|
|
|
|
// Calcola l'importo su di una riga di pagamento
|
|
TImporto TEC_array::importo(const TPartita& game, const TRectype& pag, bool valuta) const
|
|
{
|
|
const int nriga = pag.get_int(PAGSCA_NRIGA);
|
|
const TRiga_partite& fat = game.riga(nriga); // Riga di fattura
|
|
const bool fat_val = fat.in_valuta();
|
|
|
|
const int nrigp = pag.get_int(PAGSCA_NRIGP);
|
|
const TRiga_partite& sum = game.riga(nrigp); // Riga di pagamento
|
|
const char sez = sum.sezione();
|
|
|
|
const char* const field = valuta && fat_val ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO;
|
|
TImporto imp(sez, pag.get_real(field)); // Importo base
|
|
|
|
if (!fat_val)
|
|
{
|
|
imp.valore() += pag.get_real(PAGSCA_RITENUTE); // Sommo le ritenute se sono il lire
|
|
const TImporto ritsoc(sum.sezione_ritsoc(), pag.get_real(PAGSCA_RITSOC));
|
|
imp += ritsoc;
|
|
}
|
|
|
|
if (pag.get_char(PAGSCA_ACCSAL) == 'S') // Se il pagamento ha abbuoni o differenze cambio
|
|
{
|
|
real abb(pag.get(PAGSCA_ABBUONI));
|
|
if (!valuta && fat_val) // Se voglio gli abbuoni in lire ma la fattura non lo e'
|
|
{
|
|
const TValuta val(sum); // Leggo il cambio dalla riga di partita
|
|
val.val2eur(abb); // Converto in Euro gli abbuoni
|
|
abb += pag.get_real(PAGSCA_DIFFCAM); // Sommo l'eventuale differenza cambio (gia' in lire)
|
|
}
|
|
imp.valore() += abb; // Sommo il tutto all'importo base (sez e' uguale per tutti i valori)
|
|
}
|
|
|
|
return imp;
|
|
}
|
|
|
|
// Certified 100%
|
|
TImporto& TEC_array::importo_riga_scaduto(int n)
|
|
{
|
|
CHECKD(n > 0 && n < 9999, "Riga scaduto errata ", n);
|
|
TImporto* imp = importo_riga_scaduto_ptr(n);
|
|
if (imp == NULL)
|
|
{
|
|
imp = new TImporto;
|
|
_scaduto.add(imp, n);
|
|
}
|
|
return *imp;
|
|
}
|
|
|
|
// Ordina i pagamenti in ordine di DATAPAG
|
|
int TEC_array::ordina_pag(const void* pag1, const void* pag2)
|
|
{
|
|
const int r1 = (*(TRectype**)pag1)->get_int(PAGSCA_NRIGP);
|
|
const TDate d1 = _sort_game->riga(r1).get(PART_DATAPAG);
|
|
const int r2 = (*(TRectype**)pag2)->get_int(PAGSCA_NRIGP);
|
|
const TDate d2 = _sort_game->riga(r2).get(PART_DATAPAG);
|
|
const int diff = d1 == d2 ? 0 : (d1 > d2 ? +1 : -1);
|
|
return diff;
|
|
}
|
|
|
|
real TEC_array::calcola_scaduto(const TRiga_scadenze& rata, bool valuta)
|
|
{
|
|
const TPartita& game = rata.partita();
|
|
const char sezione = game.conto().tipo() == 'C' ? 'D' : 'A';
|
|
|
|
TImporto scaduto_rata = rata.importo(valuta);
|
|
|
|
int riga_corrente_scaduto = 0;
|
|
|
|
const int numpag = rata.rows(); // Numero totale di pagamenti sulla rata
|
|
TRectype** arrpag = NULL; // Array di puntatori ai pagamenti
|
|
if (numpag > 0)
|
|
{
|
|
arrpag = new TRectype*[numpag];
|
|
int i = 0;
|
|
for (int p = rata.last(); p > 0; p = rata.pred(p))
|
|
arrpag[i++] = (TRectype*)&rata.row(p); // Copia puntatori ai pagamenti nell'array
|
|
_sort_game = (TPartita*)&game; // Inizializza partita di appoggio al sort
|
|
qsort(arrpag, numpag, sizeof(TRectype*), ordina_pag);
|
|
}
|
|
|
|
for (int i = 0; i < numpag; i++)
|
|
{
|
|
const TRectype& pag = *arrpag[i];
|
|
const int nrigp = pag.get_int(PAGSCA_NRIGP);
|
|
const TRiga_partite& sum = game.riga(nrigp);
|
|
TImporto imp = importo(game, pag, valuta);
|
|
|
|
tipo_movimento tm = sum.tipo(); // Determina tipo riga
|
|
|
|
// Normalmente gli utenti non usano il tipo pagamento insoluto, per cui devo
|
|
// riconoscere i pagamenti che in realta' sono a fronte di insoluti:
|
|
// 1) hanno tipo movimento = tm_pagamento
|
|
// 2) ho gia' incontrato un insoluto
|
|
// 3) il saldo della rata e' a zero o sommando l'importo arriva sotto zero
|
|
if (tm == tm_pagamento && riga_corrente_scaduto != 0)
|
|
{
|
|
if (scaduto_rata.is_zero())
|
|
{
|
|
tm = tm_pagamento_insoluto;
|
|
}
|
|
else
|
|
{
|
|
TImporto p(scaduto_rata);
|
|
p += imp;
|
|
p.normalize(sezione);
|
|
|
|
if (p.valore() < ZERO)
|
|
{
|
|
scaduto_rata.set('D', ZERO);
|
|
imp += p;
|
|
tm = tm_pagamento_insoluto;
|
|
}
|
|
}
|
|
}
|
|
if (tm == tm_insoluto || tm == tm_pagamento_insoluto)
|
|
{
|
|
if (tm == tm_insoluto)
|
|
riga_corrente_scaduto = nrigp;
|
|
else
|
|
CHECKD(riga_corrente_scaduto > 0, "Pagamento insoluto senza insoluto ", nrigp);
|
|
importo_riga_scaduto(riga_corrente_scaduto) += imp;
|
|
}
|
|
else
|
|
{
|
|
scaduto_rata += imp;
|
|
}
|
|
}
|
|
|
|
if (arrpag != NULL)
|
|
delete arrpag;
|
|
|
|
scaduto_rata.normalize(sezione);
|
|
return scaduto_rata.valore();
|
|
}
|
|
|
|
TEC_row& TEC_array::new_row(const TRiga_partite& row, const TDate& data,
|
|
const TImporto& imp, int n)
|
|
{
|
|
CHECKD(n > 0, "Numero rata errato: ", n);
|
|
TEC_row* riga = new TEC_row(row, data, imp, n);
|
|
add(riga);
|
|
return *riga;
|
|
}
|
|
|
|
void TEC_array::add_row(const TRiga_partite& row)
|
|
{
|
|
const bool in_valuta = form().in_valuta() && row.in_valuta();
|
|
const char sezione = row.get_char(PART_TIPOCF) == 'C' ? 'D' : 'A';
|
|
|
|
const TDate data_op(row.get(PART_DATAREG));
|
|
if (data_op <= form().data_limite_operazione())
|
|
{
|
|
if (row.is_fattura())
|
|
{
|
|
for (int r = 1; r <= row.rate(); r++)
|
|
{
|
|
const TRiga_scadenze& rata = row.rata(r);
|
|
const TDate data_scad(rata.get(SCAD_DATASCAD));
|
|
TEC_row& rec = new_row(row, data_scad, rata.importo(in_valuta), r);
|
|
if (data_scad <= form().data_limite_scaduto())
|
|
{
|
|
const real s = calcola_scaduto(rata, in_valuta);
|
|
rec.scaduto(s);
|
|
}
|
|
if (in_valuta)
|
|
{
|
|
TImporto il = rata.importo(false);
|
|
il.normalize(sezione);
|
|
rec.importo_euro(il.valore());
|
|
}
|
|
rec.rata_bloccata(rata.get_bool(SCAD_BLOCCATA));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
const TDate data_pag(row.get(PART_DATAPAG));
|
|
const TImporto imp(row.importo(in_valuta, 0x1)); // Importo pulito senza nient'altro
|
|
TEC_row& riga = new_row(row, data_pag, imp, RIGA_PAGAMENTO);
|
|
|
|
const int tipo_pag = row.get_int(PART_TIPOPAG);
|
|
const tipo_movimento tipo_mov = row.tipo();
|
|
|
|
// Controlla se e' un pagamento con effetti
|
|
if ((tipo_mov == tm_pagamento || tipo_mov == tm_pagamento_insoluto) &&
|
|
(tipo_pag >= 2 && tipo_pag <= 7))
|
|
{
|
|
const TDate& dls = form().data_limite_scaduto();
|
|
const TDate& dir = form().data_inizio_rischio();
|
|
|
|
bool sbf = false;
|
|
TImporto esposto(row.esposto(in_valuta, dls, dir, sbf));
|
|
bool esp = !esposto.is_zero();
|
|
|
|
if (esp)
|
|
{
|
|
const char sezione = row.get_char(PART_TIPOCF) == 'C' ? 'A' : 'D';
|
|
esposto.normalize(sezione);
|
|
riga.salvo_buon_fine(sbf); // Esposto salvo buon fine
|
|
riga.esposto(esposto.valore());
|
|
}
|
|
}
|
|
|
|
const TImporto abbuoni(row.importo(in_valuta, 0x2));
|
|
if (!abbuoni.is_zero())
|
|
{
|
|
TEC_row& rec = new_row(row, data_pag, abbuoni, RIGA_ABBUONI);
|
|
rec.descrizione(form().describe(PEC_ABBUONI));
|
|
if (in_valuta)
|
|
{
|
|
TImporto il(row.importo(false, 0x2));
|
|
il.normalize(sezione);
|
|
rec.importo_euro(il.valore());
|
|
}
|
|
}
|
|
|
|
TImporto diffcam(row.importo(false, 0x4));
|
|
if (!diffcam.is_zero() && !in_valuta)
|
|
{
|
|
TEC_row& rec = new_row(row, data_pag, TImporto('D', ZERO), RIGA_DIFFCAM);
|
|
rec.descrizione(form().describe(PEC_DIFFCAM));
|
|
rec.importo(diffcam);
|
|
}
|
|
|
|
TImporto ritenute(row.importo(false, 0x8));
|
|
if (!ritenute.is_zero())
|
|
{
|
|
TEC_row& rec = new_row(row, data_pag, TImporto('D', ZERO), RIGA_RITENUTE);
|
|
rec.descrizione(form().describe(PEC_RITENUTE));
|
|
if (in_valuta)
|
|
{
|
|
ritenute.normalize(sezione);
|
|
rec.importo_euro(ritenute.valore());
|
|
}
|
|
else
|
|
rec.importo(ritenute);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void TEC_array::arrange_scaduto(const TPartita& game)
|
|
|
|
{
|
|
const bool in_valuta = form().in_valuta() && row(0).in_valuta();
|
|
TImporto totpag(game.importo_pagato_unassigned(in_valuta));
|
|
const char sezione = game.conto().tipo() == 'C' ? 'A' : 'D';
|
|
|
|
totpag.normalize(sezione);
|
|
int r;
|
|
for (r = items()-1; r >= 0; r--)
|
|
{
|
|
TEC_row& s = row(r);
|
|
real imp(s.scaduto());
|
|
if (imp.sign() < 0)
|
|
{
|
|
totpag += TImporto(sezione, -imp);
|
|
s.scaduto(ZERO);
|
|
}
|
|
}
|
|
for (r = 0; r < items() && totpag.valore() > ZERO; r++)
|
|
{
|
|
TEC_row& s = row(r);
|
|
real imp = s.scaduto();
|
|
if (imp.sign() > 0)
|
|
{
|
|
if (imp >= totpag.valore())
|
|
{
|
|
imp -= totpag.valore();
|
|
s.scaduto(imp);
|
|
totpag = TImporto(sezione, ZERO);
|
|
}
|
|
else
|
|
{
|
|
s.scaduto(ZERO);
|
|
totpag -= TImporto(sezione, imp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
TEC_array::TEC_array(const TPartita& game, const TEC_form* f)
|
|
: _form(f)
|
|
{
|
|
int r;
|
|
for (r = game.last(); r > 0; r = game.pred(r))
|
|
add_row(game.riga(r));
|
|
if (items() > 0)
|
|
{
|
|
const char sezione = game.conto().tipo() == 'C' ? 'D' : 'A';
|
|
for (r = items()-1; r >= 0; r--)
|
|
{
|
|
TEC_row& s = row(r);
|
|
if (s.rata() == RIGA_PAGAMENTO)
|
|
{
|
|
TImporto* imp = importo_riga_scaduto_ptr(s.riga());
|
|
if (imp != NULL)
|
|
{
|
|
imp->normalize(sezione);
|
|
s.scaduto(imp->valore());
|
|
}
|
|
}
|
|
}
|
|
sort();
|
|
arrange_scaduto(game);
|
|
}
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Form speciale per estratti conto
|
|
///////////////////////////////////////////////////////////
|
|
|
|
void TEC_form::stampa_testata(TPrinter& pr)
|
|
{
|
|
TPrint_section& head = section('H');
|
|
|
|
TForm_item& pagina = head.find_field(PEC_PAGINA);
|
|
TString16 pg; pg << int(pr.getcurrentpage());
|
|
pagina.set(pg);
|
|
|
|
head.update();
|
|
|
|
int r = head.height()-1;
|
|
if (r > 0)
|
|
{
|
|
TPrintrow& head_row = head.row(r-1);
|
|
for (int j = 0; j <= r; j++)
|
|
pr.setheaderline(j, head.row(j));
|
|
}
|
|
}
|
|
|
|
// Confronta due totali in valuta alfabeticamente
|
|
static int tot_compare(const void* o1, const void* o2)
|
|
{
|
|
if (o1 == o2) // Sfrutto una piccola debolezza di qsort:
|
|
return 0; // ogni tanto confronta oggetti con se stessi
|
|
|
|
const THash_object* h1 = *((const THash_object**)o1);
|
|
const THash_object* h2 = *((const THash_object**)o2);
|
|
return xvt_str_compare_ignoring_case(h1->key(), h2->key());
|
|
}
|
|
|
|
word TEC_form::ordina_totali_per_valuta(THash_object* tot[MAXTOT])
|
|
{
|
|
// I totali sono in un assoc array disordinato per cui li copio in un
|
|
// array e li ordino alfabeticamente in base al loro codice valuta
|
|
TTotalizer& arr = totali();
|
|
arr.restart();
|
|
word num_rip = 0;
|
|
for (THash_object* obj = arr.get_hashobj();
|
|
num_rip < MAXTOT && obj != NULL;
|
|
obj = arr.get_hashobj())
|
|
tot[num_rip++] = obj;
|
|
qsort(tot, num_rip, sizeof(THash_object*), tot_compare);
|
|
return num_rip;
|
|
}
|
|
|
|
void TEC_form::stampa_riporti(TPrinter& pr)
|
|
{
|
|
THash_object* tot[MAXTOT];
|
|
_num_rip = ordina_totali_per_valuta(tot);
|
|
|
|
if (_num_rip > _maxtot)
|
|
_num_rip = _maxtot;
|
|
|
|
const TString& riporto = describe(PEC_RIPORTO);
|
|
TString desc(80);
|
|
TPrint_section& body = section('B');
|
|
for (word j = 0; j < _num_rip; j++)
|
|
{
|
|
const TString& key = tot[j]->key();
|
|
TTotal& t = (TTotal&)(tot[j]->obj());
|
|
|
|
desc = riporto;
|
|
TValuta val;
|
|
if (key.not_empty())
|
|
{
|
|
desc << ' ' << key;
|
|
TValuta val1(key,botime,ZERO); // E' una valuta fittizia, giusto per far
|
|
val = val1; // eseguire in set_imp() i calcoli per i decimali.
|
|
}
|
|
TEC_row rip(desc, t.importo().normalize(),val);
|
|
rip.scaduto(t.scaduto());
|
|
rip.esposto(t.esposto());
|
|
rip.importo_euro(t.importo_euro());
|
|
rip.print_on(body);
|
|
pr.setfooterline(j+1, body.row(0));
|
|
}
|
|
}
|
|
|
|
int TEC_form::find_magic(TString& s, TString& magic1, TString& magic2) const
|
|
{
|
|
const int pos = s.find('<', 0);
|
|
int end;
|
|
if (pos >= 0)
|
|
{
|
|
end = s.find('>', pos);
|
|
if (end > pos)
|
|
{
|
|
int p1 = pos+1;
|
|
magic1 = s.mid(p1, 2);
|
|
while (isalnum(s[p1])) p1++;
|
|
while (p1 < end && !isalnum(s[p1])) p1++;
|
|
if (p1 < end)
|
|
magic2 = s.mid(p1, 2);
|
|
else
|
|
magic2.cut(0);
|
|
}
|
|
else
|
|
end = s.len()-1;
|
|
|
|
const TString right(s.mid(end+1));
|
|
s.cut(pos); s << right;
|
|
}
|
|
return pos;
|
|
}
|
|
|
|
void TEC_form::change_magic_body(const TEC_row& row, TString& s)
|
|
{
|
|
TString magic1(4), magic2(4), val(50);
|
|
int pos;
|
|
while ((pos = find_magic(s, magic1, magic2)) >= 0)
|
|
{
|
|
val.cut(0);
|
|
if (magic1 == "PA" || magic2 == "PA")
|
|
{
|
|
val = row.descrizione();
|
|
if (val.empty())
|
|
val = cache().get(LF_CAUSALI, row.causale()).get(CAU_DESCR);
|
|
}
|
|
if (magic1 == "MO" || magic2 == "MO")
|
|
{
|
|
val = cache().get(LF_MOV, row.num_reg()).get(MOV_DESCR);
|
|
}
|
|
s.insert(val, pos);
|
|
}
|
|
}
|
|
|
|
void TEC_form::change_magic_footer(const THash_object& o, TString& s)
|
|
{
|
|
TString magic1(4), magic2(4), val(50);
|
|
int pos;
|
|
while ((pos = find_magic(s, magic1, magic2)) >= 0)
|
|
{
|
|
val.cut(0);
|
|
if (magic1 == "DA") // DATA
|
|
{
|
|
const TDate& d = magic2 == "SC" ? _dls : _dlo;
|
|
if (d != eotime)
|
|
val = d.string();
|
|
} else
|
|
if (magic1 == "VA") // CODICE VALUTA
|
|
val = o.key(); else
|
|
if (magic1 == "DE") // DESCRIZIONE VALUTA
|
|
{
|
|
val = magic2 == "VA" ? o.key() : TCurrency::get_firm_val();
|
|
if (val.not_empty())
|
|
val = cache().get("%VAL", val).get("S0");
|
|
}
|
|
s.insert(val, pos);
|
|
}
|
|
}
|
|
|
|
void TEC_form::print_total(int riga, const THash_object& o)
|
|
{
|
|
const short MAXID = 4;
|
|
const short f_id[MAXID] = { PEC_TSALDO, PEC_TSCADUTO, PEC_TESPOSTO, PEC_TIMPEURO };
|
|
TString_array prompt(MAXID);
|
|
|
|
TPrint_section& foot = section('F');
|
|
TPrint_section& body = section('B');
|
|
TForm_item& bdesc = body.find_field(PEC_DESCR);
|
|
|
|
// Sostituisce magic-names nei prompt
|
|
TString80 s;
|
|
for (int i = 0; i < MAXID; i++)
|
|
{
|
|
TForm_item& desc_field = foot.find_field(f_id[i]);
|
|
if (desc_field.shown())
|
|
{
|
|
s = desc_field.prompt();
|
|
prompt.add(s, i);
|
|
change_magic_footer(o, s);
|
|
desc_field.set_prompt(s);
|
|
if (desc_field.x() <= 0)
|
|
desc_field.set_x(bdesc.x());
|
|
}
|
|
}
|
|
|
|
const TTotal& t = (const TTotal&)o.obj();
|
|
TImporto imp = t.importo(); imp.normalize();
|
|
|
|
const bool in_valuta = o.key().not_empty();
|
|
TForm_item& dare = foot.find_field(PEC_DARE);
|
|
TForm_item& avere = foot.find_field(PEC_AVERE);
|
|
TForm_item& valuta = foot.find_field(PEC_VALUTA);
|
|
|
|
if (in_valuta)
|
|
valuta.set(o.key());
|
|
else
|
|
valuta.set("");
|
|
|
|
if (dare.x() <= 0 || avere.x() <= 0)
|
|
{
|
|
TForm_item& bdare = body.find_field(PEC_DARE);
|
|
dare.set_x(bdare.x());
|
|
dare.width() = bdare.width();
|
|
|
|
TForm_item& bavere = body.find_field(PEC_AVERE);
|
|
avere.set_x(bavere.x());
|
|
avere.width() = bavere.width();
|
|
}
|
|
|
|
if (imp.sezione() == 'D')
|
|
{
|
|
dare.set(imp.valore().string());
|
|
avere.set("");
|
|
}
|
|
else
|
|
{
|
|
dare.set("");
|
|
avere.set(imp.valore().string());
|
|
}
|
|
|
|
TForm_item& scaduto = foot.find_field(PEC_SCADUTO);
|
|
if (scaduto.x() <= 0)
|
|
{
|
|
TForm_item& bscaduto = body.find_field(PEC_SCADUTO);
|
|
scaduto.set_x(bscaduto.x());
|
|
scaduto.width() = bscaduto.width();
|
|
}
|
|
scaduto.set(t.scaduto().string());
|
|
|
|
TForm_item& esposto = foot.find_field(PEC_ESPOSTO);
|
|
if (esposto.x() <= 0)
|
|
{
|
|
TForm_item& besposto = body.find_field(PEC_ESPOSTO);
|
|
esposto.set_x(besposto.x());
|
|
esposto.width() = besposto.width();
|
|
}
|
|
esposto.set(t.esposto().string());
|
|
|
|
TForm_item& implire = foot.find_field(PEC_IMPEURO);
|
|
if (implire.x() <= 0)
|
|
{
|
|
TForm_item& bimplire = body.find_field(PEC_IMPEURO);
|
|
implire.set_x(bimplire.x());
|
|
esposto.width() = bimplire.width();
|
|
if (bimplire.shown())
|
|
implire.show();
|
|
else
|
|
implire.hide();
|
|
}
|
|
implire.set(t.importo_euro().string());
|
|
|
|
foot.update();
|
|
|
|
// Ripristina prompt originari
|
|
for (int i = 0; i < MAXID; i++)
|
|
{
|
|
const TString* p = (const TString*)prompt.objptr(i);
|
|
if (p)
|
|
{
|
|
TForm_item& desc_field = foot.find_field(f_id[i]);
|
|
desc_field.set_prompt(*p);
|
|
}
|
|
}
|
|
|
|
for (word r = 0; r < _total_rows; r++)
|
|
printer().setfooterline(riga + r, foot.row(r));
|
|
}
|
|
|
|
void TEC_form::stampa_pedata()
|
|
{
|
|
THash_object* tot[MAXTOT];
|
|
word num_rip = ordina_totali_per_valuta(tot);
|
|
|
|
if (num_rip > _maxtot)
|
|
num_rip = _maxtot;
|
|
|
|
for (word j = 0; j < num_rip; j++)
|
|
print_total(j*_total_rows+1, *tot[j]);
|
|
}
|
|
|
|
void TEC_form::export_total()
|
|
{
|
|
THash_object* tot[MAXTOT];
|
|
word num_rip = ordina_totali_per_valuta(tot);
|
|
for (word j = 0; j < num_rip; j++)
|
|
{
|
|
_recordset->new_rec();
|
|
|
|
const THash_object& o = *tot[j];
|
|
const TTotal& t = (const TTotal&)o.obj();
|
|
|
|
TString descr; descr << "*** " << TR("Totale") << ' ' << o.key();
|
|
_recordset->set("Descrizione", TVariant(descr));
|
|
_recordset->set(t.importo().sezione() == 'D' ? "Dare" : "Avere", t.importo().valore());
|
|
_recordset->set("Scaduto", t.scaduto());
|
|
_recordset->set("Esposto", t.esposto());
|
|
|
|
// _recordset->new_rec();
|
|
}
|
|
}
|
|
|
|
void TEC_form::ultima_pagina()
|
|
{
|
|
set_last_page(true);
|
|
}
|
|
|
|
void TEC_form::ec_header_handler(TPrinter& pr)
|
|
{
|
|
pr.resetheader();
|
|
_form->stampa_testata(pr);
|
|
}
|
|
|
|
void TEC_form::ec_footer_handler(TPrinter& pr)
|
|
{
|
|
pr.resetfooter();
|
|
if (_form->page(pr) > 0) // Normal page
|
|
_form->stampa_riporti(pr);
|
|
else // Last page
|
|
_form->stampa_pedata();
|
|
}
|
|
|
|
void TEC_form::azzera_totali()
|
|
{
|
|
totali().destroy(); // Azzera tutti i riporti
|
|
_num_rip = 0; // Azzera il numero di righe di riporto
|
|
set_last_page(false); // Azzera il flag di ultima pagina di stampa
|
|
|
|
if (printing())
|
|
{
|
|
TPrint_section& foot = section('F');
|
|
printer().footerlen(foot.height());
|
|
printer().setcurrentpage(1);
|
|
}
|
|
}
|
|
|
|
bool TEC_form::print_game(const TPartita& game)
|
|
{
|
|
bool ok = false;
|
|
|
|
TEC_array righe(game, this);
|
|
|
|
|
|
TPrint_section& body = section('B');
|
|
|
|
TImporto saldo;
|
|
real scaduto, esposto, implire;
|
|
|
|
// Stampa le righe di partita
|
|
|
|
int ultima_riga = 0;
|
|
int ultima_rata = 0;
|
|
|
|
int r;
|
|
for (r = 0; r < righe.items(); r++)
|
|
{
|
|
if (printing())
|
|
{
|
|
TPrinter& pr = printer();
|
|
if (pr.rows_left() <= (body.height()+1)) // salto pagina
|
|
{
|
|
pr.formfeed();
|
|
for (word nr = 0; nr < _num_rip; nr++)
|
|
{
|
|
TPrintrow* fl = pr.getfooterline(nr + 1);
|
|
CHECKD(fl, "Manca la riga di riporto ", nr + 1);
|
|
pr.print(*fl);
|
|
}
|
|
}
|
|
}
|
|
|
|
TEC_row& riga = righe.row(r);
|
|
const int ri = riga.riga();
|
|
const int ra = riga.rata();
|
|
if (ri == ultima_riga && ra == ultima_rata+1)
|
|
riga.reset_uguali();
|
|
ultima_riga = ri;
|
|
ultima_rata = ra;
|
|
|
|
if (printing())
|
|
{
|
|
riga.print_on(body);
|
|
printer().print(body.row(0));
|
|
}
|
|
else
|
|
riga.export_to(*_recordset);
|
|
|
|
TString4 codval;
|
|
if (in_valuta())
|
|
codval = riga.valuta().codice();
|
|
|
|
totali().add(riga.importo(), riga.scaduto(), riga.esposto(),
|
|
riga.importo_euro(), codval);
|
|
|
|
saldo += riga.importo();
|
|
scaduto += riga.scaduto();
|
|
esposto += riga.esposto();
|
|
implire += riga.importo_euro();
|
|
ok = true;
|
|
}
|
|
|
|
if (ok && stampa_saldo())
|
|
{
|
|
saldo.normalize();
|
|
|
|
const TString & dessaldo = describe(PEC_SALDO);
|
|
TString80 desc = dessaldo;
|
|
const TValuta& val = righe.row(r-1).valuta();
|
|
|
|
if (in_valuta() && val.in_valuta()) // Aggiunge alla descrizione il codice valuta se necessario
|
|
desc << ' ' << val.codice();
|
|
|
|
TEC_row sld(desc, saldo, val);
|
|
|
|
sld.scaduto(scaduto);
|
|
sld.esposto(esposto);
|
|
sld.importo_euro(implire);
|
|
|
|
if (printing())
|
|
{
|
|
sld.print_on(body);
|
|
printer().print(body.row(0));
|
|
}
|
|
else
|
|
sld.export_to(*_recordset);
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
const TString& TEC_form::describe(short id, char sez, pagetype pt) const
|
|
{
|
|
const TForm_item& fi = find_field(sez, pt, id);
|
|
return fi.prompt();
|
|
}
|
|
|
|
void TEC_form::init_header(const TMask& m)
|
|
{
|
|
TPrint_section& head = section('H');
|
|
|
|
TForm_item& luogo_invio = head.find_field(PEC_LUOGOIN);
|
|
luogo_invio.set(m.get(F_LUOGOSEND));
|
|
|
|
TForm_item& data_invio = head.find_field(PEC_DATAIN);
|
|
data_invio.set(m.get(F_DATASEND));
|
|
|
|
TForm_item& fi = head.find_field(PEC_MEMO);
|
|
if (fi.shown())
|
|
{
|
|
TString key;
|
|
|
|
key.format("%s|%s|H0|%d", (const char *) name(), (const char *) code(), PEC_MEMO);
|
|
|
|
const TRectype & rform = cache().get(LF_RFORM, key);
|
|
if (!rform.empty())
|
|
fi.set(rform.get("TESTO"));
|
|
}
|
|
|
|
TPrint_section& fink = section('G');
|
|
if (fink.fields() > 0)
|
|
fink.update(); // Setta il backgroud di stampa
|
|
}
|
|
|
|
void TEC_form::set_agente(const TString& codag)
|
|
{
|
|
const bool good = codag.full();
|
|
|
|
TPrint_section& head = section('H');
|
|
TForm_item& agente = head.find_field(PEC_AGENTE);
|
|
agente.show(good);
|
|
|
|
if (good)
|
|
{
|
|
TString ag;
|
|
ag << codag << ' ';
|
|
ag << cache().get(LF_AGENTI, codag, AGE_RAGSOC);
|
|
|
|
if (printing())
|
|
{
|
|
agente.set(ag);
|
|
}
|
|
else
|
|
{
|
|
_recordset->new_rec();
|
|
_recordset->set("Descrizione", TVariant(ag));
|
|
_recordset->new_rec();
|
|
}
|
|
}
|
|
}
|
|
|
|
TEC_form::TEC_form(const TEC_mask& m, bool gesval, bool excel)
|
|
: TForm(BASE_EC_PROFILE, m.get_prof_name()), _recordset(NULL),
|
|
_in_valuta(false), _stampa_saldo(true), _num_rip(0), _total_rows(0)
|
|
{
|
|
_form = this;
|
|
|
|
TCursor_sheet& cs = m.cur_sheet();
|
|
_cursore = cs.cursor();
|
|
|
|
_lingua = m.get_prof_lang(); // Lingua profilo
|
|
_dlo = m.get(F_DATALIMOP);
|
|
if (!_dlo.ok())
|
|
_dlo = eotime;
|
|
_dls = m.get(F_DATALIMSC);
|
|
_giorni_rischio = m.get_int(F_GIORISCH);
|
|
_dir = _dls; _dir -= _giorni_rischio;
|
|
|
|
TForm_item& flags = find_field('H', last_page, PEC_FLAGS);
|
|
|
|
TToken_string f(flags.prompt());
|
|
_in_valuta = gesval && f.get_char(0) == 'X'; // Il profilo e' in valuta se c'e' il flag di valuta
|
|
_fincatura = f.get_int(1);
|
|
|
|
if (!excel)
|
|
{
|
|
TPrinter& pr = printer();
|
|
|
|
pr.setheaderhandler(ec_header_handler);
|
|
TPrint_section& head = section('H');
|
|
pr.headerlen(head.height());
|
|
|
|
pr.setfooterhandler(ec_footer_handler);
|
|
const TPrint_section& foot = section('F');
|
|
pr.footerlen(foot.height());
|
|
|
|
if (_fincatura > 0)
|
|
{
|
|
const int first = head.height()-2;
|
|
const int last = pr.formlen();
|
|
const int horiz[] = { first+2, last-foot.height()+1, 0 };
|
|
set_fink_mode(_fincatura == 1 ? false : true);
|
|
genera_fincatura(odd_page, first, last, horiz);
|
|
}
|
|
|
|
TForm_item& uns = section('F').find_field(PEC_UNASSIGNED);
|
|
TForm_item& tuns = section('F').find_field(PEC_TUNASSIGNED);
|
|
if (uns.shown()) uns.hide();
|
|
if (tuns.shown()) tuns.hide();
|
|
|
|
genera_intestazioni(odd_page, head.height() - 1);
|
|
init_header(m); // Set fixed text
|
|
|
|
_total_rows = 1;
|
|
for (word fi = 0; fi < foot.fields(); fi++)
|
|
{
|
|
const TForm_item& item = foot.field(fi);
|
|
if (item.shown())
|
|
{
|
|
const word y = (word)item.y();
|
|
if (y > _total_rows)
|
|
_total_rows = y;
|
|
}
|
|
}
|
|
|
|
_maxtot = f.get_int(3);
|
|
|
|
// La prima e l'ultima riga del footer devono essere lasciate libere per la fincatura
|
|
// Ogni totale occupa _total_rows righe: per cui posso calcolare il massimo di totali
|
|
// che posso stampare nel footer.
|
|
const word max = (foot.height() - 2) / _total_rows;
|
|
if (_maxtot <= 0 || _maxtot > max)
|
|
_maxtot = max;
|
|
}
|
|
else
|
|
_recordset = new TEC_recordset;
|
|
}
|
|
|
|
TEC_form::~TEC_form()
|
|
{
|
|
if (printing())
|
|
{
|
|
TPrinter& pr = printer();
|
|
pr.setheaderhandler(NULL);
|
|
pr.setfooterhandler(NULL);
|
|
}
|
|
else
|
|
{
|
|
delete _recordset;
|
|
}
|
|
_form = NULL;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TEC_gamelist
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TEC_Game_list
|
|
{
|
|
TAssoc_array _games;
|
|
|
|
protected:
|
|
void signature(const TRectype& rec, TToken_string& signature) const;
|
|
|
|
public:
|
|
void add_game(const TRectype& rec);
|
|
bool has_clifo(long codcf);
|
|
bool has_game(const TRectype& rec);
|
|
};
|
|
|
|
void TEC_Game_list::signature(const TRectype& rec, TToken_string& signature) const
|
|
{
|
|
signature = rec.get(SCAD_TIPOCF);
|
|
signature.add(rec.get(SCAD_SOTTOCONTO));
|
|
signature.add(rec.get(SCAD_ANNO));
|
|
signature.add(rec.get(SCAD_NUMPART));
|
|
signature.strip_spaces();
|
|
}
|
|
|
|
void TEC_Game_list::add_game(const TRectype& rec)
|
|
{
|
|
TToken_string signat; signature(rec, signat);
|
|
_games.add(signat);
|
|
}
|
|
|
|
bool TEC_Game_list::has_clifo(long codcf)
|
|
{
|
|
TToken_string signat;
|
|
FOR_EACH_ASSOC_OBJECT(_games, obj, key, str)
|
|
{
|
|
signat = key;
|
|
if (signat.get_long(1) == codcf)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool TEC_Game_list::has_game(const TRectype& rec)
|
|
{
|
|
TToken_string signat; signature(rec, signat);
|
|
return _games.is_key(signat);
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Stampa estratti conto
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TStampaEC_application : public TSkeleton_application
|
|
{
|
|
TEC_mask* _msk;
|
|
TEC_form* _form;
|
|
|
|
TString _lingua_ditta;
|
|
bool _gesval; // Gestione valuta
|
|
char _tiponumec; // Tipo numerazione EC ' ', 'G', 'A'
|
|
long _lastnumec; // Ultimo numero EC 'G'
|
|
TAssoc_array _lastnumcf; // Ultimo numero stampato 'A'
|
|
|
|
protected: // TSkeleton_application
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
virtual void main_loop();
|
|
virtual void on_firm_change();
|
|
virtual void on_config_change();
|
|
virtual const char * extra_modules() const {return "sc";}
|
|
|
|
void find_agents_scads(TAssoc_array& agents);
|
|
void find_agents_unassigned_pags(TAssoc_array& agents);
|
|
|
|
public:
|
|
static TStampaEC_application& app() { return (TStampaEC_application&)main_app(); }
|
|
long find_agents_games(TAssoc_array& agents);
|
|
|
|
TEC_mask& mask() { return *_msk; }
|
|
TCursor_sheet& sheet() { return _msk->cur_sheet(); }
|
|
TEC_form& form() { return *_form; }
|
|
void update_numec(const TRectype& clf, int sign);
|
|
void save_numec();
|
|
|
|
bool print_selected(); // print selected items
|
|
bool print_agents(); // print selected items by agent
|
|
int print_ec(TEC_Game_list* games = NULL); // print one ec only
|
|
|
|
TStampaEC_application();
|
|
virtual ~TStampaEC_application() {}
|
|
};
|
|
|
|
bool TStampaEC_application::print_selected()
|
|
{
|
|
TCursor_sheet& s = sheet();
|
|
TCursor& c = *s.cursor();
|
|
|
|
const char who = mask().get_who();
|
|
const int key = mask().get_key();
|
|
|
|
// Filtra il cursore del form in modo che diventi uguale al cursor_sheet corrente
|
|
// Qui sarebbe bello copiarsi l'indice dell'altro cursore
|
|
TCursor& fc = *form().cursor();
|
|
fc.setkey(key);
|
|
TRectype filter(LF_CLIFO);
|
|
filter.put(CLI_TIPOCF, who);
|
|
fc.setregion(filter, filter);
|
|
|
|
form().set_agente(EMPTY_STRING); // Nascondi agente
|
|
|
|
const long print_all = !s.one_checked(); // Se non ho selezionato nulla allora li stampo tutti
|
|
long analfabeti = 0; // Persone non stampate in quanto aventi lingua errata
|
|
const bool printing = form().printing();
|
|
const long items = c.items();
|
|
|
|
TProgind* pi = NULL;
|
|
if (printing)
|
|
printer().open();
|
|
else
|
|
pi = new TProgind(items, TR("Calcolo estratto conto"), true, true);
|
|
|
|
for (long i = 0; i < items; i++)
|
|
{
|
|
if (print_all || s.checked(i))
|
|
{
|
|
fc = i; // Muove il cursore alla posizione corrente
|
|
const int ret = print_ec();
|
|
if (ret < 0)
|
|
analfabeti++;
|
|
}
|
|
|
|
if (printing)
|
|
{
|
|
if (printer().frozen())
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
if (!pi->addstatus(1))
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (printing)
|
|
{
|
|
printer().close();
|
|
if (_tiponumec > ' ' && who == 'C')
|
|
save_numec();
|
|
|
|
if (analfabeti > 0)
|
|
{
|
|
const char* anag = who == 'C' ? TR("clienti") : TR("fornitori");
|
|
warning_box(FR("%ld %s non sono stati stampati in quanto "
|
|
"il codice lingua non corrispondeva al profilo di stampa"),
|
|
analfabeti, anag);
|
|
}
|
|
}
|
|
else
|
|
delete pi;
|
|
|
|
return true;
|
|
}
|
|
|
|
void TStampaEC_application::find_agents_scads(TAssoc_array& agents)
|
|
{
|
|
const TString& fromage = mask().get(F_FROM_AGENT);
|
|
const TString& toage = mask().get(F_TO_AGENT);
|
|
const long fromcli = mask().get_long(SC_CFCODFR);
|
|
const long tocli = mask().get_long(SC_CFCODTO);
|
|
|
|
TRelation rel(LF_SCADENZE);
|
|
rel.add(LF_PAGSCA, "TIPOC==TIPOC|GRUPPO==GRUPPO|CONTO==CONTO|SOTTOCONTO==SOTTOCONTO|"
|
|
"ANNO==ANNO|NUMPART==NUMPART|NRIGA==NRIGA|NRATA==NRATA");
|
|
|
|
TRectype& curr = rel.curr();
|
|
const TRectype& pagsca = rel.curr(LF_PAGSCA);
|
|
|
|
curr.put(SCAD_TIPOCF, mask().get(SC_CLIFO));
|
|
TRectype recfr(curr), recto(curr);
|
|
if (fromcli > 0)
|
|
recfr.put(PAGSCA_SOTTOCONTO, fromcli);
|
|
if (tocli >= fromcli)
|
|
recto.put(PAGSCA_SOTTOCONTO, tocli);
|
|
|
|
TString filter;
|
|
if (!mask().get_bool(F_STAMPCHIU))
|
|
filter << "PAGATA!=\"X\"";
|
|
TCursor cur(&rel, filter, 1, &recfr, &recto);
|
|
const long items = cur.items();
|
|
cur.freeze();
|
|
|
|
TProgind pi(items, TR("Ricerca scadenze aperte per agente..."), true, true);
|
|
for (cur = 0L; cur.pos() < items; ++cur)
|
|
{
|
|
if (!pi.addstatus(1))
|
|
break;
|
|
|
|
const char* codag = pagsca.get(PAGSCA_CODAG);
|
|
if (*codag == '\0')
|
|
{
|
|
codag = curr.get(SCAD_CODAG);
|
|
if (*codag == '\0')
|
|
continue;
|
|
}
|
|
if (fromage.not_empty() && fromage > codag)
|
|
continue;
|
|
if (toage.not_empty() && toage < codag)
|
|
continue;
|
|
|
|
TEC_Game_list* games = (TEC_Game_list*)agents.objptr(codag);
|
|
if (games == NULL)
|
|
{
|
|
games = new TEC_Game_list;
|
|
agents.add(codag, (TObject*)games);
|
|
}
|
|
games->add_game(curr);
|
|
}
|
|
}
|
|
|
|
void TStampaEC_application::find_agents_unassigned_pags(TAssoc_array& agents)
|
|
{
|
|
const TString& fromage = mask().get(F_FROM_AGENT);
|
|
const TString& toage = mask().get(F_TO_AGENT);
|
|
const long fromcli = mask().get_long(SC_CFCODFR);
|
|
const long tocli = mask().get_long(SC_CFCODTO);
|
|
|
|
TRelation rel(LF_PAGSCA);
|
|
TRectype& curr = rel.curr();
|
|
curr.put(PAGSCA_TIPOC, mask().get(SC_CLIFO)); // Imposta C o F
|
|
|
|
TRectype recfr(curr), recto(curr);
|
|
if (fromcli > 0)
|
|
recfr.put(PAGSCA_SOTTOCONTO, fromcli); // Imposta cliente iniziale
|
|
if (tocli >= fromcli)
|
|
recto.put(PAGSCA_SOTTOCONTO, tocli); // Imposta cliente finale
|
|
|
|
TString filter;
|
|
filter << '(' << PAGSCA_NRATA <<"==9999)";
|
|
if (fromage.full())
|
|
filter << "&&(" << PAGSCA_CODAG << ">='" << fromage << "')";
|
|
else
|
|
filter << "&&(" << PAGSCA_CODAG << "!='')";
|
|
if (toage.full())
|
|
filter << "&&(" << PAGSCA_CODAG << "<='" << toage << "')";
|
|
|
|
TCursor cur(&rel, filter, 1, &recfr, &recto);
|
|
const long items = cur.items();
|
|
if (items > 0)
|
|
{
|
|
cur.freeze();
|
|
TProgind pi(items, TR("Ricerca pagamenti non assegnati per agente..."), true, true);
|
|
for (cur = 0L; cur.pos() < items; ++cur)
|
|
{
|
|
if (!pi.addstatus(1))
|
|
break;
|
|
const char* codag = curr.get(PAGSCA_CODAG);
|
|
TEC_Game_list* games = (TEC_Game_list*)agents.objptr(codag);
|
|
if (games == NULL)
|
|
{
|
|
games = new TEC_Game_list;
|
|
agents.add(codag, (TObject*)games);
|
|
}
|
|
games->add_game(curr);
|
|
}
|
|
}
|
|
}
|
|
|
|
long TStampaEC_application::find_agents_games(TAssoc_array& agents)
|
|
{
|
|
find_agents_scads(agents);
|
|
find_agents_unassigned_pags(agents);
|
|
return agents.items();
|
|
}
|
|
|
|
bool TStampaEC_application::print_agents()
|
|
{
|
|
TCursor_sheet& s = sheet();
|
|
TCursor& c = *s.cursor();
|
|
|
|
const char who = mask().get_who();
|
|
const int key = mask().get_key();
|
|
|
|
// Filtra il cursore del form in modo che diventi uguale al cursor_sheet corrente
|
|
// Qui sarebbe bello copiarsi l'indice dell'altro cursore
|
|
TCursor& fc = *form().cursor();
|
|
fc.setkey(key);
|
|
TRectype filter(LF_CLIFO);
|
|
filter.put(CLI_TIPOCF, who);
|
|
fc.setregion(filter, filter);
|
|
|
|
const bool printing = form().printing();
|
|
const long print_all = !s.one_checked(); // Se non ho selezionato nulla allora li stampo tutti
|
|
long analfabeti = 0; // Persone non stampate in quanto aventi lingua errata
|
|
|
|
TAssoc_array agents;
|
|
const long totag = find_agents_games(agents);
|
|
if (totag <= 0)
|
|
return false;
|
|
|
|
TRelation rel(LF_AGENTI);
|
|
TCursor cur(&rel);
|
|
const long items = cur.items();
|
|
cur.freeze();
|
|
|
|
TProgind* pi = NULL;
|
|
if (printing)
|
|
printer().open();
|
|
else
|
|
pi = new TProgind(items, "Calcolo estratto conto", true, true);
|
|
|
|
for (cur = 0L; cur.pos() < items; ++cur)
|
|
{
|
|
const TString& codag = cur.curr().get(AGE_CODAGE);
|
|
TEC_Game_list* games = (TEC_Game_list*)agents.objptr(codag);
|
|
if (games != NULL)
|
|
{
|
|
form().set_agente(codag);
|
|
const long items = c.items();
|
|
for (long i = 0; i < items; i++)
|
|
{
|
|
if (print_all || s.checked(i))
|
|
{
|
|
fc = i; // Muove il cursore alla posizione corrente
|
|
const long codcf = fc.curr().get_long(CLI_CODCF);
|
|
if (games->has_clifo(codcf))
|
|
{
|
|
const int ret = print_ec(games);
|
|
if (ret < 0)
|
|
analfabeti++;
|
|
}
|
|
}
|
|
if (printing)
|
|
{
|
|
if (printer().frozen())
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
if (!pi->addstatus(1))
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (printing)
|
|
{
|
|
printer().close();
|
|
if (_tiponumec > ' ' && who == 'C')
|
|
save_numec();
|
|
|
|
if (analfabeti > 0)
|
|
{
|
|
const char* anag = who == 'C' ? TR("clienti") : TR("fornitori");
|
|
warning_box(FR("%ld %s non sono stati stampati in quanto "
|
|
"il codice lingua non corrispondeva al profilo di stampa"),
|
|
analfabeti, anag);
|
|
}
|
|
}
|
|
else
|
|
delete pi;
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
void TStampaEC_application::save_numec()
|
|
{
|
|
// Ho numerato qualche estratto conto?
|
|
if (_lastnumcf.items() > 0 && form().printing())
|
|
{
|
|
if (yesno_box(TR("Si desidera aggiornare il numero di estratto conto stampato definitivamente?")))
|
|
{
|
|
TProgind pi(_lastnumcf.items(), TR("Aggiornamento numero estratto conto..."), false, true);
|
|
const char tipocf = mask().get_who(); // Dovrebbe essere sempre 'C'
|
|
TLocalisamfile cfven(LF_CFVEN);
|
|
FOR_EACH_ASSOC_STRING(_lastnumcf, obj, key, str)
|
|
{
|
|
pi.addstatus(1);
|
|
cfven.put(CFV_TIPOCF, tipocf);
|
|
cfven.put(CFV_CODCF, key);
|
|
const int err = cfven.read();
|
|
if (err != NOERR)
|
|
{
|
|
cfven.zero();
|
|
cfven.put(CFV_TIPOCF, tipocf);
|
|
cfven.put(CFV_CODCF, key);
|
|
}
|
|
cfven.put("NUMESC", str);
|
|
cfven.put("DATAESC", mask().get(F_DATASEND));
|
|
if (err == NOERR)
|
|
cfven.rewrite();
|
|
else
|
|
cfven.write();
|
|
}
|
|
if (_tiponumec == 'G')
|
|
{
|
|
TConfig c(CONFIG_DITTA, "cg");
|
|
c.set("LastEC", _lastnumec);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Ripristino vecchio numero di estratto conto sulla maschera
|
|
if (_tiponumec == 'G')
|
|
{
|
|
TConfig c(CONFIG_DITTA, "cg");
|
|
_lastnumec = c.get_long("LastEC");
|
|
}
|
|
}
|
|
_lastnumcf.destroy(); // Azzera comunque elenco EC stampati
|
|
}
|
|
}
|
|
|
|
void TStampaEC_application::update_numec(const TRectype& clf, int sign)
|
|
{
|
|
const char tipocf = clf.get_char(CLI_TIPOCF);
|
|
if (_tiponumec > ' ' && tipocf == 'C' && form().printing())
|
|
{
|
|
TForm_item& nec = form().find_field('H', odd_page, PEC_NUMPROG);
|
|
if (nec.shown())
|
|
{
|
|
const TString8 codcf = clf.get(CLI_CODCF);
|
|
TString16 num;
|
|
switch(_tiponumec)
|
|
{
|
|
case 'A':
|
|
if (sign > 0)
|
|
{
|
|
TString16 key;
|
|
key.format("%c|%s", tipocf, (const char*)codcf);
|
|
const TRectype& cfven = cache().get(LF_CFVEN, key);
|
|
num << (cfven.get_long("NUMESC")+1);
|
|
}
|
|
break;
|
|
case 'G':
|
|
if (sign > 0)
|
|
{
|
|
_lastnumec++;
|
|
num << _lastnumec;
|
|
}
|
|
else
|
|
_lastnumec--;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
if (num.full())
|
|
{
|
|
nec.set(num);
|
|
_lastnumcf.add(codcf, num);
|
|
}
|
|
else
|
|
_lastnumcf.remove(codcf);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Nuovo modo con cursore
|
|
int TStampaEC_application::print_ec(TEC_Game_list* games)
|
|
{
|
|
TWait_cursor hourglass;
|
|
|
|
TEC_form& f = form();
|
|
const bool printing = f.printing();
|
|
|
|
const TRectype& clf = f.cursor()->curr();
|
|
|
|
if (printing)
|
|
{
|
|
// make controllations per lingua profilo/CF
|
|
const TString& lincf = clf.get(CLI_CODLIN);
|
|
bool ok = true;
|
|
if ((f.lingua() == _lingua_ditta && lincf.full()) ||
|
|
f.lingua() != _lingua_ditta)
|
|
ok = lincf == f.lingua();
|
|
if (!ok) // Cliente analfabeta
|
|
return -1;
|
|
}
|
|
|
|
f.azzera_totali(); // Azzera totali di fine pagina
|
|
|
|
// Filtra solo le partite del cliente selezionato
|
|
TRelation rel(LF_PARTITE);
|
|
TRectype& curr = rel.curr();
|
|
curr.put(PART_TIPOCF, clf.get(CLI_TIPOCF));
|
|
curr.put(PART_SOTTOCONTO, clf.get(CLI_CODCF));
|
|
TCursor cur(&rel, "", 1, &curr, &curr);
|
|
|
|
const long items = cur.items();
|
|
cur.freeze();
|
|
|
|
const bool stampa_chiuse = mask().get_bool(F_STAMPCHIU);
|
|
const TDate data_chiuse = mask().get(F_DATACHIU);
|
|
|
|
TString status;
|
|
|
|
int printed = 0; // Non ho stampato ancora nulla
|
|
|
|
if (printing)
|
|
update_numec(clf, +1); // Incrementa contatore
|
|
|
|
TString8 last_game;
|
|
int last_year = 0;
|
|
|
|
for (cur = 0; cur.pos() < items; ++cur)
|
|
{
|
|
const int curr_year = curr.get_int(PART_ANNO);
|
|
const TString& curr_game = curr.get(PART_NUMPART);
|
|
if (curr_year == last_year && curr_game == last_game)
|
|
continue;
|
|
last_game = curr_game;
|
|
last_year = curr_year;
|
|
|
|
// Non fregare i clienti agli altri agenti!
|
|
if (games != NULL && !games->has_game(curr))
|
|
continue;
|
|
|
|
TPartita game(curr);
|
|
|
|
status.cut(0);
|
|
status << game.anno() << ' ' << game.numero();
|
|
xvtil_statbar_set(status);
|
|
|
|
const TDate& dir = f.data_inizio_rischio();
|
|
const TDate& dlo = f.data_limite_operazione();
|
|
const TDate& dls = f.data_limite_scaduto();
|
|
const TImporto saldo = game.calcola_saldo_al(f.in_valuta(), dlo, dls, dir);
|
|
if (saldo.is_zero())
|
|
{
|
|
int r = 0;
|
|
if (stampa_chiuse)
|
|
{
|
|
for (r = game.last(); r > 0 ; r = game.pred(r))
|
|
{
|
|
const TRiga_partite& riga = game.riga(r);
|
|
if (riga.is_fattura())
|
|
{
|
|
const TDate dd = riga.get(PART_DATADOC);
|
|
if (dd >= data_chiuse)
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (r == 0)
|
|
continue;
|
|
}
|
|
|
|
if (printing)
|
|
{
|
|
if (printed)
|
|
{
|
|
TPrintrow empty; // Salta una riga vuota
|
|
printer().print(empty); // (Non farlo alla fine di ogni partita!)
|
|
}
|
|
if (printer().frozen())
|
|
break;
|
|
}
|
|
|
|
if (f.print_game(game))
|
|
printed++;
|
|
}
|
|
|
|
if (printing)
|
|
{
|
|
if (printed > 0)
|
|
{
|
|
f.ultima_pagina();
|
|
printer().formfeed();
|
|
}
|
|
else
|
|
update_numec(clf, -1);
|
|
}
|
|
else
|
|
{
|
|
if (printed > 0 && f.stampa_saldo())
|
|
{
|
|
f.export_total();
|
|
// f.recordset().new_rec();
|
|
}
|
|
}
|
|
|
|
xvtil_statbar_set(NULL);
|
|
|
|
return printed;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Generic TApplication methods
|
|
///////////////////////////////////////////////////////////
|
|
|
|
bool TStampaEC_application::create()
|
|
{
|
|
open_files(LF_TABCOM, LF_TAB, LF_CAUSALI, LF_MOV, LF_RMOV, 0);
|
|
open_files(LF_NDITTE, LF_ANAG, LF_COMUNI, LF_RFORM, 0);
|
|
open_files(LF_CLIFO, LF_PARTITE, LF_SCADENZE, LF_PAGSCA ,0);
|
|
_msk = new TEC_mask("ps0925100a");
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
bool TStampaEC_application::destroy()
|
|
{
|
|
delete _msk;
|
|
return TSkeleton_application::destroy();
|
|
}
|
|
|
|
void TStampaEC_application::on_firm_change()
|
|
{
|
|
mask().reset();
|
|
TApplication::on_firm_change();
|
|
}
|
|
|
|
void TStampaEC_application::on_config_change()
|
|
{
|
|
TConfig c(CONFIG_DITTA, "cg");
|
|
_lingua_ditta = c.get("CodLin");
|
|
_gesval = c.get_bool("GesVal");
|
|
_tiponumec = c.get_char("NumEC");
|
|
_lastnumec = c.get_long("LastEC");
|
|
}
|
|
|
|
void TStampaEC_application::main_loop()
|
|
{
|
|
TEC_mask& m = mask();
|
|
m.set(F_STAMPSALDO, "X");
|
|
|
|
while (true)
|
|
{
|
|
m.show(F_ULTIMOEC, _tiponumec == 'G');
|
|
m.set(F_ULTIMOEC, _lastnumec);
|
|
const KEY k = m.run();
|
|
if (k == K_QUIT)
|
|
break;
|
|
|
|
const bool excel = k != K_ENTER;
|
|
|
|
_form = new TEC_form(m, _gesval, excel);
|
|
|
|
_form->stampa_saldo(m.get_bool(F_STAMPSALDO));
|
|
|
|
if (!excel)
|
|
{
|
|
TForm_item& nec = _form->find_field('H', odd_page, PEC_NUMPROG);
|
|
if (nec.enabled() && nec.shown())
|
|
{
|
|
nec.show(_tiponumec > ' ' && m.get_who() == 'C');
|
|
_lastnumec = m.get_long(F_ULTIMOEC);
|
|
}
|
|
}
|
|
long ditta = prefix().get_codditta();
|
|
const long from_ditta = m.get_long(F_CODDITTA);
|
|
const long to_ditta = m.get_long(F_CODDITTATO);
|
|
|
|
for (int d = from_ditta; d <= to_ditta; d++)
|
|
{
|
|
if (prefix().exist(d))
|
|
{
|
|
prefix().set_codditta(d);
|
|
if (m.get_bool(F_GROUPAGENT))
|
|
print_agents();
|
|
else
|
|
print_selected();
|
|
}
|
|
}
|
|
prefix().set_codditta(ditta);
|
|
|
|
if (excel)
|
|
{
|
|
TFilename slk; slk.tempdir(); slk.add("ec.xls");
|
|
_form->recordset().save_as(slk, fmt_html);
|
|
xvt_sys_goto_url(slk, "open");
|
|
}
|
|
|
|
delete _form;
|
|
_form = NULL;
|
|
|
|
}
|
|
}
|
|
|
|
TStampaEC_application::TStampaEC_application()
|
|
: _lingua_ditta(1), _msk(NULL), _form(NULL)
|
|
{}
|
|
|
|
int ps0925100(int argc, char** argv)
|
|
{
|
|
TStampaEC_application app;
|
|
app.run(argc, argv, TR("Stampa Estratti Conto"));
|
|
return 0;
|
|
}
|
|
|