Patch level : 12.0 790
Files correlati : fp0400, f1lib Commento : - Aggiunto log per stato contabilizzazione (salvate/annullate) - Corretta esportazione importi negativi
This commit is contained in:
parent
952eeb374f
commit
9cdaf56763
@ -6,6 +6,7 @@
|
|||||||
#include "execp.h"
|
#include "execp.h"
|
||||||
#include "cfven.h"
|
#include "cfven.h"
|
||||||
#include "../fp/fp0400a.h"
|
#include "../fp/fp0400a.h"
|
||||||
|
#include "reputils.h"
|
||||||
|
|
||||||
TString& TProtocollo::prot_in(const int year, const char* tipoprot, const char* progres)
|
TString& TProtocollo::prot_in(const int year, const char* tipoprot, const char* progres)
|
||||||
{
|
{
|
||||||
@ -139,3 +140,41 @@ void run_cont_ini()
|
|||||||
#endif
|
#endif
|
||||||
TExternal_app(run_string).run();
|
TExternal_app(run_string).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TF1_log::log(int severity, const char* msg)
|
||||||
|
{
|
||||||
|
if (_log == nullptr)
|
||||||
|
{
|
||||||
|
_log = new TLog_report("Stato contabilizzazione:");
|
||||||
|
// Tento l'eliminazione del file
|
||||||
|
std::remove("f1_cg.log");
|
||||||
|
}
|
||||||
|
|
||||||
|
static TString txt;
|
||||||
|
txt.cut(0);
|
||||||
|
if (severity == LOG_MSG)
|
||||||
|
txt << "[message] : ";
|
||||||
|
else if(severity == LOG_WARN)
|
||||||
|
txt << "[warning] : ";
|
||||||
|
else if (severity == LOG_ERR)
|
||||||
|
txt << "[error] : ";
|
||||||
|
txt << msg;
|
||||||
|
_log->log(severity, txt);
|
||||||
|
// Scrivo anche su file
|
||||||
|
std::filebuf fb;
|
||||||
|
fb.open("f1_cg.log", std::ios::out | std::ios::app);
|
||||||
|
std::ostream os(&fb);
|
||||||
|
os << txt << std::endl;
|
||||||
|
fb.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
bool TF1_log::show_log()
|
||||||
|
{
|
||||||
|
if (_log)
|
||||||
|
{
|
||||||
|
_log->preview();
|
||||||
|
delete _log;
|
||||||
|
_log = NULL;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
@ -3,12 +3,17 @@
|
|||||||
|
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "report.h"
|
||||||
|
#include "reputils.h"
|
||||||
|
|
||||||
#define FILE_CONFIG CONFIG_DITTA
|
#define FILE_CONFIG CONFIG_DITTA
|
||||||
#define FILE_SECTION "f1"
|
#define FILE_SECTION "f1"
|
||||||
#define F1_CAUSFA "causfa"
|
#define F1_CAUSFA "causfa"
|
||||||
#define F1_CAUSNC "causnc"
|
#define F1_CAUSNC "causnc"
|
||||||
#define F1_INIREGCONT "cg2CONTAB"
|
#define F1_INIREGCONT "cg2CONTAB"
|
||||||
|
#define LOG_MSG 0
|
||||||
|
#define LOG_WARN 1
|
||||||
|
#define LOG_ERR 2
|
||||||
|
|
||||||
enum err_cont
|
enum err_cont
|
||||||
{
|
{
|
||||||
@ -41,6 +46,15 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TF1_log : TObject
|
||||||
|
{
|
||||||
|
TLog_report* _log;
|
||||||
|
public:
|
||||||
|
TF1_log() : _log(nullptr){}
|
||||||
|
void log(int severity, const char* msg);
|
||||||
|
bool show_log();
|
||||||
|
};
|
||||||
|
|
||||||
void set_ini_codcaus(const TString& codcaus, bool nc = false);
|
void set_ini_codcaus(const TString& codcaus, bool nc = false);
|
||||||
const char* get_ini_codcaus(bool nc = false);
|
const char* get_ini_codcaus(bool nc = false);
|
||||||
const char* get_codcaus(const char * tipodoc, const char* codcf);
|
const char* get_codcaus(const char * tipodoc, const char* codcf);
|
||||||
|
@ -33,7 +33,9 @@ enum { filtri = 0, elenco_fe = 1, elenco_err = 2 }; // Enum per bottoni toolbar
|
|||||||
|
|
||||||
class TPassive_mask : public TAutomask
|
class TPassive_mask : public TAutomask
|
||||||
{
|
{
|
||||||
|
TLog_report* _log;
|
||||||
bool _f1;
|
bool _f1;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool _filter_changed;
|
bool _filter_changed;
|
||||||
TFilename _tmp_dir;
|
TFilename _tmp_dir;
|
||||||
@ -59,6 +61,7 @@ protected:
|
|||||||
|
|
||||||
// Gestione F1
|
// Gestione F1
|
||||||
int prepara_contab() const;
|
int prepara_contab() const;
|
||||||
|
void log_contab();
|
||||||
void contabilizza();
|
void contabilizza();
|
||||||
TDate load_data() const;
|
TDate load_data() const;
|
||||||
// Handlers
|
// Handlers
|
||||||
@ -557,8 +560,7 @@ int TPassive_mask::prepara_contab() const
|
|||||||
contab_ini.set("DATADOC", row->get(sf.cid2index(S_DATADOC)));
|
contab_ini.set("DATADOC", row->get(sf.cid2index(S_DATADOC)));
|
||||||
contab_ini.set("NUMDOCEXT", row->get(sf.cid2index(S_NDOC)));
|
contab_ini.set("NUMDOCEXT", row->get(sf.cid2index(S_NDOC)));
|
||||||
contab_ini.set("NUMDOC", TString(row->get(sf.cid2index(S_NDOC))).right(7));
|
contab_ini.set("NUMDOC", TString(row->get(sf.cid2index(S_NDOC))).right(7));
|
||||||
contab_ini.set("TOTDOC", row->get(sf.cid2index(S_TOTDOC)));
|
contab_ini.set("TOTDOC", abs(real(row->get(sf.cid2index(S_TOTDOC)))).string());
|
||||||
contab_ini.set("PROGFPPRO", row->get(sf.cid2index(S_NPROT)));
|
|
||||||
contab_ini.set("KEYFPPRO", row->get(sf.cid2index(S_PROKEY)));
|
contab_ini.set("KEYFPPRO", row->get(sf.cid2index(S_PROKEY)));
|
||||||
|
|
||||||
row->add("", 0);
|
row->add("", 0);
|
||||||
@ -574,6 +576,65 @@ int TPassive_mask::prepara_contab() const
|
|||||||
return is_ready;
|
return is_ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TPassive_mask::log_contab()
|
||||||
|
{
|
||||||
|
TFilename cg_ini;
|
||||||
|
TString msg;
|
||||||
|
TF1_log log;
|
||||||
|
std::vector<TString> doc_saved, doc_canceled;
|
||||||
|
FOR_EACH_SHEET_ROW(sfield(F_DOCS), n, row)
|
||||||
|
{
|
||||||
|
TString num; num.format("%04d", n);
|
||||||
|
#ifdef DBG
|
||||||
|
cg_ini = TString(F1_INIREGCONT) << num << ".ini";
|
||||||
|
#else
|
||||||
|
cg_ini = TFilename().tempdir() << "\\" << TString(F1_INIREGCONT) << num << ".ini";
|
||||||
|
#endif
|
||||||
|
if(cg_ini.exist())
|
||||||
|
{
|
||||||
|
TConfig config(cg_ini, "Transaction");
|
||||||
|
TString numdoc;
|
||||||
|
if (config.get("Result") == "OK")
|
||||||
|
{
|
||||||
|
numdoc = config.get("NUMDOC", "23");
|
||||||
|
doc_saved.insert(doc_saved.end(), numdoc);
|
||||||
|
}
|
||||||
|
else if(config.get("Result") == "CANCEL")
|
||||||
|
{
|
||||||
|
numdoc = config.get("NUMDOC", "23");
|
||||||
|
doc_canceled.insert(doc_canceled.end(), numdoc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const int elem_save = doc_saved.size();
|
||||||
|
const int elem_canc = doc_canceled.size();
|
||||||
|
if (elem_save > 0)
|
||||||
|
{
|
||||||
|
if (elem_save == 1)
|
||||||
|
msg << "Il documento n. '" << doc_saved[0] << "' e' stata registrato.";
|
||||||
|
else
|
||||||
|
msg << "Sono stati registrati " << elem_save << " documenti.";
|
||||||
|
if (elem_save > 1)
|
||||||
|
for (int i = 0; i < elem_save; i++)
|
||||||
|
msg << "\n - Documento n. '" << doc_saved[i] << "'";
|
||||||
|
log.log(LOG_MSG, msg);
|
||||||
|
}
|
||||||
|
if (elem_canc > 0)
|
||||||
|
{
|
||||||
|
msg.cut(0);
|
||||||
|
if (elem_canc == 1)
|
||||||
|
msg << "La registrazione del documento n. '" << doc_canceled[0] << "' e' stata annullata.";
|
||||||
|
else
|
||||||
|
msg << "Sono state annullate " << elem_canc << " registrazioni.";
|
||||||
|
if (elem_canc > 1)
|
||||||
|
for (int i = 0; i < elem_canc; i++)
|
||||||
|
msg << "\n - Documento n. '" << doc_canceled[i] << "'";
|
||||||
|
log.log(LOG_WARN, msg);
|
||||||
|
}
|
||||||
|
if (elem_save > 0 || elem_canc > 0)
|
||||||
|
log.show_log();
|
||||||
|
}
|
||||||
|
|
||||||
void TPassive_mask::contabilizza()
|
void TPassive_mask::contabilizza()
|
||||||
{
|
{
|
||||||
const int stato = prepara_contab();
|
const int stato = prepara_contab();
|
||||||
@ -582,6 +643,8 @@ void TPassive_mask::contabilizza()
|
|||||||
{
|
{
|
||||||
case is_ready:
|
case is_ready:
|
||||||
run_cont_ini(); // Eseguo gli ini
|
run_cont_ini(); // Eseguo gli ini
|
||||||
|
log_contab(); // Mostro stato contabilizzate/annullate
|
||||||
|
clean_ini(F1_INIREGCONT);
|
||||||
fill(); // Ricarico sheet per togliere quelli contabilizzati
|
fill(); // Ricarico sheet per togliere quelli contabilizzati
|
||||||
break;
|
break;
|
||||||
case no_codcaus:
|
case no_codcaus:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user