diff --git a/src/fe/felib.cpp b/src/fe/felib.cpp index f80364eda..efc6f7513 100644 --- a/src/fe/felib.cpp +++ b/src/fe/felib.cpp @@ -192,6 +192,17 @@ const TString& TAnagrafica::provincia_residenza() const return provincia_di(_com_res); } +const TString& TAnagrafica::stato_residenzaISO() 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); @@ -276,7 +287,7 @@ const TString& TAnagrafica::stato_estero_UNICO() const return EMPTY_STRING; TString4 u; u.format("%03d", _stato_estero); - const TString& cod = cache().get("%STA", u, "S8"); // S8=UNICO S9=ISTAT + 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; @@ -284,10 +295,14 @@ const TString& TAnagrafica::stato_estero_UNICO() const const TString& TAnagrafica::stato_partita_IVA() const { + TString& str = get_tmp_string(); if (_stato_paiv.full()) - return _stato_paiv; - TString& str = get_tmp_string(); - if (italiano()) str = "IT"; + str = _stato_paiv; + else + { + // Propongo il codice iso del suo stato + str = stato_residenzaISO(); + } return str; } diff --git a/src/fe/felib.h b/src/fe/felib.h index 3efa9a75c..4c9f90396 100644 --- a/src/fe/felib.h +++ b/src/fe/felib.h @@ -57,6 +57,7 @@ public: const TString& codice_comune_residenza() const { return estero() ? EMPTY_STRING : _com_res; } const TString& comune_residenza() const; const TString& provincia_residenza() const; + const TString& stato_residenza() const; const TString& localita_residenza() const { return _loc_res; } const TString& indirizzo_residenza() const { return _ind_res; } const TString& via_residenza() const { return _via_res; }