diff --git a/ci/ci0400.cpp b/ci/ci0400.cpp index 33bd73679..56dd6bfa2 100755 --- a/ci/ci0400.cpp +++ b/ci/ci0400.cpp @@ -246,7 +246,11 @@ void TImmissioneDocumenti_mask::update_current_calendar(int year) const int doc_items = cursor.items(); for (cursor = 0; cursor.pos() < doc_items; ++cursor) - dayfl.set(relation.lfile().get_date(DOC_DATADOC) - caput_anni, 1); + { + const TDate datadoc = relation.lfile().get_date(DOC_DATADOC); + if (datadoc.year() == year) + dayfl.set(datadoc - caput_anni, 1); + } if (ordered()[currpage]) { caput_anni += dayfl.last_one(); @@ -417,19 +421,35 @@ bool delete_closed(const TRelation& rel, void* pJolly) TDocumento & doc = (TDocumento &) rel.lfile().curr(); const int rows = doc.physical_rows(); bool closed = true; + TBit_array rows2delete; - for (int i = 1; closed && i <= rows; i++) + for (int i = 1; i <= rows; i++) { + const char t = doc[i].tipo().tipo(); + if (t == RIGA_SCONTI || t == RIGA_OMAGGI || t == RIGA_DESCRIZIONI) + continue; const TString & codcms = doc[i].codice_commessa(); const TRectype & cms = cache().get(LF_COMMESSE, codcms); + const bool closed_row = cms.get_bool("CHIUSA"); - closed &= cms.get_bool("CHIUSA"); + rows2delete.set(i, closed_row); + closed &= closed_row; } if (closed) { doc.stato('9'); doc.remove(); } + else + if (rows2delete.first_one() >= 0) + { + for (int i = rows; i >= 1 ; i--) + { + if (rows2delete[i]) + doc.destroy_row(i, true); + } + doc.rewrite(); + } return true; }