Patch level : 12.0 no-patch
Files correlati : Commento : Spostati TAnagrafica e TClifor in cglib
This commit is contained in:
		
							parent
							
								
									ba2c68bba4
								
							
						
					
					
						commit
						f110178497
					
				
							
								
								
									
										134
									
								
								src/cg/cglib.h
									
									
									
									
									
								
							
							
						
						
									
										134
									
								
								src/cg/cglib.h
									
									
									
									
									
								
							| @ -37,9 +37,11 @@ | ||||
| #include <pconti.h>  | ||||
| #include <comuni.h> | ||||
| #include <clifo.h> | ||||
| #include <cfven.h> | ||||
| #include <occas.h>   | ||||
| #include <indsp.h>  | ||||
| #include <rcausali.h>   | ||||
| #include <causali.h>  | ||||
| #include <occas.h>   | ||||
| #include <partite.h>   | ||||
| #include <scadenze.h>  | ||||
| #include <pagsca.h>  | ||||
| @ -1373,4 +1375,134 @@ public: | ||||
|   virtual ~TMovimentoPN() {} | ||||
| }; | ||||
| 
 | ||||
| // utility
 | ||||
| bool fe_decode_cofi(const TString& cofi, char& sex_nasc, TDate& dt_nasc, TString& com_nasc); | ||||
| 
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| // TAnagrafica
 | ||||
| ///////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| class TAnagrafica : public TObject | ||||
| { | ||||
| 	char _tipo; // F o G
 | ||||
| 	char _sociounico; | ||||
| 	TString4 _stato_paiv; | ||||
| 	TString		 _cofi, _paiv, _cofiest; | ||||
| 	TString80 _ragsoc; | ||||
| 	TString4 _com_nasc, _com_res; | ||||
| 	TString80 _loc_res, _ind_res, _via_res; | ||||
| 	TString16 _civ_res, _cap_res; | ||||
| 	TDate _data_nasc; | ||||
| 	int _allegato, _stato_estero, _stato_nasc; | ||||
| 
 | ||||
| 	TAnagrafica& operator =(const TAnagrafica&) { CHECK(false, "Can't copy TAnagrafica"); } | ||||
| 	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'; } | ||||
| 	bool giuridica() const { return _tipo == 'G'; } | ||||
| 
 | ||||
| 	const TString& codice_fiscale() const { return _cofi; } | ||||
| 	const TString& codice_fiscale_estero() const { return _cofiest; } | ||||
| 	const TString& partita_IVA() const { return _paiv; } | ||||
| 	const TString& stato_partita_IVA() const; | ||||
| 
 | ||||
| 	const TString& ragione_sociale() const; | ||||
| 	const TString& cognome() const; | ||||
| 	const TString& nome() const; | ||||
| 	char sesso() const { CHECK(fisica(), "Solo sesso fisico!"); return (_cofi[9] >= '4') ? 'F' : 'M'; } | ||||
| 	const TDate& data_nascita() const { return _data_nasc; } | ||||
| 	bool italiano() const; | ||||
| 	bool estero() const { return !italiano(); } | ||||
| 	bool estero_CEE() const; | ||||
| 	bool estero_non_CEE() const { return estero() && !estero_CEE(); } | ||||
| 	const TString& stato_estero_UNICO() const; | ||||
| 	int inserimento_in_allegato() const { return _allegato; } | ||||
| 	char is_black_list(const TDate& datareg) const; | ||||
| 	const char sociounico() const { return _sociounico; } | ||||
| 
 | ||||
| 	const TString& comune_nascita() const; | ||||
| 	const TString& provincia_nascita() const; | ||||
| 	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_ISO() 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; } | ||||
| 	const TString& civico_residenza() const { return _civ_res; } | ||||
| 	const TString& CAP_residenza() const { return _cap_res; } | ||||
| 
 | ||||
| 	bool init(const TRectype& rec); | ||||
| 	bool init(int num, const TString& codice); | ||||
| 	bool init(int num, long codice); | ||||
| 	bool init(int num, char tipo, long codice); | ||||
| 	bool init(char tipocf, long codice, const TString& ocfpi); | ||||
| 
 | ||||
| 	TAnagrafica() : _tipo('\0') {} | ||||
| 	TAnagrafica(int lognum, const TString& codice) { init(lognum, codice); } | ||||
| 	TAnagrafica(int lognum, long codice) { init(lognum, codice); } | ||||
| 	TAnagrafica(int lognum, char tipo, long codice) { init(lognum, tipo, codice); } | ||||
| 	TAnagrafica(char tipo, long codice, const TString& ocfpi) { init(tipo, codice, ocfpi); } | ||||
| 	TAnagrafica(const TRectype& rec) { init(rec); } | ||||
| }; | ||||
| 
 | ||||
| class TOccasionale : public TRectype | ||||
| { | ||||
| public: | ||||
| 	const TString& codice() const { return get(OCC_CFPI); } | ||||
| 	TRectype& operator = (const TRectype& r); | ||||
| 	TOccasionale& operator = (const TOccasionale& r); | ||||
| 
 | ||||
| 	TOccasionale(); | ||||
| 	TOccasionale(const TRectype& r); | ||||
| 	TOccasionale(const TOccasionale& r); | ||||
| 	virtual ~TOccasionale(); | ||||
| }; | ||||
| 
 | ||||
| class TCli_for : public TMultiple_rectype | ||||
| { | ||||
| 	TRectype _ven_rec; | ||||
| 	TRectype _letint; | ||||
| 	TDate _last_data; | ||||
| 	bool _use_lettere; | ||||
| 	bool _extended; | ||||
| 	bool _lettera_found; | ||||
| 
 | ||||
| protected: | ||||
| 	virtual int write_rewrite(TBaseisamfile& f, bool re = FALSE) const; | ||||
| 	void init(); | ||||
| 
 | ||||
| public: | ||||
| 	bool read_lettera(const TDate & data, bool extended = false); | ||||
| 	bool occasionale() const { return get_bool(CLI_OCCAS); } | ||||
| 	TRectype& vendite() const; | ||||
| 	bool use_lettere() const { return _use_lettere; } | ||||
| 	const TRectype & lettera() const { return _letint; } | ||||
| 	const TRectype & indsp(const int codindsp) const; | ||||
| 
 | ||||
| 	char tipo() const { return get_char(CLI_TIPOCF); } | ||||
| 	long codice() const { return get_long(CLI_CODCF); } | ||||
| 	bool ok() const { return !empty(); } | ||||
| 
 | ||||
| 	virtual int read(const TRectype& rec, word op = _isequal, word lockop = _nolock); | ||||
| 	int read(char tipo, long codice, word op = _isequal, word lockop = _nolock); | ||||
| 	virtual int remove(TBaseisamfile& f) const; | ||||
| 	//	void cli2doc(TDocumento& doc); in velib03
 | ||||
| 	const TString& find_listino_al(const TDate& datadoc) const; | ||||
| 
 | ||||
| 	const TString & get_iban(); | ||||
| 	TToken_string & get_ban_pres(int nprog = 1); | ||||
| 
 | ||||
| 	TCli_for(char tipo = ' ', long codice = 0L); | ||||
| 	TCli_for(const TRectype & rec); | ||||
| 	TCli_for(const TCli_for & c); | ||||
| 	virtual ~TCli_for(); | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										931
									
								
								src/cg/cglib07.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										931
									
								
								src/cg/cglib07.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,931 @@ | ||||
| #include <applicat.h> | ||||
| #include <lffiles.h> | ||||
| #include <modaut.h> | ||||
| #include <recarray.h> | ||||
| #include <validate.h> | ||||
| 
 | ||||
| #include "cglib.h" | ||||
| #include "../ve/condv.h" | ||||
| #include "../li/letint.h" | ||||
| #include "../cg/cfban.h" | ||||
| #include <alleg.h> | ||||
| #include <anagr.h> | ||||
| #include <effetti.h> | ||||
| #include <anafis.h> | ||||
| #include <comuni.h> | ||||
| # | ||||
| #include <nditte.h> | ||||
| 
 | ||||
| bool fe_decode_cofi(const TString& cofi, char& sex_nasc, TDate& dt_nasc, TString& com_nasc) | ||||
| { | ||||
| 	if (cofi.len() != 16 || !cf_check("", cofi)) | ||||
| 		return false; | ||||
| 
 | ||||
| 	const TFixed_string wm = "ABCDEHLMPRST"; // Controllo data di nascita
 | ||||
| 
 | ||||
| 	int anno = atoi(cofi.mid(6, 2)); | ||||
| 	anno += anno < 25 ? 2000 : 1900; | ||||
| 	const int mese = wm.find(cofi[8]) + 1; | ||||
| 	int giorno = atoi(cofi.mid(9, 2)); | ||||
| 	if (giorno > 40) | ||||
| 	{ | ||||
| 		giorno -= 40; | ||||
| 		sex_nasc = 'F'; | ||||
| 	} | ||||
| 	else | ||||
| 		sex_nasc = 'M'; | ||||
| 
 | ||||
| 	com_nasc = cofi.mid(11, 4); | ||||
| 
 | ||||
| 	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; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| TOccasionale::TOccasionale() : TRectype(LF_OCCAS) | ||||
| { } | ||||
| 
 | ||||
| TOccasionale::TOccasionale(const TRectype& r) : TRectype(r) | ||||
| { } | ||||
| 
 | ||||
| TOccasionale::TOccasionale(const TOccasionale& r) : TRectype(r) | ||||
| { } | ||||
| 
 | ||||
| TRectype& TOccasionale::operator=(const TRectype& r) | ||||
| { | ||||
|   return TRectype::operator=(r); | ||||
| } | ||||
| 
 | ||||
| TOccasionale& TOccasionale::operator=(const TOccasionale& r) | ||||
| {         | ||||
|   TRectype::operator=(r); | ||||
|   return *this; | ||||
| } | ||||
| 
 | ||||
| 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; | ||||
| } | ||||
| const TRectype & TCli_for::indsp(const int codindsp) const | ||||
| { | ||||
| 	TToken_string key = tipo(); | ||||
| 
 | ||||
| 	key.add(codice()); | ||||
| 	key.add(codindsp); | ||||
| 	const TRectype & recindsp = cache().get(LF_INDSP, key); | ||||
| 
 | ||||
| 	return recindsp; | ||||
| } | ||||
| 
 | ||||
| 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() | ||||
| { } | ||||
|          | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user