From 758ffd8c4c90ee0ae48bedeb4584be7816d98a7e Mon Sep 17 00:00:00 2001 From: Simone Palacino Date: Tue, 8 Sep 2020 14:47:48 +0200 Subject: [PATCH] Patch level : 12.0 994 Files correlati : ve5.exe batbclr.msk batbiva.msk fp0.exe ve5.exe ve0300a.src vemenu.men vetbspp.msk vetbtip.msk Commento : - Aggiornamento codici per nuovo tracciato in vigore dall'1 Ottobre: TipoDocSDI TipoRitenute Pagamenti - Modificata esportazione fp per lettura Nuovi codici per le ritenute dalle SPESE. --- build/Ba3.vcxproj | 6 +- build/Ba3.vcxproj.filters | 6 - build/ba.sln | 8 + build/ve5.vcxproj | 3 + build/ve5.vcxproj.filters | 9 + src/ba/batbclr.uml | 1 + src/ba/batbiva.uml | 41 ++- src/fe/felib.cpp | 518 -------------------------------------- src/fp/fplib01.cpp | 10 +- src/ve/clifor.cpp | 330 ------------------------ src/ve/ve0300a.src | 2 +- src/ve/ve5.cpp | 1 + src/ve/ve5.h | 1 + src/ve/velib.h | 1 + src/ve/vemenu.men | 1 + src/ve/vetbspp.h | 4 +- src/ve/vetbspp.uml | 13 + src/ve/vetbtip.uml | 13 +- 18 files changed, 93 insertions(+), 875 deletions(-) diff --git a/build/Ba3.vcxproj b/build/Ba3.vcxproj index a98502cc8..1e9b1b2d1 100644 --- a/build/Ba3.vcxproj +++ b/build/Ba3.vcxproj @@ -229,9 +229,6 @@ %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) @@ -284,6 +281,9 @@ {2d38a763-3d74-4338-9362-b891784ec90e} + + {7b80f974-ce2e-4bd9-855a-44ff139ff288} + diff --git a/build/Ba3.vcxproj.filters b/build/Ba3.vcxproj.filters index ecfae2123..0b4bec035 100644 --- a/build/Ba3.vcxproj.filters +++ b/build/Ba3.vcxproj.filters @@ -54,12 +54,6 @@ Sources - - Sources - - - Sources - diff --git a/build/ba.sln b/build/ba.sln index 62efdf77d..c5433913a 100644 --- a/build/ba.sln +++ b/build/ba.sln @@ -49,6 +49,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fastrip", "fastrip.vcxproj" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "patchdef", "patchdef.vcxproj", "{2DCB2E4A-EFB6-4561-8D87-C5ADBDB76533}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cglib", "cglib.vcxproj", "{7B80F974-CE2E-4BD9-855A-44FF139FF288}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -197,6 +199,12 @@ Global {2DCB2E4A-EFB6-4561-8D87-C5ADBDB76533}.Release|Win32.ActiveCfg = Release|Win32 {2DCB2E4A-EFB6-4561-8D87-C5ADBDB76533}.Release|Win32.Build.0 = Release|Win32 {2DCB2E4A-EFB6-4561-8D87-C5ADBDB76533}.Release|x64.ActiveCfg = Release|Win32 + {7B80F974-CE2E-4BD9-855A-44FF139FF288}.Debug|Win32.ActiveCfg = Debug|Win32 + {7B80F974-CE2E-4BD9-855A-44FF139FF288}.Debug|Win32.Build.0 = Debug|Win32 + {7B80F974-CE2E-4BD9-855A-44FF139FF288}.Debug|x64.ActiveCfg = Debug|Win32 + {7B80F974-CE2E-4BD9-855A-44FF139FF288}.Release|Win32.ActiveCfg = Release|Win32 + {7B80F974-CE2E-4BD9-855A-44FF139FF288}.Release|Win32.Build.0 = Release|Win32 + {7B80F974-CE2E-4BD9-855A-44FF139FF288}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/build/ve5.vcxproj b/build/ve5.vcxproj index 31a38e8e7..5cd6deb09 100644 --- a/build/ve5.vcxproj +++ b/build/ve5.vcxproj @@ -191,6 +191,7 @@ %(AdditionalIncludeDirectories) %(PreprocessorDefinitions) + @@ -199,6 +200,7 @@ + @@ -207,6 +209,7 @@ + diff --git a/build/ve5.vcxproj.filters b/build/ve5.vcxproj.filters index 5cc7f96da..569a335c0 100644 --- a/build/ve5.vcxproj.filters +++ b/build/ve5.vcxproj.filters @@ -36,6 +36,9 @@ Sources + + Sources + @@ -56,6 +59,9 @@ Masks + + Masks + @@ -76,6 +82,9 @@ Headers + + Headers + diff --git a/src/ba/batbclr.uml b/src/ba/batbclr.uml index 180556eb6..5200ef954 100755 --- a/src/ba/batbclr.uml +++ b/src/ba/batbclr.uml @@ -80,6 +80,7 @@ BEGIN ITEM "MP20|SEPA Direct Debit CORE" ITEM "MP21|SEPA Direct Debit B2B" ITEM "MP22|Trattenuta su somme già riscosse" + ITEM "MP23|PagoPA" END STRING F_DESCR 50 diff --git a/src/ba/batbiva.uml b/src/ba/batbiva.uml index bdbd4447f..b6fd8a700 100755 --- a/src/ba/batbiva.uml +++ b/src/ba/batbiva.uml @@ -311,19 +311,36 @@ BEGIN FIELD B3 END -LIST FLD_NATURA 2 40 +LIST FLD_NATURA 4 81 BEGIN -PROMPT 3 19 "Natura: " -FIELD S12 -HELP "Indicare la natura del codice IVA per le fatture PA/TF" -ITEM "|IVA ordinaria" -ITEM "N1|N1 - IVA esclusa ex art 15" -ITEM "N2|N2 - IVA non soggetta" -ITEM "N3|N3 - IVA non imponibile" -ITEM "N4|N4 - IVA esente" -ITEM "N5|N5 - IVA in regime del margine" -ITEM "N6|N6 - IVA in reverse charge" -ITEM "N7|N7 - IVA assolta in altro stato U3" + PROMPT 3 19 "Natura: " + FIELD S12 + HELP "Indicare la natura del codice IVA per le fatture PA/TF" + ITEM "|IVA ordinaria" + ITEM "N1|N1 IVA esclusa ex art 15" + ITEM "N2|N2 IVA non soggetta (DEPRECATA)" + ITEM "N2.1|N2.1 Non soggette ad IVA ai sensi degli artt. da 7 a 7-septies del DPR 633/72" + ITEM "N2.2|N2.2 Non soggette - altri casi" + ITEM "N3|N3 IVA non imponibile (DEPRECATA)" + ITEM "N3.1|N3.1 Non impon. - esportazioni" + ITEM "N3.2|N3.2 Non impon. - cessioni intracomunitarie" + ITEM "N3.3|N3.3 Non impon. - cessioni verso San Marino" + ITEM "N3.4|N3.4 Non impon. - operazioni assimilate alle cessioni all'esportazione" + ITEM "N3.5|N3.5 Non impon. - a seguito di dichiarazioni d'intento" + ITEM "N3.6|N3.6 Non impon. - altre operazioni che non concorrono alla formazioni del plafond" + ITEM "N4|N4 IVA esente" + ITEM "N5|N5 IVA in regime del margine" + ITEM "N6|N6 IVA in reverse charge (DEPRECATA)" + ITEM "N6.1|N6.1 Invers. cont. - cessione di rottami e altri materiali di recupero" + ITEM "N6.2|N6.2 Invers. cont. - cessione di oro e argento puro" + ITEM "N6.3|N6.3 Invers. cont. - subappalto nel settore edile" + ITEM "N6.4|N6.4 Invers. cont. - cessione di fabbricati" + ITEM "N6.5|N6.5 Invers. cont. - cessione di telefoni cellulari" + ITEM "N6.6|N6.6 Invers. cont. - cessione di prodotti elettronici" + ITEM "N6.7|N6.7 Invers. cont. - prestazioni comparto edile e settori connessi" + ITEM "N6.8|N6.8 Invers. cont. - operazioni settore energetico" + ITEM "N6.9|N6.9 Invers. cont. - altri casi" + ITEM "N7|N7 IVA assolta in altro stato U3" END BOOLEAN FLD_NUM_B6 diff --git a/src/fe/felib.cpp b/src/fe/felib.cpp index dea70ed86..8c5c06032 100644 --- a/src/fe/felib.cpp +++ b/src/fe/felib.cpp @@ -117,524 +117,6 @@ bool fe_decode_cofi(const TString& cofi, char& sex_nasc, TDate& dt_nasc, TString return true; } - -/////////////////////////////////////////////////////////// -// TAnagrafica -/////////////////////////////////////////////////////////// - -static bool is_stato_estero(const TString& codcom) -{ return codcom.full() && codcom.match("Z[0-9][0-9][0-9]"); } - -static const TString& comune_di(const TString& codcom, int stato) -{ - if (codcom.blank() || codcom.len() != 4) - return EMPTY_STRING; - - TString8 key; - if (stato > 0) - key.format("%03d", stato); - key << '|' << codcom; - return cache().get(LF_COMUNI, key, COM_DENCOM); -} - -static const TString& provincia_di(const TString& codcom) -{ - if (codcom.blank() || codcom.len() != 4) - return EMPTY_STRING; - TString& prov = get_tmp_string(); - if (is_stato_estero(codcom)) - prov = "EE"; - else - { - TString8 key; key << '|' << codcom; - prov = cache().get(LF_COMUNI, key, COM_PROVCOM); - if (prov.len() > 2) prov = "RM"; - } - return prov; -} - -const TString& TAnagrafica::comune_nascita() const -{ - if (is_stato_estero(_com_nasc)) - { - const TString& c = comune_di(_com_nasc, 0); - if (c.full()) - return c; - } - if (_stato_nasc > 0) - { - TString4 u; u.format("%03d", _stato_nasc); - const TString& s = cache().get("%STA", u, "S0"); - if (s.full()) - return s; - } - return comune_di(_com_nasc, _stato_nasc); -} - -const TString& TAnagrafica::provincia_nascita() const -{ - if (_stato_nasc > 0 || is_stato_estero(_com_nasc)) - return get_tmp_string() = "EE"; - return provincia_di(_com_nasc); -} - -const TString& TAnagrafica::comune_residenza() const -{ - const TString& cr = comune_di(_com_res, _stato_estero); - if (cr.full()) - return cr; - return _loc_res; -} - -const TString& TAnagrafica::provincia_residenza() const -{ - if (estero()) - return get_tmp_string() = "EE"; - return provincia_di(_com_res); -} - -const TString& TAnagrafica::stato_residenza_ISO() const -{ - if(italiano()) - return get_tmp_string() = "IT"; - else - { - TString4 u; u.format("%03d", _stato_estero); - return cache().get("%STA", u, "S10"); - } -} - -void TAnagrafica::build_ind_res(const TRectype& rec, const char* ind, const char* civ) -{ - _via_res = _ind_res = rec.get(ind); - _civ_res = rec.get(civ); - - if (_civ_res.blank()) - { - const int comma = _via_res.rfind(','); - if (comma > 0 && _via_res.len()-comma <= 8) - { - _civ_res = _via_res.mid(comma+1); _civ_res.trim(); - _via_res.cut(comma); _via_res.trim(); - } - } - - if (_via_res.full()) - { - TString80 ind = _via_res; - if (_civ_res.full()) - ind << ", " << _civ_res; - ind.strip_double_spaces(); - TParagraph_string s(ind, 40); - _ind_res = s.get(0); // prende solo i primi 40 caratteri dell'indirizzo completo - } - - // Sistema persone senza codice stato, ma residenti in comune estero - if (_stato_estero <= 0 && is_stato_estero(_com_res)) - { - const TString80 naz = comune_di(_com_res, 0); - TString query; query.format("USE %%STA KEY 2\nFROM S0=%c\nTO S0=%c", naz[0], naz[0]); - TISAM_recordset sta(query); - double dBest = 0; - int nBest = 0; - for (bool ok = sta.move_first(); ok; ok = sta.move_next()) - { - const double s = xvt_str_fuzzy_compare(naz, sta.get("S0").as_string()); - if (s > dBest) - { - nBest = sta.get("CODTAB").as_int(); - dBest = s; - if (dBest >= 1.0) - break; - } - } - if (dBest > 0.8) - _stato_estero = nBest; - } -} - -const TString& TAnagrafica::ragione_sociale() const -{ - if (fisica()) - { - TString& rs = get_tmp_string(); - rs = _ragsoc; - return rs.strip_double_spaces(); - } - return _ragsoc; -} - -const TString& TAnagrafica::cognome() const -{ - TString& c = get_tmp_string(); - c = _ragsoc.left(30); - return c.trim(); -} - -const TString& TAnagrafica::nome() const -{ - CHECK(fisica(), "Non chiedere nome giuridico!"); - TString& c = get_tmp_string(); - c = _ragsoc.mid(30,20); - return c.trim(); -} - -bool TAnagrafica::italiano() const -{ return _stato_estero == 0 && !is_stato_estero(_com_res); } - -bool TAnagrafica::estero_CEE() const -{ - return estero() && cache().get("%SCE", stato_residenza_ISO(), "B0"); -} - -const TString& TAnagrafica::stato_estero_UNICO() const -{ - if (_stato_estero <= 0) - return EMPTY_STRING; - - TString4 u; u.format("%03d", _stato_estero); - const TString& cod = cache().get("%STA", u, "S8"); // S8=UNICO S9=ISTAT S10=ISO - if (cod.len() == 3) - return cod; - return get_tmp_string() = u; -} - -const TString& TAnagrafica::stato_partita_IVA() const -{ - TString& str = get_tmp_string(); - if (_stato_paiv.full()) - str = _stato_paiv; - else if(italiano()) - { - str = "IT"; - } - return str; -} - -char TAnagrafica::is_black_list(const TDate& datareg) const -{ - char is_black = ' '; - if (_stato_estero > 0) - { - TString4 u; u.format("%03d", _stato_estero); - const TRectype& sta = cache().get("%STA", u); - - if (sta.get_bool("B1")) // San Marino - { - if (datareg.date2ansi() < TDate(24,2,2014)) - is_black = 'M'; - } - else - { - if (sta.get_bool("B0")) // Black List - is_black = 'S'; - } - } - return is_black; -} - -void TAnagrafica::split_ragsoc() -{ - if (_tipo == 'F') - { - if (nome().blank()) - { - const int space = _ragsoc.find(' '); - if (space >= 4) - { - TString80 nom = _ragsoc.mid(space+1); - nom.cut(20); - _ragsoc.cut(space); - _ragsoc.insert(nom, 30); - } - } - } - else - _ragsoc.strip_double_spaces(); - _ragsoc.replace('"', '\''); // gli " creano casini nel csv -} - -bool TAnagrafica::init(const TRectype& rec) -{ - _tipo = '\0'; - _sociounico = '\0'; - _stato_estero = _stato_nasc = 0; - _allegato = 0; - _ragsoc.cut(0); - if (rec.empty()) - return false; - - bool is_firm = false; - - switch (rec.num()) - { - case LF_OCCAS: - _cofi = rec.get(OCC_COFI); - _paiv = rec.get(OCC_PAIV); - if (_cofi.blank() || _paiv.blank()) - { - const TString& codice = rec.get(OCC_CFPI); - if (_cofi.blank() && cf_check("", codice)) - _cofi = codice; - if (_paiv.blank() && pi_check("", codice)) - _paiv = codice; - } - _ragsoc = rec.get(OCC_RAGSOC); - _data_nasc = rec.get(OCC_DNASC); - _stato_nasc = rec.get_int(OCC_STATONASC); - _com_nasc = rec.get(OCC_COMNASC); - _stato_estero = rec.get_int(OCC_STATO); - _com_res = rec.get(OCC_COM); - _loc_res = rec.get(OCC_LOCALITA); - _cap_res = rec.get(OCC_CAP); - build_ind_res(rec, OCC_INDIR, OCC_CIV); - if (_com_nasc.full() || (!_stato_estero && !real::is_natural(_cofi) || cf_check("", _cofi))) - { - _tipo = 'F'; - if (_cofi.full() && (!_data_nasc.ok()) || _com_nasc.blank()) - { - char sex = 'X'; - fe_decode_cofi(_cofi, sex, _data_nasc, _com_nasc); - } - } - else - _tipo = 'G'; - _allegato = _tipo == 'F' ? 6 : 2; - break; - case LF_ANAG: - _tipo = rec.get_char(ANA_TIPOA); - _ragsoc = rec.get(ANA_RAGSOC); - _cofi = rec.get(ANA_COFI); - _cofiest = rec.get(ANA_COFIEST); - _paiv = rec.get(ANA_PAIV); - _stato_paiv = rec.get(ANA_STATOPAIV); - - if (_ragsoc.starts_with("EYCK")) - int zingara = 1; - - // Comune di residenza fiscale o domicilio - _stato_estero = rec.get_int(ANA_STATORES); - _com_res = rec.get(ANA_COMRF); - if (_com_res.empty()) - _com_res = rec.get(ANA_COMRES); - build_ind_res(rec, ANA_INDRES, ANA_CIVRES); - _cap_res = rec.get(ANA_CAPRES); - - // Dati di nascita persone fisiche - if (_tipo == 'F' || (italiano() && isalpha(_cofi[0]))) - { - const long codana = rec.get_long(ANA_CODANAGR); - if (codana > 0) - { - const TRectype& anafis = cache().get(LF_ANAGFIS, codana); - _data_nasc = anafis.get(ANF_DATANASC); - _stato_nasc = anafis.get_int(ANF_STATONASC); - _com_nasc = anafis.get(ANF_COMNASC); - if ((!_data_nasc.ok() || _com_nasc.blank()) && cf_check("", _cofi)) - { - char sex = 'X'; - fe_decode_cofi(_cofi, sex, _data_nasc, _com_nasc); - } - } - } - else - _tipo = 'G'; - break; - case LF_NDITTE: - { - const char tipoa = rec.get_char(NDT_TIPOA); - const long codana = rec.get_long(NDT_CODANAGR); - const bool good = init(LF_ANAG, tipoa, codana); - _sociounico = rec.get_char(NDT_SOCIOUNICO); - if (_tipo == 'G') - { - _ragsoc = rec.get(NDT_RAGSOC); - split_ragsoc(); - } - return good; - } - break; - case LF_CLIFO: - _allegato = rec.get_int(CLI_ALLEG); - if (_allegato == 4) - { - const long ca = rec.get_long(CLI_CODALLEG); - if (ca > 0) - return init(rec.get_char(CLI_TIPOCF), ca, EMPTY_STRING); - } - - _tipo = ' '; // Non faccio assunzioni sulla persona fisica - - is_firm = (rec.get_char(CLI_TIPOPERS) == 'G' || rec.get_char(CLI_TIPOAPER) == 'G' || _allegato == 7) && (_allegato != 6); - if (!is_firm && rec.get(CLI_PAIV).full()) - { - TString80 rs = rec.get(CLI_RAGSOC); rs.lower(); - const char* soc[] = { "&", "azienda ", " sas ", " s.a.s.", " snc", " s.n.c.", " srl", " s.r.l.", - "coop.", "cooperativa", " s.n.c.", " srl", " s.r.l.", " s.p.a", " s.a.", NULL }; - for (int s = 0; soc[s] && !is_firm; s++) - is_firm = rs.find(soc[s]) > 0; - if (!is_firm) - is_firm = rs.ends_with(" spa") || (rs.find(" di ") > 15); // Shopping Point di Karoline Reiner - } - - if (!is_firm) - { - bool has_cofi = false; // Codice fiscale alfanumerico? - const TString& cli_cofi = rec.get(CLI_COFI); - if (cli_cofi.full() && isalpha(cli_cofi[0])) - has_cofi = cf_check(rec.get(CLI_STATOPAIV), cli_cofi); - - // Persona Fisica? - if (rec.get_char(CLI_TIPOAPER) == 'F' || rec.get_date(CLI_DATANASC).ok() || has_cofi || _allegato == 6) - { - const long cod = rec.get_long(CLI_CODANAGPER); // Percipiente? - if (cod > 0) - init(LF_ANAG, 'F', cod); - - _tipo = 'F'; - _data_nasc = rec.get_date(CLI_DATANASC); - if (!_data_nasc.ok() && has_cofi) - { - char sex = 'X'; - fe_decode_cofi(cli_cofi, sex, _data_nasc, _com_nasc); - } - - if (_com_nasc.blank()) - { - _com_nasc = rec.get(CLI_COMNASC); - if (_com_nasc.blank() && has_cofi) - { - char sex = 'X'; - fe_decode_cofi(cli_cofi, sex, _data_nasc, _com_nasc); - } - } - if (_stato_nasc <= 0) - _stato_nasc = rec.get_int(CLI_STATONASC); - if (_com_nasc.blank() && _stato_nasc > 0) - { - TString4 sn; sn.format("%03d", _stato_nasc); - const TString80 stato = cache().get("%STA", sn, "S0"); - TISAM_recordset comuni("USE COMUNI\nFROM COM=Z\nTO STATO=\"0~\""); - double best = 0.8; - for (bool ok = comuni.move_first(); ok; ok = comuni.move_next()) - { - const TString& desc = comuni.get(COM_DENCOM).as_string(); - const double score = xvt_str_fuzzy_compare_ignoring_case(desc, stato); - if (score > best) - { - best = score; - _stato_nasc = 0; - _com_nasc = comuni.get(COM_COM).as_string(); - if (best >= 1.0) - break; - } - } - } - } - } - - // Assegno codice fiscale e partita IVA se validi, altrimenti mantengo quelli dell'anagrafica - if (rec.get(CLI_COFI).full()) - _cofi = rec.get(CLI_COFI); - if (rec.get(CLI_PAIV).full()) - { - _paiv = rec.get(CLI_PAIV); - _stato_paiv = rec.get(CLI_STATOPAIV); - } - - if (_allegato != 5 && _allegato != 9) - { - if (_stato_paiv.blank() || _stato_paiv == "IT") - { - // Ci sono anagrafiche con codice fiscale numerico e partita IVA vuota! - // I codici fiscali che cominciano per 8 e 9 sono le associazioni riconosciute e non, rispettivamente. - if (_paiv.blank() && pi_check(_stato_paiv, _cofi) && _cofi[0] < '8') - _paiv = _cofi; - if (_paiv.len() == 11 && pi_check(_stato_paiv, _paiv) && (_paiv[0] == '8' || _paiv[0] == '9')) - { - if (_cofi.blank()) - _cofi = _paiv; - _paiv.cut(0); - } - } - } - - // Prevale sempre la ragione sociale del cliente: "Il cliente ha sempre ragione". - _ragsoc = rec.get(CLI_RAGSOC); - - _loc_res = rec.get(CLI_LOCCF); - _cap_res = rec.get(CLI_CAPCF); - _stato_estero = rec.get_int(CLI_STATOCF); - if (_stato_estero <= 0 && (_allegato == 5 || _allegato == 9)) // Estero CEE o extra-CEE - _stato_estero = -1; // Stato estero ignoto - _com_res = rec.get(CLI_COMCF); - build_ind_res(rec, CLI_INDCF, CLI_CIVCF); - - if (_tipo != 'F' && _tipo != 'G') - { - switch (_allegato) - { - case 6: _tipo = 'F'; break; // Privato - case 7: _tipo = 'G'; break; // Ente pubblico - case 8: _tipo = 'G'; break; // Fallimento - default: - if (_com_nasc.full()) - _tipo = 'F'; - else - { - _tipo = rec.get_char(CLI_TIPOPERS); - if (_tipo != 'F' || is_firm) - _tipo = 'G'; - } - break; - } - } - if (_tipo == 'G' || _ragsoc.len() <= 30) - split_ragsoc(); - break; - case LF_MOV: - return init(rec.get_char(MOV_TIPO), rec.get_long(MOV_CODCF), rec.get(MOV_OCFPI)); - case LF_ALLEG: - return init(rec.get_char(ALL_TIPOCF), rec.get_long(ALL_CODCF), rec.get(ALL_OCFPI)); - case LF_EFFETTI: - return init(rec.get_char(EFF_TIPOCF), rec.get_long(EFF_CODCF), EMPTY_STRING); - case LF_PERC: - return init(LF_ANAG, rec.get_char("TIPOA"), rec.get_long("CODANAGR")); - default: - CHECKD(false, "Record non valido per TAnagrafica ", rec.num()); - break; - } - split_ragsoc(); - - return _tipo == 'F' || _tipo == 'G'; -} - -bool TAnagrafica::init(int num, const TString& codice) -{ return init(cache().get(num, codice)); } - -bool TAnagrafica::init(int num, long codice) -{ return init(cache().get(num, codice)); } - -bool TAnagrafica::init(int num, char tipo, long codice) -{ - TString8 key; key.format("%c|%ld", tipo, codice); - return init(cache().get(num, key)); -} - -bool TAnagrafica::init(char tipocf, long codice, const TString& ocfpi) -{ - bool done = false; - if (ocfpi.full()) - done = init(LF_OCCAS, ocfpi); - if (!done) - { - CHECK(tipocf == 'C' || tipocf == 'F', "Tipo cli/for non valido"); - CHECKD(codice > 0, "Codice cli/for non valido", codice); - done = init(LF_CLIFO, tipocf, codice); - } - return done; -} - /////////////////////////////////////////////////////////// // TSpesometro_set /////////////////////////////////////////////////////////// diff --git a/src/fp/fplib01.cpp b/src/fp/fplib01.cpp index 8d04e7523..cbcdedbdc 100644 --- a/src/fp/fplib01.cpp +++ b/src/fp/fplib01.cpp @@ -181,7 +181,7 @@ TString& complete_num_fp(const TCodice_numerazione& codnum, const int numdoc) bool chiave_paf(const TDocumento& doc, TString& hfatt, TString& bfatt) { hfatt.cut(0); - if (doc.clifor().occasionale()) + if (doc.clifor().is_occasionale()) hfatt << "O" << doc.get("OCFPI"); else hfatt << doc.clifor().tipo() << doc.clifor().codice(); @@ -1293,8 +1293,11 @@ const real calc_ritenuta(const TDocumento& doc) void TDoc_fp::add_ritenuta(const TDocumentoEsteso& doc, const TSpesa_prest& sp, TPaf_record& paf0700f) const { // - const real importo_ritenute = (doc.imponibile() - doc.spese()) * sp.perc() / CENTO; // Le spese non contribuiscono mai al calcolo delle ritenute! - paf0700f.set("P7_TIPORITENUTA", _rec_clifo.get_char(CLI_TIPOPERS) == 'F' ? "RT01" : "RT02"); + const real importo_ritenute = (doc.imponibile() - doc.spese()) * sp.perc() / CENTO; // Le spese non contribuiscono mai al calcolo delle ritenute! + TString tipo_rit = sp.codice_tipo_ritenuta_fp(); + if (tipo_rit.empty()) + tipo_rit = _rec_clifo.get_char(CLI_TIPOPERS) == 'F' ? "RT01" : "RT02"; + paf0700f.set("P7_TIPORITENUTA", tipo_rit); paf0700f.set("P7_IMPORTORIT", converti_prezzo(importo_ritenute)); paf0700f.set("P7_ALIQUOTARIT", sp.perc()); static TString caus_la; caus_la.cut(0); @@ -1978,6 +1981,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc) if (sp.tipo_ritenuta() == 'F') { paf1800f.set("PI_RITENUTA", "SI"); + // Todo: modifica nuovo tracciato xml: si possono aggiungere piu' casse prev. la prima sempre sul paf07, le altre sulla nuova tab paf35. add_ritenuta(doc, rdoc->spesa(), paf0700f); } } diff --git a/src/ve/clifor.cpp b/src/ve/clifor.cpp index ef4a92e3a..22023b351 100755 --- a/src/ve/clifor.cpp +++ b/src/ve/clifor.cpp @@ -29,333 +29,3 @@ TOccasionale& TOccasionale::operator=(const TOccasionale& r) TOccasionale::~TOccasionale() { } - -int TCli_for::write_rewrite(TBaseisamfile& f, bool re) const -{ - int err = TMultiple_rectype::write_rewrite(f, re); - - if (err == NOERR) - { - TLocalisamfile v(LF_CFVEN); - const TRectype& v_rec = vendite(); - err = v.write(v_rec); - if (err == _isreinsert) - err = v.write(v_rec); - } - return err; -} - -TRectype& TCli_for::vendite() const -{ - const char t = tipo(); - const long c = codice(); - - if (_ven_rec.empty() || t != _ven_rec.get_char(CFV_TIPOCF) || c != _ven_rec.get_long(CFV_CODCF)) - { - TLocalisamfile v(LF_CFVEN); - v.put(CFV_TIPOCF,t); - v.put(CFV_CODCF, c); - if (v.read() == NOERR) - ((TCli_for*)this)->_ven_rec = v.curr(); - } - return (TRectype &) _ven_rec; -} - -bool TCli_for::read_lettera(const TDate& data, bool extended) -{ - if (use_lettere()) - { - if (data != _last_data || _extended != extended) - { - _letint.zero(); - TRelation r(LF_LETINT); - - TRectype to(r.curr()); - to.put(LETINT_CODCLI, codice()); - to.put(LETINT_ANNO, data.year()); - - TRectype from(to); - from.put(LETINT_ANNO, data.year() - 1); - - TCursor c(&r, "", 2, &from, &to); - const int items = c.items(); - if (items > 0) - { - TDate dal; - TDate al(31, 12, data.year()); - - for (long pos = items - 1; pos >= 0L; pos--) - { - c = pos; - - const int tipo = c.curr().get_int(LETINT_TIPOOP); - - if (tipo == 3) // Nel periodo - { - dal = c.curr().get_date(LETINT_DAL); - al = c.curr().get_date(LETINT_AL); - } - else if(tipo == 2) - { - dal = c.curr().get_date(LETINT_DAL); - if (c.pos() < items - 1) - { - ++c; - const int tipo_next = c.curr().get_int(LETINT_TIPOOP); - if (tipo_next == 3 || tipo_next == 2) - al = c.curr().get_date(LETINT_DAL); - else - al = c.curr().get_date(LETINT_VSDATA); - --c; - } - } - else - { - dal = c.curr().get_date(LETINT_VSDATA); - if (c.pos() < items - 1) - { - ++c; - const int tipo_next = c.curr().get_int(LETINT_TIPOOP); - if (tipo_next == 3) - al = c.curr().get_date(LETINT_DAL); - else - al = c.curr().get_date(LETINT_VSDATA); - --c; - } - } - if (dal <= data) - { - _letint = c.curr(); - break; - } - } - _lettera_found = !_letint.empty(); - if (_lettera_found && !extended) - _lettera_found = data <= al; - } - _last_data = data; - _extended = extended; - } - } - return _lettera_found; -} - -int TCli_for::read(const TRectype & rec, word op, word lockop) -{ - _ven_rec.zero(); - int err = TMultiple_rectype::read(rec, op, lockop); - _last_data = botime; - return err; -} - -int TCli_for::read(char tipo, long codice, word op, word lockop) -{ - int err = NOERR; - _ven_rec.zero(); - zero(); - if (tipo > ' ' && codice > 0L) - { - put(CLI_TIPOCF, tipo); - put(CLI_CODCF, codice); - err = TMultiple_rectype::read(op, lockop); - } - _last_data = botime; - return err; -} - -int TCli_for::remove(TBaseisamfile& f) const -{ - TLocalisamfile v(LF_CFVEN); - const int err = vendite().remove(v); - if (err != NOERR && err != _iskeynotfound) - return err; - return TMultiple_rectype::remove(f); -} - -void TCli_for::init() -{ -// _tipo = new TRecfield(*this, CLI_TIPOCF); -// _codice = new TRecfield(*this, CLI_CODCF); -// _ven_tipo = new TRecfield(_ven_rec, CFV_TIPOCF); -// _ven_codice = new TRecfield(_ven_rec, CFV_CODCF); - _use_lettere = main_app().has_module(LIAUT, CHK_DONGLE); -} - -const TString& TCli_for::find_listino_al(const TDate& datadoc) const -{ - const bool gest_list_catven = ini_get_bool(CONFIG_DITTA, "ve", "GESLISCV", false, 1); - const TRectype& v = vendite(); - TString4 listino = v.get(CFV_CODLIST); - - TToken_string key_condv; - key_condv = "L"; - if (gest_list_catven) - key_condv.add(v.get(CFV_CATVEN)); - - //se il cliente ha un listino specificato -> va usato (previo controllo validità) - while (listino.full()) - { - key_condv.add(listino, 4); - - const TRectype& rec_condv = cache().get(LF_CONDV, key_condv); - const TDate inizio_validita = rec_condv.get_date(CONDV_VALIN); - const TDate fine_validita = rec_condv.get_date(CONDV_VALFIN); - - // usa il listino indicato sul cliente solo se è valido per la data del documento - if (datadoc >= inizio_validita && (datadoc <= fine_validita || !fine_validita.ok())) - break; - - listino = rec_condv.get(CONDV_CODLISSUCC); - } - return get_tmp_string() = listino; -} - -void TCli_for::cli2doc(TDocumento& doc) -{ - const TRectype& v = vendite(); - - doc.put(DOC_CODVAL, get(CLI_CODVAL)); - doc.put(DOC_CODLIN, get(CLI_CODLIN)); - doc.put(DOC_CODPAG, get(CLI_CODPAG)); - - TToken_string key; - - key.add(get(CLI_TIPOCF)); - key.add(get(CLI_CODCF)); - key.add("V"); - key.add("1"); - - const TRectype& cfban = cache().get(LF_CFBAN, key); - - if (cfban.empty()) - { - doc.put(DOC_CODABIA, get(CLI_CODABI)); - doc.put(DOC_CODCABA, get(CLI_CODCAB)); - doc.put(DOC_IBAN, get(CLI_IBAN)); - } - else - { - doc.put(DOC_CODABIA, cfban.get(CFBAN_ABI)); - doc.put(DOC_CODCABA, cfban.get(CFBAN_CAB)); - doc.put(DOC_IBAN, cfban.get(CFBAN_IBAN)); - } - - // Trasforma chiave da Vostra a Nostra banca - key.add("N", 2); - const TRectype& cfbanpr = cache().get(LF_CFBAN, key); - - // Setta i campi che appartengono al file LF_CFVEN - if (cfbanpr.empty()) - { - doc.put(DOC_CODABIP, v.get(CFV_CODABIPR)); - doc.put(DOC_CODCABP, v.get(CFV_CODCABPR)); - } - else - { - doc.put(DOC_CODABIP, cfbanpr.get(CFBAN_ABI)); - doc.put(DOC_CODCABP, cfbanpr.get(CFBAN_CAB)); - doc.put(DOC_PROGBNP, cfbanpr.get(CFBAN_PROGPR)); - } - doc.put(DOC_RAGGR, v.get(CFV_RAGGDOC)); - doc.put(DOC_RAGGREFF, v.get(CFV_RAGGEFF)); - doc.put(DOC_CODINDSP, v.get(CFV_CODINDSP)); - doc.put(DOC_CODAG, v.get(CFV_CODAG)); - doc.put(DOC_CODAGVIS, v.get(CFV_CODAG1)); - doc.put(DOC_CODSPMEZZO, v.get(CFV_CODSPMEZZO)); - doc.put(DOC_CODPORTO, v.get(CFV_CODPORTO)); - doc.put(DOC_CODNOTESP1, v.get(CFV_CODNOTESP1)); - doc.put(DOC_CODNOTESP2, v.get(CFV_CODNOTESP2)); - doc.put(DOC_CODNOTE, v.get(CFV_CODNOTE)); - doc.put(DOC_CODVETT1, v.get(CFV_CODVETT1)); - doc.put(DOC_CODVETT2, v.get(CFV_CODVETT2)); - doc.put(DOC_CODVETT3, v.get(CFV_CODVETT3)); - doc.put(DOC_PERCSPINC, v.get(CFV_PERCSPINC)); - doc.put(DOC_ADDBOLLI, v.get(CFV_ADDBOLLI)); - doc.put(DOC_CATVEN, v.get(CFV_CATVEN)); - - const int alleg = get_int(CLI_ALLEG); - const bool split_payment = doc.get_date(DOC_DATADOC).year() >= 2015 && get_bool(CLI_SPLITPAY); - - doc.put(DOC_LIQDIFF, !split_payment && alleg == 7 && ini_get_bool(CONFIG_DITTA, "cg", "GesLiqDiff") ? "X" : ""); - - //listino: deve essere attiva la gestione listini nella ditta - const bool gest_listini = ini_get_bool(CONFIG_DITTA, "ve", "GES", false, 1); - if (gest_listini) - { - const TDate datadoc = doc.get_date(DOC_DATADOC); - const TString& listino = find_listino_al(datadoc); - doc.put(DOC_CODLIST, listino); - } - - doc.put(DOC_ZONA, v.get(CFV_CODZONA)); - doc.put(DOC_RAGGR, v.get(CFV_RAGGDOC)); - - //aggiungere gestione spese e bolli??? - doc.put(DOC_CODPORTO, v.get(CFV_CODPORTO)); -} - -const TString& TCli_for::get_iban() -{ - TString & iban = get_tmp_string(30); - TToken_string key; - - key.add(tipo()); - key.add(codice()); - key.add("V"); - key.add(1); - - const TRectype& cfban = cache().get(LF_CFBAN, key); - - if (!cfban.empty()) - { - const TString& abi_cf = cfban.get(CFBAN_ABI); - const TString& cab_cf = cfban.get(CFBAN_CAB); - iban = cfban.get(CFBAN_IBAN); - } - return iban; -} - -TToken_string& TCli_for::get_ban_pres(int nprog) -{ - TToken_string & ban = get_tmp_string(30); - TToken_string key; - - key.add(tipo()); - key.add(codice()); - key.add("N"); - key.add(nprog); - - const TRectype& cfban = cache().get(LF_CFBAN, key); - - if (!cfban.empty()) - { - ban.add(cfban.get(CFBAN_ABI)); - ban.add(cfban.get(CFBAN_CAB)); - ban.add(cfban.get(CFBAN_PROGPR)); - } - return ban; -} -TCli_for::TCli_for(char tipo, long codice) : TMultiple_rectype( LF_CLIFO ), _ven_rec(LF_CFVEN), - _letint(LF_LETINT), _use_lettere(false), _lettera_found(false), _extended(false) -{ - init(); - add_file(LF_INDSP, IND_CODIND); - if (tipo > ' ' && codice > 0L) - read(tipo, codice); -} - -TCli_for::TCli_for(const TRectype & rec) : TMultiple_rectype(rec), _ven_rec(LF_CFVEN), - _letint(LF_LETINT), _use_lettere(false), _lettera_found(false), _extended(false) -{ - init(); - add_file(LF_INDSP, IND_CODIND); - read(rec); -} - -TCli_for::TCli_for(const TCli_for & c) : TMultiple_rectype(c), _ven_rec(c._ven_rec), - _letint(LF_LETINT), _use_lettere(false), _lettera_found(false), _extended(false) -{ init(); } - -TCli_for::~TCli_for() -{ } - diff --git a/src/ve/ve0300a.src b/src/ve/ve0300a.src index 99405d586..9b6878c4f 100755 --- a/src/ve/ve0300a.src +++ b/src/ve/ve0300a.src @@ -2002,7 +2002,7 @@ Y=1 SIZE=40 PROMPT="Tipo documento SDI " FIELDNAME=TIPO_SDI -ITEMS=|@TD01|TD01 Fattura@TD02|TD02 Acconto/Anticipo su fattura@TD03|TD03 Acconto/Anticipo su parcella@TD04|TD04 Nota di credito@TD05|TD05 Nota di debito@TD06|TD06 parcella +ITEMS=|@TD01|TD01 Fattura@TD02|TD02 Acconto/Anticipo su fattura@TD03|TD03 Acconto/Anticipo su parcella@TD04|TD04 Nota di credito@TD05|TD05 Nota di debito@TD06|TD06 Parcella@TD16|TD16 Integraz. fatt. rev.ch. interno@TD17|TD17 Integ./autof. acq. servizi estero@TD18|TD18 Integ. acq. beni intracomunitari@TD19|TD19 Integ./autof. acq. beni ex art. 17@TD20|TD20 Autofattura@TD21|TD21 Autofattura per splafonamento@TD22|TD22 Estrazione beni da Deposito IVA@TD23|TD23 Estr. beni Deposito IVA vers. IVA@TD24|TD24 Fatt. differita art.21 c.4 lett. a@TD25|TD25 Fatt. differita art. 21 c.4 per.3 b@TD26|TD26 Cess. beni ammort./passaggi interni@TD27|TD27 Fatt. autoconsumo/cessioni gratuite" [INVIO_FP] TYPE=T_CHECKBOX diff --git a/src/ve/ve5.cpp b/src/ve/ve5.cpp index 268f160a7..99003d3d2 100755 --- a/src/ve/ve5.cpp +++ b/src/ve/ve5.cpp @@ -12,6 +12,7 @@ int main(int argc, char** argv) case 3 : ve5400(argc, argv); break; // Archivia documenti case 4 : ve5500(argc, argv); break; // Compatta documenti case 5 : ve5600(argc, argv); break; // recupero testate documenti + case 6 : ve5700(argc, argv); break; // Cambiamento tipo documenti fp (TD01, ...) default: ve5100(argc, argv); break; // Cancella documenti } return 0; diff --git a/src/ve/ve5.h b/src/ve/ve5.h index 114dca133..133e5ed28 100755 --- a/src/ve/ve5.h +++ b/src/ve/ve5.h @@ -7,6 +7,7 @@ int ve5300(int argc, char* argv[]); int ve5400(int argc, char* argv[]); int ve5500(int argc, char* argv[]); int ve5600(int argc, char* argv[]); +int ve5700(int argc, char* argv[]); #endif diff --git a/src/ve/velib.h b/src/ve/velib.h index 7cdf0cdfb..02ec93c53 100755 --- a/src/ve/velib.h +++ b/src/ve/velib.h @@ -148,6 +148,7 @@ public: real prezzo() const; // R10 o R0 real qta() const { return get_real("R1"); } real perc() const { return get_real("R2"); } + const TString& codice_tipo_ritenuta_fp() const { return get("S2").mid(0, 4); } char tipo_ritenuta() const { return get_char("S9"); } const TString& tipo_riga() const { return get("S8"); } char genere() const; diff --git a/src/ve/vemenu.men b/src/ve/vemenu.men index d811d944e..50d296c5b 100755 --- a/src/ve/vemenu.men +++ b/src/ve/vemenu.men @@ -36,6 +36,7 @@ Item_07 = "Lista ritenute per F24", "ve8 -0", "F" Item_08 = "Controllo IBAN su documenti", "ve4 -2", "F" Item_09 = "Controllo ordini evasi", "ve6 -9", "F" Item_10 = "Stampa avanzata riepilogo documenti immessi", "ve1 -6", "F" +Item_11 = "Cambiamento Tipo Documento SDI", "ve5 -6", "F" [VEMENU_052] Caption = "Configurazione" diff --git a/src/ve/vetbspp.h b/src/ve/vetbspp.h index 7fe8daf1f..977276bb0 100755 --- a/src/ve/vetbspp.h +++ b/src/ve/vetbspp.h @@ -26,7 +26,7 @@ #define SPP_CODTRB1 126 #define SPP_SEZIONE 127 #define SPP_CODCAUS770 128 -#define SPP_TIPOSP 129 +#define SPP_TIPOSP 129 #define SPP_CDC_V1 130 #define SPP_CDC_V2 131 @@ -38,6 +38,8 @@ #define SPP_CDC_A3 142 #define SPP_CDC_A4 143 +#define SPP_TIPORITFP 150 + #define SPP_CODQUA 160 #define SPP_CAUSD 161 diff --git a/src/ve/vetbspp.uml b/src/ve/vetbspp.uml index fc6fa688f..60588e4ea 100755 --- a/src/ve/vetbspp.uml +++ b/src/ve/vetbspp.uml @@ -330,6 +330,19 @@ BEGIN ADD RUN CG0 -0 END +LIST SPP_TIPORITFP 4 37 +BEGIN + PROMPT 2 19 "Tipo Ritenuta (FP)" + FIELD S2[1,4] + ITEM "|" + ITEM "RT01|RT01 - Ritenuta persone fisiche" + ITEM "RT02|RT02 - Ritenuta persone giuridiche" + ITEM "RT03|RT03 - Contributo INPS" + ITEM "RT04|RT04 - Contributo ENASARCO" + ITEM "RT05|RT05 - Contributo ENPAM" + ITEM "RT06|RT06 - Altro contributo" +END + LIST SPP_TIPOSP 1 20 BEGIN PROMPT 2 20 "Tipologia di spesa/prestazione " diff --git a/src/ve/vetbtip.uml b/src/ve/vetbtip.uml index ed064bf37..110c44d79 100755 --- a/src/ve/vetbtip.uml +++ b/src/ve/vetbtip.uml @@ -82,7 +82,7 @@ BEGIN CHECKTYPE REQUIRED END -LIST F_TIPO_SDI_TIP 35 +LIST F_TIPO_SDI_TIP 40 BEGIN PROMPT 2 5 "Tipo documento SDI " FIELD S3[37,40] @@ -93,7 +93,18 @@ BEGIN ITEM "TD04|TD04 Nota di credito" MESSAGE ENABLE,F_NOTACREDDEB|"X" ITEM "TD05|TD05 Nota di debito" MESSAGE ENABLE,F_NOTACREDDEB|"X" ITEM "TD06|TD06 Parcella" MESSAGE ENABLE,F_NOTACREDDEB|"" + ITEM "TD16|TD16 Integraz. fatt. rev.ch. interno" MESSAGE ENABLE,F_NOTACREDDEB|"" + ITEM "TD17|TD17 Integ./autof. acq. servizi estero" MESSAGE ENABLE,F_NOTACREDDEB|"" + ITEM "TD18|TD18 Integ. acq. beni intracomunitari" MESSAGE ENABLE,F_NOTACREDDEB|"" + ITEM "TD19|TD19 Integ./autof. acq. beni ex art. 17" MESSAGE ENABLE,F_NOTACREDDEB|"" ITEM "TD20|TD20 Autofattura" MESSAGE ENABLE,F_NOTACREDDEB|"" + ITEM "TD21|TD21 Autofattura per splafonamento" MESSAGE ENABLE,F_NOTACREDDEB|"" + ITEM "TD22|TD22 Estrazione beni da Deposito IVA" MESSAGE ENABLE,F_NOTACREDDEB|"" + ITEM "TD23|TD23 Estr. beni Deposito IVA vers. IVA" MESSAGE ENABLE,F_NOTACREDDEB|"" + ITEM "TD24|TD24 Fatt. differita art.21 c.4 lett. a" MESSAGE ENABLE,F_NOTACREDDEB|"" + ITEM "TD25|TD25 Fatt. differita art. 21 c.4 per.3 b" MESSAGE ENABLE,F_NOTACREDDEB|"" + ITEM "TD26|TD26 Cess. beni ammort./passaggi interni" MESSAGE ENABLE,F_NOTACREDDEB|"" + ITEM "TD27|TD27 Fatt. autoconsumo/cessioni gratuite" MESSAGE ENABLE,F_NOTACREDDEB|"" END BOOLEAN F_ESPORTA_FP