Patch level : 12.0 no-patch

Files correlati     : fp
Commento            :
- Sistemato setter esportazione documenti, non si toglieva il flag una volta valorizzato
- Sistemato parsing caratteri speciali
- Sistemata lettura descrizione nel documento
- Messa a punto SQL
- Aumentata dimensione get_tmp_string a 1024 token
This commit is contained in:
Mattia Tollari 2018-10-08 10:42:28 +02:00
parent eb69b23204
commit fdedce8cbb
6 changed files with 88 additions and 19 deletions

View File

@ -41,8 +41,8 @@ void TParametri_mask::save_all() const
ini_set_string(CONFIG_DITTA, "fp", "flddest", get(F_FLDDEST)); ini_set_string(CONFIG_DITTA, "fp", "flddest", get(F_FLDDEST));
ini_set_string(CONFIG_DITTA, "fp", "fldusrdest", get(F_FLDUSRDEST)); ini_set_string(CONFIG_DITTA, "fp", "fldusrdest", get(F_FLDUSRDEST));
ini_set_string(CONFIG_DITTA, "fp", "cofitras", get(F_COFI)); ini_set_string(CONFIG_DITTA, "fp", "cofitras", get(F_COFI));
ini_set_bool(CONFIG_DITTA, "fp", "gestioneallegati", get(F_ESPORTAALLEG)); ini_set_bool(CONFIG_DITTA, "fp", "gestioneallegati", get_bool(F_ESPORTAALLEG));
ini_set_bool(CONFIG_DITTA, "fp", "allegafatt", get(F_ESPORTADOC)); ini_set_bool(CONFIG_DITTA, "fp", "allegafatt", get_bool(F_ESPORTADOC));
} }
void TParametri_mask::load_all() void TParametri_mask::load_all()

View File

@ -138,7 +138,7 @@ bool chiave_paf(const TDocumento& doc, TString& hfatt, TString& bfatt)
TString16 fullnumdoc; TString16 fullnumdoc;
codnum.complete_num(ndoc, fullnumdoc); codnum.complete_num(ndoc, fullnumdoc);
bfatt.cut(0) << doc.get_date(DOC_DATADOC).date2ansi() << '/' << doc.tipo().tipo_doc_sdi() << '/' << fullnumdoc; bfatt.cut(0) << doc.get_date(DOC_DATADOC).date2ansi() << '_' << doc.tipo().tipo_doc_sdi() << '_' << fullnumdoc;
return hfatt.full() && bfatt.full(); return hfatt.full() && bfatt.full();
} }
@ -175,6 +175,57 @@ bool get_coddest(const char tipocf, const long codcf, TString& coddest, TString&
return true; return true;
} }
inline const TString& no_special(char a)
{
TString& r = get_tmp_string().cut(0);
switch(a)
{
case 'à':
r << "a''";
break;
case 'è':
case 'é':
r << "e''";
break;
case 'ì':
r << "i''";
break;
case 'ò':
r << "o''";
break;
case 'ù':
r << "u''";
break;
case '\'':
r << "''";
break;
case '\\':
r << "\\\\";
break;
default:
r << a;
}
return r;
/*
if (a == 'à')
return "a''";
else if (a == 'è' || a == 'é')
return "e''";
else if (a == 'ì')
return "i''";
else if (a == 'ò')
return "o''";
else if (a == 'ù')
return "u''";
else if (a == '\'')
return "''";
else if (a == '\\')
return "\\\\";
// Se non trovo nulla ritorno il valore
return a;
*/
}
/*************************************************************************** /***************************************************************************
* TPaf_record * TPaf_record
***************************************************************************/ ***************************************************************************/
@ -289,13 +340,14 @@ const TString& TPaf_record::var2str(const TString& fldname, const TVariant& var)
if (!apici) if (!apici)
return str; return str;
TString& tmp = get_tmp_string(); // Parso i caratteri speciali
tmp = str; TString& tmp = get_tmp_string().cut(0);
for (int a = str.rfind('\''); a >= 0; a--) for(int i = 0; i < str.len(); i++)
{ {
if (tmp[a] == '\'') tmp << no_special(str[i]);
tmp.insert("'", a);
} }
// Aggiungo apici a inizio e fine riga
tmp.insert("'", 0); tmp.insert("'", 0);
tmp << '\''; tmp << '\'';
return tmp; return tmp;
@ -534,17 +586,16 @@ bool TDoc_fp::get_bank(const TDocumento& doc, TString& iban, TString& abi, TStri
return found; return found;
} }
const char* TDoc_fp::descrizione(const TRiga_documento& rdoc) const const TString& TDoc_fp::descrizione(const TRiga_documento& rdoc) const
{ {
if (rdoc.get_bool(RDOC_DESCLUNGA)) if (rdoc.get_bool(RDOC_DESCLUNGA))
{ {
TString tmp; TString& tmp = get_tmp_string();
tmp << rdoc.get(RDOC_DESCR) << rdoc.get(RDOC_DESCEST); tmp << rdoc.get(RDOC_DESCR) << rdoc.get(RDOC_DESCEST);
tmp.replace('\n', ' '); tmp.replace('\n', ' ');
tmp.strip_double_spaces(); tmp.strip_double_spaces();
tmp.trim(); tmp.trim();
TParagraph_string para(tmp, 100); return tmp;
return para.get(0);
} }
return rdoc.get(RDOC_DESCR); return rdoc.get(RDOC_DESCR);
} }
@ -605,7 +656,10 @@ bool TDoc_fp::insert(TPaf_record& p)
{ {
ok = p.insert(); ok = p.insert();
if (!ok) if (!ok)
{
log(2, db().sq_get_string_error()); log(2, db().sq_get_string_error());
log(2, p.insert_string());
}
} }
return ok; return ok;
} }
@ -622,7 +676,10 @@ bool TDoc_fp::remove(TPaf_record& p)
{ {
ok = p.remove(); ok = p.remove();
if (!ok) if (!ok)
{
log(2, db().sq_get_string_error()); log(2, db().sq_get_string_error());
log(2, p.remove_string());
}
} }
return ok; return ok;
} }
@ -637,7 +694,10 @@ bool TDoc_fp::save_paf()
query += *i; query += *i;
ok = db().sq_set_exec(query); ok = db().sq_set_exec(query);
if (!ok) if (!ok)
{
log(2, db().sq_get_string_error()); log(2, db().sq_get_string_error());
log(2, query.c_str());
}
} }
return ok; return ok;
} }
@ -701,7 +761,8 @@ const int TDoc_fp::commit()
else else
{ {
r = -1; r = -1;
log(3, db().sq_get_string_error()); log(2, db().sq_get_string_error());
log(2, "UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_GESTIONE = 'D'");
} }
} }
_to_commit = false; _to_commit = false;
@ -1140,10 +1201,11 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
TPaf_record paf3000f("PAF3000F"); TPaf_record paf3000f("PAF3000F");
paf3000f.set("PT_KEYHEADERFATT", hfatt); paf3000f.set("PT_KEYHEADERFATT", hfatt);
paf3000f.set("PT_KEYBODYFATT", bfatt); paf3000f.set("PT_KEYBODYFATT", bfatt);
remove(paf3000f);
paf3000f.set("PT_RIFNUMLINEA", riga); paf3000f.set("PT_RIFNUMLINEA", riga);
paf3000f.set("PT_COMMENTO", descrizione(*rdoc)); paf3000f.set("PT_COMMENTO", descrizione(*rdoc));
// paf1800f.set("PI_ALIQUOTAIVA", "22.00"); // Altrimenti scarta le righe di descrizione paf1800f.set("PI_ALIQUOTAIVA", "22.00"); // Altrimenti scarta le righe di descrizione
// <CodiceArticolo> // <CodiceArticolo>
long riga_art = 0; long riga_art = 0;

View File

@ -11,6 +11,7 @@
#include <vector> #include <vector>
#define SQL_FLD "sql/" #define SQL_FLD "sql/"
#define CARATTERI_SPECIALI "àèéìòù°'\\"
// Ritorna la connessione al DB paf secondo i parametri impostati nel programma di configurazione // Ritorna la connessione al DB paf secondo i parametri impostati nel programma di configurazione
SSimple_query& db(); SSimple_query& db();
@ -20,6 +21,7 @@ bool check_tables();
bool chiave_paf(const TDocumento& doc, TString& hfatt, TString& bfatt); bool chiave_paf(const TDocumento& doc, TString& hfatt, TString& bfatt);
bool chiave_paf(const TRectype& doc, TString& hfatt, TString& bfatt); bool chiave_paf(const TRectype& doc, TString& hfatt, TString& bfatt);
bool get_coddest(const char tipocf, const long codcf, TString& coddest, TString& pec); bool get_coddest(const char tipocf, const long codcf, TString& coddest, TString& pec);
inline const TString& no_special(char a);
// Contenitore di campi di un record di database MSSQLServer // Contenitore di campi di un record di database MSSQLServer
class TPaf_record : public TObject class TPaf_record : public TObject
@ -100,7 +102,7 @@ protected:
bool parse_sconto(const TString& formula, TToken_string& sconti) const; bool parse_sconto(const TString& formula, TToken_string& sconti) const;
static bool get_bnp_iban(const TString& abi, const TString& cab, int prg, TString& iban); static bool get_bnp_iban(const TString& abi, const TString& cab, int prg, TString& iban);
bool get_bank(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const; bool get_bank(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const;
const char* descrizione(const TRiga_documento& rdoc) const; const TString& descrizione(const TRiga_documento& rdoc) const;
const TRectype& cco(const TRectype& doc) const; // Contratto/Convenzione/Offerta const TRectype& cco(const TRectype& doc) const; // Contratto/Convenzione/Offerta
void log(int severity, const char* msg); void log(int severity, const char* msg);

View File

@ -1269,7 +1269,7 @@ CREATE TABLE PAF3000F (
PT_KEYHEADERFATT CHAR(20) NOT NULL DEFAULT '' , PT_KEYHEADERFATT CHAR(20) NOT NULL DEFAULT '' ,
PT_KEYBODYFATT CHAR(50) NOT NULL DEFAULT '' , PT_KEYBODYFATT CHAR(50) NOT NULL DEFAULT '' ,
PT_RIFNUMLINEA NUMERIC(4, 0) NOT NULL DEFAULT 0 , PT_RIFNUMLINEA NUMERIC(4, 0) NOT NULL DEFAULT 0 ,
PT_COMMENTO VARCHAR NOT NULL DEFAULT '' , PT_COMMENTO VARCHAR(1000) NOT NULL DEFAULT '' ,
PT_GESTIONE CHAR(1) NOT NULL DEFAULT '' ) ; PT_GESTIONE CHAR(1) NOT NULL DEFAULT '' ) ;
ALTER TABLE PAF3000F ALTER TABLE PAF3000F
@ -1754,7 +1754,7 @@ CREATE INDEX PAF2800F_KEY
CREATE INDEX PAF2900F_KEY CREATE INDEX PAF2900F_KEY
ON PAF2900F (PS_KEYPRGINVIO ASC , PS_KEYHEADERFATT ASC , PS_KEYBODYFATT ASC ) ON PAF2900F (PS_KEYPRGINVIO ASC , PS_KEYHEADERFATT ASC , PS_KEYBODYFATT ASC )
; ;
CREATE INDEX PAF3100F_KEY CREATE INDEX PAF3100F_KEY
ON PAF3100F (PH_KEYPRGINVIO ASC , PH_KEYHEADERFATT ASC , PH_KEYBODYFATT ASC ) ON PAF3100F (PH_KEYPRGINVIO ASC , PH_KEYHEADERFATT ASC , PH_KEYBODYFATT ASC )
; ;

View File

@ -83,4 +83,9 @@ ALTER TABLE PAFW300F ADD CONSTRAINT PAFW300F_TLLNNAPRV1 DEFAULT '19700101 00:00:
UPDATE PAFW300F SET PW_UPAG = '19700101 00:00:00' WHERE PW_UPAG IS NULL; UPDATE PAFW300F SET PW_UPAG = '19700101 00:00:00' WHERE PW_UPAG IS NULL;
ALTER TABLE PAFW300F ALTER COLUMN PW_UPAG DATETIME NOT NULL; ALTER TABLE PAFW300F ALTER COLUMN PW_UPAG DATETIME NOT NULL;
-- TLLNNAPRV -> Tolla non approva -- TLLNNAPRV -> Tolla non approva
-- Aggiungo chiave mancante
CREATE INDEX PAF3000F_KEY
ON PAF3000F ( PT_KEYPRGINVIO ASC, PT_KEYHEADERFATT ASC, PT_KEYBODYFATT ASC, PT_RIFNUMLINEA ASC) ;

View File

@ -2055,7 +2055,7 @@ void TParagraph_string::tokenize()
TToken_string& get_tmp_string(int len) TToken_string& get_tmp_string(int len)
{ {
static TString_array ararar(128); static TString_array ararar(1024);
static int next = 0; static int next = 0;
TToken_string* str = (TToken_string*)ararar.objptr(next); TToken_string* str = (TToken_string*)ararar.objptr(next);