cg1500.cpp e cg1600.cpp Migliorate le prestazioni del calcolo saldi e
saldacon.h spostato il TDecoder da saldacon.h a Tele Piu' 2 git-svn-id: svn://10.65.10.50/trunk@3947 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
64abb304de
commit
3b583ef40e
@ -1712,6 +1712,8 @@ bool CG1500_application::calcola(int g, int c, long s)
|
||||
TLocalisamfile rmov(LF_RMOV);
|
||||
TLocalisamfile mov(LF_MOV);
|
||||
|
||||
TDecoder causali(LF_CAUSALI, CAU_CODCAUS, CAU_MOVAP);
|
||||
|
||||
_mov_periodo_dare = ZERO;
|
||||
_mov_periodo_avere = ZERO;
|
||||
_prg_prec_dare = ZERO;
|
||||
@ -1729,21 +1731,20 @@ bool CG1500_application::calcola(int g, int c, long s)
|
||||
rmov.put(RMV_SOTTOCONTO,s);
|
||||
TRectype rec(rmov.curr());
|
||||
|
||||
rmov.read(_isgteq);
|
||||
for ( ; !rmov.eof(); rmov.next())
|
||||
for (int err = rmov.read(_isgteq); err != NOERR; err = rmov.next())
|
||||
{
|
||||
if (rmov.curr() != rec) break;
|
||||
if (rmov.curr() != rec)
|
||||
break;
|
||||
|
||||
annoe = rmov.get_int(RMV_ANNOES);
|
||||
data = rmov.get_date(RMV_DATAREG);
|
||||
num_reg = rmov.get_long(RMV_NUMREG);
|
||||
|
||||
mov.setkey(1);
|
||||
mov.zero();
|
||||
mov.put(MOV_NUMREG, num_reg);
|
||||
mov.read();
|
||||
if (mov.bad())
|
||||
if (mov.read() != NOERR)
|
||||
mov.zero();
|
||||
|
||||
provvis = mov.get_char(MOV_PROVVIS);
|
||||
datacomp = mov.get_date(MOV_DATACOMP);
|
||||
|
||||
@ -1753,38 +1754,31 @@ bool CG1500_application::calcola(int g, int c, long s)
|
||||
if (_stampa_mov_prov == 3 && provvis == '\0') //bilancio dei soli provvisori
|
||||
continue;
|
||||
|
||||
TString codcaus(mov.get(MOV_CODCAUS));
|
||||
|
||||
// if (codcaus.not_empty())
|
||||
// if (codcaus == causale_chiusura())
|
||||
// continue;
|
||||
const TString& codcaus = mov.get(MOV_CODCAUS);
|
||||
const char causap = causali.decode(codcaus)[0];
|
||||
|
||||
// Modifica del 03-03-95
|
||||
if (!_quadratura && causap == 'C')
|
||||
{
|
||||
// Si tratta di causale di chiusura:
|
||||
// Non e' richiesta la quadratura con il Libro Giornale (Modifica
|
||||
// del 18-06-96 richiesta da Patrizia in seguito alla modifica dei SALDI)
|
||||
continue;
|
||||
}
|
||||
|
||||
TCaus cau (codcaus);
|
||||
|
||||
if (codcaus.not_empty())
|
||||
if (cau.chiusura()) // Si tratta di causale di chiusura
|
||||
if (!_quadratura) // Non e' richiesta la quadratura con il Libro Giornale (Modifica
|
||||
continue; // del 18-06-96 richiesta da Patrizia in seguito alla modifica dei SALDI)
|
||||
|
||||
//la causale e' uguale a quella di chiusura
|
||||
//break;
|
||||
|
||||
sezione = rmov.get_char(RMV_SEZIONE);
|
||||
importo = rmov.get_real(RMV_IMPORTO);
|
||||
|
||||
if (_annoes == 0)
|
||||
data_reg = data;
|
||||
else data_reg = datacomp;
|
||||
else
|
||||
data_reg = datacomp;
|
||||
|
||||
if (importo == 0)
|
||||
continue;
|
||||
|
||||
//calcolo i movimenti del periodo
|
||||
if ( data_reg >= _datada && data_reg <= _dataa)
|
||||
if ((cau.apertura() && _dataini != _datada) ||
|
||||
(!cau.apertura()))
|
||||
if ((causap == 'A' && _dataini != _datada) || (causap != 'A'))
|
||||
{
|
||||
conto_mov = TRUE;
|
||||
if (sezione == 'D')
|
||||
@ -1796,7 +1790,8 @@ bool CG1500_application::calcola(int g, int c, long s)
|
||||
//il saldo inizio es. e' dato dall'importo dare - importo avere di quei movimenti che hanno causale == apertura e data reg >= data inizio es. e <= data limite sup.
|
||||
if (_datada == _dataini) //calcolo il saldo iniziale
|
||||
{
|
||||
if (cau.apertura())
|
||||
if (causap == 'A')
|
||||
{
|
||||
if ( (data_reg >= _dataini) && (data_reg <= _dataa) )
|
||||
{
|
||||
if (sezione == 'D')
|
||||
@ -1805,6 +1800,7 @@ bool CG1500_application::calcola(int g, int c, long s)
|
||||
_u_max = fnc_max(_u_max, data);
|
||||
conto_mov = _mov_ap = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_datada > _dataini) //calcolo i progressivi precedenti
|
||||
if ( (data_reg >= _dataini) && (data_reg < _datada) )
|
||||
@ -2847,8 +2843,6 @@ void CG1500_application::postclose_print()
|
||||
|
||||
void CG1500_application::set_page(int file, int counter)
|
||||
{
|
||||
TString dep = "";
|
||||
|
||||
if (_bilancio == 1) //stampa bilancio a sezioni contrapposte
|
||||
{
|
||||
_i = 1;
|
||||
@ -2857,7 +2851,7 @@ void CG1500_application::set_page(int file, int counter)
|
||||
{
|
||||
set_row(_i++,"@29gATTIVITA'@94gPASSIVITA'");
|
||||
set_row(_i++,"@29g---------@94g----------");
|
||||
set_row(_i++, (const char*)dep);
|
||||
set_row(_i++, "");
|
||||
}
|
||||
|
||||
controlla_conto(_eof1,_eof2); //stampo una riga vuota tra un gruppo e un conto altrimenti no
|
||||
@ -2868,7 +2862,7 @@ void CG1500_application::set_page(int file, int counter)
|
||||
printer().formfeed();
|
||||
set_row(_i++,"@29gCOSTI@94gRICAVI");
|
||||
set_row(_i++,"@29g-----@94g------");
|
||||
set_row(_i++, (const char*)dep);
|
||||
set_row(_i++, "");
|
||||
_salto_pagina = TRUE;
|
||||
|
||||
}
|
||||
@ -2885,7 +2879,7 @@ void CG1500_application::set_page(int file, int counter)
|
||||
printer().formfeed();
|
||||
set_row(_i++,"@59gCONTI D'ORDINE");
|
||||
set_row(_i++,"@59g--------------");
|
||||
set_row(_i++, (const char*)dep);
|
||||
set_row(_i++, "");
|
||||
if (_eof5 && _eof6)
|
||||
{
|
||||
_stampato = TRUE;
|
||||
@ -2911,7 +2905,7 @@ void CG1500_application::set_page(int file, int counter)
|
||||
}
|
||||
else //stampa bilancio di verifica
|
||||
{
|
||||
TString udata = _ultima_data.string(brief,'/');
|
||||
TString16 udata = _ultima_data.string(brief,'/');
|
||||
char app;
|
||||
int r = 1;
|
||||
|
||||
@ -3072,16 +3066,15 @@ int CG1500_application::stampa_record_conto(int g,int c,const TString& d,
|
||||
const real& r1,const real& r2,const real& r3,const real& r4,const real& r5,
|
||||
const char app)
|
||||
{
|
||||
TString dep = "";
|
||||
int r = 1;
|
||||
|
||||
if (_stampa_width == 148)
|
||||
{
|
||||
set_row(r,"@49g!@82g!@115g!",(const char*)dep); //stampo una riga vuota
|
||||
set_row(r,"@148g!",(const char*)dep);
|
||||
set_row(r,"@49g!@82g!@115g!"); //stampo una riga vuota
|
||||
set_row(r,"@148g!");
|
||||
}
|
||||
else
|
||||
set_row(r,"@49g!@82g!@114g!",(const char*)dep); //stampo una riga vuota
|
||||
set_row(r,"@49g!@82g!@114g!"); //stampo una riga vuota
|
||||
r++;
|
||||
if (_verifica == 2)
|
||||
{
|
||||
@ -3151,19 +3144,19 @@ int CG1500_application::stampa_record_conto(int g,int c,const TString& d,
|
||||
}
|
||||
if (_stampa_width == 148)
|
||||
{
|
||||
set_row(r,"@49g!@82g!@115g!",(const char*)dep);
|
||||
set_row(r,"@148g!",(const char*)dep);
|
||||
set_row(r,"@49g!@82g!@115g!");
|
||||
set_row(r,"@148g!");
|
||||
}
|
||||
else
|
||||
set_row(r,"@49g!@82g!@114g!",(const char*)dep);
|
||||
set_row(r,"@49g!@82g!@114g!");
|
||||
r++;
|
||||
if (_stampa_width == 148)
|
||||
{
|
||||
set_row(r,"@49g!@82g!@115g!",(const char*)dep);
|
||||
set_row(r,"@148g!",(const char*)dep);
|
||||
set_row(r,"@49g!@82g!@115g!");
|
||||
set_row(r,"@148g!");
|
||||
}
|
||||
else
|
||||
set_row(r,"@49g!@82g!@114g!",(const char*)dep);
|
||||
set_row(r,"@49g!@82g!@114g!");
|
||||
r++;
|
||||
|
||||
if (app == 'D')
|
||||
|
@ -972,7 +972,7 @@ bool data_fine(TMask_field& f, KEY k)
|
||||
f.mask().show(F_QUADRATURA);
|
||||
else
|
||||
f.mask().hide(F_QUADRATURA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (k == K_ENTER)
|
||||
|
170
cg/cg3600.cpp
170
cg/cg3600.cpp
@ -305,75 +305,6 @@ bool TList::remove(long index)
|
||||
return o != NULL;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TDecoder
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TDecoder : private TAssoc_array
|
||||
{
|
||||
TLocalisamfile* _file;
|
||||
TString _if, _of;
|
||||
|
||||
public:
|
||||
const TString& decode(const char* code);
|
||||
const TString& decode(long code);
|
||||
|
||||
TDecoder(int num, const char* inf, const char* outf);
|
||||
TDecoder(const char* table, const char* outf = "S0");
|
||||
virtual ~TDecoder();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TDecoder
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TDecoder::TDecoder(int num, const char* inf, const char* outf)
|
||||
: _file(new TLocalisamfile(num)), _if(inf), _of(outf)
|
||||
{ }
|
||||
|
||||
TDecoder::TDecoder(const char* tab, const char* outf)
|
||||
: _file(new TTable(tab)), _if("CODTAB"), _of(outf)
|
||||
{ }
|
||||
|
||||
TDecoder::~TDecoder()
|
||||
{
|
||||
delete _file;
|
||||
}
|
||||
|
||||
const TString& TDecoder::decode(const char* code)
|
||||
{
|
||||
if (code == NULL)
|
||||
code = "";
|
||||
|
||||
TObject* obj = objptr(code);
|
||||
if (obj == NULL)
|
||||
{
|
||||
int err = ~NOERR;
|
||||
if (*code)
|
||||
{
|
||||
_file->setkey(1);
|
||||
_file->put(_if, code);
|
||||
err = _file->read();
|
||||
}
|
||||
if (err == NOERR)
|
||||
obj = new TString(_file->get(_of)); // Found
|
||||
else
|
||||
obj = new TString(1); // Not found
|
||||
add(code, obj);
|
||||
}
|
||||
const TString& s = (const TString&)*obj;
|
||||
return s;
|
||||
}
|
||||
|
||||
const TString& TDecoder::decode(long code)
|
||||
{
|
||||
TString16 c;
|
||||
if (code > 0)
|
||||
c << code;
|
||||
return decode(c);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TBalance
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -675,7 +606,9 @@ TMastrino::~TMastrino()
|
||||
}
|
||||
|
||||
long TMastrino::succ(long rec, tipo_riga_mastrino tipo) const
|
||||
{
|
||||
{
|
||||
if (rec < 0) rec = -1;
|
||||
|
||||
const long ul = items();
|
||||
for (long i = rec+1; i < ul; i++)
|
||||
{
|
||||
@ -687,6 +620,7 @@ long TMastrino::succ(long rec, tipo_riga_mastrino tipo) const
|
||||
|
||||
long TMastrino::pred(long rec, tipo_riga_mastrino tipo) const
|
||||
{
|
||||
if (rec > items()) rec = items();
|
||||
for (long i = rec-1; i >= 0; i--)
|
||||
{
|
||||
if (row(i).tipo() == tipo)
|
||||
@ -779,6 +713,11 @@ void TMastrino::read(const TBill& conto,
|
||||
|
||||
conto.put(rmov_rec);
|
||||
rmov_rec.put(RMV_DATAREG, min_data_reg);
|
||||
|
||||
#ifdef DBG
|
||||
long num_rec = 0;
|
||||
const clock_t clock_start = clock();
|
||||
#endif
|
||||
|
||||
for (int err = rel().read(_isgteq); err == NOERR; err = rel().next())
|
||||
{
|
||||
@ -791,15 +730,23 @@ void TMastrino::read(const TBill& conto,
|
||||
const TBill conto_corrente(rmov_rec);
|
||||
if (conto_corrente != conto)
|
||||
break;
|
||||
|
||||
const long giorno = data_reg - min_data_reg + 1;
|
||||
pi.setstatus(giorno);
|
||||
|
||||
#ifdef DBG
|
||||
num_rec++;
|
||||
if ((num_rec & 0x7F) == 0)
|
||||
{
|
||||
TString80 msg;
|
||||
const long sec = (clock() - clock_start) / CLOCKS_PER_SEC;
|
||||
msg.format("%ld records at %ld rec/sec", num_rec, num_rec / sec);
|
||||
pi.set_text(msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Ignora i movimenti provvisori
|
||||
if (mov_rec.get_char(MOV_PROVVIS) > ' ')
|
||||
continue;
|
||||
|
||||
const TDate data_corrente(_esercizio <= 0 ? data_reg : mov_rec.get_date(MOV_DATADOC));
|
||||
const TDate data_corrente(_esercizio <= 0 ? data_reg : mov_rec.get_date(MOV_DATACOMP));
|
||||
if (data_corrente > _a_data)
|
||||
continue;
|
||||
|
||||
@ -835,6 +782,9 @@ void TMastrino::read(const TBill& conto,
|
||||
_riga.append(r);
|
||||
}
|
||||
}
|
||||
|
||||
const long giorno = data_reg - min_data_reg + 1;
|
||||
pi.setstatus(giorno);
|
||||
}
|
||||
|
||||
pi.setstatus(num_giorni); // Raramente arriva in fondo!
|
||||
@ -1082,6 +1032,9 @@ TGrid_control::TGrid_control(
|
||||
{
|
||||
switch(*f)
|
||||
{
|
||||
case 'A':
|
||||
auto_num = TRUE;
|
||||
break;
|
||||
case 'D':
|
||||
_read_only = TRUE;
|
||||
break;
|
||||
@ -1521,7 +1474,7 @@ bool TGrid_control::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
else
|
||||
{
|
||||
if (cell.get_size() > 2)
|
||||
cell.set(rec);
|
||||
cell.set(rec+1);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1997,18 +1950,26 @@ void TMastrini_grid::cell_request(long rec, short id, TGrid_cell& cell)
|
||||
if (riga.tipo() == riga_mastrino)
|
||||
{
|
||||
const TRectype& mov = _mastrino.testata(rec);
|
||||
cell.set(mov.get(MOV_DESCR));
|
||||
const TString& text = mov.get(MOV_DESCR);
|
||||
if (text.empty())
|
||||
{
|
||||
const TRectype& rmov = _mastrino.riga(rec);
|
||||
cell.set(rmov.get(RMV_DESCR));
|
||||
}
|
||||
else
|
||||
cell.set(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
const TRectype& rmov = _mastrino.riga(rec);
|
||||
const char* text = rmov.get(RMV_DESCR);
|
||||
if (*text == '\0')
|
||||
const TString& text = rmov.get(RMV_DESCR);
|
||||
if (text.empty())
|
||||
{
|
||||
const TBill conto(rmov);
|
||||
text = conto.descrizione();
|
||||
cell.set(conto.descrizione());
|
||||
}
|
||||
cell.set(text);
|
||||
else
|
||||
cell.set(text);
|
||||
}
|
||||
break;
|
||||
case 104:
|
||||
@ -2117,30 +2078,47 @@ void TMastrini_grid::on_dbl_cell(long rec, short id)
|
||||
}
|
||||
|
||||
void TMastrini_grid::on_grid_button()
|
||||
{
|
||||
begin_wait();
|
||||
|
||||
if (items() > 0)
|
||||
{
|
||||
const long total = _mastrino.items();
|
||||
if (total > 0)
|
||||
{
|
||||
long sample_rec = selected();
|
||||
if (sample_rec < 0 || sample_rec >= items())
|
||||
sample_rec = 0;
|
||||
|
||||
if (_mastrino.expandable(sample_rec))
|
||||
{
|
||||
for (long n = items()-1; n >= 0; n--)
|
||||
TProgind* pi = NULL;
|
||||
|
||||
if (total > 50)
|
||||
pi = new TProgind(total, "Calcolo contropartite", FALSE, TRUE, 48);
|
||||
else
|
||||
begin_wait();
|
||||
|
||||
const long last_con = _mastrino.last(riga_contropartita);
|
||||
const bool expand = last_con < 0;
|
||||
if (expand)
|
||||
{
|
||||
for (long n = _mastrino.last(riga_mastrino);
|
||||
n >= 0; n = _mastrino.pred(n, riga_mastrino))
|
||||
{
|
||||
if (_mastrino.expandable(n))
|
||||
_mastrino.expand(n);
|
||||
if (pi)
|
||||
pi->setstatus(total - n);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (long n = 0; n < _mastrino.items(); n++)
|
||||
if (_mastrino[n].tipo() != riga_mastrino)
|
||||
_mastrino.collapse(--n);
|
||||
{
|
||||
for (long n = last_con; n > 0; n = _mastrino.pred(n, riga_contropartita))
|
||||
{
|
||||
_mastrino.collapse(n);
|
||||
if (pi)
|
||||
pi->setstatus(total - n + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (pi)
|
||||
delete pi;
|
||||
else
|
||||
end_wait();
|
||||
|
||||
update();
|
||||
}
|
||||
end_wait();
|
||||
}
|
||||
|
||||
void TMastrini_grid::on_record_button(long rec)
|
||||
|
28
cg/cglib.h
28
cg/cglib.h
@ -31,6 +31,32 @@ public:
|
||||
~TCaus() {}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TDecoder
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TDecoder : private TAssoc_array
|
||||
{
|
||||
TLocalisamfile* _file;
|
||||
TString _if, _of;
|
||||
long _last_firm;
|
||||
|
||||
protected:
|
||||
void init_firm();
|
||||
|
||||
public:
|
||||
const TString& decode(const char* code);
|
||||
const TString& decode(long code);
|
||||
|
||||
TDecoder(int num, const char* inf, const char* outf);
|
||||
TDecoder(const char* table, const char* outf = "S0");
|
||||
virtual ~TDecoder();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSaldi_list
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TSaldi_list : public TAssoc_array
|
||||
{
|
||||
public:
|
||||
@ -63,6 +89,8 @@ class TSaldo
|
||||
bool _rec_presente_ep;
|
||||
bool _prec;
|
||||
|
||||
TDecoder _causali_apertura;
|
||||
|
||||
protected:
|
||||
void InFinEs(int);
|
||||
bool leggi_mov(long numreg); // Leggi testata
|
||||
|
152
cg/cglib01.cpp
152
cg/cglib01.cpp
@ -2,6 +2,8 @@
|
||||
// calcolo dei saldi
|
||||
|
||||
#include <config.h>
|
||||
#include <xvtility.h>
|
||||
|
||||
#include <rmov.h>
|
||||
#include <mov.h>
|
||||
#include <saldi.h>
|
||||
@ -23,21 +25,24 @@ TCaus::TCaus(const char* cod) : _rec(LF_CAUSALI)
|
||||
|
||||
// Legge le righe della causale attualmente selezionata sulla maschera
|
||||
bool TCaus::read(const char* cod)
|
||||
{
|
||||
TLocalisamfile caus(LF_CAUSALI);
|
||||
|
||||
_rec = caus.curr(); _rec.zero(); // Delete header
|
||||
|
||||
if (*cod > ' ')
|
||||
{
|
||||
bool ok = FALSE;
|
||||
if (cod && *cod)
|
||||
{
|
||||
TLocalisamfile caus(LF_CAUSALI);
|
||||
caus.setkey(1);
|
||||
caus.put(CAU_CODCAUS, cod);
|
||||
|
||||
int err = caus.read();
|
||||
if (err != NOERR) return FALSE;
|
||||
_rec = caus.curr();
|
||||
}
|
||||
return TRUE;
|
||||
ok = caus.read() == NOERR;
|
||||
if (ok)
|
||||
_rec = caus.curr();
|
||||
else
|
||||
_rec.zero();
|
||||
}
|
||||
else
|
||||
_rec.zero();
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TCaus::chiusura() const
|
||||
@ -46,6 +51,11 @@ bool TCaus::chiusura() const
|
||||
bool TCaus::apertura() const
|
||||
{ return _rec.get_char("MOVAP") == 'A'; }
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSaldi_list
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// Cerca l'esercizio precedente di EseCorr
|
||||
// Se EseCorr e' gia' il primo ritorna 0
|
||||
@ -103,10 +113,16 @@ TRectype* TSaldi_list::saldi() const
|
||||
return (TRectype*)o;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSaldo
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TSaldo::TSaldo() : _saldi(LF_SALDI), _saldoiniziale(ZERO), _saldo_iniziale(ZERO),
|
||||
_prg_dare(ZERO), _prg_avere(ZERO), _saldo(ZERO), _annoes(0),
|
||||
_indbil(0), _prec(FALSE), _movimentato(FALSE), _significativo(FALSE),
|
||||
_rec_presente_ec(FALSE), _rec_presente_ep(FALSE)
|
||||
_rec_presente_ec(FALSE), _rec_presente_ep(FALSE),
|
||||
_causali_apertura(LF_CAUSALI, CAU_CODCAUS, CAU_MOVAP)
|
||||
|
||||
{}
|
||||
|
||||
real TSaldo::saldofin_esprec(int annoes, int g, int c, long s, bool saldo_chiusura, bool mov_prec)
|
||||
@ -196,19 +212,19 @@ const char* TSaldo::causale_apertura_es()
|
||||
|
||||
bool TSaldo::leggi_mov(long nr)
|
||||
{
|
||||
TLocalisamfile mov(LF_MOV, FALSE);
|
||||
bool ok = TRUE;
|
||||
|
||||
mov.zero();
|
||||
mov.put (MOV_NUMREG,nr);
|
||||
|
||||
if (ok = (mov.read() == NOERR))
|
||||
TLocalisamfile mov(LF_MOV);
|
||||
// mov.zero();
|
||||
mov.put (MOV_NUMREG, nr);
|
||||
const bool ok = mov.read() == NOERR;
|
||||
if (ok)
|
||||
{
|
||||
_codcaus = mov.get (MOV_CODCAUS);
|
||||
_datareg = mov.get_date(MOV_DATAREG);
|
||||
_provv = mov.get (MOV_PROVVIS);
|
||||
_datacomp = mov.get_date(MOV_DATACOMP);
|
||||
_codcaus = mov.get(MOV_CODCAUS);
|
||||
_datareg = mov.get(MOV_DATAREG);
|
||||
_provv = mov.get(MOV_PROVVIS); // _provv.trim();
|
||||
_datacomp = mov.get(MOV_DATACOMP);
|
||||
}
|
||||
else
|
||||
NFCHECK("Testata assente: %ld", nr);
|
||||
return ok;
|
||||
}
|
||||
|
||||
@ -216,14 +232,7 @@ bool TSaldo::leggi_mov(long nr)
|
||||
bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDate& data_inf,
|
||||
const TDate& data_sup, int indbil, int stp_prov)
|
||||
{
|
||||
TString16 gcs_corr, gcs_prec;
|
||||
int gruppo, conto, annoe;
|
||||
long sottoconto, num_reg;
|
||||
real importo;
|
||||
TDate data_mov;
|
||||
char sezione;
|
||||
|
||||
TLocalisamfile rmov(LF_RMOV, FALSE);
|
||||
TLocalisamfile rmov(LF_RMOV);
|
||||
|
||||
_saldo_iniziale = ZERO;
|
||||
_saldo = ZERO;
|
||||
@ -232,27 +241,44 @@ bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDat
|
||||
_rec_presente_ec = FALSE;
|
||||
_prec = FALSE;
|
||||
|
||||
gcs_prec = "";
|
||||
|
||||
rmov.setkey(2);
|
||||
rmov.zero();
|
||||
rmov.put(RMV_GRUPPO,g);
|
||||
rmov.put(RMV_CONTO,c);
|
||||
rmov.put(RMV_SOTTOCONTO,s);
|
||||
TRectype rec(rmov.curr());
|
||||
|
||||
// Anche se non movimentato vado a vedere il saldo
|
||||
if (stp_prov != 3)
|
||||
_saldo = calcola_saldo_iniziale(g,c,s,indbil);
|
||||
|
||||
#ifdef DBG
|
||||
long num_rec = 0;
|
||||
const clock_t clock_start = clock();
|
||||
#endif
|
||||
|
||||
for (rmov.read(_isgteq); !rmov.eof(); rmov.next())
|
||||
{
|
||||
if (rmov.curr() != rec) break;
|
||||
|
||||
annoe = rmov.get_int(RMV_ANNOES);
|
||||
gruppo = rmov.get_int(RMV_GRUPPO);
|
||||
conto = rmov.get_int(RMV_CONTO);
|
||||
sottoconto = rmov.get_long(RMV_SOTTOCONTO);
|
||||
num_reg = rmov.get_long(RMV_NUMREG);
|
||||
sezione = rmov.get_char(RMV_SEZIONE);
|
||||
importo = rmov.get_real(RMV_IMPORTO);
|
||||
const int gruppo = rmov.get_int(RMV_GRUPPO);
|
||||
const int conto = rmov.get_int(RMV_CONTO);
|
||||
const long sottoconto = rmov.get_long(RMV_SOTTOCONTO);
|
||||
if (gruppo != g || conto != c || sottoconto != s)
|
||||
break;
|
||||
|
||||
#ifdef DBG
|
||||
num_rec++;
|
||||
if ((num_rec & 0x7F) == 0)
|
||||
{
|
||||
TString80 msg;
|
||||
const long sec = (clock() - clock_start) / CLOCKS_PER_SEC;
|
||||
msg.format("%ld records at %ld rec/sec", num_rec, num_rec / sec);
|
||||
xvt_statbar_set(msg);
|
||||
do_events();
|
||||
}
|
||||
#endif
|
||||
|
||||
const long num_reg = rmov.get_long(RMV_NUMREG);
|
||||
TDate data_mov;
|
||||
|
||||
// Leggo la testata
|
||||
leggi_mov(num_reg);
|
||||
|
||||
@ -269,33 +295,30 @@ bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDat
|
||||
if (data_mov < data_inf || data_mov > data_sup)
|
||||
continue;
|
||||
|
||||
// "Se la causale del movimento e' uguale a quella di chiusura,
|
||||
// "Se la causale del movimento e' di chiusura,
|
||||
// o di apertura il movimento non va considerato"
|
||||
TCaus cau(_codcaus);
|
||||
|
||||
if (_codcaus.not_empty())
|
||||
if (cau.chiusura()) continue;
|
||||
{
|
||||
const TString& movap = _causali_apertura.decode(_codcaus);
|
||||
if (movap == "C")
|
||||
continue;
|
||||
}
|
||||
|
||||
//bilancio normale (non comprende i provvisori) ?
|
||||
if (stp_prov == 1 && _provv.trim().not_empty())
|
||||
if (stp_prov == 1 && _provv.not_empty())
|
||||
continue;
|
||||
|
||||
//bilancio dei soli provvisori ?
|
||||
if (stp_prov == 3 && _provv.trim().empty())
|
||||
if (stp_prov == 3 && _provv.empty())
|
||||
continue;
|
||||
|
||||
// I mov. di puro riferimento (= con importo = 0) vanno scartati
|
||||
if (importo == ZERO) continue;
|
||||
|
||||
gcs_corr.format ("%3d%3d%6ld", gruppo, conto, sottoconto);
|
||||
|
||||
if (gcs_corr != gcs_prec)
|
||||
{
|
||||
gcs_prec = gcs_corr;
|
||||
if (stp_prov != 3) //bilancio normale o globale
|
||||
_saldo = calcola_saldo_iniziale(gruppo,conto,sottoconto,indbil);
|
||||
}
|
||||
const char sezione = rmov.get_char(RMV_SEZIONE);
|
||||
const real importo = rmov.get(RMV_IMPORTO);
|
||||
|
||||
// I mov. di puro riferimento (= con importo = 0) vanno scartati
|
||||
if (importo == ZERO)
|
||||
continue;
|
||||
|
||||
_movimentato = TRUE;
|
||||
|
||||
if (sezione == 'D')
|
||||
@ -304,11 +327,10 @@ bool TSaldo::data_limite_bilancio(int bilancio, int g, int c, long s, const TDat
|
||||
_saldo -= importo;
|
||||
}
|
||||
|
||||
// Anche se non movimentato vado a vedere il saldo
|
||||
if (!_movimentato)
|
||||
if (stp_prov != 3)
|
||||
_saldo = calcola_saldo_iniziale(g,c,s,indbil);
|
||||
|
||||
#ifdef DBG
|
||||
xvt_statbar_refresh();
|
||||
#endif
|
||||
|
||||
return _movimentato;
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,83 @@ void TTab_conti::aggiorna_conto(const TBill& tcon,
|
||||
remove(*tc, anno_es, scaricato);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TDecoder
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TDecoder::TDecoder(int num, const char* inf, const char* outf)
|
||||
: _file(new TLocalisamfile(num)), _if(inf), _of(outf)
|
||||
{
|
||||
init_firm();
|
||||
}
|
||||
|
||||
TDecoder::TDecoder(const char* tab, const char* outf)
|
||||
: _file(new TTable(tab)), _if("CODTAB"), _of(outf)
|
||||
{
|
||||
init_firm();
|
||||
}
|
||||
|
||||
TDecoder::~TDecoder()
|
||||
{
|
||||
delete _file;
|
||||
}
|
||||
|
||||
void TDecoder::init_firm()
|
||||
{
|
||||
TDir dir;
|
||||
dir.get(_file->num());
|
||||
|
||||
// Se e' un file comune metti a -1, altrimenti alla ditta corrente
|
||||
_last_firm = dir.is_com() ? -1 : prefix().get_codditta();
|
||||
}
|
||||
|
||||
const TString& TDecoder::decode(const char* code)
|
||||
{
|
||||
if (_last_firm >= 0) // Se e' un file di ditta ...
|
||||
{ // ... controlla che non sia cambiata
|
||||
const long cur_firm = prefix().get_codditta();
|
||||
if (cur_firm != _last_firm)
|
||||
{
|
||||
_last_firm = cur_firm;
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
|
||||
if (code == NULL)
|
||||
code = "";
|
||||
|
||||
TObject* obj = objptr(code);
|
||||
if (obj == NULL)
|
||||
{
|
||||
int err = ~NOERR;
|
||||
if (*code)
|
||||
{
|
||||
_file->setkey(1);
|
||||
_file->put(_if, code);
|
||||
err = _file->read();
|
||||
}
|
||||
if (err == NOERR)
|
||||
obj = new TString(_file->get(_of)); // Found
|
||||
else
|
||||
obj = new TString(1); // Not found
|
||||
add(code, obj);
|
||||
}
|
||||
const TString& s = (const TString&)*obj;
|
||||
return s;
|
||||
}
|
||||
|
||||
const TString& TDecoder::decode(long code)
|
||||
{
|
||||
TString16 c;
|
||||
if (code > 0)
|
||||
c << code;
|
||||
return decode(c);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSaldo_agg
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TSaldo_agg::TSaldo_agg() : _anno_es(0), _data_ulmov(""), _num_ulmov(0l),
|
||||
_movap(normale), _provv(FALSE), _movimentato(FALSE)
|
||||
{}
|
||||
@ -157,15 +234,6 @@ void TSaldo_agg::clear_saldi(int year)
|
||||
{
|
||||
if (!saldi.get_bool(SLD_FLSCA))
|
||||
{
|
||||
/* saldi.put(SLD_FLAGSALINI, "D");
|
||||
saldi.zero(SLD_SALDO);
|
||||
saldi.zero(SLD_PDAREPRO);
|
||||
saldi.zero(SLD_PAVEREPRO);
|
||||
saldi.zero(SLD_PDARE);
|
||||
saldi.zero(SLD_PAVERE);
|
||||
saldi.zero(SLD_NUMULTMOV);
|
||||
saldi.zero(SLD_DATAULMOV);
|
||||
*/
|
||||
saldi.remove();
|
||||
}
|
||||
else
|
||||
|
@ -245,57 +245,6 @@ void TValuta::lit2val(TImporto& imp) const
|
||||
lit2val(imp.valore());
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TDecoder
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TDecoder::TDecoder(int num, const char* inf, const char* outf)
|
||||
: _file(new TLocalisamfile(num)), _if(inf), _of(outf)
|
||||
{ }
|
||||
|
||||
TDecoder::TDecoder(const char* tab, const char* outf)
|
||||
: _file(new TTable(tab)), _if("CODTAB"), _of(outf)
|
||||
{ }
|
||||
|
||||
TDecoder::~TDecoder()
|
||||
{
|
||||
delete _file;
|
||||
}
|
||||
|
||||
const TString& TDecoder::decode(const char* code)
|
||||
{
|
||||
if (code == NULL)
|
||||
code = "";
|
||||
|
||||
TObject* obj = objptr(code);
|
||||
if (obj == NULL)
|
||||
{
|
||||
int err = ~NOERR;
|
||||
if (*code)
|
||||
{
|
||||
_file->setkey(1);
|
||||
_file->put(_if, code);
|
||||
err = _file->read();
|
||||
}
|
||||
if (err == NOERR)
|
||||
obj = new TString(_file->get(_of)); // Found
|
||||
else
|
||||
obj = new TString(1); // Not found
|
||||
add(code, obj);
|
||||
}
|
||||
const TString& s = (const TString&)*obj;
|
||||
return s;
|
||||
}
|
||||
|
||||
const TString& TDecoder::decode(long code)
|
||||
{
|
||||
TString16 c;
|
||||
if (code > 0)
|
||||
c << code;
|
||||
return decode(c);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TRiga_scadenze
|
||||
///////////////////////////////////////////////////////////
|
||||
|
@ -108,24 +108,6 @@ public:
|
||||
virtual ~TValuta() {}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TDecoder
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TDecoder : private TAssoc_array
|
||||
{
|
||||
TLocalisamfile* _file;
|
||||
TString _if, _of;
|
||||
|
||||
public:
|
||||
const TString& decode(const char* code);
|
||||
const TString& decode(long code);
|
||||
|
||||
TDecoder(int num, const char* inf, const char* outf);
|
||||
TDecoder(const char* table, const char* outf = "S0");
|
||||
virtual ~TDecoder();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Riga scadenza
|
||||
///////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user