Patch level : 12.0 no-patch
Files correlati : fp0 Commento : - Aggiunti altri file in apertura per invio fatturazione elettronica - Divisa funzione extract_info per read e search - Aggiunta possibilità di selezionare la chiave durante la search - Aggiunte tabelle %NUM e %CPG nella read
This commit is contained in:
parent
1f21b6b70e
commit
3ffa118088
@ -743,14 +743,13 @@ bool TDoc2Paf::create()
|
|||||||
{
|
{
|
||||||
open_files(LF_TAB, LF_TABCOM, LF_TABMOD, LF_ANAG,
|
open_files(LF_TAB, LF_TABCOM, LF_TABMOD, LF_ANAG,
|
||||||
LF_CLIFO, LF_CFVEN, LF_CFBAN, LF_NDITTE,
|
LF_CLIFO, LF_CFVEN, LF_CFBAN, LF_NDITTE,
|
||||||
LF_DOC, LF_RIGHEDOC, 0);
|
LF_DOC, LF_RIGHEDOC, LF_CODCORR, LF_ANAMAG, 0);
|
||||||
|
|
||||||
TRectype cfven(LF_CFVEN);
|
const TRectype cfven(LF_CFVEN);
|
||||||
if (cfven.length(CFV_PADESTIN) != 7) // Nuova lunghezza per privati
|
if (cfven.length(CFV_PADESTIN) != 7) // Nuova lunghezza per privati
|
||||||
return error_box(TR("Database non convertito per fatturazione F.P."));
|
return error_box(TR("Database non convertito per fatturazione F.P."));
|
||||||
|
|
||||||
return check_tables() && TSkeleton_application::create();
|
return check_tables() && TSkeleton_application::create();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDoc2Paf::destroy()
|
bool TDoc2Paf::destroy()
|
||||||
|
@ -389,7 +389,8 @@ private:
|
|||||||
enum TFP_operator { error, eq, neq, gt, ls, gteq, lseq, and, or };
|
enum TFP_operator { error, eq, neq, gt, ls, gteq, lseq, and, or };
|
||||||
|
|
||||||
// Etrattori
|
// Etrattori
|
||||||
static void extract_info(const TString& expr, TString& tabella, TString& campo, TToken_string* search);
|
static void extract_info(const TString& expr, TString& tabella, TString& campo);
|
||||||
|
static void extract_info(const TString& expr, TString& tabella, TString& campo, TToken_string& search, int& key);
|
||||||
static bool calc_table(const TString& tabella, int& file);
|
static bool calc_table(const TString& tabella, int& file);
|
||||||
static void split_condition(const TString& cond, TString& cond_sx, TString& cond_dx, TFP_operator& symb);
|
static void split_condition(const TString& cond, TString& cond_sx, TString& cond_dx, TFP_operator& symb);
|
||||||
static TVariant& get_value(const TRectype& rec, const TString& campo);
|
static TVariant& get_value(const TRectype& rec, const TString& campo);
|
||||||
|
@ -51,6 +51,7 @@ bool set_connection(SSimple_query& s)
|
|||||||
#endif
|
#endif
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSimple_query& fp_db()
|
SSimple_query& fp_db()
|
||||||
{
|
{
|
||||||
static SSimple_query* db = nullptr;
|
static SSimple_query* db = nullptr;
|
||||||
@ -63,6 +64,7 @@ SSimple_query& fp_db()
|
|||||||
}
|
}
|
||||||
return *db;
|
return *db;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool run_fp_psw_mask()
|
bool run_fp_psw_mask()
|
||||||
{
|
{
|
||||||
static TMask* m;
|
static TMask* m;
|
||||||
|
@ -255,8 +255,6 @@ TFP_custom_cache::TFP_custom_cache()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TFP_expression
|
* TFP_expression
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -364,7 +362,7 @@ bool TFP_expression::check_condition(const TString& cond, TRiga_documento& rdoc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFP_expression::extract_info(const TString& expr, TString& tabella, TString& campo, TToken_string* search)
|
void TFP_expression::extract_info(const TString& expr, TString& tabella, TString& campo)
|
||||||
{
|
{
|
||||||
// Prendo la stringa pulita della parte sinistra
|
// Prendo la stringa pulita della parte sinistra
|
||||||
TString clean_expr = expr.mid(expr.find('(') + 1);
|
TString clean_expr = expr.mid(expr.find('(') + 1);
|
||||||
@ -377,13 +375,38 @@ void TFP_expression::extract_info(const TString& expr, TString& tabella, TString
|
|||||||
// Trimmare sempre come se non sapessi fare altro nella vita
|
// Trimmare sempre come se non sapessi fare altro nella vita
|
||||||
tabella.cut(0) << info.remove(0); tabella.trim();
|
tabella.cut(0) << info.remove(0); tabella.trim();
|
||||||
campo.cut(0) << info.remove(0); campo.trim();
|
campo.cut(0) << info.remove(0); campo.trim();
|
||||||
if (search != nullptr)
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TFP_expression::extract_info(const TString& expr, TString& tabella, TString& campo, TToken_string& search, int& key)
|
||||||
|
{
|
||||||
|
// Prendo la stringa pulita della parte sinistra
|
||||||
|
TString clean_expr = expr.mid(expr.find('(') + 1);
|
||||||
|
// Tolgo eventuali spazi ai lati
|
||||||
|
clean_expr.trim();
|
||||||
|
// Tolgo la virgola finale
|
||||||
|
clean_expr.rtrim(1);
|
||||||
|
TToken_string info(clean_expr, ',');
|
||||||
|
|
||||||
|
// Trimmare sempre come se non sapessi fare altro nella vita
|
||||||
|
tabella.cut(0) << info.remove(0); tabella.trim();
|
||||||
|
if(tabella.contains('.'))
|
||||||
{
|
{
|
||||||
// Prendo il resto
|
TToken_string app(tabella, '.');
|
||||||
search->cut(0) << info;
|
tabella = app.get();
|
||||||
search->trim();
|
key = atoi(app.get());
|
||||||
search->restart();
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
key = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
campo.cut(0) << info.remove(0); campo.trim();
|
||||||
|
|
||||||
|
// Prendo il resto e lo devolvo nella ricerca
|
||||||
|
search.cut(0) << info;
|
||||||
|
search.trim();
|
||||||
|
search.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TFP_expression::calc_table(const TString& tabella, int& file)
|
bool TFP_expression::calc_table(const TString& tabella, int& file)
|
||||||
@ -549,17 +572,26 @@ TVariant& TFP_expression::parse_var(const TString& str)
|
|||||||
TVariant& TFP_expression::parse_read(const TString& str, TRiga_documento& rdoc)
|
TVariant& TFP_expression::parse_read(const TString& str, TRiga_documento& rdoc)
|
||||||
{
|
{
|
||||||
TString tabella, campo;
|
TString tabella, campo;
|
||||||
extract_info(str, tabella, campo, nullptr);
|
extract_info(str, tabella, campo);
|
||||||
return do_read(tabella, campo, rdoc);
|
return do_read(tabella, campo, rdoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
TVariant& TFP_expression::do_read(const TString& tabella, const TString& campo, TRiga_documento& rdoc)
|
TVariant& TFP_expression::do_read(const TString& tabella, const TString& campo, TRiga_documento& rdoc)
|
||||||
{
|
{
|
||||||
|
const TDocumento& doc = rdoc.doc();
|
||||||
// Prima di tutto controllo se è una delle tabelle multitracciato che supporto
|
// Prima di tutto controllo se è una delle tabelle multitracciato che supporto
|
||||||
if(tabella == "%TIP")
|
if(tabella == "%TIP")
|
||||||
{
|
{
|
||||||
return get_value(rdoc.doc().tipo(), campo);
|
return get_value(doc.tipo(), campo);
|
||||||
|
}
|
||||||
|
if(tabella == "%NUM")
|
||||||
|
{
|
||||||
|
return get_value(doc.codice_numerazione(), campo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tabella == "%CPG")
|
||||||
|
{
|
||||||
|
return get_value(cache().get("%CPG", doc.get(DOC_CODPAG)), campo);
|
||||||
}
|
}
|
||||||
|
|
||||||
int file;
|
int file;
|
||||||
@ -568,17 +600,19 @@ TVariant& TFP_expression::do_read(const TString& tabella, const TString& campo,
|
|||||||
switch (file)
|
switch (file)
|
||||||
{
|
{
|
||||||
case LF_DOC:
|
case LF_DOC:
|
||||||
return get_value(rdoc.doc(), campo);
|
return get_value(doc, campo);
|
||||||
case LF_RIGHEDOC:
|
case LF_RIGHEDOC:
|
||||||
return get_value(rdoc, campo);
|
return get_value(rdoc, campo);
|
||||||
case LF_CLIFO:
|
case LF_CLIFO:
|
||||||
return get_value(rdoc.doc().clifor(), campo);
|
return get_value(doc.clifor(), campo);
|
||||||
case LF_CFVEN:
|
case LF_CFVEN:
|
||||||
return get_value(rdoc.doc().clifor().vendite(), campo);
|
return get_value(doc.clifor().vendite(), campo);
|
||||||
case LF_LETINT:
|
case LF_LETINT:
|
||||||
return get_value(rdoc.doc().clifor().lettera(), campo);
|
return get_value(doc.clifor().lettera(), campo);
|
||||||
case LF_ANAMAG:
|
case LF_ANAMAG:
|
||||||
return get_value(rdoc.articolo(), campo);
|
return get_value(rdoc.articolo(), campo);
|
||||||
|
case LF_CODCORR:
|
||||||
|
return get_value(cache().get(LF_CODCORR, rdoc.articolo().codice()), campo);
|
||||||
default:
|
default:
|
||||||
static TVariant null_var(EMPTY_STRING);
|
static TVariant null_var(EMPTY_STRING);
|
||||||
return null_var;
|
return null_var;
|
||||||
@ -588,10 +622,10 @@ TVariant& TFP_expression::do_read(const TString& tabella, const TString& campo,
|
|||||||
TVariant& TFP_expression::parse_search(const TString& str, TRiga_documento& rdoc)
|
TVariant& TFP_expression::parse_search(const TString& str, TRiga_documento& rdoc)
|
||||||
{
|
{
|
||||||
TString tabella, campo;
|
TString tabella, campo;
|
||||||
TToken_string input_search, search;
|
TToken_string input_search("", ';'), search;
|
||||||
int file;
|
int file, key;
|
||||||
|
|
||||||
extract_info(str, tabella, campo, &input_search);
|
extract_info(str, tabella, campo, input_search, key);
|
||||||
const bool multi_table = calc_table(tabella, file);
|
const bool multi_table = calc_table(tabella, file);
|
||||||
|
|
||||||
// Parso ogni singolo token della ricerca
|
// Parso ogni singolo token della ricerca
|
||||||
@ -602,10 +636,10 @@ TVariant& TFP_expression::parse_search(const TString& str, TRiga_documento& rdoc
|
|||||||
|
|
||||||
if (multi_table)
|
if (multi_table)
|
||||||
{
|
{
|
||||||
return get_value(cache().get(tabella, search), campo);
|
return get_value(cache().get(tabella, search, key), campo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return get_value(cache().get(file, search), campo);
|
return get_value(cache().get(file, search, key), campo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user