From 283f883c64af2c4e562fbb5ac84cca5d6156ce67 Mon Sep 17 00:00:00 2001 From: bonazzi Date: Thu, 17 May 2018 13:17:16 +0000 Subject: [PATCH] Patch level : 12.0 580 Files correlati : cg4.exe f171.trr f171.dir cg2100c.msk Modifiche alla dichiarazione e alla liquidazione per il volume d'affari (movimenti per cassa) Corretto il calcolo degli abbuoni in prima nota Corretta la ricerca per partita IVA in prima nota git-svn-id: svn://10.65.10.50/branches/R_10_00@24490 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- src/cg/cg2100.cpp | 82 ++++++++++++++++++++-------------------------- src/cg/cg4300.cpp | 35 +------------------- src/cg/cg4301.cpp | 24 ++++++++++---- src/cg/cg4304.cpp | 55 +++++++++++++++++++++---------- src/cg/cg4400a.uml | 2 +- src/cg/cglib01.h | 5 +-- 6 files changed, 95 insertions(+), 108 deletions(-) diff --git a/src/cg/cg2100.cpp b/src/cg/cg2100.cpp index 52609dc63..c893eebef 100755 --- a/src/cg/cg2100.cpp +++ b/src/cg/cg2100.cpp @@ -82,8 +82,7 @@ TMask* TPrimanota_application::load_mask(int n) { m->set_handler(F_DATA74TER, data74ter_handler); m->set_handler(F_PROTIVA, protiva_handler); - m->set_handler(F_CLIENTE, clifo_handler); - m->set_handler(F_FORNITORE, clifo_handler); + m->set_handler(F_CODCLIFOR, clifo_handler); m->set_handler(F_RITFIS, ritfis_handler); m->set_handler(F_RITSOC, ritsoc_handler); m->set_handler(F_CORRISPETTIVO, corrlire_handler); @@ -409,9 +408,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year) const char tipo = nriga == 1 ? 'T' : ' '; if (nriga == 1 && tc.tipo() > ' ' && tc.ok()) - { - m->set(tc.tipo() == 'C' ? F_CLIENTE : F_FORNITORE, tc.sottoconto()); - } + m->set(F_CODCLIFOR, tc.sottoconto()); set_cgs_row(-1,zero,tc,desc,tipo); } } @@ -578,27 +575,18 @@ void TPrimanota_application::init_mask(TMask& m) const TCausale& cc = causale(); const bool corrisp = cc.corrispettivi(); - bool clig = false, forg = false; - if (_iva == iva_acquisti) - forg = true; - else - clig = corrisp ? false : true; // Mostra i gruppo clienti ed eventualmente quello fornitori - if (clig) + if (corrisp) QUI { - m.show(-2, forg); - m.show(-1, clig); + m.hide(-2); + m.hide(-1); } else { - m.show(-1, clig); - m.show(-2, forg); + m.show(-1); + m.show(-2); } - const bool is_forn = forg || (causale().soloiva() && clifo() == "F"); - - m.show(F_CLIENTE, !is_forn); - m.show(F_FORNITORE, is_forn); m.hide(-7); // Nascondi tutti i campi del modulo FE if (corrisp) @@ -837,13 +825,17 @@ void TPrimanota_application::init_insert_mode(TMask& m) occas_mask().reset(); m.hide(F_OCCASEDIT); - const TString& tipo = clifo(); + const TString & tipo = clifo(); + TEdit_field & cf = m.efield(F_CODCLIFOR); m.set(F_CLIFO, tipo); - m.show(F_CLIENTE, tipo == "C"); - m.show(F_RAGSOCCLIENTE, tipo == "C"); - m.show(F_FORNITORE, tipo == "F"); - m.show(F_RAGSOCFORNITORE, tipo == "F"); + cf.set_prompt(tipo == "C" ? "Cliente" : "Fornitore"); + cf.set_warning(tipo == "C" ? "Cliente assente" : "Fornitore assente"); + + TEdit_field & rf = m.efield(F_RAGSOCCF); + + rf.set_warning(tipo == "C" ? "Cliente assente" : "Fornitore assente"); + #ifdef PRORATA100 m.hide(F_ADJUST_PRORATA); // In inserimento non puo' esistere un pro-rata errato! #endif @@ -944,15 +936,18 @@ void TPrimanota_application::init_modify_mode(TMask& m) // Determina se il movimento è stato trasferito da AS/400: // praticamente controlla che non ci sia nessun tipo movimento sulle righe contabili. _as400 = false; - if (iva() != nessuna_iva) + if (iva() != nessuna_iva) { - const TString& tipo = clifo(); + const TString & tipo = _rel->lfile().get(MOV_TIPO); + TEdit_field & cf = m.efield(F_CODCLIFOR); m.set(F_CLIFO, tipo); - m.show(F_CLIENTE, tipo == "C"); - m.show(F_RAGSOCCLIENTE, tipo == "C"); - m.show(F_FORNITORE, tipo == "F"); - m.show(F_RAGSOCFORNITORE, tipo == "F"); + cf.set_prompt(tipo == "C" ? "Cliente" : "Fornitore"); + cf.set_warning(tipo == "C" ? "Cliente assente" : "Fornitore assente"); + + TEdit_field & rf = m.efield(F_RAGSOCCF); + + rf.set_warning(tipo == "C" ? "Cliente assente" : "Fornitore assente"); } if (is_saldaconto() || iva() != nessuna_iva) @@ -1679,12 +1674,12 @@ void TPrimanota_application::genera_automatico(int tipo, const char* causimm) // Reperisce l'eventuale cliente associato al fornitore e lo propone if (tcf_reg == 'F') - m.set(F_FORNITORE, _automatico->_clifo.codclifo()); + m.set(F_CODCLIFOR, _automatico->_clifo.codclifo()); else { TString8 forn; forn.format("F|%ld", _automatico->_clifo.codclifo()); const TString& clnt = cache().get(LF_CLIFO, forn, CLI_CODCFASS); - m.set(F_CLIENTE, clnt); + m.set(F_CODCLIFOR, clnt); } m.set(F_TOTALE, _automatico->_totale); // Imposta il totale documento e ... m.set(F_CODIVA, _automatico->_codiva, true); // ... scatena creazione prima riga IVA @@ -1870,7 +1865,7 @@ bool TPrimanota_application::link_m770() { if (m770 == 1 || m770 == 5) { - const long forn = cm.get_long(F_FORNITORE); + const long forn = cm.get_long(F_CODCLIFOR); if (is_percipient(forn, tipper, codper)) calcola_m770(tipo_coll = 1, spese, compenso, imposte, ritenute); } @@ -2101,7 +2096,7 @@ void TPrimanota_application::ini2mask(TConfig& ini, TMask& msk, bool query) if (msk.insert_mode()) { // Propone condizioni di pagamento e banche - TEdit_field& clifo = msk.efield(iva() == iva_vendite ? F_CLIENTE : F_FORNITORE); + TEdit_field& clifo = msk.efield(F_CODCLIFOR); if (!clifo.empty() && clifo.active()) { clifo.set_focusdirty(); @@ -2395,7 +2390,7 @@ bool TPrimanota_application::link_intra(const TMask& m, const char* action) intro.set("ANNORETT", dataint.year()); intro.set("PERETT", freq.date2periodo(dataint, tipo)); intro.set("STATO", m.get(F_STATOPAIV)); - intro.set("PIVA", tipo == 'B' ? m.get(F_PIVAFORNITORE) : m.get(F_PIVACLIENTE)); + intro.set("PIVA", m.get(F_PIVA)); intro.set("NUMREG", m.get(F_NUMREG)); appname << "in0 -6 /i" << intrini; @@ -2418,18 +2413,11 @@ bool TPrimanota_application::link_intra(const TMask& m, const char* action) intro.set(MOV_NUMREG, m.get(F_NUMREG)); intro.set(MOV_DATAREG, m.get(F_DATAREG)); - if (m.field(F_CLIENTE).shown()) - { - intro.set(MOV_TIPOMOV, "C"); // Cessione - intro.set("TIPOCF", "C"); // Cliente - intro.set(MOV_CODCF, m.get(F_CLIENTE)); - } - else - { - intro.set(MOV_TIPOMOV, "A"); // Acquisto - intro.set("TIPOCF", "F"); // Fornitore - intro.set(MOV_CODCF, m.get(F_FORNITORE)); - } + const TString & tipo = clifo(); + + intro.set(MOV_TIPOMOV, tipo == "C" ? "C" : "A"); // Cessione (TIPO=C) Acquisto (TIPO=F) + intro.set("TIPOCF", tipo); // Cliente + intro.set(MOV_CODCF, m.get(F_CODCLIFOR)); // Controlla flag sulla causale const bool valintra = causale().valintra(); diff --git a/src/cg/cg4300.cpp b/src/cg/cg4300.cpp index e7c2b2953..c0e493dac 100755 --- a/src/cg/cg4300.cpp +++ b/src/cg/cg4300.cpp @@ -360,21 +360,6 @@ bool TLiquidazione_app::user_create() _canprint = is_month_ok_strict(_month) || _month == 13; _isannual = _isriepilogo = _month == 13; - //modifica del 03/05/1995 -/* bool need_refresh = false; - for (int m = 1; m < _month; m++) - { - const TRectype & lim = get_lim(m) ; - - if (is_month_ok_strict(m) && !lim.get_bool("B0")) - { - need_refresh = true; - break; - } - } - if (need_refresh) - _recalc = ever; */ - // determina attivita' prevalente e istanzia cazzuole // per vedere che Kazzo di liquidazione calcolare const TString8 attprev = _nditte->curr().get("CODATTPREV"); @@ -401,24 +386,6 @@ bool TLiquidazione_app::user_create() if (_isprint && _descr_arr.items() > 0) print(); - /*if (!nocalc) - { - // se ci sono altri mesi dopo l'ultimo calcolato, invalida il - // flag 'calcolato' del primo, per causare il ricalcolo dei - // successivi (evitando problemi per credito precedente) - for (int m = _month+1; m <= 13; m++) - { - TRectype lim = get_lim(m); - - if (lim.not_empty()) - { - lim.zero("B0"); - put_lim(lim); - break; - } - } - } */ - TApplication::set_firm(__firm); user_destroy(); } @@ -926,7 +893,7 @@ bool TLiquidazione_app::set_liquidazione() // handlers have set everything _month = _what == trimestre ? m.get_int(CG43_LST_TRIM) : m.get_int(CG43_LST_MESE); - + _year = m.get(CG43_FLD_ANNO); _date = m.get(CG43_FLD_DATA); _isprint = m.get_bool(CG43_CHK_STAMPA); diff --git a/src/cg/cg4301.cpp b/src/cg/cg4301.cpp index f928618b5..8e9b9c95e 100755 --- a/src/cg/cg4301.cpp +++ b/src/cg/cg4301.cpp @@ -575,10 +575,10 @@ bool TLiquidazione_app::update_att(int month, const char* codatt, TAssoc_array & void TLiquidazione_app::zero_att(int month, const char* codatt) { TTable *arr[4] = { _pim, _pis, _prm, _prp }; - const char* flds[] = { "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", + const char* flds[] = { "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", "R11", "R12", "R13", "R14", "R15", "R16", "R17", "R18", "R19", "R20", "R21", "R22", "R23", "R24", "R25", "R26", "R27", "R28", "R29", - "R30", "R31", "R32", "R33", + "R30", "R31", "R32", "R33", "R34", "S0", "S1", "S2", NULL }; TString80 codtab; @@ -920,7 +920,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & real esenti_b14 = ZERO; real vendite_rev = ZERO; // Vendire in reverse charge (da escludere in prorata) real cred_fattrit; - + /* Comunicazione dati iva annuale dal 2016 calcolata in cg5 // Comunicazione dati iva annuale (dal 2003) real cessioni_cd1_1 = ZERO; // Totale operazioni attive @@ -937,8 +937,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & 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 cessioni_cd1_1s = ZERO; // Totale operazioni attive in split payment - */ + 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; @@ -1168,6 +1168,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & const bool corrisp = _reg->get_bool("B0"); const tiporeg tipomov = (tiporeg)_reg->get_int("I0"); // 1=Vendite; 2=Acquisti tipo_movimento tm = (tipo_movimento)_mov->get_int(MOV_TIPOMOV); + real imp_split_payment; if (tm == tm_nessuno) { @@ -1523,7 +1524,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & const real lordo_orig = imponibile_orig + imposta_orig; if (is_split_payment(_mov->curr())) + { imposta_orig = ZERO; + imp_split_payment = imponibile_orig; // Imponibile operazioni attive in split payment + } real diff_imp; // Liquidazione differita imponibile real diff_iva; // Liquidazione differita imposta @@ -2741,7 +2745,9 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & } #endif // fatture vendita a liquidazione differita - tab->curr().add("R26", diff_imp); + if (diff_imp > ZERO) + int i = 1; + tab->curr().add("R26", diff_imp); tab->curr().add("R27", diff_iva); tab->curr().add("R28", incdiff_imp); tab->curr().add("R29", incdiff_iva); @@ -2759,6 +2765,8 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & else { // fatture acquisto a liquidazione differita + if (diff_imp > ZERO) + int i = 1; tab->curr().add("R30", diff_imp); tab->curr().add("R31", diff_iva); tab->curr().add("R32", incdiff_imp); @@ -2774,7 +2782,9 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt, TAssoc_array & } } } - + if (imp_split_payment != ZERO) + tab->curr().add("R34", imp_split_payment); + imp_split_payment = ZERO; tab->rewrite(); // rewrite current table } // for per tabelle } // for is_detraibile diff --git a/src/cg/cg4304.cpp b/src/cg/cg4304.cpp index e38497daf..eacaa560a 100755 --- a/src/cg/cg4304.cpp +++ b/src/cg/cg4304.cpp @@ -2511,6 +2511,13 @@ void TLiquidazione_app::set_grand_2000(_DescrItem& d, int &rw) set_row(rw++, FR("%s@11gCredito IVA compensabile detratto in F24%s@75g%r"), _is_visliq ? "$[r]" : "", _is_visliq ? "$[n]" : "", &credito_utilizzato_F24); credito_utilizzabile -= credito_utilizzato_F24; set_row(rw++,FR("@11gCredito compensabile attuale@58g%r"), &credito_utilizzabile); + if (credito_utilizzabile > ZERO && cre_deb_per < ZERO) + { + const real cred = credito_utilizzabile - cre_deb_per; + + set_row(rw++, FR("@11gCredito complessivo@58g%r"), &cred); + } + } else { @@ -2549,18 +2556,27 @@ static void imp2string(const real& n, TString& str) void TLiquidazione_app::set_iva_succ(int& rw) { TString query; - - query << "USE IVADIFF KEY 2"; - if (!_end_cassa) - query << "\nFROM ANNOLIQ=" << _year; - query << "\nTO ANNOLIQ=" << _year; - TISAM_recordset id(query); const TDate da_datareg(1, 1, atoi(_year)); + const TDate a_datareg(31, 12, atoi(_year)); + + // query << "USE IVADIFF KEY 2 SELECT BETWEEN(DATAREG,#DAL,#AL)"; + query << "USE IVADIFF KEY 4"; + if (!_end_cassa) + query << "\nFROM DATAREG=" << da_datareg; + + query << "\nTO DATAREG=" << a_datareg; + TISAM_recordset id(query); +/* const TDate da_datareg(1, 1, atoi(_year)); const TDate a_datareg(31, 12, atoi(_year)); + + id.set_var("DAL", _end_cassa ? botime : da_datareg); + id.set_var("AL", a_datareg); */ + TImporto ven_diff, ven_xcas, acq_xcas, acq_diff; TString8 codiva; TString8 tipo_aliquota; TToken_string key; + TImporto tot_iva; for (bool ok = id.move_first(); ok; ok = id.move_next()) { @@ -2577,19 +2593,24 @@ void TLiquidazione_app::set_iva_succ(int& rw) if (tipo_aliquota.blank()) { - if (tipoiva == 1) // Vendite + const TDate datapag = id.get(ID_DATAREGP).as_date(); + + if (datapag <= a_datareg) { - if (tipodiff == 1) - ven_diff += imp; + if (tipoiva == 1) // Vendite + { + if (tipodiff == 1) + ven_diff += imp; + else + ven_xcas += imp; + } else - ven_xcas += imp; - } - else - { - if (tipodiff == 1) - acq_diff += imp; - else - acq_xcas += imp; + { + if (tipodiff == 1) + acq_diff += imp; + else + acq_xcas += imp; + } } } } diff --git a/src/cg/cg4400a.uml b/src/cg/cg4400a.uml index 8e83195bd..8961e2c40 100755 --- a/src/cg/cg4400a.uml +++ b/src/cg/cg4400a.uml @@ -162,7 +162,7 @@ LISTBOX FINO_A_MESE 10 BEGIN PROMPT 3 9 "Fino al mese " HELP "Mese fino al quale eseguire la stampa" - FLAGS "M" + FLAGS "M" GROUP 1 END diff --git a/src/cg/cglib01.h b/src/cg/cglib01.h index 93821a829..5249fed3f 100755 --- a/src/cg/cglib01.h +++ b/src/cg/cglib01.h @@ -158,8 +158,9 @@ public: // TObject bool senza_imposta() { return percentuale() == ZERO;} int allegato(char tipocf) const { return get_int(tipocf == 'F' ? "S8" : "S7"); } - bool has_plafond() const { return get_int("S3") > 0; } - + bool has_plafond() const { return get_int("S3") > 0; } + bool sospeso() const { return get_bool("B2"); } + real imposta(const real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Calcola l'imposta sull'imponibile l'imposta e la ritorna real scorpora(real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Scorpora dall'imponibile l'imposta e la ritorna real lordo(const real& imponibile, int ndec = AUTO_DECIMALS, const char * codval = "") const; // Calcola il lordo dell'imponibile l'imposta e la ritorna