From 5fde0436de192887837762ee5e02a4967ffea685 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 25 Feb 2016 11:30:51 +0000 Subject: [PATCH] Nuova comunicazione annuale IVA Nuovi dari per CU git-svn-id: svn://10.65.10.50/branches/R_10_00@23176 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg0200.cpp | 43 +- cg/cg0200.h | 1 + cg/cg0200a.uml | 9 +- cg/cg2102.cpp | 10 +- cg/cg3900.cpp | 1 + cg/cg4300.cpp | 14 +- cg/cg4300.h | 2 +- cg/cg4301.cpp | 296 +++++++----- cg/cg4303.cpp | 8 +- cg/cg4304.cpp | 114 ++--- cg/cg4400.cpp | 6 +- cg/cg5100.cpp | 22 +- cg/cg5100a.uml | 12 +- cg/cg5200.cpp | 30 +- cg/cg5300.cpp | 26 +- cg/cg5300a.uml | 4 +- cg/cg5400.cpp | 8 +- cg/cg5500.h | 4 +- cg/cg5501.cpp | 6 +- cg/cg5600.cpp | 6 +- cg/cg5700.cpp | 1209 +++++++++++++++++++++++++++------------------- cg/cg5700.h | 1 + cg/cg5700a.uml | 15 +- cg/cg5700b.uml | 70 +-- cg/cg5800.cpp | 2 +- cg/cg5800ra.rep | 2 +- cg/cglib01.cpp | 5 +- cg/cglib03.cpp | 2 +- cg/cgmenu.men | 3 +- cg/cgstsplit.rep | 114 +++++ cg/cgstsplit.uml | 20 + cg/cgtbbnp.h | 1 + cg/cgtbbnp.uml | 10 +- 33 files changed, 1247 insertions(+), 829 deletions(-) create mode 100644 cg/cgstsplit.rep create mode 100644 cg/cgstsplit.uml diff --git a/cg/cg0200.cpp b/cg/cg0200.cpp index 7e7dbbf98..1628952cc 100755 --- a/cg/cg0200.cpp +++ b/cg/cg0200.cpp @@ -74,6 +74,8 @@ protected: static bool tipo_handler(TMask_field& f, KEY key); static bool crea_percipienti(TMask_field& f, KEY key); static bool percip_handler(TMask_field& f, KEY key); + static bool previd_handler(TMask_field& f, KEY key); + static bool email_handler(TMask_field& f, KEY k); static bool rsoc_handler(TMask_field& f, KEY k); static bool comi_handler(TMask_field& f, KEY k); @@ -300,7 +302,6 @@ bool TClifo_application::tipo_handler(TMask_field& f, KEY key) TMask& m = f.mask(); const bool fis = f.get() == "F"; m.show(-5, fis); - return true; } @@ -348,7 +349,7 @@ bool TClifo_application::crea_percipienti(TMask_field& f, KEY key) if (anag.read() == NOERR) { m.set(F_CODANAGPER, percip); - message_box(TR("Esiste già una anagrafica corrispondente al fornitore")); + warning_box(TR("Esiste già una anagrafica corrispondente al fornitore")); return true; } } @@ -411,26 +412,25 @@ bool TClifo_application::crea_percipienti(TMask_field& f, KEY key) bool TClifo_application::percip_handler(TMask_field& f, KEY key) { TMask& m = f.mask(); - const bool full = f.get().full(); if (f.to_check(key, true)) + { + const bool full = !f.empty(); m.enable(DLG_ANAG, !full); - + m.enable(DLG_PERC, full && main_app().has_module(M77AUT)); + } if (f.to_check(key) && full) { const long percip = m.get_long(F_CODANAGPER); const char tipo = m.get(F_TIPOAPER)[0]; - TToken_string k; - - k.add(tipo); - k.add(percip); - const TRectype & anag = cache().get(LF_ANAG, k); - const TString& c = m.get(F_COFI), p = m.get(F_PAIV); - + TToken_string k; k.add(tipo); k.add(percip); + const TRectype& anag = cache().get(LF_ANAG, k); if (key == K_TAB && anag.empty()) return true; - if ((c.full() && c != anag.get(ANA_COFI)) || + const TString& c = m.get(F_COFI); + const TString& p = m.get(F_PAIV); + if ((c.full() && c != anag.get(ANA_COFI)) || (p.full() && p != anag.get(ANA_PAIV))) return error_box(TR("Percipiente non corretto: codice fiscale o partita IVA diversa")); @@ -468,6 +468,24 @@ bool TClifo_application::percip_handler(TMask_field& f, KEY key) return true; } +bool TClifo_application::previd_handler(TMask_field& f, KEY key) +{ + if (key == K_SPACE) + { + const TMask& m = f.mask(); + const TEdit_field& cod = m.efield(F_CODANAGPER); + if (cod.empty()) + return cod.error_box(TR("Specificare un'anagrafica valida")); + + TRectype rec(LF_PERC); + rec.put("CODDITTA", main_app().get_firm()); + rec.put("TIPOA", m.get(F_TIPOAPER)); + rec.put("CODANAGR", cod.get()); + rec.edit(LF_PERC, NULL, "770 -2"); + } + return true; +} + bool TClifo_application::email_handler(TMask_field& f, KEY k) { if (k == K_SPACE) @@ -1499,6 +1517,7 @@ bool TClifo_application::user_create() // initvar e arrmask _msk->set_handler(F_CODANAGPER, percip_handler); _msk->set_handler(F_TIPOPERS, tipo_handler); _msk->set_handler(DLG_ANAG, crea_percipienti); + _msk->set_handler(DLG_PERC, previd_handler); _msk->set_handler(F_ALLEG, alleg_handler); _msk->set_handler(F_CODALLEG, codalleg_handler); _msk->set_handler(DLG_EMAIL, email_handler); diff --git a/cg/cg0200.h b/cg/cg0200.h index 0ce3bae58..ba8153894 100755 --- a/cg/cg0200.h +++ b/cg/cg0200.h @@ -181,6 +181,7 @@ #define F_DESENTE 314 #define F_INDENTE 315 #define F_SPLITPAY 316 +#define DLG_PERC 317 #define F_TPIMBALLO 401 #define F_DIMENSIONE 402 diff --git a/cg/cg0200a.uml b/cg/cg0200a.uml index 72af0c886..13cf8342e 100755 --- a/cg/cg0200a.uml +++ b/cg/cg0200a.uml @@ -608,7 +608,7 @@ END LIST F_SESSO 1 12 BEGIN - PROMPT 38 17 "Sesso" + PROMPT 34 17 "Sesso" HELP "Sesso della persona fisica" ITEM "M|Maschio" ITEM "F|Femmina" @@ -616,6 +616,13 @@ BEGIN GROUP 5 END +BUTTON DLG_PERC 15 1 +BEGIN + PROMPT 57 17 "Dati Previdenziali" + GROUP 4 +END + + NUMBER F_STATONASC 3 BEGIN PROMPT 2 18 "Stato " diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index aa9f5e73f..00225ffca 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -3157,13 +3157,21 @@ bool TPrimanota_application::liqdiff_handler(TMask_field& f, KEY key) // Certified 99% bool TPrimanota_application::ivaxcassa_handler(TMask_field& f, KEY key) { - if (key == K_SPACE && f.mask().is_running()) + const TMask& m = f.mask(); + if (key == K_SPACE && m.is_running()) force_iva_det_bill(); if (key == K_ENTER && f.get().full()) { if (app().is_fattura_split()) return f.error_box(TR("Non è ammessa IVA per cassa con split payment")); + if (m.get(F_CLIFO) == "C") + { + TString8 key; key.format("C|%ld", m.get_long(F_CLIENTE)); + const TRectype& clifo = cache().get(LF_CLIFO, key); + if (clifo.get_int(CLI_ALLEG) == 6) + return f.error_box(TR("Non è ammessa IVA per cassa con clienti privati")); + } } return true; diff --git a/cg/cg3900.cpp b/cg/cg3900.cpp index b4c0a2fe2..c7c189e85 100755 --- a/cg/cg3900.cpp +++ b/cg/cg3900.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/cg/cg4300.cpp b/cg/cg4300.cpp index 659952826..0db0ce13d 100755 --- a/cg/cg4300.cpp +++ b/cg/cg4300.cpp @@ -128,7 +128,7 @@ bool TLiquidazione_app::user_create() _att_r = &(_nditte->curr(LF_ATTIV)); _ditte = new TArray_sheet(-1, -1, -4, -4, TR("Selezione Ditte"), - HR("@1|Codice@R|Ragione Sociale@50|Vers.|Agr.Min")); + HR("@1|Codice@R|Ragione Sociale@50|Vers.|IVAxCassa")); _n_ditte = 0l; // Caro tab11, ricordati che un giorno sarai un file unico! @@ -144,8 +144,7 @@ bool TLiquidazione_app::user_create() TDate oggi(TODAY); _year.format("%d",oggi.year()); _month = oggi.month(); - TConfig conf(CONFIG_STUDIO); - _sind11 = conf.get_bool("Sind11"); + _sind11 = ini_get_bool(CONFIG_STUDIO, "cg", "Sind11"); } else // parse messaggio { @@ -625,8 +624,7 @@ void TLiquidazione_app::build_nomiditte() if (good) { // check no parametri liquidazione - if (!look_lia(dt.get_long("CODDITTA"))) - good = FALSE; + good = look_lia(dt.get_long("CODDITTA")); } else continue; @@ -639,7 +637,7 @@ void TLiquidazione_app::build_nomiditte() if (good) { d->add(_lia->get("S7")); - d->add(_lia->get("B2")); + d->add(_lia->get("B5")); // IVA per cassa } else { @@ -848,9 +846,9 @@ void TLiquidazione_app::build_ditte_sheet(wht what) TToken_string* d = new TToken_string(64); *d = (TToken_string&)_nomiditte[i]; const char vers = d->get_char(2); - const bool agr = d->get_char(3) == 'X'; + const bool ixc = d->get_char(3) == 'X'; - const bool unselectable = (vers == '?') || (_month < 13 && agr); + const bool unselectable = (vers == '?'); if ((what == mnt && vers == 'T') || (what == trimestre && vers == 'M')) continue; diff --git a/cg/cg4300.h b/cg/cg4300.h index a723b3598..2975d1194 100755 --- a/cg/cg4300.h +++ b/cg/cg4300.h @@ -446,7 +446,7 @@ protected: bool print_inc_diff_log(int& rw, int tipoatt, int tipoiva); bool print_dainc_diff_log(int& rw, int tipoatt, int tipoiva); bool ivadiff_chiusa(const TRectype& mov, const TDate& fine) const; - bool sarebbe_da_pagare(const TRectype& mov, const TDate& fine) const; + bool sarebbe_maturata(const TRectype& mov, const TDate& inizio, const TDate& fine) const; public: diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index eb15b5c52..2dacb0797 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -305,6 +305,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) _pla->zero("R15"); _pla->zero("R16"); _pla->zero("R17"); + _pla->zero("R18"); _pla->put("S1","0"); _pla->put("S2","0"); _pla->put("S3","0"); @@ -594,12 +595,25 @@ bool TLiquidazione_app::ivadiff_chiusa(const TRectype& mov, const TDate& fine) c return chiusa; } +static TDate data_maturazione_IVA_diff(const TRectype& mov) +{ + const TDate data_reg = mov.get(MOV_DATAREG); + const TDate data_doc = mov.get(MOV_DATADOC); + TDate data_rif = data_doc.ok() && data_doc < data_reg ? data_doc : data_reg; + data_rif.addyear(1); data_rif.set_end_month(); + return data_rif; +} + // Fattura più vecchia di un anno a ente NON pubblico -bool TLiquidazione_app::sarebbe_da_pagare(const TRectype& mov, const TDate& fine) const +bool TLiquidazione_app::sarebbe_maturata(const TRectype& mov, const TDate& inizio, const TDate& fine) const { if (mov.get_int(MOV_TIPOMOV) != tm_fattura) return false; + const TDate data_lim = data_maturazione_IVA_diff(mov); // Data limite (un anno dopo quella di riferimento) + if (data_lim < inizio || data_lim > fine) + return false; // maturazione fuori range + // La data di riferimento sarebbe quella di consegna della merce, ma non avendola usiamo la data documento. // In assenza della data documento siamo costretti ad usare la data di registrazione const TDate data_reg = mov.get(MOV_DATAREG); @@ -618,16 +632,14 @@ bool TLiquidazione_app::sarebbe_da_pagare(const TRectype& mov, const TDate& fine } else if (mov.get_bool(MOV_IVAXCASSA)) { - if (!gestione_IVAxCassa(fine) || _isviaggio) // Le agenzie viaggio non posso aderire al regime IVA per cassa + if (_isviaggio || !gestione_IVAxCassa(fine)) // Le agenzie viaggio non posso aderire al regime IVA per cassa return true; // Ho superato la soglia di applicabilità dell'IVA per cassa } else return true; // Regime IVA normale - TString8 key; key.format("%c|%ld", mov.get_char(MOV_TIPO), mov.get_long(MOV_CODCF)); - const TRectype& clifo = cache().get(LF_CLIFO, key); + const TRectype& clifo = cache().get_rec(LF_CLIFO, mov.get_char(MOV_TIPO), mov.get_long(MOV_CODCF)); int alleg = clifo.get_int(CLI_ALLEG); - if (alleg == 7 || alleg == 8) // Ente pubblico e amministrazione controllata ... return false; // ... possono aspettare le calende greche @@ -654,13 +666,10 @@ bool TLiquidazione_app::sarebbe_da_pagare(const TRectype& mov, const TDate& fine return true; } - if (ivadiff_chiusa(mov, fine)) + if (ivadiff_chiusa(mov, min(data_lim,fine))) return false; - if (giorni >= 365) - return true; // E' passato più di un anno! - - return false; + return true; // E' passato più di un anno! } bool TLiquidazione_app::residuo_da_liquidare(const TRectype& lastid, real& importo_res, real& imponib_res, real& imposta_res) const @@ -890,6 +899,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) real esenti_c3_bam = ZERO; // Beni ammorizzabili esenti c3 real esenti_c1a_bam = ZERO; // Beni ammorizzabili esenti c1a real esenti_b14 = ZERO; + real vendite_rev = ZERO; // Vendire in reverse charge (da escludere in prorata) // Comunicazione dati iva annuale (dal 2003) real cessioni_cd1_1 = ZERO; // Totale operazioni attive @@ -901,11 +911,12 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) real acquisti_cd2_2 = ZERO; // non imponibili real acquisti_cd2_3 = ZERO; // esenti real acquisti_cd2_4 = ZERO; // intra - real acquisti_cd2_5 = ZERO; // beni strumentali + real acquisti_cd2_5 = ZERO; // beni strumentali real oroargento_cd3_1 = ZERO; // imponibile acquisto oro e argento real oroargento_cd3_2 = ZERO; // imposta acquisto oro e argento - real rottami_cd3_3 = ZERO; // imponibile acquisto rottami - real rottami_cd3_4 = ZERO; // imposta acquisto rottami + real rottami_cd3_3 = ZERO; // imponibile acquisto rottami + real rottami_cd3_4 = ZERO; // imposta acquisto rottami + real cessioni_cd1_1s = ZERO; // Totale operazioni attive in split payment real esni_rimb = ZERO; // ci sommo tutti esenti e ni validi per rimborso real corr_CEE = ZERO; @@ -1027,7 +1038,6 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) const TDate fromdate(1, month == 13 ? 1 : month, year_int); TDate t; - if (_recalc_regis) // Vecchia selezione prima del 1998 o calcolo progressivi per stampa registri bollati { t.set_month(month == 13 ? 12 : month); @@ -1079,8 +1089,12 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) trueatt.cut(5); TString pimsg; - pimsg << TR("Ricalcolo attività ") << trueatt << " (" << TR("mese ") - << (month > 12 ? "13" : itom(month)) << ' ' << year_int << ')'; + pimsg << TR("Ricalcolo attività ") << trueatt << " ("; + if (month > 12) + pimsg << "13ma "; + else + pimsg << TR("mese ") << itom(month); + pimsg << ' ' << year_int << ')'; TProgress_monitor pi(items, pimsg, false); for (; _cur->pos() < items; ++(*_cur)) @@ -1106,7 +1120,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) } #ifndef NDEBUG - if (_mov->get_long(MOV_NUMREG) == 19956) + if (_mov->get_long(MOV_NUMREG) == 23353) int cazzone = 1; #endif @@ -1125,11 +1139,34 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) // Gestione SPLIT PAYMENT dal 01-01-2015: movimenti a enti pubblici senza ritenuta e senza reverse charge if (tipomov == vendita && (tm == tm_fattura || tm == tm_nota_credito) && !cau_intra && date.year() >= 2015 && is_split_payment(_mov->curr())) + { + // *** aggiunto il 27-01-2016 *** + // In tredicesima devo compilare anche CD1_1 + if (month == 13 && date.year() == year_int) + { + do // scansione semplificata delle righe IVA + { + const int rmi_tipoatt = max(_rmoviva->get_int(RMI_TIPOATT), 1); // Poteva capitare tipoatt == 0 + if (rmi_tipoatt != tipatt) + continue; + const TString& codiva = _rmoviva->get(RMI_CODIVA); + if (!look_iva(codiva)) + continue; + const TString& iva_vpn = _iva->get("S10"); + if (iva_vpn.full()) + { + const real imponibile_orig = _rmoviva->get(RMI_IMPONIBILE); + cessioni_cd1_1s += imponibile_orig; + cessioni_cd1_1 += imponibile_orig; + } + } while (_cur->next_match(LF_RMOVIVA)); + } continue; // Ignora movimento di split payment + } // Inizio gestione IVA differita const bool iva_diff = _mov->get_bool(MOV_LIQDIFF) && is_IVA_diff(_mov->curr()); - const bool iva_cass = !iva_diff && !_isviaggio && tm > tm_nessuno && _mov->get_bool(MOV_IVAXCASSA) && is_IVAxCassa(_mov->curr()); + const bool iva_cass = !iva_diff && !_isviaggio && tm > tm_nessuno && is_IVAxCassa(_mov->curr()); const bool bIsMovDiff = (iva_diff || iva_cass) && !_recalc_regis; // Aggiunto test su ricalcolo da registri 13-12-2012 bool dok = is_date_ok(date, month, liqmonth, year_int); @@ -1138,7 +1175,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) if (bIsMovDiff && tm == tm_fattura) { - const bool id_chiusa = ivadiff_chiusa(_mov->curr(), inizio); + // const bool id_chiusa = ivadiff_chiusa(_mov->curr(), inizio); + const bool id_chiusa = ivadiff_chiusa(_mov->curr(), TDate(31,12,inizio.year()-1)); if (!dok && id_chiusa) continue; // Salta vecchi movimenti differiti già chiusi @@ -1159,8 +1197,19 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) if (game_found && !id_chiusa) { const TRiga_partite& rp = p->riga(row); - TImporto pg, nc; - flag_pg_nc = rp.calcola_pagato_periodo(inizio+1L, fine, pg, nc, &pagscatt); + + TDate orizzonte = fine; // caso tradizionale + + // esperimento del 15-02-2016 + if (1) + { + TDate data_rif = data_maturazione_IVA_diff(_mov->curr()); + if (data_rif < fine) + orizzonte = data_rif; + } + + TImporto pg_per, nc_per; + flag_pg_nc = rp.calcola_pagato_periodo(inizio+1L, orizzonte, pg_per, nc_per, &pagscatt); if (pagscatt.items() >= 2) { // Fondo tra loro le righe generate dallo stesso pagamento @@ -1176,13 +1225,14 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) } } } - if (sarebbe_da_pagare(_mov->curr(), fine)) + if (sarebbe_maturata(_mov->curr(), inizio+1L, fine)) { TPointer_array pagscaold; - rp.calcola_pagato_periodo(TDate(0L), fine, pg, nc, &pagscaold); + TImporto pg_tot, nc_tot; + rp.calcola_pagato_periodo(TDate(0L), orizzonte, pg_tot, nc_tot, &pagscaold); // Controllo se ci siam persi delle note di credito negli anni scorsi - if (!nc.is_zero() && pagscaold.items() > pagscatt.items()) + if (!nc_tot.is_zero() && pagscaold.items() > pagscatt.items()) { FOR_EACH_ARRAY_ITEM(pagscaold, i, obj) { @@ -1221,7 +1271,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) } TImporto saldo = rp.importo(false); - saldo += pg; saldo += nc; + saldo += pg_tot; saldo += nc_tot; saldo.normalize(sezfat); if (saldo.valore() > ZERO) tot_da_incassare = saldo.valore(); @@ -1236,15 +1286,16 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) else { // Fattura più vecchia di un anno a ente NON pubblico - if (sarebbe_da_pagare(_mov->curr(), fine)) + if (sarebbe_maturata(_mov->curr(), inizio+1L, fine)) tot_da_incassare = _mov->get_real(MOV_TOTDOC); } } // Simulo incasso se necessario - if (!tot_da_incassare.is_zero()) // già controllato se sarebbe_da_pagare(_mov->curr(), fine) + if (!tot_da_incassare.is_zero()) // già controllato se sarebbe_maturata(_mov->curr(), fine) { tot_incassato = tot_da_incassare; - datainc = fine; + + datainc = data_maturazione_IVA_diff(_mov->curr()); _mov->put(MOV_DATAINC, datainc); } if (tot_incassato > ZERO && is_date_ok(datainc, month, liqmonth, year_int)) @@ -1427,6 +1478,11 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) const char sezpag = tipomov == vendita ? 'A' : 'D'; const real totfat = _mov->get(MOV_TOTDOC); +#ifndef NDEBUG + if (_mov->get_long(MOV_NUMREG) == 23353) + int cazzone = 1; +#endif + TLocalisamfile id(LF_IVADIFF); TRectype& idcurr = id.curr(); FOR_EACH_ARRAY_ITEM(pagscatt, r, obj) @@ -1651,75 +1707,75 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) const TString& iva_vpn = _iva->get(tipomov == vendita ? "S10" : "S11"); - // Aggiunto "&& is_detraibile" al test altrimenti somma due volte imponibile_orig (22/01/2015) - if (iva_vpn.full() && _mov->get(MOV_ANNOIVA) == _year && is_detraibile) + // Aggiunto "&& is_detraibile==0" al test altrimenti somma due volte imponibile_orig (22/01/2015) + if (!bIsMovDiff && iva_vpn.full() && _mov->get_int(MOV_ANNOIVA) == year_int && is_detraibile == 0) { switch (tipomov) { - case vendita: // CD1 - 1 2 3 4 - { - // bool is_valid = !corrisp && tipodoc != "AF" && (cau_intra || !cau_valintra) && - // sosp_imp != normale && sosp_imp != liquidazione; - bool is_valid = tipodoc != "AF" && sosp_imp != normale && sosp_imp != liquidazione; - if (is_valid) - { - cessioni_cd1_1 += imponibile_orig; - if (iva_vpn.starts_with("CD1")) - { - if (tipocr == 4) - cessioni_cd1_5 += imponibile_orig; - } - if (!cau_intra) - { - if (iva_vpn == "CD12") - cessioni_cd1_2 += imponibile_orig; else - if (iva_vpn == "CD13") - cessioni_cd1_3 += imponibile_orig; - } - else - { - if (iva_vpn == "CD14") - cessioni_cd1_4 += imponibile_orig; - } - } - - } - break; - case acquisto: // CD2 - 1 2 3 4 - { - acquisti_cd2_1 += imponibile_orig; - if (iva_vpn.starts_with("CD2")) + case vendita: // CD1 - 1 2 3 4 + { + // bool is_valid = !corrisp && tipodoc != "AF" && (cau_intra || !cau_valintra) && + // sosp_imp != normale && sosp_imp != liquidazione; + bool is_valid = tipodoc != "AF" && sosp_imp != normale && sosp_imp != liquidazione; + if (is_valid) + { + cessioni_cd1_1 += imponibile_orig; + if (iva_vpn.starts_with("CD1")) { - if (tipocr == 2 || tipocr == 3 || tipocr == 8) - acquisti_cd2_5 += imponibile_orig; + if (tipocr == 4) + cessioni_cd1_5 += imponibile_orig; } - if (!cau_intra) - { - if (iva_vpn == "CD22") - acquisti_cd2_2 += imponibile_orig; - else - if (iva_vpn == "CD23") - acquisti_cd2_3 += imponibile_orig; - } - else - { - if (iva_vpn == "CD24") - acquisti_cd2_4 += imponibile_orig; - } - if (iva_vpn == "CD31") - { - oroargento_cd3_1 += imponibile_orig; - oroargento_cd3_2 += imposta_orig; - } - if (iva_vpn == "CD33") - { - rottami_cd3_3 += imponibile_orig; - rottami_cd3_4 += imposta_orig; - } - } - break; - default: - break; + if (!cau_intra) + { + if (iva_vpn == "CD12") + cessioni_cd1_2 += imponibile_orig; else + if (iva_vpn == "CD13") + cessioni_cd1_3 += imponibile_orig; + } + else + { + if (iva_vpn == "CD14") + cessioni_cd1_4 += imponibile_orig; + } + } + + } + break; + case acquisto: // CD2 - 1 2 3 4 + { + acquisti_cd2_1 += imponibile_orig; + if (iva_vpn.starts_with("CD2")) + { + if (tipocr == 2 || tipocr == 3 || tipocr == 8) + acquisti_cd2_5 += imponibile_orig; + } + if (!cau_intra) + { + if (iva_vpn == "CD22") + acquisti_cd2_2 += imponibile_orig; + else + if (iva_vpn == "CD23") + acquisti_cd2_3 += imponibile_orig; + } + else + { + if (iva_vpn == "CD24") + acquisti_cd2_4 += imponibile_orig; + } + if (iva_vpn == "CD31") + { + oroargento_cd3_1 += imponibile_orig; + oroargento_cd3_2 += imposta_orig; + } + if (iva_vpn == "CD33") + { + rottami_cd3_3 += imponibile_orig; + rottami_cd3_4 += imposta_orig; + } + } + break; + default: + break; } } } @@ -1841,16 +1897,16 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) * (Sergio 1995) */ { - /* NO! - * Invece non le deve comprendere nell'annuale - * (Vladimiro 1995, piu' tardi) - */ + // Invece non le deve comprendere nell'annuale (Vladimiro 1995, piu' tardi) if (!(_month == 13 && autodafe)) { cess_amm += imponibile; cess_amm_iva += imposta; } - } + } + + if (is_detraibile && !imponibile.is_zero() && is_reverse_charge(_mov->curr())) + vendite_rev += imponibile; } break; default: // Chissa'... forse in futuro vi sara' un ulteriore tipo di movimento... @@ -2173,7 +2229,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) } // corrispettivi - bool true_corrisp = FALSE; + bool true_corrisp = false; if (corrisp) { /* @@ -2423,12 +2479,15 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) if (tipomov == vendita) { #ifndef NDEBUG - if (month == 13 && reg == "VEN" && !incdiff_iva.is_zero()) + if (codiva=="10" && !incdiff_iva.is_zero()) { const real oldv = tab->get("R29"); const real newv = oldv + incdiff_iva; + const long numreg = _mov->get_long(MOV_NUMREG); + if (numreg == 23260) + int cazzone = 1; __trace("%s %s\t%s\t%s\t%7ld\t%s\t+\t%s\t=\t%s", tab->name(), (const char*)tab->curr().get("CODTAB"), (const char*)reg, (const char*)tipocr_s, - _mov->get_long(MOV_NUMREG), oldv.stringa(12, 2), incdiff_iva.stringa(12, 2), newv.stringa(12, 2)); + numreg, oldv.stringa(12, 2), incdiff_iva.stringa(12, 2), newv.stringa(12, 2)); } #endif // fatture vendita a liquidazione differita @@ -2676,6 +2735,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) _pom->put("R8", leasing_iva); _pom->put("R11", ammort_indet); _pom->put("R12", ammort_indet_iva); + _pum->put("R0", cess_amm); _pum->put("R1", cess_amm_iva); _pum->put("R2", ammort_6); @@ -2702,6 +2762,9 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) _pum->put("R25", rottami_cd3_4); _pum->put("R26", acquisti_cd2_5); _pum->put("R27", cessioni_cd1_5); + _pum->put("R28", vendite_rev); // Vendite in reverse charge da escludere da prorata + _pum->put("R29", cessioni_cd1_1s); // cessioni in split + _pam->put("R0", acquisti); _pam->put("R1", vendite); _pam->put("R6", assp_imp); @@ -3441,7 +3504,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) deltam -= month; look_lia(); - const bool new_age_2000 = (year_int >= 2000) && (_lia->get("S9") == "NV"); + const bool new_age_2000 = (_lia->get("S9") == "NV"); real risultato = ZERO; @@ -3682,12 +3745,15 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) if (somma_rettifiche) { const real rett = _lim->get_real("R5"); - risultato += rett; - rettifiche += rett; - if (rett.sign() < 0) - res_cred -= rett; - else - res_debt += rett; + if (!rett.is_zero()) + { + risultato += rett; + rettifiche += rett; + if (rett.sign() < 0) + res_cred -= rett; + else + res_debt += rett; + } } } @@ -3851,18 +3917,18 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) real es_c3_am = _pla->get_real("R16"); real es_c1a_am = _pla->get_real("R17"); real csamm = _pla->get_real("R4"); - + real ven_rev = _pla->get_real("R18"); real prorata = 0.0; real conguaglio = 0.0; real topay = 0.0; const real ris = vf1 + vf2; // gia' esclusi: NS, B3, cess. amm // calcola nuovo prorata dal 1998 per ogni attivita' (miste: 1+2) - const real rsa = ris - (es_c1a-es_c1a_am) - (es_c3-es_c3_am); + const real rsa = ris - (es_c1a-es_c1a_am) - (es_c3-es_c3_am) - ven_rev; const real rsn = rsa - es_c1; if (!rsa.is_zero()) { - prorata = CENTO - (rsn * CENTO / rsa); // Percentuale di indetraibilita: reciproco della percentuale di detraibilita' + prorata = CENTO - (rsn * CENTO / rsa); // Percentuale di indetraibilità: reciproco della detraibilità prorata.round(0); } @@ -3892,7 +3958,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) // scrivi nuovo prorata in tabella anno successivo const TString4 yr = _year; _year.format("%d", atoi(_year) + 1); - look_pla(att, TRUE); + look_pla(att, true); _pla->put("R8", prorata); _pla->rewrite(); if (look_lia(0l, true)) @@ -3942,7 +4008,7 @@ void TLiquidazione_app::write_liq(int month, const char* codatts) look_lim(month+deltam,TRUE); // azzeriamo tutto (tranne r1, r5, s1, s0, s7) - const TString codtab = _lim->get("CODTAB"); + const TString16 codtab = _lim->get("CODTAB"); real rimborso = _lim->get("R1"); real r5 = _lim->get("R5"); // Rettifiche @@ -4210,6 +4276,7 @@ void TLiquidazione_app::recalc_annual(const char* att) real ven_lrd = 0.0; real volaff1 = 0.0; real volaff2 = 0.0; + real ven_rev = 0.0; TString4 codiva,reg,tiva; TToken_string va7("",'!'); @@ -4231,6 +4298,7 @@ void TLiquidazione_app::recalc_annual(const char* att) cess_amm = _pla->get_real("R4"); pro_pag = _pla->get_real("R12"); iva_acq = _pla->get_real("R11"); + ven_rev = _pla->get_real("R18"); // Per avere un risultato corretto, si deve totalizzare PIM->R3 per codice iva // e quindi effettuare lo scorporo dell'imponibile e aggiungere al relativo volume d'affari @@ -4319,6 +4387,7 @@ void TLiquidazione_app::recalc_annual(const char* att) es_c3_am += _pum->get_real("S4"); es_c1a_am += _pum->get_real("S5"); cess_amm += _pum->get_real("R0"); + ven_rev += _pum->get_real("R28"); // Nota: // l'iva acquisti del mese 13 memorizzata in PLM->R1, e' si' la sommatoria @@ -4342,7 +4411,8 @@ void TLiquidazione_app::recalc_annual(const char* att) _pla->put("R11", iva_acq); _pla->put("R12", pro_pag); _pla->put("R14", volaff1); - _pla->put("S1", volaff2.string()); + _pla->put("S1", volaff2.string()); + _pla->put("R18", ven_rev); _pla->rewrite(); } diff --git a/cg/cg4303.cpp b/cg/cg4303.cpp index bebc916d3..6ecd80cc4 100755 --- a/cg/cg4303.cpp +++ b/cg/cg4303.cpp @@ -100,9 +100,7 @@ void TLiquidazione_app::recalc_corrispettivi(int month, const char* codatt) { if (_iva->get("S10").not_empty()) // Solo CD1_1 ha senso coi corrispettivi... { - real cd1_1 = _pum->get_real("R14"); - cd1_1 += imponibile; - _pum->put("R14", cd1_1); + _pum->curr().add("R14", imponibile); // CD1_1 _pum->rewrite(); } } @@ -343,9 +341,7 @@ void TLiquidazione_app::recalc_ventilation(int month, const char* codatt) { if (_iva->get("S10").not_empty()) // Solo CD1_1 ha senso coi corrispettivi { - real cd1_1 = _pum->get_real("R14"); - cd1_1 += imponibile; - _pum->put("R14", cd1_1); + _pum->curr().add("R14", imponibile); // CD1_1 _pum->rewrite(); } } diff --git a/cg/cg4304.cpp b/cg/cg4304.cpp index 481623b6b..269db078e 100755 --- a/cg/cg4304.cpp +++ b/cg/cg4304.cpp @@ -1087,7 +1087,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool // sospensione imposta: non piu' due palle, ma QUATTRO... // caro Ferdinando... ora son divenute ben OTTO... - // grazie all'iva ad esigibilita' differita da pagare/de"TRARRE" + // grazie all'iva ad esigibilità differita da pagare/de"TRARRE" TToken_string tt(t->_s4); real aqsi(tt.get(0)); real aqsv(tt.get(1)); @@ -1140,19 +1140,20 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool real v1 = _pla->get_real("R14"); // Totale imponibile vendite real v2 = _pla->get_real("S1"); // Volume d'affari II attività real ris = v1 + v2; - real e1 = _pla->get_real("R1"); // Totale vendite esenti C1 - real e2 = _pla->get_real("R2"); // Totale vendite esenti C2 - real e3 = _pla->get_real("R3"); // Totale vendite esenti C3 - real e4 = _pla->get_real("R15"); // Totale vendite esenti C1A - real e5 = _pla->get_real("R16"); // Totale vendite beni ammortizzabili esenti C3 - real e6 = _pla->get_real("R17"); // Totale vendite beni ammortizzabili esenti C1A + real e1 = _pla->get_real("R1"); // Totale vendite esenti C1 + real e2 = _pla->get_real("R2"); // Totale vendite esenti C2 + real e3 = _pla->get_real("R3"); // Totale vendite esenti C3 + real e4 = _pla->get_real("R15"); // Totale vendite esenti C1A + real e5 = _pla->get_real("R16"); // Totale vendite beni ammortizzabili esenti C3 + real e6 = _pla->get_real("R17"); // Totale vendite beni ammortizzabili esenti C1A real bam = _pla->get_real("R4"); // Cessione beni ammortizzabili + real vrc = _pla->get_real("R18"); // Vendite reverse charge real iaq = _pla->get_real("R11"); // IVA acquisti real ppg = _pla->get_real("R12"); // pro-rata pagato // calcola nuovo prorata per ogni attivita' (miste: 1+2) real pr; - const real rsa = ris - (e3-e5) - (e4-e6); + const real rsa = ris - (e3-e5) - (e4-e6) - vrc; if (!rsa.is_zero()) { const real rsn = rsa - e1; @@ -1176,7 +1177,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool _DescrItem* dd = new _DescrItem(ANNUAL); - // MonsterFish: arrotonda alle 1000 LIRE C1,C2,C3,C1A + // MonsterFish: arrotonda all'Euro C1,C2,C3,C1A round_imposta(e1); round_imposta(e2); round_imposta(e3); @@ -1185,10 +1186,13 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool round_imposta(e6); round_imposta(bam); round_imposta(ris); + round_imposta(vrc); // segna flag prorata if ((e1+e2+e3+e4) > ZERO) + { dd->_f0 |= IS_PRORATA; + } dd->_r0 = ris; dd->_r1 = e1; dd->_r2 = pr > ZERO ? pr : ZERO; @@ -1199,6 +1203,7 @@ void TLiquidazione_app::describe_pims(int month, const char* codatt, const bool dd->_r7 = e4; dd->_r8 = e5; dd->_r9 = e6; + dd->_r10 = vrc; t->_arr.add(dd); } } @@ -1230,16 +1235,16 @@ void TLiquidazione_app::describe_liq(int month, const char* codatts, _DescrItem* d->_r33 = _lim->get_real("R33"); // fdiffinc_iva_acq TToken_string tt(80); - tt.add(_lam->get_real("R0").string()); // IVA Vendite - tt.add(_lam->get_real("R1").string()); // IVA Acquisti - tt.add(_lam->get_real("R2").string()); // Credito precedente - tt.add(_lam->get_real("R3").string()); // Debito precedente - tt.add(_lam->get_real("R4").string()); + tt.add(_lam->get("R0")); // IVA Vendite + tt.add(_lam->get("R1")); // IVA Acquisti + tt.add(_lam->get("R2")); // Credito precedente + tt.add(_lam->get("R3")); // Debito precedente + tt.add(_lam->get("R4")); d->_s0 = tt; - d->_s1 = _lim->get_real("R11").string(); // Acc. dec. - d->_s2 = _lim->get_real("R12").string(); - d->_s3 = _lim->get_real("R13").string(); + d->_s1 = _lim->get("R11"); // Acc. dec. + d->_s2 = _lim->get("R12"); + d->_s3 = _lim->get("R13"); // descrizione rettifiche if (month < 13) @@ -1421,7 +1426,7 @@ void TLiquidazione_app::set_firm(_DescrItem& d) if (!_isregis) { set_header(soh++,FR("Ditta %s %s@107gData @>@125gPag. @#"), - (const char*)(d._s0), (const char*)(d._s1)); + (const char*)d._s0, (const char*)d._s1); set_header(soh++,""); } set_header(soh++,sep); @@ -1638,10 +1643,6 @@ int TLiquidazione_app::calc_inc_diff(int tipoiva, real& imponibile_diff, real& i const real imp = rec.get_real(RMI_IMPONIBILE); if (!iva.is_zero() || !imp.is_zero()) { -#ifdef DBG - if (iva.is_zero() && !imp.is_zero()) - int cazzonga = 1; -#endif const int tipodiff = rec.get_int("TIPODIFF"); switch (tipodiff) { @@ -1913,7 +1914,7 @@ void TLiquidazione_app::set_pim_head(_DescrItem& d) // print_dainc_diff_log(r, d._f2, d._f3); // 15-03-2013 obosleto in quanto stampato su registri? } else - if (d._flags == PIM_HEAD_DI) + if (d._flags == PIM_HEAD_DI) { TString msg; msg = TR("Incassi/pagamenti a liquidazione differita"); @@ -2117,7 +2118,7 @@ void TLiquidazione_app::set_plm(_DescrItem& d) void TLiquidazione_app::set_pumpam(const _DescrItem& d) { - bool printed = FALSE; + bool printed = false; // d._f1 dice se c'era qualcosa sopra nella stessa pagina real spgn(d._s2); @@ -2189,7 +2190,7 @@ void TLiquidazione_app::set_pumpam(const _DescrItem& d) } if (! (d._r0.is_zero() && d._r1.is_zero())) { - printed = TRUE; + printed = true; set_row(row++, FR("Acquisto beni ammortizzabili IVA detraibile@50g%r@69g%r"), &(d._r0), &(d._r1)); @@ -2730,7 +2731,7 @@ void TLiquidazione_app::set_grand(_DescrItem& d) { for (int i = 0; i < d._arr.items(); i++) { - _DescrItem& di = (_DescrItem&)d._arr[i]; + const _DescrItem& di = (_DescrItem&)d._arr[i]; if (di._flags == RIMBORSO) { @@ -2748,8 +2749,7 @@ void TLiquidazione_app::set_grand(_DescrItem& d) { // esenti e non imponibili set_row(rw++,""); - set_row(rw++,TR("1) Soggetto con quota di operazioni esenti e non" - " imponibili superiore al 25%%")); + set_row(rw++,TR("1) Soggetto con quota di operazioni esenti e non imponibili superiore al 25%%")); real perc = di._r0 * CENTO / di._r1; perc.round(0); @@ -2765,8 +2765,7 @@ void TLiquidazione_app::set_grand(_DescrItem& d) if (di._f1) { set_row(rw++,""); - set_row(rw++,TR("2) Soggetto con acquisti ad aliquota media " - "superiore a quella delle vendite")); + set_row(rw++,TR("2) Soggetto con acquisti ad aliquota media superiore a quella delle vendite")); TString sep(strlen(REAL_PICTURE)+2); sep.fill('-'); set_row(rw++,""); set_row(rw++,FR("@26gTotale imposte sugli acquisti@66g%r"), &(di._r5)); @@ -2779,7 +2778,7 @@ void TLiquidazione_app::set_grand(_DescrItem& d) set_row(rw++,FR("@26gTotale imponibili sulle vendite@66g%r"), &(di._r2)); } - set_print_zero(FALSE); + set_print_zero(false); } } // prospettino versamento @@ -2849,53 +2848,42 @@ void TLiquidazione_app::set_grand(_DescrItem& d) bool TLiquidazione_app::set_annual(_DescrItem& d) { // chiamata internamente a set_pims - bool ret = FALSE; + bool ret = false; int row = get_maxrow()+1; if (row == 1) row = 4; if (d._f0 & IS_PRORATA) { - // non lo ha stampato prima se annuale, perche' Vladimiro il nefido - // pretende l'assurdo aggiornamento della perc. a quella nuova + // non lo ha stampato prima se annuale, perche' Vladimiro il nefido pretende l'assurdo aggiornamento della perc. a quella nuova const int year_int = atoi(_year); row++; - set_row(++row, year_int > 1997 ? TR("CALCOLO DELLA PERCENTUALE DI DETRAIBILITA'") : TR("CALCOLO DELLA PERCENTUALE DI INDETRAIBILITA'")); + set_row(++row, TR("CALCOLO DELLA PERCENTUALE DI DETRAIBILITA'")); row++; set_bookmark(TR("Calcolo pro-rata"), _att_bookmark); - ret = TRUE; - set_print_zero(TRUE); + ret = true; + set_print_zero(true); set_row(row++,""); - if (year_int > 1997) - { - const real perc_det = CENTO - d._r2; - const TString16 s1 = perc_det.string(); - const TString16 s2 = d._r2.string(); - set_row(row++, FR("%% PRO-RATA (%s%%) ed IVA non detraibile (%s%%)@69g%r"), - (const char*)s1, (const char*)s2, &(d._r6)); - set_row(row++,FR("C1 - Operazioni esenti escluse da nr. 1 a 9 e 11 art. 10 @69g%r"), &(d._r1)); - set_row(row++,FR("C2 - Operazioni esenti di cui nr. 11 art. 10 @69g%r"), &(d._r4)); - set_row(row++,FR("C3 - Operazioni esenti da nr. 1 a 9 art. 10 @69g%r"), &(d._r5)); - set_row(row++,FR("@6gdi cui cessione beni ammortizzabili @69g%r"), &(d._r8)); - set_row(row++,FR("C1A - Operazioni esenti di cui all'art.10 n. 27 quinquies @69g%r"), &(d._r7)); - set_row(row++,FR("@6gdi cui cessione beni ammortizzabili @69g%r"), &(d._r9)); - set_row(row++,FR("Volume d'affari @69g%r"), &(d._r0)); - set_row(row++,FR("Detraibilità@69g%r%%"), &perc_det); - } - else - { - set_row(row++, FR("%% PRO-RATA ed IVA non detraibile (%s%%)@69g%r"), - (const char*)(d._r2.string()), &(d._r6)); - set_row(row++,FR("B1 - Operazioni esenti, escluse da nr. 1 a 9 e 11 art. 10 @69g%r"), &(d._r1)); - set_row(row++,FR("B2 - Operazioni esenti, di cui nr. 11 art. 10 @69g%r"), &(d._r4)); - set_row(row++,FR("B3 - Operazioni esenti da nr. 1 a 9 art. 10 @69g%r"), &(d._r5)); - set_row(row++,FR("Volume d'affari - B3 @69g%r"), &(d._r0)); - set_row(row++,FR("Indetraibilità@69g%r%%"), &(d._r2)); - } + const real perc_det = CENTO - d._r2; + const real vol_aff = d._r0 - d._r10; // Valutare se eliminare d._r10 come valore e sottrarlo a monte + const TString16 s1 = perc_det.stringa(); + const TString16 s2 = d._r2.stringa(); + set_row(row++, FR("%% PRO-RATA (%s%%) ed IVA non detraibile (%s%%)@69g%r"), + (const char*)s1, (const char*)s2, &(d._r6)); + + set_row(row++,FR("C1 - Operazioni esenti escluse da nr. 1 a 9 e 11 art. 10 @69g%r"), &(d._r1)); + set_row(row++,FR("C2 - Operazioni esenti di cui nr. 11 art. 10 @69g%r"), &(d._r4)); + set_row(row++,FR("C3 - Operazioni esenti da nr. 1 a 9 art. 10 @69g%r"), &(d._r5)); + set_row(row++,FR("@6gdi cui cessione beni ammortizzabili @69g%r"), &(d._r8)); + set_row(row++,FR("C1A - Operazioni esenti di cui all'art.10 n. 27 quinquies @69g%r"), &(d._r7)); + set_row(row++,FR("@6gdi cui cessione beni ammortizzabili @69g%r"), &(d._r9)); + set_row(row++,FR("Totale vendite al fine del calcolo del pro-rata @69g%r"), &vol_aff); + set_row(row++,FR("Detraibilità @69g%r%%"), &perc_det); + set_print_zero(FALSE); } return ret; diff --git a/cg/cg4400.cpp b/cg/cg4400.cpp index 78f8db62e..595c0825a 100755 --- a/cg/cg4400.cpp +++ b/cg/cg4400.cpp @@ -3022,8 +3022,7 @@ void TStampa_registri_app::on_page_printed(int file) bool TStampa_registri_app::stampo_liquidazione(int mese) { - //test tradotti alla lettera da AS/400 - //assolutamente incongruenti !!! + //test tradotti alla lettera da AS/400 assolutamente incongruenti !!! const bool trim_month_flag = (_frequiva == 'T' && (mese == 3 || mese == 6 || mese == 9 || mese == 12)) ||_frequiva != 'T' || (mese == 12 && _tipo_riepilogativo == 'A'); @@ -3100,8 +3099,7 @@ void TStampa_registri_app::liq_other_case() { TFilename app; app.temp(); int mese = _fino_a_mese; - //se la frequenza e' trimestrale - //aggiusta il mese al trimestre a cui appartiene + //se la frequenza e' trimestrale aggiusta il mese al trimestre a cui appartiene if (_frequiva == 'T') mese += 2 - ((mese-1) % 3); send_message(calc_reg ? 'R' : 'C', app, calc_reg ? _datareg.month() : mese); diff --git a/cg/cg5100.cpp b/cg/cg5100.cpp index d8561347d..5c8efaa30 100755 --- a/cg/cg5100.cpp +++ b/cg/cg5100.cpp @@ -19,7 +19,7 @@ class TParametri_ditta : public TConfig_application void check_registers(int year); public: - virtual bool check_autorization() const {return FALSE;} + virtual bool check_autorization() const {return false;} virtual const char* get_mask_name() const {return "cg5100a";} virtual bool preprocess_config (TMask& mask, TConfig& config); virtual bool postprocess_config (TMask& mask, TConfig& config); @@ -46,7 +46,7 @@ bool TParametri_ditta::user_create() // istanzia array _atts on le attività della ditta corrente _atts.add(r.get(ATT_CODATT)); - return TRUE; + return true; } @@ -131,10 +131,10 @@ void TParametri_ditta::swap_file(int logicnum, bool tocom) file = dir.filename(); if (dir.eox() == 0L || !file.exist()) { - set_autoload_new_files(FALSE); + set_autoload_new_files(false); TSystemisamfile s(logicnum); s.build(); - set_autoload_new_files(TRUE); + set_autoload_new_files(true); } } @@ -151,7 +151,7 @@ void TParametri_ditta::load_file(int logicnum) TFilename lf; lf.format("%sstd/lf%04d.txt", firm2dir(-1), logicnum); if (lf.exist()) - f.load(lf, '|', '\0', '\n', TRUE, TRUE); + f.load(lf, '|', '\0', '\n', true, true); } @@ -173,7 +173,7 @@ bool TParametri_ditta::preprocess_config (TMask& mask, TConfig& config) } else mask.disable(-GROUP_CONTABILITA); - return TRUE; + return true; } bool TParametri_ditta::postprocess_config(TMask& mask, TConfig& config) @@ -183,7 +183,7 @@ bool TParametri_ditta::postprocess_config(TMask& mask, TConfig& config) // MI3262 // La gestione liquidazione differita e' stata spostata sui parametri liquidazione // ovvero cg5300.cpp - return TRUE; + return true; } bool TParametri_ditta::postprocess_config_changed(const char* par, const char* var, @@ -192,7 +192,7 @@ bool TParametri_ditta::postprocess_config_changed(const char* par, const char* v const bool changed = strcmp(oldv, newv) != 0; if (!changed) - return TRUE; + return true; const TFixed_string v(var); if (v == "AnCfCm") { @@ -202,7 +202,7 @@ bool TParametri_ditta::postprocess_config_changed(const char* par, const char* v swap_file(LF_INDSP, *newv == 'X'); } else - return FALSE; + return false; } else if (v == "PcTcCm") { @@ -225,9 +225,9 @@ bool TParametri_ditta::postprocess_config_changed(const char* par, const char* v } } else - return FALSE; + return false; } - return TRUE; + return true; } int cg5100 (int argc, char* argv[]) diff --git a/cg/cg5100a.uml b/cg/cg5100a.uml index 05e226025..98d1dcbb1 100755 --- a/cg/cg5100a.uml +++ b/cg/cg5100a.uml @@ -96,12 +96,12 @@ END BOOLEAN CHK_GESSAL BEGIN PROMPT 4 13 "Gestione saldaconto " - MESSAGE TRUE ENABLE,CHK_GESVAL|ENABLE,CHK_NRCLIDX|ENABLE,CHK_NRFORDX - MESSAGE TRUE ENABLE,CHK_DTCFPG|ENABLE,CHK_RIFPRO|ENABLE,FLD_CODLIN - MESSAGE TRUE ENABLE,FLD_NUM_EC|ENABLE,FLD_LAST_EC|ENABLE,CHK_EASYSAL - MESSAGE FALSE DISABLE,CHK_GESVAL|DISABLE,CHK_NRCLIDX|DISABLE,CHK_NRFORDX - MESSAGE FALSE DISABLE,CHK_DTCFPG|DISABLE,CHK_RIFPRO|DISABLE,FLD_CODLIN - MESSAGE FALSE DISABLE,FLD_NUM_EC|DISABLE,FLD_LAST_EC|CLEAR,CHK_EASYSAL + MESSAGE true ENABLE,CHK_GESVAL|ENABLE,CHK_NRCLIDX|ENABLE,CHK_NRFORDX + MESSAGE true ENABLE,CHK_DTCFPG|ENABLE,CHK_RIFPRO|ENABLE,FLD_CODLIN + MESSAGE true ENABLE,FLD_NUM_EC|ENABLE,FLD_LAST_EC|ENABLE,CHK_EASYSAL + MESSAGE false DISABLE,CHK_GESVAL|DISABLE,CHK_NRCLIDX|DISABLE,CHK_NRFORDX + MESSAGE false DISABLE,CHK_DTCFPG|DISABLE,CHK_RIFPRO|DISABLE,FLD_CODLIN + MESSAGE false DISABLE,FLD_NUM_EC|DISABLE,FLD_LAST_EC|CLEAR,CHK_EASYSAL FIELD GesSal GROUP GROUP_SALDACONTO END diff --git a/cg/cg5200.cpp b/cg/cg5200.cpp index fa26079dd..14ef9e2a8 100755 --- a/cg/cg5200.cpp +++ b/cg/cg5200.cpp @@ -21,7 +21,7 @@ public: bool TRiga_array::add_riga(const TRectype& rec_saldi) { - bool flsca, found = FALSE; + bool flsca, found = false; int annoes, annoesr; char flag = ' ', flagr = ' '; char flagfin = ' ', flagfinr = ' '; @@ -78,7 +78,7 @@ bool TRiga_array::add_riga(const TRectype& rec_saldi) pdarepror += pdarepro; paverepror = rec_saldi.get_real(SLD_PAVEREPRO); paverepror += paverepro; - found = TRUE; + found = true; r.put(SLD_FLSCA, flsca); r.put(SLD_ANNOES, annoes); r.put(SLD_PDARE, pdarer); @@ -121,7 +121,7 @@ protected: virtual bool user_destroy(); virtual TRelation* get_relation() const { return _rel; } virtual TMask* get_mask(int mode) { return _msk; } - virtual bool changing_mask(int mode) {return FALSE; } + virtual bool changing_mask(int mode) {return false; } virtual int read(TMask& m); virtual void init_query_mode(TMask&); virtual void init_modify_mode(TMask&); @@ -152,7 +152,7 @@ bool TSaldibrowse_application::sheet_action(TSheet_field& s, int r, KEY k) void TSaldibrowse_application::init_query_mode(TMask& m) { _anno = 0; - _scarongly = FALSE; + _scarongly = false; m.disable(DLG_FINDREC); m.enable(F_DESCR_CONTO); m.enable(F_ANNO); @@ -180,7 +180,7 @@ bool TSaldibrowse_application::fai_filtro() int annop = 0; char tipo; - _saldo_gruppo = _saldo_conto = _saldo_sottoc = FALSE; + _saldo_gruppo = _saldo_conto = _saldo_sottoc = false; TMask& m = curr_mask(); tipo = m.get(F_TIPOCF)[0]; if (_anno != 0) @@ -198,10 +198,10 @@ bool TSaldibrowse_application::fai_filtro() _s = m.get_long(F_SOTTOC_CLIENTE); else _s = m.get_long(F_SOTTOC_FORN); if (_c == 0) - _saldo_gruppo = TRUE; + _saldo_gruppo = true; else if (_s == 0l) - _saldo_conto = TRUE; - else _saldo_sottoc = TRUE; + _saldo_conto = true; + else _saldo_sottoc = true; TRectype from (LF_SALDI); TRectype to (LF_SALDI); @@ -222,7 +222,7 @@ bool TSaldibrowse_application::fai_filtro() _cur->setregion(from,to); - return TRUE; + return true; } bool TSaldibrowse_application::anno_handler(TMask_field& f, KEY key) @@ -238,23 +238,23 @@ bool TSaldibrowse_application::anno_handler(TMask_field& f, KEY key) app()._anno = anno; } } - return TRUE; + return true; } bool TSaldibrowse_application::flsca_handler(TMask_field& f, KEY key) { if (key == K_SPACE) app()._scarongly = !f.get().blank(); - return TRUE; + return true; } bool TSaldibrowse_application::sottoc_handler(TMask_field& f, KEY key) { - bool ok = TRUE; + bool ok = true; if (key == K_TAB) { - bool stop = FALSE; + bool stop = false; TMask& m = f.mask(); int gruppo = m.get_int(F_GRUPPO); @@ -337,7 +337,7 @@ bool TSaldibrowse_application::user_create() set_search_field(F_GRUPPO); - return TRUE; + return true; } bool TSaldibrowse_application::user_destroy() @@ -348,7 +348,7 @@ bool TSaldibrowse_application::user_destroy() delete _cur; // delete _esc; - return TRUE; + return true; } int TSaldibrowse_application::read(TMask& m) diff --git a/cg/cg5300.cpp b/cg/cg5300.cpp index 3bc3a8976..c6c2e38e8 100755 --- a/cg/cg5300.cpp +++ b/cg/cg5300.cpp @@ -38,11 +38,11 @@ protected: // Relapp virtual TRelation* get_relation() const { return _rel; } virtual TMask* get_mask(int mode) { return _msk; } - virtual bool changing_mask(int mode) { return FALSE; } + virtual bool changing_mask(int mode) { return false; } // file intertface - virtual bool remove() { return TRUE; } - virtual bool protected_record(TRectype&) { return TRUE; } + virtual bool remove() { return true; } + virtual bool protected_record(TRectype&) { return true; } virtual void init_query_mode(TMask&); virtual void init_insert_mode(TMask& m); virtual int rewrite(const TMask& m); @@ -72,7 +72,7 @@ bool TParaliq_app::ditta_handler(TMask_field& f, KEY k) TFirm fr(atol(f.get())); f.mask().set(F_CODVAL, fr.codice_valuta()); } - return TRUE; + return true; } bool TParaliq_app::gelidi_handler(TMask_field& f, KEY k) @@ -93,7 +93,7 @@ bool TParaliq_app::gelidi_handler(TMask_field& f, KEY k) } } } - return TRUE; + return true; } bool TParaliq_app::agrmin_handler(TMask_field& f, KEY k) @@ -118,7 +118,7 @@ bool TParaliq_app::agrmin_handler(TMask_field& f, KEY k) } } } - return TRUE; + return true; } bool TParaliq_app::credres_handler(TMask_field& f, KEY k) @@ -144,7 +144,7 @@ bool TParaliq_app::credres_handler(TMask_field& f, KEY k) if (id == F_CRED_RES && i != 0 && r == 0.0) return f.error_box(TR("Impostare anche il credito residuo.")); } - return TRUE; + return true; } bool TParaliq_app::credpreccost_handler(TMask_field& f, KEY k) @@ -158,7 +158,7 @@ bool TParaliq_app::credpreccost_handler(TMask_field& f, KEY k) r.round(euro ? m.get_int(F_ROUNDDIC) : -3); f.set(r.string()); } - return TRUE; + return true; } bool TParaliq_app::utcred_handler(TMask_field& f, KEY k) @@ -198,7 +198,7 @@ bool TParaliq_app::utcred_handler(TMask_field& f, KEY k) else m.set(F_MESE_RES_AL, oldmese); } - return TRUE; + return true; } void TParaliq_app::check_registers(int year) @@ -308,7 +308,7 @@ bool TParaliq_app::user_destroy() { delete _rel; delete _msk; - return TRUE; + return true; } bool TParaliq_app::sheet_action(TSheet_field& s, int r, KEY k) @@ -326,7 +326,7 @@ void TParaliq_app::init_query_mode(TMask& m) void TParaliq_app::init_insert_mode(TMask& m) { // Inizializza array delle attività - init_array(m, TRUE); + init_array(m, true); m.set(F_ROUNDLIQ, TCurrency::get_firm_dec()); } @@ -342,7 +342,7 @@ int TParaliq_app::rewrite(const TMask& m) const char freq = m.get(F_FREQ_VERS)[0]; int err = NOERR; - bool was = FALSE; + bool was = false; for (int i = 0; err == NOERR && i < sf.items(); i++) { @@ -457,7 +457,7 @@ int TParaliq_app::read(TMask& m) TCursor cur(&relpla, "", 1, &pla, &pla); const TRecnotype items = cur.items(); - init_array(m, FALSE); // Carica tutti i codici attività + init_array(m, false); // Carica tutti i codici attività cur.freeze(); for (cur = 0L; cur.pos() < items; ++cur) { diff --git a/cg/cg5300a.uml b/cg/cg5300a.uml index 18fc6b7c9..3d99f7958 100755 --- a/cg/cg5300a.uml +++ b/cg/cg5300a.uml @@ -107,8 +107,8 @@ BOOLEAN F_GESIC BEGIN PROMPT 4 7 "Gestione IVA per cassa" FIELD B5 - MESSAGE FALSE DISABLE,F_ICDAL|DISABLE,F_ICAL - MESSAGE TRUE ENABLE,F_ICDAL|ENABLE,F_ICAL + MESSAGE false DISABLE,F_ICDAL|DISABLE,F_ICAL + MESSAGE true ENABLE,F_ICDAL|ENABLE,F_ICAL MODULE IC END diff --git a/cg/cg5400.cpp b/cg/cg5400.cpp index 1b96535e7..1cc27b869 100755 --- a/cg/cg5400.cpp +++ b/cg/cg5400.cpp @@ -32,7 +32,7 @@ bool TRipristina_stampa::reg_restore(const TString& regist, { CHECKD(month > 0 && month < 13, "Mese errato ", month); - bool ok = TRUE; + bool ok = true; const char * const fieldname = giornale ? MOV_STAMPATO : MOV_REGST; TRelation rel(LF_MOV); TLocalisamfile& mov = rel.lfile(); @@ -66,7 +66,7 @@ bool TRipristina_stampa::reg_restore(const TString& regist, const long nitems = cursor.items(); TString msg; msg.format(FR("Ripristino stampa del registro %s"), (const char*)regist); - TProgind p(nitems ? nitems : 1, msg , TRUE, TRUE); + TProgind p(nitems ? nitems : 1, msg , true, true); if (giornale) { @@ -137,7 +137,7 @@ bool TRipristina_stampa::inl_restore(const TString& lib, int year, int month) const TRecnotype items = cur.items(); cur.freeze(); - bool ok = FALSE; + bool ok = false; // Azzera il flag di stampato sugli indici con mese >= month for (cur = 0L; cur.pos() < items; ++cur) @@ -187,7 +187,7 @@ void TRipristina_stampa::main_loop() { long firm = prefix().get_codditta(); const TString4 reg = msk.get(F_REG); - bool giornale = FALSE; + bool giornale = false; if (_op == restore_reg) { diff --git a/cg/cg5500.h b/cg/cg5500.h index 5362b9dc8..849e402a7 100755 --- a/cg/cg5500.h +++ b/cg/cg5500.h @@ -66,7 +66,7 @@ protected: static bool vers_action(TSheet_field& s, int r, KEY k); public: - virtual bool firm_change_enabled() const { return FALSE; } + virtual bool firm_change_enabled() const { return false; } static Visliq_app& app() { return (Visliq_app&)main_app(); } TArray_sheet* get_ditte_sheet() { return _ditte; } @@ -76,7 +76,7 @@ public: bool look_lia(long ditta = 0l, int year = 0); bool look_lim(int m); - bool look_del(int month, int type, bool create = FALSE); + bool look_del(int month, int type, bool create = false); void read_general(TMask& m); void write_general(TMask& m); diff --git a/cg/cg5501.cpp b/cg/cg5501.cpp index 3a0d33c20..04dbe77e1 100755 --- a/cg/cg5501.cpp +++ b/cg/cg5501.cpp @@ -4,7 +4,7 @@ bool Visliq_app::look_lim(int m) { - bool ok = FALSE; + bool ok = false; _lim_r->zero(); _lam_r->zero(); @@ -64,11 +64,11 @@ bool Visliq_app::look_lia(long ditta, int year) bool Visliq_app::is_trim(int x) - // TRUE se il mese passato e' un trimestre + // true se il mese passato e' un trimestre { return x == 3 || x == 6 || x == 9 || x == 12; } bool Visliq_app::is_month_ok(int x, int month) - // TRUE se il mese passato e' compatibile con il regime + // true se il mese passato e' compatibile con il regime // di liquidazione e (opz) non e' maggiore di quello scelto { if (month == -1) month = x; diff --git a/cg/cg5600.cpp b/cg/cg5600.cpp index 8db4311e8..dc2f43572 100755 --- a/cg/cg5600.cpp +++ b/cg/cg5600.cpp @@ -54,7 +54,7 @@ bool TRipristino_liq::ch_year_handler(TMask_field& f, KEY key) app().build_nomiditte(); app().build_ditte_sheet(); } - return TRUE; + return true; } @@ -107,7 +107,7 @@ bool TRipristino_liq::create() build_ditte_sheet(); dispatch_e_menu(BAR_ITEM_ID(1)); - return TRUE; + return true; } bool TRipristino_liq::destroy() @@ -216,7 +216,7 @@ bool TRipristino_liq::restore_firm(long firm) zero_cursor("PPA"); zero_cursor("RMB"); zero_cursor("LIM"); - return TRUE; + return true; } diff --git a/cg/cg5700.cpp b/cg/cg5700.cpp index 0c272b2d5..a294e571a 100755 --- a/cg/cg5700.cpp +++ b/cg/cg5700.cpp @@ -1,508 +1,701 @@ -// Programma per la gestione e la stampa della dichiarazione periodica IVA -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "cg5700.h" -#include "cglib03.h" - -class TDich_periodica_selfirm_mask : public TAutomask -{ - TArray_sheet * _ditte; - TString_array _nomiditte; - int _year; - -protected: - bool select_button(); - void build_ditte_sheet(); - -public: - const int get_year() const { return _year; } - virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); - TDich_periodica_selfirm_mask(); - virtual ~TDich_periodica_selfirm_mask(); -}; - -TDich_periodica_selfirm_mask::TDich_periodica_selfirm_mask() : TAutomask("cg5700a") -{ - _ditte = new TArray_sheet(-1, -1, 70, 15, TR("Selezione Ditte"), - HR("Codice@6R|Ragione Sociale@50")); - TDate oggi(TODAY); - _year = oggi.year(); - - build_ditte_sheet(); -} - -TDich_periodica_selfirm_mask::~TDich_periodica_selfirm_mask() -{ - delete _ditte; -} - -void TDich_periodica_selfirm_mask::build_ditte_sheet() -{ - TTable pum("PUM"); - - _ditte->destroy(); - TPointer_array firms; - TPrefix::firms(firms); - - long good_company = -1; - - FOR_EACH_ARRAY_ITEM(firms, i, obj) - { - TToken_string* d = new TToken_string(63); - const long codditta = firms.get_long(i); - d->add(codditta); - d->add(cache().get(LF_NDITTE, codditta, NDT_RAGSOC)); - const long pos = _ditte->add(d); - - pum.put("CODTAB", _year); - if (pum.read(_isgteq) == NOERR && atoi(pum.get("CODTAB").left(4)) == _year) - { - if (good_company <= 0) - good_company = pos; - } - else - _ditte->disable_row(pos); - } - - if (good_company >= 0) - { - TToken_string& row = _ditte->row(good_company); - set(F_CODDITTA, row.get(0)); - set(F_RAGSOC, row.get(1)); - } - else - { - reset(F_CODDITTA); - reset(F_RAGSOC); - } -} - -bool TDich_periodica_selfirm_mask::select_button() -{ - if (_ditte->run() == K_ENTER) - { - TToken_string& row = _ditte->row(_ditte->selected()); - set(F_CODDITTA, row.get(0)); - set(F_RAGSOC, row.get(1)); - return true; - } - return false; -} - -bool TDich_periodica_selfirm_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) -{ - switch (o.dlg()) - { - case F_CODDITTA: - if (e == fe_button) - return select_button(); - - if (e == fe_modify) - { - bool found = false; - const long ditta = atol(o.get()); - for (long i = 0; i < _ditte->items(); i++) - { - TToken_string& row = _ditte->row(i); - if (ditta == row.get_long(0)) - { - if (_ditte->row_enabled(i)) - { - set(F_CODDITTA, row.get(0)); - set(F_RAGSOC, row.get(1)); - found = true; - } - break; - } - } - if (!found) - o.reset(); - return found; - } - break; - case F_RAGSOC: - if (e == fe_button) - return select_button(); - if (e == fe_modify) - { - bool found = FALSE; - TString16 ditta = o.get(); - for (int i = 0; i < _ditte->items(); i++) - { - TToken_string& row = _ditte->row(i); - TString ts(row.get(1)); - if (ts.find(ditta) != -1) - { - if (_ditte->row_enabled(i)) - { - set(F_CODDITTA, row.get(0)); - set(F_RAGSOC, row.get(1)); - found = TRUE; - break; - } - } - } - if (!found) o.reset(); - return found; - } - break; - case F_YEAR: - if (e == fe_modify) - { - _year = atoi(o.get()); - build_ditte_sheet(); - } - break; - default: - break; - } - - return TRUE; -} - -bool change_prompt(TString& p, int year) -{ - bool changed = FALSE; - if (p.left(2) == "VP") - { - const int vp = atoi(p.mid(2,2)); - if (year >= 2001) - { - if (vp >= 5) - { - switch (vp) - { - case 6: - p = TR("VP11 - IVA detratta per il periodo"); - break; - case 9: - p = TR("VP14 - IVA non versata o in eccesso da dich. prec."); - break; - default: - TString4 n; - n.format("%2d", vp+5); - p.overwrite(n, 2); - break; - } - changed = TRUE; - } - } - } - return changed; -} - - -class TDich_periodica_iva_form : public TForm -{ -public: - TDich_periodica_iva_form(int anno); -}; - -TDich_periodica_iva_form::TDich_periodica_iva_form(int anno) : TForm("cg5700a") -{ - TPrint_section& b = section('B', odd_page); - TString p; - for (int i = b.fields()-1; i > 0; i--) - { - TForm_item& f = b.field(i); - p = f.prompt(); - if (change_prompt(p, anno)) - f.set_prompt(p); - } -} - -class TDich_periodica_iva_mask : public TAutomask -{ - TDich_periodica_selfirm_mask * _sf; - bool _dirty_versament; // Sporco versamento... - -protected: - void read_iva_data(); - real imposta_diff(int tipo) const; - -public: - void set_prospect(); - void print_prospect(); - virtual bool on_key(KEY k); - virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); - TDich_periodica_iva_mask(TDich_periodica_selfirm_mask *m); -}; - -TDich_periodica_iva_mask::TDich_periodica_iva_mask(TDich_periodica_selfirm_mask *m) - : TAutomask("cg5700b") -{ - _sf = m; - - const int anno = _sf->get_int(F_YEAR); - if (anno > 2000) - { - TString p; - for (int i = fields()-1; i > 0; i--) - { - TMask_field& f = fld(i); - p = f.prompt(); - if (change_prompt(p, anno)) - f.set_prompt(p); - } - } -} - -// tipo=1 vendite; 2 = acquisti -real TDich_periodica_iva_mask::imposta_diff(int tipo) const -{ - real imposta; - - const int anno = _sf->get_year(); - const TDate data_da(1,1,anno); - const TDate data_a(31,12,anno); - - TString query; - query << "USE IVADIFF SELECT (BETWEEN(DATAREGP,#DAL,#AL))&&(STR(" - << "(MOV.TOTDOC>0)&&(TIPOMOV>2)&&(MESELIQ<13)&&(TIPOIVA=" << tipo << ')' - << "))"; - query << "\nJOIN MOV INTO NUMREG==NUMREG"; - TISAM_recordset id(query); - id.set_var("#DAL", data_da); - id.set_var("#AL", data_a); - - for (bool ok = id.move_first(); ok; ok = id.move_next()) - imposta += id.get(RMI_IMPOSTA).as_real(); - return imposta; -} - -void TDich_periodica_iva_mask::read_iva_data() -{ - TString8 key; key.format("%4d13", _sf->get_year()); - const TRectype& lim = cache().get("LIM", key); - - if (lim.get_bool("B0")) - { - const TRectype & lam = cache().get("LAM", key); - - TString descrizione(120); - descrizione = lim.get("S0"); - descrizione << lim.get("S1"); - const bool exclude_sign = descrizione.find("$$") >= 0 || descrizione.find(">>") >= 0; - - real cd1_1 = ZERO; - real cd1_2 = ZERO; - real cd1_3 = ZERO; - real cd1_4 = ZERO; - real cd1_5 = ZERO; - real cd2_1 = ZERO; - real cd2_2 = ZERO; - real cd2_3 = ZERO; - real cd2_4 = ZERO; - real cd2_5 = ZERO; - real cd3_1 = ZERO; - real cd3_2 = ZERO; - real cd3_3 = ZERO; - real cd3_4 = ZERO; - - TRelation relpum("PUM"); - TRectype& pum = relpum.curr(); - key.format("%04d",_sf->get_year()); - pum.put("CODTAB", key); - TCursor cur(&relpum, "", 1, &pum, &pum); - - const TRecnotype items = cur.items(); - cur.freeze(); - for (cur = 0L; cur.pos() < items; ++cur) - { - const TString& codtab = pum.get("CODTAB"); - const TString& annoiva = codtab.left(4); - if (annoiva != key) - break; - if (atoi(codtab.right(2)) == 13) // Solo annuale - { - cd1_1 += pum.get_real("R14"); - cd1_2 += pum.get_real("R15"); - cd1_3 += pum.get_real("R16"); - cd1_4 += pum.get_real("R17"); - cd2_1 += pum.get_real("R18"); - cd2_2 += pum.get_real("R19"); - cd2_3 += pum.get_real("R20"); - cd2_4 += pum.get_real("R21"); - cd3_1 += pum.get_real("R22"); - cd3_2 += pum.get_real("R23"); - cd3_3 += pum.get_real("R24"); - cd3_4 += pum.get_real("R25"); - cd2_5 += pum.get_real("R26"); - cd1_5 += pum.get_real("R27"); - } - - } - // Arrotondare tutto all'Euro - cd1_1.round(); cd1_2.round(); cd1_3.round(); cd1_4.round(); cd1_5.round(); - cd2_1.round(); cd2_2.round(); cd2_3.round(); cd2_4.round(); cd2_5.round(); - cd3_1.round(); cd3_2.round(); cd3_3.round(); cd3_3.round(); - - const real rettifica = lim.get_real("R5"); // Rettifiche - - real cd4 = lam.get_real("R0"); // Iva esigibile per il periodo - cd4 += imposta_diff(1); - if (rettifica > ZERO) - cd4 += rettifica; - cd4.round(); - - real cd5 = lam.get_real("R1"); // Iva che si detrae per il periodo - cd5 += imposta_diff(2); - if (rettifica < ZERO && !exclude_sign) - cd5 += abs(rettifica); - cd5.round(); - - const real cd6 = cd4 - cd5; // IVA a debito o credito per il periodo - real cd6_1, cd6_2; - if (cd6 >= ZERO) - cd6_1 = cd6; - else - cd6_2 = -cd6; - - set(F_CD1_1, cd1_1); set(F_CD1_2, cd1_2); set(F_CD1_3, cd1_3); set(F_CD1_4, cd1_4); set(F_CD1_5, cd1_5); - set(F_CD2_1, cd2_1); set(F_CD2_2, cd2_2); set(F_CD2_3, cd2_3); set(F_CD2_4, cd2_4); set(F_CD2_5, cd2_5); - set(F_CD3_1, cd3_1); set(F_CD3_2, cd3_2); set(F_CD3_3, cd3_3); set(F_CD3_4, cd3_4); - set(F_CD4, cd4); set(F_CD5, cd5); - set(F_CD6_1, cd6_1); set(F_CD6_2, cd6_2); - } - else - error_box("Risultati liquidazione non presenti o da ricalcolare per l'anno %d.", _sf->get_year()); - -} - -void TDich_periodica_iva_mask::print_prospect() -{ - const int anno = _sf->get_int(F_YEAR); - TDich_periodica_iva_form frm(anno); - - frm.find_field('B', odd_page, FF_YEAR).set(get(F_YEAR)); - - frm.find_field('B', odd_page, FF_CD1_1).set(get(F_CD1_1)); - frm.find_field('B', odd_page, FF_CD1_2).set(get(F_CD1_2)); - frm.find_field('B', odd_page, FF_CD1_3).set(get(F_CD1_3)); - frm.find_field('B', odd_page, FF_CD1_4).set(get(F_CD1_4)); - frm.find_field('B', odd_page, FF_CD1_5).set(get(F_CD1_5)); - - frm.find_field('B', odd_page, FF_CD2_1).set(get(F_CD2_1)); - frm.find_field('B', odd_page, FF_CD2_2).set(get(F_CD2_2)); - frm.find_field('B', odd_page, FF_CD2_3).set(get(F_CD2_3)); - frm.find_field('B', odd_page, FF_CD2_4).set(get(F_CD2_4)); - frm.find_field('B', odd_page, FF_CD2_5).set(get(F_CD2_5)); - - frm.find_field('B', odd_page, FF_CD3_1).set(get(F_CD3_1)); - frm.find_field('B', odd_page, FF_CD3_2).set(get(F_CD3_2)); - - frm.find_field('B', odd_page, FF_CD3_3).set(get(F_CD3_3)); - frm.find_field('B', odd_page, FF_CD3_4).set(get(F_CD3_3)); - - frm.find_field('B', odd_page, FF_CD4).set(get(F_CD4)); - frm.find_field('B', odd_page, FF_CD5).set(get(F_CD5)); - - frm.find_field('B', odd_page, FF_CD6_1).set(get(F_CD6_1)); - frm.find_field('B', odd_page, FF_CD6_2).set(get(F_CD6_2)); - - TRectype f(LF_NDITTE); - f.put(NDT_CODDITTA, get(F_CODDITTA)); - - frm.cursor()->setregion(f,f); - frm.print(); -} - -void TDich_periodica_iva_mask::set_prospect() -{ - CHECK(_sf, "Invalid mask"); - - _dirty_versament = FALSE; - - const int anno = _sf->get_year(); - const long ditta = _sf->get_long(F_CODDITTA); - - set(F_YEAR, anno); - set(F_CODDITTA, ditta); - set(F_RAGSOC, _sf->get(F_RAGSOC)); - - TFirm frm(ditta); - - TIva_round ir; - ir.set_default_iva_mode(anno, FALSE, ditta); - - read_iva_data(); -} - -bool TDich_periodica_iva_mask::on_key(KEY k) -{ - return TAutomask::on_key(k); -} - -bool TDich_periodica_iva_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) -{ - return TRUE; -} - -class TDich_periodica_iva_app : public TSkeleton_application -{ -protected: - virtual bool create(); - virtual bool destroy(); - virtual void main_loop(); -public: - virtual bool firm_change_enabled() const { return FALSE; } - TDich_periodica_iva_app () {}; - virtual ~TDich_periodica_iva_app () {}; -}; - -bool TDich_periodica_iva_app::create() -{ - open_files(LF_TAB, LF_TABCOM, LF_NDITTE, 0); - return TSkeleton_application::create(); -} - -bool TDich_periodica_iva_app::destroy() -{ - return TSkeleton_application::destroy(); -} - -void TDich_periodica_iva_app::main_loop() -{ - const long ditta = get_firm(); - - TDich_periodica_selfirm_mask* m1 = new TDich_periodica_selfirm_mask(); - while (m1->run() != K_QUIT) - { - if (m1->get(F_CODDITTA).empty() || m1->get(F_RAGSOC).empty()) - { - error_box(TR("Selezionare una ditta")); - continue; - } - - set_firm(m1->get_long(F_CODDITTA)); - - TDich_periodica_iva_mask* m2 = new TDich_periodica_iva_mask(m1); - m2->reset(); - m2->enable_default(); - m2->set_prospect(); - if (m2->run() == K_ENTER) - m2->print_prospect(); - delete m2; - } - delete m1; - - set_firm(ditta); -} - -int cg5700(int argc, char* argv[]) -{ - TDich_periodica_iva_app a; - a.run(argc, argv, TR("Comunicazione annuale dati IVA")); - return 0; -} \ No newline at end of file +// Programma per la gestione e la stampa della dichiarazione periodica IVA +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "cg5700.h" +#include "cglib03.h" + +class TDich_periodica_selfirm_mask : public TAutomask +{ + TArray_sheet * _ditte; + TString_array _nomiditte; + int _year; + +protected: + bool select_button(); + void build_ditte_sheet(); + +public: + const int get_year() const { return _year; } + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + TDich_periodica_selfirm_mask(); + virtual ~TDich_periodica_selfirm_mask(); +}; + +TDich_periodica_selfirm_mask::TDich_periodica_selfirm_mask() : TAutomask("cg5700a") +{ + _ditte = new TArray_sheet(-1, -1, 70, 15, TR("Selezione Ditte"), HR("Codice@6R|Ragione Sociale@50")); +} + +TDich_periodica_selfirm_mask::~TDich_periodica_selfirm_mask() +{ + delete _ditte; +} + +void TDich_periodica_selfirm_mask::build_ditte_sheet() +{ + TTable pum("PUM"); + + _ditte->destroy(); + TPointer_array firms; + TPrefix::firms(firms); + + long good_company = -1; + + FOR_EACH_ARRAY_ITEM(firms, i, obj) + { + TToken_string* d = new TToken_string(63); + const long codditta = firms.get_long(i); + d->add(codditta); + d->add(cache().get(LF_NDITTE, codditta, NDT_RAGSOC)); + const long pos = _ditte->add(d); + + pum.put("CODTAB", _year); + if (pum.read(_isgteq) == NOERR && atoi(pum.get("CODTAB").left(4)) == _year) + { + if (good_company <= 0) + good_company = pos; + } + else + _ditte->disable_row(pos); + } + + if (good_company >= 0) + { + TToken_string& row = _ditte->row(good_company); + set(F_CODDITTA, row.get(0)); + set(F_RAGSOC, row.get(1)); + } + else + { + reset(F_CODDITTA); + reset(F_RAGSOC); + } +} + +bool TDich_periodica_selfirm_mask::select_button() +{ + if (_ditte->run() == K_ENTER) + { + TToken_string& row = _ditte->row(_ditte->selected()); + set(F_CODDITTA, row.get(0)); + set(F_RAGSOC, row.get(1)); + return true; + } + return false; +} + +bool TDich_periodica_selfirm_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + switch (o.dlg()) + { + case F_CODDITTA: + if (e == fe_button) + return select_button(); + + if (e == fe_modify) + { + bool found = false; + const long ditta = atol(o.get()); + for (long i = 0; i < _ditte->items(); i++) + { + TToken_string& row = _ditte->row(i); + if (ditta == row.get_long(0)) + { + if (_ditte->row_enabled(i)) + { + set(F_CODDITTA, row.get(0)); + set(F_RAGSOC, row.get(1)); + found = true; + } + break; + } + } + if (!found) + o.reset(); + return found; + } + break; + case F_RAGSOC: + if (e == fe_button) + return select_button(); + if (e == fe_modify) + { + bool found = false; + TString16 ditta = o.get(); + for (int i = 0; i < _ditte->items(); i++) + { + TToken_string& row = _ditte->row(i); + TString ts(row.get(1)); + if (ts.find(ditta) != -1) + { + if (_ditte->row_enabled(i)) + { + set(F_CODDITTA, row.get(0)); + set(F_RAGSOC, row.get(1)); + found = true; + break; + } + } + } + if (!found) o.reset(); + return found; + } + break; + case F_YEAR: + if (e == fe_init && o.empty()) + { + const TDate oggi(TODAY); + o.set(oggi.year()-1); + e = fe_modify; + } + if (e == fe_modify) + { + _year = atoi(o.get()); + build_ditte_sheet(); + } + break; + default: + break; + } + + return true; +} + +bool change_prompt(TString& p, int year) +{ + bool changed = false; + if (p.left(2) == "VP") + { + const int vp = atoi(p.mid(2,2)); + if (year >= 2001) + { + if (vp >= 5) + { + switch (vp) + { + case 6: + p = TR("VP11 - IVA detratta per il periodo"); + break; + case 9: + p = TR("VP14 - IVA non versata o in eccesso da dich. prec."); + break; + default: + TString4 n; + n.format("%2d", vp+5); + p.overwrite(n, 2); + break; + } + changed = true; + } + } + } + return changed; +} + + +class TDich_periodica_iva_form : public TForm +{ +public: + TDich_periodica_iva_form(int anno); +}; + +TDich_periodica_iva_form::TDich_periodica_iva_form(int anno) : TForm("cg5700a") +{ + TPrint_section& b = section('B', odd_page); + TString p; + for (int i = b.fields()-1; i > 0; i--) + { + TForm_item& f = b.field(i); + p = f.prompt(); + if (change_prompt(p, anno)) + f.set_prompt(p); + } +} + +/////////////////////////////////////////////////////////// +// TDich_periodica_iva_mask +/////////////////////////////////////////////////////////// + +struct Tcd +{ + real cd1_1, cd1_1s, cd1_2, cd1_3, cd1_4, cd1_5; + real cd2_1, cd2_1s, cd2_2, cd2_3, cd2_4, cd2_5; + real cd3_1, cd3_2, cd3_3, cd3_4; + + void Reset() { memset(this,0, sizeof(Tcd)); } +}; + +class TDich_periodica_iva_mask : public TAutomask +{ + TDich_periodica_selfirm_mask * _sf; + bool _dirty_versament; // Sporco versamento... + +protected: + void read_iva_data(); + real imposta_diff(int tipo) const; + void calc_cd_new(int anno, Tcd& s) const; + void calc_cd_old(int anno, Tcd& s) const; + +public: + void set_prospect(); + void print_prospect(); + virtual bool on_key(KEY k); + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + TDich_periodica_iva_mask(TDich_periodica_selfirm_mask *m); +}; + +TDich_periodica_iva_mask::TDich_periodica_iva_mask(TDich_periodica_selfirm_mask *m) + : TAutomask("cg5700b") +{ + _sf = m; + + const int anno = _sf->get_int(F_YEAR); + if (anno > 2000) + { + TString p; + for (int i = fields()-1; i > 0; i--) + { + TMask_field& f = fld(i); + p = f.prompt(); + if (change_prompt(p, anno)) + f.set_prompt(p); + } + } +} + +// tipo=1 vendite; 2=acquisti +real TDich_periodica_iva_mask::imposta_diff(int tipo) const +{ + real imposta; + + const int anno = _sf->get_year(); + const TDate data_da(1,1,anno); + const TDate data_a(31,12,anno); + + TString query; + query << "USE IVADIFF SELECT (BETWEEN(DATAREGP,#DAL,#AL))&&(STR(" + << "(MOV.TOTDOC>0)&&(TIPOMOV>2)&&(MESELIQ<13)&&(TIPOIVA=" << tipo << ')' + << "))"; + query << "\nJOIN MOV INTO NUMREG==NUMREG"; + TISAM_recordset id(query); + id.set_var("#DAL", data_da); + id.set_var("#AL", data_a); + + TProgress_monitor pi(id.items(), TR("Calcolo IVA differita")); + for (bool ok = id.move_first(); ok; ok = id.move_next()) + { + imposta += id.get(RMI_IMPOSTA).as_real(); + pi.add_status(); + } + return imposta; +} + +void TDich_periodica_iva_mask::calc_cd_new(int anno, Tcd& s) const +{ + s.Reset(); + + TString query; + query << "USE MOV KEY 2" + << "\nSELECT (ANNOIVA==#ANNO)" + << "\nFROM DATAREG=#DAL" + << "\nTO DATAREG=#AL"; + + TISAM_recordset movs(query); + movs.set_var("#ANNO", long(anno)); + movs.set_var("#DAL", TDate(1,1,anno)); + movs.set_var("#AL", TDate(31,12,anno)); + + const TRectype& mov = movs.cursor()->curr(LF_MOV); + + TProgress_monitor pi(movs.items(), TR("Ricalcolo righe IVA")); + + TFilename ivalog; ivalog.tempdir(); ivalog.add("cg5700log.txt"); + ofstream flog(ivalog); + flog << "NUMREG\tRIGA\tDATA\tREG\tDIFF\tIMPONIBILE\tIVA\tIMPOSTA\tCD\tNORMALE\tDIFFERITA\tXCASSA\tSPLIT\tNOTE" << endl; + + for (bool go = movs.move_first(); go; go = movs.move_next()) + { + if (!pi.add_status()) + break; + + TToken_string tok(127, '\t'); + tok.add(mov.get(MOV_NUMREG)); + tok.add(0); + tok.add(mov.get(MOV_DATAREG)); + tok.add(mov.get(MOV_REG)); + + TString8 regkey; regkey.format("%04d%s", anno, (const char*)mov.get(MOV_REG)); + const TRectype& reg = cache().get("REG", regkey); + const int tipo_reg = reg.get_int("I0"); + + bool skipped = false; + if (tipo_reg != 1 && tipo_reg != 2) + { + tok.add("Registro nè vendite nè acquisti", 13); + flog << tok << endl; + skipped = true; + } + const int sosp_imp = reg.get_bool("B1") ? reg.get_int("I9") : 0; + if (sosp_imp == 1 || sosp_imp == 3) + { + tok.add("Registro in sospensione", 13); + flog << tok << endl; + skipped = true; + } + + const TString& tipodoc = mov.get(MOV_TIPODOC); + if (tipodoc == "AF") + { + tok.add("Autofattura", 13); + flog << tok << endl; + skipped = true; + } + + const TRectype& cau = cache().get(LF_CAUSALI, mov.get(MOV_CODCAUS)); + const bool iva_intra = cau.get_bool(CAU_INTRACOM); + const bool iva_split = anno >= 2015 && tipo_reg == 1 && is_split_payment(mov); + const bool iva_diff = !iva_split && is_IVA_diff(mov); + const bool iva_cassa = !iva_diff && is_IVAxCassa(mov); + const bool iva_speciale = iva_split || iva_diff || iva_cassa; + + if (iva_speciale) + tok.add(iva_split ? "SPLIT" : (iva_diff ? "DIFF" : "XCASSA"), 4); + + TRecord_array rmoviva(mov.get(MOV_NUMREG), LF_RMOVIVA); + const int nlast = rmoviva.last_row(); + for (int nr = 1; nr <= nlast; nr++) + { + const TRectype& rmi = rmoviva.row(nr); + const real imponibile = rmi.get(RMI_IMPONIBILE); + const real imposta = rmi.get(RMI_IMPOSTA); + const int tipo_cr = rmi.get_int(RMI_TIPOCR); + const TString& codiva = rmi.get(RMI_CODIVA); + const TString4 iva_vpn = skipped ? EMPTY_STRING : cache().get("%IVA", codiva, tipo_reg == 1 ? "S10" : "S11"); + tok.add(nr, 1); + tok.add(imponibile.stringe(0, 2), 5); + tok.add(codiva, 6); + tok.add(imposta.stringe(0, 2), 7); + tok.add(iva_vpn, 8); + if (iva_vpn.blank()) + { + if (!skipped) tok.add("Codice IVA non rilevante", 13); + flog << tok << endl; + continue; + } + + if (tipo_reg == 1) + { + s.cd1_1 += imponibile; + if (iva_speciale) + s.cd1_1s += imponibile; + + if (iva_vpn.starts_with("CD1")) + { + if (tipo_cr == 4) + s.cd1_5 += imponibile; + } + if (!iva_intra) + { + if (iva_vpn == "CD12") + s.cd1_2 += imponibile; else + if (iva_vpn == "CD13") + s.cd1_3 += imponibile; + } + else + { + if (iva_vpn == "CD14") + s.cd1_4 += imponibile; + } + } else + if (tipo_reg == 2) + { + s.cd2_1 += imponibile; + if (iva_speciale) + s.cd2_1s += imponibile; + if (iva_vpn.starts_with("CD2")) + { + if (tipo_cr == 2 || tipo_cr == 3 || tipo_cr == 8) + s.cd2_5 += imponibile; + } + if (!iva_intra) + { + if (iva_vpn == "CD22") + s.cd2_2 += imponibile; + else + if (iva_vpn == "CD23") + s.cd2_3 += imponibile; + } + else + { + if (iva_vpn == "CD24") + s.cd2_4 += imponibile; + } + if (iva_vpn == "CD31") + { + s.cd3_1 += imponibile; + s.cd3_2 += imposta; + } + if (iva_vpn == "CD33") + { + s.cd3_3 += imponibile; + s.cd3_4 += imposta; + } + } + + TToken_string row = tok; + row.add("", 13); + const int index = iva_split ? 12 : (iva_cassa ? 11 : (iva_diff ? 10 : 9)); + row.add(imponibile.stringe(0, 2), index); + flog << row << endl; + } + } +} + +void TDich_periodica_iva_mask::calc_cd_old(int anno, Tcd& s) const +{ + s.Reset(); + + TRelation relpum("PUM"); + TRectype& pum = relpum.curr(); + TString4 key; key.format("%04d", anno); + pum.put("CODTAB", key); + TCursor cur(&relpum, "", 1, &pum, &pum); + + const TRecnotype items = cur.items(); + cur.freeze(); + for (cur = 0L; cur.pos() < items; ++cur) + { + const TString& codtab = pum.get("CODTAB"); + const TString& annoiva = codtab.left(4); + if (annoiva != key) + break; + if (atoi(codtab.right(2)) == 13) // Solo annuale + { + s.cd1_1 += pum.get_real("R14"); + s.cd1_2 += pum.get_real("R15"); + s.cd1_3 += pum.get_real("R16"); + s.cd1_4 += pum.get_real("R17"); + s.cd2_1 += pum.get_real("R18"); + s.cd2_2 += pum.get_real("R19"); + s.cd2_3 += pum.get_real("R20"); + s.cd2_4 += pum.get_real("R21"); + s.cd3_1 += pum.get_real("R22"); + s.cd3_2 += pum.get_real("R23"); + s.cd3_3 += pum.get_real("R24"); + s.cd3_4 += pum.get_real("R25"); + s.cd2_5 += pum.get_real("R26"); + s.cd1_5 += pum.get_real("R27"); + + // Novità 2016 + s.cd1_1s += pum.get_real("R29"); // vendite in split dal 2015 (già comprese in cd1_1!) + } + } +} + +void TDich_periodica_iva_mask::read_iva_data() +{ + const int anno = _sf->get_year(); + TString8 key; key.format("%4d13", anno); + const TRectype& lim = cache().get("LIM", key); + + if (lim.get_bool("B0")) + { + const TRectype& lam = cache().get("LAM", key); + TString descrizione(120); descrizione << lim.get("S0") << lim.get("S1"); + const bool exclude_sign = descrizione.find("$$") >= 0 || descrizione.find(">>") >= 0; + + Tcd cd_old; calc_cd_old(anno, cd_old); + Tcd cd_new; calc_cd_new(anno, cd_new); + + real cd1_1 = cd_new.cd1_1; cd1_1.round(); + real cd1_1s = cd_new.cd1_1s; cd1_1s.round(); + real cd1_2 = cd_new.cd1_2; cd1_2.round(); + real cd1_3 = cd_new.cd1_3; cd1_3.round(); + real cd1_4 = cd_new.cd1_4; cd1_4.round(); + real cd1_5 = cd_new.cd1_5; cd1_5.round(); + + real cd2_1 = cd_new.cd2_1; cd2_1.round(); + real cd2_1s = cd_new.cd2_1s; cd2_1s.round(); + real cd2_2 = cd_new.cd2_2; cd2_2.round(); + real cd2_3 = cd_new.cd2_3; cd2_3.round(); + real cd2_4 = cd_new.cd2_4; cd2_4.round(); + real cd2_5 = cd_new.cd2_5; cd2_5.round(); + + real cd3_1 = cd_new.cd3_1; cd3_1.round(); + real cd3_2 = cd_new.cd3_2; cd3_2.round(); + real cd3_3 = cd_new.cd3_3; cd3_3.round(); + real cd3_4 = cd_new.cd3_4; cd3_4.round(); + + const real rettifica = lim.get_real("R5"); // Rettifiche + + real cd4 = lam.get_real("R0"); // Iva esigibile per il periodo + cd4 += imposta_diff(1); + if (rettifica > ZERO) + cd4 += rettifica; + cd4.round(); + + real cd5 = lam.get_real("R1"); // Iva che si detrae per il periodo + cd5 += imposta_diff(2); + if (rettifica < ZERO && !exclude_sign) + cd5 += abs(rettifica); + cd5.round(); + + const real cd6 = cd4 - cd5; // IVA a debito o credito per il periodo + real cd6_1, cd6_2; + if (cd6 >= ZERO) + cd6_1 = cd6; + else + cd6_2 = -cd6; + + set(F_CD1_1, cd1_1); set(F_CD1_2, cd1_2); set(F_CD1_3, cd1_3); set(F_CD1_4, cd1_4); set(F_CD1_5, cd1_5); + set(F_CD2_1, cd2_1); set(F_CD2_2, cd2_2); set(F_CD2_3, cd2_3); set(F_CD2_4, cd2_4); set(F_CD2_5, cd2_5); + set(F_CD3_1, cd3_1); set(F_CD3_2, cd3_2); set(F_CD3_3, cd3_3); set(F_CD3_4, cd3_4); + set(F_CD4, cd4); set(F_CD5, cd5); + set(F_CD6_1, cd6_1); set(F_CD6_2, cd6_2); + + set(F_CD1_1S, cd1_1s); // dal 2016 + } + else + error_box("Risultati liquidazione non presenti o da ricalcolare per l'anno %d.", anno); +} + +void TDich_periodica_iva_mask::print_prospect() +{ + const int anno = _sf->get_int(F_YEAR); + TDich_periodica_iva_form frm(anno); + + frm.find_field('B', odd_page, FF_YEAR).set(get(F_YEAR)); + + frm.find_field('B', odd_page, FF_CD1_1).set(get(F_CD1_1)); + frm.find_field('B', odd_page, FF_CD1_2).set(get(F_CD1_2)); + frm.find_field('B', odd_page, FF_CD1_3).set(get(F_CD1_3)); + frm.find_field('B', odd_page, FF_CD1_4).set(get(F_CD1_4)); + frm.find_field('B', odd_page, FF_CD1_5).set(get(F_CD1_5)); + + frm.find_field('B', odd_page, FF_CD2_1).set(get(F_CD2_1)); + frm.find_field('B', odd_page, FF_CD2_2).set(get(F_CD2_2)); + frm.find_field('B', odd_page, FF_CD2_3).set(get(F_CD2_3)); + frm.find_field('B', odd_page, FF_CD2_4).set(get(F_CD2_4)); + frm.find_field('B', odd_page, FF_CD2_5).set(get(F_CD2_5)); + + frm.find_field('B', odd_page, FF_CD3_1).set(get(F_CD3_1)); + frm.find_field('B', odd_page, FF_CD3_2).set(get(F_CD3_2)); + + frm.find_field('B', odd_page, FF_CD3_3).set(get(F_CD3_3)); + frm.find_field('B', odd_page, FF_CD3_4).set(get(F_CD3_3)); + + frm.find_field('B', odd_page, FF_CD4).set(get(F_CD4)); + frm.find_field('B', odd_page, FF_CD5).set(get(F_CD5)); + + frm.find_field('B', odd_page, FF_CD6_1).set(get(F_CD6_1)); + frm.find_field('B', odd_page, FF_CD6_2).set(get(F_CD6_2)); + + TRectype f(LF_NDITTE); + f.put(NDT_CODDITTA, get(F_CODDITTA)); + + frm.cursor()->setregion(f,f); + frm.print(); +} + +void TDich_periodica_iva_mask::set_prospect() +{ + CHECK(_sf, "Invalid mask"); + + _dirty_versament = false; + + const int anno = _sf->get_year(); + const long ditta = _sf->get_long(F_CODDITTA); + + set(F_YEAR, anno); + set(F_CODDITTA, ditta); + set(F_RAGSOC, _sf->get(F_RAGSOC)); + + TFirm frm(ditta); + + TIva_round ir; + ir.set_default_iva_mode(anno, false, ditta); + + read_iva_data(); +} + +bool TDich_periodica_iva_mask::on_key(KEY k) +{ + return TAutomask::on_key(k); +} + +bool TDich_periodica_iva_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + return true; +} + +class TDich_periodica_iva_app : public TSkeleton_application +{ +protected: + virtual bool create(); + virtual bool destroy(); + virtual void main_loop(); +public: + virtual bool firm_change_enabled() const { return false; } + TDich_periodica_iva_app () {}; + virtual ~TDich_periodica_iva_app () {}; +}; + +bool TDich_periodica_iva_app::create() +{ + open_files(LF_TAB, LF_TABCOM, LF_NDITTE, 0); + return TSkeleton_application::create(); +} + +bool TDich_periodica_iva_app::destroy() +{ + return TSkeleton_application::destroy(); +} + +void TDich_periodica_iva_app::main_loop() +{ + const long ditta = get_firm(); + + TDich_periodica_selfirm_mask* m1 = new TDich_periodica_selfirm_mask(); + while (m1->run() != K_QUIT) + { + if (m1->get(F_CODDITTA).empty() || m1->get(F_RAGSOC).empty()) + { + error_box(TR("Selezionare una ditta")); + continue; + } + + set_firm(m1->get_long(F_CODDITTA)); + + TDich_periodica_iva_mask* m2 = new TDich_periodica_iva_mask(m1); + m2->reset(); + m2->enable_default(); + m2->set_prospect(); + if (m2->run() == K_ENTER) + m2->print_prospect(); + delete m2; + } + delete m1; + + set_firm(ditta); +} + +int cg5700(int argc, char* argv[]) +{ + TDich_periodica_iva_app a; + a.run(argc, argv, TR("Comunicazione annuale dati IVA")); + return 0; +} diff --git a/cg/cg5700.h b/cg/cg5700.h index 425c6559d..99e745def 100755 --- a/cg/cg5700.h +++ b/cg/cg5700.h @@ -20,6 +20,7 @@ #define F_CD6_2 120 #define F_CD2_5 121 #define F_CD1_5 122 +#define F_CD1_1S 151 #define FF_YEAR 101 #define FF_CODDITTA 102 diff --git a/cg/cg5700a.uml b/cg/cg5700a.uml index 19be4fe83..e3c1013a5 100755 --- a/cg/cg5700a.uml +++ b/cg/cg5700a.uml @@ -1,11 +1,10 @@ #include "cg5700.h" -PAGE "Comunicazione Annuale dati IVA" -1 -1 60 8 +PAGE "Comunicazione Annuale dati IVA" -1 -1 62 4 NUMBER F_YEAR 4 BEGIN PROMPT 1 1 "Anno " - FLAGS "A" END NUMBER F_CODDITTA 5 @@ -20,15 +19,11 @@ BEGIN FLAGS "B" END -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -12 -1 "" -END +ENDPAGE -BUTTON DLG_QUIT 10 2 -BEGIN - PROMPT -22 -1 "" -END +TOOLABR "" 0 0 0 2 + +#include ENDPAGE diff --git a/cg/cg5700b.uml b/cg/cg5700b.uml index e2b1468a6..3a43a5fa2 100755 --- a/cg/cg5700b.uml +++ b/cg/cg5700b.uml @@ -13,144 +13,146 @@ ENDPAGE PAGE "Comunicazione annuale dati IVA" 0 0 0 2 -GROUPBOX DLG_NULL 79 4 +NUMBER F_YEAR 4 BEGIN - PROMPT 0 0 "@bDitta corrente" -END - -NUMBER F_CODDITTA 5 -BEGIN - PROMPT 2 1 "Codice " + PROMPT 1 0 "Anno " FLAGS "D" END +NUMBER F_CODDITTA 5 +BEGIN + PROMPT 12 0 "Rag. Soc. " + FLAGS "HU" +END + STRING F_RAGSOC 50 BEGIN - PROMPT 16 1 "Rag. Soc. " + PROMPT 12 0 "Rag. Soc. " FLAGS "D" END -NUMBER F_YEAR 4 -BEGIN - PROMPT 2 2 "Anno " - FLAGS "D" -END - CURRENCY F_CD1_1 18 BEGIN - PROMPT 1 4 "@bCD1 Operazioni attive " + PROMPT 1 1 "@bCD1 Operazioni attive " FLAGS "D" END CURRENCY F_CD1_2 18 BEGIN - PROMPT 1 5 " di cui: operazioni non imponibili " + PROMPT 1 2 " di cui: operazioni non imponibili " FLAGS "D" END CURRENCY F_CD1_3 18 BEGIN - PROMPT 1 6 " operazioni esenti " + PROMPT 1 3 " operazioni esenti " + FLAGS "D" +END + +CURRENCY F_CD1_1S 18 +BEGIN + PROMPT 1 4 " operazioni in split/differita/per cassa " FLAGS "D" END CURRENCY F_CD1_4 18 BEGIN - PROMPT 1 7 " cessioni intracomunitarie di beni " + PROMPT 1 5 " cessioni intracomunitarie di beni " FLAGS "D" END CURRENCY F_CD1_5 18 BEGIN - PROMPT 1 8 "di cui: cess. beni strumentali " + PROMPT 1 6 "di cui: cess. beni strumentali " FLAGS "D" END CURRENCY F_CD2_1 18 BEGIN - PROMPT 1 9 "@bCD2 Operazioni passive " + PROMPT 1 7 "@bCD2 Operazioni passive " FLAGS "D" END CURRENCY F_CD2_2 18 BEGIN - PROMPT 1 10 " di cui: operazioni non imponibili " + PROMPT 1 8 " di cui: operazioni non imponibili " FLAGS "D" END CURRENCY F_CD2_3 18 BEGIN - PROMPT 1 11 " operazioni esenti " + PROMPT 1 9 " operazioni esenti " FLAGS "D" END CURRENCY F_CD2_4 18 BEGIN - PROMPT 1 12 " acquisti intracomunitari di beni " + PROMPT 1 10 " acquisti intracomunitari di beni " FLAGS "D" END CURRENCY F_CD2_5 18 BEGIN - PROMPT 1 13 "di cui: acq. beni strumentali " + PROMPT 1 11 "di cui: acq. beni strumentali " FLAGS "D" END TEXT -1 BEGIN - PROMPT 1 14 "@bImportazioni di oro industriale e argento puro senza IVA alla dogana " + PROMPT 1 13 "@bImportazioni di oro industriale e argento puro senza IVA alla dogana " END CURRENCY F_CD3_1 18 BEGIN - PROMPT 1 15 "CD3 Imponibile " + PROMPT 1 14 "CD3 Imponibile " FLAGS "D" END CURRENCY F_CD3_2 18 BEGIN - PROMPT 52 15 "Imposta " + PROMPT 52 14 "Imposta " FLAGS "D" END TEXT -1 BEGIN - PROMPT 1 16 "@bRottami e altri materiali di recupero " + PROMPT 1 15 "@bRottami e altri materiali di recupero " END CURRENCY F_CD3_3 18 BEGIN - PROMPT 1 17 "CD3 Imponibile " + PROMPT 1 16 "CD3 Imponibile " FLAGS "D" END CURRENCY F_CD3_4 18 BEGIN - PROMPT 52 17 "Imposta " + PROMPT 52 16 "Imposta " FLAGS "D" END CURRENCY F_CD4 18 BEGIN - PROMPT 1 19 "CD4 Iva esigibile " + PROMPT 1 18 "CD4 Iva esigibile " FLAGS "D" END CURRENCY F_CD5 18 BEGIN - PROMPT 1 20 "CD5 Iva detraibile " + PROMPT 1 19 "CD5 Iva detraibile " FLAGS "D" END + CURRENCY F_CD6_1 18 BEGIN - PROMPT 1 21 "CD6 IVA dovuta " + PROMPT 1 20 "CD6 IVA dovuta " FLAGS "D" END CURRENCY F_CD6_2 18 BEGIN - PROMPT 48 21 "o a credito " + PROMPT 48 20 "o a credito " FLAGS "D" END diff --git a/cg/cg5800.cpp b/cg/cg5800.cpp index 6904fb397..f8b1a0195 100755 --- a/cg/cg5800.cpp +++ b/cg/cg5800.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -234,7 +235,6 @@ void TQuadro_VT_iva_mask::read_iva_data() } else warning_box(FR("Risultati liquidazione non presenti o da ricalcolare per l'anno %d."), _sf->get_year()); - } void TQuadro_VT_iva_mask::print_prospect() diff --git a/cg/cg5800ra.rep b/cg/cg5800ra.rep index 26bbd68c8..24113b33e 100755 --- a/cg/cg5800ra.rep +++ b/cg/cg5800ra.rep @@ -1,5 +1,5 @@ - + Lista privati per regione per quadro VT
diff --git a/cg/cglib01.cpp b/cg/cglib01.cpp index 0963d7b66..0039e0d73 100755 --- a/cg/cglib01.cpp +++ b/cg/cglib01.cpp @@ -522,7 +522,6 @@ real* TRegistro::read_prorata(int anno) const real* prorata = NULL; const TRectype& pla = cache().get("%PLA", chiave); - if (!pla.empty()) prorata = new real(pla.get("R8")); @@ -569,7 +568,7 @@ bool TRegistro::update(long protiva, const TDate& datareg) if (protiva > _rec.get_long("I5")) { _rec.put("I5", protiva); - updated = FALSE; + updated = false; } if (datareg > _rec.get_date("D2")) { @@ -927,7 +926,7 @@ int TBill::compare(const TSortable& s) const // Certified 95% bool TBill::find() { - bool ok = FALSE; + bool ok = false; if ((_tipo != 'C' && _tipo != 'F') || _sottoconto == 0L) { diff --git a/cg/cglib03.cpp b/cg/cglib03.cpp index b2bae5b51..a6ce9aa2d 100755 --- a/cg/cglib03.cpp +++ b/cg/cglib03.cpp @@ -187,7 +187,7 @@ bool is_split_payment(const TRectype& mov) { TISAM_recordset par("USE PART KEY 2 SELECT ANNO<2015\nFROM NREG=#NR\nTO NREG=#NR"); par.set_var("#NR", mov.get_long(MOV_NUMREG)); - if (!par.empty()) // Se la nota si rifersice a partite vecchie non ha lo split payment + if (!par.empty()) // Se la nota si riferisce a partite vecchie non ha lo split payment yes = false; } } diff --git a/cg/cgmenu.men b/cg/cgmenu.men index 3ed57028b..3c83d3534 100755 --- a/cg/cgmenu.men +++ b/cg/cgmenu.men @@ -245,7 +245,7 @@ Flags = "" Item_01 = "Ricezione conti e periodi", "trrice", "" Item_02 = "Tabella piano dei conti", "ab0 -1", "" Item_03 = "Tabella periodi di bilancio", "ab0 -0 %pdb", "" -Item_04 = "Copia aggancio piano dei conti", "vcopia", "" +Item_04 = "Copia aggancio piano dei conti", "vcopia", "" Item_05 = "Calcolo bilanci", "cb0000", "" [CGMENU_026] @@ -257,6 +257,7 @@ Item_01 = "Con iva indetraibile", "cg3 -6 I", "F" Item_02 = "Per tipo costo/ricavo", "cg3 -6 C", "F" Item_03 = "Intracomunitarie", "cg3 -6 N", "F" Item_04 = "Doppie", "cg3 -7", "F" +Item_05 = "Emesse in Split-Payment", "ba8 -4 cgstsplit.rep", "F" [CGMENU_027] Caption = "Gestione acconti IVA" diff --git a/cg/cgstsplit.rep b/cg/cgstsplit.rep new file mode 100644 index 000000000..4db7d0c10 --- /dev/null +++ b/cg/cgstsplit.rep @@ -0,0 +1,114 @@ + + + fatture in split + +
+ + + "Ditta: "+#SYSTEM.RAGSOC + + + "Data di Stampa: "+#SYSTEM.DATE+" - Pag. "+#PAGE + + + + "Lista Fatture emesse in Split Payment nel periodo: "+#DADATA+" - "+#ADATA + + + + + + + + + + + + +
+
+ + MESSAGE RESET,F1 +
+
+ RMOVIVA.CODIVA + + MESSAGE RESET,F2 + + + RMOVIVA.CODIVA + + + MESSAGE TABLEREAD,%IVA,#10,S0 + +
+
+
+ + + RMOVIVA.NUMREG + + + MOV.DATAREG + + + MOV.CODCAUS + + + MOV.REG + + + MOV.CODCF + + + + CLIFO.RAGSOC + + + RMOVIVA.CODIVA + + + RMOVIVA.IMPONIBILE + MESSAGE ADD,F2.100 + + + RMOVIVA.IMPOSTA + MESSAGE ADD,F2.200 + + + MOV.SPLITPAY + + + CLIFO.SPLITPAY + +
+
+
+ + + + +
+
+ + + + #H2.10 + + + #H2.20 + + + MESSAGE ADD,F1.100 + + + MESSAGE ADD,F1.200 + +
+ USE RMOVIVA SELECT ((MOV.SPLITPAY="S")||((MOV.SPLITPAY="")(20.SPLITPAY="X")))BETWEEN(23.DATAREG,#DADATA,#ADATA) +BY RMOVIVA.CODIVA 23.DATAREG +JOIN MOV INTO NUMREG==NUMREG +JOIN CLIFO TO MOV INTO TIPOCF==TIPO CODCF==CODCF + \ No newline at end of file diff --git a/cg/cgstsplit.uml b/cg/cgstsplit.uml new file mode 100644 index 000000000..5361cb9da --- /dev/null +++ b/cg/cgstsplit.uml @@ -0,0 +1,20 @@ + +PA "Estrazione Fatture in Split-Payment" -1 -1 30 4 +DA 120 +BE + PR 4 1 "Dalla data " + FI DADATA + CH REQUIRED +EN + +DA 121 +BE + PR 4 2 "Alla data " + FI ADATA + CH REQUIRED +EN +ENDPAGE +TOOLBAR "topbar" 0 0 0 2 +#include +ENDPAGE +ENDMASK diff --git a/cg/cgtbbnp.h b/cg/cgtbbnp.h index 35b8170a3..2324abc19 100755 --- a/cg/cgtbbnp.h +++ b/cg/cgtbbnp.h @@ -50,6 +50,7 @@ #define F_PROG 153 #define F_CREDITOR_ID 154 #define F_SEPA_FATT 155 +#define F_SEPA_CUC 156 #endif//__CGTBBNP_H diff --git a/cg/cgtbbnp.uml b/cg/cgtbbnp.uml index 2d802d49a..405d7f630 100755 --- a/cg/cgtbbnp.uml +++ b/cg/cgtbbnp.uml @@ -405,7 +405,7 @@ ENDPAGE PAGE "Parametri Distinte" 0 -1 77 20 -GROUPBOX DLG_NULL 78 7 +GROUPBOX DLG_NULL 78 8 BEGIN PROMPT 1 1 "@bParametri distinte SETIF / SEPA" END @@ -436,9 +436,15 @@ BEGIN FIELD S4 END +STRING F_SEPA_CUC 8 +BEGIN + PROMPT 2 6 "Codice CUC assegnato da CBI " + FIELD S5 +END + BOOLEAN F_SEPA_FATT BEGIN - PROMPT 2 6 "Dati fattura dettagliati su bonifici e R.I.D. SEPA" + PROMPT 2 7 "Riferimenti strutturati su bonifici e R.I.D. SEPA" FIELD B3 END