diff --git a/cg/cg4100.cpp b/cg/cg4100.cpp index 35a35837e..873b62add 100755 --- a/cg/cg4100.cpp +++ b/cg/cg4100.cpp @@ -379,14 +379,8 @@ bool CG4100_App::sort_sal() { if (oldnumreg !=0) { - sal.set_anno_es(atoi(_year)); - sal.set_movap(apertura); - sal.set_movprovv(provvis); - sal.set_data_ulmov(datareg); - sal.set_num_ulmov(oldnumreg); if (sal.items() > 0) sal.registra(); - sal.reset(); } oldnumreg = numreg; mov.zero(); @@ -394,10 +388,9 @@ bool CG4100_App::sort_sal() mov.read(); CHECK(mov.good(),"Archivi movimenti e righe inconsistenti"); - const char* codcaus = mov.get(MOV_CODCAUS); - - // cerca causale causali.zero(); + const char* codcaus = mov.get(MOV_CODCAUS); + // cerca causale if (*codcaus) { causali.put(CAU_CODCAUS, codcaus); @@ -408,6 +401,13 @@ bool CG4100_App::sort_sal() else apertura = FALSE; provvis = mov.get(MOV_PROVVIS).not_empty(); datareg = mov.get_date(MOV_DATAREG); + + sal.reset(); + sal.set_anno_es(atoi(_year)); + sal.set_movap(apertura); + sal.set_movprovv(provvis); + sal.set_data_ulmov(datareg); + sal.set_num_ulmov(oldnumreg); } const char sezione = rmov.get(RMV_SEZIONE)[0]; real importo(rmov.get(RMV_IMPORTO)); @@ -418,13 +418,10 @@ bool CG4100_App::sort_sal() prnd.addstatus(1); do_events(); } - sal.set_anno_es(atoi(_year)); - sal.set_movap(apertura); - sal.set_movprovv(provvis); - sal.set_data_ulmov(datareg); - sal.set_num_ulmov(oldnumreg); + if (sal.items() > 0) sal.registra(); + remove("__sal__.sav"); return TRUE; }