Patch level : 12.0 1098
Files correlati : fp0.exe Commento : corretta esportazione partite IVA europee che iniziano con 8 o 9
This commit is contained in:
parent
c7d5a79111
commit
ddefbd0c94
@ -83,9 +83,9 @@ public:
|
||||
|
||||
|
||||
TString& insert_string();
|
||||
TString& update_string();
|
||||
TString& filter_string();
|
||||
bool update();
|
||||
// TString& update_string();
|
||||
// TString& filter_string();
|
||||
// bool update();
|
||||
bool insert();
|
||||
TString& remove_string(bool id_riga = false);
|
||||
bool remove();
|
||||
|
@ -466,7 +466,7 @@ bool TPaf_record::remove()
|
||||
return ok;
|
||||
}
|
||||
// Carica un record in base ai campi chiave
|
||||
bool TPaf_record::search()
|
||||
/*bool TPaf_record::search()
|
||||
{
|
||||
CHECKS(_fields.items() > 0, "Can't search with empty key on table ", static_cast<const char*>(_table));
|
||||
|
||||
@ -589,7 +589,70 @@ bool TPaf_record::update()
|
||||
{
|
||||
return fp_db().sq_set_exec(update_string(), false);
|
||||
}
|
||||
*/
|
||||
|
||||
bool TPaf_record::search()
|
||||
{
|
||||
CHECKS(_fields.items() > 0, "Can't search with empty key on table ", static_cast<const char*>(_table));
|
||||
TString256 query;
|
||||
query << "SELECT TOP 1 * FROM " << _table << " WHERE ";
|
||||
FOR_EACH_TOKEN(_key, fld)
|
||||
{
|
||||
const TVariant& var = get(fld);
|
||||
if (!var.is_null())
|
||||
query << fld << '=' << var2str(fld, var) << " AND ";
|
||||
}
|
||||
query.rtrim(5);
|
||||
query << " ORDER BY ";
|
||||
FOR_EACH_TOKEN(_key, fld)
|
||||
{
|
||||
const TVariant& var = get(fld);
|
||||
if (!var.is_null())
|
||||
query << fld << ", ";
|
||||
}
|
||||
query.rtrim(2) << " DESC;";
|
||||
// return xvt_sql_execute(_db, query, paf_search_record, this) == 1;
|
||||
// TODO: Valutare
|
||||
return fp_db().sq_set_exec(query);
|
||||
}
|
||||
|
||||
// Carica un record in base ad un massimo di 3 campi chiave
|
||||
bool TPaf_record::search(const char* k1, const char* k2, const char* k3)
|
||||
{
|
||||
_fields.destroy();
|
||||
set(_key.get(0), k1);
|
||||
set(_key.get(1), k2);
|
||||
if (k3 && *k3)
|
||||
set(_key.get(2), k3);
|
||||
return search();
|
||||
}
|
||||
|
||||
TString & TPaf_record::insert_string()
|
||||
{
|
||||
CHECKS(_fields.items() >= _key.items(), "Can't insert empty record on table ", _table);
|
||||
static TString query, values;
|
||||
query.cut(0); values.cut(0);
|
||||
query << "INSERT INTO " << _table << "\n(";
|
||||
FOR_EACH_ASSOC_OBJECT(_fields, obj, fld, itm)
|
||||
{
|
||||
const TVariant& var = get(fld);
|
||||
if (!var.is_null())
|
||||
{
|
||||
query << fld << ',';
|
||||
values << var2str(fld, var) << ',';
|
||||
}
|
||||
}
|
||||
query.rtrim(1);
|
||||
values.rtrim(1);
|
||||
query << ")\nVALUES (" << values << ");";
|
||||
return query;
|
||||
}
|
||||
|
||||
// Aggiunge un record al db
|
||||
bool TPaf_record::insert()
|
||||
{
|
||||
return fp_db().sq_set_exec(insert_string(), false);
|
||||
}
|
||||
// Crea un record della tabella data ed imposta i nomi dei campi chiave
|
||||
TPaf_record::TPaf_record(const char* table) : _table(table), _key(15, ',')
|
||||
{
|
||||
@ -1670,23 +1733,28 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
|
||||
TString stato = cliente.stato_partita_IVA();
|
||||
TTable tab_codiso("%SCE");
|
||||
tab_codiso.tab();
|
||||
|
||||
tab_codiso.put("CODTAB", stato); tab_codiso.read();
|
||||
TString piva = cliente.partita_IVA(),
|
||||
fisc = cliente.codice_fiscale();
|
||||
|
||||
fisc = cliente.codice_fiscale();
|
||||
if (!stato.full())
|
||||
stato = "IT";
|
||||
if (tab_codiso.get_bool("B0") || stato == "IT") // Cliente EU
|
||||
if (tab_codiso.get_bool("B0") || stato == "IT") // Cliente EU
|
||||
{
|
||||
if (piva.full())
|
||||
if (stato == "IT")
|
||||
{
|
||||
if (piva.len() == 11 && (piva[0] == '8' || piva[0] == '9'))
|
||||
if (piva.full())
|
||||
{
|
||||
fisc = piva;
|
||||
piva.cut(0);
|
||||
if (piva.len() == 11 && (piva[0] == '8' || piva[0] == '9'))
|
||||
{
|
||||
fisc = piva;
|
||||
piva.cut(0);
|
||||
}
|
||||
}
|
||||
else if (fisc.full() && fisc.len() == 11 && (fisc[0] == '8' || fisc[0] == '9'))
|
||||
piva.cut(0);
|
||||
}
|
||||
else if (fisc.full() && fisc.len() == 11 && (fisc[0] == '8' || fisc[0] == '9'))
|
||||
piva.cut(0);
|
||||
|
||||
if (piva.full())
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user