diff --git a/src/tf/tf0200.cpp b/src/tf/tf0200.cpp index 4fd26190f..79b6fd3bf 100644 --- a/src/tf/tf0200.cpp +++ b/src/tf/tf0200.cpp @@ -7,6 +7,7 @@ #include #include #include // TExternal_app +#include // dongle() #include "cglib03.h" @@ -184,7 +185,7 @@ void calcolaCreditoPrec(real& creprec, real& creaprec, bool mensile, int anno, i if(rowLiq.get_real("IVAVER") == ZERO) { - creprec = rowLiq.get_real("CREPREC") + rowLiq.get_real("IVADOVC"); + creprec = rowLiq.get_real("IVAVERC"); // Possono esserci valori negativi, nel caso vanno sommati altrimenti sostituisco if(rowLiq.get_real("CREAPREC") < ZERO) creaprec += rowLiq.get_real("CREAPREC"); @@ -443,8 +444,8 @@ void ComLiqPerIva_mask::extractinator() // Per gli amici GTFO // Riga LIM const TRectype rowLim = getLIM(anno, start); - // Controllo che la liquidazione è stata effettuata - if(rowLim.empty() || rowLim.get_bool("B0")) + // Controllo che la liquidazione è stata effettuata, controllo da fare solo nella 12 + if(dongle().year_assist() > 2121 && (rowLim.empty() || rowLim.get_bool("B0"))) { error_box("Attenzione non è stata calcolata la liquidazione del periodo corrente"); return; @@ -456,9 +457,9 @@ void ComLiqPerIva_mask::extractinator() // Per gli amici GTFO /* Sembra che in PAM ci sia già tutto quello che mi serve! * Chiave PAM: ANNO + COD_ATTIVITA' + MESE */ static TRelation rpam(LF_TAB); - TRectype from(rpam.curr()); from.put("COD", "PAM");from.put("CODTAB", anno); - TRectype to(rpam.curr()); to.put("COD" , "PAM");to.put("CODTAB", anno); - TCursor curPam(&rpam, "", 1, &from, &to); + TRectype pamFrom(rpam.curr()); pamFrom.put("COD", "PAM");pamFrom.put("CODTAB", anno); + TRectype pamTo(rpam.curr()); pamTo.put("COD" , "PAM");pamTo.put("CODTAB", anno); + TCursor curPam(&rpam, "", 1, &pamFrom, &pamTo); for(curPam = 0; curPam.pos() < curPam.items(); ++curPam) { TRectype rowPam = curPam.curr(); @@ -467,6 +468,53 @@ void ComLiqPerIva_mask::extractinator() // Per gli amici GTFO totoppas = totoppas + rowPam.get_real("R0"); } + // Devo sottrarre gli indetraibili, quindi prendo prm e sottraggo + static TRelation rprm(LF_TAB); + TRectype prmFrom(rprm.curr()); prmFrom.put("COD", "PRM");prmFrom.put("CODTAB", anno); + TRectype prmTo(rprm.curr()); prmTo.put("COD" , "PRM");prmTo.put("CODTAB", anno); + + TCursor curPrm(&rprm, "", 1, &prmFrom, &prmTo); + for(curPrm = 0; curPrm.pos() < curPrm.items(); ++curPrm) + { + TRectype rowPrm = curPrm.curr(); + // Controllo il mese + TString codtab = rowPrm.get("CODTAB"); + if(atoi(rowPrm.get("CODTAB").sub(13,15)) != start) continue; + + // Verifico su che registro mi trovo + int tiporeg = rowPrm.get_int("I1"); + /* + bool detraibile = atoi(rowPrm.get("CODTAB").mid(20,1)) == 0; // Se > è indetraibile + // Tutti i non detraibili sono passivi ma un controllo in più non fa mai male + if(!detraibile && tiporeg == reg_pas) + { + totoppas = totoppas + rowPrm.get_real("R0"); + } + */ + // Verifico che sia Non soggetto + bool nonSogg = rowPrm.get("S5") == "NS"; + if(nonSogg && tiporeg == reg_pas) + { + totoppas = totoppas - rowPrm.get_real("R0"); + } + else if (nonSogg && tiporeg == reg_att) + { + totopatt = totopatt - rowPrm.get_real("R0"); + } + } + + // Aggiungo gli indeducibili per articolo 19 + static TRelation rpom(LF_TAB); + TRectype pomFrom(rpom.curr()); pomFrom.put("COD", "POM");pomFrom.put("CODTAB", anno); + TRectype pomTo(rpom.curr()); pomTo.put("COD" , "POM");pomTo.put("CODTAB", anno); + TCursor curPom(&rpom, "", 1, &pomFrom, &pomTo); + for(curPom = 0; curPom.pos() < curPom.items(); ++curPom) + { + TRectype rowPom = curPom.curr(); + if(atoi(rowPom.get("CODTAB").right(2)) != start) continue; + totoppas = totoppas + rowPom.get_real("R1"); + } + // Se ha attiva l'IVA x cassa if(gestione_IVAxCassa(data_da)) {