Patch level : 12.0 682

Files correlati     : fp
Commento            :
- Sistemato errore in caricamento
- Aggiunta gestione fatture perse nel nulla
- Limitata dimensione descrizione fatture a 1000 caratteri (specifiche SDI)
- Tolti reference nella insert_string e messe variabili static per evitare sforamento in caso di descrizioni lunghe (PAF3000F)
This commit is contained in:
Mattia Tollari 2019-01-25 14:47:19 +01:00
parent 890cfff6c4
commit 9c1396fc7b
5 changed files with 62 additions and 22 deletions

View File

@ -30,6 +30,7 @@ protected:
enum {_codnum, _tipodoc, _dastato, _astato, _tiposdi};
void set_filter_changed();
void set_pronto();
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
void next_page(int p);
bool check_not_empty();
@ -48,6 +49,8 @@ public:
TPA_mask() : TAutomask("fp0300a"), _filter_changed(true)
{
disable(DLG_OK);
disable(DLG_SAVEREC);
disable(DLG_FINDREC);
load_all_fields();
}
void save_all_fields() const;
@ -168,9 +171,11 @@ void TPA_mask::fill()
#ifdef DBG
enable(DLG_OK);
enable(DLG_SAVEREC);
enable(DLG_FINDREC);
#else
enable(DLG_OK, filter_selected != "X");
enable(DLG_OK, filter_selected != "X" && filter_selected != "P");
enable(DLG_SAVEREC, fp_settings().is_f8() && filter_selected == "X");
enable(DLG_FINDREC, filter_selected != "P")
#endif
// Record di controllo per eventuali elaborazioni precedenti
@ -289,6 +294,14 @@ void TPA_mask::set_filter_changed()
_filter_changed = true;
}
void TPA_mask::set_pronto()
{
if(fp_db().sq_set_exec("UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_GESTIONE = 'D'") && fp_db().sq_commit())
{
message_box("Fatture esportate!");
}
}
bool TPA_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
switch (o.dlg())
@ -349,6 +362,11 @@ bool TPA_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
set_err_paf();
}
break;
case DLG_FINDREC:
{
if (e == fe_button)
set_pronto();
}
default: break;
}
if((e == fe_modify || e >= se_enter) && jolly == 0)
@ -546,12 +564,9 @@ void TDoc2Paf::main_loop()
}
}
}
if (ndocs > 0)
{
if (elab.commit() <= 0)
error_box("Errore durante il salvataggio");
elab.show_log();
}
if (elab.force_commit() <= 0)
error_box("Errore durante il cambiamento di stato finale, potrebbero esser rimaste delle fatture in Pronto");
elab.show_log();
}
}

View File

@ -22,6 +22,13 @@ BEGIN
FLAGS "D"
END
BUTTON DLG_FINDREC 2 2
BEGIN
PROMPT 1 1 "Segna pronto"
PICTURE TOOL_PERMISSIONS
FLAGS "D"
END
#include <helpbar.h>
ENDPAGE
@ -49,6 +56,7 @@ BEGIN
ITEM "X|XML Generato"
ITEM "N|Notificato"
ITEM "E|In errore"
ITEM "D|Pronto"
FLAGS "Z"
END

View File

@ -122,7 +122,7 @@ protected:
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);
bool get_bank(const TDocumento& doc, TString& iban, TString& abi, TString& cab, TString& istituto) const;
const TString& descrizione(const TRiga_documento& rdoc) const;
const TString& descrizione(const TRiga_documento& rdoc);
const TRectype& cco(const TRectype& doc) const; // Contratto/Convenzione/Offerta
void log(int severity, const char* msg);
@ -144,6 +144,7 @@ public:
// Mostra il log a fine esecuzione
bool show_log();
const int commit();
const int force_commit();
void set_cache_insert(const bool v) { _cache_insert = v; }

View File

@ -454,7 +454,9 @@ TString & TPaf_record::insert_string()
{
CHECKS(_fields.items() >= _key.items(), "Can't insert empty record on table ", _table);
TString& query = get_tmp_string().cut(0), values = get_tmp_string().cut(0);
static TString query, values;
query.cut(0); values.cut(0);
query << "INSERT INTO " << _table << "\n(";
FOR_EACH_ASSOC_OBJECT(_fields, obj, fld, itm)
{
@ -623,18 +625,24 @@ bool TDoc_fp::get_bank(const TDocumento& doc, TString& iban, TString& abi, TStri
return found;
}
const TString& TDoc_fp::descrizione(const TRiga_documento& rdoc) const
const TString& TDoc_fp::descrizione(const TRiga_documento& rdoc)
{
if (rdoc.get_bool(RDOC_DESCLUNGA))
if (rdoc.get_bool(RDOC_DESCLUNGA))
{
TString& tmp = get_tmp_string();
tmp << rdoc.get(RDOC_DESCR) << rdoc.get(RDOC_DESCEST);
tmp.replace('\n', ' ');
tmp.strip_double_spaces();
tmp.trim();
if(tmp.len() > 1000)
{
TString& tmp = get_tmp_string();
tmp << rdoc.get(RDOC_DESCR) << rdoc.get(RDOC_DESCEST);
tmp.replace('\n', ' ');
tmp.strip_double_spaces();
tmp.trim();
return tmp;
TString err;
err << "Il documento " << rdoc.doc().anno() << " " << rdoc.doc().codice_numerazione().codice() << " " << rdoc.doc().numero() << " ha la riga numero " << rdoc.numero() << " più lunga di quanto supportato dal formato dell'agenzia delle entrate, verrà troncata a 1000 caratteri";
log(1, err);
}
return rdoc.get(RDOC_DESCR);
return tmp.left(1000);
}
return rdoc.get(RDOC_DESCR);
}
const TRectype* TDoc_fp::find_parent_row(const TRectype& rdoc) const
@ -817,6 +825,12 @@ const int TDoc_fp::commit()
return r;
}
const int TDoc_fp::force_commit()
{
_to_commit = true;
return commit();
}
const char* TDoc_fp::natura(const TString& codiva) const
{
@ -1312,7 +1326,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
if(piva.empty() && codfisc.empty())
{
TString msg = "Il vettore ";
msg << vet.get("S0").mid(0, 50) << " non ha nè codice fiscale nè partita IVA, la fattura " << doc.anno() << " " << doc.codice_numerazione() << " " << doc.numero() << " non può essere trasmessa";
msg << vet.get("S0").mid(0, 50) << " non ha nè codice fiscale nè partita IVA, la fattura " << doc.anno() << " " << doc.codice_numerazione().codice() << " " << doc.numero() << " non può essere trasmessa";
log(3, msg);
return false;
}
@ -1379,14 +1393,16 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
paf1800f.set("PI_KEYBODYFATT", _bfatt);
paf1800f.set("PI_NUMEROLINEA", ++riga);
if (descrizione(*rdoc).empty())
const TString& descrizione_riga = descrizione(*rdoc);
if (descrizione_riga.empty())
continue;
paf3000f.reset();
paf3000f.set("PT_KEYHEADERFATT", _hfatt);
paf3000f.set("PT_KEYBODYFATT", _bfatt);
paf3000f.set("PT_RIFNUMLINEA", riga);
paf3000f.set("PT_COMMENTO", descrizione(*rdoc));
paf3000f.set("PT_COMMENTO", descrizione_riga);
// <CodiceArticolo>
if (rdoc->is_articolo())

View File

@ -182,7 +182,7 @@ void TFP_selected_docs::fill_sheet(TSheet_field& sheet) const
row.add(rec.get(FP_SLD_TIPODOC));
row.add(rec.get(FP_SLD_DASTATO));
row.add(rec.get(FP_SLD_ASTATO));
row.add(TTipo_documento(TString() << rec.get("S0") << "|" << rec.get("S1")).tipo_doc_sdi());
row.add(TTipo_documento(rec.get(FP_SLD_TIPODOC)).tipo_doc_sdi());
}
}