diff --git a/src/tf/tf0500.cpp b/src/tf/tf0500.cpp index 383d837e8..c615b3d32 100644 --- a/src/tf/tf0500.cpp +++ b/src/tf/tf0500.cpp @@ -32,6 +32,7 @@ const TRectype getLim(int anno, int mese) return cache().get("LIM", key); } +// Ritorna il record richiesto di ivaliq const TRectype getLiq(int anno, int mese) { TString key; key << anno << "|"; @@ -41,6 +42,13 @@ const TRectype getLiq(int anno, int mese) return cache().get(LF_IVALIQ, key); } +// Ritorna il record richiesto di tabcom.LIA +const TRectype getLia(int anno) +{ + TString key; key << format("%05d", prefix().firm().codice()) << anno; // %05d Crea un numero di 5 cifre partendo dal codice e mettendoci 0 davanti + return cache().get("%LIA", key); +} + TString formatCurrency(TString value) { real app(value); @@ -170,10 +178,10 @@ bool TIvaSend_app::generate(TIvaSend_msk& msk) ofstream file; TFilename path(msk.get(F_PATH)); - TRectype rowLim = getLim(msk.get_int(F_ANNO), msk.isMese() ? msk.get_int(F_DAMESE) : (((msk.get_int(F_DATRIMESTRE) - 1) * 3) + 1)); + TRectype rowLia = getLia(msk.get_int(F_ANNO)); // Decido di utilizzare I10 come numero progressivo di trasmissione - int prog = rowLim.get_int("I14"); prog++; + int prog = rowLia.get_int("I14"); prog++; TString nomeFile; nomeFile << "IT" << getAnagDitta().get("PAIV") << TIPO_FILE << prog << ".csv"; @@ -189,7 +197,7 @@ bool TIvaSend_app::generate(TIvaSend_msk& msk) int end = msk.isMese() ? msk.get_int(F_AMESE) : (((msk.get_int(F_ATRIMESTRE) - 1) * 3) + 1); for(; start <= end; start++) { - rowLim = getLim(msk.get_int(F_ANNO), start); // rowLim viene già usata sopra + TRectype rowLim = getLim(msk.get_int(F_ANNO), start); // rowLim viene già usata sopra TRectype rowLiq = getLiq(msk.get_int(F_ANNO), start); TToken_string riga(testata); @@ -227,9 +235,9 @@ bool TIvaSend_app::generate(TIvaSend_msk& msk) riga.add(formatCurrency(rowLiq.get("ACCDOV"))); // Acconto dovuto riga.add(formatCurrency(rowLiq.get("IVAVER"))); // IVA da versare riga.add(formatCurrency(rowLiq.get("IVAVERC"))); // IVA a credito VP14 col 2 - riga.add(prog); // Numero interno trasmissione - riga.add(""); // Flag trasmesso - riga.add(""); // Flag accettato + riga.add(prog); // Numero interno trasmissione + riga.add(""); // Flag trasmesso + riga.add(""); // Flag accettato // Appendo al file file << riga << "\n"; @@ -237,8 +245,8 @@ bool TIvaSend_app::generate(TIvaSend_msk& msk) file.close(); // Aggiorno l'univoco - rowLim.put("I14", prog); - if(rowLim.rewrite(TLocalisamfile(LF_TAB)) != NOERR) + rowLia.put("I14", prog); + if(rowLia.rewrite(TLocalisamfile(LF_TABCOM)) != NOERR) { error_box("Errore aggiornamento progressivo"); return false;