Patch level : 12.0 892

Files correlati     : f90.exe f90100b.msk
Commento            :
- Riordinato codice e scritto inizio di documentazione delle classe e funzioni.
- Migliorata gestione esclusione: mi segno su F9ERROR gli esclusi.
- Aggiustato bug strano che toglieva o metteva 'si' nel campo ESCLUSI dello sheet: aggiunto fill
- Aggiunto bottone seleziona tutti gli esclusi
This commit is contained in:
Simone Palacino 2019-10-22 17:36:05 +02:00
parent 4c05e884c3
commit 6ae9011969
4 changed files with 116 additions and 49 deletions

View File

@ -102,10 +102,11 @@ bool TEstrai_mask::estrai_handler(TMask_field& f, KEY key)
message_box("Estrazione avvenuta con successo!");
app().segna_estratti();
}
if (!stato)
if (stato == 0 || stato == -3)
{
app().segna_in_errore();
warning_box("L'estrazione non e' stata completata. Controllare il log degli errori.");
if (stato == 0) // Errore scrittura F9IVA, non segno in errore ...
app().segna_in_errore(); // ...in testata se l'errore e' in scrittura dell'F9DRD
}
msk.field(ES_DESCR).set("");
msk.stop_run(K_FORCE_CLOSE);
@ -512,11 +513,14 @@ int TF9_app::estrai_single(TToken_string& row, char flagprov, char tipodoc)
TString err;
_head.stato_estr = prepara_movimenti_escl(get_tipoiva(), numreg, err);
const bool ok = esporta();
const bool ok = esporta(); // La testata la scrivo sempre. L'iva solo se diagnostica passata.
if (!ok)
{
error_box(db().sq_get_text_error(false));
TString msg;
msg << "Errore database: impossibile scrivere nuova estrazione.\n"
<< db().sq_get_text_error(false);
error_box(msg);
return -99;
}
else
@ -528,9 +532,8 @@ int TF9_app::estrai_single(TToken_string& row, char flagprov, char tipodoc)
warning_box("Attenzione l'estrazione ha prodotto degli errori. \nControllare e correggere eventuali problemi \npremendo il pulsante 'Controllo Estr.'");
return -2;
}
if (_head.stato_estr == D_GEST_OK)
else
return estrazione_iva(true) ? 1 : 0;
return -3;
}
}
@ -690,30 +693,6 @@ void TF9_app::edit_wa() const
"INSERT INTO F9WA00K (F9PCSOC, F9PPCDC0) VALUES (" << _ambiente << ", " << _addr_doc << ");";
}
void TF9_app::export_error_list(bool esclusi)
{
TF9_dberr dberr;
vector<TToken_string>& movs = esclusi ? _esclusi : _movs;
for(auto it = movs.begin(); it != movs.end(); ++it)
{
if(it->get(0)[0] == 'X')
{
dberr.add(_head.id_estr);
for(int i = 1; i < 15; i++)
{
TString string(it->get(i));
if (i == 2 || i == 3) // Sono obbligato a far cosi' per aggiungere le date
dberr.add(TDate(it->get(i)));
else if (string.full())
dberr.add(string);
else
dberr.add(); // Se vuoto metto NULL
}
dberr.send();
}
}
}
void TF9_app::load()
{
const TDate dataini = get_dataini();
@ -737,7 +716,7 @@ void TF9_app::load()
{
if (!progr.add_status())
break;
TToken_string elab_f9(recset_get_string(mov, MOV_ELABF9), ';');
TToken_string elab_f9(recset_get_string(mov, MOV_ELABF9), ';');
TCausale caus(recset_get_string(mov, MOV_CODCAUS, 3));
// Se definitivo controllo il flag di stampato REGST
if ((flagpro || recset_get_bool(mov, MOV_REGST)) && recset_get_string(mov, MOV_NUMDOC).full() && caus.reg().iva() == tipo
@ -822,16 +801,13 @@ state_fppro TF9_app::check_fppro(int numreg) const
return not_fa;
}
/** Controlla lo stato delle fatture
* per le fatt. acquisto non collegate a fppro cerca di agganciarle
*/
const char * TF9_app::prepara_movimenti(TipoIVA tipo)
{
bool ok = true;
if (tipo == iva_acquisti)
{
// Controlli per le fatture di acquisto prepara_movimenti
// Controlli per le fatture di acquisto
TProgress_monitor bar(_movs.size(), "Controllo stato movimenti di acquisto");
for (auto it = _movs.begin(); it != _movs.end(); ++it)
@ -1064,19 +1040,25 @@ int TF9_app::estrai()
_head.stato_estr = prepara_movimenti(get_tipoiva());
const bool ok = esporta();
if (!ok)
error_box("Errore database: impossibile scrivere nuova estrazione.");
if (!ok)
{
TString msg;
msg << "Errore database: impossibile scrivere nuova estrazione.\n"
<< db().sq_get_text_error(false);
error_box(msg);
return -99;
}
else
{
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.");
return -2;
}
else if (_head.stato_estr == D_GEST_OK)
else
return estrazione_iva() ? 1 : 0;
}
return -2;
}
bool TF9_app::estrazione_iva(const bool escluso)
@ -1171,6 +1153,30 @@ bool TF9_app::estrazione_iva(const bool escluso)
return stato;
}
void TF9_app::export_error_list(bool esclusi)
{
TF9_dberr dberr;
vector<TToken_string>& movs = esclusi ? _esclusi : _movs;
for (auto it = movs.begin(); it != movs.end(); ++it)
{
if (it->get(0)[0] == 'X')
{
dberr.add(_head.id_estr);
for (int i = 1; i < 15; i++)
{
TString string(it->get(i));
if (i == 2 || i == 3) // Sono obbligato a far cosi' per aggiungere le date
dberr.add(TDate(it->get(i)));
else if (string.full())
dberr.add(string);
else
dberr.add(); // Se vuoto metto NULL
}
dberr.send();
}
}
}
const char* TF9_app::categoria_doc()
{
return ""; // todo:
@ -1432,10 +1438,10 @@ void TControllo_mask::fill()
{
row = *it;
row[0] = (char&)" ";
if (!_is_escluso && _tipo_doc_err == 'A' || _is_escluso && app().get_tipoiva_escl() == iva_acquisti)
/*if (!_is_escluso && _tipo_doc_err == 'A' || _is_escluso && app().get_tipoiva_escl() == iva_acquisti)
row.add("", cid2index(F_CESCLUDI));
else
row.add("X", cid2index(F_CESCLUDI));
row.add("X", cid2index(F_CESCLUDI));*/
}
}
sf.force_update();
@ -1624,6 +1630,9 @@ void TControllo_mask::conferma_esclusi() const
movs.put(MOV_ELABF9, stato);
movs.rewrite();
row->add("Si", cid2index(F_CESCLUSO));
TString query;
query << "UPDATE " F9_ERR " SET ESCLUSO = 'Si' WHERE IDESTR = '" << _id_estr << "' AND NUMREG = '" << row->get(cid2index(F_CNUMREG)) << "';";
db().sq_set_exec(query);
}
else
{
@ -1632,6 +1641,9 @@ void TControllo_mask::conferma_esclusi() const
movs.put(MOV_ELABF9, "");
row->add("", cid2index(F_CESCLUSO));
movs.rewrite();
TString query;
query << "UPDATE " F9_ERR " SET ESCLUSO = NULL WHERE IDESTR = '" << _id_estr << "' AND NUMREG = '" << row->get(cid2index(F_CNUMREG)) << "';";
db().sq_set_exec(query);
}
}
}
@ -1670,7 +1682,10 @@ bool TControllo_mask::on_field_event(TOperable_field& o, TField_event e, long jo
break;
case B_ESCL:
if (e == fe_button)
{
conferma_esclusi();
fill();
}
break;
case B_SELESCL:
if (e == fe_button)
@ -1678,10 +1693,23 @@ bool TControllo_mask::on_field_event(TOperable_field& o, TField_event e, long jo
_sel_esclusi = !_sel_esclusi;
field(B_ASSOC).enable(!_sel_esclusi);
field(B_ESCL).enable(_sel_esclusi);
field(B_ALLESCL).enable(_sel_esclusi);
sfield(S_CONTROLLO).enable_column(cid2index(F_CESCLUDI), _sel_esclusi);
sfield(S_CONTROLLO).force_update();
}
break;
case B_ALLESCL:
if (e == fe_button)
{
TSheet_field& sf = sfield(S_CONTROLLO);
sf.hide();
const bool active = *sf.row(0).get(cid2index(F_CESCLUDI)) == 'X';
FOR_EACH_SHEET_ROW(sf, nr, row)
row->add(active ? " " : "X", cid2index(F_CESCLUDI));
sf.force_update();
sf.show();
}
break;
case S_CONTROLLO:
if (e == fe_init)
sfield(S_CONTROLLO).enable_column(cid2index(F_CESCLUDI), false);
@ -1699,6 +1727,7 @@ TControllo_mask::TControllo_mask(const char* id_estr, bool esclusi) : TAutomask(
{
_id_estr = id_estr;
field(B_ESCL).disable();
field(B_ALLESCL).disable();
get_win_order();
_is_escluso = esclusi;

View File

@ -76,6 +76,14 @@ class TF9_app : public TSkeleton_application
static const char* traduci_stato(const TString& cod);
state_fppro check_fppro(int numreg) const;
/** DIAGNOSTICA GESTIONALE.
* Controllo lo stato delle fatture:
* Per le fatt. acquisto non collegate a fppro cerca di agganciarle.
* Le fatture di vendita devono essere collegate ad un documento originario.
*
* \return D_GEST_OK (03) se non ci sono errori e l'estrazione puo' continuare.
* \return D_GEST_ERR (02) se la diagnostica ha riportato degli errori.
*/
const char* prepara_movimenti(TipoIVA tipo);
const char* prepara_movimenti_escl(TipoIVA tipo, int numreg, TString& err) const;
static bool is_doc_xml(const TLocalisamfile& mov);
@ -84,9 +92,12 @@ class TF9_app : public TSkeleton_application
static TString& drd_attr();
TString& drd_tovalues() const;
/** Controlla ultimo id estrazione della giornata e in base al tipo di estrazione,
* genera il progressivo seguente. Chiamata da \a estrai() e \a estrai_single().
* \return Nuovo id estrazione. */
TString next_estr_today(char tipo) const;
bool esporta() const;
bool new_extr() const;
bool esporta() const; /**< Scrittura testata estrazione. Tabella F9DRD. Chiama \a new_extr(). */
bool new_extr() const; /**< See \a esporta(). */
TDate get_dataini() const { return _estr_msk->get_date(ES_DATAINI); }
TDate get_dataend() const { return _estr_msk->get_date(ES_DATAEND); }
@ -98,6 +109,7 @@ class TF9_app : public TSkeleton_application
bool is_provviso() const { return _estr_msk->get(ES_FLAGPROV)[0] == 'P'; }
//void fill();
/** Caricamento di tutti i movimenti data un periodo di data registrazione. */
void load();
public:
@ -121,11 +133,23 @@ public:
static bool mov_handler(TMask_field&, KEY key);
void edit_wa() const;
/** Estrazione per pacchetti "normali" (non da esclusi).
* Viene chiamata dall'handler estrai_handler: bottone estrai nella maschera estrazione.
*
* \return 1 Se l'estrazione e' avvenuta senza errori.
* \return 0 Errore scrittura database iva.
* \return -1 Non esistono movimenti estraibili in quel periodo, o periodo sovrapposto ad altra estrazione.
* \return -2 La diagnostica ha riportato errori.
* \return -99 Errore scrittura F9DRD. */
int estrai();
int estrai_single(TToken_string& row, char flagprov, char tipodoc); /**< Estrazione singole per esclusi */
/** 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);
int estrai(); // Estrazione per pacchetti "normali"
int estrai_single(TToken_string& row, char flagprov, char tipodoc); // Estrazione singole per esclusi
bool estrazione_iva(bool escluso = false); // Estrazione dati IVA sia per pacch. normali che per esclusi
bool segna_estratti(bool escluso = false, int numreg = 0); // Segna su mov che il movimento e' stato estratto
bool segna_estratti(bool escluso = false, int numreg = 0); /**< Segna su mov che il movimento e' stato estratto */
void segna_in_errore() const;
static const char* categoria_doc();

View File

@ -4,10 +4,11 @@
#define B_ASSOC 202
#define B_SELESCL 203
#define B_ESCL 204
#define B_ALLESCL 205
// Sheet movimenti da controllare
#define S_CONTROLLO 205
#define S_FPPRO 206
#define S_CONTROLLO 206
#define S_FPPRO 207
// Cambi maschera ordinamento sheet FPPRO
#define F_ORDER 301

View File

@ -16,6 +16,12 @@ BEGIN
FLAGS ""
END
BUTTON DLG_NULL 2 2
BEGIN
PROMPT -1 1 ""
PICTURE 0
END
BUTTON B_SELESCL 2 2
BEGIN
PROMPT 1 8 "Sel. esclusi"
@ -30,6 +36,13 @@ BEGIN
FLAGS ""
END
BUTTON B_ALLESCL 2 2
BEGIN
PROMPT 1 7 "Sel. tutti"
PICTURE TOOL_MULTISEL
FLAGS ""
END
#include <helpbar.h>
ENDPAGE