Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : Corretta importazione clienti e fornitori da 36 git-svn-id: svn://10.65.10.50/trunk@6951 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
1e0ec20f1b
commit
7e6e33cc8f
@ -11,8 +11,13 @@
|
||||
#include "ibm36.h"
|
||||
|
||||
#include <comuni.h>
|
||||
#include <cfven.h>
|
||||
#include <clifo.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TMask36 Maschera principale di selezione
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TMask36 : public TAutomask
|
||||
{
|
||||
protected:
|
||||
@ -28,8 +33,55 @@ bool TMask36::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TBankitalia
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TBankitalia : public TObject
|
||||
{
|
||||
TAssoc_array _bank;
|
||||
|
||||
public:
|
||||
const TString* codban2abicab(const char* codban);
|
||||
void update();
|
||||
|
||||
TBankitalia() { }
|
||||
virtual ~TBankitalia() { }
|
||||
};
|
||||
|
||||
void TBankitalia::update()
|
||||
{
|
||||
TTable ban("%BAN");
|
||||
const TRectype& curban = ban.curr();
|
||||
|
||||
_bank.destroy();
|
||||
for (int err = ban.first(); err == NOERR; err = ban.next())
|
||||
{
|
||||
TString16 codban = curban.get("S9");
|
||||
if (codban.not_empty())
|
||||
{
|
||||
const TString& abicab = curban.get("CODTAB");
|
||||
_bank.add(codban, abicab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const TString* TBankitalia::codban2abicab(const char* cod)
|
||||
{
|
||||
if (_bank.items() == 0)
|
||||
update();
|
||||
const TString* abicab = (const TString*)_bank.objptr(cod);
|
||||
return abicab;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TTrasfer36 Applicazione di importazione dati da 36
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TTrasfer36 : public TSkeleton_application
|
||||
{
|
||||
TBankitalia _bankitalia;
|
||||
|
||||
protected:
|
||||
virtual void main_loop();
|
||||
virtual const char* extra_modules() const { return "*"; } // Non e' un modulo normale
|
||||
@ -37,6 +89,9 @@ protected:
|
||||
public:
|
||||
const TString& cap2com(const TString& cap, const TString& name) const;
|
||||
void split_indir(const TString& indir, TString& via, TString& civ) const;
|
||||
void mettilavirgola(TFile_text& file, TRecord_text& curr, const char* field, int len, int comma);
|
||||
void permille(TFile_text& file, TRecord_text& curr, const char* field);
|
||||
void machedata(TFile_text& file, TRecord_text& curr, const char* field);
|
||||
void import_tables(const TFilename& name, TBrowsefile_field& bf);
|
||||
void import_clifo(const TFilename& name, TBrowsefile_field& bf);
|
||||
};
|
||||
@ -159,15 +214,29 @@ void TTrasfer36::import_tables(const TFilename& name, TBrowsefile_field& bf)
|
||||
TString16 cab = file.get_field(curr, "CAB");
|
||||
if (abi.empty() || cab.empty())
|
||||
{
|
||||
if (abi.empty()) abi = "99999";
|
||||
if (cab.empty()) { cab = cod; cab.right_just(5, '0'); }
|
||||
|
||||
msg = "! La banca ";
|
||||
msg << cod << " non dispone di un codice ABI/CAB valido";
|
||||
bf.add_line(msg);
|
||||
msg = "- Verra' creata la banca fittizia ";
|
||||
msg << abi << ' ' << cab;
|
||||
bf.add_line(msg);
|
||||
if (abi.empty())
|
||||
abi = "99999";
|
||||
if (cab.empty())
|
||||
{
|
||||
const TString* abicab = _bankitalia.codban2abicab(cod);
|
||||
if (abicab != NULL)
|
||||
{
|
||||
abi = abicab->left(5);
|
||||
cab = abicab->mid(5);
|
||||
}
|
||||
else
|
||||
{
|
||||
ban.last();
|
||||
const TString16 abicab = ban.get("CODTAB");
|
||||
if (abicab.left(5) == "99999")
|
||||
{
|
||||
long numcab = atol(abicab.mid(5)) + 1;
|
||||
cab.format("%05ld", numcab);
|
||||
}
|
||||
else
|
||||
cab = "00001";
|
||||
}
|
||||
}
|
||||
}
|
||||
abi.right_just(5, '0');
|
||||
cab.right_just(5, '0');
|
||||
@ -189,14 +258,21 @@ void TTrasfer36::import_tables(const TFilename& name, TBrowsefile_field& bf)
|
||||
ban.put("CODTAB", codtab);
|
||||
if (ban.read() == NOERR)
|
||||
{
|
||||
ban.put("I14", cod);
|
||||
ban.put("S9", cod);
|
||||
ban.rewrite();
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "! La banca ";
|
||||
msg << cod << " non dispone di un codice ABI/CAB valido";
|
||||
bf.add_line(msg);
|
||||
msg = "- Verra' creata la banca fittizia ";
|
||||
msg << abi << ' ' << cab;
|
||||
bf.add_line(msg);
|
||||
|
||||
ban.put("CODTAB", codtab);
|
||||
ban.put("S0", file.get_field(curr, "RAGSOC"));
|
||||
ban.put("I14", cod);
|
||||
ban.put("S9", cod);
|
||||
|
||||
const TString& cap = file.get_field(curr, "CAP");
|
||||
ban.put("S3", cap);
|
||||
@ -219,12 +295,69 @@ void TTrasfer36::import_tables(const TFilename& name, TBrowsefile_field& bf)
|
||||
}
|
||||
}
|
||||
|
||||
_bankitalia.update();
|
||||
|
||||
msg = "Record importati: ";
|
||||
msg << valid;
|
||||
bf.add_line(msg);
|
||||
bf.add_line("");
|
||||
}
|
||||
|
||||
void TTrasfer36::mettilavirgola(TFile_text& file, TRecord_text& curr, const char* field, int len, int comma)
|
||||
{
|
||||
TString80 num = file.get_field(curr, field);
|
||||
if (!real::is_null(num))
|
||||
{
|
||||
num.right_just(len, '0');
|
||||
num.insert(".", len - comma);
|
||||
file.add_field(curr, field, num);
|
||||
}
|
||||
}
|
||||
|
||||
void TTrasfer36::permille(TFile_text& file, TRecord_text& curr, const char* field)
|
||||
{
|
||||
TString80 num = file.get_field(curr, field);
|
||||
if (!real::is_null(num))
|
||||
{
|
||||
num << "000";
|
||||
file.add_field(curr, field, num);
|
||||
}
|
||||
}
|
||||
|
||||
void TTrasfer36::machedata(TFile_text& file, TRecord_text& curr, const char* field)
|
||||
{
|
||||
TString80 num = file.get_field(curr, field);
|
||||
if (!real::is_null(num))
|
||||
{
|
||||
switch (num.len())
|
||||
{
|
||||
case 6:
|
||||
{
|
||||
num.insert("19", 0);
|
||||
const TDate data(atol(num));
|
||||
file.add_field(curr, field, data.string());
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
{
|
||||
const int secolo = num[0] - '0';
|
||||
long ansidata = atol(num.mid(1));
|
||||
ansidata += (19 + secolo) * 1000000L;
|
||||
const TDate data(ansidata);
|
||||
file.add_field(curr, field, data.string());
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
num.insert("-", 4);
|
||||
num.insert("-", 2);
|
||||
file.add_field(curr, field, num);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TTrasfer36::import_clifo(const TFilename& name, TBrowsefile_field& bf)
|
||||
{
|
||||
TAssoc_array missing_firm;
|
||||
@ -276,6 +409,9 @@ void TTrasfer36::import_clifo(const TFilename& name, TBrowsefile_field& bf)
|
||||
|
||||
const char* tipocf = (tipo_record & 0x1) ? "C" : "F";
|
||||
const long codcf = atol(file.get_field(curr, "CODCF"));
|
||||
TString16 extcf;
|
||||
extcf << (*tipocf == 'C' ? "cliente" : "fornitore") << ' ' << codcf;
|
||||
|
||||
TLocalisamfile& clifo = rel.lfile();
|
||||
clifo.put(CLI_TIPOCF, tipocf);
|
||||
clifo.put(CLI_CODCF, codcf);
|
||||
@ -292,7 +428,7 @@ void TTrasfer36::import_clifo(const TFilename& name, TBrowsefile_field& bf)
|
||||
if (err != NOERR)
|
||||
{
|
||||
msg = "! Non esiste il ";
|
||||
msg << (*tipocf == 'C' ? "cliente" : "fornitore") << ' ' << codcf;
|
||||
msg << extcf;
|
||||
bf.add_line(msg);
|
||||
msg = "- Inserimento di ";
|
||||
msg << file.get_field(curr, "COGNOME") << file.get_field(curr, "NOME");
|
||||
@ -311,6 +447,45 @@ void TTrasfer36::import_clifo(const TFilename& name, TBrowsefile_field& bf)
|
||||
case 3:
|
||||
if (err == NOERR)
|
||||
{
|
||||
TString cod = file.get_field(curr, "CODICE BANCA D'APPOGGIO");
|
||||
if (!cod.blank())
|
||||
{
|
||||
const TString* abicab = _bankitalia.codban2abicab(cod);
|
||||
if (abicab)
|
||||
{
|
||||
rel.curr().put(CLI_CODABI, abicab->left(5));
|
||||
rel.curr().put(CLI_CODCAB, abicab->mid(5));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "Ipossibile determinare l'ABI/CAB della banca d'appoggio ";
|
||||
msg << cod << " del " << extcf;
|
||||
bf.add_line(msg);
|
||||
}
|
||||
}
|
||||
|
||||
cod = file.get_field(curr, "CODICE BANCA PRESENTAZIONE EFFETTI");
|
||||
if (!cod.blank())
|
||||
{
|
||||
const TString* abicab = _bankitalia.codban2abicab(cod);
|
||||
if (abicab)
|
||||
{
|
||||
rel.curr(LF_CFVEN).put(CFV_CODABIPR, abicab->left(5));
|
||||
rel.curr(LF_CFVEN).put(CFV_CODCABPR, abicab->mid(5));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "Ipossibile determinare l'ABI/CAB della banca di presentazione ";
|
||||
msg << cod << " del " << extcf;
|
||||
bf.add_line(msg);
|
||||
}
|
||||
}
|
||||
|
||||
mettilavirgola(file, curr, "PROVVIGIONE AGENTE", 5, 2);
|
||||
permille(file, curr, "IMPORTO MINIMO EFFETTI");
|
||||
machedata(file, curr, "DATA INIZIO RID");
|
||||
machedata(file, curr, "DATA REVOCA RID");
|
||||
|
||||
rel.write_enable(LF_CFVEN);
|
||||
const int err = file.autosave(rel, curr);
|
||||
if (err != NOERR)
|
||||
@ -323,10 +498,27 @@ void TTrasfer36::import_clifo(const TFilename& name, TBrowsefile_field& bf)
|
||||
valid++;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
// Ignored
|
||||
case 5:
|
||||
if (err != NOERR)
|
||||
{
|
||||
machedata(file, curr, "DATA INVIO ULTIMO ESTRATTO CONTO");
|
||||
machedata(file, curr, "DATA INVIO ULTIMO SOLLECITO");
|
||||
permille(file, curr, "FIDO");
|
||||
|
||||
rel.write_enable(LF_CFVEN);
|
||||
const int err = file.autosave(rel, curr);
|
||||
if (err != NOERR)
|
||||
{
|
||||
msg = "! Errore di scrittura sul file LF_CFVEN: ";
|
||||
msg << err;
|
||||
bf.add_line(msg);
|
||||
}
|
||||
else
|
||||
valid++;
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
default: break;// Ignored
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,15 +95,15 @@ LENGTH(40) = 1
|
||||
LENGTH(41) = 7
|
||||
LENGTH(42) = 7
|
||||
LENGTH(43) = 1
|
||||
LENGTH(44) = 1
|
||||
LENGTH(45) = 5
|
||||
LENGTH(44) = 5
|
||||
LENGTH(45) = 4
|
||||
LENGTH(46) = 4
|
||||
LENGTH(47) = 4
|
||||
LENGTH(48) = 4
|
||||
LENGTH(48) = 1
|
||||
LENGTH(49) = 1
|
||||
LENGTH(50) = 1
|
||||
LENGTH(51) = 1
|
||||
LENGTH(52) = 1
|
||||
LENGTH(52) = 12
|
||||
LENGTH(53) = 12
|
||||
|
||||
NAME(0) = ANNULLATO
|
||||
@ -151,7 +151,7 @@ NAME(41) = DATA INIZIO RID
|
||||
NAME(42) = DATA REVOCA RID
|
||||
NAME(43) = FILLER
|
||||
NAME(44) = EMISSIONE EFFETTI A RICHIESTA
|
||||
NAME(45) = IMPORTO MINIMO EFFETTI/1000
|
||||
NAME(45) = IMPORTO MINIMO EFFETTI
|
||||
NAME(46) = GGMM INIZIO NON ACCETTAZIONE EFFETtI
|
||||
NAME(47) = GGMM FINE NON ACCETTAZIONE EFFETtI
|
||||
NAME(48) = GGMM SCADENZA EFFETTI DEI PERIODI NON ACCETTATI
|
||||
@ -177,44 +177,44 @@ POSITION(12) = 33
|
||||
POSITION(13) = 35
|
||||
POSITION(14) = 45
|
||||
POSITION(15) = 47
|
||||
POSITION(16) = 50
|
||||
POSITION(17) = 51
|
||||
POSITION(18) = 52
|
||||
POSITION(19) = 55
|
||||
POSITION(20) = 57
|
||||
POSITION(21) = 59
|
||||
POSITION(22) = 61
|
||||
POSITION(23) = 63
|
||||
POSITION(24) = 66
|
||||
POSITION(25) = 69
|
||||
POSITION(26) = 72
|
||||
POSITION(27) = 73
|
||||
POSITION(28) = 74
|
||||
POSITION(29) = 80
|
||||
POSITION(30) = 82
|
||||
POSITION(31) = 83
|
||||
POSITION(32) = 89
|
||||
POSITION(33) = 95
|
||||
POSITION(34) = 101
|
||||
POSITION(35) = 107
|
||||
POSITION(36) = 108
|
||||
POSITION(37) = 110
|
||||
POSITION(38) = 113
|
||||
POSITION(39) = 116
|
||||
POSITION(40) = 119
|
||||
POSITION(41) = 120
|
||||
POSITION(42) = 124
|
||||
POSITION(43) = 128
|
||||
POSITION(44) = 129
|
||||
POSITION(45) = 130
|
||||
POSITION(46) = 133
|
||||
POSITION(47) = 141
|
||||
POSITION(48) = 149
|
||||
POSITION(49) = 157
|
||||
POSITION(50) = 158
|
||||
POSITION(51) = 159
|
||||
POSITION(52) = 160
|
||||
POSITION(53) = 161
|
||||
POSITION(16) = 52
|
||||
POSITION(17) = 53
|
||||
POSITION(18) = 54
|
||||
POSITION(19) = 57
|
||||
POSITION(20) = 59
|
||||
POSITION(21) = 61
|
||||
POSITION(22) = 63
|
||||
POSITION(23) = 65
|
||||
POSITION(24) = 68
|
||||
POSITION(25) = 71
|
||||
POSITION(26) = 74
|
||||
POSITION(27) = 75
|
||||
POSITION(28) = 76
|
||||
POSITION(29) = 82
|
||||
POSITION(30) = 84
|
||||
POSITION(31) = 85
|
||||
POSITION(32) = 91
|
||||
POSITION(33) = 97
|
||||
POSITION(34) = 103
|
||||
POSITION(35) = 109
|
||||
POSITION(36) = 110
|
||||
POSITION(37) = 112
|
||||
POSITION(38) = 115
|
||||
POSITION(39) = 118
|
||||
POSITION(40) = 121
|
||||
POSITION(41) = 122
|
||||
POSITION(42) = 129
|
||||
POSITION(43) = 136
|
||||
POSITION(44) = 137
|
||||
POSITION(45) = 142
|
||||
POSITION(46) = 150
|
||||
POSITION(47) = 158
|
||||
POSITION(48) = 166
|
||||
POSITION(49) = 167
|
||||
POSITION(50) = 168
|
||||
POSITION(51) = 169
|
||||
POSITION(52) = 170
|
||||
POSITION(53) = 182
|
||||
|
||||
FIELD(1) = TIPOCF
|
||||
FIELD(3) = CODCF
|
||||
@ -276,16 +276,91 @@ LENGTH(0) = 1
|
||||
LENGTH(1) = 1
|
||||
LENGTH(2) = 4
|
||||
LENGTH(3) = 6
|
||||
LENGTH(4) = 2
|
||||
LENGTH(5) = 1
|
||||
LENGTH(6) = 2
|
||||
LENGTH(7) = 2
|
||||
LENGTH(8) = 5
|
||||
LENGTH(9) = 3
|
||||
LENGTH(10) = 1
|
||||
LENGTH(11) = 3
|
||||
LENGTH(12) = 2
|
||||
LENGTH(13) = 1
|
||||
LENGTH(14) = 6
|
||||
LENGTH(15) = 6
|
||||
LENGTH(16) = 9
|
||||
LENGTH(17) = 5
|
||||
LENGTH(18) = 51
|
||||
LENGTH(19) = 2
|
||||
LENGTH(20) = 30
|
||||
LENGTH(21) = 8
|
||||
LENGTH(22) = 20
|
||||
LENGTH(23) = 2
|
||||
LENGTH(24) = 3
|
||||
|
||||
NAME(0) = ANNULLATO
|
||||
NAME(1) = TIPOCF
|
||||
NAME(2) = DITTA
|
||||
NAME(3) = CODCF
|
||||
NAME(4) = CODICE CATEGORIA VENDITE
|
||||
NAME(5) = FLAG GESTIONE CONTRATTO
|
||||
NAME(6) = CODICE LISTINO
|
||||
NAME(7) = CODICE TABELLA SCONTO INCONDIZIONATO
|
||||
NAME(8) = PERCENTUALE SCONTO CLIENTE
|
||||
NAME(9) = CODICE MAGAZZINO
|
||||
NAME(10) = CODICE DEPOSITO
|
||||
NAME(11) = CODICI SPESE DA ADDEBITARE
|
||||
NAME(12) = CODICE PROFILO SOLLECITO
|
||||
NAME(13) = NUMERO MASSIMO SOLLECITO
|
||||
NAME(14) = DATA INVIO ESTRATTO CONTO
|
||||
NAME(15) = DATA INVIO ULTIMO SOLLECITO
|
||||
NAME(16) = FIDO
|
||||
NAME(17) = PERCENTUALE SCONTO RIGA
|
||||
NAME(19) = TITOLO ONORIFICO
|
||||
NAME(21) = DATA DI NASCITA
|
||||
NAME(22) = LUOGO DI NASCITA
|
||||
NAME(23) = PROVINCIA DI NASCITA
|
||||
NAME(24) = NAZIONE DI NASCITA
|
||||
|
||||
POSITION(0) = 0
|
||||
POSITION(1) = 1
|
||||
POSITION(2) = 2
|
||||
POSITION(3) = 6
|
||||
POSITION(4) = 0
|
||||
POSITION(5) = 14
|
||||
POSITION(6) = 15
|
||||
POSITION(7) = 17
|
||||
POSITION(8) = 19
|
||||
POSITION(9) = 22
|
||||
POSITION(10) = 25
|
||||
POSITION(11) = 26
|
||||
POSITION(12) = 38
|
||||
POSITION(13) = 40
|
||||
POSITION(14) = 41
|
||||
POSITION(15) = 47
|
||||
POSITION(16) = 53
|
||||
POSITION(17) = 58
|
||||
POSITION(18) = 61
|
||||
POSITION(19) = 112
|
||||
POSITION(20) = 114
|
||||
POSITION(21) = 144
|
||||
POSITION(22) = 152
|
||||
POSITION(23) = 172
|
||||
POSITION(24) = 174
|
||||
|
||||
FIELD(1) = TIPOCF
|
||||
FIELD(3) = CODCF
|
||||
FIELD(5) = 17->GESCONTR
|
||||
FIELD(6) = 17->CODLIS
|
||||
FIELD(7) = 17->CODSCC
|
||||
FIELD(8) = 17->SCONTO
|
||||
FIELD(9) = 17->CODMAG
|
||||
FIELD(10) = 17->CODDEP
|
||||
FIELD(12) = 17->PROFSOLL
|
||||
FIELD(13) = 17->MAXSOLL
|
||||
FIELD(14) = 17->DATAESC
|
||||
FIELD(15) = 17->DATASOLL
|
||||
FIELD(16) = 17->FIDO
|
||||
|
||||
[RECORD 6]
|
||||
LENGTH(0) = 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user