diff --git a/sc/sc2400.cpp b/sc/sc2400.cpp index 40ac0f0e6..7b2891902 100755 --- a/sc/sc2400.cpp +++ b/sc/sc2400.cpp @@ -77,10 +77,12 @@ bool TStampaSol_application::print_selected() const int ret = print_sol(); if (ret > 0) one_printed = TRUE; - else + else + { + one_printed = FALSE; if (ret < 0) - analfabeti++; - + analfabeti++; + } } if (one_printed) printer().formfeed(); @@ -147,7 +149,31 @@ int TStampaSol_application::print_sol() saldo.normalize(f.sezione_normale()); - if (sel_tot_saldo || saldo.valore() >= sel_importo ) + TImporto unreferenced; //Totale non assegnati per questa partita. + { + // Tutto questo ha senso se e solo se la partita e' espressa in un'unica valuta. + TString valuta; + TRecord_array& unassigned = game.unassigned(); + for (int r = unassigned.last_row(); r > 0; r = unassigned.pred_row(r)) + { + const TRectype& rec = unassigned.row(r); + const TRiga_partite& sum = game.riga(rec.get_int(PAGSCA_NRIGP)); + const char * field = (sum.in_valuta() && f.in_valuta() ? PAGSCA_IMPORTOVAL : PAGSCA_IMPORTO); + if (valuta.empty()) valuta = sum.get(PART_CODVAL); + if (sum.get_date(PART_DATAPAG)<=data_limite_soll) + { + TImporto r(sum.sezione(),rec.get_real(field)); + unreferenced += r; + } + } + if (unreferenced.valore() > 0) + { + unreferenced.normalize('A'); //per i non assegnati/anticipi c'e' solo la colonna AVERE + form().totali().add(unreferenced,valuta); + } + } + + if (sel_tot_saldo || unreferenced.valore() > 0 || saldo.valore() >= sel_importo ) { const bool printed = form().print_game(game); if (printed) diff --git a/sc/sc2401.cpp b/sc/sc2401.cpp index b2cc74e1f..1281d187f 100755 --- a/sc/sc2401.cpp +++ b/sc/sc2401.cpp @@ -94,7 +94,7 @@ int TESSL_row::compare(const TSortable& s) const if (c == 0) c = r._rata - _rata; } else - c = _data < r._data ? +1 : -1; + c = _data < r._data ? -1 : +1; return c; } @@ -637,8 +637,8 @@ void TESSL_form::change_magic_footer(const THash_object& o, TString& s) void TESSL_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 }; + const short MAXID = 5; + const short f_id[MAXID] = { PEC_TSALDO, PEC_TSCADUTO, PEC_TESPOSTO, PEC_TIMPLIRE, PEC_TUNASSIGNED }; TString_array prompt(MAXID); TPrint_section& foot = section('F'); @@ -674,16 +674,25 @@ void TESSL_form::print_total(int riga, const THash_object& o) TForm_item& bavere = body.find_field(PEC_AVERE); avere.set_x(bavere.x()); } - - if (imp.sezione() == 'D') + char sez = imp.sezione(); + real num = imp.valore(); + if (sez=='D' && num<0) { - dare.set(imp.valore().string()); + num = abs(num); sez = 'A'; + } + if (sez=='A' && num<0) + { + num = abs(num); sez = 'D'; + } + if (sez == 'D') + { + dare.set(num.string()); avere.set(""); } else { dare.set(""); - avere.set(imp.valore().string()); + avere.set(num.string()); } TForm_item& scaduto = foot.find_field(PEC_SCADUTO); @@ -709,6 +718,14 @@ void TESSL_form::print_total(int riga, const THash_object& o) implire.set_x(bimplire.x()); } implire.set(t.importo_lire().string()); + + TForm_item& unreferenced = foot.find_field(PEC_UNASSIGNED); + if (unreferenced.x() <= 0) + { + TForm_item& uns = body.find_field(PEC_AVERE); + unreferenced.set_x(uns.x()); + } + unreferenced.set(t.unassigned().valore().string()); foot.update();