From 0f5687a928cfb2fedff2f847e3d82b53731aec2b Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Fri, 12 Nov 2021 15:37:29 +0100 Subject: [PATCH] Patch level : 12.0 1096 Files correlati : li0.exe Commento : Corretta la ricostruzione plafond. --- src/li/li0100.cpp | 2 +- src/li/li0700.cpp | 2 +- src/li/li0700a.h | 3 ++- src/li/li0700a.uml | 5 +++++ src/li/lilib01.cpp | 42 ++++++++++++++++++++++-------------------- src/li/lilib01.h | 4 ++-- 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/li/li0100.cpp b/src/li/li0100.cpp index 0f715afde..8bbf74252 100644 --- a/src/li/li0100.cpp +++ b/src/li/li0100.cpp @@ -188,7 +188,7 @@ bool TVisLI_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) sto.set(F_FROM_CLI, get_long(F_DACODCF)); sto.set(F_TO_CLI, get_long(F_ACODCF)); if (sto.run() == K_ENTER) - genera_li_storico(sto.get_int(F_ANNO_STO), sto.get_long(F_FROM_CLI), sto.get_long(F_TO_CLI)); + genera_li_storico(sto.get_bool(F_UPDATE_DOC), sto.get_int(F_ANNO_STO), sto.get_long(F_FROM_CLI), sto.get_long(F_TO_CLI)); return false; break; } diff --git a/src/li/li0700.cpp b/src/li/li0700.cpp index 4a2c91b73..1a2302001 100644 --- a/src/li/li0700.cpp +++ b/src/li/li0700.cpp @@ -36,7 +36,7 @@ void TRebuild_letint::main_loop() mask.set(F_ANNO_STO, today.year()); while (mask.run() == K_ENTER) - genera_li_storico(mask.get_int(F_ANNO_STO), mask.get_long(F_FROM_CLI), mask.get_long(F_TO_CLI)); + genera_li_storico(mask.get_bool(F_UPDATE_DOC), mask.get_int(F_ANNO_STO), mask.get_long(F_FROM_CLI), mask.get_long(F_TO_CLI)); } int li0700(int argc, char* argv[]) diff --git a/src/li/li0700a.h b/src/li/li0700a.h index a12d5d1c2..d0b54724b 100644 --- a/src/li/li0700a.h +++ b/src/li/li0700a.h @@ -3,4 +3,5 @@ #define F_ANNO_STO 101 #define F_FROM_CLI 102 -#define F_TO_CLI 103 \ No newline at end of file +#define F_TO_CLI 103 +#define F_UPDATE_DOC 104 \ No newline at end of file diff --git a/src/li/li0700a.uml b/src/li/li0700a.uml index 0edb39e9b..4805187e4 100644 --- a/src/li/li0700a.uml +++ b/src/li/li0700a.uml @@ -50,5 +50,10 @@ BEGIN CHECKTYPE SEARCH END +BOOLEAN F_UPDATE_DOC +BEGIN + PROMPT 2 7 "Aggiorna le fatture correlate" +END + ENDPAGE ENDMASK diff --git a/src/li/lilib01.cpp b/src/li/lilib01.cpp index 29ec746af..67fe0087d 100644 --- a/src/li/lilib01.cpp +++ b/src/li/lilib01.cpp @@ -140,7 +140,7 @@ void TLi_manager::set_anno(const int anno) } } -void genera_li_storico(const int anno, const long from_cli, const long to_cli, const char tipocf) +void genera_li_storico(bool update_doc, const int anno, const long from_cli, const long to_cli, const char tipocf) { // Apro la tabella dei plafonds con chiave 2 (CODCLI+ANNO+NUMPROT) e per ogni cliente calcolo i plafond dal 2017 const TDate dal(1, 1, anno); @@ -211,7 +211,7 @@ void genera_li_storico(const int anno, const long from_cli, const long to_cli, c const int anno = INIZIO_LETINT + y; TLi_manager li('C', atol(codcli), anno); - li.rebuild_plafond(true, anno); + li.rebuild_plafond(update_doc, anno); } } } @@ -242,16 +242,17 @@ int TLi_manager::flush() TLocalisamfile letint(LF_LETINT); const int rows = _plafonds.items(); - for (int r = 0; r < rows; r++) + for (int r = 0; err == NOERR && r < rows; r++) { TRectype & row = (TRectype &)_plafonds[r]; - int err = row.rewrite(letint); + err = row.rewrite(letint); } - _dirty = false; + _dirty = err != NOERR; // almeno se c'è un errore non lo segna come scritto } return err; } + TRectype & TLi_manager::get_lint(const int numprot) { const int rows = _plafonds.items(); @@ -485,6 +486,7 @@ void TLi_manager::rebuild_plafond(bool update_docs, const int anno) TDate al; al.set_end_year(anno); set_anno(anno); + clear_letint(); din.read('D', 'C', _codcli, anno, tipi(), stati(), dal, al); const int items = din.items(); @@ -492,23 +494,21 @@ void TLi_manager::rebuild_plafond(bool update_docs, const int anno) if (_valid_plafond) { TProgress_monitor status(items, "Aggiornamento plafond : Ricostuzione"); - bool ok = true; - clear_letint(); - for (int i = 0; ok && i < items; i++) + for (int i = 0; status.add_status() && i < items; i++) { - if (ok = status.add_status()) - { - TToken_string plafs("", ','); + TToken_string plafs("", ','); - din[i].zero(DOC_PLAFOND); - if (update_docs) - din[i].rewrite(); - else - utilizza_plafond(din[i], plafs, din[i].importo_plafond()); + if (update_docs) + { + din[i].zero(DOC_PLAFOND); + din[i].rewrite(); } + else + utilizza_plafond(din[i], plafs, din[i].importo_plafond()); } - flush(); + if (!update_docs) + flush(); } else { @@ -527,7 +527,7 @@ void TLi_manager::rebuild_plafond(bool update_docs, const int anno) } } -void TLi_manager::read(const char t, const long c, TDate inidic, TDate findic) +void TLi_manager::read(const char t, const long c, int anno) { TRectype reclint(LF_LETINT); @@ -535,6 +535,8 @@ void TLi_manager::read(const char t, const long c, TDate inidic, TDate findic) _plafond = ZERO; _dirty = false; _days.destroy(); + if (anno != 0) + _anno = anno; TDate inizio_anno; inizio_anno.set_start_year(_anno); TDate fine_anno; fine_anno.set_end_year(_anno); const int last_day = fine_anno - inizio_anno; @@ -556,8 +558,8 @@ void TLi_manager::read(const char t, const long c, TDate inidic, TDate findic) for (int r = 0; r < rows; r++) { const TRectype & row = (const TRectype &)_plafonds[r]; - const real & importo = row.get_real(LETINT_IMPORTO); - const real & utilizzato = row.get_real(LETINT_UTILIZZATO); + const real importo = row.get_real(LETINT_IMPORTO); + const real utilizzato = row.get_real(LETINT_UTILIZZATO); _plafond += importo; _utilizzato += utilizzato; diff --git a/src/li/lilib01.h b/src/li/lilib01.h index c19f00cb0..fdb12bbcf 100644 --- a/src/li/lilib01.h +++ b/src/li/lilib01.h @@ -37,7 +37,7 @@ void lint_reset_msg(); // restituisce i messaggi const TToken_string & lint_get_msg(); // Ricostruisce il plafond dall'anno -void genera_li_storico(const int anno, const long from_cli = 0L, const long to_cli = 0L, const char tipocf = 'C'); +void genera_li_storico(bool update_doc, const int anno, const long from_cli = 0L, const long to_cli = 0L, const char tipocf = 'C'); // Ritorna la lista dei tipi TToken_string & tipi(); // Ritorna la lista degli stati @@ -110,7 +110,7 @@ public: bool write_rewrite(TDocumento& d, bool rewrite = false); bool remove(TDocumento& d); - void read(const char t = ' ', const long c = 0L, TDate iniDic = TDate(NULLDATE), TDate finDic = TDate(NULLDATE)); + void read(const char t = ' ', const long c = 0L, int anno = 0); // Costructors/Destructors TLi_manager(const long c, const int anno = 0) : TLi_manager('C', c, anno) {}