From c6cdc3fcd4a03608a594e20e14839df0b7c84b73 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 27 Dec 2011 11:48:39 +0000 Subject: [PATCH] =?UTF-8?q?Patch=20level=20=20=20=20=20=20=20=20=20:=2010.?= =?UTF-8?q?0=20Files=20correlati=20=20=20=20=20:=20fe0.exe=20Ricompilazion?= =?UTF-8?q?e=20Demo=20:=20[=20]=20Commento=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20:=20Migliorata=20estrazione=20di=20Cognome=20e=20Nome=20d?= =?UTF-8?q?i=20anagrafiche=20in=20cui=20=C3=A8=20presente=20solo=20la=20pr?= =?UTF-8?q?ima=20parte=20della=20Ragione=20Sociale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://10.65.10.50/branches/R_10_00@22537 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- fe/felib.cpp | 73 ++++++++++++++++++++++++++++++++++++++++------------ fe/felib.h | 3 ++- 2 files changed, 58 insertions(+), 18 deletions(-) diff --git a/fe/felib.cpp b/fe/felib.cpp index 538196ea7..0266837a6 100644 --- a/fe/felib.cpp +++ b/fe/felib.cpp @@ -86,6 +86,26 @@ const TString& TAnagrafica::stato_estero_UNICO() const return get_tmp_string() = u; } +void TAnagrafica::split_ragsoc() +{ + if (_tipo == 'F') + { + if (nome().blank()) + { + const int space = _ragsoc.find(' '); + if (space > 0) + { + TString80 nom = _ragsoc.mid(space+1); + nom.cut(20); + _ragsoc.cut(space); + _ragsoc.insert(nom, 30); + } + } + } + else + _ragsoc.strip_double_spaces(); +} + bool TAnagrafica::init(const TRectype& rec) { _tipo = '\0'; @@ -97,7 +117,6 @@ bool TAnagrafica::init(const TRectype& rec) switch (rec.num()) { case LF_OCCAS: - _tipo = 'F'; _cofi = rec.get(OCC_COFI); _paiv = rec.get(OCC_PAIV); if (_cofi.blank() || _paiv.blank()) @@ -115,7 +134,11 @@ bool TAnagrafica::init(const TRectype& rec) _loc_res = rec.get(OCC_LOCALITA); build_ind_res(rec, OCC_INDIR, OCC_CIV); _stato_estero = rec.get_int(OCC_STATO); - _allegato = _paiv.blank() ? 6 : 2; + if (_com_nasc.full() || (!_stato_estero && !real::is_natural(_cofi) || cf_check("", _cofi))) + _tipo = 'F'; + else + _tipo = 'G'; + _allegato = _tipo == 'F' ? 6 : 2; break; case LF_ANAG: _tipo = rec.get_char(ANA_TIPOA); @@ -156,21 +179,20 @@ bool TAnagrafica::init(const TRectype& rec) if (ca > 0) return init(rec.get_char(CLI_TIPOCF), ca, EMPTY_STRING); } - _tipo = rec.get_char(CLI_TIPOAPER); - if (_tipo == 'F') + + _tipo = ' '; // Non faccio assunzioni sulla persona fisica + + if (rec.get_char(CLI_TIPOCF) == 'F') // Fornitore -> Percipiente { const long cod = rec.get_long(CLI_CODANAGPER); - if (cod > 0 && init(LF_ANAG, _tipo, cod)) - { - if (rec.get(CLI_COMNASC).not_empty()) - _com_nasc = rec.get(CLI_COMNASC); - if (rec.get(CLI_DATANASC).not_empty()) - _data_nasc = rec.get(CLI_DATANASC); - } - _tipo = 'F'; // init could reset _tipo + if (cod > 0) + init(LF_ANAG, 'F', cod); + if (rec.get(CLI_COMNASC).not_empty()) + _com_nasc = rec.get(CLI_COMNASC); + if (rec.get(CLI_DATANASC).not_empty()) + _data_nasc = rec.get(CLI_DATANASC); } - else - _tipo = 'G'; + // Assegno codice fiscale e partita IVA se validi, altrimenti mantengo quelli dell'anagrafica if (rec.get(CLI_COFI).not_empty()) _cofi = rec.get(CLI_COFI); @@ -182,6 +204,25 @@ bool TAnagrafica::init(const TRectype& rec) _ragsoc = rec.get(CLI_RAGSOC); _stato_estero = rec.get_int(CLI_STATOCF); _loc_res = rec.get(CLI_LOCCF); + + if (_tipo != 'F' && _tipo != 'G') + { + switch (_allegato) + { + case 6: _tipo = 'F'; break; + case 7: _tipo = 'G'; break; + default: + if (_com_nasc.full()) + _tipo = 'F'; + else + { + _tipo = rec.get_char(CLI_TIPOPERS); + if (_tipo != 'F') + _tipo = 'G'; + } + break; + } + } break; case LF_MOV: return init(rec.get_char(MOV_TIPO), rec.get_long(MOV_CODCF), rec.get(MOV_OCFPI)); @@ -191,9 +232,7 @@ bool TAnagrafica::init(const TRectype& rec) CHECKD(false, "Record non valido per TAnagrafica ", rec.num()); break; } - - if (_tipo == 'G') // Per le persone fisiche devo mantenere la netta separazione tra cognome e nome - _ragsoc.strip_double_spaces(); + split_ragsoc(); return _tipo == 'F' || _tipo == 'G'; } diff --git a/fe/felib.h b/fe/felib.h index 0248e8857..9b5498006 100644 --- a/fe/felib.h +++ b/fe/felib.h @@ -27,7 +27,8 @@ class TAnagrafica : public TObject TAnagrafica(const TAnagrafica&) { CHECK(false, "Can't copy TAnagrafica"); } protected: void build_ind_res(const TRectype& rec, const char* ind, const char* civ); - + void split_ragsoc(); + public: virtual bool ok() const { return _tipo=='F' || _tipo == 'G'; } bool fisica() const { return _tipo == 'F'; }