Faticosissima correzione per stampare correttamente totali scaduto e

ditte con partite etc.


git-svn-id: svn://10.65.10.50/trunk@2608 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1996-02-17 10:45:02 +00:00
parent ab6b2b7b80
commit 1a6ba4712e

View File

@ -69,12 +69,14 @@ class TStampaScaduto : public TPrintapp
TRelation *_rel1, *_rel2; // Relazioni di lavoro... TRelation *_rel1, *_rel2; // Relazioni di lavoro...
int _cur1, _cur2, // Identificatori dei cursori di lavoro... int _cur1, _cur2, // Identificatori dei cursori di lavoro...
_cur3, _cur4; _cur3, _cur4;
int _pending_total;
TSelection_ext_mask *_m; TSelection_ext_mask *_m;
TLocalisamfile *_scad,*_pagsca; TLocalisamfile *_scad,*_pagsca;
tipo_st _tipost; // Tipo di stampa impostato tipo_st _tipost; // Tipo di stampa impostato
bool _end_printed, bool _end_printed,
_stvaluta, _stvaluta,
_pending_clifo,
_ordcod; // VERO=ordine per codice, FALSO=ordine per ragione sociale _ordcod; // VERO=ordine per codice, FALSO=ordine per ragione sociale
TString _anno,_numdoc,_protiva,_datadoc,_codval,_residuo, TString _anno,_numdoc,_protiva,_datadoc,_codval,_residuo,
_nonscad,_buonfin,_sc_1,_sc_2,_sc_3,_sc_4,_sc_5, _nonscad,_buonfin,_sc_1,_sc_2,_sc_3,_sc_4,_sc_5,
@ -84,7 +86,6 @@ class TStampaScaduto : public TPrintapp
real _unsnc,_uns; // Unassigned per partita. real _unsnc,_uns; // Unassigned per partita.
TArray _t, // Array per i totali TArray _t, // Array per i totali
_s_date; // Date per lo scaduto _s_date; // Date per lo scaduto
TAssoc_array _save_assoc; // Questo serve per tenere in memoria il totale
friend bool fil_function(const TRelation *); friend bool fil_function(const TRelation *);
@ -103,8 +104,6 @@ public:
void print_totali_rows(int& nriga, bool what); void print_totali_rows(int& nriga, bool what);
void print_totali(int& nriga); void print_totali(int& nriga);
void print_header(); void print_header();
void save_totals();
void restore_totals();
void update_totals(bool what,real& res,real& non,real& buo, void update_totals(bool what,real& res,real& non,real& buo,
real& s1,real& s2,real& s3,real& s4,real& s5, real& s6); real& s1,real& s2,real& s3,real& s4,real& s5, real& s6);
void compute_unassigned(TPartita& p); void compute_unassigned(TPartita& p);
@ -125,39 +124,6 @@ bool fil_function(const TRelation *r)
return rt; return rt;
} }
void TStampaScaduto::save_totals()
// 'Sto salvataggio serve per memorizzare i totali nel caso in preprocess_page sia ritornato FALSE
// evitando percio' strane somme di totali o mancanze di essi.
{
TAssoc_array& a = (TAssoc_array&) _t[0];
TString_array as;
const int items = a.items();
a.get_keys(as);
_save_assoc.destroy();
for (int i = 0; i < items; i++)
{
TString k(as.row(i)); // Chiave di ordinamento(valuta)
_LineTotal& v = (_LineTotal&)a[k];
_save_assoc.add(k,v,TRUE);
}
}
void TStampaScaduto::restore_totals()
// Qui fa il contrario della precedente
{
TAssoc_array& a = (TAssoc_array&) _t[0];
TString_array as;
const int items = _save_assoc.items();
_save_assoc.get_keys(as);
for (int i = 0; i < items; i++)
{
TString k(as.row(i)); // Chiave di ordinamento(valuta)
_LineTotal& v = (_LineTotal&)_save_assoc[k];
a.add(k,v,TRUE);
}
_save_assoc.destroy();
}
void TStampaScaduto::update_totals(bool what, real& res, real& non, real& buo, void TStampaScaduto::update_totals(bool what, real& res, real& non, real& buo,
real& s1, real& s2, real& s3, real& s4, real& s5, real& s6) real& s1, real& s2, real& s3, real& s4, real& s5, real& s6)
{ {
@ -346,6 +312,7 @@ void TStampaScaduto::compute_all(TPartita& p)
bool TStampaScaduto::preprocess_page(int file, int counter) bool TStampaScaduto::preprocess_page(int file, int counter)
{ {
TRectype& rc = current_cursor()->curr(file); TRectype& rc = current_cursor()->curr(file);
int lastgood = 0;
if (file == LF_PARTITE) if (file == LF_PARTITE)
{ {
@ -357,11 +324,11 @@ bool TStampaScaduto::preprocess_page(int file, int counter)
else else
if (_tipost == altri) if (_tipost == altri)
rec = current_cursor()->curr(LF_PCON); rec = current_cursor()->curr(LF_PCON);
if (!cs.checked(c->read(_isequal))) // Se non e' stato selezionato salta alla prossima part
return FALSE;
bool ret = FALSE;
int nriga = 1; int nriga = 1;
bool checked = cs.checked(c->read(_isequal));
if (_tipost == clienti || _tipost == fornitori) if (_tipost == clienti || _tipost == fornitori)
{ {
_des = current_cursor()->curr(LF_CLIFO).get(CLI_RAGSOC); _des = current_cursor()->curr(LF_CLIFO).get(CLI_RAGSOC);
@ -374,34 +341,45 @@ bool TStampaScaduto::preprocess_page(int file, int counter)
_cod << " " << current_cursor()->curr(LF_PCON).get(PCN_CONTO); _cod << " " << current_cursor()->curr(LF_PCON).get(PCN_CONTO);
_cod << " " << current_cursor()->curr(LF_PCON).get(PCN_SOTTOCONTO); _cod << " " << current_cursor()->curr(LF_PCON).get(PCN_SOTTOCONTO);
} }
if (_cod != _cod_pre || _end_printed) // Controlla se e' cambiato il codice cli/fo/conto if (_cod != _cod_pre || _end_printed) // Controlla se e' cambiato il codice cli/fo/conto
{ {
reset_print(); reset_print();
if (_cod_pre.not_empty() || _end_printed) // stampa i totali del precedente solo se non e' la prima if (_pending_total > 0) // stampa i totali del precedente solo se non e' la prima
{ {
TAssoc_array& a = (TAssoc_array&) _t[0]; TAssoc_array& a = (TAssoc_array&) _t[0];
if (a.items() > 0) if (a.items() > 0)
{ {
save_totals();
print_totali(nriga); print_totali(nriga);
if (_end_printed) return TRUE; // Go back, print and exit! lastgood = nriga;
_pending_total = 0;
if (_end_printed)
return TRUE; // Go back, print and exit!
} }
} }
set_page_clifoco(nriga); // Setta le righe per stampare le informazioni del cli/fo/conto if (checked)
{
_pending_clifo = TRUE;
_cod_pre = _cod; _cod_pre = _cod;
set_row(nriga++,""); /* fv */
nriga++;
} }
}
if (!checked) // Se non e' stato selezionato salta alla prossima part
return FALSE;
if (rc.get_int(PART_NRIGA) == 1) if (rc.get_int(PART_NRIGA) == 1)
{
_pending_total++;
if (_pending_clifo)
{
set_page_clifoco(nriga); // Setta le righe per stampare le informazioni del cli/fo/conto
_pending_clifo = FALSE;
set_row(nriga++,"");
nriga++;
}
set_page_part(nriga); set_page_part(nriga);
else }
// if (rc.get_int(PART_NRIGA) != 1)
// {
restore_totals();
// return ret; // Skip this, 'cause row #1 has been read already!
// }
//Pesca gli estremi dalla prima riga di fattura, che non e' necessariamente la riga #1 //Pesca gli estremi dalla prima riga di fattura, che non e' necessariamente la riga #1
_residuo = ""; _residuo = "";
@ -415,6 +393,7 @@ bool TStampaScaduto::preprocess_page(int file, int counter)
_sc_6 = ""; _sc_6 = "";
TPartita p(rc); TPartita p(rc);
int r = p.prima_fattura(); int r = p.prima_fattura();
if (r > 0) //Skip next partita if no fatture! if (r > 0) //Skip next partita if no fatture!
{ {
@ -429,28 +408,40 @@ bool TStampaScaduto::preprocess_page(int file, int counter)
// Now performing fulkrum... // Now performing fulkrum...
compute_all(p); compute_all(p);
} }
current_cursor()->repos(); // Very, very necessary... current_cursor()->repos(); // Very, very necessary...
if (r < 1) if (r < 1)
{ {
restore_totals();
reset_row(nriga); reset_row(nriga);
_pending_total--;
if (_pending_clifo)
_pending_clifo = (_pending_total > 0);
return TRUE; return TRUE;
} }
if (_residuo.empty() && _nonscad.empty() && _sc_1.empty() && _sc_2.empty() && if (_residuo.empty() && _nonscad.empty() && _sc_1.empty() && _sc_2.empty() &&
_sc_3.empty() && _sc_4.empty() && _sc_5.empty() && _sc_6.empty()) _sc_3.empty() && _sc_4.empty() && _sc_5.empty() && _sc_6.empty())
{
if (_tipost == clienti) if (_tipost == clienti)
{ {
if (_buonfin.empty()) if (_buonfin.empty())
{ {
restore_totals(); // se ha stampato i totali precedenti deve mantenerli
return FALSE; for (int i = lastgood; i <= nriga; i++) reset_row(i);
_pending_total--;
if (_pending_clifo)
_pending_clifo = (_pending_total > 0);
return lastgood;
} }
} }
else else
{ {
restore_totals(); for (int i = lastgood; i <= nriga; i++) reset_row(i);
return FALSE; _pending_total--;
if (_pending_clifo) _pending_clifo = (_pending_total > 0);
return lastgood;
}
} }
} }
return TRUE; return TRUE;
@ -511,7 +502,6 @@ bool TStampaScaduto::user_destroy()
if (_m) delete _m; if (_m) delete _m;
_t.destroy(); _t.destroy();
_s_date.destroy(); _s_date.destroy();
_save_assoc.destroy();
return TRUE; return TRUE;
} }
@ -543,7 +533,8 @@ bool TStampaScaduto::set_print(int)
else _tipost = fornitori; else _tipost = fornitori;
if (_m->get_key() == 1) _ordcod = TRUE; if (_m->get_key() == 1) _ordcod = TRUE;
else _ordcod = FALSE; else _ordcod = FALSE;
_end_printed = FALSE; _end_printed = _pending_clifo =FALSE;
_pending_total = 0;
_gcr = _m->get_int(F_GIORNI); _gcr = _m->get_int(F_GIORNI);
_stvaluta = _m->get_bool(F_VALUTA); _stvaluta = _m->get_bool(F_VALUTA);
_datas = (const char *)(_m->get(F_DATASTAMPA)); _datas = (const char *)(_m->get(F_DATASTAMPA));
@ -559,7 +550,6 @@ bool TStampaScaduto::set_print(int)
TAssoc_array& aa = (TAssoc_array&) _t[it]; TAssoc_array& aa = (TAssoc_array&) _t[it];
aa.destroy(); // Totali lineari (singolo e generale) aa.destroy(); // Totali lineari (singolo e generale)
} }
_save_assoc.destroy();
get_cursor(_cur1)->set_filterfunction(fil_function,TRUE); get_cursor(_cur1)->set_filterfunction(fil_function,TRUE);
get_cursor(_cur2)->set_filterfunction(fil_function,TRUE); get_cursor(_cur2)->set_filterfunction(fil_function,TRUE);
get_cursor(_cur3)->set_filterfunction(fil_function,TRUE); get_cursor(_cur3)->set_filterfunction(fil_function,TRUE);