Patch level : HARDY

Files correlati     :
Ricompilazione Demo : [ ]
Commento            : conversione destinazioni (cli e indsped)


git-svn-id: svn://10.65.10.50/branches/R_10_00@21140 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2010-11-16 13:52:48 +00:00
parent 97ff642b7c
commit 289d0aac6c
3 changed files with 190 additions and 15 deletions

View File

@ -869,6 +869,13 @@ long THardy_clienti::get_codcf(const TString &key)
}
bool THardy_clienti::trasferisci()
{
if (trasferisci_clienti())
return trasferisci_destinazioni();
return false;
}
bool THardy_clienti::trasferisci_clienti()
{
TString query =
"SELECT * "
@ -915,7 +922,12 @@ bool THardy_clienti::trasferisci()
rec.put(CLI_LOCCF, loc);
}
aggiorna_record(rec, lista_campi);
test_write(clienti);
if (test_write(clienti))
{
TString msg;
msg << TR("Inserito cliente ") << " '" << key << '\'' << TR("con codice ") << codcf ;
log(msg);
}
}
else
{
@ -928,6 +940,125 @@ bool THardy_clienti::trasferisci()
return write_enabled();
}
bool THardy_clienti::is_piva_doppia(const long codcf)
{
TToken_string tok; tok.add("C"); tok.add(codcf);
const TString& statopaiv = cache().get(LF_CLIFO, tok, CLI_STATOPAIV);
const TString& paiv = cache().get(LF_CLIFO, tok, CLI_PAIV);
TISAM_recordset clifo("USE CLIFO KEY 5\nSELECT (CODCF > 200000)&&(CODCF < 300000)\nFROM TIPOCF='C' STATOPAIV=#STATOPAIV PAIV=#PAIV\nTO TIPOCF='C' STATOPAIV=#STATOPAIV PAIV=#PAIV");
clifo.set_var("#STATOPAIV", TVariant(statopaiv));
clifo.set_var("#PAIV", TVariant(paiv));
return (clifo.items() > 1);
}
int THardy_clienti::get_next_key_indsped(const char tipocf, const long codcf) const
{
TISAM_recordset indsped("USE INDSPED\nFROM TIPOCF=#TIPO CODCF=#CODE\nTO TIPOCF=#TIPO CODCF=#CODE");
TString4 str; str << tipocf;
indsped.set_var("#TIPO", TVariant(str));
indsped.set_var("#CODE", TVariant(codcf));
int codind = 1;
if (indsped.items() > 0) // La move_last da errore fatale su recordset vuoti!
{
indsped.move_last();
codind += indsped.get("CODIND").as_int();
}
return codind;
}
bool THardy_clienti::trasferisci_destinazioni()
{
TString query =
"SELECT * "
"FROM dbo.Destinazioni ";
TRecordset& recset = create_recordset(query);
TConfig& ini = config();
TString_array lista_campi, lista_campi_indsped;
ini.list_variables(lista_campi, true, "DESTINAZIONI", true);
ini.list_variables(lista_campi_indsped, true, "INDSPED", true);
TSystemisamfile clifo(LF_CLIFO);
TSystemisamfile indsped(LF_INDSP);
clifo.open(_lock);
indsped.open(_lock);
TRectype& rec = clifo.curr();
TRectype& rec_indsped = indsped.curr();
THardy_iterator hi(this);
while (++hi)
{
// costruisco la chiave
const TString16 key = get_str("IdConto");
long codcf = get_codcf(key);
rec.zero();
rec.put(CLI_TIPOCF, "C");
rec.put(CLI_CODCF, codcf);
bool good = clifo.read() == NOERR;
if (good)
{
bool doppio = is_piva_doppia(codcf);
if (codcf > 200000 && codcf < 300000 && doppio)
{
// cambio dati tra clienti e destinazione
// ricerca comune
const TString8 cap = get_str("IdCap"); //cap
TString80 loc = get_str("Localita"); //località
const TString8 com = cap2comune(cap,loc); //codice comune
const TString8 stato = get_str("IdNazione"); //stato
rec.put(CLI_CAPCF, cap);
if (com.full() && !com.blank())
{
rec.put(CLI_COMCF, com); //se riesce la CAP2COMUNE, inserisco il codice comune
loc = "";
rec.put(CLI_LOCCF, loc);
}
else
{
rec.put(CLI_COMCF, com);
if (stato != "IT" && !stato.blank()) //altrimenti metto tutto nella località, eventualmente concatenando lo stato
loc << " - " << stato;
rec.put(CLI_LOCCF, loc);
}
aggiorna_record(rec, lista_campi);
if (test_write(clifo))
{
TString msg;
msg << TR("Modificato cliente ") << " '" << key << '\'' << TR("con codice ") << codcf ;
log(msg);
}
}
else
{
// inserisco indirizzo di spedizione
int codind = 0;
codind = get_next_key_indsped('C', codcf);
rec_indsped.zero();
rec_indsped.put(IND_TIPOCF, "C");
rec_indsped.put(IND_CODCF, codcf);
rec_indsped.put(IND_CODIND, codind);
aggiorna_record(rec_indsped, lista_campi_indsped);
if (test_write(indsped))
{
TString msg;
msg << TR("Inserito indirizzo di spedizione ") << " '" << key << '\'' ;
log(msg);
}
}
}
else
{
TString msg;
msg << TR("Impossibile stabilire cliente del codice destinazione") << " '" << key << '\'';
log(msg);
}
}
clifo.close();
indsped.close();
return write_enabled();
}
long THardy_fornitori::get_codcf(const TString &key)
{
long codcf = atoi(key.mid(3,6));

View File

@ -197,7 +197,11 @@ public:
class THardy_clienti : public THardy_transfer
{
protected:
bool is_piva_doppia(const long codcf);
long get_codcf(const TString& key);
int get_next_key_indsped(const char tipocf, const long codcf) const;
bool trasferisci_clienti();
bool trasferisci_destinazioni();
public:
virtual bool trasferisci();
};

View File

@ -170,7 +170,6 @@ DIRTY =
REFERENTE = Referente
VALINTRA =
[CLIENTI]
RAGSOC = _STREXPR,LEFT(RagioneSociale+" "+DatiAggiuntivi; 50)
INDCF = Indirizzo
@ -217,13 +216,66 @@ CODVAL =
CODLIN =
FIDO =
CODPAG =
RICALT =
RICALT = IdConto
OGGETTI =
SOSPESO =
DIRTY =
REFERENTE = Referente
VALINTRA =
[DESTINAZIONI]
RAGSOC = _STREXPR,LEFT(RagioneSociale+" "+DatiAggiuntivi; 50)
INDCF = Indirizzo
CIVCF =
LOCALITACF =
STATOCF = _TAB,%TPS,IdIso,S6
COMCF =
CAPCF = CAP
PTEL =
TEL = Telefono1
PTEL2 =
TEL2 = Telefono2
PTEL3 =
TEL3 = TelCellulare
PFAX =
FAX = TelFax
PTELEX =
TELEX =
MAIL = EMail
DATANASC =
STATONASC =
COMNASC =
CODSTAT =
CODABI =
CODCAB =
NUMCC =
IBAN =
OCCAS =
STATO =
CODVAL =
CODLIN =
FIDO =
CODPAG =
RICALT = IdConto
OGGETTI =
SOSPESO =
DIRTY =
REFERENTE = Referente
VALINTRA =
[INDSPED]
RAGSOC = _STREXPR,LEFT(RagioneSociale+" "+DatiAggiuntivi; 50)
INDIR = Indirizzo
CIV =
LOCALITA =
STATO = _TAB,%TPS,IdIso,S6
COM =
CAP = CAP
PTEL =
TEL = Telefono1
PFAX =
FAX = TelFax
[CFVEN]
CODINDDOC =
CODNOTE =
@ -319,18 +371,6 @@ PLURIMAND =
DATACESS =
[INDSPED]
RAGSOC = TradeName1
INDIR = Address
CIV =
LOCALITA =
CAP = ZipCode
STATO = _TAB,%TPS,State,S6
COM =
PTEL =
TEL = TelNumber
PFAX =
FAX = FaxNumber
IVARID =
[CONAI]
AC = CONACC