diff --git a/sc/sc1200.cpp b/sc/sc1200.cpp index 0dacce89c..97956a0b9 100755 --- a/sc/sc1200.cpp +++ b/sc/sc1200.cpp @@ -38,7 +38,7 @@ protected: // Applicat protected: void zap_file(int logicnum) const; bool zap_partite() const; - int crea_partite(int anno_es, int anno_rif, bool check); + int crea_partite(int anno_es, int anno_rif, int next_anno_es); public: char is_clifo(int g, int c, long s, int& indbil); @@ -137,16 +137,18 @@ char TCreatepart_app::is_clifo(int g, int c, long s, int& indbil) return cf; } -int TCreatepart_app::crea_partite(int anno_es, int anno_rif, bool check) +int TCreatepart_app::crea_partite(int anno_es, int anno_rif, int next_anno_es) { - TRelation saldi(LF_SALDI); + const bool check = anno_es != next_anno_es; + TRelation saldi(LF_SALDI); + saldi.curr().put(SLD_ANNOES, anno_es); TCursor cur(&saldi, "", 1, &saldi.curr(), &saldi.curr()); const long items = cur.items(); if (items == 0) - return -1; + return 0; begin_wait(); @@ -165,6 +167,18 @@ int TCreatepart_app::crea_partite(int anno_es, int anno_rif, bool check) const long sottoc = cur.curr().get_long(SLD_SOTTOCONTO); int indbil; const char cf = is_clifo(gruppo, conto, sottoc, indbil); + if (check) + { + TLocalisamfile work_saldi(LF_SALDI); + work_saldi.zero(); + work_saldi.put(SLD_GRUPPO, gruppo); + work_saldi.put(SLD_CONTO, conto); + work_saldi.put(SLD_SOTTOCONTO, sottoc); + work_saldi.put(SLD_ANNOES, next_anno_es); + work_saldi.put(SLD_FLSCA, ""); + if (work_saldi.read() == NOERR) + continue; + } if (cf > ' ') { TSaldo sld; @@ -197,6 +211,7 @@ int TCreatepart_app::crea_partite(int anno_es, int anno_rif, bool check) numero.right_just(7); TPartita game(clifo, anno_rif, numero); +/* if (check) { for (int p = game.last(); p > 0; p = game.pred(p)) @@ -209,7 +224,8 @@ int TCreatepart_app::crea_partite(int anno_es, int anno_rif, bool check) } if (p > 0) // Il cliente esiste gia', per cui ignoro il saldo continue; - } + } +*/ TRiga_partite& riga = game.new_row(); riga.put(PART_DATAREG, _today); @@ -280,9 +296,14 @@ bool TCreatepart_app::menu(MENU_TAG) const TEsercizio& selected_es = _esc.esercizio(anno_es); const int anno_rif = selected_es.inizio().year(); - int n_part = crea_partite(anno_es, anno_rif, FALSE); - if (n_part < 0) - message_box("Nessun saldo presente per l'esercizio %d", anno_es); + int n_part = crea_partite(anno_es, anno_rif, selected_es.codice()); + + const int pred_es = _esc.pred(anno_es); + if (pred_es > 0) + { + const int p = crea_partite(pred_es, anno_rif, selected_es.codice()); + if (p > 0) n_part += p; + } if (n_part > 0) {