Patch level : 12.0 no-patch
Files correlati : f90.exe f90100a.msk f90100b.msk f90200a.msk Commento : - F9 ARCHIVIAZIONE SOSTITUTIVA: - Aggiunto programma f90200 per configurazione categorie documentali. - Aggiunti due flag nella configurazione: no fatt ven Campo e visualizza mov dopo diag. - Spostato pulsante estrai in prima posizione. - Aggiunta maschera per tabella conf categorie doc - Sostituiti tutti tab con spazi - Disattivato apri estrazione se non in stato '02' - Implementata classe TEstrazione che gestisce le informazioni e le procedure di un'estrazione - Aggiunta finestra per inserire descrizione per estrazione escluso - Creata struct movimento_t per gestire meglio il vettore dei movimenti da estr.
This commit is contained in:
parent
46b04b1db1
commit
33bd61c8c3
@ -8,7 +8,9 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
switch (r)
|
switch (r)
|
||||||
{
|
{
|
||||||
default: rt = f90100(argc, argv); break;
|
default:
|
||||||
|
case 0: rt = f90100(argc, argv); break; // Programma estrazione pacchetti
|
||||||
|
case 1: rt = f90200(argc, argv); break; // Tabella categorie documentali
|
||||||
}
|
}
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
@ -2,5 +2,6 @@
|
|||||||
#define __F90_H
|
#define __F90_H
|
||||||
|
|
||||||
int f90100(int argc, char* argv[]);
|
int f90100(int argc, char* argv[]);
|
||||||
|
int f90200(int argc, char* argv[]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
File diff suppressed because it is too large
Load Diff
203
src/f9/f90100.h
203
src/f9/f90100.h
@ -1,41 +1,22 @@
|
|||||||
#pragma once
|
#ifndef __F90100H__
|
||||||
#include "applicat.h"
|
#define __F90100H__
|
||||||
#include "f90100a.h"
|
|
||||||
#include <automask.h>
|
|
||||||
#include "execp.h"
|
|
||||||
|
|
||||||
#define PAR_MOD "F9"
|
#define PAR_MOD "F9"
|
||||||
#define AMBIENTE_F9 "CODSOC" // Codice ambiente (codsoc)
|
#define AMBIENTE_F9 "CODSOC" // Codice ambiente (codsoc)
|
||||||
#define ADDRCART_F9 "ADDDOC" // Indirizzo documenti cartacei
|
#define ADDRCART_F9 "ADDDOC" // Indirizzo documenti cartacei
|
||||||
|
#define VENDEXT_F9 "VENDEXT" // Flag no vendite con campo
|
||||||
|
#define VIEWMOV_F9 "VIEWMOVPRE" // Flag visualizza moviementi prima di estrarre
|
||||||
|
|
||||||
TDate today(TODAY);
|
#include "execp.h"
|
||||||
|
#include "f90100a.h"
|
||||||
enum state_fppro
|
#include "f9lib01.h"
|
||||||
{
|
#include "mov.h"
|
||||||
correct = 1,
|
#include <automask.h>
|
||||||
reg_with_err = -1,
|
#include "applicat.h"
|
||||||
not_fa = -10, // Non e' fattura acquisti
|
|
||||||
guessed = 100,
|
|
||||||
no_guessed = 0
|
|
||||||
};
|
|
||||||
|
|
||||||
struct drd
|
|
||||||
{
|
|
||||||
TString cod_soc;
|
|
||||||
TString id_estr;
|
|
||||||
bool flag_prov{ true };
|
|
||||||
TString descr;
|
|
||||||
char tipo_doc{ 'A' };
|
|
||||||
TDate dal;
|
|
||||||
TDate al;
|
|
||||||
TString user;
|
|
||||||
TString timestamp;
|
|
||||||
TString4 stato_estr{ "01" };
|
|
||||||
TString addr_cart;
|
|
||||||
};
|
|
||||||
|
|
||||||
SSimple_query& db();
|
|
||||||
|
|
||||||
|
/** class TEstrai_mask
|
||||||
|
* \brief Piccola maschera "creata a runtime" per avviare l'estrazione.
|
||||||
|
*/
|
||||||
class TEstrai_mask : public TMask
|
class TEstrai_mask : public TMask
|
||||||
{
|
{
|
||||||
TString _descr;
|
TString _descr;
|
||||||
@ -59,46 +40,27 @@ class TF9_app : public TSkeleton_application
|
|||||||
//friend class TEstrai_mask;
|
//friend class TEstrai_mask;
|
||||||
friend class TMonitor_mask;
|
friend class TMonitor_mask;
|
||||||
friend class TControllo_mask;
|
friend class TControllo_mask;
|
||||||
drd _head;
|
friend class TEstrazione;
|
||||||
TEstrai_mask* _estr_msk;
|
|
||||||
TMonitor_mask* _msk;
|
struct config
|
||||||
//TControllo_mask* _controllo_msk;
|
{
|
||||||
vector<TToken_string> _movs;
|
TString ambiente; // Codice ambiente (codsoc)
|
||||||
|
TString addr_doc; // Indirizzo documenti cartacei
|
||||||
|
bool vendext;
|
||||||
|
bool viewmovpre;
|
||||||
|
} _config;
|
||||||
|
unique_ptr<TEstrai_mask> _estr_msk;
|
||||||
|
unique_ptr<TMonitor_mask> _msk;
|
||||||
|
vector<movimento_t> _movs;
|
||||||
vector<TToken_string> _esclusi; // Vettore con i movimenti esclusi
|
vector<TToken_string> _esclusi; // Vettore con i movimenti esclusi
|
||||||
vector<TToken_string> _esclusi_vect;
|
vector<TToken_string> _esclusi_vect;
|
||||||
TToken_string _mov_escl;
|
TToken_string _mov_escl;
|
||||||
int _tot_movs;
|
|
||||||
TString _ambiente; // Codice ambiente (codsoc)
|
|
||||||
TString _addr_doc; // Indirizzo documenti cartacei
|
|
||||||
char _tipodoc_escl;
|
char _tipodoc_escl;
|
||||||
char _flagprov_escl;
|
char _flagprov_escl;
|
||||||
TString _log;
|
TString _log;
|
||||||
|
|
||||||
static const char* traduci_stato(const TString& cod);
|
shared_ptr<TEstrazione> _estrazione;
|
||||||
|
TEstrazione* _estr_escluso;
|
||||||
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);
|
|
||||||
static bool check_periodo_def(const drd& head);
|
|
||||||
|
|
||||||
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; /**< 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_dataini() const { return _estr_msk->get_date(ES_DATAINI); }
|
||||||
TDate get_dataend() const { return _estr_msk->get_date(ES_DATAEND); }
|
TDate get_dataend() const { return _estr_msk->get_date(ES_DATAEND); }
|
||||||
@ -109,43 +71,39 @@ class TF9_app : public TSkeleton_application
|
|||||||
TString get_descr() const { return _estr_msk->get(ES_DESCR); }
|
TString get_descr() const { return _estr_msk->get(ES_DESCR); }
|
||||||
bool is_provviso() const { return _estr_msk->get(ES_FLAGPROV)[0] == 'P'; }
|
bool is_provviso() const { return _estr_msk->get(ES_FLAGPROV)[0] == 'P'; }
|
||||||
|
|
||||||
|
static const char* traduci_stato(const TString& cod);
|
||||||
|
|
||||||
//void fill();
|
//void fill();
|
||||||
/** Caricamento di tutti i movimenti data un periodo di data registrazione. */
|
|
||||||
void load();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const TString& get_ambiente() const { return _ambiente; }
|
const TString& get_ambiente() const { return _config.ambiente; }
|
||||||
const TString& get_addr_doc() const { return _addr_doc; };
|
const TString& get_addr_doc() const { return _config.addr_doc; }
|
||||||
|
bool get_has_vendext() const { return _config.vendext; }
|
||||||
|
bool get_viewmov() const { return _config.viewmovpre; }
|
||||||
|
|
||||||
void set_ambiente(const char* cod) { _ambiente.cut(0) << cod; };
|
void set_ambiente(const char* cod) { _config.ambiente.cut(0) << cod; }
|
||||||
void set_addr_doc(const char* add) { _addr_doc.cut(0) << add; };
|
void set_addr_doc(const char* add) { _config.addr_doc.cut(0) << add; }
|
||||||
|
void set_has_vendext(const bool flag) { _config.vendext = flag; }
|
||||||
|
void set_viewmov(const bool flag) { _config.viewmovpre = flag; }
|
||||||
|
|
||||||
void run_estr_msk() const { _estr_msk->run(); }
|
void run_estr_msk() const { _estr_msk->run(); }
|
||||||
|
|
||||||
static TMask& descr_msk();
|
|
||||||
|
|
||||||
static void open_new_mask();
|
|
||||||
// Estrazione esclusi
|
// Estrazione esclusi
|
||||||
static bool select_escl_notify(TSheet_field& s, int row, KEY key);
|
static bool select_escl_notify(TSheet_field& s, int row, KEY key);
|
||||||
static bool controllo_escl_handler(TMask_field& field, KEY key);
|
static bool controllo_escl_handler(TMask_field& field, KEY key);
|
||||||
static bool year_handler(TMask_field& field, KEY key);
|
static bool year_handler(TMask_field& field, KEY key);
|
||||||
void open_esclusi();
|
void open_esclusi();
|
||||||
static void fill_esclusi();
|
static void fill_esclusi();
|
||||||
|
static movimento_t escl2mov(TToken_string* row);
|
||||||
static bool estrai_escl_handler(TMask_field&, KEY key);
|
static bool estrai_escl_handler(TMask_field&, KEY key);
|
||||||
static bool mov_handler(TMask_field&, KEY key);
|
static bool mov_handler(TMask_field&, KEY key);
|
||||||
static bool mov_handler_escl(TMask_field&, KEY key);
|
static bool mov_handler_escl(TMask_field&, KEY key);
|
||||||
|
|
||||||
void edit_wa() const;
|
void edit_wa() const;
|
||||||
/** Estrazione per pacchetti "normali" (non da esclusi).
|
/** Caricamento di tutti i movimenti data un periodo di data registrazione.
|
||||||
* Viene chiamata dall'handler estrai_handler: bottone estrai nella maschera estrazione.
|
* \return See TEstrazione::estrai().
|
||||||
*
|
*/
|
||||||
* \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();
|
||||||
int estrai_single(TToken_string& row, char flagprov, char tipodoc); /**< Estrazione singole per esclusi */
|
|
||||||
|
|
||||||
// logs
|
// logs
|
||||||
|
|
||||||
@ -153,60 +111,48 @@ public:
|
|||||||
void add_msg_log(const char* msg);
|
void add_msg_log(const char* msg);
|
||||||
void add_sqlerror_msg_log(const char* query);
|
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);
|
|
||||||
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 */
|
bool segna_estratti(bool escluso = false, int numreg = 0); /**< Segna su mov che il movimento e' stato estratto */
|
||||||
void segna_in_errore() const;
|
void segna_in_errore() const;
|
||||||
|
|
||||||
static const char* categoria_doc();
|
|
||||||
static const char* caus_sos(const TLocalisamfile& mov, TipoIVA acquisti);
|
|
||||||
static bool is_autofattura(const TLocalisamfile& mov);
|
static bool is_autofattura(const TLocalisamfile& mov);
|
||||||
|
|
||||||
void main_loop() override;
|
void main_loop() override;
|
||||||
|
|
||||||
// Controllo e aggiornamento tabelle F9
|
// Controllo e aggiornamento tabelle F9
|
||||||
|
|
||||||
bool create_tables() const; // Creazione tabelle F9
|
bool create_tables() const; /**< Creazione tabelle F9 */
|
||||||
bool check_tabelle_f9() const; // Controllo esistenza delle tabelle e in caso le crea
|
bool check_tabelle_f9() const; /**< Controllo esistenza delle tabelle e in caso le crea */
|
||||||
bool aggiorna_tab_f9(int version) const; // Aggiorna modifiche alle tabelle F9 come descritto in cima al file .cpp
|
bool aggiorna_tab_f9(int version) const; /**< Aggiorna modifiche alle tabelle F9 come descritto in cima al file .cpp */
|
||||||
bool check_tab_version() const; // Controllo della versione e in caso aggiorna le tabelle
|
bool check_tab_version() const; /**< Controllo della versione e in caso aggiorna le tabelle */
|
||||||
bool check_table() const;
|
bool check_table() const;
|
||||||
TF9_app() : _estr_msk(nullptr), _msk(nullptr), _mov_escl("", '|'), _tot_movs(0), _ambiente(""), _addr_doc(""),
|
TF9_app() : _config({ "", "", false, false }), _estr_msk(nullptr), _msk(nullptr), _mov_escl("", '|'),
|
||||||
_tipodoc_escl('A'), _flagprov_escl('P') { }
|
_tipodoc_escl('A'), _flagprov_escl('P'), _estrazione(nullptr), _estr_escluso(nullptr)
|
||||||
|
{ }
|
||||||
};
|
};
|
||||||
|
TF9_app& f9_app();
|
||||||
TF9_app& app();
|
|
||||||
|
|
||||||
class TMonitor_mask : public TAutomask
|
class TMonitor_mask : public TAutomask
|
||||||
{
|
{
|
||||||
vector<TToken_string> _fppro;
|
|
||||||
friend class TF9_app;
|
friend class TF9_app;
|
||||||
|
vector<TToken_string> _fppro;
|
||||||
|
|
||||||
static bool save_conf_handler(TMask_field& f, KEY key);
|
static bool save_conf_handler(TMask_field& f, KEY key);
|
||||||
|
|
||||||
void controllo_errori() const;
|
void controllo_errori() const;
|
||||||
|
void delete_pack(bool all = false) const;
|
||||||
|
|
||||||
// Riempie sheet per visualizzare le estrazioni
|
// Riempie sheet per visualizzare le estrazioni
|
||||||
|
void fill() const;
|
||||||
|
|
||||||
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
||||||
bool on_key(KEY key) override;
|
bool on_key(KEY key) override;
|
||||||
|
void open_mostra_estrazione() const;
|
||||||
static void open_win_estr();
|
static void open_win_estr();
|
||||||
void open_win_conf() const;
|
void open_win_conf() const;
|
||||||
|
|
||||||
void fill() const;
|
|
||||||
|
|
||||||
void delete_pack(bool all = false) const;
|
|
||||||
|
|
||||||
void sel() const;
|
void sel() const;
|
||||||
void open_mostra_estrazione();
|
|
||||||
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TMonitor_mask() : TAutomask("f90100a")
|
TMonitor_mask() : TAutomask("f90100a") { fill(); }
|
||||||
{
|
|
||||||
//disable(DLG_FINDREC);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TControllo_mask : public TAutomask
|
class TControllo_mask : public TAutomask
|
||||||
@ -218,6 +164,10 @@ class TControllo_mask : public TAutomask
|
|||||||
bool _is_escluso;
|
bool _is_escluso;
|
||||||
TString _id_estr;
|
TString _id_estr;
|
||||||
char _tipo_doc_err{};
|
char _tipo_doc_err{};
|
||||||
|
vector<TToken_string> _movs;
|
||||||
|
|
||||||
|
void associa();
|
||||||
|
void conferma_esclusi() const;
|
||||||
|
|
||||||
vector<TToken_string>& import_error_list();
|
vector<TToken_string>& import_error_list();
|
||||||
void fill();
|
void fill();
|
||||||
@ -228,33 +178,12 @@ class TControllo_mask : public TAutomask
|
|||||||
TToken_string* selected_mov();
|
TToken_string* selected_mov();
|
||||||
TToken_string* selected_fat() const;
|
TToken_string* selected_fat() const;
|
||||||
|
|
||||||
// Gestisce la selezione multipla negli sheet di controllo movimenti
|
/** Gestisce la selezione multipla negli sheet di controllo movimenti */
|
||||||
void selfatt(TOperable_field& o, long jolly) const;
|
void selfatt(TOperable_field& o, long jolly) const;
|
||||||
void conferma_esclusi() const;
|
|
||||||
void associa();
|
|
||||||
|
|
||||||
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TControllo_mask(const char* id_estr, bool esclusi = false);
|
explicit TControllo_mask(const char* id_estr, bool esclusi = false);
|
||||||
};
|
|
||||||
|
|
||||||
class TF9_dberr
|
|
||||||
{
|
|
||||||
TString _str;
|
|
||||||
TString _insert;
|
|
||||||
|
|
||||||
void add_str(const TString& string);
|
|
||||||
public:
|
|
||||||
void add(const TString& string);
|
|
||||||
void add(const TDate& date) { add(date.date2ansi()); }
|
|
||||||
void add(const char* string) { add(TString(string)); }
|
|
||||||
void add(long num);
|
|
||||||
void add() { add_str("NULL"); }
|
|
||||||
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();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool open_mov(const TRectype& mov)
|
inline bool open_mov(const TRectype& mov)
|
||||||
@ -281,8 +210,14 @@ inline bool open_mov(const TRectype& mov)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Getters per semplificare i get dai TRecorset
|
// Getters per semplificare i get dai TRecorset
|
||||||
|
|
||||||
const TString& recset_get_string(const TRecordset& rec, const char* field, int zero_filled = -1);
|
const TString& recset_get_string(const TRecordset& rec, const char* field, int zero_filled = -1);
|
||||||
|
int recset_get_int(const TRecordset& rec, const char* field, int zero_filled = -1);
|
||||||
bool recset_get_bool(const TRecordset& rec, const char* field);
|
bool recset_get_bool(const TRecordset& rec, const char* field);
|
||||||
real recset_get_real(const TRecordset& rec, const char* field);
|
real recset_get_real(const TRecordset& rec, const char* field);
|
||||||
|
|
||||||
|
#endif //__F90100H__
|
@ -17,21 +17,21 @@
|
|||||||
#define F_DESCR_E 111
|
#define F_DESCR_E 111
|
||||||
|
|
||||||
// Campi del vettore _movs per promemoria
|
// Campi del vettore _movs per promemoria
|
||||||
#define F_SEL 101
|
// F_SEL 101
|
||||||
#define F_NUMREG 102
|
// F_NUMREG 102
|
||||||
#define F_DATAREG 103
|
// F_DATAREG 103
|
||||||
#define F_DATADOC 104
|
// F_DATADOC 104
|
||||||
#define F_CODCAUS 105
|
// F_CODCAUS 105
|
||||||
#define F_MESELIQ 106
|
// F_MESELIQ 106
|
||||||
#define F_NUMDOC 107
|
// F_NUMDOC 107
|
||||||
#define F_IMPTOTDOC 108
|
// F_IMPTOTDOC 108
|
||||||
#define F_FORN 109
|
// F_FORN 109
|
||||||
#define F_RAGSOC 110
|
// F_RAGSOC 110
|
||||||
#define F_PROTIVA 111
|
// F_PROTIVA 111
|
||||||
#define F_DESCR 112
|
// F_DESCR 112
|
||||||
#define F_ESCLUDI 113
|
// F_ESCLUDI 113
|
||||||
#define F_ESCLUSO 114
|
// F_ESCLUSO 114
|
||||||
#define F_DESCRERR 115
|
// F_DESCRERR 115
|
||||||
|
|
||||||
// Campi maschera finestra runtime estrazione
|
// Campi maschera finestra runtime estrazione
|
||||||
#define ES_DATAINI 501
|
#define ES_DATAINI 501
|
||||||
@ -49,6 +49,9 @@
|
|||||||
#define CF_CODSOC 502
|
#define CF_CODSOC 502
|
||||||
#define CF_ADDRGROUP 503
|
#define CF_ADDRGROUP 503
|
||||||
#define CF_ADDRDOC 504
|
#define CF_ADDRDOC 504
|
||||||
|
#define CF_ESTRGROUP 505
|
||||||
|
#define CF_VENDEXT 506
|
||||||
|
#define CF_VIEWMOVPRE 507
|
||||||
|
|
||||||
// Campi maschera descrizione estrazione
|
// Campi maschera descrizione estrazione
|
||||||
#define DES_TEXT 501
|
#define DES_TEXT 501
|
||||||
|
@ -2,12 +2,6 @@
|
|||||||
|
|
||||||
TOOLBAR "topbar" 0 0 0 2
|
TOOLBAR "topbar" 0 0 0 2
|
||||||
|
|
||||||
BUTTON DLG_DELREC 2 2
|
|
||||||
BEGIN
|
|
||||||
PROMPT 1 1 "~Elimina"
|
|
||||||
PICTURE TOOL_DELREC
|
|
||||||
END
|
|
||||||
|
|
||||||
BUTTON DLG_ELABORA 2 2
|
BUTTON DLG_ELABORA 2 2
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 1 2 "Estrazione"
|
PROMPT 1 2 "Estrazione"
|
||||||
@ -15,6 +9,12 @@ BEGIN
|
|||||||
FLAGS ""
|
FLAGS ""
|
||||||
END
|
END
|
||||||
|
|
||||||
|
BUTTON DLG_DELREC 2 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 1 "~Elimina"
|
||||||
|
PICTURE TOOL_DELREC
|
||||||
|
END
|
||||||
|
|
||||||
BUTTON DLG_CONFIG 2 2
|
BUTTON DLG_CONFIG 2 2
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 1 3 "Configurazione"
|
PROMPT 1 3 "Configurazione"
|
||||||
|
@ -64,7 +64,7 @@ BEGIN
|
|||||||
ITEM "Mese\nliquidazione@8"
|
ITEM "Mese\nliquidazione@8"
|
||||||
ITEM "Numero\nDocumento@8"
|
ITEM "Numero\nDocumento@8"
|
||||||
ITEM "Totale\nDocumento@8"
|
ITEM "Totale\nDocumento@8"
|
||||||
ITEM "Fornitore@8"
|
ITEM "Cliente/\nFornitore@8"
|
||||||
ITEM "Ragione\nSociale@8"
|
ITEM "Ragione\nSociale@8"
|
||||||
ITEM "Cod. regis./\nprot.IVA@8"
|
ITEM "Cod. regis./\nprot.IVA@8"
|
||||||
ITEM "Descrizione@8"
|
ITEM "Descrizione@8"
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#define F9_WA "F9WA00K"
|
#define F9_WA "F9WA00K"
|
||||||
#define F9_DRD "F9DRD00K"
|
#define F9_DRD "F9DRD00K"
|
||||||
#define F9_IVA "F9IVA00K"
|
#define F9_IVA "F9IVA00K"
|
||||||
@ -7,6 +5,7 @@
|
|||||||
#define F9_ERR "F9ERROR"
|
#define F9_ERR "F9ERROR"
|
||||||
|
|
||||||
// FILE DRD : DRIVER ESTRAZIONE GIORNALE IVA
|
// FILE DRD : DRIVER ESTRAZIONE GIORNALE IVA
|
||||||
|
|
||||||
#define DRD_CODSOC "F9RCSOC" // A(10) [K]
|
#define DRD_CODSOC "F9RCSOC" // A(10) [K]
|
||||||
#define DRD_ID_EST "F9RIDES" // A(18) [K]
|
#define DRD_ID_EST "F9RIDES" // A(18) [K]
|
||||||
#define DRD_FLAG_PD "F9RFPDE" // A(1) [K] - { P | D } - Flag provvisorio/definitivo
|
#define DRD_FLAG_PD "F9RFPDE" // A(1) [K] - { P | D } - Flag provvisorio/definitivo
|
||||||
@ -17,7 +16,9 @@
|
|||||||
#define DRD_UTENTE "F9RUTEE" // A(10) - Utente estrazione
|
#define DRD_UTENTE "F9RUTEE" // A(10) - Utente estrazione
|
||||||
#define DRD_TIME "F9RUHES" // T - Data e ora estrazione
|
#define DRD_TIME "F9RUHES" // T - Data e ora estrazione
|
||||||
#define DRD_STATO "F9RIDAS" // A(2) - { 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 } - Stato estrazione documenti
|
#define DRD_STATO "F9RIDAS" // A(2) - { 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 } - Stato estrazione documenti
|
||||||
|
|
||||||
// Stati /////////////////
|
// Stati /////////////////
|
||||||
|
|
||||||
#define IN_DIAGN "01" // 01 = in diagnostica
|
#define IN_DIAGN "01" // 01 = in diagnostica
|
||||||
#define D_GEST_ERR "02" // 02 = errore diagnostica gestionale
|
#define D_GEST_ERR "02" // 02 = errore diagnostica gestionale
|
||||||
#define D_GEST_OK "03" // 03 = diagnostica gestionale ok,
|
#define D_GEST_OK "03" // 03 = diagnostica gestionale ok,
|
||||||
@ -28,10 +29,12 @@
|
|||||||
#define D_ERR_SOS "08" // 08 = errore diagnostica sostitutiva
|
#define D_ERR_SOS "08" // 08 = errore diagnostica sostitutiva
|
||||||
#define ELAB_COMPL "09" // 09 = Pacchetto archiviazione acquisito
|
#define ELAB_COMPL "09" // 09 = Pacchetto archiviazione acquisito
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
|
||||||
#define DRD_PERC "F9RPCDC" // A(256) - Perc. copia doc. cartacei WA
|
#define DRD_PERC "F9RPCDC" // A(256) - Perc. copia doc. cartacei WA
|
||||||
|
|
||||||
|
|
||||||
// FILE IVA : DOCUMENTI ESTRATTI DAL GIORNALE IVA
|
// FILE IVA : DOCUMENTI ESTRATTI DAL GIORNALE IVA
|
||||||
|
|
||||||
#define IVA_CODSOC "F9ICSOC" // A(10) [K] - Codice società
|
#define IVA_CODSOC "F9ICSOC" // A(10) [K] - Codice società
|
||||||
#define IVA_IDLAN "F9IIDLA" // A(18) [K] - ID UNIVOCO DI LANCIO
|
#define IVA_IDLAN "F9IIDLA" // A(18) [K] - ID UNIVOCO DI LANCIO
|
||||||
#define IVA_FLAG_PD "F9IFPDE" // A(1) [K] - Flag Provvisorio / Definitivo
|
#define IVA_FLAG_PD "F9IFPDE" // A(1) [K] - Flag Provvisorio / Definitivo
|
||||||
@ -88,6 +91,7 @@
|
|||||||
|
|
||||||
|
|
||||||
// FILE DRT : TABELLA CATEGORIE DOCUMENTALI
|
// FILE DRT : TABELLA CATEGORIE DOCUMENTALI
|
||||||
|
|
||||||
#define DRT_CODSOC "F9TCSOC" // A(10) [K] - COD.SOCIETÀ
|
#define DRT_CODSOC "F9TCSOC" // A(10) [K] - COD.SOCIETÀ
|
||||||
#define DRT_CATDOC "F9TCADO" // A(10) [K] - Categoria documento
|
#define DRT_CATDOC "F9TCADO" // A(10) [K] - Categoria documento
|
||||||
#define DRT_DESCR "F9TDES" // A(30) - Descrizione documento
|
#define DRT_DESCR "F9TDES" // A(30) - Descrizione documento
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "../fp/fplib.h"
|
#include "../fp/fplib.h"
|
||||||
#include "f901tab.h"
|
#include "f901tab.h"
|
||||||
#include "f9lib.h"
|
#include "f90100.h"
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// TConfigurazione_sostitutiva_msk
|
// TConfigurazione_sostitutiva_msk
|
||||||
@ -68,7 +68,7 @@ public:
|
|||||||
|
|
||||||
void TConfigurazione_sostitutiva_app::add_error_log(TString& query)
|
void TConfigurazione_sostitutiva_app::add_error_log(TString& query)
|
||||||
{
|
{
|
||||||
_log << "\n" << query << "\n" << db().sq_get_text_error() << "\n" << db().sq_get_string_error();
|
_log << "\n" << query << "\n" << fp_db().sq_get_text_error() << "\n" << fp_db().sq_get_string_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TConfigurazione_sostitutiva_app::main_loop()
|
void TConfigurazione_sostitutiva_app::main_loop()
|
||||||
@ -89,8 +89,8 @@ void TConfigurazione_sostitutiva_app::main_loop()
|
|||||||
" INSERT INTO " F9_DRT " ( ) \n"
|
" INSERT INTO " F9_DRT " ( ) \n"
|
||||||
" VALUES ();\n";
|
" VALUES ();\n";
|
||||||
}
|
}
|
||||||
bool ok = db().sq_set_exec(query, false);
|
bool ok = fp_db().sq_set_exec(query, false);
|
||||||
ok &= db().sq_commit();
|
ok &= fp_db().sq_commit();
|
||||||
if (false)
|
if (false)
|
||||||
{
|
{
|
||||||
add_error_log(query);
|
add_error_log(query);
|
||||||
|
11
src/f9/f90200a.h
Normal file
11
src/f9/f90200a.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#define S_CLASSDOC 201
|
||||||
|
|
||||||
|
#define F_SELCLASS 101
|
||||||
|
#define F_CATDOC 102
|
||||||
|
#define F_DESCRDOC 103
|
||||||
|
#define F_CLASDOCSOS 104
|
||||||
|
#define F_CAUSSOS 105
|
||||||
|
#define F_CAUSCONT 106
|
||||||
|
#define F_TIPOCAUSCONT 107
|
||||||
|
#define F_TIPOMOVCONT 108
|
||||||
|
#define F_OPERCEE 109
|
104
src/f9/f90200a.uml
Normal file
104
src/f9/f90200a.uml
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
#include "f90200a.h"
|
||||||
|
|
||||||
|
TOOLBAR "topbar" 0 0 0 2
|
||||||
|
|
||||||
|
BUTTON DLG_OK 2 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 1 "Registra"
|
||||||
|
PICTURE TOOL_SAVEREC
|
||||||
|
END
|
||||||
|
|
||||||
|
#include "helpbar.h"
|
||||||
|
ENDPAGE
|
||||||
|
|
||||||
|
PAGE "Classi Documentali" 0 2 0 0
|
||||||
|
|
||||||
|
SPREADSHEET S_CLASSDOC -1 -1
|
||||||
|
BEGIN
|
||||||
|
PROMPT 0 0 "Classi Documentali"
|
||||||
|
ITEM " "
|
||||||
|
ITEM "Categoria\nDocumento (Codice)@18"
|
||||||
|
ITEM "Descrizione\nDocumento"
|
||||||
|
ITEM "Classe Documentale\nSostitutiva@18"
|
||||||
|
ITEM "Causale per\nSostitutiva (TD01...)@12"
|
||||||
|
ITEM "Causale\nContabile"
|
||||||
|
ITEM "Tipo Causale\nContabile"
|
||||||
|
ITEM "Tipo Movimento\nContabile"
|
||||||
|
ITEM "Operatore CEE"
|
||||||
|
END
|
||||||
|
|
||||||
|
ENDPAGE
|
||||||
|
ENDMASK
|
||||||
|
|
||||||
|
|
||||||
|
PAGE "Righe doc" -1 -1 78 13
|
||||||
|
|
||||||
|
BOOLEAN F_SELCLASS
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 1 "Seleziona"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_CATDOC 5
|
||||||
|
BEGIN
|
||||||
|
PROMPT 0 0 "Categoria Documento"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_DESCRDOC 5
|
||||||
|
BEGIN
|
||||||
|
PROMPT 0 0 "Descrizione Documento"
|
||||||
|
END
|
||||||
|
|
||||||
|
LIST F_CLASDOCSOS 3 24
|
||||||
|
BEGIN
|
||||||
|
PROMPT 0 0 ""
|
||||||
|
FLAGS ""
|
||||||
|
ITEM "FTA|FTA - Fattura Acquisti"
|
||||||
|
ITEM "FTV|FTV - Fattura di Vendita"
|
||||||
|
END
|
||||||
|
|
||||||
|
LIST F_CAUSSOS 4 33
|
||||||
|
BEGIN
|
||||||
|
PROMPT 0 0 ""
|
||||||
|
FLAGS ""
|
||||||
|
ITEM ""
|
||||||
|
ITEM "TD01|TD01 Fattura"
|
||||||
|
ITEM "TD02|TD02 Acconto/Anticipo su fattura"
|
||||||
|
ITEM "TD03|TD03 Acconto/Anticipo su parcella"
|
||||||
|
ITEM "TD04|TD04 Nota di credito"
|
||||||
|
ITEM "TD05|TD05 Nota di debito"
|
||||||
|
ITEM "TD06|TD06 Parcella"
|
||||||
|
ITEM "TD20|TD20 Autofattura"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_CAUSCONT 5
|
||||||
|
BEGIN
|
||||||
|
PROMPT 0 0 "Causale Contabile"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_TIPOCAUSCONT 5
|
||||||
|
BEGIN
|
||||||
|
PROMPT 0 0 "Tipo Causale Contabile"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_TIPOMOVCONT 5
|
||||||
|
BEGIN
|
||||||
|
PROMPT 0 0 "Tipo Movimento Contabile"
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_OPERCEE 5
|
||||||
|
BEGIN
|
||||||
|
PROMPT 0 0 "Operatore CEE"
|
||||||
|
END
|
||||||
|
|
||||||
|
ENDPAGE
|
||||||
|
|
||||||
|
TOOLBAR "topbar" 0 0 0 2
|
||||||
|
BUTTON DLG_QUIT 2 2
|
||||||
|
BEGIN
|
||||||
|
PROMPT 3 1 "Fine"
|
||||||
|
MESSAGE EXIT,K_QUIT
|
||||||
|
PICTURE TOOL_QUIT
|
||||||
|
END
|
||||||
|
|
||||||
|
ENPAGE
|
||||||
|
ENDMASK
|
589
src/f9/f9lib01.cpp
Normal file
589
src/f9/f9lib01.cpp
Normal file
@ -0,0 +1,589 @@
|
|||||||
|
#include "f9lib01.h"
|
||||||
|
#include "f1lib.h"
|
||||||
|
#include "f901tab.h"
|
||||||
|
#include "progind.h"
|
||||||
|
#include "clifo.h"
|
||||||
|
#include <cg2103.h>
|
||||||
|
#include "mov.h"
|
||||||
|
#include "../fp/fplib.h"
|
||||||
|
|
||||||
|
const char* check_str(const TString& str);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////
|
||||||
|
// TEstrazione
|
||||||
|
////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
const char* TEstrazione::categoria_doc()
|
||||||
|
{
|
||||||
|
return ""; // todo:
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* TEstrazione::caus_sos(const TLocalisamfile& mov, TipoIVA acquisti)
|
||||||
|
{
|
||||||
|
if (acquisti == iva_acquisti)
|
||||||
|
{
|
||||||
|
TToken_string keys(mov.get(MOV_KEYFPPRO));
|
||||||
|
fppro_db().set_keys(keys);
|
||||||
|
return fppro_db().get_tipodoc();
|
||||||
|
}
|
||||||
|
if (acquisti == iva_vendite)
|
||||||
|
{
|
||||||
|
const TDocumento doc(mov.get(MOV_DPROVV)[0], mov.get_int(MOV_DANNO), mov.get(MOV_DCODNUM), mov.get_int(MOV_DNDOC));
|
||||||
|
static TString tipo_doc_sdi;
|
||||||
|
return tipo_doc_sdi = doc.tipo().tipo_doc_sdi();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
state_fppro TEstrazione::check_fppro(int numreg)
|
||||||
|
{
|
||||||
|
TLocalisamfile mov(LF_MOV);
|
||||||
|
mov.put(MOV_NUMREG, numreg);
|
||||||
|
if (mov.read() == NOERR && check_causale(mov.get(MOV_CODCAUS)))
|
||||||
|
{
|
||||||
|
// Controllo se ho i riferimenti all'FPPRO e verifico che sia tutto ok
|
||||||
|
const TString& keys_fppro = mov.get(MOV_KEYFPPRO);
|
||||||
|
if (keys_fppro.full())
|
||||||
|
{
|
||||||
|
TToken_string keys(keys_fppro, ';');
|
||||||
|
if (fppro_db().check_reg(keys, numreg))
|
||||||
|
return correct;
|
||||||
|
TString err(fppro_db().get_last_error());
|
||||||
|
if (!err.empty())
|
||||||
|
error_box(err.cut(0) << "Errore durante il controllo del movimento n. " << numreg << "\n" << err);
|
||||||
|
return reg_with_err;
|
||||||
|
}
|
||||||
|
else // Se non ho i riferimenti faccio guessing
|
||||||
|
{
|
||||||
|
if (fppro_db().guess_the_doc(mov))
|
||||||
|
return guessed;
|
||||||
|
return no_guessed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return not_fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TEstrazione::check_periodo_def() const
|
||||||
|
{
|
||||||
|
TString query;
|
||||||
|
// Controllo se ci sono estrazioni (definitive) che si sovrappongono di periodo (con lo stesso tipo) e che non siano in stato di errore
|
||||||
|
// Nel caso di stato di errore e' invece possibile la ri-estrazione
|
||||||
|
query << "SELECT *\nFROM F9DRD00K\n" <<
|
||||||
|
"WHERE " << DRD_DATAA << " >= '" << _head.dal.date2ansi() << "' AND " DRD_DATADA " <= '" << _head.al.date2ansi() << "' AND "
|
||||||
|
DRD_FLAG_PD " = 'D' AND\n " DRD_STATO " <> '" D_GEST_ERR "' AND " DRD_STATO " <> '" D_WA_ERR "' AND " DRD_STATO " <> '" D_ERR_SOS "' AND " DRD_TIPODOC " = '" << _head.tipo_doc << "';";
|
||||||
|
fp_db().sq_set_exec(query);
|
||||||
|
return fp_db().sq_items() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TEstrazione::is_doc_xml(const TLocalisamfile& mov)
|
||||||
|
{
|
||||||
|
const char provv = mov.get(MOV_DPROVV)[0];
|
||||||
|
const int anno = mov.get_int(MOV_DANNO);
|
||||||
|
const TString& codnum = mov.get(MOV_DCODNUM);
|
||||||
|
const int numdoc = mov.get_int(MOV_DNDOC);
|
||||||
|
|
||||||
|
const TDocumento doc(provv, anno, codnum, numdoc);
|
||||||
|
TString hfatt(20), bfatt(50), query;
|
||||||
|
if (chiave_paf(doc, hfatt, bfatt))
|
||||||
|
{
|
||||||
|
query << "SELECT * FROM PAF0100F WHERE P1_KEYHEADERFATT = '" << hfatt << "' AND P1_KEYBODYFATT = '" << bfatt << "';";
|
||||||
|
fp_db().sq_set_exec(query);
|
||||||
|
return fp_db().sq_items() > 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TString& TEstrazione::drd_attr()
|
||||||
|
{
|
||||||
|
static TString attr;
|
||||||
|
attr.cut(0) << DRD_CODSOC ", " DRD_ID_EST ", " DRD_FLAG_PD ", " DRD_DESC
|
||||||
|
", " DRD_TIPODOC ", " DRD_DATADA ", " DRD_DATAA ", " DRD_UTENTE ", " DRD_TIME ", "
|
||||||
|
DRD_STATO ", " DRD_PERC;
|
||||||
|
return attr;
|
||||||
|
}
|
||||||
|
|
||||||
|
TString& TEstrazione::drd_tovalues() const
|
||||||
|
{
|
||||||
|
static TString str;
|
||||||
|
return str.cut(0) << "'" << _head.cod_soc << "', '" << _head.id_estr << "', '" << (_head.flag_prov ? "P" : "D") << "', '" << _head.descr <<
|
||||||
|
"', '" << _head.tipo_doc << "', '" << _head.dal.date2ansi() << "', '" << _head.al.date2ansi() << "', '" << _head.user << "', CURRENT_TIMESTAMP, '" <<
|
||||||
|
_head.stato_estr << "', '" << _head.addr_cart << "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TEstrazione::new_extr() const
|
||||||
|
{
|
||||||
|
TString query;
|
||||||
|
query << "INSERT INTO " F9_DRD " ( " << drd_attr() << " ) \nVALUES ( " << drd_tovalues() << " );";
|
||||||
|
bool ok = fp_db().sq_set_exec(query);
|
||||||
|
ok = ok && fp_db().sq_commit();
|
||||||
|
if (!ok)
|
||||||
|
write_errorsql_log(query);
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TEstrazione::scrivi_testata_su_db() const
|
||||||
|
{
|
||||||
|
return new_extr();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TEstrazione::export_error_list() const
|
||||||
|
{
|
||||||
|
TF9_dberr dberr;
|
||||||
|
const vector<movimento_t>& movs = _movs;
|
||||||
|
bool ok = true;
|
||||||
|
int count = 0;
|
||||||
|
for (auto it = movs.begin(); it != movs.end(); ++it)
|
||||||
|
{
|
||||||
|
if (it->err)
|
||||||
|
{
|
||||||
|
#ifdef DBG
|
||||||
|
if (count == 25)
|
||||||
|
bool simo = true;
|
||||||
|
if (it->numreg == 187680)
|
||||||
|
bool simo = true;
|
||||||
|
#endif
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
string.replace("'", "''");
|
||||||
|
dberr.add(string);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dberr.add(); // Se vuoto metto NULL
|
||||||
|
}
|
||||||
|
if (!(ok &= dberr.send()))
|
||||||
|
break;
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
TString TEstrazione::next_estr_today(char tipo) const
|
||||||
|
{
|
||||||
|
char estr[] = { 0,0,0,0,0,0,0,0,0 };
|
||||||
|
TString query;
|
||||||
|
query << "SELECT TOP 1 " DRD_ID_EST " AS IDESTR\n"
|
||||||
|
"FROM " F9_DRD "\n"
|
||||||
|
"WHERE " DRD_ID_EST " LIKE '" << today.date2ansi() << "%'\n" <<
|
||||||
|
"ORDER BY " DRD_ID_EST " DESC";
|
||||||
|
fp_db().sq_set_exec(query);
|
||||||
|
|
||||||
|
const int last_estr = fp_db().sq_items() > 0 ? real(fp_db().sq_get("IDESTR").ltrim(10)).integer() : -1;
|
||||||
|
|
||||||
|
if (last_estr < -1 || last_estr == 99999999)
|
||||||
|
{
|
||||||
|
ofstream fout; fout.open("f9err_nextestr.txt");
|
||||||
|
if (fout.is_open())
|
||||||
|
{
|
||||||
|
fout << "Errore progressivo nuova estrazione!\n" << today << "\nn:" << last_estr << "\n" << query << "\n";
|
||||||
|
fout.close();
|
||||||
|
}
|
||||||
|
TString msg;
|
||||||
|
fatal_box(msg << "database error: progressivo nuova estrazione. Ultima estrazione: " << last_estr);
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf_s(estr, 9, "%08d", last_estr + 1);
|
||||||
|
return TString(estr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TEstrazione::write_errorsql_log(const TString& query) const
|
||||||
|
{
|
||||||
|
TString msg;
|
||||||
|
msg << query << "\n" <<
|
||||||
|
fp_db().sq_get_string_error() << "\n" <<
|
||||||
|
fp_db().sq_get_text_error();
|
||||||
|
if (_error_sql->is_open())
|
||||||
|
*_error_sql << msg << "\n\n";
|
||||||
|
#ifdef DBG
|
||||||
|
else
|
||||||
|
warning_box("Impossibile aprire il file f9_TEstrazione_error_sql.txt\nper scrivere errori scrittura db.");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Public methods /////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TEstrazione::add_mov(const movimento_t& movimento)
|
||||||
|
{
|
||||||
|
_movs.insert(_movs.end(), movimento);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TEstrazione::aggiorna_stato() const
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
TString query;
|
||||||
|
query << "UPDATE " F9_DRD "\n" \
|
||||||
|
"SET " DRD_STATO " = '" << _head.stato_estr << "'\n" \
|
||||||
|
"WHERE " DRD_CODSOC " = '" << _head.cod_soc << "'" \
|
||||||
|
" AND " DRD_ID_EST " = '" << _head.id_estr << "'" \
|
||||||
|
" AND " DRD_FLAG_PD " = '" << _head.flag_prov << "'";
|
||||||
|
ok = fp_db().sq_set_exec(query);
|
||||||
|
ok = ok && fp_db().sq_commit();
|
||||||
|
if (!ok)
|
||||||
|
write_errorsql_log(query);
|
||||||
|
} while (!ok && yesno_box("Impossibile aggiornare stato dell'estrazione.\nRiprovare?"));
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* TEstrazione::diagnostica_mov()
|
||||||
|
{
|
||||||
|
bool ok = true;
|
||||||
|
const TipoIVA tipo = get_tipoiva();
|
||||||
|
if (tipo == iva_acquisti)
|
||||||
|
{
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
if (!bar.add_status())
|
||||||
|
break;
|
||||||
|
|
||||||
|
movimento_t& mov_i = *it;
|
||||||
|
//const int numreg = row.get_int(cid2index(F_NUMREG));
|
||||||
|
const int numreg = mov_i.numreg;
|
||||||
|
switch (check_fppro(numreg))
|
||||||
|
{
|
||||||
|
case guessed:
|
||||||
|
ok &= fppro_db().associa_mov(numreg);
|
||||||
|
//row.add(fppro_db().get_keys_fppro());
|
||||||
|
case correct:
|
||||||
|
ok &= true;
|
||||||
|
mov_i.state = correct;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case not_fa:
|
||||||
|
mov_i.descr_err = "Non fattura";
|
||||||
|
mov_i.state = not_fa;
|
||||||
|
case reg_with_err:
|
||||||
|
mov_i.descr_err = "Registrazione con errori";
|
||||||
|
mov_i.state = reg_with_err;
|
||||||
|
case no_guessed:
|
||||||
|
ok &= false;
|
||||||
|
mov_i.err = true; // Mi segno il movimento che ha un problema
|
||||||
|
mov_i.descr_err = "Non associato a fattura elettr. abbinamento automatico non riuscito. Abbinare manualmente, o escludere";
|
||||||
|
mov_i.state = no_guessed;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (tipo == iva_vendite)
|
||||||
|
{
|
||||||
|
// Controlli per le fatture di vendita
|
||||||
|
|
||||||
|
// Vendite senza controlli.
|
||||||
|
// C'e' chi se le importa da altri gestionali!!! Sad :(
|
||||||
|
// Li mortacci loro!
|
||||||
|
// Bisogna pensare i casi in cui le fatture sono da escludere e non le posso escludere
|
||||||
|
// Ripensare esclusione vendite
|
||||||
|
|
||||||
|
TProgress_monitor bar(_movs.size(), "Controllo stato movimenti di vendita");
|
||||||
|
for (auto it = _movs.begin(); it != _movs.end(); ++it)
|
||||||
|
{
|
||||||
|
if (!bar.add_status())
|
||||||
|
break;
|
||||||
|
//TToken_string& row = *it;
|
||||||
|
movimento_t& row = *it;
|
||||||
|
TString numreg(row.numreg);
|
||||||
|
TLocalisamfile mov(LF_MOV);
|
||||||
|
mov.put(MOV_NUMREG, numreg);
|
||||||
|
mov.read();
|
||||||
|
// Controllo che abbia il riferimento al documento originale generatore del movimento
|
||||||
|
// todo: modificare controllo in base al flag in configurazione
|
||||||
|
if (mov.get(MOV_DPROVV).empty() || mov.get(MOV_DANNO).empty() || mov.get(MOV_DCODNUM).empty() || mov.get(MOV_DNDOC).empty())
|
||||||
|
{
|
||||||
|
row.err = true;
|
||||||
|
row.descr_err = "Movimento non collegato a un documento originale. Impossibile estrarre. Escludere?";
|
||||||
|
ok &= false;
|
||||||
|
}
|
||||||
|
else if (!is_doc_xml(mov)) // Quindi controllo che sia un documento xml, se no lo metto in errore e te lo escludi a mano, se e' da escludere
|
||||||
|
{
|
||||||
|
row.err = true;
|
||||||
|
row.descr_err = "Movimento collegato a un documento senza fatturazione elettronica. Escludere?";
|
||||||
|
ok &= false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_head.stato_estr = ok ? D_GEST_OK : D_GEST_ERR;
|
||||||
|
aggiorna_stato();
|
||||||
|
return _head.stato_estr;
|
||||||
|
}
|
||||||
|
|
||||||
|
result_estr TEstrazione::estrai()
|
||||||
|
{
|
||||||
|
// Se non c'e' nessun movimento non sto nemmeno a scrivere il record di estrazione.
|
||||||
|
// Se estrazione definitiva controllo che il periodo non si sovrapponga alle altre estrazioni def.
|
||||||
|
// Do' errore ed esco subito.
|
||||||
|
if (_movs.empty())
|
||||||
|
{
|
||||||
|
warning_box("Non esistono movimenti estraibili per il periodo selezionato.");
|
||||||
|
return estr_stop;
|
||||||
|
}
|
||||||
|
if (!_escluso && !_head.flag_prov && !check_periodo_def())
|
||||||
|
{
|
||||||
|
error_box("Attenzione e' stato inserito un periodo che si sovrappone\nad un'estrazione definitiva gia' esistente. Impossibile procedere.");
|
||||||
|
return estr_stop;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Non so come usare questi 18 caaratteri...
|
||||||
|
// Ci metto un po' di roba anche se sono dati gia' noti in altri campi (I know..) + un numero incrementale.
|
||||||
|
_head.id_estr.cut(0) << today.date2ansi() << (_head.flag_prov ? "P" : "D") << (!_escluso ? "N" : "X") <<
|
||||||
|
next_estr_today(_head.tipo_doc);
|
||||||
|
_head.user = user();
|
||||||
|
// Eseguo controllo sui movimenti e segno in testata lo stato
|
||||||
|
_head.stato_estr = IN_DIAGN; // "01" che verra' quasi subito rimpiazzato dal risultato della diagnostica.
|
||||||
|
if (_escluso)
|
||||||
|
set_dates(); // Se escluso imposto data inizio e fine uguali
|
||||||
|
|
||||||
|
// Scrivo record estrazione in stato '01'.
|
||||||
|
const bool ok = scrivi_testata_su_db();
|
||||||
|
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
TString msg;
|
||||||
|
msg << "Errore database: impossibile scrivere nuova estrazione.\n"
|
||||||
|
<< fp_db().sq_get_text_error(false);
|
||||||
|
error_box(msg);
|
||||||
|
return estr_err_db_drd;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Faccio partire la diagnostica e mi salvo il nuovo stato.
|
||||||
|
diagnostica_mov();
|
||||||
|
|
||||||
|
//_esclusi.clear();
|
||||||
|
//_esclusi.insert(_esclusi.end(), row);
|
||||||
|
if (_head.stato_estr == D_GEST_ERR)
|
||||||
|
{
|
||||||
|
warning_box("Attenzione l'estrazione ha prodotto degli errori.\n" \
|
||||||
|
"Controllare e correggere eventuali problemi\ndal Controllo Estrazione.");
|
||||||
|
// Se in errore, esporto lista errori sul db
|
||||||
|
if (!export_error_list())
|
||||||
|
warning_box("Errore scrittura db. Controllare log errori.");
|
||||||
|
return estr_diag_err; // Errore diagnostica gestionale
|
||||||
|
}
|
||||||
|
|
||||||
|
// Se va tutto ben fino a qui, posso andare a scrivere nella
|
||||||
|
// tabella IVA i movimenti.
|
||||||
|
return estrazione_iva() ? estr_ok : estr_err_db_iva;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TEstrazione::estrazione_iva(bool escluso)
|
||||||
|
{
|
||||||
|
bool stato = true;
|
||||||
|
TString query;
|
||||||
|
|
||||||
|
TProgress_monitor bar(_movs.size(), "Estrazione dati IVA");
|
||||||
|
for (auto it = _movs.begin(); it != _movs.end() && stato; ++it)
|
||||||
|
{
|
||||||
|
if (!bar.add_status())
|
||||||
|
break;
|
||||||
|
|
||||||
|
TLocalisamfile mov(LF_MOV);
|
||||||
|
TLocalisamfile cli(LF_CLIFO);
|
||||||
|
mov.put(MOV_NUMREG, it->numreg);
|
||||||
|
mov.read();
|
||||||
|
cli.put(CLI_TIPOCF, mov.get(MOV_TIPO));
|
||||||
|
cli.put(CLI_CODCF, mov.get(MOV_CODCF));
|
||||||
|
cli.read();
|
||||||
|
TString statopaiv; statopaiv << cli.get(CLI_STATOPAIV);
|
||||||
|
TString idfisc;
|
||||||
|
TString numdoc; numdoc << (mov.get(MOV_NUMDOCEXT).full() ? mov.get(MOV_NUMDOCEXT) : mov.get(MOV_NUMDOC));
|
||||||
|
if (statopaiv == "IT" || statopaiv.empty())
|
||||||
|
{
|
||||||
|
idfisc << "IT";
|
||||||
|
if (cli.get(CLI_PAIV).full()) // Se non ho la partita IVA e' privato quindi non metto niente solo cod. ISO
|
||||||
|
idfisc << cli.get(CLI_PAIV);
|
||||||
|
}
|
||||||
|
else idfisc << statopaiv << cli.get(CLI_COFI); // Esteri
|
||||||
|
|
||||||
|
query.cut(0) << "INSERT INTO " F9_IVA " (\n"
|
||||||
|
IVA_CODSOC ", " IVA_IDLAN ", " IVA_FLAG_PD ",\n"
|
||||||
|
IVA_ANNOES ", " IVA_GIVA ", " IVA_TIPOG ",\n"
|
||||||
|
IVA_DOCXML ", " IVA_TIPOCF ", " IVA_CODCF ",\n"
|
||||||
|
IVA_RAGSOC ", " IVA_IDFISC ", " IVA_PIVA ",\n"
|
||||||
|
IVA_CODFIS ", " IVA_CATDOC ", " IVA_CAUSSOS ",\n"
|
||||||
|
IVA_NUMDOC ", " IVA_DATADOC ", " IVA_SEZIVA ",\n"
|
||||||
|
IVA_TIPOREG ", " IVA_NPROT ", " IVA_DATPROT;
|
||||||
|
/*if(is_autofattura(mov))
|
||||||
|
{
|
||||||
|
query << ",\n"
|
||||||
|
IVA_FORNOR ", " IVA_REGOR ", " IVA_NUMOR ", " IVA_DATAOR;
|
||||||
|
}*/
|
||||||
|
query << ",\n"
|
||||||
|
IVA_CLASDOC ", " IVA_USERELA ", " IVA_TIMEELA;
|
||||||
|
if (_head.tipo_doc == 'A')
|
||||||
|
{
|
||||||
|
query << ",\n"
|
||||||
|
IVA_TIPPROT ", " IVA_NUMPROT ", " IVA_ANNPROT ", " IVA_TIMERIC;
|
||||||
|
}
|
||||||
|
const long datadoc = mov.get_date(MOV_DATADOC).date2ansi();
|
||||||
|
const long datareg = mov.get_date(MOV_DATAREG).date2ansi();
|
||||||
|
|
||||||
|
const TString& name_reg = TRegistro(TCausale(mov.get(MOV_CODCAUS)).reg()).name();
|
||||||
|
query << "\n)\n" <<
|
||||||
|
"VALUES (\n" <<
|
||||||
|
"'" << _head.cod_soc << "', '" << _head.id_estr << "', '" << (_head.flag_prov ? "P" : "D") << "',\n" <<
|
||||||
|
"'" << mov.get(MOV_ANNOES) << "', '" << _head.tipo_doc << "', '" << name_reg << "',\n" <<
|
||||||
|
"'" << 'S' << "', '" << mov.get(MOV_TIPO) << "', '" << mov.get(MOV_CODCF) << "',\n" <<
|
||||||
|
"'" << check_str(cli.get(CLI_RAGSOC)) << "', '" << idfisc << "', '" << cli.get(CLI_PAIV) << "',\n" <<
|
||||||
|
"'" << cli.get(CLI_COFI) << "', '" << categoria_doc() << "', '" << caus_sos(mov, get_tipoiva()) << "',\n" <<
|
||||||
|
"'" << numdoc << "', '" << datadoc << "', '" << mov.get(MOV_REG) << "',\n" <<
|
||||||
|
"'" << "" << "', '" << mov.get(MOV_PROTIVA) << "', '" << datareg << "'";
|
||||||
|
//if (is_autofattura(mov))
|
||||||
|
//{
|
||||||
|
// query << ",\n" <<
|
||||||
|
// "'" << "" << "', '" << "" << "', '" << "N ORI" << "', '" << "20010101" << "'";
|
||||||
|
//}
|
||||||
|
query << ",\n" <<
|
||||||
|
"'" << (_head.tipo_doc == 'A' ? "FTA" : "FTV") << "', '" << user() << "', " << "GETDATE()";
|
||||||
|
if (_head.tipo_doc == 'A')
|
||||||
|
{
|
||||||
|
TToken_string keys(mov.get(MOV_KEYFPPRO), ';');
|
||||||
|
fppro_db().set_keys(keys);
|
||||||
|
query << ",\n" <<
|
||||||
|
"'" << fppro_db().get_tipoprot() << "', '" << fppro_db().get_numprot() << "', '" << fppro_db().get_annoprot() << "', '" << fppro_db().get_dataoraric() << "'";
|
||||||
|
}
|
||||||
|
query << "\n)";
|
||||||
|
const bool ok = fp_db().sq_set_exec(query);
|
||||||
|
if (!ok)
|
||||||
|
write_errorsql_log(query);
|
||||||
|
|
||||||
|
stato &= ok;
|
||||||
|
}
|
||||||
|
return stato;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TEstrazione::set_dates()
|
||||||
|
{
|
||||||
|
if (_escluso)
|
||||||
|
{
|
||||||
|
set_dataini(_movs[0].datareg);
|
||||||
|
set_dataend(_movs[0].datareg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEstrazione::TEstrazione(const TString& ambiente, const bool flag_prov, const char tipodoc, const TString& descr,
|
||||||
|
const TString& addrcart, const bool escluso, const TDate* const dal, const TDate* const al) : _descr(descr)
|
||||||
|
{
|
||||||
|
_head.cod_soc = ambiente;
|
||||||
|
_head.flag_prov = flag_prov;
|
||||||
|
_head.descr = descr;
|
||||||
|
_head.tipo_doc = tipodoc;
|
||||||
|
if (!escluso && dal != nullptr && al != nullptr)
|
||||||
|
{
|
||||||
|
_head.dal = *dal;
|
||||||
|
_head.al = *al;
|
||||||
|
}
|
||||||
|
_head.addr_cart = addrcart;
|
||||||
|
|
||||||
|
_escluso = escluso;
|
||||||
|
|
||||||
|
_error_sql = new fstream;
|
||||||
|
_error_sql->open("f9_TEstrazione_error_sql.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// TF9_dberr
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TF9_dberr::add_str(const TString& string)
|
||||||
|
{
|
||||||
|
_insert.rtrim(1);
|
||||||
|
if (_insert[_insert.len() - 1] != '(')
|
||||||
|
_insert << ", ";
|
||||||
|
_insert << string << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
void TF9_dberr::write_sqlerrlog(const TString& query) const
|
||||||
|
{
|
||||||
|
if (_fout->is_open())
|
||||||
|
{
|
||||||
|
TString msg;
|
||||||
|
msg << query << "\n" <<
|
||||||
|
fp_db().sq_get_string_error() << "\n" <<
|
||||||
|
fp_db().sq_get_text_error();
|
||||||
|
*_fout << msg << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TF9_dberr::add(const TString& string)
|
||||||
|
{
|
||||||
|
TString str;
|
||||||
|
add_str(str << "'" << string << "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TF9_dberr::add(const long num)
|
||||||
|
{
|
||||||
|
TString app;
|
||||||
|
app << num;
|
||||||
|
add(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TF9_dberr::send()
|
||||||
|
{
|
||||||
|
fp_db().sq_set_exec(_insert);
|
||||||
|
write_sqlerrlog(_insert);
|
||||||
|
_insert.cut(0) << "INSERT INTO " F9_ERR " VALUES ()";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TF9_dberr::del_err(const TString& id_estr, int numreg)
|
||||||
|
{
|
||||||
|
TString query;
|
||||||
|
query << "DELETE FROM " F9_ERR " WHERE IDESTR = '" << id_estr << "' AND NUMREG = '" << numreg << "';";
|
||||||
|
fp_db().sq_set_exec(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
char TF9_dberr::get_errori(const TString& id_estr, vector<TToken_string>& controllo_mov)
|
||||||
|
{
|
||||||
|
TString query;
|
||||||
|
query << "SELECT * FROM " F9_ERR " WHERE IDESTR = '" << id_estr << "';";
|
||||||
|
fp_db().sq_set_exec(query, false);
|
||||||
|
for (bool ok = fp_db().sq_next(); ok; ok = fp_db().sq_next())
|
||||||
|
{
|
||||||
|
TToken_string row("", '|');
|
||||||
|
row.add("X");
|
||||||
|
for (int i = 1; i < 15; i++)
|
||||||
|
{
|
||||||
|
if (fp_db().sq_get_type_field(i) == _datefld)
|
||||||
|
row.add(fp_db().sq_get_date(fp_db().sq_get_name_field(i)));
|
||||||
|
else
|
||||||
|
row.add(fp_db().sq_get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
controllo_mov.insert(controllo_mov.end(), row);
|
||||||
|
}
|
||||||
|
query.cut(0) << "SELECT " DRD_TIPODOC " FROM " F9_DRD "\n" <<
|
||||||
|
"WHERE " DRD_ID_EST " = '" << id_estr << "'";
|
||||||
|
fp_db().sq_set_exec(query);
|
||||||
|
return fp_db().sq_get((unsigned)0)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
TF9_dberr::TF9_dberr()
|
||||||
|
{
|
||||||
|
_insert.cut(0) << "INSERT INTO " F9_ERR " VALUES ()";
|
||||||
|
_fout = new ofstream;
|
||||||
|
_fout->open("f9_dberr.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
const char* check_str(const TString& str)
|
||||||
|
{
|
||||||
|
static TString n_str; n_str.cut(0) << str;
|
||||||
|
n_str.replace("'", "\'\'");
|
||||||
|
n_str.replace(" ", " ");
|
||||||
|
return (const char*)n_str;
|
||||||
|
}
|
202
src/f9/f9lib01.h
Normal file
202
src/f9/f9lib01.h
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
#ifndef __F901001H__
|
||||||
|
#define __F901001H__
|
||||||
|
|
||||||
|
#include "strings.h"
|
||||||
|
#include "date.h"
|
||||||
|
#include "real.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <cglib01.h>
|
||||||
|
|
||||||
|
const TDate today(TODAY);
|
||||||
|
|
||||||
|
struct drd
|
||||||
|
{
|
||||||
|
TString cod_soc;
|
||||||
|
TString id_estr;
|
||||||
|
bool flag_prov{ true };
|
||||||
|
TString descr;
|
||||||
|
char tipo_doc{ 'A' };
|
||||||
|
TDate dal;
|
||||||
|
TDate al;
|
||||||
|
TString user;
|
||||||
|
TString timestamp;
|
||||||
|
TString4 stato_estr{ "01" };
|
||||||
|
TString addr_cart;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum result_estr
|
||||||
|
{
|
||||||
|
estr_ok = 1, // Estrazione e' avvenuta senza errori.
|
||||||
|
estr_err_db_iva = 0, // Errore scrittura database iva.
|
||||||
|
estr_stop = -1, // Non esistono movimenti estraibili in quel periodo, o periodo sovrapposto ad altra estrazione.
|
||||||
|
estr_diag_err = -2, // La diagnostica ha riportato errori.
|
||||||
|
estr_err_db_drd = -99 // Errore scrittura F9DRD.
|
||||||
|
};
|
||||||
|
|
||||||
|
enum state_fppro
|
||||||
|
{
|
||||||
|
correct = 1,
|
||||||
|
reg_with_err = -1,
|
||||||
|
not_fa = -10, // Non e' fattura acquisti
|
||||||
|
guessed = 100,
|
||||||
|
no_guessed = 0,
|
||||||
|
null_state = -100
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _movimento_t
|
||||||
|
{
|
||||||
|
bool err;
|
||||||
|
int numreg;
|
||||||
|
TDate datareg;
|
||||||
|
TDate datadoc;
|
||||||
|
TString codcaus;
|
||||||
|
int meseliq;
|
||||||
|
TString numdoc;
|
||||||
|
real tot;
|
||||||
|
int codcf;
|
||||||
|
TString ragsoc;
|
||||||
|
TString reg_protiva;
|
||||||
|
TString descr;
|
||||||
|
state_fppro state;
|
||||||
|
TString descr_err;
|
||||||
|
|
||||||
|
TString get(int i) const
|
||||||
|
{
|
||||||
|
TString a;
|
||||||
|
switch (i)
|
||||||
|
{
|
||||||
|
case 0: return err;
|
||||||
|
case 1: return a << numreg;
|
||||||
|
case 2: return (const char*)datareg;
|
||||||
|
case 3: return (const char*)datadoc;
|
||||||
|
case 4: return codcaus;
|
||||||
|
case 5: return a << meseliq;
|
||||||
|
case 6: return numdoc;
|
||||||
|
case 7:
|
||||||
|
a << tot;
|
||||||
|
if (a == "0")
|
||||||
|
a << ".0";
|
||||||
|
return a;
|
||||||
|
case 8: return a << codcf;
|
||||||
|
case 9: return ragsoc;
|
||||||
|
case 10: return reg_protiva;
|
||||||
|
case 11: return descr;
|
||||||
|
case 14: return descr_err;
|
||||||
|
default: return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} movimento_t;
|
||||||
|
|
||||||
|
class TEstrazione : public TObject
|
||||||
|
{
|
||||||
|
drd _head;
|
||||||
|
vector<movimento_t> _movs;
|
||||||
|
fstream* _error_sql;
|
||||||
|
bool _escluso;
|
||||||
|
const TString _descr;
|
||||||
|
|
||||||
|
/** Aggiorna stato estrazione. Utilizzato ad esempio dopo la diagnostica per riportare
|
||||||
|
* il nuovo stato sul db.
|
||||||
|
*/
|
||||||
|
void aggiorna_stato() const;
|
||||||
|
static const char* categoria_doc();
|
||||||
|
static const char* caus_sos(const TLocalisamfile& mov, TipoIVA acquisti);
|
||||||
|
/** CHECK RIFERIMENTO FPPRO
|
||||||
|
* Per le fatture di acquisto controllo se ho il riferimento nell'FPPRO.
|
||||||
|
* Altrimenti cerco di capire se riesco a trovare il corrispondente del movimento
|
||||||
|
* nell'FPPRO ("Guessing").
|
||||||
|
* \return \a correct se ho gia' il riferimento e corrisponde effettivamente.
|
||||||
|
* \return \a reg_with_err se ho il riferimento ma la corrispondenza e' sbagliata.
|
||||||
|
* \return \a guessed se non ho il riferimento ma sono riuscito a trovarlo a manina.
|
||||||
|
* \return \a no_guessed se non avevo il riferimento e non sono riuscito a trovarlo.
|
||||||
|
* \return \a not_fa se il movimento passato non è una fattura.
|
||||||
|
*/
|
||||||
|
static state_fppro check_fppro(int numreg);
|
||||||
|
bool check_periodo_def() const;
|
||||||
|
TipoIVA get_tipoiva() const { return _head.tipo_doc == 'A' ? iva_acquisti : iva_vendite; }
|
||||||
|
static bool is_doc_xml(const TLocalisamfile& mov);
|
||||||
|
|
||||||
|
static TString& drd_attr();
|
||||||
|
TString& drd_tovalues() const;
|
||||||
|
bool new_extr() const; /**< See \a scrivi_testata_su_db(). */
|
||||||
|
bool scrivi_testata_su_db() const; /**< Scrittura testata estrazione. Tabella F9DRD. Chiama \a new_extr(). */
|
||||||
|
bool export_error_list() const; /**< Esporta sheet controllo fatture sul db. */
|
||||||
|
|
||||||
|
/** 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;
|
||||||
|
void write_errorsql_log(const TString& query) const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
void add_mov(const movimento_t& movimento);
|
||||||
|
/** 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.
|
||||||
|
* Automaticamente aggiorna lo stato nella dell'estrazione, anche sul db (chiama /a aggiorna_stato()).
|
||||||
|
*
|
||||||
|
* \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* diagnostica_mov();
|
||||||
|
/** Estrazione per pacchetti "normali" (non da esclusi).
|
||||||
|
* Viene chiamata dall'handler estrai_handler: bottone estrai nella maschera estrazione.
|
||||||
|
*
|
||||||
|
* \return estr_ok (1) Se l'estrazione e' avvenuta senza errori.
|
||||||
|
* \return estr_err_db_iva (0) Errore scrittura database iva.
|
||||||
|
* \return estr_stop (-1) Non esistono movimenti estraibili in quel periodo, o periodo sovrapposto ad altra estrazione.
|
||||||
|
* \return estr_diag_err (-2) La diagnostica ha riportato errori.
|
||||||
|
* \return estr_err_db_drd (-99) Errore scrittura F9DRD. */
|
||||||
|
result_estr estrai();
|
||||||
|
/** 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);
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
TString get_id_estr() const { return _head.id_estr; }
|
||||||
|
TString4 get_stato_estr() const { return _head.stato_estr; }
|
||||||
|
const vector<movimento_t>& get_movs() const { return _movs; }
|
||||||
|
|
||||||
|
// Setters
|
||||||
|
void set_provvisorio(bool flag_prov) { _head.flag_prov = flag_prov; }
|
||||||
|
void set_dataini(const TDate& dal) { _head.dal = dal; }
|
||||||
|
void set_dataend(const TDate& al) { _head.al = al; }
|
||||||
|
void set_dates(); // Solo se e' escluso
|
||||||
|
void set_tipodoc(char tipodoc) { _head.tipo_doc = tipodoc; }
|
||||||
|
void set_ambiente(const TString& ambiente) { _head.cod_soc = ambiente; }
|
||||||
|
void set_descr(const TString& descr) { _head.descr = descr; }
|
||||||
|
void set_addrcart(const TString& addrcart) { _head.addr_cart = addrcart; }
|
||||||
|
|
||||||
|
TEstrazione(const TString& ambiente, bool flag_prov, char tipodoc, const TString& descr, const TString& addrcart,
|
||||||
|
bool escluso, const TDate* dal = nullptr, const TDate* al = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class TF9_dberr
|
||||||
|
{
|
||||||
|
TString _str;
|
||||||
|
TString _insert;
|
||||||
|
ofstream* _fout;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void add_str(const TString& string);
|
||||||
|
void write_sqlerrlog(const TString& query) const;
|
||||||
|
public:
|
||||||
|
void add(const TString& string);
|
||||||
|
void add(const TDate& date) { add(date.date2ansi()); }
|
||||||
|
void add(const char* string) { add(TString(string)); }
|
||||||
|
void add(long num);
|
||||||
|
void add() { add_str("NULL"); }
|
||||||
|
bool send();
|
||||||
|
static void del_err(const TString& id_estr, int numreg);
|
||||||
|
static char get_errori(const TString& id_estr, vector<TToken_string>& controllo_mov);
|
||||||
|
TF9_dberr();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // #ifndef __F901001H__
|
Loading…
x
Reference in New Issue
Block a user