1995-11-06 11:10:50 +00:00
|
|
|
#include <applicat.h>
|
1995-11-14 10:28:43 +00:00
|
|
|
#include <config.h>
|
1995-11-06 11:10:50 +00:00
|
|
|
#include <form.h>
|
1995-11-27 08:39:47 +00:00
|
|
|
#include <printer.h>
|
1995-12-01 11:49:57 +00:00
|
|
|
#include <tabutil.h>
|
1995-11-06 11:10:50 +00:00
|
|
|
#include <urldefid.h>
|
|
|
|
|
1995-11-27 17:10:46 +00:00
|
|
|
#include "../cg/saldacon.h"
|
1995-11-27 08:39:47 +00:00
|
|
|
#include "sc2.h"
|
|
|
|
#include "sc2101.h"
|
1995-12-05 17:17:41 +00:00
|
|
|
#include "sc2102.h"
|
1995-11-06 11:10:50 +00:00
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
#include "sc2100a.h"
|
1995-12-04 11:06:42 +00:00
|
|
|
#include "sc21pec.h"
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-11-14 10:28:43 +00:00
|
|
|
#include <clifo.h>
|
1995-12-01 11:49:57 +00:00
|
|
|
#include <causali.h>
|
1995-12-19 15:56:21 +00:00
|
|
|
#include <mov.h>
|
1995-12-04 11:06:42 +00:00
|
|
|
#include <pagsca.h>
|
1995-12-01 11:49:57 +00:00
|
|
|
#include <scadenze.h>
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TEC_form
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TEC_form : public TForm
|
|
|
|
{
|
1995-12-19 15:56:21 +00:00
|
|
|
friend class TEC_row;
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
static TEC_form* _form;
|
1995-12-13 15:14:22 +00:00
|
|
|
|
|
|
|
enum { MAXTOT = 16 };
|
1995-12-01 11:49:57 +00:00
|
|
|
|
|
|
|
TCursor* _cursore;
|
|
|
|
TTotalizer _totali;
|
1995-12-14 13:17:51 +00:00
|
|
|
TDecoder _causali; // Decodificatore dei codici causale
|
|
|
|
TDecoder _valute; // Decodificatore dei codici valuta
|
1995-12-19 15:56:21 +00:00
|
|
|
TDecoder _movimenti; // Decodificatore delle descrizioni dei movimenti
|
1995-12-04 11:06:42 +00:00
|
|
|
|
1995-12-11 17:38:54 +00:00
|
|
|
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
|
1995-12-15 17:12:03 +00:00
|
|
|
int _fincatura; // 0 = nessuna, 1 = testo, 2 = grafica
|
1995-12-12 13:37:30 +00:00
|
|
|
word _num_rip; // Numero di righe usate per i riporti
|
1995-12-14 13:17:51 +00:00
|
|
|
word _total_rows; // Numero di righe usate per i totali
|
1995-12-01 11:49:57 +00:00
|
|
|
|
|
|
|
protected:
|
1995-12-15 17:12:03 +00:00
|
|
|
void init_header(const TMask& m);
|
1995-12-13 15:14:22 +00:00
|
|
|
word ordina_totali_per_valuta(THash_object* tot[MAXTOT]);
|
1995-12-19 15:56:21 +00:00
|
|
|
|
|
|
|
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);
|
1995-12-15 17:12:03 +00:00
|
|
|
void print_total(int riga, const THash_object& o);
|
1995-12-13 15:14:22 +00:00
|
|
|
|
1995-12-12 13:37:30 +00:00
|
|
|
void stampa_testata(TPrinter& p);
|
1995-12-13 15:14:22 +00:00
|
|
|
void stampa_pedata(TPrinter& p);
|
1995-12-12 13:37:30 +00:00
|
|
|
void stampa_riporti(TPrinter& p);
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
static void ec_header_handler(TPrinter& p);
|
|
|
|
static void ec_footer_handler(TPrinter& p);
|
1995-12-04 11:06:42 +00:00
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
public:
|
1995-12-19 15:56:21 +00:00
|
|
|
TTotalizer& totali() { return _totali; }
|
|
|
|
TDecoder& causali() { return _causali; }
|
|
|
|
TDecoder& valute() { return _valute; }
|
|
|
|
TDecoder& movimenti() { return _movimenti; }
|
1995-12-04 11:06:42 +00:00
|
|
|
|
|
|
|
const TDate& data_limite_operazione() const { return _dlo; }
|
1995-12-19 15:56:21 +00:00
|
|
|
const TDate& data_limite_scaduto() const { return _dls; }
|
|
|
|
int giorni_rischio() const { return _giorni_rischio; }
|
|
|
|
const TDate& data_inizio_rischio() const { return _dir; }
|
1995-12-11 11:22:47 +00:00
|
|
|
|
1995-12-04 11:06:42 +00:00
|
|
|
const TString& lingua() const { return _lingua; }
|
1995-12-11 11:22:47 +00:00
|
|
|
bool in_valuta() const { return _in_valuta; }
|
1995-12-19 15:56:21 +00:00
|
|
|
const TString& describe(short id, char sez = 'H', pagetype pt = last_page) const;
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-12 13:37:30 +00:00
|
|
|
void azzera_totali();
|
1995-12-13 15:14:22 +00:00
|
|
|
void ultima_pagina();
|
1995-12-01 11:49:57 +00:00
|
|
|
bool print_game(const TPartita& game);
|
|
|
|
|
1995-12-12 13:37:30 +00:00
|
|
|
TEC_form(const TEC_mask& m, bool gesval);
|
1995-12-01 11:49:57 +00:00
|
|
|
virtual ~TEC_form();
|
|
|
|
};
|
|
|
|
|
|
|
|
TEC_form* TEC_form::_form = NULL;
|
|
|
|
|
1995-11-14 10:28:43 +00:00
|
|
|
|
1995-11-27 13:51:46 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TEC_row
|
1995-12-07 17:05:07 +00:00
|
|
|
// Rappresenta una singola riga di stampa
|
1995-11-27 13:51:46 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TEC_row : public TSortable
|
1995-12-01 11:49:57 +00:00
|
|
|
{
|
1995-12-07 17:05:07 +00:00
|
|
|
TDate _data; // Data scadenza o pagamento
|
|
|
|
int _riga; // Riga della fattura
|
|
|
|
int _rata; // Numero rata o progrssivo
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-07 17:05:07 +00:00
|
|
|
TString _causale; // Codice causale
|
|
|
|
TString _descrizione; // Sua descrizione
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-07 17:05:07 +00:00
|
|
|
TDate _data_doc; // Data del documento
|
|
|
|
TString _num_doc; // Numero documento
|
|
|
|
long _num_prot; // Protocollo IVA
|
1995-12-19 15:56:21 +00:00
|
|
|
long _num_reg; // Numero registrazione
|
1995-12-07 17:05:07 +00:00
|
|
|
TImporto _importo; // Importo in valuta
|
1995-12-12 13:37:30 +00:00
|
|
|
real _importo_lire; // Importo in lire
|
1995-12-07 17:05:07 +00:00
|
|
|
real _scaduto; // Importo scaduto
|
1995-12-11 11:22:47 +00:00
|
|
|
real _esposto; // Importo esposto
|
|
|
|
bool _salvo_buon_fine; // Importo esposto salvo buon fine
|
1995-12-07 17:05:07 +00:00
|
|
|
real _totale; // Totale documento
|
|
|
|
TValuta _valuta; // Codice valuta, data cambio e cambio
|
1995-11-27 13:51:46 +00:00
|
|
|
|
|
|
|
protected: // TSortable
|
|
|
|
virtual int compare(const TSortable& s) const;
|
1995-12-11 17:38:54 +00:00
|
|
|
void set_imp(TForm_item& fi, const real& imp, bool valuta) const;
|
1995-12-19 15:56:21 +00:00
|
|
|
|
|
|
|
TEC_form& form() const;
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
public:
|
1995-12-07 17:05:07 +00:00
|
|
|
int riga() const { return _riga; }
|
|
|
|
int rata() const { return _rata; }
|
1995-12-11 17:38:54 +00:00
|
|
|
|
1995-12-15 17:12:03 +00:00
|
|
|
void reset_uguali();
|
1995-12-01 11:49:57 +00:00
|
|
|
void descrizione(const char* s) { _descrizione = s; }
|
1995-12-11 11:22:47 +00:00
|
|
|
void importo(const TImporto& i) { _importo = i; }
|
1995-12-12 13:37:30 +00:00
|
|
|
void importo_lire(const real& i) { _importo_lire = i; }
|
1995-12-04 11:06:42 +00:00
|
|
|
void scaduto(const real& s) { _scaduto = s; }
|
1995-12-11 11:22:47 +00:00
|
|
|
void esposto(const real& e) { _esposto = e; }
|
|
|
|
void salvo_buon_fine(bool sbf) { _salvo_buon_fine = sbf; }
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-19 15:56:21 +00:00
|
|
|
const TString& causale() const { return _causale; }
|
|
|
|
const TString& descrizione() const { return _descrizione; }
|
|
|
|
long num_reg() const { return _num_reg; }
|
1995-12-04 11:06:42 +00:00
|
|
|
const TDate& data() const { return _data; }
|
1995-12-12 13:37:30 +00:00
|
|
|
const TImporto& importo() const { return _importo; }
|
|
|
|
const real& importo_lire() const { return _importo_lire; }
|
1995-12-11 11:22:47 +00:00
|
|
|
real scaduto() const { return _scaduto; }
|
|
|
|
real esposto() const { return _esposto; }
|
|
|
|
const TValuta& valuta() const { return _valuta; }
|
1995-12-11 17:38:54 +00:00
|
|
|
bool in_valuta() const { return _valuta.in_valuta(); }
|
1995-12-01 11:49:57 +00:00
|
|
|
|
|
|
|
void print_on(TPrint_section& body);
|
|
|
|
|
1995-12-04 11:06:42 +00:00
|
|
|
TEC_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata);
|
1995-12-01 11:49:57 +00:00
|
|
|
TEC_row(const char* desc, const TImporto& imp);
|
1995-11-27 13:51:46 +00:00
|
|
|
virtual ~TEC_row() {}
|
|
|
|
};
|
|
|
|
|
1995-12-04 11:06:42 +00:00
|
|
|
TEC_row::TEC_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata)
|
1995-12-19 15:56:21 +00:00
|
|
|
: _num_prot(0), _num_reg(0), _salvo_buon_fine(FALSE)
|
1995-12-04 11:06:42 +00:00
|
|
|
{
|
1995-12-19 15:56:21 +00:00
|
|
|
_riga = row.get_int(PART_NRIGA);
|
|
|
|
_rata = rata;
|
|
|
|
_data = data;
|
|
|
|
_causale = row.get(PART_CODCAUS);
|
|
|
|
_data_doc = row.get(PART_DATADOC);
|
|
|
|
_num_prot = row.get_long(PART_PROTIVA);
|
|
|
|
_num_reg = row.get_long(PART_NREG);
|
|
|
|
_importo = imp; _importo.normalize();
|
|
|
|
_totale = row.get_real(PART_IMPTOTDOC);
|
|
|
|
_descrizione = row.get(PART_DESCR);
|
1995-12-04 11:06:42 +00:00
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
_valuta.get(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEC_row::TEC_row(const char* desc, const TImporto& imp)
|
1995-12-19 15:56:21 +00:00
|
|
|
: _riga(9999), _rata(9999), _num_prot(0), _num_reg(0), _salvo_buon_fine(FALSE)
|
1995-12-01 11:49:57 +00:00
|
|
|
{
|
|
|
|
_descrizione = desc;
|
1995-12-04 11:06:42 +00:00
|
|
|
_importo = imp; _importo.normalize();
|
1995-12-01 11:49:57 +00:00
|
|
|
}
|
|
|
|
|
1995-12-07 17:05:07 +00:00
|
|
|
// Le righe dell'estratto conto sono ordinate per data, riga partita, numero rata o
|
1995-12-04 11:06:42 +00:00
|
|
|
// posizione iniziale nell'array (in caso di uguaglianza di tutto il resto)
|
1995-12-01 11:49:57 +00:00
|
|
|
int TEC_row::compare(const TSortable& s) const
|
1995-11-27 13:51:46 +00:00
|
|
|
{
|
1995-12-01 11:49:57 +00:00
|
|
|
const TEC_row& r = (const TEC_row&)s;
|
|
|
|
int c = 0;
|
|
|
|
if (_data == r._data)
|
1995-12-04 11:06:42 +00:00
|
|
|
{
|
1995-12-11 11:22:47 +00:00
|
|
|
c = _riga - r._riga;
|
1995-12-04 11:06:42 +00:00
|
|
|
if (c == 0)
|
1995-12-11 11:22:47 +00:00
|
|
|
c = _rata - r._rata;
|
1995-12-04 11:06:42 +00:00
|
|
|
}
|
1995-12-01 11:49:57 +00:00
|
|
|
else
|
1995-12-11 11:22:47 +00:00
|
|
|
c = _data > r._data ? +1 : -1;
|
1995-12-01 11:49:57 +00:00
|
|
|
return c;
|
1995-12-15 17:12:03 +00:00
|
|
|
}
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-15 17:12:03 +00:00
|
|
|
// Annulla i campi uguali alla riga precedente
|
|
|
|
void TEC_row::reset_uguali()
|
|
|
|
{
|
|
|
|
_num_doc = "";
|
|
|
|
_data_doc = botime;
|
|
|
|
_num_prot = 0;
|
|
|
|
_totale = ZERO;
|
|
|
|
}
|
1995-12-11 17:38:54 +00:00
|
|
|
|
|
|
|
void TEC_row::set_imp(TForm_item& fi, const real& imp, bool valuta) const
|
|
|
|
{
|
1995-12-15 17:12:03 +00:00
|
|
|
TString old_picture(20);
|
1995-12-11 17:38:54 +00:00
|
|
|
if (valuta)
|
|
|
|
{
|
|
|
|
old_picture = fi.picture();
|
|
|
|
TString new_picture(20);
|
1995-12-15 17:12:03 +00:00
|
|
|
|
|
|
|
if (old_picture.empty())
|
|
|
|
{
|
|
|
|
new_picture = valuta ? ".3" : ".";
|
|
|
|
}
|
1995-12-11 17:38:54 +00:00
|
|
|
else
|
1995-12-15 17:12:03 +00:00
|
|
|
{
|
|
|
|
new_picture = old_picture;
|
|
|
|
if (old_picture.find(',') > 0)
|
|
|
|
new_picture << ".###";
|
|
|
|
else
|
|
|
|
new_picture << ",###";
|
|
|
|
}
|
1995-12-11 17:38:54 +00:00
|
|
|
fi.set_picture(new_picture);
|
|
|
|
}
|
|
|
|
|
|
|
|
fi.set(imp.string());
|
|
|
|
|
|
|
|
if (valuta)
|
|
|
|
{
|
|
|
|
fi.set_picture(old_picture);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-12-19 15:56:21 +00:00
|
|
|
TEC_form& TEC_row::form() const
|
|
|
|
{
|
|
|
|
TEC_form* f = TEC_form::_form;
|
|
|
|
CHECK(f, "NULL form");
|
|
|
|
return *f;
|
|
|
|
}
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
void TEC_row::print_on(TPrint_section& body)
|
|
|
|
{
|
|
|
|
TEC_form& form = (TEC_form&)body.form();
|
1995-12-11 17:38:54 +00:00
|
|
|
const bool valuta = form.in_valuta() && in_valuta();
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-04 11:06:42 +00:00
|
|
|
TForm_item& causale = body.find_field(PEC_CODCAUS);
|
|
|
|
causale.set(_causale);
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-04 11:06:42 +00:00
|
|
|
TForm_item& descr = body.find_field(PEC_DESCR1);
|
1995-12-19 15:56:21 +00:00
|
|
|
|
|
|
|
if (num_reg() > 0) // Riga di partita vera e propria (non totale parziale)
|
|
|
|
{
|
|
|
|
TString s(80); s = descr.prompt();
|
|
|
|
TEC_form::_form->change_magic_body(*this, s);
|
|
|
|
descr.set(s);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
descr.set(_descrizione);
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-04 11:06:42 +00:00
|
|
|
TForm_item& datadoc = body.find_field(PEC_DATADOC);
|
|
|
|
datadoc.set(_data_doc.string());
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-04 11:06:42 +00:00
|
|
|
TForm_item& numdoc = body.find_field(PEC_NUMDOC);
|
|
|
|
numdoc.set(_num_doc);
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-04 11:06:42 +00:00
|
|
|
TForm_item& numprot = body.find_field(PEC_PROTIVA);
|
|
|
|
TString16 protiva; protiva << _num_prot;
|
|
|
|
numprot.set(protiva);
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-04 11:06:42 +00:00
|
|
|
TForm_item& datapag = body.find_field(PEC_DATAPAG);
|
|
|
|
datapag.set(_data.string());
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-19 15:56:21 +00:00
|
|
|
const real& imp = _importo.valore();
|
1995-12-04 11:06:42 +00:00
|
|
|
TForm_item& dare = body.find_field(PEC_DARE);
|
|
|
|
TForm_item& avere = body.find_field(PEC_AVERE);
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-04 11:06:42 +00:00
|
|
|
if (_importo.sezione() == 'D')
|
|
|
|
{
|
1995-12-11 17:38:54 +00:00
|
|
|
set_imp(dare, imp, valuta);
|
1995-12-04 11:06:42 +00:00
|
|
|
avere.set("");
|
1995-12-01 11:49:57 +00:00
|
|
|
}
|
1995-12-04 11:06:42 +00:00
|
|
|
else
|
1995-11-27 13:51:46 +00:00
|
|
|
{
|
1995-12-11 17:38:54 +00:00
|
|
|
set_imp(avere, imp, valuta);
|
1995-12-04 11:06:42 +00:00
|
|
|
dare.set("");
|
|
|
|
}
|
|
|
|
|
|
|
|
TForm_item& scaduto = body.find_field(PEC_SCADUTO);
|
1995-12-11 17:38:54 +00:00
|
|
|
set_imp(scaduto, _scaduto, valuta);
|
1995-12-04 11:06:42 +00:00
|
|
|
|
1995-12-11 11:22:47 +00:00
|
|
|
TForm_item& esposto = body.find_field(PEC_ESPOSTO);
|
1995-12-11 17:38:54 +00:00
|
|
|
set_imp(esposto, _esposto, valuta);
|
1995-12-11 11:22:47 +00:00
|
|
|
|
1995-12-12 13:37:30 +00:00
|
|
|
TForm_item& lire = body.find_field(PEC_IMPLIRE);
|
|
|
|
lire.set(_importo_lire.string());
|
|
|
|
|
1995-12-11 11:22:47 +00:00
|
|
|
TForm_item& sbf = body.find_field(PEC_SBF);
|
|
|
|
sbf.set(_salvo_buon_fine ? "*" : " ");
|
|
|
|
|
1995-12-04 11:06:42 +00:00
|
|
|
TForm_item& cambio = body.find_field(PEC_CAMBIO);
|
|
|
|
cambio.set(_valuta.cambio().string());
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-04 11:06:42 +00:00
|
|
|
TForm_item& datacambio = body.find_field(PEC_DATACAM);
|
|
|
|
datacambio.set(_valuta.data().string());
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-19 15:56:21 +00:00
|
|
|
const TString old_prompt(descr.prompt());
|
|
|
|
descr.set_prompt(""); // Nasconde temporaneamente il prompt per non stampare i <magic>
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
body.update();
|
1995-12-19 15:56:21 +00:00
|
|
|
|
|
|
|
descr.set_prompt(old_prompt); // Ripristina il vecchio prompt
|
1995-11-27 13:51:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
1995-12-01 11:49:57 +00:00
|
|
|
// TEC_array
|
1995-11-27 13:51:46 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
class TEC_array : public TArray
|
1995-12-07 17:05:07 +00:00
|
|
|
{
|
|
|
|
TArray _scaduto; // Array di importi scaduti
|
|
|
|
|
|
|
|
const TEC_form* _form; // Form che contiene l'array di righe
|
1995-12-01 11:49:57 +00:00
|
|
|
|
|
|
|
protected:
|
1995-12-04 11:06:42 +00:00
|
|
|
TEC_row& new_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata = 0);
|
1995-12-01 11:49:57 +00:00
|
|
|
void add_row(const TRiga_partite& row);
|
1995-12-04 11:06:42 +00:00
|
|
|
|
|
|
|
const TEC_form& form() const { return *_form; }
|
1995-12-07 17:05:07 +00:00
|
|
|
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;
|
1995-12-01 11:49:57 +00:00
|
|
|
|
|
|
|
public:
|
1995-12-04 11:06:42 +00:00
|
|
|
TEC_row& row(int r) const { return (TEC_row&)operator[](r); }
|
1995-11-27 13:51:46 +00:00
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
TEC_array(const TPartita& game, const TEC_form* f);
|
|
|
|
virtual ~TEC_array() {}
|
1995-11-27 13:51:46 +00:00
|
|
|
};
|
|
|
|
|
1995-12-07 17:05:07 +00:00
|
|
|
// 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);
|
1995-12-15 17:12:03 +00:00
|
|
|
const TRiga_partite& fat = game.riga(nriga); // Riga di fattura
|
1995-12-07 17:05:07 +00:00
|
|
|
const bool fat_val = fat.in_valuta();
|
|
|
|
|
|
|
|
const int nrigp = pag.get_int(PAGSCA_NRIGP);
|
1995-12-15 17:12:03 +00:00
|
|
|
const TRiga_partite& sum = game.riga(nrigp); // Riga di pagamento
|
1995-12-07 17:05:07 +00:00
|
|
|
const char sez = sum.sezione();
|
|
|
|
|
|
|
|
const char* const field = valuta && fat_val ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO;
|
1995-12-15 17:12:03 +00:00
|
|
|
TImporto imp(sez, pag.get_real(field)); // Importo base
|
1995-12-07 17:05:07 +00:00
|
|
|
|
|
|
|
if (!fat_val)
|
1995-12-15 17:12:03 +00:00
|
|
|
imp.valore() += pag.get_real(PAGSCA_RITENUTE); // Sommo le ritenute se sono il lire
|
1995-12-07 17:05:07 +00:00
|
|
|
|
1995-12-15 17:12:03 +00:00
|
|
|
if (pag.get_char(PAGSCA_ACCSAL) == 'S') // Se il pagamento ha abbuoni o differenze cambio
|
1995-12-07 17:05:07 +00:00
|
|
|
{
|
|
|
|
real abb(pag.get(PAGSCA_ABBUONI));
|
1995-12-15 17:12:03 +00:00
|
|
|
if (!valuta && fat_val) // Se voglio gli abbuoni in lire ma la fattura non lo e'
|
1995-12-07 17:05:07 +00:00
|
|
|
{
|
1995-12-15 17:12:03 +00:00
|
|
|
const TValuta val(sum); // Leggo il cambio dalla riga di partita
|
|
|
|
val.val2lit(abb); // Converto in lire gli abbuoni
|
|
|
|
abb += pag.get_real(PAGSCA_DIFFCAM); // Sommo l'eventuale differenza cambio (gia' in lire)
|
1995-12-07 17:05:07 +00:00
|
|
|
}
|
1995-12-15 17:12:03 +00:00
|
|
|
imp.valore() += abb; // Sommo il tutto all'importo base (sez e' uguale per tutti i valori)
|
1995-12-07 17:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return imp;
|
|
|
|
}
|
|
|
|
|
1995-12-11 11:22:47 +00:00
|
|
|
// Certified 100%
|
1995-12-07 17:05:07 +00:00
|
|
|
TImporto& TEC_array::importo_riga_scaduto(int n)
|
1995-12-11 11:22:47 +00:00
|
|
|
{
|
|
|
|
CHECKD(n > 0 && n < 9999, "Riga scaduto errata ", n);
|
1995-12-07 17:05:07 +00:00
|
|
|
TImporto* imp = importo_riga_scaduto_ptr(n);
|
|
|
|
if (imp == NULL)
|
|
|
|
{
|
|
|
|
imp = new TImporto;
|
1995-12-11 11:22:47 +00:00
|
|
|
_scaduto.add(imp, n);
|
1995-12-07 17:05:07 +00:00
|
|
|
}
|
|
|
|
return *imp;
|
|
|
|
}
|
|
|
|
|
|
|
|
real TEC_array::calcola_scaduto(const TRiga_scadenze& rata, bool valuta)
|
1995-12-04 11:06:42 +00:00
|
|
|
{
|
|
|
|
const TPartita& game = rata.partita();
|
1995-12-11 17:38:54 +00:00
|
|
|
const char sezione = game.conto().tipo() == 'C' ? 'D' : 'A';
|
|
|
|
|
1995-12-07 17:05:07 +00:00
|
|
|
TImporto scaduto_rata = rata.importo(TRUE);
|
1995-12-04 11:06:42 +00:00
|
|
|
|
1995-12-07 17:05:07 +00:00
|
|
|
int riga_corrente_scaduto = 0;
|
1995-12-04 11:06:42 +00:00
|
|
|
|
1995-12-07 17:05:07 +00:00
|
|
|
const int lastp = rata.last(); // Ultimo pagamento sulla rata corrente
|
|
|
|
for (int p = rata.first(); p <= lastp; p = rata.succ(p)) // Qui bisogna andare in avanti!
|
1995-12-04 11:06:42 +00:00
|
|
|
{
|
|
|
|
const TRectype& pag = rata.row(p);
|
1995-12-11 11:22:47 +00:00
|
|
|
const int nrigp = pag.get_int(PAGSCA_NRIGP);
|
|
|
|
const TRiga_partite& sum = game.riga(nrigp);
|
1995-12-11 17:38:54 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1995-12-11 11:22:47 +00:00
|
|
|
if (tm == tm_insoluto || tm == tm_pagamento_insoluto)
|
1995-12-07 17:05:07 +00:00
|
|
|
{
|
|
|
|
if (tm == tm_insoluto)
|
1995-12-11 11:22:47 +00:00
|
|
|
riga_corrente_scaduto = nrigp;
|
1995-12-07 17:05:07 +00:00
|
|
|
else
|
|
|
|
CHECKD(riga_corrente_scaduto > 0, "Pagamento insoluto senza insoluto ", p);
|
|
|
|
importo_riga_scaduto(riga_corrente_scaduto) += imp;
|
|
|
|
}
|
|
|
|
else
|
1995-12-04 11:06:42 +00:00
|
|
|
{
|
1995-12-07 17:05:07 +00:00
|
|
|
scaduto_rata += imp;
|
1995-12-04 11:06:42 +00:00
|
|
|
}
|
|
|
|
}
|
1995-12-07 17:05:07 +00:00
|
|
|
|
|
|
|
scaduto_rata.normalize(sezione);
|
|
|
|
return scaduto_rata.valore();
|
1995-12-04 11:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEC_row& TEC_array::new_row(const TRiga_partite& row, const TDate& data,
|
|
|
|
const TImporto& imp, int n)
|
|
|
|
{
|
1995-12-11 11:22:47 +00:00
|
|
|
CHECKD(n > 0, "Numero rata errato: ", n);
|
1995-12-01 11:49:57 +00:00
|
|
|
TEC_row* riga = new TEC_row(row, data, imp, n);
|
1995-12-11 11:22:47 +00:00
|
|
|
add(riga);
|
1995-12-01 11:49:57 +00:00
|
|
|
return *riga;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TEC_array::add_row(const TRiga_partite& row)
|
1995-11-27 13:51:46 +00:00
|
|
|
{
|
1995-12-11 17:38:54 +00:00
|
|
|
const bool in_valuta = form().in_valuta() && row.in_valuta();
|
1995-12-12 13:37:30 +00:00
|
|
|
const char sezione = row.get_char(PART_TIPOCF) == 'C' ? 'D' : 'A';
|
1995-12-11 11:22:47 +00:00
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
if (row.is_fattura())
|
1995-11-27 13:51:46 +00:00
|
|
|
{
|
1995-12-01 11:49:57 +00:00
|
|
|
for (int r = 1; r <= row.rate(); r++)
|
|
|
|
{
|
|
|
|
const TRiga_scadenze& rata = row.rata(r);
|
|
|
|
const TDate data(rata.get(SCAD_DATASCAD));
|
1995-12-04 11:06:42 +00:00
|
|
|
if (data <= form().data_limite_operazione())
|
|
|
|
{
|
1995-12-11 11:22:47 +00:00
|
|
|
TEC_row& rec = new_row(row, data, rata.importo(in_valuta), r);
|
1995-12-04 11:06:42 +00:00
|
|
|
if (data <= form().data_limite_scaduto())
|
|
|
|
{
|
1995-12-11 11:22:47 +00:00
|
|
|
const real s = calcola_scaduto(rata, in_valuta);
|
1995-12-04 11:06:42 +00:00
|
|
|
rec.scaduto(s);
|
|
|
|
}
|
1995-12-12 13:37:30 +00:00
|
|
|
if (in_valuta)
|
|
|
|
{
|
|
|
|
TImporto il = rata.importo(FALSE);
|
|
|
|
il.normalize(sezione);
|
|
|
|
rec.importo_lire(il.valore());
|
|
|
|
}
|
1995-12-04 11:06:42 +00:00
|
|
|
}
|
1995-12-01 11:49:57 +00:00
|
|
|
}
|
1995-11-27 13:51:46 +00:00
|
|
|
}
|
|
|
|
else
|
1995-12-01 11:49:57 +00:00
|
|
|
{
|
|
|
|
const TDate data(row.get(PART_DATAPAG));
|
1995-12-04 11:06:42 +00:00
|
|
|
if (data <= form().data_limite_operazione())
|
|
|
|
{
|
1995-12-12 13:37:30 +00:00
|
|
|
const TImporto imp(row.importo(in_valuta, 0x1)); // Importo pulito senza nient'altro
|
1995-12-11 11:22:47 +00:00
|
|
|
TEC_row& riga = new_row(row, data, imp, 1);
|
|
|
|
|
|
|
|
const int tipo_pag = row.get_int(PART_TIPOPAG);
|
|
|
|
if (tipo_pag >= 2 && tipo_pag <= 7) // Controlla se e' un pagamento con effetti
|
|
|
|
{
|
|
|
|
const TDate data_pag(row.get(PART_DATAPAG));
|
|
|
|
const TDate& dls = form().data_limite_scaduto();
|
|
|
|
const int gr = form().giorni_rischio();
|
|
|
|
|
|
|
|
bool sbf = FALSE;
|
|
|
|
if (gr > 0)
|
|
|
|
{
|
|
|
|
const TDate& dir = form().data_inizio_rischio();
|
1995-12-11 17:38:54 +00:00
|
|
|
sbf = data_pag > dir && data_pag <= dls;
|
1995-12-11 11:22:47 +00:00
|
|
|
riga.salvo_buon_fine(sbf); // Esposto salvo buon fine
|
|
|
|
}
|
|
|
|
|
|
|
|
bool esp = sbf;
|
|
|
|
if (!esp)
|
|
|
|
{
|
|
|
|
esp = gr > 0 ? data_pag >= dls : data_pag > dls; // Esposto normale
|
|
|
|
}
|
|
|
|
|
|
|
|
if (esp)
|
|
|
|
{
|
|
|
|
TImporto esposto(imp);
|
|
|
|
const char sezione = row.get_char(PART_TIPOCF) == 'C' ? 'D' : 'A';
|
|
|
|
esposto.normalize(sezione);
|
|
|
|
riga.esposto(esposto.valore());
|
|
|
|
}
|
|
|
|
}
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-11 11:22:47 +00:00
|
|
|
const TImporto abbuoni(row.importo(in_valuta, 0x2));
|
1995-12-04 11:06:42 +00:00
|
|
|
if (!abbuoni.is_zero())
|
|
|
|
{
|
1995-12-12 13:37:30 +00:00
|
|
|
TEC_row& rec = new_row(row, data, abbuoni, 2);
|
1995-12-14 13:17:51 +00:00
|
|
|
rec.descrizione(form().describe(PEC_ABBUONI));
|
1995-12-12 13:37:30 +00:00
|
|
|
if (in_valuta)
|
|
|
|
{
|
|
|
|
TImporto il(row.importo(FALSE, 0x2));
|
|
|
|
il.normalize(sezione);
|
|
|
|
rec.importo_lire(il.valore());
|
|
|
|
}
|
1995-12-04 11:06:42 +00:00
|
|
|
}
|
1995-12-11 11:22:47 +00:00
|
|
|
|
1995-12-15 17:12:03 +00:00
|
|
|
TImporto diffcam(row.importo(FALSE, 0x4));
|
1995-12-04 11:06:42 +00:00
|
|
|
if (!diffcam.is_zero())
|
|
|
|
{
|
1995-12-15 17:12:03 +00:00
|
|
|
TEC_row& rec = new_row(row, data, TImporto('D', ZERO), 3);
|
1995-12-14 13:17:51 +00:00
|
|
|
rec.descrizione(form().describe(PEC_DIFFCAM));
|
1995-12-12 13:37:30 +00:00
|
|
|
if (in_valuta)
|
|
|
|
{
|
1995-12-15 17:12:03 +00:00
|
|
|
diffcam.normalize(sezione);
|
|
|
|
rec.importo_lire(diffcam.valore());
|
1995-12-12 13:37:30 +00:00
|
|
|
}
|
1995-12-15 17:12:03 +00:00
|
|
|
else
|
|
|
|
rec.importo(diffcam);
|
1995-12-12 13:37:30 +00:00
|
|
|
}
|
|
|
|
|
1995-12-15 17:12:03 +00:00
|
|
|
TImporto ritenute(row.importo(FALSE, 0x8));
|
1995-12-12 13:37:30 +00:00
|
|
|
if (!ritenute.is_zero())
|
|
|
|
{
|
1995-12-15 17:12:03 +00:00
|
|
|
TEC_row& rec = new_row(row, data, TImporto('D', ZERO), 4);
|
|
|
|
rec.descrizione(form().describe(PEC_RITENUTE));
|
|
|
|
if (in_valuta)
|
|
|
|
{
|
|
|
|
ritenute.normalize(sezione);
|
|
|
|
rec.importo_lire(ritenute.valore());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rec.importo(ritenute);
|
1995-12-04 11:06:42 +00:00
|
|
|
}
|
1995-12-01 11:49:57 +00:00
|
|
|
}
|
1995-11-27 13:51:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
TEC_array::TEC_array(const TPartita& game, const TEC_form* f)
|
|
|
|
: _form(f)
|
|
|
|
{
|
|
|
|
for (int r = game.last(); r > 0; r = game.pred(r))
|
|
|
|
add_row(game.riga(r));
|
1995-12-07 17:05:07 +00:00
|
|
|
|
|
|
|
const char sezione = game.conto().tipo() == 'C' ? 'D' : 'A';
|
|
|
|
for (r = items()-1; r >= 0; r--)
|
|
|
|
{
|
|
|
|
TEC_row& s = row(r);
|
1995-12-11 11:22:47 +00:00
|
|
|
if (s.rata() == 1)
|
1995-12-07 17:05:07 +00:00
|
|
|
{
|
1995-12-11 11:22:47 +00:00
|
|
|
TImporto* imp = importo_riga_scaduto_ptr(s.riga());
|
|
|
|
if (imp != NULL)
|
|
|
|
{
|
|
|
|
imp->normalize(sezione);
|
|
|
|
s.scaduto(imp->valore());
|
|
|
|
}
|
1995-12-07 17:05:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
sort();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Form speciale per estratti conto
|
|
|
|
///////////////////////////////////////////////////////////
|
1995-11-06 11:10:50 +00:00
|
|
|
|
1995-12-12 13:37:30 +00:00
|
|
|
void TEC_form::stampa_testata(TPrinter& pr)
|
1995-11-06 11:10:50 +00:00
|
|
|
{
|
1995-12-12 13:37:30 +00:00
|
|
|
TPrint_section& head = section('H');
|
|
|
|
|
|
|
|
TForm_item& pagina = head.find_field(PEC_PAGINA);
|
|
|
|
TString16 pg; pg << int(pr.getcurrentpage());
|
|
|
|
pagina.set(pg);
|
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
head.update();
|
1995-12-12 13:37:30 +00:00
|
|
|
|
|
|
|
const word r = head.height()-1;
|
|
|
|
TPrintrow& head_row = head.row(r-1);
|
|
|
|
|
|
|
|
TPrint_section& body = section('B');
|
|
|
|
for (int f = body.fields()-1; f >= 0; f--)
|
|
|
|
{
|
|
|
|
// Leggi lo special e stampalo
|
|
|
|
TForm_item& fi = body.field(f);
|
1995-12-13 15:14:22 +00:00
|
|
|
if (fi.shown())
|
|
|
|
{
|
|
|
|
const int x = offset_x() + fi.x() - 1; // Le TPrintrow partono da 0, bestia!
|
|
|
|
head_row.put(fi.key(), x);
|
|
|
|
}
|
1995-12-12 13:37:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (word j = 0; j <= r; j++)
|
1995-11-27 08:39:47 +00:00
|
|
|
pr.setheaderline(j, head.row(j));
|
1995-11-06 11:10:50 +00:00
|
|
|
}
|
|
|
|
|
1995-12-11 11:22:47 +00:00
|
|
|
// 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
|
|
|
|
|
1995-12-15 17:12:03 +00:00
|
|
|
const THash_object* h1 = *((const THash_object**)o1);
|
|
|
|
const THash_object* h2 = *((const THash_object**)o2);
|
1995-12-11 11:22:47 +00:00
|
|
|
return stricmp(h1->key(), h2->key());
|
1995-12-04 11:06:42 +00:00
|
|
|
}
|
1995-11-06 11:10:50 +00:00
|
|
|
|
1995-12-13 15:14:22 +00:00
|
|
|
word TEC_form::ordina_totali_per_valuta(THash_object* tot[MAXTOT])
|
1995-11-06 11:10:50 +00:00
|
|
|
{
|
1995-12-04 11:06:42 +00:00
|
|
|
// 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
|
1995-12-12 13:37:30 +00:00
|
|
|
TTotalizer& arr = totali();
|
|
|
|
arr.restart();
|
1995-12-13 15:14:22 +00:00
|
|
|
word num_rip = 0;
|
1995-12-12 13:37:30 +00:00
|
|
|
for (THash_object* obj = arr.get_hashobj();
|
1995-12-13 15:14:22 +00:00
|
|
|
num_rip < MAXTOT && obj != NULL;
|
1995-12-12 13:37:30 +00:00
|
|
|
obj = arr.get_hashobj())
|
1995-12-13 15:14:22 +00:00
|
|
|
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);
|
1995-12-15 17:12:03 +00:00
|
|
|
|
|
|
|
const word maxtot = section('F').height() - 1; // La prima riga e' riservata alla fincatura
|
1995-12-12 13:37:30 +00:00
|
|
|
if (_num_rip > maxtot)
|
|
|
|
_num_rip = maxtot;
|
|
|
|
|
1995-12-19 15:56:21 +00:00
|
|
|
const TString& riporto = describe(PEC_RIPORTO);
|
1995-12-11 11:22:47 +00:00
|
|
|
TString desc(80);
|
1995-12-12 13:37:30 +00:00
|
|
|
TPrint_section& body = section('B');
|
|
|
|
for (word j = 0; j < _num_rip; j++)
|
1995-12-04 11:06:42 +00:00
|
|
|
{
|
|
|
|
const TString& key = tot[j]->key();
|
1995-12-11 11:22:47 +00:00
|
|
|
TTotal& t = (TTotal&)(tot[j]->obj());
|
|
|
|
|
1995-12-11 17:38:54 +00:00
|
|
|
desc = riporto;
|
1995-12-11 11:22:47 +00:00
|
|
|
if (key.not_empty())
|
|
|
|
desc << ' ' << key;
|
|
|
|
TEC_row rip(desc, t.importo().normalize());
|
|
|
|
rip.scaduto(t.scaduto());
|
|
|
|
rip.esposto(t.esposto());
|
1995-12-12 13:37:30 +00:00
|
|
|
rip.importo_lire(t.importo_lire());
|
1995-12-11 11:22:47 +00:00
|
|
|
rip.print_on(body);
|
1995-12-15 17:12:03 +00:00
|
|
|
pr.setfooterline(j+1, body.row(0));
|
1995-12-04 11:06:42 +00:00
|
|
|
}
|
1995-12-12 13:37:30 +00:00
|
|
|
}
|
|
|
|
|
1995-12-19 15:56:21 +00:00
|
|
|
int TEC_form::find_magic(TString& s, TString& magic1, TString& magic2) const
|
|
|
|
{
|
|
|
|
const int pos = s.find('<', 0);
|
|
|
|
int end;
|
|
|
|
if (pos >= 0)
|
1995-12-14 13:17:51 +00:00
|
|
|
{
|
1995-12-19 15:56:21 +00:00
|
|
|
end = s.find('>', pos);
|
1995-12-14 13:17:51 +00:00
|
|
|
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);
|
1995-12-19 15:56:21 +00:00
|
|
|
else
|
|
|
|
magic2.cut(0);
|
1995-12-14 13:17:51 +00:00
|
|
|
}
|
1995-12-19 15:56:21 +00:00
|
|
|
else
|
|
|
|
end = s.len()-1;
|
1995-12-14 13:17:51 +00:00
|
|
|
|
1995-12-19 15:56:21 +00:00
|
|
|
const TString right(s.right(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 = causali().decode(row.causale());
|
|
|
|
}
|
|
|
|
if (magic1 == "MO" || magic2 == "MO")
|
|
|
|
{
|
|
|
|
val = movimenti().decode(row.num_reg());
|
|
|
|
}
|
|
|
|
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")
|
|
|
|
{
|
|
|
|
const TDate& d = magic2 == "SC" ? _dls : _dlo;
|
|
|
|
val = d.string();
|
|
|
|
}
|
|
|
|
if (magic1 == "VA")
|
|
|
|
val = o.key();
|
|
|
|
if (magic1 == "DE")
|
|
|
|
val = valute().decode(o.key());
|
|
|
|
|
|
|
|
s.insert(val, pos);
|
1995-12-14 13:17:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-12-15 17:12:03 +00:00
|
|
|
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_TIMPLIRE };
|
|
|
|
TString_array prompt(MAXID);
|
|
|
|
|
|
|
|
TPrint_section& foot = section('F');
|
|
|
|
|
|
|
|
// Sostituisce magic-names nei prompt
|
|
|
|
TString s(80);
|
|
|
|
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);
|
1995-12-19 15:56:21 +00:00
|
|
|
change_magic_footer(o, s);
|
1995-12-15 17:12:03 +00:00
|
|
|
desc_field.set_prompt(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const TTotal& t = (const TTotal&)o.obj();
|
|
|
|
const TImporto& imp = t.importo();
|
|
|
|
TForm_item& dare = foot.find_field(PEC_DARE);
|
|
|
|
TForm_item& avere = foot.find_field(PEC_AVERE);
|
1995-12-19 15:56:21 +00:00
|
|
|
|
|
|
|
TPrint_section& body = section('B');
|
|
|
|
if (dare.x() <= 0 || avere.x() <= 0)
|
|
|
|
{
|
|
|
|
const TForm_item& bdare = body.find_field(PEC_DARE);
|
|
|
|
dare.x() = bdare.x();
|
|
|
|
|
|
|
|
const TForm_item& bavere = body.find_field(PEC_AVERE);
|
|
|
|
avere.x() = bavere.x();
|
|
|
|
}
|
|
|
|
|
1995-12-15 17:12:03 +00:00
|
|
|
if (imp.sezione() == 'D')
|
|
|
|
{
|
|
|
|
dare.set(imp.valore().string());
|
|
|
|
avere.set("");
|
1995-12-14 13:17:51 +00:00
|
|
|
}
|
1995-12-15 17:12:03 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
dare.set("");
|
|
|
|
avere.set(imp.valore().string());
|
|
|
|
}
|
|
|
|
|
|
|
|
TForm_item& scaduto = foot.find_field(PEC_SCADUTO);
|
1995-12-19 15:56:21 +00:00
|
|
|
if (scaduto.x() <= 0)
|
|
|
|
{
|
|
|
|
const TForm_item& bscaduto = body.find_field(PEC_SCADUTO);
|
|
|
|
scaduto.x() = bscaduto.x();
|
|
|
|
}
|
1995-12-15 17:12:03 +00:00
|
|
|
scaduto.set(t.scaduto().string());
|
|
|
|
|
|
|
|
TForm_item& esposto = foot.find_field(PEC_ESPOSTO);
|
1995-12-19 15:56:21 +00:00
|
|
|
if (esposto.x() <= 0)
|
|
|
|
{
|
|
|
|
const TForm_item& besposto = body.find_field(PEC_ESPOSTO);
|
|
|
|
esposto.x() = besposto.x();
|
|
|
|
}
|
|
|
|
esposto.set(t.esposto().string());
|
1995-12-15 17:12:03 +00:00
|
|
|
|
|
|
|
TForm_item& implire = foot.find_field(PEC_IMPLIRE);
|
1995-12-19 15:56:21 +00:00
|
|
|
if (implire.x() <= 0)
|
|
|
|
{
|
|
|
|
const TForm_item& bimplire = body.find_field(PEC_IMPLIRE);
|
|
|
|
implire.x() = bimplire.x();
|
|
|
|
}
|
1995-12-15 17:12:03 +00:00
|
|
|
implire.set(t.importo_lire().string());
|
|
|
|
|
|
|
|
foot.update();
|
|
|
|
|
|
|
|
// Ripristina prompt originari
|
|
|
|
for (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));
|
1995-12-14 13:17:51 +00:00
|
|
|
}
|
|
|
|
|
1995-12-13 15:14:22 +00:00
|
|
|
void TEC_form::stampa_pedata(TPrinter& pr)
|
|
|
|
{
|
|
|
|
THash_object* tot[MAXTOT];
|
|
|
|
word num_rip = ordina_totali_per_valuta(tot);
|
1995-12-15 17:12:03 +00:00
|
|
|
|
|
|
|
// La prima riga del footer deve essere lasciata libera per la fincatura
|
|
|
|
// Ogni sottosezione di totale occupa _total_rows righe: per cui devo calcolare
|
|
|
|
// quanti totali ci stanno nelle righe riservate al footer
|
|
|
|
const word maxtot = (section('F').height()-1) / _total_rows;
|
1995-12-13 15:14:22 +00:00
|
|
|
if (num_rip > maxtot)
|
|
|
|
num_rip = maxtot;
|
|
|
|
|
|
|
|
for (word j = 0; j < num_rip; j++)
|
1995-12-15 17:12:03 +00:00
|
|
|
print_total(j*_total_rows+1, *tot[j]);
|
1995-12-13 15:14:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TEC_form::ultima_pagina()
|
|
|
|
{
|
|
|
|
set_last_page(TRUE);
|
|
|
|
}
|
|
|
|
|
1995-12-12 13:37:30 +00:00
|
|
|
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);
|
1995-12-13 15:14:22 +00:00
|
|
|
else // Last page
|
|
|
|
_form->stampa_pedata(pr);
|
1995-11-27 08:39:47 +00:00
|
|
|
}
|
|
|
|
|
1995-12-12 13:37:30 +00:00
|
|
|
void TEC_form::azzera_totali()
|
|
|
|
{
|
1995-12-13 15:14:22 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
TPrint_section& foot = section('F');
|
|
|
|
printer().footerlen(foot.height());
|
1995-12-12 13:37:30 +00:00
|
|
|
}
|
1995-12-04 11:06:42 +00:00
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
bool TEC_form::print_game(const TPartita& game)
|
|
|
|
{
|
|
|
|
bool ok = FALSE;
|
|
|
|
|
|
|
|
TEC_array righe(game, this);
|
|
|
|
|
|
|
|
TPrinter& pr = printer();
|
|
|
|
TPrintrow prow;
|
|
|
|
|
|
|
|
TPrint_section& body = section('B');
|
|
|
|
|
|
|
|
TImporto saldo;
|
1995-12-12 13:37:30 +00:00
|
|
|
real scaduto, esposto, implire;
|
1995-12-01 11:49:57 +00:00
|
|
|
|
|
|
|
// Stampa le righe di partita
|
1995-12-11 17:38:54 +00:00
|
|
|
|
|
|
|
int ultima_riga = 0;
|
|
|
|
int ultima_rata = 0;
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
for (int r = 0; r < righe.items(); r++)
|
|
|
|
{
|
1995-12-04 11:06:42 +00:00
|
|
|
TEC_row& riga = righe.row(r);
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
if (pr.rows_left() < body.height())
|
1995-12-12 13:37:30 +00:00
|
|
|
{
|
1995-12-01 11:49:57 +00:00
|
|
|
pr.formfeed();
|
1995-12-12 13:37:30 +00:00
|
|
|
for (word nr = 0; nr < _num_rip; nr++)
|
|
|
|
{
|
|
|
|
TPrintrow* fl = pr.getfooterline(nr);
|
|
|
|
CHECKD(fl, "Manca la riga di riporto ", nr);
|
|
|
|
pr.print(*fl);
|
|
|
|
}
|
|
|
|
}
|
1995-12-11 17:38:54 +00:00
|
|
|
|
|
|
|
const int ri = riga.riga();
|
|
|
|
const int ra = riga.rata();
|
|
|
|
if (ri == ultima_riga && ra == ultima_rata+1)
|
1995-12-15 17:12:03 +00:00
|
|
|
riga.reset_uguali();
|
1995-12-11 17:38:54 +00:00
|
|
|
ultima_riga = ri;
|
|
|
|
ultima_rata = ra;
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
riga.print_on(body);
|
1995-12-04 11:06:42 +00:00
|
|
|
pr.print(body.row(0));
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-12-12 13:37:30 +00:00
|
|
|
totali().add(riga.importo(), riga.scaduto(), riga.esposto(),
|
|
|
|
riga.importo_lire(), riga.valuta().codice());
|
1995-12-01 11:49:57 +00:00
|
|
|
|
|
|
|
saldo += riga.importo();
|
1995-12-11 11:22:47 +00:00
|
|
|
scaduto += riga.scaduto();
|
|
|
|
esposto += riga.esposto();
|
1995-12-12 13:37:30 +00:00
|
|
|
implire += riga.importo_lire();
|
1995-12-01 11:49:57 +00:00
|
|
|
ok = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
saldo.normalize();
|
|
|
|
|
1995-12-14 13:17:51 +00:00
|
|
|
TEC_row sld(describe(PEC_SALDO), saldo);
|
1995-12-11 11:22:47 +00:00
|
|
|
sld.scaduto(scaduto);
|
|
|
|
sld.esposto(esposto);
|
1995-12-12 13:37:30 +00:00
|
|
|
sld.importo_lire(implire);
|
1995-12-01 11:49:57 +00:00
|
|
|
sld.print_on(body);
|
1995-12-11 11:22:47 +00:00
|
|
|
pr.print(body.row(0));
|
1995-12-01 11:49:57 +00:00
|
|
|
|
|
|
|
// Salta una riga vuota
|
|
|
|
TPrintrow vuota;
|
|
|
|
pr.print(vuota);
|
|
|
|
}
|
|
|
|
return ok;
|
1995-11-06 11:10:50 +00:00
|
|
|
}
|
|
|
|
|
1995-12-13 15:14:22 +00:00
|
|
|
const TString& TEC_form::describe(short id, char sez, pagetype pt) const
|
1995-12-11 11:22:47 +00:00
|
|
|
{
|
1995-12-13 15:14:22 +00:00
|
|
|
const TForm_item& fi = find_field(sez, pt, id);
|
1995-12-11 11:22:47 +00:00
|
|
|
return fi.prompt();
|
|
|
|
}
|
|
|
|
|
1995-12-15 17:12:03 +00:00
|
|
|
void TEC_form::init_header(const TMask& m)
|
1995-12-14 13:17:51 +00:00
|
|
|
{
|
1995-12-15 17:12:03 +00:00
|
|
|
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);
|
1995-12-14 13:17:51 +00:00
|
|
|
if (fi.shown())
|
|
|
|
{
|
|
|
|
TLocalisamfile f(LF_RFORM);
|
|
|
|
f.put("TIPOPROF", name());
|
|
|
|
f.put("CODPROF", code());
|
|
|
|
f.put("SEZ", "H");
|
|
|
|
f.put("ID", PEC_MEMO);
|
|
|
|
const int err = f.read();
|
|
|
|
if (err == NOERR)
|
|
|
|
fi.set(f.get("TESTO"));
|
|
|
|
}
|
1995-12-15 17:12:03 +00:00
|
|
|
|
|
|
|
if (_fincatura)
|
|
|
|
{
|
|
|
|
TPrint_section& fink = section('G');
|
|
|
|
if (fink.fields() > 0) fink.update(); // Setta il backgroud di stampa
|
|
|
|
}
|
1995-12-14 13:17:51 +00:00
|
|
|
}
|
|
|
|
|
1995-12-12 13:37:30 +00:00
|
|
|
TEC_form::TEC_form(const TEC_mask& m, bool gesval)
|
1995-12-11 17:38:54 +00:00
|
|
|
: TForm(BASE_EC_PROFILE, m.get_prof_code()),
|
1995-12-14 13:17:51 +00:00
|
|
|
_in_valuta(FALSE), _num_rip(0), _total_rows(0),
|
|
|
|
_causali(LF_CAUSALI, CAU_CODCAUS, CAU_DESCR),
|
1995-12-19 15:56:21 +00:00
|
|
|
_movimenti(LF_MOV, MOV_NUMREG, MOV_DESCR),
|
1995-12-14 13:17:51 +00:00
|
|
|
_valute("%VAL")
|
1995-11-27 13:51:46 +00:00
|
|
|
{
|
|
|
|
_form = this;
|
1995-12-11 17:38:54 +00:00
|
|
|
|
1995-12-04 11:06:42 +00:00
|
|
|
TCursor_sheet& cs = m.cur_sheet();
|
|
|
|
_cursore = cs.cursor();
|
|
|
|
|
1995-12-15 17:12:03 +00:00
|
|
|
_lingua = m.get_prof_lang(); // Lingua profilo
|
1995-12-11 11:22:47 +00:00
|
|
|
_dlo = m.get(F_DATALIMOP);
|
|
|
|
_dls = m.get(F_DATALIMSC);
|
|
|
|
_giorni_rischio = m.get_int(F_GIORISCH);
|
|
|
|
_dir = _dls; _dir -= _giorni_rischio;
|
1995-12-12 13:37:30 +00:00
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
TPrinter& pr = printer();
|
|
|
|
|
|
|
|
pr.setheaderhandler(ec_header_handler);
|
1995-12-12 13:37:30 +00:00
|
|
|
TPrint_section& head = section('H');
|
1995-12-13 15:14:22 +00:00
|
|
|
pr.headerlen(head.height());
|
1995-12-15 17:12:03 +00:00
|
|
|
|
|
|
|
TForm_item& flags = head.find_field(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);
|
|
|
|
init_header(m); // Set fixed text
|
1995-12-12 13:37:30 +00:00
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
pr.setfooterhandler(ec_footer_handler);
|
1995-12-11 17:38:54 +00:00
|
|
|
const TPrint_section& foot = section('F');
|
|
|
|
pr.footerlen(foot.height());
|
1995-12-14 13:17:51 +00:00
|
|
|
|
|
|
|
_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;
|
|
|
|
}
|
|
|
|
}
|
1995-11-06 11:10:50 +00:00
|
|
|
}
|
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
TEC_form::~TEC_form()
|
|
|
|
{
|
1995-11-27 13:51:46 +00:00
|
|
|
TPrinter& pr = printer();
|
|
|
|
pr.setheaderhandler(NULL);
|
|
|
|
pr.setfooterhandler(NULL);
|
|
|
|
_form = NULL;
|
1995-11-06 11:10:50 +00:00
|
|
|
}
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Stampa estratti conto
|
|
|
|
///////////////////////////////////////////////////////////
|
1995-11-06 11:10:50 +00:00
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
class TStampaEC_application : public TApplication
|
|
|
|
{
|
|
|
|
TEC_mask* _msk;
|
|
|
|
TEC_form* _form;
|
1995-11-06 11:10:50 +00:00
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
TFile_array _file;
|
|
|
|
|
1995-12-14 13:17:51 +00:00
|
|
|
TString _lingua_ditta;
|
|
|
|
bool _gesval;
|
1995-11-27 08:39:47 +00:00
|
|
|
|
|
|
|
protected: // TApplication
|
|
|
|
virtual bool create();
|
|
|
|
virtual bool destroy();
|
|
|
|
virtual bool menu(MENU_TAG m);
|
|
|
|
virtual void on_firm_change();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static TStampaEC_application& app() { return (TStampaEC_application&)main_app(); }
|
1995-11-06 11:10:50 +00:00
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
public:
|
|
|
|
TEC_mask& mask() { return *_msk; }
|
|
|
|
TCursor_sheet& sheet() { return _msk->cur_sheet(); }
|
|
|
|
TEC_form& form() { return *_form; }
|
1995-11-06 11:10:50 +00:00
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
bool print_selected(); // print selected items
|
1995-11-27 13:51:46 +00:00
|
|
|
bool print_ec(); // print one item
|
1995-11-06 11:10:50 +00:00
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
TStampaEC_application();
|
|
|
|
virtual ~TStampaEC_application() {}
|
|
|
|
};
|
1995-11-06 11:10:50 +00:00
|
|
|
|
|
|
|
bool TStampaEC_application::print_selected()
|
1995-11-27 08:39:47 +00:00
|
|
|
{
|
1995-12-01 11:49:57 +00:00
|
|
|
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 mode 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);
|
|
|
|
|
1995-11-27 13:51:46 +00:00
|
|
|
const long print_all = !s.one_checked(); // Se non ho selezionato nulla allora li stampo tutti
|
1995-11-27 08:39:47 +00:00
|
|
|
long analfabeti = 0; // Persone non stampate in quanto aventi lingua errata
|
|
|
|
|
|
|
|
printer().open();
|
|
|
|
|
1995-12-13 15:14:22 +00:00
|
|
|
bool one_printed = FALSE;
|
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
const long items = c.items();
|
1995-11-27 13:51:46 +00:00
|
|
|
for (long i = 0; i < items; i++) if (print_all || s.checked(i))
|
1995-12-01 11:49:57 +00:00
|
|
|
{
|
1995-12-13 15:14:22 +00:00
|
|
|
if (one_printed)
|
|
|
|
printer().formfeed();
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
fc = i; // Muove il cursore alla posizione corrente
|
1995-11-27 13:51:46 +00:00
|
|
|
const bool ok = print_ec();
|
1995-12-13 15:14:22 +00:00
|
|
|
if (ok)
|
|
|
|
one_printed = TRUE;
|
|
|
|
else
|
|
|
|
analfabeti++;
|
1995-12-15 17:12:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (one_printed)
|
|
|
|
printer().formfeed();
|
1995-11-27 08:39:47 +00:00
|
|
|
printer().close();
|
|
|
|
|
|
|
|
if (analfabeti > 0)
|
1995-12-01 11:49:57 +00:00
|
|
|
warning_box("%ld clienti/fornitori non sono stati stampati in quanto "
|
1995-11-27 08:39:47 +00:00
|
|
|
"il codice lingua non corrispondeva al profilo di stampa", analfabeti);
|
|
|
|
|
1995-11-06 11:10:50 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1995-11-27 13:51:46 +00:00
|
|
|
bool TStampaEC_application::print_ec()
|
1995-11-14 10:28:43 +00:00
|
|
|
{
|
1995-11-27 08:39:47 +00:00
|
|
|
TEC_form& f = form();
|
1995-11-14 10:28:43 +00:00
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
const TRectype& clf = f.cursor()->file().curr();
|
|
|
|
const TString lincf(clf.get(CLI_CODLIN));
|
1995-11-14 10:28:43 +00:00
|
|
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
|
|
|
|
// make controllations per lingua profilo/CF
|
1995-12-04 11:06:42 +00:00
|
|
|
if ((f.lingua() == _lingua_ditta && !lincf.empty()) || f.lingua() != _lingua_ditta)
|
|
|
|
ok = lincf == f.lingua();
|
1995-11-14 10:28:43 +00:00
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
if (!ok) // Cliente analfabeta
|
|
|
|
return FALSE;
|
1995-12-12 13:37:30 +00:00
|
|
|
|
|
|
|
f.azzera_totali(); // Azzera totali di fine pagina
|
1995-11-27 13:51:46 +00:00
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
// Filtra solo le partite del cliente selezionato
|
|
|
|
TLocalisamfile& partite = _file[LF_PARTITE];
|
|
|
|
partite.zero();
|
|
|
|
partite.put(PART_TIPOCF, clf.get(CLI_TIPOCF));
|
|
|
|
partite.put(PART_SOTTOCONTO, clf.get(CLI_CODCF));
|
|
|
|
const TRectype filter(partite.curr());
|
|
|
|
|
|
|
|
const bool stampa_chiuse = mask().get_bool(F_STAMPCHIU);
|
|
|
|
const TDate data_chiuse = mask().get(F_DATACHIU);
|
|
|
|
|
|
|
|
bool one_printed = FALSE;
|
|
|
|
for (int err = partite.read(_isgteq);
|
1995-11-27 13:51:46 +00:00
|
|
|
err == NOERR && partite.curr() == filter;
|
|
|
|
err = partite.read(_isgreat))
|
|
|
|
{
|
|
|
|
TPartita game(partite.curr());
|
1995-12-01 11:49:57 +00:00
|
|
|
|
|
|
|
if (game.chiusa())
|
1995-12-11 11:22:47 +00:00
|
|
|
{
|
1995-12-13 15:14:22 +00:00
|
|
|
const TDate& dir = f.data_inizio_rischio();
|
|
|
|
const TDate& dlo = f.data_limite_operazione();
|
|
|
|
const TImporto saldo = game.calcola_saldo_al(f.in_valuta(), dlo, dir);
|
1995-12-01 11:49:57 +00:00
|
|
|
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));
|
1995-12-11 11:22:47 +00:00
|
|
|
if (dd > dir)
|
1995-12-01 11:49:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (r == 0)
|
|
|
|
continue;
|
|
|
|
}
|
1995-11-27 13:51:46 +00:00
|
|
|
}
|
1995-12-01 11:49:57 +00:00
|
|
|
|
|
|
|
const bool printed = form().print_game(game);
|
|
|
|
if (printed)
|
|
|
|
one_printed = TRUE;
|
1995-11-27 08:39:47 +00:00
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
partite.put(PART_NRIGA, 9999);
|
1995-12-12 13:37:30 +00:00
|
|
|
}
|
|
|
|
|
1995-12-13 15:14:22 +00:00
|
|
|
if (one_printed)
|
|
|
|
f.ultima_pagina();
|
1995-11-27 13:51:46 +00:00
|
|
|
|
1995-11-06 11:10:50 +00:00
|
|
|
return TRUE;
|
1995-11-27 08:39:47 +00:00
|
|
|
}
|
1995-11-06 11:10:50 +00:00
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Generic TApplication methods
|
|
|
|
///////////////////////////////////////////////////////////
|
1995-11-06 11:10:50 +00:00
|
|
|
|
|
|
|
bool TStampaEC_application::create()
|
|
|
|
{
|
|
|
|
TApplication::create();
|
|
|
|
|
1995-12-01 11:49:57 +00:00
|
|
|
_file.open(LF_TABCOM, LF_TAB, LF_CAUSALI, LF_MOV, LF_RMOV, 0);
|
1995-12-14 13:17:51 +00:00
|
|
|
_file.open(LF_NDITTE, LF_ANAG, LF_COMUNI, LF_RFORM, 0);
|
1995-12-01 11:49:57 +00:00
|
|
|
_file.open(LF_CLIFO, LF_PARTITE, LF_SCADENZE, LF_PAGSCA ,0);
|
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
_msk = new TEC_mask("sc2100a");
|
1995-11-06 11:10:50 +00:00
|
|
|
|
|
|
|
dispatch_e_menu(MENU_ITEM(1));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TStampaEC_application::destroy()
|
1995-11-27 08:39:47 +00:00
|
|
|
{
|
|
|
|
delete _msk;
|
1995-12-05 17:17:41 +00:00
|
|
|
_file.close();
|
1995-11-06 11:10:50 +00:00
|
|
|
return TApplication::destroy();
|
|
|
|
}
|
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
void TStampaEC_application::on_firm_change()
|
|
|
|
{
|
|
|
|
TApplication::on_firm_change();
|
|
|
|
TConfig c(CONFIG_DITTA, "cg");
|
1995-12-04 11:06:42 +00:00
|
|
|
_lingua_ditta = c.get("CodLin");
|
1995-11-27 08:39:47 +00:00
|
|
|
_gesval = c.get_bool("GesVal");
|
|
|
|
}
|
|
|
|
|
1995-12-11 11:22:47 +00:00
|
|
|
bool TStampaEC_application::menu(MENU_TAG)
|
1995-11-06 11:10:50 +00:00
|
|
|
{
|
1995-12-11 11:22:47 +00:00
|
|
|
TEC_mask& m = mask();
|
|
|
|
while (m.run() != K_QUIT)
|
|
|
|
{
|
1995-12-12 13:37:30 +00:00
|
|
|
_form = new TEC_form(m, _gesval);
|
1995-12-11 11:22:47 +00:00
|
|
|
|
|
|
|
print_selected();
|
|
|
|
|
|
|
|
delete _form;
|
|
|
|
_form = NULL;
|
|
|
|
}
|
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
return FALSE;
|
1995-11-06 11:10:50 +00:00
|
|
|
}
|
|
|
|
|
1995-11-27 08:39:47 +00:00
|
|
|
TStampaEC_application::TStampaEC_application()
|
1995-12-04 11:06:42 +00:00
|
|
|
: _lingua_ditta(1), _msk(NULL), _form(NULL)
|
1995-11-14 10:28:43 +00:00
|
|
|
{}
|
1995-11-06 11:10:50 +00:00
|
|
|
|
|
|
|
int sc2100(int argc, char** argv)
|
|
|
|
{
|
|
|
|
TStampaEC_application app;
|
|
|
|
app.run(argc, argv, "Stampa Estratti Conto");
|
|
|
|
return 0;
|
|
|
|
}
|
1995-12-01 11:49:57 +00:00
|
|
|
|