diff --git a/cg/cg6700.cpp b/cg/cg6700.cpp index 8e55ca605..d85958c24 100755 --- a/cg/cg6700.cpp +++ b/cg/cg6700.cpp @@ -1153,7 +1153,9 @@ void TRic_ListaMov::aggiorna_mov() mov.put(MOV_ANNOIVA, _annoiva); mov.put(MOV_REG, _registro); mov.put(MOV_TIPODOC, _tipodoc); - mov.put(MOV_TIPO, _tipocf); + mov.put(MOV_TIPO, _tipocf); + if (_tipodoc == "NC" || _tipodoc == "ST") + _tot_doc = _tot_doc * -1; mov.put(MOV_TOTDOC, _tot_doc); mov.rewrite(); @@ -1175,6 +1177,11 @@ void TRic_ListaMov::aggiorna_iva(char tipo) TLocalisamfile& riva = current_cursor()->file(LF_RMOVIVA); // riva.put(RMI_ANNOES, _annoese); + if (_tipodoc == "NC" || _tipodoc == "ST") + { + _impo = _impo * -1; + _impos = _impos * -1; + } riva.put(RMI_IMPONIBILE, _impo); riva.put(RMI_IMPOSTA, _impos); riva.put(RMI_TIPOC, tipo); diff --git a/cg/cg6900.h b/cg/cg6900.h index aaafd5424..6ad7c578a 100755 --- a/cg/cg6900.h +++ b/cg/cg6900.h @@ -159,6 +159,7 @@ public: void invio_righe_contabili(); void invio_righe_IVA(); void invio_occasionali(TString& record, TString& ocfpi); + void tipodocumento(long nreg,TString& tipodoc); TInv_cont(char mov); }; diff --git a/cg/cg6904.cpp b/cg/cg6904.cpp index ba3ce84f4..5c4484b26 100755 --- a/cg/cg6904.cpp +++ b/cg/cg6904.cpp @@ -744,8 +744,11 @@ void TInv_cont::invio_testata_movimenti() long codcf = _tmov->get_long(MOV_CODCF); str.format("%06ld", codcf); record.overwrite(str,174); - - real totdoc (_tmov->get_real(MOV_TOTDOC)); + + TString tipodoc (_tmov->get(MOV_TIPODOC)); + real totdoc (_tmov->get_real(MOV_TOTDOC)); + if (tipodoc == "NC" || tipodoc =="ST") + totdoc = totdoc * -1; if (totdoc.sign() < 0) { record.overwrite("-",180); @@ -952,10 +955,25 @@ void TInv_cont::invio_righe_contabili() _tras_file.close(); } +void TInv_cont::tipodocumento(long nreg, TString& tipodoc) +{ + TRecnotype rec = _tmov->recno(); + TIsamtempfile& tmov = *_tmov; + + tmov.setkey(1); + tmov.zero(); + tmov.put(MOV_NUMREG, nreg); + if (tmov.read() == NOERR) + tipodoc = tmov.get(MOV_TIPODOC); + + _tmov->readat(rec); +} + void TInv_cont::invio_righe_IVA() { int size = 1024; TString record(size); + long nreg_p = -1; long cicli = _triva->items(); _prog = new TProgind(cicli,"Movimenti Iva: generazione file TRASFER per PC\nPrego attendere.",FALSE); @@ -984,8 +1002,14 @@ void TInv_cont::invio_righe_IVA() TString codiva = _triva->get(RMI_CODIVA); str.format("%-4s", (const char*) codiva); record.overwrite(str,60); - + + TString tipodoc = ""; + if (nreg != nreg_p) + tipodocumento(nreg,tipodoc); + nreg_p = nreg; real imponibile (_triva->get_real(RMI_IMPONIBILE)); + if (tipodoc == "NC" || tipodoc =="ST") + imponibile = imponibile * -1; if (imponibile.sign() < 0) { record.overwrite("-",64); @@ -997,6 +1021,8 @@ void TInv_cont::invio_righe_IVA() record.overwrite(str,65); //Imponibile real imposta (_triva->get_real(RMI_IMPOSTA)); + if (tipodoc == "NC" || tipodoc =="ST") + imposta = imposta * -1; if (imposta.sign() < 0) { record.overwrite("-",79); diff --git a/cg/cglib04.cpp b/cg/cglib04.cpp index 51292cd3a..e3e523f75 100755 --- a/cg/cglib04.cpp +++ b/cg/cglib04.cpp @@ -4,7 +4,6 @@ #include #include #include -#include "cglib.h" #include "cglib04.h" const int size = 256; //Lunghezza del record del TRASFER @@ -1484,16 +1483,6 @@ void TTransfer_file::write_tmp_movPN(TString& record,bool create) if (fname == "TIPODOC") tipodoc = field; - - if (fname == "TOTDOC") - { - if (tipodoc == "NC" || tipodoc == "ST") - { - real totdoc (field); - totdoc = totdoc * -1; - field = totdoc.string(); - } - } } if (fname == "IMPORTO") @@ -1781,15 +1770,6 @@ void TTransfer_file::write_tmp_movIVA(TString& record, bool create) int nriga = atoi(field); field.format("%3d", nriga); } - if (fname == "IMPONIBILE" || fname == "IMPOSTA") - { - if (tipodoc == "NC" || tipodoc == "ST") - { - real imp (field); - imp = imp * -1; - field = imp.string(); - } - } } if (logicnum == LF_MOV && ( fname == "NUMREG" || flag == 2 ) ) @@ -2919,8 +2899,18 @@ void TTransfer_file::write_testata_movimenti(TString& record) } if (fname == MOV_OCFPI) - if (field.trim().empty()) - occas = FALSE; + if (field.trim().empty()) + { + TString rags = record.sub(290,340); + if (rags.trim().not_empty()) + { + TString app = "RIC"; + _npoccas++; + field.format("%3s%6d", (const char*)app,_npoccas); + } + else + occas = FALSE; + } if (flag == 2) { @@ -3410,9 +3400,16 @@ const char* riconverti (TString& data_PC,bool anno_di_quattro) int date2esc(const TDate& d, int* prevesc) { if (prevesc) *prevesc = 0; - TEsercizi_contabili esc; - int e = esc.date2esc(d); - if (prevesc) *prevesc = esc.pred(e); - return e; + TTable esc("ESC"); + for (int err = esc.first(); err == NOERR; err = esc.next()) + { + const TDate ia(esc.get("D0")); // Data inizio esercizio + const TDate fa(esc.get("D1")); // Data fine esercizio + const anno = esc.get_int("CODTAB"); + if (d >= ia && d <= fa) + return anno; + if (prevesc) *prevesc = anno; + } + return 0; }