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:
parent
ab6b2b7b80
commit
1a6ba4712e
130
sc/sc2300.cpp
130
sc/sc2300.cpp
@ -69,12 +69,14 @@ class TStampaScaduto : public TPrintapp
|
||||
TRelation *_rel1, *_rel2; // Relazioni di lavoro...
|
||||
int _cur1, _cur2, // Identificatori dei cursori di lavoro...
|
||||
_cur3, _cur4;
|
||||
|
||||
int _pending_total;
|
||||
|
||||
TSelection_ext_mask *_m;
|
||||
TLocalisamfile *_scad,*_pagsca;
|
||||
tipo_st _tipost; // Tipo di stampa impostato
|
||||
bool _end_printed,
|
||||
_stvaluta,
|
||||
_pending_clifo,
|
||||
_ordcod; // VERO=ordine per codice, FALSO=ordine per ragione sociale
|
||||
TString _anno,_numdoc,_protiva,_datadoc,_codval,_residuo,
|
||||
_nonscad,_buonfin,_sc_1,_sc_2,_sc_3,_sc_4,_sc_5,
|
||||
@ -84,8 +86,7 @@ class TStampaScaduto : public TPrintapp
|
||||
real _unsnc,_uns; // Unassigned per partita.
|
||||
TArray _t, // Array per i totali
|
||||
_s_date; // Date per lo scaduto
|
||||
TAssoc_array _save_assoc; // Questo serve per tenere in memoria il totale
|
||||
|
||||
|
||||
friend bool fil_function(const TRelation *);
|
||||
|
||||
public:
|
||||
@ -103,8 +104,6 @@ public:
|
||||
void print_totali_rows(int& nriga, bool what);
|
||||
void print_totali(int& nriga);
|
||||
void print_header();
|
||||
void save_totals();
|
||||
void restore_totals();
|
||||
void update_totals(bool what,real& res,real& non,real& buo,
|
||||
real& s1,real& s2,real& s3,real& s4,real& s5, real& s6);
|
||||
void compute_unassigned(TPartita& p);
|
||||
@ -125,39 +124,6 @@ bool fil_function(const TRelation *r)
|
||||
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,
|
||||
real& s1, real& s2, real& s3, real& s4, real& s5, real& s6)
|
||||
{
|
||||
@ -346,9 +312,10 @@ void TStampaScaduto::compute_all(TPartita& p)
|
||||
bool TStampaScaduto::preprocess_page(int file, int counter)
|
||||
{
|
||||
TRectype& rc = current_cursor()->curr(file);
|
||||
int lastgood = 0;
|
||||
|
||||
if (file == LF_PARTITE)
|
||||
{
|
||||
{
|
||||
TCursor_sheet& cs = _m->cur_sheet(); // Sheet di selezione (CLI/FO/PCON)
|
||||
TCursor* c = cs.cursor();
|
||||
TRectype& rec = c->curr();
|
||||
@ -357,11 +324,11 @@ bool TStampaScaduto::preprocess_page(int file, int counter)
|
||||
else
|
||||
if (_tipost == altri)
|
||||
rec = current_cursor()->curr(LF_PCON);
|
||||
if (!cs.checked(c->read(_isequal))) // Se non e' stato selezionato salta alla prossima part
|
||||
return FALSE;
|
||||
|
||||
int nriga = 1;
|
||||
|
||||
bool checked = cs.checked(c->read(_isequal));
|
||||
|
||||
bool ret = FALSE;
|
||||
int nriga = 1;
|
||||
if (_tipost == clienti || _tipost == fornitori)
|
||||
{
|
||||
_des = current_cursor()->curr(LF_CLIFO).get(CLI_RAGSOC);
|
||||
@ -371,37 +338,48 @@ bool TStampaScaduto::preprocess_page(int file, int counter)
|
||||
{
|
||||
_des = current_cursor()->curr(LF_PCON).get(PCN_DESCR);
|
||||
_cod = current_cursor()->curr(LF_PCON).get(PCN_GRUPPO);
|
||||
_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);
|
||||
}
|
||||
}
|
||||
|
||||
if (_cod != _cod_pre || _end_printed) // Controlla se e' cambiato il codice cli/fo/conto
|
||||
{
|
||||
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];
|
||||
if (a.items() > 0)
|
||||
{
|
||||
save_totals();
|
||||
print_totali(nriga);
|
||||
if (_end_printed) return TRUE; // Go back, print and exit!
|
||||
print_totali(nriga);
|
||||
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
|
||||
_cod_pre = _cod;
|
||||
set_row(nriga++,""); /* fv */
|
||||
nriga++;
|
||||
if (checked)
|
||||
{
|
||||
_pending_clifo = TRUE;
|
||||
_cod_pre = _cod;
|
||||
}
|
||||
}
|
||||
|
||||
if (!checked) // Se non e' stato selezionato salta alla prossima part
|
||||
return FALSE;
|
||||
|
||||
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);
|
||||
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
|
||||
_residuo = "";
|
||||
@ -415,6 +393,7 @@ bool TStampaScaduto::preprocess_page(int file, int counter)
|
||||
_sc_6 = "";
|
||||
|
||||
TPartita p(rc);
|
||||
|
||||
int r = p.prima_fattura();
|
||||
if (r > 0) //Skip next partita if no fatture!
|
||||
{
|
||||
@ -429,29 +408,41 @@ bool TStampaScaduto::preprocess_page(int file, int counter)
|
||||
// Now performing fulkrum...
|
||||
compute_all(p);
|
||||
}
|
||||
|
||||
current_cursor()->repos(); // Very, very necessary...
|
||||
|
||||
if (r < 1)
|
||||
{
|
||||
restore_totals();
|
||||
reset_row(nriga);
|
||||
_pending_total--;
|
||||
if (_pending_clifo)
|
||||
_pending_clifo = (_pending_total > 0);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (_residuo.empty() && _nonscad.empty() && _sc_1.empty() && _sc_2.empty() &&
|
||||
_sc_3.empty() && _sc_4.empty() && _sc_5.empty() && _sc_6.empty())
|
||||
{
|
||||
if (_tipost == clienti)
|
||||
{
|
||||
if (_buonfin.empty())
|
||||
{
|
||||
restore_totals();
|
||||
return FALSE;
|
||||
{
|
||||
// se ha stampato i totali precedenti deve mantenerli
|
||||
for (int i = lastgood; i <= nriga; i++) reset_row(i);
|
||||
_pending_total--;
|
||||
if (_pending_clifo)
|
||||
_pending_clifo = (_pending_total > 0);
|
||||
return lastgood;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
restore_totals();
|
||||
return FALSE;
|
||||
}
|
||||
for (int i = lastgood; i <= nriga; i++) reset_row(i);
|
||||
_pending_total--;
|
||||
if (_pending_clifo) _pending_clifo = (_pending_total > 0);
|
||||
return lastgood;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -511,7 +502,6 @@ bool TStampaScaduto::user_destroy()
|
||||
if (_m) delete _m;
|
||||
_t.destroy();
|
||||
_s_date.destroy();
|
||||
_save_assoc.destroy();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -543,7 +533,8 @@ bool TStampaScaduto::set_print(int)
|
||||
else _tipost = fornitori;
|
||||
if (_m->get_key() == 1) _ordcod = TRUE;
|
||||
else _ordcod = FALSE;
|
||||
_end_printed = FALSE;
|
||||
_end_printed = _pending_clifo =FALSE;
|
||||
_pending_total = 0;
|
||||
_gcr = _m->get_int(F_GIORNI);
|
||||
_stvaluta = _m->get_bool(F_VALUTA);
|
||||
_datas = (const char *)(_m->get(F_DATASTAMPA));
|
||||
@ -559,7 +550,6 @@ bool TStampaScaduto::set_print(int)
|
||||
TAssoc_array& aa = (TAssoc_array&) _t[it];
|
||||
aa.destroy(); // Totali lineari (singolo e generale)
|
||||
}
|
||||
_save_assoc.destroy();
|
||||
get_cursor(_cur1)->set_filterfunction(fil_function,TRUE);
|
||||
get_cursor(_cur2)->set_filterfunction(fil_function,TRUE);
|
||||
get_cursor(_cur3)->set_filterfunction(fil_function,TRUE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user