#include #include #include #include #include #include // cache() #include // TISAM_recordset #include #include #include // TExternal_app #include // dongle() #include "..\cg\cglib01.h" #include "..\cg\cglib03.h" #include #include #include "tf0.h" #include "tf0200a.h" #define CAMPI_CON_BOOLEAN F_TOTOPATT #define CONF_MODULO "tf" #define LAST_DATACOMP_ATT "LASTCOMPATT" #define LAST_DATACOMP_PAS "LASTCOMPPAS" #define FLAG_ATT_MOD "ATTDATACOMPMOD" #define FLAG_PAS_MOD "PASDATACOMPMOD" #define STOP "$$" // ComLiqPerIva: Comunicazione Liquidazioni Periodiche IVA /** Utilities **/ // Ritorna un cursore di tab.PRM const TCursor getPRM(int anno) { static TRelation rprm(LF_TAB); TRectype from(rprm.curr()); from.put("COD", "PRM");from.put("CODTAB", anno); TRectype to(rprm.curr()); to.put("COD" , "PRM");to.put("CODTAB", anno); TCursor cprm(&rprm, "", 1, &from, &to); return cprm; } const TRectype getLIM(int anno, int mese) { TString key; key << anno; if(mese < 10) key << "0"; key << mese; return cache().get("LIM", 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); } // Ritorna il record richiesto di tabcom.LIM const TRectype getLAM(int anno, int mese) { TString key; key << anno; if(mese < 10) key << "0"; key << mese; return cache().get("LAM", key); } // Ritorna il record valido richiesto di tabcom.VER const TRectype getVER(int anno, int mese) { // Questa tabella ha come chiave l'inizio validità, creo un cursore e scorro finche non trovo l'ultimo periodo valido static TRelation rver(LF_TABCOM); static TRectype from(rver.curr()); from.put("COD", "VER"); static TRectype to(rver.curr()); to.put("COD" , "VER"); static TCursor cver(&rver, "", 1, &from, &to); // Costruisco il controllo sulla chiave TString key; key << anno; if(mese < 10) key << "0" << mese; else key << mese; TRectype row_ret(LF_TABCOM); for(cver = 0; cver.pos() < cver.items(); ++cver) { TRectype row_ver = cver.curr(); if(row_ver.get("CODTAB") < key) { row_ret = row_ver; } else break; } return row_ret; } /* Scopiazzata e divisa in due da cg4304.cpp * Calcola solo le imposte, aggiunto controllo indetraibilità, non devono essere presi in considerazione * i movimenti se indetraibili */ int calc_inc_diff(int anno, int mese, int tipoiva, real& imposta_diff, real& imposta_xcas) { CHECKD(tipoiva == 1 || tipoiva == 2, "Bad tipo iva:", tipoiva); int flag = 0; imposta_diff = imposta_xcas = ZERO; TString limit; limit << "ANNOLIQ=" << anno; if (mese < 13) limit << " MESELIQ=" << mese; TString query; // righe pagamento (TIPOMOV>=3) ed escluse NC! query << "USE IVADIFF KEY 2 SELECT (TIPOMOV>2)&&(TIPOIVA=" << tipoiva << ")" << "\nFROM " << limit << "\nTO " << limit; TISAM_recordset id(query); const TRectype& rec = id.cursor()->curr(); for (bool ok = id.move_first(); ok; ok = id.move_next()) { const real iva = rec.get_real(RMI_IMPOSTA); if (!iva.is_zero() && !rec.get_bool("INDETR")) { const int tipodiff = rec.get_int("TIPODIFF"); switch (tipodiff) { case 1: imposta_diff += iva; break; case 2: imposta_xcas += iva; break; default: break; } flag |= tipodiff; } } if (tipoiva == 2 && !rec.get_bool("INDETR")) { real perc_prorata; query = "USE PLM"; query << "\nFROM CODTAB=" << anno << "\nTO CODTAB=" << anno; TISAM_recordset ip(query); const TRectype& recp = ip.cursor()->curr(); for (bool ok = ip.move_first(); ok && perc_prorata == ZERO; ok = ip.move_next()) { int m = atoi(ip.get("CODTAB").as_string().mid(10)); real p = ip.get("R12").as_real(); if (m == mese && p != ZERO) perc_prorata = p; } if (perc_prorata > ZERO) { real ind = ZERO; if (imposta_diff > ZERO) { ind = imposta_diff * perc_prorata / CENTO; ind.round(TCurrency::get_firm_dec()); imposta_diff -= ind; } if (imposta_xcas > ZERO) { ind = imposta_xcas * perc_prorata / CENTO; ind.round(TCurrency::get_firm_dec()); imposta_xcas -= ind; } } } return flag; } /* Funzione per determinare il credito dell'anno precedente delle dichiarazioni precedenti */ void calcola_credito_prec(real& creprec, real& creaprec, bool mensile, int anno, int mese) { // Credito anno precedente /* Per calcolare il credito dell'anno precedente inizio a leggere i record precedenti su IVALIQ * fino a quando ne trovo uno >= 0. */ TRectype row_lia = getLIA(anno); if(mensile || (!mensile && ((mese - 1) % 3) == 0)) { TRelation iva_liq(LF_IVALIQ); TRectype from(iva_liq.curr()); from.put("ANNO", anno); from.put("MESE", 1); // Fino al mese precedente TRectype to(iva_liq.curr()); to.put("ANNO", anno); to.put("MESE", mese - 1); TCursor cur_liq(&iva_liq, "GENERATA!=\"G\"", 1, &from, &to); bool trovato = false; for(cur_liq = 0; cur_liq.pos() < cur_liq.items(); ++cur_liq) { TRectype row_liq = cur_liq.curr(); if(row_liq.get_int("MESE") >= mese) break; // Perchè li prende lo stesso? trovato = trovato || row_liq.get_real("CREAPREC") > ZERO; creprec = row_liq.get_real("IVAVERC"); } /* Se non ho trovato nessun valore positivo (i negativi senza nessun positivo prima non sono validi) * vado a leggere la liquidazione di quest'anno */ if(!trovato && mese == 1) { creaprec = row_lia.get_real("R0"); } } } class TCom_liq_per_iva_msk : public TAutomask { bool _last_elab_att; // Flags per controllare se hanno cambiato il tipo di elaborazione (data competenza) bool _last_elab_pas; protected: bool _mensile; // Aggiunta questa variabile per specificare se è stato impostato un tipo di liquidazione. // In Release sembra che durante la ricerca salta l'inizializzazione e imposta prima gli altri campi bool _init_liq; TRectype _true_data; void write_datacomp_mod(bool enabled, bool attive); virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); void extractinator(); void check_old_value(int field, const real& val); public: TCom_liq_per_iva_msk() : TAutomask("tf0200a"), _true_data(LF_IVALIQ), _init_liq(false) { _last_elab_att = ini_get_bool(CONFIG_DITTA, CONF_MODULO, LAST_DATACOMP_ATT, false); _last_elab_pas = ini_get_bool(CONFIG_DITTA, CONF_MODULO, LAST_DATACOMP_PAS, false); first_focus(F_ANNO); } void save_gen(); }; void TCom_liq_per_iva_msk::write_datacomp_mod(const bool enabled, bool attive) { int count = 0; TString line; const TDate today(TODAY); TString mod; mod << user() << (enabled ? "|E|" : "|D|") << today.month() << "." << today.day(); if (attive) { line = ini_get_string(CONFIG_DITTA, CONF_MODULO, FLAG_ATT_MOD, STOP, count); for (; line != STOP; line = ini_get_string(CONFIG_DITTA, CONF_MODULO, FLAG_ATT_MOD, STOP, ++count)) {} ini_set_string(CONFIG_DITTA, CONF_MODULO, FLAG_ATT_MOD, mod, count); ini_set_bool(CONFIG_DITTA, CONF_MODULO, LAST_DATACOMP_ATT, enabled); _last_elab_att = enabled; } else { line = ini_get_string(CONFIG_DITTA, CONF_MODULO, FLAG_PAS_MOD, STOP, count); for (; line != STOP; line = ini_get_string(CONFIG_DITTA, CONF_MODULO, FLAG_PAS_MOD, STOP, ++count)) {} ini_set_string(CONFIG_DITTA, CONF_MODULO, FLAG_PAS_MOD, mod, count); ini_set_bool(CONFIG_DITTA, CONF_MODULO, LAST_DATACOMP_PAS, enabled); _last_elab_pas = enabled; } } bool TCom_liq_per_iva_msk::on_field_event(TOperable_field& o, TField_event e, long jolly) { switch (o.dlg()) { case F_ANNO: if(e == fe_modify) { TString cod = get(F_CODDITTA); cod << get_int(F_ANNO); if(cache().get("%LIA", cod).empty()) { warning_box("Attenzione anno di liquidazione non presente"); set(F_ANNO, ""); break; } if(cache().get("%LIA", cod, "S7") == "M") { _mensile = true; _init_liq = true; enable(F_MESE); disable(F_TRIMESTRE); } else { _mensile = false; _init_liq = true; disable(F_MESE); enable(F_TRIMESTRE); } } break; case F_MESE: if(e == fe_modify && _mensile && _init_liq) set(F_TRIMESTRE, (get_int(F_MESE) - 1) / 3 + 1); break; case F_TRIMESTRE: if(e == fe_init && !query_mode()) disable(F_TRIMESTRE); if(e == fe_modify && !_mensile && _init_liq && query_mode()) { set(F_MESE, get_int(F_TRIMESTRE) * 3); disable(F_TRIMESTRE); send_key(K_TAB, F_ANNO); } break; case DLG_CANCEL: enable(F_TRIMESTRE); break; case DLG_RECALC: // Vado a prendere i dati di quel mese dalla liquidazione IVA if(e == fe_button) { // Controllo che non ci sia già if(!cache().get(LF_IVALIQ, TString(get(F_ANNO)) << "|" << get(F_MESE) << "|U").empty()) { if(!yesno_box("Sono già stati elaborati questi dati, si desidera ricalcolarli?")) break; } extractinator(); } break; case DLG_EMAIL: { if(e == fe_button) { // Richiamo il programma di invio TExternal_app invio_app("tf0 -4"); invio_app.run(); } } break; case F_ATT_COMP: if(e == fe_init) set(F_ATT_COMP, _last_elab_att ? "X" : " "); else if(e == fe_modify) warning_box("Attenzione la modifica di questo valore comporta un diverso calcolo dei rigo VP2. L'utente è pregato di controllarne la correttezza.\nSi consiglia di ricalcolare e rispedire tutti periodi dell'anno"); break; case F_PAS_COMP: if (e == fe_init) set(F_PAS_COMP, _last_elab_pas ? "X" : " "); else if (e == fe_modify) warning_box("Attenzione la modifica di questo valore comporta un diverso calcolo dei rigo VP3. L'utente è pregato di controllarne la correttezza.\nSi consiglia di ricalcolare e rispedire tutti periodi dell'anno"); break; case DLG_SAVEREC: if(e == fe_button) { bool att_dt_comp = get_bool(F_ATT_COMP); bool pas_dt_comp = get_bool(F_PAS_COMP); if (att_dt_comp != _last_elab_att) write_datacomp_mod(att_dt_comp, true); if (pas_dt_comp != _last_elab_pas) write_datacomp_mod(pas_dt_comp, false); } if(e != fe_init && !_true_data.empty()) _true_data.write_rewrite(TLocalisamfile(LF_IVALIQ)); } if(o.dlg() >= CAMPI_CON_BOOLEAN && o.dlg() <= F_IMPNOVER && e == fe_modify) // Se l'utente modifica manualmente uno dei campi calcolati da Campo flaggo il DB { check_old_value(o.dlg(), get_real(o.dlg())); } // Controllo sull'aggiornamento di campi collegati ad altri if(e == fe_modify) { switch(o.dlg()) { // Iva Esigibile VS Iva Detratta case F_IVAES : case F_IVAESXC : case F_IVAESDIFF : case F_IVADET : case F_IVADETXC : case F_IVADETDIFF : { real ivaes = get_real(F_IVAES); real ivadet = get_real(F_IVADET); if((ivaes - ivadet) >= ZERO) { set(F_IVADOV, ivaes - ivadet); set(F_IVADOVC, ZERO); check_old_value(F_IVADOV, ivaes - ivadet); check_old_value(F_IVADOVC, ""); } else { set(F_IVADOV, ZERO); set(F_IVADOVC, (ivaes - ivadet) * -UNO); check_old_value(F_IVADOV, ""); check_old_value(F_IVADOVC, (ivaes - ivadet) * -UNO); } } // IVA da versare VS a credito case F_IVADOV : case F_DEBPREC : case F_INTLIQTRI : case F_IVADOVC : case F_CREPREC : case F_CREAPREC : case F_VEAUE : case F_CREIMP : case F_ACCDOV : { // Ricalcolo VP13 e VP14 real debito = get_real(F_IVADOV) + get_real(F_DEBPREC) + get_real(F_INTLIQTRI); /* Se il credito anno precedente è negativo devo mantenerlo tale ma sottrarlo al credito dell'anno precedente delle dichiarazioni precedenti */ real creaprec = get_real(F_CREAPREC); if(creaprec < ZERO) { real creprec = ZERO; real appcreaprec; calcola_credito_prec(creprec, appcreaprec, _mensile, get_int(F_ANNO), get_int(F_MESE)); creaprec = appcreaprec + creaprec; } real credito = get_real(F_IVADOVC) + get_real(F_CREPREC) + creaprec + get_real(F_VEAUE) + get_real(F_CREIMP) + get_real(F_ACCDOV); if(debito - credito >= ZERO) { set(F_IVAVER, debito - credito); set(F_IVAVERC, ZERO); check_old_value(F_IVAVER, debito - credito); check_old_value(F_IVAVERC, ""); } else { set(F_IVAVER, ZERO); set(F_IVAVERC, credito - debito); check_old_value(F_IVAVER, ""); check_old_value(F_IVAVERC, credito - debito); } } break; } } return true; } // Funzione che effettivamente estrapola i dati necessari void TCom_liq_per_iva_msk::extractinator() // Per gli amici GTFO { /* Devo estrapolare più mesi, per farlo vado ciclo n volte (1 o 3) in base se stiamo parlando di trimestralità o meno * I dati da prelevare saranno in PRM, LIM e %LIA * In PRM e LIM troverò le informazioni suddivise per mese, mentre in %LIA ho l'anno di liquidazione */ int start = _mensile ? get_int(F_MESE) : (((get_int(F_TRIMESTRE) - 1) * 3) + 1); int end = _mensile ? start : start + 2; int anno = get_int(F_ANNO); // Valori da calcolare real totopatt = ZERO; real totopattxc = ZERO; real totoppas = ZERO; real totoppasxc = ZERO; real ivaes = ZERO; real ivaesxc = ZERO; real ivaesdiff = ZERO; real ivadet = ZERO; real ivadetxc = ZERO; real ivadetdiff = ZERO; real rettifiche = ZERO; real varimp = ZERO; real rimborsi = ZERO; real impnover = ZERO; real crespec = ZERO; real vereff = ZERO; real ivadov = ZERO; real ivadovc = ZERO; real debprec = ZERO; real creprec = ZERO; real creaprec = ZERO; real intliqtri = ZERO; real accdov = ZERO; real ivaver = ZERO; real ivaverc = ZERO; const bool att_dt_comp = get_bool(F_ATT_COMP); const bool pas_dt_comp = get_bool(F_PAS_COMP); for(; start <= end; start++) { TDate data_da(1, start, anno); TDate data_a; if (start == 12) { data_a = TDate(1, 12, anno); data_a.set_end_month(); } else { data_a = TDate(1, start + 1, anno); data_a.set_end_month(); } bool has_ixc = gestione_IVAxCassa(data_da); /**************************************************************************************************************** * TOTOPATT, TOTOPATTXC, TOTOPPAS, TOTOPPASXC, IVAES, IVAESXC, IVAESDIFF, * IVADET , IVADETXC, IVADETDIFF ****************************************************************************************************************/ // Riga LIM const TRectype row_lim = getLIM(anno, start); // Controllo che la liquidazione è stata effettuata, controllo da fare solo nella 12 if (dongle().year_assist() > 2121 && (row_lim.empty() || row_lim.get_bool("B0")) && !yesno_box("Attenzione non e' stata calcolata la liquidazione del periodo corrente, si desidera proseguire ugualmente?")) { return; } // Riga LIA const TRectype row_lia = getLIA(anno); TString query_iva = "USE RMOVIVA\n"; query_iva << "SELECT ( " << FIELD_NAME(LF_MOV, MOV_REG) << "!=\"\")&&BETWEEN( " << FIELD_NAME(LF_MOV, MOV_DATAREG) << ",#DADATAREG,#ADATAREG)"; // scritto FIELD_NAME meglio usarla query_iva << "\nJOIN MOV INTO " << MOV_NUMREG << "==" << MOV_NUMREG << "\n"; TISAM_recordset cur_iva(query_iva); cur_iva.set_var("#DADATAREG", data_da); cur_iva.set_var("#ADATAREG", data_a); for (bool ok = cur_iva.move_first(); ok; ok = cur_iva.move_next()) { TString totat, totpas, i; // Controllo che sia un movimento con codice non "non soggetto" TCodiceIVA codiva(cur_iva.get(FIELD_NAME(LF_RMOVIVA, RMI_CODIVA)).as_string()); if (codiva.tipo() == "NS") continue; // Controllo che la registrazione sia di del mese che mi interessa o con flag "liquidazione periodo precedente" const int month_reg = cur_iva.get("23." MOV_DATAREG).as_date().month(); const int month_liq = cur_iva.get("23." MOV_MESELIQ).as_int(); // month_liq viene valorizzato solo se è del mese precedente o sempre? Nei record vecchi ovviamente sarà a zero ma adesso che ci mette? // Prendo il tipo di registro TRegistro reg(cur_iva.get(FIELD_NAME(LF_MOV, MOV_REG)).as_string(), anno); int tiporeg = reg.tipo(); bool is_corrispettivo = reg.corrispettivi(); // Prendiamo l'imponibile real imp = cur_iva.get("25.IMPONIBILE").as_real(); real imposta = cur_iva.get("25.IMPOSTA").as_real(); if (tiporeg == iva_acquisti) { bool pt_nel_m_prec = month_reg == start && month_liq != month_reg && month_liq != 0; bool mese_succ_non_comp = month_reg != start && (month_liq == month_reg || month_liq == 0); if ( (!pas_dt_comp && month_reg != start) || (pas_dt_comp && (start != 12 && mese_succ_non_comp || start != 1 && pt_nel_m_prec) ) ) continue; } else { bool pt_nel_m_prec = month_reg == start && month_liq != month_reg && month_liq != 0; bool mese_succ_non_comp = month_reg != start && (month_liq == month_reg || month_liq == 0); if ((!att_dt_comp && month_reg != start) || (att_dt_comp && (start != 12 && mese_succ_non_comp || start != 1 && pt_nel_m_prec) ) ) continue; } // Se è un movimento IvaXCassa o LiqDiff if (has_ixc && (cur_iva.get("23.IVAXCASSA").as_bool() || cur_iva.get("23.LIQDIFF").as_bool())) { if (tiporeg == iva_vendite) totopattxc += imp; else totoppasxc += imp; } else { if (tiporeg == iva_vendite) { // Controllo il reverse charge, non va calcolato nel totale delle operazioni attive! // Se non ha una riga di movimento non lo sommo TString key_rc = cur_iva.get("23.NUMREG").as_string(); key_rc << "|1"; if (!cache().get(LF_RMOV, key_rc).empty()) { // Controllo se è un corrispettivo non scorporato (imponibile e iva assieme) if (is_corrispettivo && codiva.percentuale() > ZERO && imposta == ZERO) { // Nell'imponibile è presente il totale fattura, devo calcolare l'imposta e sottrarla // Es iva 22% => imp : 122 = x : 100 codiva.scorpora(imp); } totopatt += imp; } } else totoppas += imp; } } // Sommiamo i corrispettivi al registro delle vendite // Se ha attiva l'IVA x cassa calcolo le imposte (imponibili per comodità già calcolati sopra) if(has_ixc) { // IVA esigibile real imposta_diff, imposta_xcas; imposta_diff = imposta_xcas = ZERO; // 1 = Vendite calc_inc_diff(anno, start, iva_vendite, imposta_diff, imposta_xcas); ivaesxc = ivaesxc + imposta_xcas; ivaesdiff = ivaesdiff + imposta_diff; // IVA detraibile imposta_diff = imposta_xcas = ZERO; // 2 = Acquisti calc_inc_diff(anno, start, iva_acquisti, imposta_diff, imposta_xcas); ivadetxc = ivadetxc + imposta_xcas; ivadetdiff = ivadetdiff + imposta_diff; } /** Resto *****************************************************************************************************/ TRectype row_lam = getLAM(anno, start); /* É saltato fuori che in caso di liquidazione trimestrale l'importo ivaes e ivadet * viene scritto su ogni mese, quindi prendo solo quando * start == end -> iva mensile o ultimo mese della trimestrale */ if(start == end) { ivaes += row_lam.get_real("R0"); ivadet += row_lam.get_real("R1"); } ivaes += ivaesxc + ivaesdiff; ivadet += ivadetxc + ivadetdiff; rettifiche = rettifiche + row_lim.get_real("R5"); varimp = varimp + row_lim.get_real("R17"); rimborsi = rimborsi + row_lim.get_real("R1"); impnover = impnover + row_lim.get_real("R18"); crespec = crespec + row_lim.get_real("R19"); vereff = vereff + row_lim.get_real("R8"); debprec = debprec + row_lim.get_real("S2"); real app_real = ZERO; // Credito periodo precedente e anno precedente calcola_credito_prec(creprec, creaprec, _mensile, anno, start); if(creaprec < ZERO) creaprec = ZERO; intliqtri = intliqtri + row_lim.get_real("R14"); accdov = accdov + row_lim.get_real("R11"); } // Controllo debprec // Calcolo prendendo dalla tabella %VER TRectype row_ver = getVER(anno, start); if(row_ver.empty() || row_ver.get_real("R5") == ZERO) { error_box("Non è stata valorizzato correttamente il campo \"Periodico\" in \"Versamenti ed interessi IVA\""); return; } else { if(debprec > row_ver.get_real("R5")) // Se è maggiore di 25.82€ va azzerato debprec = ZERO; } // Calcolo ivadov/ivadovc ivadov = ivaes - ivadet; ivadovc = ivadet - ivaes; if(ivadov > ZERO) { ivadovc = ZERO; } else { ivadov = ZERO; } // Calcolo l'IVA da versare o a Credito if (!_mensile && get_int(F_TRIMESTRE) == 5) { ivaver = ZERO; ivaverc = ZERO; } else { ivaver = (ivadov + debprec + intliqtri) - (ivadovc + creprec + creaprec + get_real(F_VEAUE) + get_real(F_CREIMP) + accdov); ivaverc = (ivadovc + creprec + creaprec + get_real(F_VEAUE) + get_real(F_CREIMP) + accdov) - (ivadov + debprec + intliqtri); // Controllo quale va sotto zero e la tolgo if (ivaver >= ZERO) { ivaverc = ZERO; } else { ivaver = ZERO; } } // Sommo i totali con i totali xc totopatt += totopattxc; totoppas += totoppasxc; // Imposto tutti i campi set(F_TOTOPATT, totopatt); set(F_TOTOPATTXC, totopattxc); set(F_TOTOPPAS, totoppas); set(F_TOTOPPASXC, totoppasxc); set(F_IVAES, ivaes); set(F_IVAESXC, ivaesxc); set(F_IVAESDIFF, ivaesdiff); set(F_IVADET, ivadet); set(F_IVADETXC, ivadetxc); set(F_IVADETDIFF, ivadetdiff); set(F_IVADOV, ivadov); set(F_IVADOVC, ivadovc); set(F_DEBPREC, debprec); set(F_CREPREC, creprec); set(F_CREAPREC, creaprec); //set(F_VEAUE, veaue); // Campi non calcolati, messi qua per un eventuale futuro //set(F_CREIMP, creimp); set(F_INTLIQTRI, intliqtri); set(F_ACCDOV, accdov); set(F_IVAVER, ivaver); set(F_IVAVERC, ivaverc); set(F_RETTIFICHE, rettifiche); set(F_VARIMP, varimp); set(F_RIMBORSI, rimborsi); set(F_IMPNOVER, impnover); set(F_CRESPEC, crespec); set(F_VEREFF, vereff); // Preparo il record save_gen(); // Azzero i booleani for(int i = B_TOTOPATT; i <= B_CRESPEC; i++) { set(i, ""); } } void TCom_liq_per_iva_msk::save_gen() { // Assegno tutti i campi _true_data.put("ANNO", get(F_ANNO)); _true_data.put("MESE", get(F_MESE)); _true_data.put("TRIMESTRE", get(F_TRIMESTRE)); _true_data.put("GENERATA", 'G'); // Segno che è generata da campo _true_data.put("TOTOPATT", get(F_TOTOPATT)); _true_data.put("TOTOPATTXC", get(F_TOTOPATTXC)); _true_data.put("TOTOPPAS", get(F_TOTOPPAS)); _true_data.put("TOTOPPASXC", get(F_TOTOPPASXC)); _true_data.put("IVAES", get(F_IVAES)); _true_data.put("IVAESXC", get(F_IVAESXC)); _true_data.put("IVAESDIFF", get(F_IVAESDIFF)); _true_data.put("IVADET", get(F_IVADET)); _true_data.put("IVADETXC", get(F_IVADETXC)); _true_data.put("IVADETDIFF", get(F_IVADETDIFF)); _true_data.put("IVADOV", get(F_IVADOV)); _true_data.put("IVADOVC", get(F_IVADOVC)); _true_data.put("DEBPREC", get(F_DEBPREC)); _true_data.put("CREPREC", get(F_CREPREC)); _true_data.put("CREAPREC", get(F_CREAPREC)); _true_data.put("VEAUE", get(F_VEAUE)); _true_data.put("CREIMP", get(F_CREIMP)); _true_data.put("INTLIQTRI", get(F_INTLIQTRI)); _true_data.put("ACCDOV", get(F_ACCDOV)); _true_data.put("IVAVER", get(F_IVAVER)); _true_data.put("IVAVERC", get(F_IVAVERC)); _true_data.put("RETTIFICHE", get(F_RETTIFICHE)); _true_data.put("VARIMP", get(F_VARIMP)); _true_data.put("RIMBORSI", get(F_RIMBORSI)); _true_data.put("CRESPEC", get(F_CRESPEC)); _true_data.put("IMPNOVER", get(F_IMPNOVER)); _true_data.put("VEREFF", get(F_VEREFF)); } void TCom_liq_per_iva_msk::check_old_value(int field, const real& val) { if(_true_data.empty()) { TString key; key << get(F_ANNO) << "|" << get(F_MESE) << "|G"; _true_data = cache().get(LF_IVALIQ, key); } real true_val = ZERO; // Modo più intelligente di uno stupido switch case? switch(field) { case F_TOTOPATT: true_val = _true_data.get_real("TOTOPATT"); break; case F_TOTOPATTXC: true_val = _true_data.get_real("TOTOPATTXC"); break; case F_TOTOPPAS: true_val = _true_data.get_real("TOTOPPAS"); break; case F_TOTOPPASXC: true_val = _true_data.get_real("TOTOPPASXC"); break; case F_IVAES: true_val = _true_data.get_real("IVAES"); break; case F_IVAESXC: true_val = _true_data.get_real("IVAESXC"); break; case F_IVAESDIFF: true_val = _true_data.get_real("IVAESDIFF"); break; case F_IVADET: true_val = _true_data.get_real("IVADET"); break; case F_IVADETXC: true_val = _true_data.get_real("IVADETXC"); break; case F_IVADETDIFF: true_val = _true_data.get_real("IVADETDIFF"); break; case F_IVADOV: true_val = _true_data.get_real("IVADOV"); break; case F_IVADOVC: true_val = _true_data.get_real("IVADOVC"); break; case F_DEBPREC: true_val = _true_data.get_real("DEBPREC"); break; case F_CREPREC: true_val = _true_data.get_real("CREPREC"); break; case F_CREAPREC: true_val = _true_data.get_real("CREAPREC"); break; case F_VEAUE: true_val = _true_data.get_real("VEAUE"); break; case F_CREIMP: true_val = _true_data.get_real("CREIMP"); break; case F_INTLIQTRI: true_val = _true_data.get_real("INTLIQTRI"); break; case F_ACCDOV: true_val = _true_data.get_real("ACCDOV"); break; case F_IVAVER: true_val = _true_data.get_real("IVAVER"); break; case F_IVAVERC: true_val = _true_data.get_real("IVAVERC"); break; case F_RETTIFICHE: true_val = _true_data.get_real("RETTIFICHE"); break; case F_VARIMP: true_val = _true_data.get_real("VARIMP"); break; case F_RIMBORSI: true_val = _true_data.get_real("RIMBORSI"); break; case F_CRESPEC: true_val = _true_data.get_real("CRESPEC"); break; case F_IMPNOVER: true_val = _true_data.get_real("IMPNOVER"); break; case F_VEREFF: true_val = _true_data.get_real("VEREFF"); break; } set(field + 50, true_val != val ? "X" : ""); } class TCom_liq_per_iva_app : public TRelation_application { private: TCom_liq_per_iva_msk* _mask; TRelation* _rel; protected: bool user_create(); bool user_destroy(); virtual TMask* get_mask(int mode) { return _mask; } public: virtual TRelation* get_relation() const {return (TRelation*)_rel;} }; bool TCom_liq_per_iva_app::user_create() { _rel = new TRelation(LF_IVALIQ); _mask = new TCom_liq_per_iva_msk; set_search_field(F_ANNO); return true; } bool TCom_liq_per_iva_app::user_destroy() { delete _mask; return true; } int tf0200(int argc, char* argv[]) { TCom_liq_per_iva_app app; app.run(argc, argv, TR("Trasferimento dati liquidazione IVA")); return 0; }