Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Corretta importazione agenti nei clienti


git-svn-id: svn://10.65.10.50/branches/R_10_00@21169 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2010-11-23 16:31:15 +00:00
parent e0762200f6
commit 9110f73911
5 changed files with 346 additions and 170 deletions

View File

@ -1,5 +1,6 @@
#include "hacnv100.h"
#include "hacnv100a.h"
#include "halib.h"
#include <applicat.h>
#include <automask.h>
@ -824,57 +825,19 @@ bool THardy_pcon::trasferisci_sottoconti()
return write_enabled();
}
long THardy_clienti::get_codcf(const TString &key)
{
long codcf = 0;
const char first = key[0];
long cod_hardy = atoi(key.mid(3,6));
switch (first)
{
case 'H':
{
codcf = 130000+cod_hardy;
}
break;
case 'P':
{
codcf = 140000+cod_hardy;
}
break;
case '0':
{
const char second = key[1];
if (second == '1')
codcf = 120000+cod_hardy;
else if (second == '0')
{
const char third = key[2];
if (third == '4')
codcf = 110000+cod_hardy;
else if (third == '3')
codcf = 100000+cod_hardy;
else if (third == '2')
codcf = 200000+cod_hardy;
else
codcf = cod_hardy;
}
}
break;
default:
codcf = cod_hardy;
}
if (codcf > 999999)
codcf = 0;
return codcf;
}
///////////////////////////////////////////////////////////
// THardy_clienti
///////////////////////////////////////////////////////////
bool THardy_clienti::trasferisci()
{
if (trasferisci_clienti())
return trasferisci_destinazioni();
return false;
bool ok = trasferisci_clienti();
if (ok)
ok = trasferisci_destinazioni();
return ok;
}
// trasferisce i clienti
bool THardy_clienti::trasferisci_clienti()
{
TString query =
@ -899,8 +862,8 @@ bool THardy_clienti::trasferisci_clienti()
while (++hi)
{
// costruisco la chiave
const TString16 key = get_str("IdConto");
long codcf = get_codcf(key);
const TString& key = get_str("IdConto");
const long codcf = get_codcf(key);
if (codcf > 0)
{
rec.zero();
@ -930,7 +893,8 @@ bool THardy_clienti::trasferisci_clienti()
if (test_write(clienti))
{
TString msg;
msg << TR("Inserito cliente ") << " '" << key << '\'' << TR("con codice ") << codcf ;
msg << TR("Inserito cliente ") << " '" << key << "\' -> "
<< codcf << " - " << rec.get(CLI_RAGSOC);
log(msg);
}
@ -940,8 +904,11 @@ bool THardy_clienti::trasferisci_clienti()
cfv_rec.put(CFV_CODCF, codcf);
const TString4 codzona = get_str("IdZona");
cfv_rec.put(CFV_CODZONA, codzona);
const TString4 codag = get_str("IdAgente1"); //agente principale
TString8 codag = get_str("IdAgente1"); //agente principale
codag.right_just(5, '0');
cfv_rec.put(CFV_CODAG, codag);
test_write(cfven);
}
else
@ -956,6 +923,8 @@ bool THardy_clienti::trasferisci_clienti()
return write_enabled();
}
// verifica se esiste un altro cliente con stessa partita iva (solo tra 200000 e 300000)
// per decidere se fare scambio dati tra destinazioni e clienti oppure inserire un indirizzo di spedizione
bool THardy_clienti::is_piva_doppia(const long codcf)
{
TToken_string tok; tok.add("C"); tok.add(codcf);
@ -967,6 +936,7 @@ bool THardy_clienti::is_piva_doppia(const long codcf)
return (clifo.items() > 1);
}
// restituisce il codice indirizzo di spedizione da usare per inserimento record
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");
@ -982,11 +952,14 @@ int THardy_clienti::get_next_key_indsped(const char tipocf, const long codcf) co
return codind;
}
// trasferisce la tabella Destinazioni che vale sia come indirizzi di spedizione sia come verifica dei dati sui clienti
// in caso di partita iva doppia (solo clienti tra 200000 e 300000) prende i dati su Destinazioni
// come dati anagrafici del clienti (esempio Esselunga)
bool THardy_clienti::trasferisci_destinazioni()
{
TString query =
"SELECT * "
"FROM dbo.Destinazioni ";
"FROM dbo.Destinazioni";
TRecordset& recset = create_recordset(query);
TConfig& ini = config();
@ -1004,8 +977,8 @@ bool THardy_clienti::trasferisci_destinazioni()
while (++hi)
{
// costruisco la chiave
const TString16 key = get_str("IdConto");
long codcf = get_codcf(key);
const TString& key = get_str("IdConto");
const long codcf = get_codcf(key);
rec.zero();
rec.put(CLI_TIPOCF, "C");
rec.put(CLI_CODCF, codcf);
@ -1048,8 +1021,7 @@ bool THardy_clienti::trasferisci_destinazioni()
else
{
// inserisco indirizzo di spedizione
int codind = 0;
codind = get_next_key_indsped('C', codcf);
int codind = get_next_key_indsped('C', codcf);
rec_indsped.zero();
rec_indsped.put(IND_TIPOCF, "C");
rec_indsped.put(IND_CODCF, codcf);
@ -1075,9 +1047,13 @@ bool THardy_clienti::trasferisci_destinazioni()
return write_enabled();
}
long THardy_fornitori::get_codcf(const TString &key) const
///////////////////////////////////////////////////////////
// THardy_fornitori
///////////////////////////////////////////////////////////
long THardy_clienti::get_codcf(const TString& key) const
{
long codcf = atol(key.mid(3,6));
const long codcf = atol(key.mid(3,6));
return codcf;
}
@ -1099,8 +1075,8 @@ bool THardy_fornitori::trasferisci()
THardy_iterator hi(this);
while (++hi)
{
const TString16 key = get_str("IdConto");
long codcf = get_codcf(key);
const TString& key = get_str("IdConto");
const long codcf = get_codcf(key);
if (codcf > 0)
{
rec.zero();
@ -1140,6 +1116,9 @@ bool THardy_fornitori::trasferisci()
return write_enabled();
}
///////////////////////////////////////////////////////////
// THardy_agenti
///////////////////////////////////////////////////////////
const TString& THardy_agenti::get_codage(const TString& key) const
{
TString& codage = get_tmp_string();
@ -1166,14 +1145,20 @@ bool THardy_agenti::trasferisci()
THardy_iterator hi(this);
while (++hi)
{
const TString16 key = get_str("IdAgente");
const TString8 codage = get_codage(key);
if (codage > 0)
const TString8 key = get_str("IdAgente");
if (!real::is_null(key))
{
rec.zero();
rec.put(AGE_CODAGE, codage);
rec.put(AGE_CODAGE, get_codage(key));
aggiorna_record(rec, lista_campi);
test_write(agenti);
if (test_write(agenti))
{
TString msg;
msg << TR("Inserito agente ") << " '" << key << "\' -> "
<< rec.get(AGE_CODAGE) << " - " << rec.get(AGE_RAGSOC);
log(msg);
}
}
else
{
@ -1186,6 +1171,100 @@ bool THardy_agenti::trasferisci()
return write_enabled();
}
///////////////////////////////////////////////////////////
// THardy_listini
///////////////////////////////////////////////////////////
bool THardy_listini::trasferisci()
{
if (trasferisci_listini())
return trasferisci_listinid();
return false;
}
// trasferisce tabella Listini (condv L)
bool THardy_listini::trasferisci_listini()
{
TString query =
"SELECT * "
"FROM dbo.Listini ";
TRecordset& recset = create_recordset(query);
TConfig& ini = config();
TString_array lista_campi;
ini.list_variables(lista_campi, true, "LISTINI", true);
TSystemisamfile condv(LF_CONDV);
condv.open(_lock);
TRectype& rec = condv.curr();
THardy_iterator hi(this);
while (++hi)
{
aggiorna_record(rec, lista_campi);
test_write(condv);
}
condv.close();
return write_enabled();
}
// trasferisce tabella ListiniD (rcondv L)
bool THardy_listini::trasferisci_listinid()
{
TString query =
"SELECT * "
"FROM dbo.ListiniD ";
TRecordset& recset = create_recordset(query);
TConfig& ini = config();
TString_array lista_campi;
ini.list_variables(lista_campi, true, "LISTINID", true);
TSystemisamfile rcondv(LF_RCONDV);
rcondv.open(_lock);
TRectype& rec = rcondv.curr();
THardy_iterator hi(this);
while (++hi)
{
aggiorna_record(rec, lista_campi);
test_write(rcondv);
}
rcondv.close();
return write_enabled();
}
///////////////////////////////////////////////////////////
// THardy_contratti
///////////////////////////////////////////////////////////
// trasferisce tabella ListiniCF (condv C)
// inserisco una testata per ogni cliente e tutte le righe relative agli articoli di quel cliente
// tralasciando le righe con DataFine < data impostata da parametri
bool THardy_contratti::trasferisci()
{
TString query =
"SELECT * "
"FROM dbo.ListiniCF "
"ORDER BY IdConto ";
TRecordset& recset = create_recordset(query);
TConfig& ini = config();
TString_array lista_campi;
ini.list_variables(lista_campi, true, "CONTRATTI", true);
TSystemisamfile condv(LF_CONDV);
TSystemisamfile rcondv(LF_RCONDV);
condv.open(_lock);
rcondv.open(_lock);
TRectype& rec_condv = condv.curr();
TRectype& rec_rcondv = rcondv.curr();
THardy_iterator hi(this);
int oldconto = -1;
int codcontratto = 0;
while (++hi)
{
aggiorna_record(rec_condv, lista_campi);
test_write(condv);
}
condv.close();
return write_enabled();
}
///////////////////////////////////////////////////////////
// TImportazioneHardy_mask
///////////////////////////////////////////////////////////
@ -1292,7 +1371,6 @@ void TImportazioneHardy_mask::trasferisci()
book.add(log);
rep_to_print = true;
}
if (go_on && get_bool(F_UM))
{
THardy_um pc;
@ -1341,6 +1419,22 @@ void TImportazioneHardy_mask::trasferisci()
book.add(log);
rep_to_print = true;
}
if (go_on && get_bool(F_LISTINI))
{
THardy_listini pc;
pc.init(TR("Listini"), query_header, log);
go_on = pc.trasferisci();
book.add(log);
rep_to_print = true;
}
if (go_on && get_bool(F_CONTRATTI))
{
THardy_contratti pc;
pc.init(TR("Contratti"), query_header, log);
go_on = pc.trasferisci();
book.add(log);
rep_to_print = true;
}
if (rep_to_print && book.pages() > 0)
book.preview();

View File

@ -190,6 +190,7 @@ protected:
bool trasferisci_gruppi();
bool trasferisci_conti();
bool trasferisci_sottoconti();
public:
virtual bool trasferisci();
};
@ -198,18 +199,17 @@ 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();
long get_codcf(const TString& key) const;
public:
virtual bool trasferisci();
};
class THardy_fornitori : public THardy_transfer
class THardy_fornitori : public THardy_clienti
{
protected:
long get_codcf(const TString& key) const;
public:
virtual bool trasferisci();
};
@ -222,6 +222,20 @@ public:
virtual bool trasferisci();
};
class THardy_listini : public THardy_transfer
{
protected:
bool trasferisci_listini();
bool trasferisci_listinid();
public:
virtual bool trasferisci();
};
class THardy_contratti : public THardy_transfer
{
public:
virtual bool trasferisci();
};
class TCache_art;
class TCache_umart;

View File

@ -81,42 +81,52 @@ S0=DsBanca
[CAB]
S0=DsDocumento
// tabella causali contabili
[CAUCONT]
CODCAUS = IdCausale
DESCR = DsCausaleEstesa
// tabella causali magazzino
[CAUMAG]
CODTAB = IdCausale
S0 = DsCausaleEstesa
// tabella unita di misura
[UM]
CODTAB = IdUm
S0 = DsUm
// articoli
[ANAMAG]
CODART = IdProdotto
DESCR = DsProdotto
CODIVA = IdIva
GRMERC = IdCategoria
// unita di misura articoli
[UMART]
CODART = IdProdotto
NRIGA = _FISSO,1
UM = IdUM1
// piano dei conti (gruppi)
[MASTRI]
DESCR = DsMastro
// piano dei conti (conti e sottoconti)
[CONTI]
DESCR = RagioneSociale
// conversione tabella tipo mastro
[FlTipoMastro]
1 = C
5 = F
// parametri per conversione piano dei conti
[PARAMETRI]
PCON=04|05
// fornitori
[FORNITORI]
RAGSOC = _STREXPR,LEFT(RagioneSociale+" "+DatiAggiuntivi; 50)
INDCF = Indirizzo
@ -170,6 +180,7 @@ DIRTY =
REFERENTE = Referente
VALINTRA =
// clienti
[CLIENTI]
RAGSOC = _STREXPR,LEFT(RagioneSociale+" "+DatiAggiuntivi; 50)
INDCF = Indirizzo
@ -223,6 +234,7 @@ DIRTY =
REFERENTE = Referente
VALINTRA =
// archivio destinazioni hardy che agisce sul cliente
[DESTINAZIONI]
RAGSOC = _STREXPR,LEFT(RagioneSociale+" "+DatiAggiuntivi; 50)
INDCF = Indirizzo
@ -263,6 +275,7 @@ DIRTY =
REFERENTE = Referente
VALINTRA =
// archivio destinazioni hardy che agisce su indirizzi di spedizione
[INDSPED]
RAGSOC = _STREXPR,LEFT(RagioneSociale+" "+DatiAggiuntivi; 50)
INDIR = Indirizzo
@ -276,85 +289,14 @@ TEL = Telefono1
PFAX =
FAX = TelFax
[CFVEN]
CODINDDOC =
CODNOTE =
CODLEG =
CODCATC = _TAB,TPC,CategoryCode,S6
CODZONA = _TAB,TPZ,ZoneCode,S6
CODAG =
PERCPROVV =
CAPZON =
LIQPAG =
CODPRCF =
CODINDSP =
CODNOTESP1 =
CODNOTESP2 =
CODSPMEZZO = _TAB,%TPM,TransportCode,S6
CODPORTO = _TAB,%TPP,PortCode,S6
CODVETT1 =
CODVETT2 =
CODVETT3 =
RAGGDOC =
CODCFASS =
ASSFIS = _TABCOM,%TPI,CodIvaNI,S6
FATTSOSP =
VSNRPROT = ExportOrigNum
VSDATAREG = ExportOrigDate
NSNPROT = ExportProtNum
NSDATAREG = ExportProtDate
CATFIN =
CODABIPR =
CODCABPR =
CODINDEFF =
EMEFFRICH =
RAGGEFF =
IMPMINEFF =
NONACCEFF =
NONSCADEFF =
ADDBOLLI =
PERCSPINC =
IVARID =
CATVEN =
GESTCONTR =
CODLIST =
CODSCC =
CODMAG =
CODDEP =
CODSP1 =
CODSP2 =
CODSP3 =
CODSP4 =
PROFSOLL =
MAXSOLL =
DATAESC =
NUMESC =
DATASOLL =
SCONTO = Discount
TITOLO =
RAGGOR =
MINORD =
MAXORD =
PREVORD =
TIPOEVORD =
ESACC =
ESALL =
ESCAR =
ESPLA =
ESLEG =
ESVET =
CONAIASS =
TIPODOCFAT =
CODCAUS =
[AGENTI]
RAGSOC = TradeName1
RAGSOC = DsAgente
TIPO = _FISSO,A
CODCAPO =
PERCAPO =
PERCFATT =
CAMPOPROVV =
PERCPROVV = ProvvAgent
PERCPROVV = PercProvvigione
SEQRIC =
CODRICPR1 =
CODRICPR2 =
@ -370,38 +312,118 @@ MATRICOLA =
PLURIMAND =
DATACESS =
[INDSPED]
[CONAI]
AC = CONACC
AL = CONALL
CA = CONCAR
LE = CONLEG
PL = CONPLA
VE = CONVET
[LISTINI]
TIPO = _FISSO,L
CATVEN =
TIPOCF =
CODCF =
COD = KListino
DESCR = IdListino
CODVAL = _TRADUCI,IdDivisa
CAMBIO =
CONTROEURO =
DATACAM =
VALIN = 01-01-2001
VALFIN = 31-12-2100
IMPLORDI =
GESTUM =
GESTSCAGL =
GESTSCO =
OBBLIG =
CODLISSUCC =
SEQRIC =
DECIMALI =
FATHCATVEN =
FATHCOD =
ARROTONDA =
[CFV_CONAI]
AC = ESACC
AL = ESALL
CA = ESCAR
LE = ESLEG
PL = ESPLA
VE = ESVET
[LISTINID]
TIPO = _FISSO,L
CATVEN =
TIPOCF =
CODCF =
COD = KListino
TIPORIGA = _FISSO,A
CODRIGA = IdProdotto
UM =
NSCAGL =
QLIM =
PREZZO = Prezzo
SCONTO = Sconto1
ADDIVA =
CODIVA =
PERCPROVV =
QOM =
QBASE =
CODARTOM =
PROMAGGIO =
UMOM =
CODLOTTO =
ARTES =
DATAULTAUM =
PRZSTO =
DATAPRZSTO =
[STANDARD]
RAGGDOC=X
RAGGEFF=X
ADDBOLLI=
PERCSPINC=
// conversione valute per listini
[IdDivisa]
006=EUR
[CODNUM]
1 = B01
2 = B01
// contratti
[CONTRATTI]
TIPO = _FISSO,C
CATVEN =
TIPOCF =
CODCF =
COD = KListino
DESCR = IdListino
CODVAL = _TRADUCI,IdDivisa
CAMBIO =
CONTROEURO =
DATACAM =
VALIN = 01-01-2001
VALFIN = 31-12-2100
IMPLORDI =
GESTUM =
GESTSCAGL =
GESTSCO =
OBBLIG =
CODLISSUCC =
SEQRIC =
DECIMALI =
FATHCATVEN =
FATHCOD =
ARROTONDA =
[TIPODOC]
20 = B01
DDT C/RIP = BOF
[LISTINID]
TIPO = _FISSO,L
CATVEN =
TIPOCF =
CODCF =
COD = KListino
TIPORIGA = _FISSO,A
CODRIGA = IdProdotto
UM =
NSCAGL =
QLIM =
PREZZO = Prezzo
SCONTO = Sconto1
ADDIVA =
CODIVA =
PERCPROVV =
QOM =
QBASE =
CODARTOM =
PROMAGGIO =
UMOM =
CODLOTTO =
ARTES =
DATAULTAUM =
PRZSTO =
DATAPRZSTO =
// parametri generali della maschera (dns user password)
[Main]
201 = hardy
202 =

View File

@ -399,3 +399,48 @@ const TString& format_data_6(const TDate& data)
str_data.format("%02d%02d%02d", day, month, year%100);
return str_data;
}
// determina codice cliente campo a partire da codice hardy in base alle regole dettatemi da Robbi
const long get_codcf(const TString& key)
{
long codcf = 0;
const char first = key[0];
long cod_hardy = atoi(key.mid(3,6));
switch (first)
{
case 'H':
{
codcf = 130000+cod_hardy;
}
break;
case 'P':
{
codcf = 140000+cod_hardy;
}
break;
case '0':
{
const char second = key[1];
if (second == '1')
codcf = 120000+cod_hardy;
else if (second == '0')
{
const char third = key[2];
if (third == '4')
codcf = 110000+cod_hardy;
else if (third == '3')
codcf = 100000+cod_hardy;
else if (third == '2')
codcf = 200000+cod_hardy;
else
codcf = cod_hardy;
}
}
break;
default:
codcf = cod_hardy;
}
if (codcf > 999999)
codcf = 0;
return codcf;
}

View File

@ -220,4 +220,5 @@ public:
real find_sconto(const TString& str_sconto);
const TString& find_codag(const long codcf);
const TString& format_data_8(const TDate& data);
const TString& format_data_6(const TDate& data);
const TString& format_data_6(const TDate& data);
const long get_codcf(const TString& key);