diff --git a/cg/cg6700.cpp b/cg/cg6700.cpp index 6b7066351..6e8a89e56 100755 --- a/cg/cg6700.cpp +++ b/cg/cg6700.cpp @@ -2695,6 +2695,8 @@ void TRic_ListaMov::aggiorna_mov() if (mov.get(MOV_TIPOMOV).empty()) mov.put(MOV_TIPOMOV, _tipom_cau); mov.put(MOV_CODPAG, _codpag_scad); + if ((_tipodoc == "NC" || _tipodoc == "ST") && _tot_doc > 0.0) // swap sign only if positive + _tot_doc = _tot_doc * -1; mov.put(MOV_TOTDOC, _tot_doc); if (_is_salda) { @@ -2730,6 +2732,13 @@ void TRic_ListaMov::aggiorna_iva(char tipo) if (_anno == 0) riva.put(RMI_ANNOES, _annoese); + if ((_tipodoc == "NC" || _tipodoc == "ST") && _impo > 0.0) // swap sign only if positive + { + _impo = _impo * -1; + _impos = _impos * -1; + } + riva.put(RMI_IMPONIBILE, _impo); + riva.put(RMI_IMPOSTA, _impos); riva.put(RMI_TIPOC, tipo); riva.rewrite(); diff --git a/cg/cglib04.cpp b/cg/cglib04.cpp index 1cfeceb04..f915f339c 100755 --- a/cg/cglib04.cpp +++ b/cg/cglib04.cpp @@ -1727,18 +1727,21 @@ void TTransfer_file::write_tmp_movPN(TString& record,bool create) int TTransfer_file::trasfer_data_mov(TIsamtempfile& file, TRectype& dep) { - const int ln = file.num(); file.zero(); file.curr() = dep; - const bool ok = file.read() == NOERR; - file.zero(); - file.curr() = dep; - - if (ok) + if (file.read() == NOERR) + { + file.zero(); + file.curr() = dep; file.rewrite(); + } else + { + file.zero(); + file.curr() = dep; file.write(); + } return 0; } @@ -1868,7 +1871,7 @@ void TTransfer_file::write_tmp_movIVA(TString& record, bool create) { if (logicnum_p) { - trasfer_data_moviva(*file, *dep, logicnum_p, tipodoc); + trasfer_data_moviva(*file, *dep, logicnum_p); delete file; delete dep; } @@ -1959,40 +1962,22 @@ void TTransfer_file::write_tmp_movIVA(TString& record, bool create) while (trc.is_key((const char*) key)); _prog->addstatus(1); - trasfer_data_moviva(*file, *dep, logicnum_p, tipodoc); + trasfer_data_moviva(*file, *dep, logicnum_p); delete file; delete dep; } // if (trc.is_key((const char*) key)) } -int TTransfer_file::trasfer_data_moviva(TIsamtempfile& file, TRectype& dep, int ln, TString& tipodoc) +int TTransfer_file::trasfer_data_moviva(TIsamtempfile& file, TRectype& dep, int ln) { file.zero(); file.curr() = dep; - - const bool ok = file.read() == NOERR; - if (ln != LF_MOV) - { - file.zero(); - file.curr() = dep; - - if (tipodoc == "NC" || tipodoc == "ST") - { - real imp = file.get_real(RMI_IMPONIBILE); - real iva = file.get_real(RMI_IMPOSTA); - imp = imp * -1; - iva = iva * -1; - file.put(RMI_IMPONIBILE,imp); - file.put(RMI_IMPOSTA,iva); - } - - if (ok) file.rewrite(); - else file.write(); - } - else - if (ok) - { + + if (file.read() == NOERR) + { + if (ln == LF_MOV) + { TDate data74ter (dep.get_date(MOV_DATA74TER)); TString codval (dep.get (MOV_CODVALI)); TString ocfpi (dep.get (MOV_OCFPI)); @@ -2000,7 +1985,7 @@ int TTransfer_file::trasfer_data_moviva(TIsamtempfile& file, TRectype& dep, int real cambioi (dep.get_real(MOV_CAMBIOI)); real corrlire (dep.get_real(MOV_CORRLIRE)); real corrvaluta(dep.get_real(MOV_CORRVALUTA)); - + file.put(MOV_DATA74TER, data74ter); file.put(MOV_CODVALI, codval); file.put(MOV_OCFPI, ocfpi); @@ -2008,9 +1993,23 @@ int TTransfer_file::trasfer_data_moviva(TIsamtempfile& file, TRectype& dep, int file.put(MOV_CAMBIOI, cambioi); file.put(MOV_CORRLIRE, corrlire); file.put(MOV_CORRVALUTA,corrvaluta); - + file.rewrite(); } + else + { + file.zero(); + file.curr() = dep; + file.rewrite(); + } + } + else + { + file.zero(); + file.curr() = dep; + file.write(); + } + return 0; } diff --git a/cg/cglib04.h b/cg/cglib04.h index b2c0e6fd4..57824ba6c 100755 --- a/cg/cglib04.h +++ b/cg/cglib04.h @@ -213,7 +213,7 @@ private: void write_tmp_movPN(TString& record, bool create); int trasfer_data_mov(TIsamtempfile& file, TRectype& dep); void write_tmp_movIVA(TString& record, bool create); - int trasfer_data_moviva(TIsamtempfile& file, TRectype& dep, int ln, TString& tipodoc); + int trasfer_data_moviva(TIsamtempfile& file, TRectype& dep, int ln); // Funzioni per la ricezione del Saldaconto da Sistema void write_tmp_movSC(TString& record, bool create); void new_key(TString& key, int tipo, TString& buffer);