Patch level : 12.0 1096

Files correlati     : li0.exe
Commento        :

Corretta la ricostruzione plafond.
This commit is contained in:
Alessandro Bonazzi 2021-11-12 15:37:29 +01:00
parent a97a79aac6
commit 0f5687a928
6 changed files with 33 additions and 25 deletions

View File

@ -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;
}

View File

@ -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[])

View File

@ -3,4 +3,5 @@
#define F_ANNO_STO 101
#define F_FROM_CLI 102
#define F_TO_CLI 103
#define F_TO_CLI 103
#define F_UPDATE_DOC 104

View File

@ -50,5 +50,10 @@ BEGIN
CHECKTYPE SEARCH
END
BOOLEAN F_UPDATE_DOC
BEGIN
PROMPT 2 7 "Aggiorna le fatture correlate"
END
ENDPAGE
ENDMASK

View File

@ -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;

View File

@ -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) {}