Patch level : 12.0 894

Files correlati     : f90.exe f90100a.msk f90100d.msk
Commento            :
- Aggiunto monitor movimenti estratti per pacchetto
- Aggiornamento tabelle: aggiunte colonne che non esistevano inizialmente
- Corretta esecuzione query per aggiornamenti tabelle
- Aggiunto stampa su file di log
This commit is contained in:
Simone Palacino 2019-10-24 17:11:19 +02:00
parent cad79a9303
commit cc1030577f
7 changed files with 427 additions and 42 deletions

View File

@ -9,21 +9,22 @@
#include "progind.h"
#include "f90100.h"
#include "f901tab.h"
#include "f90100c.h"
#include "f90100b.h"
#include "f90100c.h"
#include "f90100d.h"
#include "sqlset.h"
/*
* - Per aggiornare le tabelle f9 aggiungere nella cartella "sql\f9\" il file sql cosi' fatto:
/** \file f90100.cpp
* Per aggiornare le tabelle f9 aggiungere nella cartella "sql\f9\" il file sql cosi' fatto:
* f9xxxx.sql dove xxxx e' il numero zero-filled della versione delle tabelle, che INCREMENTA DI DUE COME CON LE PATCH, IMPORTANTE!
* - Aggiornare la definizione qui sotto di SQL_VERSION mettendo la nuova versione.
* - Fare patch del file sql e dell'eseguibile f90.exe
* - Lanciare il programma per eseguire l'aggiornamento.
* Aggiornare la definizione qui sotto di SQL_VERSION mettendo la nuova versione.
* Fare patch del file sql e dell'eseguibile f90.exe.
* Lanciare il programma per eseguire l'aggiornamento.
*/
#define TABMOD_TABVER "S0" // Campo per la memorizzazione della versione attuale delle tabelle
#define TAB_BASE_VERSION 100 // Versione base delle tabelle
#define SQL_VERSION 100 // Utilizzo questo per controllare la versione attuale delle tabelle e nel caso aggiornarle
#define SQL_VERSION 102 // Utilizzo questo per controllare la versione attuale delle tabelle e nel caso aggiornarle
SSimple_query& db()
{
@ -48,13 +49,28 @@ TMask** esclusi_mask()
m.set_handler(B_ESTRAI, TF9_app::estrai_escl_handler); // Bottone estrai
TMask& sheet_m = ((TSheet_field&)m.field(S_ESCL)).sheet_mask(); // Maschera dei campi dello sheet
sheet_m.set_handler(DLG_USER, TF9_app::mov_handler); // Bottone collega movimento
sheet_m.set_handler(DLG_USER, TF9_app::mov_handler_escl); // Bottone collega movimento
m.field(DLG_FINDREC).disable();
}
return &_esclusi_mask;
}
TMask** inclusi_mask()
{
static TMask* _inclusi_mask = nullptr;
if(_inclusi_mask == nullptr)
{
_inclusi_mask = new TMask("f90100d.msk");
TMask& m = *_inclusi_mask;
((TSheet_field&)m.field(S_ESCL)).set_notify(TF9_app::select_escl_notify); // Handler dello sheet per selezione singola
TMask& sheet_m = ((TSheet_field&)m.field(S_ESCL)).sheet_mask(); // Maschera dei campi dello sheet
sheet_m.set_handler(DLG_USER, TF9_app::mov_handler); // Bottone collega movimento
}
return &_inclusi_mask;
}
const char* check_str(const TString& str)
{
static TString n_str; n_str.cut(0) << str;
@ -108,6 +124,7 @@ bool TEstrai_mask::estrai_handler(TMask_field& f, KEY key)
if (stato == 0) // Errore scrittura F9IVA, non segno in errore ...
app().segna_in_errore(); // ...in testata se l'errore e' in scrittura dell'F9DRD
}
app().print_log();
msk.field(ES_DESCR).set("");
msk.stop_run(K_FORCE_CLOSE);
return true;
@ -336,6 +353,75 @@ void TMonitor_mask::sel() const
sf.show();
}
void TMonitor_mask::open_mostra_estrazione()
{
TMask& msk = **inclusi_mask();
//fill
TSheet_field& sf = msk.sfield(S_ESCL);
sf.destroy();
TString id;
TToken_string* _row = nullptr;
FOR_EACH_SHEET_ROW(sfield(S_ELAB), nr, row)
{
if (row->get(0)[0] == 'X')
{
_row = row;
id = row->get(cid2index(F_IDESTR));
break;
}
}
if(_row == nullptr)
{
message_box("Selezionare un pacchetto.");
return;
}
msk.set(F_IIDESTR, _row->get(cid2index(F_IDESTR)));
msk.set(F_IDATA, _row->get(cid2index(F_DATAESTR)));
msk.set(F_IPROV, _row->get(cid2index(F_PROV_B)));
msk.set(F_ITIPOD, _row->get(cid2index(F_TIPODOC)));
msk.set(F_IDAL, _row->get(cid2index(F_DATADAL)));
msk.set(F_IAL, _row->get(cid2index(F_DATAAL)));
TString query;
query << "SELECT " IVA_SEZIVA ", " IVA_DATADOC ", " IVA_NUMDOC ", " IVA_NPROT "\n"
"FROM " F9_IVA "\n"
"WHERE " IVA_IDLAN " = '" << id << "'";
//REG + DATAREG + PROTIVA + DATAINC + DATA74TER + NUMREG
TString sql;
TSQL_recordset rec("");
db().sq_set_exec(query, false);
for (bool ok = db().sq_next(); ok; ok = db().sq_next())
{
sql.cut(0) << "SELECT NUMREG, DATAREG, DATADOC, CODCAUS, TIPODOC, MESELIQ, NUMDOC, TOTDOC, CODCF, REG, PROTIVA, DESCR "
"FROM MOV "
"WHERE REG = '" << db().sq_get(IVA_SEZIVA) << "' AND DATADOC=" << TDate(db().sq_get_date(IVA_DATADOC)).date2ansi() <<
" AND PROTIVA = " << db().sq_get(IVA_NPROT);
rec.set(sql);
rec.move_first();
TToken_string& row = sf.row(-1);
row.add(" ", 0);
row.add(rec.get(rec.find_column(MOV_NUMREG)).as_string());
row.add(rec.get(1).as_string());
row.add(rec.get(2).as_string());
row.add(rec.get(3).as_string());
row.add(rec.get(4).as_string());
row.add(rec.get(5).as_string());
row.add(rec.get(6).as_string());
row.add(rec.get(7).as_string());
row.add(rec.get(8).as_string());
TLocalisamfile clifo(LF_CLIFO);
clifo.put(CLI_CODCF, rec.get(7).as_string());
clifo.put(CLI_TIPOCF, _row->get(cid2index(F_TIPODOC))[0] == 'A' ? "F" : "C");
clifo.read();
row.add(clifo.get(CLI_RAGSOC));
row.add(TString(rec.get(8).as_string()) << "/" << rec.get(9).as_string());
row.add(rec.get(10).as_string());
}
msk.run();
}
bool TMonitor_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
switch (o.dlg())
@ -361,6 +447,9 @@ bool TMonitor_mask::on_field_event(TOperable_field& o, TField_event e, long joll
break;
case DLG_RECALC:
fill();
break;
case B_SHOWESTR:
open_mostra_estrazione();
break;
case B_SHOWESCL:
if(e == fe_button)
@ -404,10 +493,12 @@ void TF9_dberr::add(const long num)
add(app);
}
void TF9_dberr::send()
bool TF9_dberr::send()
{
db().sq_set_exec(_insert);
bool ok = db().sq_set_exec(_insert);
app().add_sqlerror_msg_log(_insert);
_insert.cut(0) << "INSERT INTO " F9_ERR " VALUES ()";
return ok;
}
void TF9_dberr::del_err(const TString& id_estr, int numreg)
@ -521,6 +612,7 @@ int TF9_app::estrai_single(TToken_string& row, char flagprov, char tipodoc)
msg << "Errore database: impossibile scrivere nuova estrazione.\n"
<< db().sq_get_text_error(false);
error_box(msg);
add_sqlerror_msg_log("");
return -99;
}
else
@ -537,28 +629,42 @@ int TF9_app::estrai_single(TToken_string& row, char flagprov, char tipodoc)
}
}
void TF9_app::add_msg_log(const char* msg)
{
_log << msg << "\n\n";
}
void TF9_app::add_sqlerror_msg_log(const char* query)
{
TString msg;
msg << query << "\n" <<
db().sq_get_string_error() << "\n" <<
db().sq_get_text_error();
add_msg_log(msg);
}
void TF9_app::open_esclusi()
{
/* Prima chiedo quale mese e anno visualizzare
*/
// FINESTRA
static TMask* ym_msk = nullptr;
if (ym_msk == nullptr)
{
ym_msk = new TMask("Mostra esclusi", 1, 25, 16);
ym_msk->add_button_tool(DLG_OK, "Conferma", TOOL_OK);
ym_msk->add_button_tool(DLG_NULL, "", 0);
ym_msk->add_button_tool(DLG_QUIT, "Esci", TOOL_QUIT);
if (ym_msk == nullptr)
{
ym_msk = new TMask("Mostra esclusi", 1, 25, 16);
ym_msk->add_button_tool(DLG_OK, "Conferma", TOOL_OK);
ym_msk->add_button_tool(DLG_NULL, "", 0);
ym_msk->add_button_tool(DLG_QUIT, "Esci", TOOL_QUIT);
ym_msk->add_groupbox(507, 0, "Movimenti da visualizzare:", 0, 0, 25, 6);
ym_msk->add_number(501, 0, "Anno", 1, 1, 4);
ym_msk->add_list(502, 0, "Mese", 1, 2, 8, "", "01|02|03|04|05|06|07|08|09|10|11|12", "Gennaio|Febbraio|Marzo|Aprile|Maggio|Giugno|Luglio|Agosto|Settembre|Ottobre|Novembre|Dicembre");
ym_msk->add_list(503, 0, "Fino al", 1, 3, 9, "", " |01|02|03|04|05|06|07|08|09|10|11|12", " |Gennaio|Febbraio|Marzo|Aprile|Maggio|Giugno|Luglio|Agosto|Settembre|Ottobre|Novembre|Dicembre");
ym_msk->add_number(501, 0, "Anno", 1, 1, 4);
ym_msk->add_list(502, 0, "Mese", 1, 2, 8, "", "01|02|03|04|05|06|07|08|09|10|11|12", "Gennaio|Febbraio|Marzo|Aprile|Maggio|Giugno|Luglio|Agosto|Settembre|Ottobre|Novembre|Dicembre");
ym_msk->add_list(503, 0, "Fino al", 1, 3, 9, "", " |01|02|03|04|05|06|07|08|09|10|11|12", " |Gennaio|Febbraio|Marzo|Aprile|Maggio|Giugno|Luglio|Agosto|Settembre|Ottobre|Novembre|Dicembre");
ym_msk->add_groupbox(506, 0, "Selezionare il tipo di estrazione", 0, 6, 25);
ym_msk->add_list(504, 0, "Flag Provvisorio", 1, 7, 1, "", "P|D", "Provvisorio|Definitivo");
ym_msk->add_list(505, 0, "Tipo doc.", 1, 4, 1, "", "A|V", "Acquisti|Vendite");
ym_msk->set(501, today.year());
ym_msk->set_handler(501, year_handler);
}
ym_msk->set(501, today.year());
ym_msk->set_handler(501, year_handler);
}
ym_msk->run();
if (ym_msk->last_key() == K_QUIT)
return;
@ -660,11 +766,22 @@ bool TF9_app::estrai_escl_handler(TMask_field&, KEY key)
}
if (!flag)
message_box("Selezionare almeno un movimento");
else
app().print_log();
fill_esclusi();
return true;
}
bool TF9_app::mov_handler(TMask_field&, KEY key)
bool TF9_app::mov_handler(TMask_field& f, KEY key)
{
TSheet_field& sf = (*inclusi_mask())->sfield(S_ESCL);
TToken_string& row = sf.row(sf.selected());
TRectype mov(LF_MOV);
mov.put(MOV_NUMREG, row.get(sf.cid2index(F_NUMREG)));
return open_mov(mov);
}
bool TF9_app::mov_handler_escl(TMask_field& f, KEY key)
{
TSheet_field& sf = (*esclusi_mask())->sfield(S_ESCL);
TToken_string& row = sf.row(sf.selected());
@ -686,6 +803,11 @@ TMask& TF9_app::descr_msk()
return *m;
}
void TF9_app::open_new_mask()
{
}
void TF9_app::edit_wa() const
{
TString query;
@ -746,6 +868,14 @@ void TF9_app::load()
_tot_movs = i;
}
void TF9_app::print_log()
{
ofstream fout;
fout.open("f9exp_err.txt");
fout << _log;
_log.cut(0);
}
const char* TF9_app::traduci_stato(const TString& cod)
{
static TString stato;
@ -1052,8 +1182,11 @@ int TF9_app::estrai()
{
if (_head.stato_estr == D_GEST_ERR)
{
export_error_list();
warning_box("Attenzione l'estrazione ha prodotto degli errori. \nControllare e correggere eventuali problemi \ndal Controllo Estrazione.");
bool ok = export_error_list();
if (!ok)
warning_box("Errore scrittura db. Controllare log errori.");
else
warning_box("Attenzione l'estrazione ha prodotto degli errori. \nControllare e correggere eventuali problemi \ndal Controllo Estrazione.");
return -2;
}
else
@ -1140,23 +1273,19 @@ bool TF9_app::estrazione_iva(const bool escluso)
}
query << "\n)";
const bool ok = db().sq_set_exec(query);
if(!ok)
{
ofstream fout;
fout.open("f9exp_err.txt");
fout << query << endl;
fout << db().sq_get_string_error() << endl;
fout << db().sq_get_text_error() << endl << endl;
}
if(!ok) add_sqlerror_msg_log(query);
stato &= ok;
}
return stato;
}
void TF9_app::export_error_list(bool esclusi)
bool TF9_app::export_error_list(bool esclusi)
{
TF9_dberr dberr;
vector<TToken_string>& movs = esclusi ? _esclusi : _movs;
bool ok = true;
for (auto it = movs.begin(); it != movs.end(); ++it)
{
if (it->get(0)[0] == 'X')
@ -1172,9 +1301,10 @@ void TF9_app::export_error_list(bool esclusi)
else
dberr.add(); // Se vuoto metto NULL
}
dberr.send();
ok &= dberr.send();
}
}
return ok;
}
const char* TF9_app::categoria_doc()
@ -1327,7 +1457,7 @@ bool TF9_app::aggiorna_tab_f9(int version) const
if(end != int(std::string::npos))
{
TString query; query << sql.c_str();
ok &= db().sq_set_exec(query);
ok &= db().sq_set_exec(query, false);
ok &= db().sq_commit();
sql.erase();
}

View File

@ -72,6 +72,7 @@ class TF9_app : public TSkeleton_application
TString _addr_doc; // Indirizzo documenti cartacei
char _tipodoc_escl;
char _flagprov_escl;
TString _log;
static const char* traduci_stato(const TString& cod);
@ -113,7 +114,7 @@ class TF9_app : public TSkeleton_application
void load();
public:
const TString& get_ambiente() const { return _ambiente; };
const TString& get_ambiente() const { return _ambiente; }
const TString& get_addr_doc() const { return _addr_doc; };
void set_ambiente(const char* cod) { _ambiente.cut(0) << cod; };
@ -123,6 +124,7 @@ public:
static TMask& descr_msk();
static void open_new_mask();
// Estrazione esclusi
static bool select_escl_notify(TSheet_field& s, int row, KEY key);
static bool controllo_escl_handler(TMask_field& field, KEY key);
@ -131,6 +133,7 @@ public:
static void fill_esclusi();
static bool estrai_escl_handler(TMask_field&, KEY key);
static bool mov_handler(TMask_field&, KEY key);
static bool mov_handler_escl(TMask_field&, KEY key);
void edit_wa() const;
/** Estrazione per pacchetti "normali" (non da esclusi).
@ -143,12 +146,19 @@ public:
* \return -99 Errore scrittura F9DRD. */
int estrai();
int estrai_single(TToken_string& row, char flagprov, char tipodoc); /**< Estrazione singole per esclusi */
// logs
void print_log();
void add_msg_log(const char* msg);
void add_sqlerror_msg_log(const char* query);
/** Estrazione dati IVA sia per pacch. normali che per esclusi. Scrittura tabella F9IVA.
* \param escluso Settare a true se si sta estraendo un movimento escluso (estrazione pacchetto singolo, see estrai_single()).
* \return true Scrittura sul db senza errori.
* \return false Errore scrittura db. */
bool estrazione_iva(bool escluso = false);
void export_error_list(bool esclusi = false);
bool export_error_list(bool esclusi = false);
bool segna_estratti(bool escluso = false, int numreg = 0); /**< Segna su mov che il movimento e' stato estratto */
void segna_in_errore() const;
@ -189,6 +199,7 @@ class TMonitor_mask : public TAutomask
void delete_pack(bool all = false) const;
void sel() const;
void open_mostra_estrazione();
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
public:
@ -240,7 +251,7 @@ public:
void add(const char* string) { add(TString(string)); }
void add(long num);
void add() { add_str("NULL"); }
void send();
bool send();
static void del_err(const TString& id_estr, int get_int);
static char get_errori(const TString& id_estr, vector<TToken_string>& movs);
TF9_dberr();

View File

@ -1,7 +1,8 @@
// Sheet Pacchetti gia' elaborati
#define S_ELAB 201
#define F_TEXT 202
#define B_SHOWESCL 203
#define B_SHOWESTR 203
#define B_SHOWESCL 204
#define F_SEL 101
#define F_ARCH_B 102

View File

@ -29,16 +29,23 @@ BEGIN
FLAGS ""
END
BUTTON B_SHOWESTR 2 2
BEGIN
PROMPT 1 5 "Apri Estr."
PICTURE BMP_EXPORT
FLAGS ""
END
BUTTON DLG_RECALC
BEGIN
PROMPT 1 5 "Ricarica"
PROMPT 1 6 "Ricarica"
PICTURE TOOL_CONVERT
FLAS ""
END
BUTTON DLG_NULL 2 2
BEGIN
PROMPT 1 8 ""
PROMPT 1 7 ""
PICTURE 0
END

24
src/f9/f90100d.h Normal file
View File

@ -0,0 +1,24 @@
#define S_ESCL 201
#define F_ETEXT 202
#define B_ESTRAI 203
#define F_IIDESTR 204
#define F_IDATA 205
#define F_IPROV 206
#define F_ITIPOD 207
#define F_IDAL 208
#define F_IAL 209
// Elenco movimenti esclusi
#define F_SEL 101
#define F_NUMREG 102
#define F_DATAREG 103
#define F_DATADOC 104
#define F_CODCAUS 105
#define F_TIPOMOV 106
#define F_MESELIQ 107
#define F_NUMDOC 108
#define F_IMPTOTDOC 109
#define F_FORN 110
#define F_RAGSOC 111
#define F_PROTIVA 112
#define F_DESCR 113

202
src/f9/f90100d.uml Normal file
View File

@ -0,0 +1,202 @@
#include "f90100d.h"
TOOLBAR "topbar" 0 0 0 2
BUTTON DLG_INFO 2 2
BEGIN
PROMPT 1 1 "Info"
MESSAGE EXIT,K_F2
PICTURE TOOL_INFO
END
BUTTON DLG_HELP 2 2
BEGIN
PROMPT 2 1 "Help"
MESSAGE EXIT,K_F1
PICTURE TOOL_HELP
END
BUTTON DLG_NULL 2 2
BEGIN
PROMPT -1 0 ""
PICTURE 0
END
BUTTON DLG_QUIT 2 2
BEGIN
PROMPT 3 1 "Fine"
MESSAGE EXIT,K_QUIT
PICTURE TOOL_QUIT
END
ENDPAGE
PAGE "Movimenti" 0 2 0 0
STRING F_IIDESTR 18
BEGIN
PROMPT 0 0 "Id estrazione"
FLAGS "D"
END
DATA F_IDATA
BEGIN
PROMPT 45 0 "Data estrazione"
FLAGS "D"
END
BOOLEAN F_IPROV
BEGIN
PROMPT 0 1 "Provvisorio"
FLAGS "D"
END
STRING F_ITIPOD 9
BEGIN
PROMPT 15 1 "Tipo Documenti"
FLAGS "D"
END
DATA F_IDAL
BEGIN
PROMPT 0 2 "Dal"
FLAGS "D"
END
DATA F_IAL
BEGIN
PROMPT 15 2 "Al"
FLAGS "D"
END
TEXT F_ETEXT
BEGIN
PROMPT 0 3 "@BMovimenti estratti nel pacchetto:"
END
SPREADSHEET S_ESCL -1 -1
BEGIN
PROMPT 0 4 "Movimenti estratti"
ITEM " "
ITEM "Numero\nReg.@8"
ITEM "Data\nReg.@8"
ITEM "Data\nDoc.@8"
ITEM "Codice\nCaus.@8"
ITEM "Tipo Doc.@5"
ITEM "Mese\nliquidazione@8"
ITEM "Numero\nDocumento@8"
ITEM "Totale\nDocumento@8"
ITEM "Cliente/\nFornitore@8"
ITEM "Ragione\nSociale@8"
ITEM "Cod. regis./\nprot.IVA@8"
ITEM "Descrizione@8"
END
ENDPAGE
ENDMASK
PAGE "Mov Inclusi" -1 -1 78 13
BOOLEAN F_SEL
BEGIN
PROMPT 1 1 ""
END
NUMERIC F_NUMREG 7
BEGIN
PROMPT 1 1 ""
FLAGS "D"
END
DATA F_DATAREG
BEGIN
PROMPT 1 1 ""
FLAGS "D"
END
DATA F_DATADOC
BEGIN
PROMPT 1 1 ""
FLAGS "D"
END
STRING F_CODCAUS 3
BEGIN
PROMPT 1 1 ""
FLAGS "D"
END
STRING F_TIPOMOV 3
BEGIN
PROMPT 1 1 ""
FLAGS "D"
END
NUMERIC F_MESELIQ 2
BEGIN
PROMPT 1 1 ""
FLAGS "D"
END
STRING F_NUMDOC 50
BEGIN
PROMPT 1 1 ""
FLAGS "D"
END
NUMERIC F_IMPTOTDOC 15 2
BEGIN
PROMPT 1 1 ""
FLAGS "D"
END
NUMERIC F_FORN 6
BEGIN
PROMPT 1 1 ""
FLAGS "D"
END
STRING F_RAGSOC 80
BEGIN
PROMPT 1 1 ""
FLAGS "D"
END
STRING F_PROTIVA 10
BEGIN
PROMPT 1 1 ""
FLAGS "D"
END
STRING F_DESCR 50
BEGIN
PROMPT 1 1 ""
FLAGS "D"
END
ENDPAGE
TOOLBAR "topbar" 0 0 0 2
BUTTON DLG_USER 2 2
BEGIN
PROMPT 1 1 "Collega"
PICTURE TOOL_LINK
END
BUTTON DLG_NULL 2 2
BEGIN
PROMPT -1 0 ""
PICTURE 0
END
BUTTON DLG_QUIT 2 2
BEGIN
PROMPT 3 1 "Fine"
MESSAGE EXIT,K_QUIT
PICTURE TOOL_QUIT
END
ENPAGE
ENDMASK

10
src/f9/sql/f90102.sql Normal file
View File

@ -0,0 +1,10 @@
IF NOT EXISTS(SELECT 1 FROM sys.columns
WHERE Name = N'F9IURIC'
AND Object_ID = Object_ID(N'F9IVA00K'))
BEGIN
ALTER TABLE F9IVA00K ADD F9IDDES CHAR(30) NOT NULL DEFAULT '',
F9ITPRT CHAR(2) NOT NULL DEFAULT '',
F9IAPRT NUMERIC(4,0) NOT NULL DEFAULT 0,
F9INPRT NUMERIC(10,0) NOT NULL DEFAULT 0,
F9IURIC DATETIME NOT NULL DEFAULT getdate()
END;