diff --git a/tp/tp0100.cpp b/tp/tp0100.cpp index 10c3e435a..26f1fb4ac 100755 --- a/tp/tp0100.cpp +++ b/tp/tp0100.cpp @@ -234,17 +234,17 @@ bool TPack_transfer::log_cancelled() return log_error(TR("Procedura interrotta dall'utente")); } -bool TPack_transfer::test_write(TLocalisamfile& file, bool re) +bool TPack_transfer::test_write(TBaseisamfile& file, bool re) { int err = NOERR; if (_write_enabled) { if (re) - err = file.rewrite(); + err = file.rewrite_write(); else { TString80 code, desc; - if (file.num() == LF_TAB || file.num() == LF_TABCOM) + if (file.num() == LF_TAB || file.num() == LF_TABCOM || file.num() == LF_TABMOD) { code = file.get("CODTAB"); desc = file.get("S0"); @@ -256,7 +256,7 @@ bool TPack_transfer::test_write(TLocalisamfile& file, bool re) } TString msg; msg << TR("Inserimento ") << code << " (" << desc << ')' - << TR(" nel file ") << file.num() << ' ' << file.description(); + << TR(" nel file ") << ' ' << file.num() << " (" << file.description() << ')'; log(msg, 1); err = file.write(); diff --git a/tp/tp0100.h b/tp/tp0100.h index e962f3a8a..25a5e5c32 100755 --- a/tp/tp0100.h +++ b/tp/tp0100.h @@ -75,8 +75,8 @@ public: bool write_enabled() const { return _write_enabled; } - bool test_write(TLocalisamfile& file, bool re = false); - bool test_rewrite(TLocalisamfile& file) { return test_write(file, true); } + bool test_write(TBaseisamfile& file, bool re = false); + bool test_rewrite(TBaseisamfile& file) { return test_write(file, true); } virtual ~TPack_transfer(); }; @@ -147,10 +147,10 @@ class TPack_clifo : public TPack_transfer bool _only_agenti; protected: - int cancella_clifo(TLocalisamfile& clifo) const; + int cancella_clifo(TBaseisamfile& clifo) const; long get_next_key(const char tipocf) const; void update_statusflag_codcontab(const TString& custsuppcode, const int statusflag, const TString& codcontab); - bool aggiorna_record(TLocalisamfile& file, const TString_array& lista_campi); + bool aggiorna_record(TBaseisamfile& file, const TString_array& lista_campi); void aggiorna_banca(); void trasferisci_conai(TRectype& rec); const TString& decode_agente(const long codforn); diff --git a/tp/tp0101.cpp b/tp/tp0101.cpp index d75c0e615..bf6db8712 100755 --- a/tp/tp0101.cpp +++ b/tp/tp0101.cpp @@ -3,15 +3,16 @@ #include #include -#include "..\pr\agenti.h" - -#include #include +#include #include #include #include #include +#include "..\cg\cfban.h" +#include "..\pr\agenti.h" + /////////////////////////////////////////////////////////// // Cache banche /////////////////////////////////////////////////////////// @@ -195,7 +196,7 @@ const TString& TPack_clifo::get_agente() return EMPTY_STRING; } -int TPack_clifo::cancella_clifo(TLocalisamfile& clifo) const +int TPack_clifo::cancella_clifo(TBaseisamfile& clifo) const { // verificare prima che il cliente sia cancellabile (MOV e DOC) TRectype& rec_clifo = clifo.curr(); @@ -333,10 +334,13 @@ bool TPack_clifo::trasferisci() ini.list_variables(lista_cfven, true, "CFVEN", true); ini.list_variables(lista_agenti, true, "AGENTI", true); - TLocalisamfile clifo(LF_CLIFO); - TLocalisamfile cfven(LF_CFVEN); - TRectype& rec_clifo = clifo.curr(); + TFast_isamfile clifo(LF_CLIFO); + TFast_isamfile cfven(LF_CFVEN); + TFast_isamfile cfban(LF_CFBAN); + + TRectype& rec_clifo = clifo.curr(); TRectype& rec_cfven = cfven.curr(); + TRectype& rec_cfban = cfban.curr(); TRecord_cache cache_comuni(LF_COMUNI, 2); @@ -354,12 +358,12 @@ bool TPack_clifo::trasferisci() if (!needs_creation) { // il cliente/fornitore va aggiornato - rec_cfven.zero(); + cfven.zero(); rec_cfven.put(CFV_TIPOCF, tipocf); rec_cfven.put(CFV_CODCF, codcf); cfven.read(); - rec_clifo.zero(); + clifo.zero(); rec_clifo.put(CLI_TIPOCF, tipocf); rec_clifo.put(CLI_CODCF, codcf); good = clifo.read() == NOERR; @@ -422,7 +426,21 @@ bool TPack_clifo::trasferisci() const bool ibanflag = get_long("IbanFlag") != 0; if (ibanflag) { - rec_clifo.put(CLI_IBAN, get_str("IbanCode")); + const TString& iban = get_str("IbanCode"); + if (iban.len() >= 15) // A volte ci sono dei valori non validi come "IT46" + { + rec_clifo.put(CLI_IBAN, iban); + cfban.zero(); + rec_cfban.put(CFBAN_TIPOCF, tipocf); + rec_cfban.put(CFBAN_CODCF, codcf); + rec_cfban.put(CFBAN_TIPOBAN, 'V'); + rec_cfban.put(CFBAN_NRIGA, 1); + rec_cfban.put(CFBAN_ABI, iban.mid( 5,5)); + rec_cfban.put(CFBAN_CAB, iban.mid(10,5)); + rec_cfban.put(CFBAN_NUMCC, iban.mid(15)); + rec_cfban.put(CFBAN_IBAN, iban); + test_write(cfban, !needs_creation); + } } // agente rec_cfven.put(CFV_CODAG, get_agente()); @@ -460,11 +478,12 @@ bool TPack_clifo::trasferisci() void TPack_clifo::update_statusflag_codcontab(const TString& custsuppcode, const int statusflag, const TString& codcontab) { TString query; - query.format("UPDATE Customers_Suppliers SET StatusFlag=%d, CodContab='%s' WHERE CustSuppCode='%s'", statusflag, (const char*) codcontab, (const char*) custsuppcode); + query.format("UPDATE Customers_Suppliers SET StatusFlag=%d, CodContab='%s' WHERE CustSuppCode='%s'", + statusflag, (const char*)codcontab, (const char*)custsuppcode); odbc_exec(query); } -bool TPack_clifo::aggiorna_record(TLocalisamfile& file, const TString_array& lista_campi) +bool TPack_clifo::aggiorna_record(TBaseisamfile& file, const TString_array& lista_campi) { TRectype& rec = file.curr(); TString campo_dest, campo_orig, valore, str; @@ -635,8 +654,8 @@ bool TPack_indsped::trasferisci() { // custsupprefcode e' il cliente/fornitore a cui si riferisce l'indirizzo di spedizione const char* custsupprefcode = get_str("CustSuppRefCode"); - str.format(FR("Non esiste l'indirizzo di spedizione %ld/%d corrispondente a %s"), - codcf, codind, custsupprefcode); + str.format(FR("Non esiste il %s %d corrispondente a %s"), + tipocf == 'C' ? TR("cliente") : TR("fornitore"), codcf, custsupprefcode); log(str, 1); } } @@ -652,6 +671,7 @@ bool TPack_indsped::trasferisci() rec_indsped.put(IND_TIPOCF, tipocf); rec_indsped.put(IND_CODCF, codcf); rec_indsped.put(IND_CODIND, codind); + codcontab.cut(0); codcontab.add(codcf); codcontab.add(codind); good = test_write(indsped);