Modificata gestione descrizioni fisse
git-svn-id: svn://10.65.10.50/trunk@2322 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
1c17b5bcc1
commit
68f9bdbfcf
139
sc/sc2100.cpp
139
sc/sc2100.cpp
@ -15,6 +15,7 @@
|
||||
|
||||
#include <clifo.h>
|
||||
#include <causali.h>
|
||||
#include <mov.h>
|
||||
#include <pagsca.h>
|
||||
#include <scadenze.h>
|
||||
|
||||
@ -25,6 +26,8 @@
|
||||
|
||||
class TEC_form : public TForm
|
||||
{
|
||||
friend class TEC_row;
|
||||
|
||||
static TEC_form* _form;
|
||||
|
||||
enum { MAXTOT = 16 };
|
||||
@ -33,6 +36,7 @@ class TEC_form : public TForm
|
||||
TTotalizer _totali;
|
||||
TDecoder _causali; // Decodificatore dei codici causale
|
||||
TDecoder _valute; // Decodificatore dei codici valuta
|
||||
TDecoder _movimenti; // Decodificatore delle descrizioni dei movimenti
|
||||
|
||||
TString _lingua; // Codice lingua del form
|
||||
TDate _dlo, _dls, _dir; // Data limite operazione, scaduto e inizio rischio
|
||||
@ -45,7 +49,10 @@ class TEC_form : public TForm
|
||||
protected:
|
||||
void init_header(const TMask& m);
|
||||
word ordina_totali_per_valuta(THash_object* tot[MAXTOT]);
|
||||
void change_magic_names(const THash_object& o, TString& s);
|
||||
|
||||
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);
|
||||
@ -59,6 +66,7 @@ public:
|
||||
TTotalizer& totali() { return _totali; }
|
||||
TDecoder& causali() { return _causali; }
|
||||
TDecoder& valute() { return _valute; }
|
||||
TDecoder& movimenti() { return _movimenti; }
|
||||
|
||||
const TDate& data_limite_operazione() const { return _dlo; }
|
||||
const TDate& data_limite_scaduto() const { return _dls; }
|
||||
@ -67,7 +75,7 @@ public:
|
||||
|
||||
const TString& lingua() const { return _lingua; }
|
||||
bool in_valuta() const { return _in_valuta; }
|
||||
const TString& describe(short id, char sez = 'B', pagetype pt = odd_page) const;
|
||||
const TString& describe(short id, char sez = 'H', pagetype pt = last_page) const;
|
||||
|
||||
void azzera_totali();
|
||||
void ultima_pagina();
|
||||
@ -97,6 +105,7 @@ class TEC_row : public TSortable
|
||||
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_lire; // Importo in lire
|
||||
real _scaduto; // Importo scaduto
|
||||
@ -109,6 +118,8 @@ protected: // TSortable
|
||||
virtual int compare(const TSortable& s) const;
|
||||
void set_imp(TForm_item& fi, const real& imp, bool valuta) const;
|
||||
|
||||
TEC_form& form() const;
|
||||
|
||||
public:
|
||||
int riga() const { return _riga; }
|
||||
int rata() const { return _rata; }
|
||||
@ -121,6 +132,9 @@ public:
|
||||
void esposto(const real& e) { _esposto = e; }
|
||||
void salvo_buon_fine(bool sbf) { _salvo_buon_fine = sbf; }
|
||||
|
||||
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_lire() const { return _importo_lire; }
|
||||
@ -137,23 +151,24 @@ public:
|
||||
};
|
||||
|
||||
TEC_row::TEC_row(const TRiga_partite& row, const TDate& data, const TImporto& imp, int rata)
|
||||
: _num_prot(0), _salvo_buon_fine(FALSE)
|
||||
: _num_prot(0), _num_reg(0), _salvo_buon_fine(FALSE)
|
||||
{
|
||||
_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);
|
||||
|
||||
_valuta.get(row);
|
||||
}
|
||||
|
||||
TEC_row::TEC_row(const char* desc, const TImporto& imp)
|
||||
: _riga(9999), _rata(9999), _num_prot(0), _salvo_buon_fine(FALSE)
|
||||
: _riga(9999), _rata(9999), _num_prot(0), _num_reg(0), _salvo_buon_fine(FALSE)
|
||||
{
|
||||
_descrizione = desc;
|
||||
_importo = imp; _importo.normalize();
|
||||
@ -216,6 +231,13 @@ void TEC_row::set_imp(TForm_item& fi, const real& imp, bool valuta) const
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
@ -223,13 +245,16 @@ void TEC_row::print_on(TPrint_section& body)
|
||||
|
||||
TForm_item& causale = body.find_field(PEC_CODCAUS);
|
||||
causale.set(_causale);
|
||||
if (_causale.not_empty() && _descrizione.empty())
|
||||
{
|
||||
TDecoder& causali = form.causali();
|
||||
_descrizione = causali.decode(_causale);
|
||||
}
|
||||
|
||||
TForm_item& descr = body.find_field(PEC_DESCR1);
|
||||
|
||||
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);
|
||||
|
||||
TForm_item& datadoc = body.find_field(PEC_DATADOC);
|
||||
@ -278,7 +303,12 @@ void TEC_row::print_on(TPrint_section& body)
|
||||
TForm_item& datacambio = body.find_field(PEC_DATACAM);
|
||||
datacambio.set(_valuta.data().string());
|
||||
|
||||
const TString old_prompt(descr.prompt());
|
||||
descr.set_prompt(""); // Nasconde temporaneamente il prompt per non stampare i <magic>
|
||||
|
||||
body.update();
|
||||
|
||||
descr.set_prompt(old_prompt); // Ripristina il vecchio prompt
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -629,7 +659,7 @@ void TEC_form::stampa_riporti(TPrinter& pr)
|
||||
if (_num_rip > maxtot)
|
||||
_num_rip = maxtot;
|
||||
|
||||
const TString& riporto = describe(PEC_RIPORTO, 'F');
|
||||
const TString& riporto = describe(PEC_RIPORTO);
|
||||
TString desc(80);
|
||||
TPrint_section& body = section('B');
|
||||
for (word j = 0; j < _num_rip; j++)
|
||||
@ -649,23 +679,60 @@ void TEC_form::stampa_riporti(TPrinter& pr)
|
||||
}
|
||||
}
|
||||
|
||||
void TEC_form::change_magic_names(const THash_object& o, TString& s)
|
||||
int TEC_form::find_magic(TString& s, TString& magic1, TString& magic2) const
|
||||
{
|
||||
TString magic1(4), magic2(4), val(50), park(80);
|
||||
|
||||
for (int pos = s.find('<', 0); pos >= 0; pos = s.find('<', pos))
|
||||
const int pos = s.find('<', 0);
|
||||
int end;
|
||||
if (pos >= 0)
|
||||
{
|
||||
const int end = s.find('>', pos);
|
||||
end = s.find('>', pos);
|
||||
if (end > pos)
|
||||
{
|
||||
int p1 = pos+1;
|
||||
magic1 = s.mid(p1, 2);
|
||||
magic2.cut(0);
|
||||
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.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")
|
||||
{
|
||||
@ -676,13 +743,8 @@ void TEC_form::change_magic_names(const THash_object& o, TString& s)
|
||||
val = o.key();
|
||||
if (magic1 == "DE")
|
||||
val = valute().decode(o.key());
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
park = s.left(pos);
|
||||
park << val << s.mid(end+1);
|
||||
s = park;
|
||||
s.insert(val, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,7 +765,7 @@ void TEC_form::print_total(int riga, const THash_object& o)
|
||||
{
|
||||
s = desc_field.prompt();
|
||||
prompt.add(s, i);
|
||||
change_magic_names(o, s);
|
||||
change_magic_footer(o, s);
|
||||
desc_field.set_prompt(s);
|
||||
}
|
||||
}
|
||||
@ -712,6 +774,17 @@ void TEC_form::print_total(int riga, const THash_object& o)
|
||||
const TImporto& imp = t.importo();
|
||||
TForm_item& dare = foot.find_field(PEC_DARE);
|
||||
TForm_item& avere = foot.find_field(PEC_AVERE);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
if (imp.sezione() == 'D')
|
||||
{
|
||||
dare.set(imp.valore().string());
|
||||
@ -724,12 +797,27 @@ void TEC_form::print_total(int riga, const THash_object& o)
|
||||
}
|
||||
|
||||
TForm_item& scaduto = foot.find_field(PEC_SCADUTO);
|
||||
if (scaduto.x() <= 0)
|
||||
{
|
||||
const TForm_item& bscaduto = body.find_field(PEC_SCADUTO);
|
||||
scaduto.x() = bscaduto.x();
|
||||
}
|
||||
scaduto.set(t.scaduto().string());
|
||||
|
||||
TForm_item& esposto = foot.find_field(PEC_ESPOSTO);
|
||||
scaduto.set(t.esposto().string());
|
||||
if (esposto.x() <= 0)
|
||||
{
|
||||
const TForm_item& besposto = body.find_field(PEC_ESPOSTO);
|
||||
esposto.x() = besposto.x();
|
||||
}
|
||||
esposto.set(t.esposto().string());
|
||||
|
||||
TForm_item& implire = foot.find_field(PEC_IMPLIRE);
|
||||
if (implire.x() <= 0)
|
||||
{
|
||||
const TForm_item& bimplire = body.find_field(PEC_IMPLIRE);
|
||||
implire.x() = bimplire.x();
|
||||
}
|
||||
implire.set(t.importo_lire().string());
|
||||
|
||||
foot.update();
|
||||
@ -907,6 +995,7 @@ TEC_form::TEC_form(const TEC_mask& m, bool gesval)
|
||||
: TForm(BASE_EC_PROFILE, m.get_prof_code()),
|
||||
_in_valuta(FALSE), _num_rip(0), _total_rows(0),
|
||||
_causali(LF_CAUSALI, CAU_CODCAUS, CAU_DESCR),
|
||||
_movimenti(LF_MOV, MOV_NUMREG, MOV_DESCR),
|
||||
_valute("%VAL")
|
||||
{
|
||||
_form = this;
|
||||
|
@ -31,6 +31,7 @@
|
||||
#define PEC_RITENUTE 304
|
||||
|
||||
#define PEC_RIPORTO 400
|
||||
|
||||
#define PEC_TSALDO 401
|
||||
#define PEC_TSCADUTO 402
|
||||
#define PEC_TESPOSTO 403
|
||||
|
Loading…
x
Reference in New Issue
Block a user