From e9f6cac4156c6f523caa7b41bef7182619e728df Mon Sep 17 00:00:00 2001 From: guy Date: Wed, 14 May 2014 08:25:17 +0000 Subject: [PATCH] Corretta gestione ini in banche clifo git-svn-id: svn://10.65.10.50/branches/R_10_00@22933 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg0200.cpp | 82 +++++++++++++++++++++++++------------------------- cg/cg0200a.uml | 59 ++++++++++++++++++------------------ cg/cg2102.cpp | 12 +++++--- cg/cg3600.cpp | 4 +-- cg/cg4301.cpp | 82 +++++++++++++++++++++++++++++++++++++++++--------- cg/cglib01.cpp | 2 +- cg/cglib02.cpp | 21 ++++++++++--- 7 files changed, 164 insertions(+), 98 deletions(-) diff --git a/cg/cg0200.cpp b/cg/cg0200.cpp index 46bdf17a0..e8a5354e6 100755 --- a/cg/cg0200.cpp +++ b/cg/cg0200.cpp @@ -575,7 +575,7 @@ HIDDEN bool codalleg_handler(TMask_field& f, KEY key) return error_box(TR("Codice non utilizzabile: partita IVA e codice fiscale non specificati")); const int tipoall = clifo.get_int(CLI_ALLEG); - if (tipoall != 0 && tipoall != 1 && tipoall != 4 && tipoall != 6) + if (tipoall != 0 && tipoall != 1 && tipoall != 4 && tipoall != 6 && tipoall != 7) return error_box(TR("Codice non utilizzabile: codice inserimento allegato non corretto")); } return true; @@ -985,47 +985,47 @@ void TClifo_application::ini2mask(TConfig& ini, TMask& m, bool query) field_sheet(F_CODINDEFF).add(riga); } } + TString p; + p << LF_CFBAN << ",V"; + TSheet_field & ns_sh = m.sfield(F_BANA); + + for (i = 0; ; i++) + { + TString para(p); para << "," << i + 1; + const TString & abi = ini.get(CFBAN_ABI, para); + if (abi.blank()) + break; + TToken_string & row = ns_sh.row(i); + + row.add(abi, ns_sh.cid2index(F_BBAN_ABI)); + row.add(ini.get(CFBAN_CAB), ns_sh.cid2index(F_BBAN_CAB)); + row.add(ini.get(CFBAN_NUMCC), ns_sh.cid2index(F_BBAN_CONTO)); + + const TString & iban = ini.get(CFBAN_IBAN); + + row.add(iban, ns_sh.cid2index(F_IBAN)); + ns_sh.update_mask(i); + } + + p.cut(0); + p << LF_CFBAN << ",N"; + TSheet_field & vs_sh = m.sfield(F_BANP); + + for (i = 0; ; i++) + { + TString para(p); para << "," << i + 1; + const TString & abi = ini.get(CFBAN_ABI, para); + + if (abi.blank()) + break; + TToken_string & row = vs_sh.row(i); + + row.add(abi, vs_sh.cid2index(F_BBAN_ABI)); + row.add(ini.get(CFBAN_CAB), vs_sh.cid2index(F_BBAN_CAB)); + row.add(ini.get(CFBAN_PROGPR), vs_sh.cid2index(F_PROGPR)); + vs_sh.update_mask(i); + } } - TString p; - - p << LF_CFBAN << ",V"; - TSheet_field & ns_sh = m.sfield(F_BANA); - - for (i = 0; ; i++) - { - TString para(p); para << "," << i + 1; - const TString & abi = ini.get(CFBAN_ABI, para); - if (abi.blank()) - break; - TToken_string & row = ns_sh.row(i); - - row.add(abi, ns_sh.cid2index(F_BBAN_ABI)); - row.add(ini.get(CFBAN_CAB, para), ns_sh.cid2index(F_BBAN_CAB)); - row.add(ini.get(CFBAN_NUMCC, para), ns_sh.cid2index(F_BBAN_CONTO)); - - const TString & iban = ini.get(CFBAN_IBAN, para); - - row.add(iban, ns_sh.cid2index(F_IBAN)); - ns_sh.update_mask(i - 1); - } - p.cut(0); - p << LF_CFBAN << ",N"; - TSheet_field & vs_sh = m.sfield(F_BANP); - - for (i = 0; ; i++) - { - TString para(p); para << "," << i + 1; - const TString & abi = ini.get(CFBAN_ABI, para); - - if (abi.blank()) - break; - TToken_string & row = vs_sh.row(i); - - row.add(abi, vs_sh.cid2index(F_BBAN_ABI)); - row.add(ini.get(CFBAN_CAB, para), vs_sh.cid2index(F_BBAN_CAB)); - row.add(ini.get(CFBAN_PROGPR, para), vs_sh.cid2index(F_PROGPR)); - vs_sh.update_mask(i - 1); - } } int TClifo_application::rewrite(const TMask& m) diff --git a/cg/cg0200a.uml b/cg/cg0200a.uml index 0de17b435..9394a70eb 100755 --- a/cg/cg0200a.uml +++ b/cg/cg0200a.uml @@ -595,37 +595,9 @@ BEGIN GROUP 5 END -STRING F_COMNASC 4 -BEGIN - PROMPT 2 18 "Comune " - FIELD COMNASC - FLAGS "U" - COPY USE F_COMCF - INPUT STATO "" - INPUT COM F_COMNASC - COPY DISPLAY F_COMCF - OUTPUT F_COMNASC COM - OUTPUT F_DENCOMNASC DENCOM - HELP "Codice del comune di nascita del cliente/fornitore" - CHECKTYPE NORMAL - WARNING "Comune assente" - ADD RUN ba4 -0 -END - -STRING F_DENCOMNASC 50 -BEGIN - PROMPT 23 18 "" - USE LF_COMUNI KEY 2 - INPUT DENCOM F_DENCOMNASC - COPY DISPLAY F_DENCOMCF - COPY OUTPUT F_COMNASC - HELP "Nome del comune di nascita" - ADD RUN ba4 -0 -END - NUMBER F_STATONASC 3 BEGIN - PROMPT 2 19 "Stato " + PROMPT 2 18 "Stato " FIELD STATONASC FLAGS "Z" USE %STA @@ -641,7 +613,7 @@ END STRING F_DESTANASC 50 BEGIN - PROMPT 23 19 "" + PROMPT 23 18 "" USE %STA KEY 2 INPUT S0 F_DESTANASC DISPLAY "Stato@60" S0 @@ -649,6 +621,33 @@ BEGIN COPY OUTPUT F_STATONASC END +STRING F_COMNASC 4 +BEGIN + PROMPT 2 19 "Comune " + FIELD COMNASC + FLAGS "U" + COPY USE F_COMCF + INPUT STATO F_STATONASC SELECT + INPUT COM F_COMNASC + COPY DISPLAY F_COMCF + OUTPUT F_COMNASC COM + OUTPUT F_DENCOMNASC DENCOM + HELP "Codice del comune di nascita" + CHECKTYPE NORMAL + WARNING "Comune assente" + ADD RUN ba4 -0 +END + +STRING F_DENCOMNASC 50 +BEGIN + PROMPT 23 19 "" + USE LF_COMUNI KEY 2 + INPUT DENCOM F_DENCOMNASC + COPY DISPLAY F_DENCOMCF + COPY OUTPUT F_COMNASC + HELP "Nome del comune di nascita" + ADD RUN ba4 -0 +END ENDPAGE diff --git a/cg/cg2102.cpp b/cg/cg2102.cpp index 845bd0744..9f24086c0 100755 --- a/cg/cg2102.cpp +++ b/cg/cg2102.cpp @@ -555,19 +555,21 @@ HIDDEN bool imptot_error(const TImporto& imptot, const TImporto& impsal, bool va msg << TR("Il totale documento in valuta") << ' ' << codval; else msg << TR("Il totale documento inserito"); - msg << TR(" e' ") << euro.string(true) << ' ' << imptot.sezione() << ",\n"; + msg << TR(" è ") << euro.string(true) << ' ' << imptot.sezione() << ",\n"; euro.set_num(cassa.valore()); msg << TR("i pagamenti e le spese ammontano a ") << euro.string(true) << ' ' << cassa.sezione() << ",\n"; euro.set_num(residuo.valore()); - msg << TR("per cui il residuo e' ") << euro.string(true); + msg << TR("per cui il residuo è ") << euro.string(true); - if (m.edit_mode() && impsal.is_zero()) + if (impsal.is_zero()) { + /* fastidioso per Pragma msg << TR("\nSi desidera registrare ugualmente?"); ok = a.cgs().yesno_box(msg); + */ } else ok = a.cgs().error_box(msg); @@ -592,7 +594,7 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k) const TRectype& rec = cache().get("%VAL", TCurrency::get_firm_val()); const char* name = rec.get("S0"); - return f.error_box(FR("Il movimento e' sbilanciato di %s %s."), ss, name); + return f.error_box(FR("Il movimento è sbilanciato di %s %s."), ss, name); } TMask& m = f.mask(); @@ -666,7 +668,7 @@ bool TPrimanota_application::cg_handler(TMask_field& f, KEY k) { TString msg(128); const TCurrency euro(speso.valore()); - msg.format("L'importo sul saldaconto della riga %d e' %s", currig, (const char*)euro.string(true)); + msg.format("L'importo sul saldaconto della riga %d è %s", currig, (const char*)euro.string(true)); if (!speso.is_zero()) msg << (speso.sezione() == 'A' ? TR(" Avere") : TR(" Dare")); diff --git a/cg/cg3600.cpp b/cg/cg3600.cpp index b42a1a11f..888143e8d 100755 --- a/cg/cg3600.cpp +++ b/cg/cg3600.cpp @@ -2042,8 +2042,8 @@ void TMastrini_grid::on_record_button(long rec) { _primanoting = true; const TRectype& testata = _mastrino.testata(rec); - bool refresh = testata.edit(); - if (refresh && yesno_box(TR("Si desidera aggiornare il mastrino?"))) + testata.edit(); + if (yesno_box(TR("Si desidera aggiornare il mastrino?"))) reread(); _primanoting = false; } diff --git a/cg/cg4301.cpp b/cg/cg4301.cpp index 5b6d38c0b..1c88d1312 100755 --- a/cg/cg4301.cpp +++ b/cg/cg4301.cpp @@ -155,6 +155,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) // Ritorna FALSE soltanto se il ricalcolo era necessario e non e' // stato effettuato per scelta dello stronzo commercialista. + // Gestione IVA differita, da non confondere con _isdifferita _isdiff = ini_get_bool(CONFIG_DITTA, "cg", "GesLiqDiff"); if (month == 13 && recalc) @@ -171,7 +172,7 @@ bool TLiquidazione_app::update_firm(int month, bool recalc) look_lim(liq_month(month), true); _isdiffacc = is_acconto_differito(); // Gestione differimento acconto IVA - _isdifferita = _isdiffacc; // Gestione IVA differita con stesso flag! + _isdifferita = _isdiffacc; look_lia(); _isintr = _freqviva == "T" && !_lia->get_bool("B3"); // was CNF_DITTA->InTrtr @@ -563,7 +564,8 @@ void TLiquidazione_app::zero_att(int month, const char* codatt) zero_diff(month,codatt); } -bool TLiquidazione_app::ivadiff_chiusa(const TRectype& mov, const TDate& fine) const +/* +static bool ivadiff_chiusa_old(const TRectype& mov, const TDate& fine) { const long numreg = mov.get_long(MOV_NUMREG); @@ -591,6 +593,50 @@ bool TLiquidazione_app::ivadiff_chiusa(const TRectype& mov, const TDate& fine) c const bool chiusa = some_pag && tot.valore() < 0.01; return chiusa; } +*/ + +static bool ivadiff_chiusa_new(const TRectype& mov, const TDate& fine) +{ + bool chiusa = false; + const long numreg = mov.get_long(MOV_NUMREG); + TLocalisamfile id(LF_IVADIFF); + TRectype& rid = id.curr(); + rid.put(MOV_NUMREG, numreg); + int err = id.read(_isgteq); + if (err == NOERR && rid.get_long(MOV_NUMREG) == numreg) + { + chiusa = id.get_bool("CHIUSA"); + if (chiusa) + { + bool some_pag = false; // Ci sono pagamenti? + TImporto tot; + for (; err == NOERR && rid.get_long(MOV_NUMREG) == numreg; err = id.next()) + { + const TDate data = rid.get("DATAREGP"); + if (data > fine) + continue; + const real imp = rid.get(RMI_IMPOSTA); + if (!imp.is_zero()) + { + const char sez = rid.get_char("SEZIONE"); + tot += TImporto(sez, imp); + if (rid.get_int(MOV_TIPOMOV) > 1) + some_pag = true; + } + } + chiusa = some_pag && tot.valore() < 0.01; + } + } + return chiusa; +} + +bool TLiquidazione_app::ivadiff_chiusa(const TRectype& mov, const TDate& fine) const +{ + bool cnew = ivadiff_chiusa_new(mov, fine); + //bool cold = ivadiff_chiusa_old(mov, fine); + // CHECK(cold == cnew, "Cazzo"); + return cnew; +} // Fattura più vecchia di un anno a ente NON pubblico bool TLiquidazione_app::sarebbe_da_pagare(const TRectype& mov, const TDate& fine) const @@ -1060,6 +1106,10 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) if (movdiff && tm == tm_fattura) { + const bool id_chiusa = ivadiff_chiusa(_mov->curr(), inizio); + if (!dok && id_chiusa) + continue; // Salta vecchi movimenti differiti già chiusi + // Sezione preferita per fatture decisa in base a vendita->'A' o acquisto->'D' const char sezfat = tipomov == vendita ? 'D' : 'A'; const char sezpag = tipomov == vendita ? 'A' : 'D'; @@ -1074,7 +1124,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) const TPartita* p = arrpart.first(); const int row = p ? p->mov2rig(numreg, 0) : 0; game_found = row > 0; - if (game_found && !ivadiff_chiusa(_mov->curr(), inizio)) // 25-02-2014 sostituito inizio al posto di fine + if (game_found && !id_chiusa) // 25-02-2014 sostituito inizio al posto di fine { const TRiga_partite& rp = p->riga(row); TImporto pg, nc; @@ -1462,7 +1512,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) //qui da verificare if ((imponibile.is_zero() && imposta.is_zero()) && - (_isdiff && + (movdiff && (is_detraibile > 0 || (diff_imp.is_zero() && diff_iva.is_zero() && incdiff_imp.is_zero() && incdiff_iva.is_zero()) @@ -1482,7 +1532,7 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) // Cumula l'ammontare delle operazioni attive/passive - // per la dichiarazione annuale fati iva + // per la dichiarazione annuale dati iva e quadro VT if (month == 13 && !fattrit) { if (tipomov == vendita) @@ -1512,23 +1562,27 @@ void TLiquidazione_app::recalc_att(int month, const char* codatt) key << "|" << clifo.get(CLI_COMCF); } - const TRectype & comune = cache().get(LF_COMUNI, key); - + const TRectype& comune = cache().get(LF_COMUNI, key); codreg = comune.get_int(COM_CODREG) + 1; } - vt_imponibile[codreg] += imponibile; - vt_imposta[codreg] += imposta; + + if (movdiff) + { + vt_imponibile[codreg] += incdiff_imp; + vt_imposta[codreg] += incdiff_iva; + } + else + { + vt_imponibile[codreg] += imponibile; + vt_imposta[codreg] += imposta; + } } } const TString& iva_vpn = _iva->get(tipomov == vendita ? "S10" : "S11"); if (iva_vpn.full()) { - if (_mov->get(MOV_ANNOIVA) != _year) - { - int cazzone = 2; - } - else + if (_mov->get(MOV_ANNOIVA) == _year) switch (tipomov) { case vendita: // CD1 - 1 2 3 4 diff --git a/cg/cglib01.cpp b/cg/cglib01.cpp index 76e8f84b4..8bc7ea241 100755 --- a/cg/cglib01.cpp +++ b/cg/cglib01.cpp @@ -379,7 +379,7 @@ const TString& cap2comune(const TString& cap, const TString& denom) denominazione.upper(); if (!denominazione.starts_with(pref)) break; - const double fc = xvt_str_fuzzy_compare (up_denom, denominazione); + const double fc = xvt_str_fuzzy_compare(up_denom, denominazione); if (fc > cmp) { cmp = fc; diff --git a/cg/cglib02.cpp b/cg/cglib02.cpp index 910ba0b74..d03dab43d 100755 --- a/cg/cglib02.cpp +++ b/cg/cglib02.cpp @@ -875,6 +875,14 @@ void TSaldo_agg::aggiorna(const TRectype& rmov, bool somma, bool scaricato) const char sez = rmov.get_char(RMV_SEZIONE); const TImporto importo(sez, imp); const TBill bill(rmov); + + const long numreg = rmov.get_long(RMV_NUMREG); + if (numreg > _num_ulmov) + { + _num_ulmov = numreg; + _data_ulmov = rmov.get_date(RMV_DATAREG); + _anno_es = rmov.get_int(RMV_ANNOES); + } aggiorna(bill, importo, somma, scaricato); } } @@ -945,8 +953,8 @@ void TSaldo_agg::registra() { THash_object* hobj = _tab_conti.get_hashobj(); TContoExt& tcon = (TContoExt&)hobj->obj(); - CHECK(tcon.ok(), "Tentativo di saldare un conto incompleto"); const int annoes = atoi(hobj->key().left(4)); + CHECK(tcon.ok() && annoes > 2000, "Tentativo di saldare un conto incompleto"); saldi.zero(); saldi.put(SLD_ANNOES, annoes); @@ -1005,13 +1013,16 @@ void TSaldo_agg::registra() r = tcon.saldo(); si = saldi.get_real(SLD_SALDO); flag_salini = saldi.get_char(SLD_FLAGSALINI); - if (r != ZERO) + if (!r.is_zero()) { - if (flag_salini == 'A') si = r - si; - else si += r; + if (flag_salini == 'A') + si = r - si; + else + si += r; if (si < ZERO) { - flag_salini = 'A'; si = -si; + flag_salini = 'A'; + si = -si; } else flag_salini = 'D';