Patch level : 12.0 964
Files correlati : ba0.exe f90.exe f90100d.msk f90200a.msk f90300a.msk f90300b.msk f181.dir f181.trr f181.des f183.dir f183.trr f183.des Commento : - Aggiunto tabella (f183) per gli annessi - Corretto costruzione codice identificativo (idfiscale) - Aggiunta barra progresso salvataggio informazioni strazione - Aggiunto controllo per movimenti di sola iva esclusi a priori dalle estrazioni - Aggiunto caricamento per i movimenti del nomefile per cartacei - Aggiunto caricamento per i movimenti degli annessi - Se estrazione iva fallisce aggiorna stato estrazione in errore diag. gest. - Migliorata notevolmente leggibilita' codice per costruzione query inserimento record IVA con una simil-prepared-statement - Aggiunta esportazione annessi in IVA - Modificata esportazione errore db movimento se data documento e' 0 mette 0001-01-01 altrimenti va in errore l'inserimento del record e non viene scritto. - Implementate funzioni per leggere direttamente dalle categorie documentali e annessi con la costruzione immediata di sheet da visualizzare - Corrette tutte le causali che ora richiedono l'anno. - Implementate classi per la gestione dei file cartacei (doc e annessi) - Corretta apertura maschera apri estr. e scrittura sheet delle due pagine - Corretta visualizzazione ragione sociale negli sheet: prendeva info cliente da un campo sbagliato e visualizzava una ragsoc sbagliata. - Corretta eliminazione estrazione per la tabella F9ERROR - Aggiunta associazione annessi per ogni catdoc - Aggiunta pagina annessi in gestione file cartacei - Aggiunta importazione file per annessi selezionando cat padre e cat annesso
This commit is contained in:
parent
7f4c7d0528
commit
fdf4bd821f
@ -162,6 +162,8 @@
|
||||
<ClInclude Include="..\src\include\expr.h" />
|
||||
<ClInclude Include="..\src\include\extcdecl.h" />
|
||||
<ClInclude Include="..\src\include\extctype.h" />
|
||||
<ClInclude Include="..\src\include\docf9.h" />
|
||||
<ClInclude Include="..\src\include\annessif9.h" />
|
||||
<ClInclude Include="..\src\include\fieldbuf.h" />
|
||||
<ClInclude Include="..\src\include\files.h" />
|
||||
<ClInclude Include="..\src\include\filetext.h" />
|
||||
|
@ -517,6 +517,12 @@
|
||||
<ClInclude Include="..\src\include\bagn006.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\include\docf9.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\include\annessif9.h">
|
||||
<Filter>Headers</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\include\about.cpp">
|
||||
@ -776,8 +782,5 @@
|
||||
<Library Include="..\lib\xvtdb.lib">
|
||||
<Filter>Libraries</Filter>
|
||||
</Library>
|
||||
<Library Include="..\exe\Cb6.lib">
|
||||
<Filter>Libraries</Filter>
|
||||
</Library>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -190,6 +190,7 @@
|
||||
<ClCompile Include="..\src\f9\f90.cpp" />
|
||||
<ClCompile Include="..\src\f9\f90100.cpp" />
|
||||
<ClCompile Include="..\src\f9\f90300.cpp" />
|
||||
<ClCompile Include="..\src\f9\f90400.cpp" />
|
||||
<ClCompile Include="..\src\f9\f9lib01.cpp" />
|
||||
<ClCompile Include="..\src\f9\f90200.cpp" />
|
||||
<ClCompile Include="..\src\f9\f9lib02.cpp">
|
||||
@ -217,6 +218,7 @@
|
||||
<MskCompiler Include="..\src\f9\f90200a.uml" />
|
||||
<MskCompiler Include="..\src\f9\f90300a.uml" />
|
||||
<MskCompiler Include="..\src\f9\f90300b.uml" />
|
||||
<MskCompiler Include="..\src\f9\f90300c.uml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<SqlCompiler Include="..\src\f9\sql\f90100.sql">
|
||||
@ -233,12 +235,15 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<DesCompiler Include="..\src\f9\d181.des" />
|
||||
<DesCompiler Include="..\src\f9\d183.des" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<DirCompiler Include="..\src\f9\f181.dir" />
|
||||
<DirCompiler Include="..\src\f9\f183.dir" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TrrCompiler Include="..\src\f9\f181.trr" />
|
||||
<TrrCompiler Include="..\src\f9\f183.trr" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MenCompiler Include="..\src\fp\fpmenu.men" />
|
||||
|
@ -77,6 +77,9 @@
|
||||
<ClCompile Include="..\src\f9\f9lib02.cpp">
|
||||
<Filter>Sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\f9\f90400.cpp">
|
||||
<Filter>Sources</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MskCompiler Include="..\src\f9\f90100a.uml">
|
||||
@ -100,6 +103,9 @@
|
||||
<MskCompiler Include="..\src\f9\f90300b.uml">
|
||||
<Filter>Masks</Filter>
|
||||
</MskCompiler>
|
||||
<MskCompiler Include="..\src\f9\f90300c.uml">
|
||||
<Filter>Masks</Filter>
|
||||
</MskCompiler>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<SqlCompiler Include="..\src\f9\sql\f90100.sql">
|
||||
@ -116,16 +122,25 @@
|
||||
<DesCompiler Include="..\src\f9\d181.des">
|
||||
<Filter>Recdesc</Filter>
|
||||
</DesCompiler>
|
||||
<DesCompiler Include="..\src\f9\d183.des">
|
||||
<Filter>Recdesc</Filter>
|
||||
</DesCompiler>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<DirCompiler Include="..\src\f9\f181.dir">
|
||||
<Filter>Recdesc</Filter>
|
||||
</DirCompiler>
|
||||
<DirCompiler Include="..\src\f9\f183.dir">
|
||||
<Filter>Recdesc</Filter>
|
||||
</DirCompiler>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TrrCompiler Include="..\src\f9\f181.trr">
|
||||
<Filter>Recdesc</Filter>
|
||||
</TrrCompiler>
|
||||
<TrrCompiler Include="..\src\f9\f183.trr">
|
||||
<Filter>Recdesc</Filter>
|
||||
</TrrCompiler>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MenCompiler Include="..\src\fp\fpmenu.men">
|
||||
|
8
exe/recdesc/d183.des
Normal file
8
exe/recdesc/d183.des
Normal file
@ -0,0 +1,8 @@
|
||||
[FieldDescr]
|
||||
CATDOCANN = Categoria documentale annesso
|
||||
CATDOCPAD = Categoria documentale padre (appartenenza annesso)
|
||||
FILENAME = Nome del file (senza indirizzo)
|
||||
LOADDATE = Data caricamento
|
||||
NUMREG = Numero di registrazione associato
|
||||
USER = Utente che ha caricato il file
|
||||
|
@ -1,3 +1,3 @@
|
||||
181
|
||||
0
|
||||
$docf9|7|7|96|0|Associazione doc cartacei / mov per f9|||
|
||||
$docf9|3|3|96|0|Associazione doc cartacei / mov per f9|||
|
||||
|
@ -1,9 +1,10 @@
|
||||
181
|
||||
4
|
||||
NUMREG|3|7|0|Numero di registrazione associato
|
||||
FILENAME|1|64|0|Nome del file (senza indirizzo)
|
||||
LOADDATE|5|8|0|Data caricamento
|
||||
NUMREG|3|7|0|Numero di registrazione associato
|
||||
USER|1|16|0|Utente che ha caricato il file
|
||||
2
|
||||
3
|
||||
NUMREG|
|
||||
FILENAME|
|
||||
FILENAME+NUMREG|X
|
||||
|
3
exe/recdesc/f183.dir
Normal file
3
exe/recdesc/f183.dir
Normal file
@ -0,0 +1,3 @@
|
||||
183
|
||||
0
|
||||
$annessif9|9|9|116|0|Tabella file annessi F9|||
|
11
exe/recdesc/f183.trr
Normal file
11
exe/recdesc/f183.trr
Normal file
@ -0,0 +1,11 @@
|
||||
183
|
||||
6
|
||||
NUMREG|3|7|0|Numero di registrazione associato
|
||||
FILENAME|1|64|0|Nome del file (senza indirizzo)
|
||||
CATDOCPAD|1|10|0|Categoria documentale padre (appartenenza annesso)
|
||||
CATDOCANN|1|10|0|Categoria documentale annesso
|
||||
LOADDATE|5|8|0|Data caricamento
|
||||
USER|1|16|0|Utente che ha caricato il file
|
||||
2
|
||||
NUMREG+FILENAME|
|
||||
FILENAME|X
|
@ -21,6 +21,22 @@ TFppro& fppro_db()
|
||||
return *fppro;
|
||||
}
|
||||
|
||||
bool TFppro::sql_inj(const TString& str)
|
||||
{
|
||||
TString appo; appo << str;
|
||||
appo.upper();
|
||||
return appo.contains("--") || appo.contains("SELECT") || appo.contains("DELETE") || appo.contains("DROP");
|
||||
}
|
||||
|
||||
bool TFppro::sql_inj(const keys_s& keys)
|
||||
{
|
||||
TToken_string str("", ';');
|
||||
str.add(keys.prginvio);
|
||||
str.add(keys.headerfatt);
|
||||
str.add(keys.bodyfatt);
|
||||
return sql_inj(str) || str.contains("'") || str.contains("\\");
|
||||
}
|
||||
|
||||
bool TFppro::check_reg(TToken_string& keys, int numreg)
|
||||
{
|
||||
return get_numreg(keys) == numreg;
|
||||
@ -124,29 +140,36 @@ real TFppro::get_ritenute() const
|
||||
|
||||
TFppro& TFppro::set_keys(TToken_string& keys)
|
||||
{
|
||||
if(keys.items() == 3)
|
||||
{
|
||||
_keys.prginvio = keys.get(0);
|
||||
_keys.headerfatt = keys.get(1);
|
||||
_keys.bodyfatt = keys.get(2);
|
||||
_is_set = false;
|
||||
_keys_setted = true;
|
||||
}
|
||||
else
|
||||
_keys_setted = false;
|
||||
return *this;
|
||||
if (keys.items() == 3)
|
||||
{
|
||||
const keys_s k = { keys.get(0), keys.get(1), keys.get(2) };
|
||||
return set_keys(k);
|
||||
}
|
||||
_is_set = false;
|
||||
_keys_setted = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
TFppro& TFppro::set_keys(const keys_s& keys)
|
||||
{
|
||||
if(*keys.prginvio != 0 && *keys.headerfatt != 0 && *keys.bodyfatt != 0)
|
||||
{
|
||||
_keys = keys;
|
||||
_is_set = false;
|
||||
_keys_setted = true;
|
||||
}
|
||||
_is_set = false;
|
||||
_keys_setted = false;
|
||||
if (sql_inj(keys))
|
||||
{
|
||||
TString msg; msg << "Database error: Possibile SQL INJECTION:\n" << keys;
|
||||
//throw std::exception(msg);
|
||||
error_box(msg);
|
||||
_last_error.cut(0) << msg;
|
||||
}
|
||||
else if (!keys.prginvio.empty() && !keys.headerfatt.empty() && !keys.bodyfatt.empty())
|
||||
{
|
||||
_keys = keys;
|
||||
_keys_setted = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_last_error.cut(0) << "Chiavi settate non valide:\n" << keys;
|
||||
_keys_setted = false;
|
||||
}
|
||||
_is_set = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -246,6 +269,14 @@ int TFppro::get_numregcont() const
|
||||
return _db->sq_get_int("PZ_NUMREGCONT");
|
||||
}
|
||||
|
||||
TString TFppro::get_last_error(bool clear)
|
||||
{
|
||||
TString l(_last_error);
|
||||
if(clear)
|
||||
_last_error.cut(0);
|
||||
return l;
|
||||
}
|
||||
|
||||
bool TFppro::set_query()
|
||||
{
|
||||
if (_keys_setted)
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef _F1LIBH_
|
||||
#define _F1LIBH_
|
||||
#ifndef _F1LIB_H_
|
||||
#define _F1LIB_H_
|
||||
|
||||
#include "strings.h"
|
||||
#include "reputils.h"
|
||||
@ -31,6 +31,12 @@ typedef struct _prot_s
|
||||
int anno;
|
||||
} prot_s;
|
||||
|
||||
|
||||
/** \class TFppro
|
||||
* Tutti i metodi che settano le chiavi, possono fallire principalmente per due motivi:
|
||||
* 1) Possbile SQL Injection;
|
||||
* 2) Chiavi settate non valide (una delle tre e' vuota).
|
||||
*/
|
||||
class TFppro : public TObject
|
||||
{
|
||||
struct keys_s
|
||||
@ -38,13 +44,25 @@ class TFppro : public TObject
|
||||
TString prginvio;
|
||||
TString headerfatt;
|
||||
TString bodyfatt;
|
||||
|
||||
operator const char*() const
|
||||
{
|
||||
static TToken_string a("", ';');
|
||||
a.add(prginvio);
|
||||
a.add(headerfatt);
|
||||
a.add(bodyfatt);
|
||||
return a;
|
||||
}
|
||||
} _keys;
|
||||
|
||||
SSimple_query* _db;
|
||||
bool _keys_setted;
|
||||
bool _is_set;
|
||||
bool _is_set; // Query is setted
|
||||
TString _fppro_query;
|
||||
TString _last_error;
|
||||
|
||||
static bool sql_inj(const TString& str);
|
||||
static bool sql_inj(const keys_s& keys);
|
||||
public:
|
||||
const char* where_str() const;
|
||||
|
||||
@ -62,6 +80,8 @@ public:
|
||||
TDate get_data_first_doc() const;
|
||||
TDate get_dataorarioric() const;
|
||||
int get_numregcont() const;
|
||||
|
||||
TString get_last_error(bool clear = true);
|
||||
// Setters
|
||||
bool set_query();
|
||||
TFppro& set_keys(TToken_string& keys);
|
||||
@ -75,7 +95,7 @@ public:
|
||||
const char* get_tipodoc() const;
|
||||
|
||||
TFppro();
|
||||
TFppro(TToken_string& keys) : TFppro() { set_keys(keys); }
|
||||
TFppro(TToken_string& keys) : TFppro() { set_keys(keys); }
|
||||
};
|
||||
|
||||
class TProtocollo : TObject
|
||||
@ -134,4 +154,5 @@ bool check_causale(const TString& cod_caus, bool acq = true);
|
||||
bool check_causale(const TString& cod_caus, const TString& tipo_doc, bool acq = true);
|
||||
bool check_caus_has_rit(const TString& cod_caus, bool rit);
|
||||
void run_cont_ini(bool liq);
|
||||
#endif
|
||||
|
||||
#endif // _F1LIB_H_
|
8
src/f9/d183.des
Normal file
8
src/f9/d183.des
Normal file
@ -0,0 +1,8 @@
|
||||
[FieldDescr]
|
||||
CATDOCANN = Categoria documentale annesso
|
||||
CATDOCPAD = Categoria documentale padre (appartenenza annesso)
|
||||
FILENAME = Nome del file (senza indirizzo)
|
||||
LOADDATE = Data caricamento
|
||||
NUMREG = Numero di registrazione associato
|
||||
USER = Utente che ha caricato il file
|
||||
|
@ -1,3 +1,3 @@
|
||||
181
|
||||
0
|
||||
$docf9|7|7|96|0|Associazione doc cartacei / mov per f9|||
|
||||
$docf9|3|3|96|0|Associazione doc cartacei / mov per f9|||
|
||||
|
@ -1,9 +1,10 @@
|
||||
181
|
||||
4
|
||||
NUMREG|3|7|0|Numero di registrazione associato
|
||||
FILENAME|1|64|0|Nome del file (senza indirizzo)
|
||||
LOADDATE|5|8|0|Data caricamento
|
||||
NUMREG|3|7|0|Numero di registrazione associato
|
||||
USER|1|16|0|Utente che ha caricato il file
|
||||
2
|
||||
3
|
||||
NUMREG|
|
||||
FILENAME|
|
||||
FILENAME+NUMREG|X
|
||||
|
3
src/f9/f183.dir
Normal file
3
src/f9/f183.dir
Normal file
@ -0,0 +1,3 @@
|
||||
183
|
||||
0
|
||||
$annessif9|9|9|116|0|Tabella file annessi F9|||
|
11
src/f9/f183.trr
Normal file
11
src/f9/f183.trr
Normal file
@ -0,0 +1,11 @@
|
||||
183
|
||||
6
|
||||
NUMREG|3|7|0|Numero di registrazione associato
|
||||
FILENAME|1|64|0|Nome del file (senza indirizzo)
|
||||
CATDOCPAD|1|10|0|Categoria documentale padre (appartenenza annesso)
|
||||
CATDOCANN|1|10|0|Categoria documentale annesso
|
||||
LOADDATE|5|8|0|Data caricamento
|
||||
USER|1|16|0|Utente che ha caricato il file
|
||||
2
|
||||
NUMREG+FILENAME|
|
||||
FILENAME|X
|
@ -12,6 +12,7 @@ int main(int argc, char** argv)
|
||||
case 0: rt = f90100(argc, argv); break; // Programma estrazione pacchetti
|
||||
case 1: rt = f90200(argc, argv); break; // Tabella categorie documentali
|
||||
case 2: rt = f90300(argc, argv); break; // Gestione documenti cartacei
|
||||
case 3: rt = f90400(argc, argv); break; // Test classi
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
|
@ -4,5 +4,6 @@
|
||||
int f90100(int argc, char* argv[]);
|
||||
int f90200(int argc, char* argv[]);
|
||||
int f90300(int argc, char* argv[]);
|
||||
int f90400(int argc, char* argv[]);
|
||||
|
||||
#endif // _F90_H_
|
||||
|
@ -145,20 +145,23 @@ int TEstrai_mask::estrai()
|
||||
TProgress_monitor* progr = new TProgress_monitor(mov.items(), "Acquisizione movimenti", false);
|
||||
TLocalisamfile clifo(LF_CLIFO);
|
||||
const TipoIVA tipo = tipodoc == 'A' ? iva_acquisti : iva_vendite;
|
||||
|
||||
int count = 0;
|
||||
// Prendo tutti i movimenti a partire da una data e li carico tutti fino alla data finale
|
||||
for (bool ok = mov.move_first(); ok; ok = mov.move_next())
|
||||
{
|
||||
if (!progr->add_status())
|
||||
break;
|
||||
int numreg = recset_get_int(mov, MOV_NUMREG);
|
||||
if (numreg == 96956)
|
||||
bool simo = true;
|
||||
|
||||
TToken_string elab_f9(recset_get_string(mov, MOV_ELABF9), ';'); // Stringa del campo elaborazione f9 nel file mov
|
||||
const bool escluso = !(elab_f9.items() == 3 && elab_f9.get(2)[0] != 'X' || elab_f9.empty());
|
||||
const TCausale caus(recset_get_string(mov, MOV_CODCAUS, 3));
|
||||
const bool stampato = recset_get_bool(mov, MOV_REGST);
|
||||
const TString& numdoc = recset_get_string(mov, MOV_NUMDOC);
|
||||
const TRegistro& reg = caus.reg();
|
||||
const TipoIVA& iva = reg.iva();
|
||||
const TCausale caus(recset_get_string(mov, MOV_CODCAUS, 3), TDate(recset_get_string(mov, MOV_DATAREG)).year());
|
||||
const bool stampato = recset_get_bool(mov, MOV_REGST);
|
||||
const TString& numdoc = recset_get_string(mov, MOV_NUMDOC);
|
||||
const TRegistro& reg = caus.reg();
|
||||
const TipoIVA& iva = reg.iva();
|
||||
// Se definitivo controllo il flag di stampato REGST
|
||||
if ((flagpro || stampato) && numdoc.full() && iva == tipo)
|
||||
{
|
||||
@ -188,6 +191,7 @@ int TEstrai_mask::estrai()
|
||||
|
||||
// Effettivo inserimento del movimento
|
||||
_estrazione->add_mov(t);
|
||||
++count;
|
||||
}
|
||||
}
|
||||
delete progr;
|
||||
@ -339,12 +343,11 @@ bool TMonitor_mask::save_conf_handler(TMask_field& f, KEY key)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMonitor_mask::estr_mov_handler(TMask_field& f, KEY key)
|
||||
bool TMonitor_mask::open_mov_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
TSheet_field& sf = ((TMonitor_mask&)f.mask())._inclusi_mask->sfield(S_ESCL);
|
||||
TToken_string& row = sf.row(sf.selected());
|
||||
TMask& sf = f.mask();
|
||||
TRectype mov(LF_MOV);
|
||||
mov.put(MOV_NUMREG, row.get(sf.cid2index(F_NUMREG)));
|
||||
mov.put(MOV_NUMREG, sf.get(F_NUMREG));
|
||||
return open_mov(mov);
|
||||
}
|
||||
|
||||
@ -358,10 +361,10 @@ TMask& TMonitor_mask::inclusi_mask()
|
||||
// Handler dello sheet per selezione singola
|
||||
|
||||
TMask& sheet_m = ((TSheet_field&)m.field(S_INCL)).sheet_mask(); // Maschera dei campi dello sheet
|
||||
sheet_m.set_handler(DLG_USER, estr_mov_handler); // Bottone collega movimento
|
||||
sheet_m.set_handler(DLG_USER, open_mov_handler); // Bottone collega movimento
|
||||
|
||||
TMask& sheet_res = ((TSheet_field&)m.field(S_RES)).sheet_mask();
|
||||
sheet_res.set_handler(DLG_USER, estr_mov_handler);
|
||||
sheet_res.set_handler(DLG_USER, open_mov_handler);
|
||||
}
|
||||
return *_inclusi_mask;
|
||||
}
|
||||
@ -407,7 +410,7 @@ void TMonitor_mask::delete_pack(const bool all) const
|
||||
" FROM " F9_DRD "\n"
|
||||
" WHERE " DRD_ID_EST " = '" << id_estr << "';\n\n"
|
||||
" IF(@stato = '" D_GEST_ERR "') BEGIN\n"
|
||||
" DELETE FROM " F9_ERR " WHERE IDOC = '" << codsoc << "' AND IDESTR = '" << id_estr << "';\n"
|
||||
" DELETE FROM " F9_ERR " WHERE " ERR_CODSOC " = '" << codsoc << "' AND " ERR_IDESTR " = '" << id_estr << "';\n"
|
||||
" END\n"
|
||||
" ELSE BEGIN\n"
|
||||
" SELECT @stato AS STATO;\n"
|
||||
@ -555,14 +558,18 @@ void TMonitor_mask::fill_estr(const char* codsoc, const char* id, const char tip
|
||||
r.add(rec.get(0).as_string()); // Numreg
|
||||
r.add(rec.get(1).as_string()); // Data reg
|
||||
r.add(rec.get(2).as_string()); // Data doc
|
||||
r.add(rec.get(3).as_string()); // Cod caus
|
||||
TString codcaus; codcaus << rec.get(3).as_string();
|
||||
const int len = codcaus.len();
|
||||
for (int i = 0; i < 3 - len; ++i)
|
||||
codcaus.add_front("0");
|
||||
r.add(codcaus); // Cod caus
|
||||
r.add(rec.get(4).as_string()); // Tipo doc
|
||||
r.add(rec.get(5).as_string()); // Mese liq
|
||||
r.add(rec.get(6).as_string()); // Num doc
|
||||
r.add(rec.get(7).as_string()); // Tot doc
|
||||
r.add(rec.get(8).as_string()); // Clifo
|
||||
TLocalisamfile clifo(LF_CLIFO);
|
||||
clifo.put(CLI_CODCF, rec.get(7).as_string());
|
||||
clifo.put(CLI_CODCF, rec.get(8).as_string());
|
||||
clifo.put(CLI_TIPOCF, tipodoc == 'A' ? "F" : "C");
|
||||
clifo.read();
|
||||
r.add(clifo.get(CLI_RAGSOC)); // Rag soc
|
||||
@ -1323,7 +1330,7 @@ void TF9_app::print_log()
|
||||
|
||||
bool TF9_app::is_autofattura(const TLocalisamfile& mov)
|
||||
{
|
||||
return TCausale(mov.get(MOV_CODCAUS)).tipo_doc() == "AF";
|
||||
return TCausale(mov.get(MOV_CODCAUS), mov.get_date(MOV_DATAREG).year()).tipo_doc() == "AF";
|
||||
}
|
||||
|
||||
bool TF9_app::segna_estratti(const bool escluso, const int numreg)
|
||||
|
@ -140,7 +140,7 @@ class TMonitor_mask : public TAutomask
|
||||
// Configurazione mask
|
||||
static bool save_conf_handler(TMask_field& f, KEY key);
|
||||
// Apri Estr. mask
|
||||
static bool estr_mov_handler(TMask_field& f, KEY key);
|
||||
static bool open_mov_handler(TMask_field& f, KEY key);
|
||||
TMask& inclusi_mask(); // Crea la maschera per 'Apri Estr.'
|
||||
void fill_estr(const char* codsoc, const char* id, char tipodoc) const;
|
||||
void fill_res(const char* codsoc, const char* id, char tipodoc) const;
|
||||
|
@ -311,7 +311,7 @@ BEGIN
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING F_RDESCRERR 87
|
||||
STRING F_RDESCRERR 92
|
||||
BEGIN
|
||||
PROMPT 1 13 ""
|
||||
FLAGS "D"
|
||||
|
@ -76,25 +76,25 @@
|
||||
#define IVA_NUMOR "F9INRRO" // A(20) - n.registrazione originale
|
||||
#define IVA_DATAOR "F9IURGO" // D - data registrazione originale
|
||||
#define IVA_CLASDOC "F9ICLDF" // A(10) - classe documentale FTV (in base al tipo documento da F9DRT00K)
|
||||
#define IVA_NOMF1 "F9INMF1" // A(100) - nome file DOC (Nome fattura cartacea)
|
||||
#define IVA_CLASAN1 "F9ICLDN" // A(10) - classe documentale(annesso 1) (in base al tipo documento da F9DRA00K)
|
||||
#define IVA_NOMF2 "F9INMF2" // A(100) - nome file 1
|
||||
#define IVA_NOMFD "F9INMF1" // A(100) - nome file DOC (Nome fattura cartacea)
|
||||
#define IVA_CLASAN1 "F9ICLDN" // A(10) - classe documentale(annesso 1) (in base al tipo documento da F9DRT00K)
|
||||
#define IVA_NOMF1 "F9INMF2" // A(100) - nome file 1
|
||||
#define IVA_CLASAN2 "F9ICLDA" // A(10) - classe documentale(annesso 2)
|
||||
#define IVA_NOMF3 "F9INMF3" // A(100) - nome file 2 (Nome documento (senza percorso))
|
||||
#define IVA_CLASAN4 "F9ICLD4" // A(10) - classe documentale(annesso 3)
|
||||
#define IVA_NOMF4 "F9INMF4" // A(100) - nome file 3
|
||||
#define IVA_CLASAN5 "F9ICLD5" // A(10) - classe documentale(annesso 4)
|
||||
#define IVA_NOMF5 "F9INMF5" // A(100) - nome file 4
|
||||
#define IVA_CLASAN6 "F9ICLD6" // A(10) - classe documentale(annesso 5)
|
||||
#define IVA_NOMF6 "F9INMF6" // A(100) - nome file 5
|
||||
#define IVA_CLASAN7 "F9ICLD7" // A(10) - classe documentale(annesso 6)
|
||||
#define IVA_NOMF7 "F9INMF7" // A(100) - nome file 6
|
||||
#define IVA_CLASAN8 "F9ICLD8" // A(10) - classe documentale(annesso 7)
|
||||
#define IVA_NOMF8 "F9INMF8" // A(100) - nome file 7
|
||||
#define IVA_CLASAN9 "F9ICLD9" // A(10) - classe documentale(annesso 8)
|
||||
#define IVA_NOMF9 "F9INMF9" // A(100) - nome file 8
|
||||
#define IVA_CLASA10 "F9ICL10" // A(10) - classe documentale(annesso 9)
|
||||
#define IVA_NOMF10 "F9INM10" // A(100) - nome file 9
|
||||
#define IVA_NOMF2 "F9INMF3" // A(100) - nome file 2 (Nome documento (senza percorso))
|
||||
#define IVA_CLASAN3 "F9ICLD4" // A(10) - classe documentale(annesso 3)
|
||||
#define IVA_NOMF3 "F9INMF4" // A(100) - nome file 3
|
||||
#define IVA_CLASAN4 "F9ICLD5" // A(10) - classe documentale(annesso 4)
|
||||
#define IVA_NOMF4 "F9INMF5" // A(100) - nome file 4
|
||||
#define IVA_CLASAN5 "F9ICLD6" // A(10) - classe documentale(annesso 5)
|
||||
#define IVA_NOMF5 "F9INMF6" // A(100) - nome file 5
|
||||
#define IVA_CLASAN6 "F9ICLD7" // A(10) - classe documentale(annesso 6)
|
||||
#define IVA_NOMF6 "F9INMF7" // A(100) - nome file 6
|
||||
#define IVA_CLASAN7 "F9ICLD8" // A(10) - classe documentale(annesso 7)
|
||||
#define IVA_NOMF7 "F9INMF8" // A(100) - nome file 7
|
||||
#define IVA_CLASAN8 "F9ICLD9" // A(10) - classe documentale(annesso 8)
|
||||
#define IVA_NOMF8 "F9INMF9" // A(100) - nome file 8
|
||||
#define IVA_CLASAN9 "F9ICL10" // A(10) - classe documentale(annesso 9)
|
||||
#define IVA_NOMF9 "F9INM10" // A(100) - nome file 9
|
||||
#define IVA_USERELA "F9IUTEE" // A(10) - Utente elaborazione
|
||||
#define IVA_TIMEELA "F9IUHEL" // D - Data e ora elaborazione
|
||||
#define IVA_TIMEWEB "F9IUHEW" // D - Data e ora elaborazione WEBAPP
|
||||
|
@ -15,10 +15,15 @@ TString escape(const char* str);
|
||||
|
||||
class TF9_categorie_doc_msk : public TAutomask
|
||||
{
|
||||
std::unique_ptr<TArray_sheet> _annessi_sheet;
|
||||
TRecord_categorie _categorie_doc;
|
||||
|
||||
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
||||
bool on_key(KEY key) override;
|
||||
|
||||
void check_spell() const;
|
||||
void fill_annessi(const TString& catdoc);
|
||||
void fill_annessi(const TString_array& annessi);
|
||||
void load_table() const;
|
||||
void salva_tabella() const;
|
||||
|
||||
@ -50,11 +55,44 @@ bool TF9_categorie_doc_msk::on_field_event(TOperable_field& o, TField_event e, l
|
||||
sf.show();
|
||||
}
|
||||
break;
|
||||
case DLG_USER:
|
||||
if (e == fe_button)
|
||||
{
|
||||
TSheet_field& sf = sfield(S_CLASSDOC);
|
||||
const TString catdoc_padre(sf.row(sf.selected()).get(1));
|
||||
const TString tipoann = sf.row(sf.selected()).get(cid2index(F_OPERCEE));
|
||||
if (!tipoann.empty())
|
||||
{
|
||||
warning_box("Impossibile visualizzare gli annessi di una categoria annesso.");
|
||||
break;
|
||||
}
|
||||
fill_annessi(catdoc_padre);
|
||||
int key;
|
||||
while ((key = _annessi_sheet->run()) != K_ESC)
|
||||
{
|
||||
if (key == K_INS)
|
||||
{
|
||||
TArray_sheet* catd = _categorie_doc.get_sheet_catdocs().get();
|
||||
if (catd->run() == K_ENTER)
|
||||
{
|
||||
_categorie_doc.add_annesso(catdoc_padre, catd->row(catd->selected()).get(0));
|
||||
fill_annessi(catdoc_padre);
|
||||
}
|
||||
}
|
||||
else if (key == K_DEL)
|
||||
{
|
||||
const int r = _annessi_sheet->selected();
|
||||
if (yesno_box("Eliminare l'annesso N. %d?", r + 1))
|
||||
{
|
||||
_categorie_doc.del_annesso(catdoc_padre, _annessi_sheet->row(r).get(0));
|
||||
fill_annessi(catdoc_padre);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
/*if(o.dlg() >= F_SELCLASS && o.dlg() <= F_OPERCEE && (e == fe_init || e == fe_modify) && jolly >= 1)
|
||||
{
|
||||
return true;
|
||||
}*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -95,6 +133,42 @@ void TF9_categorie_doc_msk::check_spell() const
|
||||
}
|
||||
}
|
||||
|
||||
void TF9_categorie_doc_msk::fill_annessi(const TString& catdoc)
|
||||
{
|
||||
TRecord_categorie annessi(TRecord_categorie::annessi);
|
||||
TToken_string r;
|
||||
if (_annessi_sheet == nullptr)
|
||||
_annessi_sheet = make_unique<TArray_sheet>(-1, -1, 78, 13, "Annessi", "Categoria\nDocumento (Codice)@15|Descrizione@26", 6);
|
||||
_annessi_sheet->destroy();
|
||||
annessi.put("CATDOC", catdoc);
|
||||
for(bool ok = annessi.read(); ok; ok = annessi.next())
|
||||
{
|
||||
_categorie_doc.put("NAME", annessi.get("NAME"));
|
||||
_categorie_doc.read(true);
|
||||
r.cut(0);
|
||||
r.add(annessi.get("NAME"), 0);
|
||||
r.add(_categorie_doc.get("DESCR"));
|
||||
_annessi_sheet->add(r);
|
||||
}
|
||||
}
|
||||
|
||||
void TF9_categorie_doc_msk::fill_annessi(const TString_array& annessi)
|
||||
{
|
||||
TToken_string r;
|
||||
if (_annessi_sheet == nullptr)
|
||||
_annessi_sheet = make_unique<TArray_sheet>(-1, -1, 78, 13, "Annessi", "Categoria\nDocumento (Codice)@15|Descrizione@26", 6);
|
||||
_annessi_sheet->destroy();
|
||||
FOR_EACH_ARRAY_ITEM(annessi, nr, row)
|
||||
{
|
||||
_categorie_doc.put("NAME", ((TToken_string*)row)->get(0));
|
||||
_categorie_doc.read();
|
||||
r.cut(0);
|
||||
r.add(((TToken_string*)row)->get(0), 0);
|
||||
r.add(_categorie_doc.get("DESCR"));
|
||||
_annessi_sheet->add(r);
|
||||
}
|
||||
}
|
||||
|
||||
void TF9_categorie_doc_msk::load_table() const
|
||||
{
|
||||
TSheet_field& sf = sfield(S_CLASSDOC);
|
||||
|
@ -62,7 +62,7 @@ BEGIN
|
||||
ITEM "Causale per\nSostitutiva (TD01...)@25"
|
||||
ITEM "Causale\nContabile@8"
|
||||
ITEM "Tipo\nDocumento@6"
|
||||
ITEM "Classificazione\nCategoria@14"
|
||||
ITEM "Classificazione\nAnnesso@14"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
@ -96,7 +96,7 @@ END
|
||||
|
||||
LIST F_CAUSSOS 4 33
|
||||
BEGIN
|
||||
PROMPT 1 5 ""
|
||||
PROMPT 1 5 "Causale per sostitutiva"
|
||||
FLAGS ""
|
||||
ITEM ""
|
||||
ITEM "TD01|TD01 Fattura"
|
||||
@ -137,16 +137,23 @@ LIST F_OPERCEE 2 14
|
||||
BEGIN
|
||||
PROMPT 1 8 "Operatore CEE"
|
||||
ITEM "|"
|
||||
ITEM "BD|Bolla Doganale"
|
||||
ITEM "DC|Doc. cartaceo"
|
||||
ITEM "RC|Reverse Charge"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
TOOLBAR "topbar" 0 0 0 2
|
||||
|
||||
BUTTON DLG_USER 2 2
|
||||
BEGIN
|
||||
PROMPT 1 1 "Annessi"
|
||||
PICTURE TOOL_LINK
|
||||
END
|
||||
|
||||
BUTTON DLG_QUIT 2 2
|
||||
BEGIN
|
||||
PROMPT 3 1 "Fine"
|
||||
PROMPT 2 1 "Fine"
|
||||
MESSAGE EXIT,K_QUIT
|
||||
PICTURE TOOL_QUIT
|
||||
END
|
||||
|
@ -1,40 +1,160 @@
|
||||
#include "f90.h"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
|
||||
#include "annessif9.h"
|
||||
#include "applicat.h"
|
||||
#include "automask.h"
|
||||
#include "f90300a.h"
|
||||
#include "docf9.h"
|
||||
#include "sheet.h"
|
||||
#include "urldefid.h"
|
||||
#include "utility.h"
|
||||
#include "f90300b.h"
|
||||
#include "mov.h"
|
||||
#include "isam.h"
|
||||
#include "f9cart.h"
|
||||
#include "f9lib01.h"
|
||||
#include "f90300a.h"
|
||||
#include "f90300b.h"
|
||||
|
||||
#define TABMOD_CARTDIR "S0"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// TImport_msk
|
||||
|
||||
class TImport_msk : public TMask
|
||||
class TImport_msk : public TAutomask
|
||||
{
|
||||
friend class TGestione_doc_cartacei_f9_msk;
|
||||
|
||||
static bool ok_handler(TMask_field& field, KEY key)
|
||||
{
|
||||
field.mask().send_key(K_ENTER, DLG_OK);
|
||||
return true;
|
||||
}
|
||||
std::shared_ptr<TArray_sheet> _catdocs;
|
||||
map<TString, unique_ptr<TArray_sheet>> _annessi;
|
||||
|
||||
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
||||
|
||||
static bool catdocann_handler(TMask_field& field, KEY key);
|
||||
static bool catannpadre_handler(TMask_field& field, KEY key);
|
||||
static bool ok_handler(TMask_field& field, KEY key);
|
||||
|
||||
const char* select_catdoc();
|
||||
|
||||
public:
|
||||
TImport_msk() : TMask("f90300b") { }
|
||||
TImport_msk();
|
||||
};
|
||||
|
||||
bool TImport_msk::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
switch (o.dlg())
|
||||
{
|
||||
case F_ISANNESSO:
|
||||
if (e == fe_modify)
|
||||
{
|
||||
const bool on = o.mask().get_bool(F_ISANNESSO);
|
||||
o.mask().enable(F_CATANNPADRE, on);
|
||||
o.mask().enable(F_CATDOCANN, on);
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TImport_msk::catdocann_handler(TMask_field& field, KEY key)
|
||||
{
|
||||
static const char* msg_notexist = "Non esistono tipologie di annessi per questa categoria documentale.";
|
||||
static const char* msg_inspadre = "Inserire prima la cat. doc. padre.";
|
||||
TImport_msk& msk = (TImport_msk&)field.mask();
|
||||
if (key == K_TAB && field.dirty() && field.full())
|
||||
{
|
||||
if (msk.get(F_CATANNPADRE).full())
|
||||
{
|
||||
const TString_array names_ann = categorie_doc().get_array_ann(msk.get(F_CATANNPADRE));
|
||||
if (names_ann.items() > 0)
|
||||
{
|
||||
bool ok = false;
|
||||
FOR_EACH_ARRAY_ITEM(names_ann, nr, ann)
|
||||
{
|
||||
if (field.get() == (*(TToken_string*)ann).get(0))
|
||||
ok = true;
|
||||
}
|
||||
if (!ok)
|
||||
{
|
||||
msk.error_box("La categoria inserita e' inesistente");
|
||||
field.set("");
|
||||
}
|
||||
}
|
||||
else
|
||||
warning_box(msg_notexist);
|
||||
}
|
||||
else
|
||||
{
|
||||
warning_box(msg_inspadre);
|
||||
field.set("");
|
||||
}
|
||||
}
|
||||
if (key == K_F9)
|
||||
{
|
||||
if (msk.get(F_CATANNPADRE).full())
|
||||
{
|
||||
TArray_sheet* annessi = categorie_doc().get_sheet_ann(msk.get(F_CATANNPADRE)).get();
|
||||
|
||||
if (annessi && annessi->items() > 0)
|
||||
{
|
||||
if (annessi->run() == K_ENTER)
|
||||
msk.set(F_CATDOCANN, annessi->row(annessi->selected()).get(0));
|
||||
}
|
||||
else
|
||||
warning_box(msg_notexist);
|
||||
}
|
||||
else
|
||||
warning_box(msg_inspadre);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TImport_msk::catannpadre_handler(TMask_field& field, KEY key)
|
||||
{
|
||||
TImport_msk& msk = (TImport_msk&)field.mask();
|
||||
if (key == K_TAB && field.dirty() && field.full())
|
||||
{
|
||||
std::set<TString>& name_cats = categorie_doc().get_name_catdocs();
|
||||
|
||||
const bool ok = name_cats.find(field.get()) != name_cats.end();
|
||||
if (!ok)
|
||||
{
|
||||
msk.error_box("La categoria inserita e' inesistente");
|
||||
field.set("");
|
||||
}
|
||||
}
|
||||
if (key == K_F9)
|
||||
{
|
||||
field.set(msk.select_catdoc());
|
||||
msk.set(F_CATDOCANN, "");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TImport_msk::ok_handler(TMask_field& field, KEY key)
|
||||
{
|
||||
field.mask().send_key(K_ENTER, DLG_OK);
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* TImport_msk::select_catdoc()
|
||||
{
|
||||
if(_catdocs == nullptr)
|
||||
_catdocs = categorie_doc().get_sheet_catdocs();
|
||||
if (_catdocs->run() == K_ENTER)
|
||||
return _catdocs->row().get(0);
|
||||
return "";
|
||||
}
|
||||
|
||||
TImport_msk::TImport_msk(): TAutomask("f90300b")
|
||||
{
|
||||
TMask::set_handler(F_CATANNPADRE, catannpadre_handler);
|
||||
TMask::set_handler(F_CATDOCANN, catdocann_handler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -62,11 +182,12 @@ class TGestione_doc_cartacei_f9_msk : public TAutomask
|
||||
static void check_deleted();
|
||||
bool check_file_exist(const TString& file) const;
|
||||
void delete_file();
|
||||
bool doc_already_exists(const TFilename& file, _Out_ TString& numreg) const;
|
||||
void fill();
|
||||
void fill_annessi() const;
|
||||
void fill_docs();
|
||||
static TToken_string& get_valid_extensions();
|
||||
void load_extensions();
|
||||
bool load_file(const TFilename& file, const TString& numreg);
|
||||
bool load_file(const TFilename& file, const TString& numreg, bool is_annesso, const TString& catannpadre, const TString& catdocann);
|
||||
void open_config_win() const;
|
||||
void open_import_win();
|
||||
static void remove_file_from_f9cart(const std::set<TString>& files);
|
||||
@ -154,18 +275,29 @@ bool TGestione_doc_cartacei_f9_msk::check_file_exist(const TString& file) const
|
||||
|
||||
void TGestione_doc_cartacei_f9_msk::delete_file()
|
||||
{
|
||||
TSheet_field& sf = sfield(S_IMPORTED);
|
||||
int p = curr_page();
|
||||
TSheet_field& sf = p == 0 ? sfield(S_IMPORTED) : sfield(S_ANNESSI);
|
||||
FOR_EACH_SHEET_ROW(sf, nr, row)
|
||||
{
|
||||
if (row->starts_with("X"))
|
||||
{
|
||||
TLocalisamfile f9cart(LF_F9CART);
|
||||
f9cart.setkey(2);
|
||||
const char* filename = row->get(cid2index(F_FILENAME));
|
||||
const char* numreg = row->get(cid2index(104));
|
||||
f9cart.put(F9C_FILENAME, filename);
|
||||
f9cart.put(F9C_NUMREG, numreg);
|
||||
f9cart.read();
|
||||
TLocalisamfile f9cart(LF_F9DOCS);
|
||||
TLocalisamfile f9annessi(LF_F9ANNESSI);
|
||||
const char* filename = row->get(cid2index(F_FILENAME));
|
||||
const char* numreg = row->get(p == 0 ? cid2index(F_NUMREG) : cid2index(F_ANUMREG));
|
||||
|
||||
if (p == 0)
|
||||
{
|
||||
f9cart.put(F9C_FILENAME, filename);
|
||||
f9cart.put(F9C_NUMREG, numreg);
|
||||
f9cart.read();
|
||||
}
|
||||
else
|
||||
{
|
||||
f9annessi.put(F9A_NUMREG, numreg);
|
||||
f9annessi.put(F9A_FILENAME, filename);
|
||||
f9annessi.read();
|
||||
}
|
||||
TFilename filecart(F9CONF.get_addr_cart());
|
||||
filecart.slash_terminate();
|
||||
TFilename deleted(filecart);
|
||||
@ -179,64 +311,97 @@ void TGestione_doc_cartacei_f9_msk::delete_file()
|
||||
if (!MoveFile(filecart, deleted))
|
||||
warning_box(TString("Attenzione:") << " non e' stato possibile rimuovere questo file: " << filecart);
|
||||
else
|
||||
f9cart.remove();
|
||||
{
|
||||
if (p == 0)
|
||||
f9cart.remove();
|
||||
else
|
||||
f9annessi.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
fill();
|
||||
}
|
||||
|
||||
bool TGestione_doc_cartacei_f9_msk::doc_already_exists(const TFilename& file, TString& numreg) const
|
||||
{
|
||||
const auto it = _list_file.find(file);
|
||||
if (it != _list_file.end())
|
||||
{
|
||||
numreg = it->second.numreg;
|
||||
return true;
|
||||
}
|
||||
numreg = "";
|
||||
return false;
|
||||
}
|
||||
|
||||
void TGestione_doc_cartacei_f9_msk::fill()
|
||||
{
|
||||
TLocalisamfile files(LF_F9CART);
|
||||
fill_docs();
|
||||
fill_annessi();
|
||||
}
|
||||
|
||||
void TGestione_doc_cartacei_f9_msk::fill_annessi() const
|
||||
{
|
||||
TLocalisamfile ann(LF_F9ANNESSI);
|
||||
if(ann.first() == NOERR)
|
||||
{
|
||||
TLocalisamfile mov(LF_MOV);
|
||||
TSheet_field& sf = sfield(S_ANNESSI);
|
||||
sf.hide();
|
||||
sf.destroy();
|
||||
do
|
||||
{
|
||||
TToken_string& row = sf.row(-1);
|
||||
const TString& numreg = ann.get(F9A_NUMREG);
|
||||
|
||||
mov.put(MOV_NUMREG, numreg);
|
||||
mov.read();
|
||||
|
||||
row.add(ann.get(F9A_FILENAME), 1); // ITEM "Nome File@25"
|
||||
row.add(ann.get(F9A_CATDOCPAD)); // ITEM "Categoria di\nappartenenza@7"
|
||||
row.add(ann.get(F9A_CATDOCANN)); // ITEM "Classe doc.\nannesso@7"
|
||||
row.add(numreg); // ITEM "Movimento\nContabile N.@7"
|
||||
row.add(mov.get(MOV_DATAREG)); // ITEM "Data\nMovimento@10"
|
||||
row.add(mov.get(MOV_CODCAUS)); // ITEM "Causale@7"
|
||||
row.add(mov.get(MOV_NUMDOC)); // ITEM "Num. Doc.@7"
|
||||
row.add(TString(mov.get(MOV_REG)) << "/" << mov.get(MOV_PROTIVA)); // ITEM "Reg./Prot. IVA@10"
|
||||
row.add(mov.get(MOV_DESCR)); // ITEM "Descrizione@20"
|
||||
row.add(ann.get(F9A_LOADDATE)); // ITEM "Data\nCaricamento@10"
|
||||
// todo: row.add("") // ITEM "Info (Errori)@25"
|
||||
} while (ann.next() == NOERR);
|
||||
sf.force_update();
|
||||
sf.show();
|
||||
}
|
||||
}
|
||||
|
||||
void TGestione_doc_cartacei_f9_msk::fill_docs()
|
||||
{
|
||||
TLocalisamfile files(LF_F9DOCS);
|
||||
TLocalisamfile mov(LF_MOV);
|
||||
TSheet_field& sf = sfield(S_IMPORTED);
|
||||
sf.hide();
|
||||
sf.destroy();
|
||||
_list_file.clear();
|
||||
std::set<TString> file_err;
|
||||
if(files.first() == NOERR)
|
||||
if (files.first() == NOERR)
|
||||
{
|
||||
do
|
||||
{
|
||||
const TString& namefile = files.get(F9C_FILENAME);
|
||||
bool not_exist = false;
|
||||
if((not_exist = !check_file_exist(namefile)))
|
||||
const TString& namefile = files.get(F9C_FILENAME);
|
||||
const bool not_exist = !check_file_exist(namefile);
|
||||
if (not_exist)
|
||||
file_err.insert(namefile);
|
||||
const TString& numreg = files.get(F9C_NUMREG);
|
||||
const TString& numreg = files.get(F9C_NUMREG);
|
||||
TString datamov, caus, numdoc, nprot, descrmov;
|
||||
mov.zero();
|
||||
mov.put(MOV_NUMREG, numreg);
|
||||
if(mov.read() == NOERR)
|
||||
if (mov.read() == NOERR)
|
||||
{
|
||||
datamov = mov.get(MOV_DATAREG);
|
||||
caus = mov.get(MOV_CODCAUS);
|
||||
numdoc = mov.get(MOV_NUMDOCEXT);
|
||||
if(numdoc.empty()) numdoc = mov.get(MOV_NUMDOC);
|
||||
datamov = mov.get(MOV_DATAREG);
|
||||
caus = mov.get(MOV_CODCAUS);
|
||||
numdoc = mov.get(MOV_NUMDOCEXT);
|
||||
if (numdoc.empty()) numdoc = mov.get(MOV_NUMDOC);
|
||||
nprot << mov.get(MOV_REG) << "/" << mov.get(MOV_PROTIVA);
|
||||
descrmov = mov.get(MOV_DESCR);
|
||||
descrmov = mov.get(MOV_DESCR);
|
||||
}
|
||||
TToken_string& r = sf.row(-1);
|
||||
r.add(" ", 0); // F_SEL
|
||||
r.add(namefile); // F_FILENAME
|
||||
r.add(files.get(F9C_LOADDATE)); // F_DATACARIC
|
||||
r.add(numreg); // F_NUMREG
|
||||
r.add(datamov); // F_DATAMOV
|
||||
r.add(caus); // F_CAUS
|
||||
r.add(numdoc); // F_NUMDOC
|
||||
r.add(nprot); // F_NPROTOCOL
|
||||
r.add(descrmov); // F_DESCRMOV
|
||||
r.add(files.get(F9C_LOADDATE)); // F_DATACARIC
|
||||
r.add(not_exist ? "IL FILE NON E' PRESENTE IN ARCHIVIO." : ""); // F_INFO
|
||||
|
||||
_list_file.insert({ namefile, { namefile, files.get(F9C_LOADDATE), numreg, files.get(F9C_USER) } });
|
||||
@ -244,7 +409,7 @@ void TGestione_doc_cartacei_f9_msk::fill()
|
||||
sf.force_update();
|
||||
}
|
||||
sf.show();
|
||||
if(!file_err.empty())
|
||||
if (!file_err.empty())
|
||||
{
|
||||
int count = 0;
|
||||
const bool m = (int)file_err.size() == 1;
|
||||
@ -252,7 +417,7 @@ void TGestione_doc_cartacei_f9_msk::fill()
|
||||
TString msg; msg << (int)file_err.size() << " file non " << (m ? "e'" : "sono") << " stat" << p <<
|
||||
" trovat" << p << ".\nSi prega di rimuoverl" << p << " dall'elenco\n\nFile non trovat" << p << ":";
|
||||
|
||||
for(auto it = file_err.begin(); it != file_err.end(); ++it)
|
||||
for (auto it = file_err.begin(); it != file_err.end(); ++it)
|
||||
{
|
||||
if (count++ == 10)
|
||||
{
|
||||
@ -260,7 +425,7 @@ void TGestione_doc_cartacei_f9_msk::fill()
|
||||
break;
|
||||
}
|
||||
msg << "\n" << *it << " [Num. Reg.: " << _list_file.find(*it)->second.numreg << "]";
|
||||
}
|
||||
}
|
||||
#ifndef DBG
|
||||
const bool del = warning_box(msg);
|
||||
#else
|
||||
@ -270,7 +435,7 @@ void TGestione_doc_cartacei_f9_msk::fill()
|
||||
fill();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TToken_string& TGestione_doc_cartacei_f9_msk::get_valid_extensions()
|
||||
@ -304,42 +469,69 @@ void TGestione_doc_cartacei_f9_msk::load_extensions()
|
||||
}
|
||||
}
|
||||
|
||||
bool TGestione_doc_cartacei_f9_msk::load_file(const TFilename& file, const TString& numreg)
|
||||
bool TGestione_doc_cartacei_f9_msk::load_file(const TFilename& file, const TString& numreg, const bool is_annesso,
|
||||
const TString& catannpadre, const TString& catdocann)
|
||||
{
|
||||
TString numreg_old;
|
||||
if(doc_already_exists(file, numreg_old))
|
||||
TString numreg_old;
|
||||
bool annesso;
|
||||
TF9_doccart f9cart;
|
||||
TLocalisamfile f9docs(LF_F9DOCS);
|
||||
TLocalisamfile f9annessi(LF_F9ANNESSI);
|
||||
if(f9cart.doc_already_exists(file, numreg_old, annesso))
|
||||
{
|
||||
error_box(TString("Attenzione:") << "esiste gia' un documento con questo nome associato al num. di registrazione " << numreg_old);
|
||||
warning_box("Attenzione: esiste gia' un %s con questo nome associato al num. di registrazione %s", annesso ? "annesso" : "documento", (const char*)numreg_old);
|
||||
return false;
|
||||
}
|
||||
|
||||
TLocalisamfile f9cart(LF_F9CART);
|
||||
f9cart.put(F9C_FILENAME, file.name());
|
||||
f9cart.put(F9C_LOADDATE, TDate(TODAY));
|
||||
f9cart.put(F9C_NUMREG, numreg);
|
||||
#ifdef DBG
|
||||
const TString n_user = user();
|
||||
if (n_user.empty())
|
||||
message_box("Attenzione nome utente vuoto!");
|
||||
f9cart.put(F9C_USER, n_user);
|
||||
#else
|
||||
f9cart.put(F9C_USER, user());
|
||||
#endif
|
||||
|
||||
if(!is_annesso)
|
||||
{
|
||||
TFilename doc;
|
||||
if (f9cart.mov2doc(numreg, doc) && !doc.empty())
|
||||
{
|
||||
warning_box("Attenzione: la registrazione num. %s ha gia' un documento associato: %s.\n"
|
||||
"Se si tratta di un annesso inserire le informazioni per la cat. documentale.", (const char*)numreg, (const char*)doc);
|
||||
return false;
|
||||
}
|
||||
|
||||
f9docs.zero();
|
||||
f9docs.put(F9C_FILENAME, file.name());
|
||||
f9docs.put(F9C_NUMREG, numreg);
|
||||
f9docs.put(F9C_LOADDATE, TDate(TODAY));
|
||||
f9docs.put(F9C_USER, user());
|
||||
}
|
||||
else
|
||||
{
|
||||
f9annessi.zero();
|
||||
f9annessi.put(F9A_NUMREG, numreg);
|
||||
f9annessi.put(F9A_FILENAME, file.name());
|
||||
f9annessi.put(F9A_CATDOCPAD, catannpadre);
|
||||
f9annessi.put(F9A_CATDOCANN, catdocann);
|
||||
f9annessi.put(F9C_LOADDATE, TDate(TODAY));
|
||||
f9annessi.put(F9C_USER, user());
|
||||
}
|
||||
TFilename fdestin = F9CONF.get_addr_cart();
|
||||
const TString filename = file.name();
|
||||
fdestin << filename;
|
||||
const bool ok = CopyFile(file, fdestin, true);
|
||||
if (!ok)
|
||||
{
|
||||
if(fdestin.exist())
|
||||
if (fdestin.exist())
|
||||
warning_box("Errore nel copiare il file nella cartella di destinazione.\nEsiste gia' un file con questo nome.");
|
||||
else
|
||||
warning_box("Errore nel copiare il file nella cartella di destinazione. Ritentare.");
|
||||
f9cart.zero();
|
||||
f9docs.zero();
|
||||
return false;
|
||||
}
|
||||
f9cart.write();
|
||||
f9cart.rewrite();
|
||||
if (!is_annesso)
|
||||
{
|
||||
f9docs.write();
|
||||
f9docs.rewrite();
|
||||
}
|
||||
else
|
||||
{
|
||||
f9annessi.write();
|
||||
f9annessi.rewrite();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -413,26 +605,41 @@ void TGestione_doc_cartacei_f9_msk::open_import_win()
|
||||
_import_msk = make_unique<TImport_msk>();
|
||||
while(_import_msk->run() == K_ENTER)
|
||||
{
|
||||
const TString& file = _import_msk->get(F_IMPADDRESS);
|
||||
const TString& numreg = _import_msk->get(F_IMPNUMREG);
|
||||
const TString& file = _import_msk->get(F_IMPADDRESS);
|
||||
const TString& numreg = _import_msk->get(F_IMPNUMREG);
|
||||
const bool is_annesso = _import_msk->get_bool(F_ISANNESSO);
|
||||
const TString& catannpadre = _import_msk->get(F_CATANNPADRE);
|
||||
const TString& catdocann = _import_msk->get(F_CATDOCANN);
|
||||
if (!file.empty())
|
||||
{
|
||||
TFilename f(file);
|
||||
if (verify_extension(f))
|
||||
{
|
||||
if (load_file(f, numreg))
|
||||
message_box("File caricato.");
|
||||
if(!numreg.empty())
|
||||
{
|
||||
if (!is_annesso || catannpadre.full() && catdocann.full())
|
||||
{
|
||||
if (load_file(f, numreg, is_annesso, catannpadre, catdocann))
|
||||
message_box("File caricato.");
|
||||
}
|
||||
else
|
||||
warning_box("Se il documento e' un annesso, si prega di inserire le\ninformazioni per la categoria documentale dell'annesso.");
|
||||
}
|
||||
else
|
||||
warning_box("Si prega di inserire il numero di registrazione.");
|
||||
}
|
||||
else
|
||||
warning_box("Questo file e' in un formato non accettato.");
|
||||
}
|
||||
else
|
||||
warning_box("Si prega di inserire il nome del file.");
|
||||
}
|
||||
fill();
|
||||
}
|
||||
|
||||
void TGestione_doc_cartacei_f9_msk::remove_file_from_f9cart(const std::set<TString>& files)
|
||||
{
|
||||
TLocalisamfile f9cart(LF_F9CART);
|
||||
TLocalisamfile f9cart(LF_F9DOCS);
|
||||
for(auto it = files.begin(); it != files.end(); ++it)
|
||||
{
|
||||
f9cart.zero();
|
||||
|
@ -1,18 +1,34 @@
|
||||
#define B_IMPORT 201
|
||||
#define B_DELETE 202
|
||||
#define B_CONFIG 203
|
||||
#define B_IMPORT 201
|
||||
#define B_DELETE 202
|
||||
#define B_CONFIG 203
|
||||
|
||||
#define S_IMPORTED 301
|
||||
#define S_IMPORTED 301
|
||||
#define S_ANNESSI 302
|
||||
|
||||
// Campi Sheet S_IMPORTED
|
||||
|
||||
#define F_SEL 101
|
||||
#define F_FILENAME 102
|
||||
#define F_DATACARIC 103
|
||||
#define F_NUMREG 104
|
||||
#define F_DATAMOV 105
|
||||
#define F_CAUS 106
|
||||
#define F_NUMDOC 107
|
||||
#define F_NPROTOCOL 108
|
||||
#define F_DESCRMOV 109
|
||||
#define F_INFO 110
|
||||
#define F_SEL 101
|
||||
#define F_FILENAME 102
|
||||
#define F_NUMREG 103
|
||||
#define F_DATAMOV 104
|
||||
#define F_CAUS 105
|
||||
#define F_NUMDOC 106
|
||||
#define F_NPROTOCOL 107
|
||||
#define F_DESCRMOV 108
|
||||
#define F_DATACARIC 109
|
||||
#define F_INFO 110
|
||||
|
||||
// Sheet S_ANNESSI
|
||||
|
||||
#define F_ASEL 101
|
||||
#define F_AFILENAME 102
|
||||
#define F_ACATPADRE 103
|
||||
#define F_ACATANN 104
|
||||
#define F_ANUMREG 105
|
||||
#define F_ADATAMOV 106
|
||||
#define F_ACAUS 107
|
||||
#define F_ANUMDOC 108
|
||||
#define F_ANPROTOCOL 109
|
||||
#define F_ADESCRMOV 110
|
||||
#define F_ADATACARIC 111
|
||||
#define F_AINFO 112
|
||||
|
@ -63,27 +63,50 @@ END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Lista File Importati" 0 2 0 0
|
||||
PAGE "Lista Documenti Cartacei" 0 2 0 0
|
||||
|
||||
SPREADSHEET S_IMPORTED -1 -1
|
||||
BEGIN
|
||||
PROMPT 0 0 "Doc Importati"
|
||||
ITEM ""
|
||||
ITEM "Nome File@25"
|
||||
ITEM "Data\nCaricamento@10"
|
||||
ITEM "Movimento\nContabile N.@7"
|
||||
ITEM "Data\nMovimento@10"
|
||||
ITEM "Causale@7"
|
||||
ITEM "Num. Doc.@7"
|
||||
ITEM "Reg./Prot. IVA@10"
|
||||
ITEM "Descrizione@20"
|
||||
ITEM "Data\nCaricamento@10"
|
||||
ITEM "Info (Errori)@25"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Lista Annessi Importati" 0 2 0 0
|
||||
|
||||
SPREADSHEET S_ANNESSI -1 -1
|
||||
BEGIN
|
||||
PROMPT 0 0 "Annessi Importati"
|
||||
ITEM ""
|
||||
ITEM "Nome File@25"
|
||||
ITEM "Categoria di\nappartenenza@10"
|
||||
ITEM "Classe doc.\nannesso@10"
|
||||
ITEM "Movimento\nContabile N.@7"
|
||||
ITEM "Data\nMovimento@10"
|
||||
ITEM "Causale@7"
|
||||
ITEM "Num. Doc.@7"
|
||||
ITEM "Reg./Prot. IVA@10"
|
||||
ITEM "Descrizione@20"
|
||||
ITEM "Data\nCaricamento@10"
|
||||
ITEM "Info (Errori)@25"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
ENDMASK
|
||||
|
||||
PAGE "SHEET_IMPORTATI" -1 -1 78 13
|
||||
|
||||
|
||||
PAGE "DOC CARTACEO" -1 -1 78 13
|
||||
|
||||
BOOLEAN F_SEL
|
||||
BEGIN
|
||||
@ -148,6 +171,83 @@ BEGIN
|
||||
END
|
||||
|
||||
|
||||
ENDPAGE
|
||||
ENDMASK
|
||||
|
||||
PAGE "ANNESSO" -1 -1 78 13
|
||||
|
||||
BOOLEAN F_ASEL
|
||||
BEGIN
|
||||
PROMPT 0 0 "Selezionato"
|
||||
END
|
||||
|
||||
STRING F_AFILENAME 256
|
||||
BEGIN
|
||||
PROMPT 0 1 "Nome del file"
|
||||
END
|
||||
|
||||
DATE F_ADATACARIC
|
||||
BEGIN
|
||||
PROMPT 0 2 "Data Caricamento File"
|
||||
END
|
||||
|
||||
STRING F_ACATPADRE 10
|
||||
BEGIN
|
||||
PROMPT 0 10 "Categoria di appartenenza"
|
||||
END
|
||||
|
||||
STRING F_ACATANN 10
|
||||
BEGIN
|
||||
PROMPT 0 11 "Classe doc. annesso"
|
||||
END
|
||||
|
||||
NUMBER F_ANUMREG 7
|
||||
BEGIN
|
||||
PROMPT 0 3 "Numero registrazione"
|
||||
USE MOV
|
||||
INPUT NUMREG F_ANUMREG
|
||||
DISPLAY "Numero" NUMREG
|
||||
DISPLAY "Data " DATAREG
|
||||
DISPLAY "Causale" CODCAUS
|
||||
DISPLAY "Num. Doc." NUMDOC
|
||||
DISPLAY "N. esteso" NUMDOCEXT
|
||||
DISPLAY "Prot. IVA" PROTIVA
|
||||
DISPLAY "Descrizione" DESCR
|
||||
OUTPUT F_ANUMREG NUMREG
|
||||
CHECKTYPE NORMAL
|
||||
FLAG "U"
|
||||
END
|
||||
|
||||
DATE F_ADATAMOV
|
||||
BEGIN
|
||||
PROMPT 0 4 "Data movimento"
|
||||
END
|
||||
|
||||
STRING F_ACAUS 3
|
||||
BEGIN
|
||||
PROMPT 0 5 "Codice causale"
|
||||
END
|
||||
|
||||
STRING F_ANUMDOC 18
|
||||
BEGIN
|
||||
PROMPT 0 6 "Numero documento"
|
||||
END
|
||||
|
||||
STRING F_ANPROTOCOL 10
|
||||
BEGIN
|
||||
PROMPT 0 7 "Numero Protocollo IVA"
|
||||
END
|
||||
|
||||
STRING F_ADESCRMOV 50
|
||||
BEGIN
|
||||
PROMPT 0 8 "Descrizione mov."
|
||||
END
|
||||
|
||||
STRING F_AINFO 50
|
||||
BEGIN
|
||||
PROMPT 0 9 "Informazione file."
|
||||
END
|
||||
|
||||
|
||||
ENDPAGE
|
||||
ENDMASK
|
@ -1,3 +1,6 @@
|
||||
#define F_IMPADDRGROUP 101
|
||||
#define F_IMPADDRESS 102
|
||||
#define F_IMPNUMREG 103
|
||||
#define F_IMPADDRGROUP 101
|
||||
#define F_IMPADDRESS 102
|
||||
#define F_IMPNUMREG 103
|
||||
#define F_ISANNESSO 104
|
||||
#define F_CATANNPADRE 105
|
||||
#define F_CATDOCANN 106
|
||||
|
@ -1,5 +1,60 @@
|
||||
#include "f90300b.h"
|
||||
|
||||
PAGE "Apri..." -1 -1 78 7
|
||||
|
||||
GROUPBOX F_IMPADDRGROUP 76 7
|
||||
BEGIN
|
||||
PROMPT 1 0 ""
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 2 1 "@BInserire percorso file."
|
||||
END
|
||||
|
||||
STRING F_IMPADDRESS 255 64
|
||||
BEGIN
|
||||
PROMPT 2 2 "Apri: "
|
||||
FSELECT ""
|
||||
FLAG "B"
|
||||
END
|
||||
|
||||
NUMBER F_IMPNUMREG 7
|
||||
BEGIN
|
||||
PROMPT 2 3 "Registrazione"
|
||||
USE MOV
|
||||
INPUT NUMREG F_IMPNUMREG
|
||||
DISPLAY "Numero" NUMREG
|
||||
DISPLAY "Data " DATAREG
|
||||
DISPLAY "Causale" CODCAUS
|
||||
DISPLAY "Num. Doc." NUMDOC
|
||||
DISPLAY "N. esteso" NUMDOCEXT
|
||||
DISPLAY "Prot. IVA" PROTIVA
|
||||
DISPLAY "Descrizione" DESCR
|
||||
OUTPUT F_IMPNUMREG NUMREG
|
||||
CHECKTYPE NORMAL
|
||||
FLAG "U"
|
||||
END
|
||||
|
||||
BOOLEAN F_ISANNESSO
|
||||
BEGIN
|
||||
PROMPT 2 4 "Annesso"
|
||||
END
|
||||
|
||||
STRING F_CATANNPADRE 10
|
||||
BEGIN
|
||||
PROMPT 2 5 "Cat.doc. padre"
|
||||
FLAGS "BD"
|
||||
END
|
||||
|
||||
STRING F_CATDOCANN 10
|
||||
BEGIN
|
||||
PROMPT 30 5 "Cat.doc. annesso"
|
||||
FLAGS "BD"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
TOOLBAR "topbar" 0 0 0 2
|
||||
|
||||
BUTTON DLG_OK 2 2
|
||||
@ -22,41 +77,4 @@ END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Apri..." 0 0 0 0
|
||||
|
||||
GROUPBOX F_IMPADDRGROUP 76 6
|
||||
BEGIN
|
||||
PROMPT 1 0 ""
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
BEGIN
|
||||
PROMPT 2 1 "@BInserire percorso file."
|
||||
END
|
||||
|
||||
STRING F_IMPADDRESS 255 64
|
||||
BEGIN
|
||||
PROMPT 2 2 "Apri: "
|
||||
FSELECT ""
|
||||
FLAG "B"
|
||||
END
|
||||
|
||||
NUMBER F_IMPNUMREG 7
|
||||
BEGIN
|
||||
PROMPT 2 6 "Registrazione"
|
||||
USE MOV
|
||||
INPUT NUMREG F_IMPNUMREG
|
||||
DISPLAY "Numero" NUMREG
|
||||
DISPLAY "Data " DATAREG
|
||||
DISPLAY "Causale" CODCAUS
|
||||
DISPLAY "Num. Doc." NUMDOC
|
||||
DISPLAY "N. esteso" NUMDOCEXT
|
||||
DISPLAY "Prot. IVA" PROTIVA
|
||||
DISPLAY "Descrizione" DESCR
|
||||
OUTPUT F_IMPNUMREG NUMREG
|
||||
CHECKTYPE NORMAL
|
||||
FLAG "U"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
ENDMASK
|
81
src/f9/f90400.cpp
Normal file
81
src/f9/f90400.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
#include "annessif9.h"
|
||||
#include "applicat.h"
|
||||
#include "f90.h"
|
||||
#include "f9lib01.h"
|
||||
|
||||
class TF9_test_app : public TSkeleton_application
|
||||
{
|
||||
public:
|
||||
void main_loop() override;
|
||||
TF9_test_app() = default;
|
||||
};
|
||||
|
||||
void TF9_test_app::main_loop()
|
||||
{
|
||||
TLocalisamfile f(LF_F9ANNESSI);
|
||||
TString search_numreg; search_numreg << 95223;
|
||||
f.zero();
|
||||
f.setkey(1);
|
||||
f.put(F9A_NUMREG, search_numreg);
|
||||
|
||||
TString filename = f.get(F9A_FILENAME);
|
||||
TString numreg;
|
||||
for(f.read(_isgteq); (numreg = f.get(F9A_NUMREG)) == search_numreg; f.next())
|
||||
{
|
||||
filename = f.get(F9A_FILENAME);
|
||||
numreg = f.get(F9A_NUMREG);
|
||||
//message_box("Filename: %s\nNumreg: %s", (const char*)filename, (const char*)numreg);
|
||||
CHECK(numreg == search_numreg, "This shit sucks.");
|
||||
CHECK(filename == "annmid.pdf" || filename == "annmid2.pdf", "YOU'RE WRONG");
|
||||
}
|
||||
|
||||
// TISAM_recordset FAILS. A sto punto uso il primo.
|
||||
//TISAM_recordset sta(R"(USE ANNESSIF9 FROM NUMREG=="95223" TO NUMREG=="95223")");
|
||||
//for (bool ok = sta.move_first(); ok; ok = sta.move_next())
|
||||
//{
|
||||
// TString filename = sta.get(F9A_FILENAME).as_string();
|
||||
// TString numreg = sta.get(F9A_NUMREG).as_string();
|
||||
// CHECK(numreg == "95223", "isam recordset failed. (EOF)"); // FAILS!
|
||||
// bool simo = true;
|
||||
//}
|
||||
|
||||
// FAILS
|
||||
//TF9_doccart doccart;
|
||||
////const TDate domani("23-05-2020");
|
||||
//doccart.put_in_doc(F9C_NUMREG, "95755");
|
||||
//bool ok = doccart.read_doc();
|
||||
//filename = doccart.get_in_doc(F9C_FILENAME);
|
||||
//numreg = doccart.get_in_doc(F9C_NUMREG);
|
||||
//CHECK(numreg == "95755", "Error in line");
|
||||
//TDate loaddate(doccart.get_in_doc(F9F_LOADDATE));
|
||||
|
||||
TF9_doccart d;
|
||||
TString_array sa;
|
||||
CHECK(d.mov2listann(search_numreg, sa) && sa.items() == 2, "COSA STAI LEGGENDO??");
|
||||
FOR_EACH_ARRAY_ITEM(sa, nr, file)
|
||||
{
|
||||
TString namefile = (*(TToken_string*)file).get(1);
|
||||
TLocalisamfile ann(LF_F9ANNESSI);
|
||||
ann.put(F9A_NUMREG, search_numreg);
|
||||
ann.put(F9A_FILENAME, namefile);
|
||||
CHECK(ann.read() == NOERR, "Non esiste questo numreg??");
|
||||
filename = ann.get(F9A_FILENAME);
|
||||
TString rec; rec <<
|
||||
filename << "\n" <<
|
||||
ann.get(F9A_NUMREG) << "\n" <<
|
||||
ann.get(F9A_CATDOCPAD) << "\n" <<
|
||||
ann.get(F9A_CATDOCANN) << "\n" <<
|
||||
ann.get(F9A_LOADDATE) << "\n" <<
|
||||
ann.get(F9A_USER);
|
||||
CHECK(filename == "annmid.pdf" || filename == "annmid2.pdf", "YOU'RE WRONG");
|
||||
//message_box(rec);
|
||||
}
|
||||
message_box("TESTS COMPLETELY SUCCESSFUL");
|
||||
}
|
||||
|
||||
int f90400(const int argc, char* argv[])
|
||||
{
|
||||
TF9_test_app test_app;
|
||||
test_app.run(argc, argv, "F9 Test Application");
|
||||
return 0;
|
||||
}
|
@ -8,6 +8,7 @@
|
||||
#include "mov.h"
|
||||
#include "../fp/fplib.h"
|
||||
|
||||
#define MODE_SHEETS 0xC
|
||||
|
||||
statistics _stats = { 0 };
|
||||
|
||||
@ -104,6 +105,40 @@ bool TEstrazione::check_periodo_def() const
|
||||
return fp_db().sq_items() == 0;
|
||||
}
|
||||
|
||||
void TEstrazione::copy_file_to_webapp_fld(const movimento_t& movimento) const
|
||||
{
|
||||
// todo:
|
||||
}
|
||||
|
||||
void TEstrazione::fill_id(TLocalisamfile& clifo, TString& statopaiv, TString& idfisc, TString& paiv, TString& codfis)
|
||||
{
|
||||
idfisc.cut(0);
|
||||
statopaiv = clifo.get(CLI_STATOPAIV);
|
||||
paiv = clifo.get(CLI_PAIV);
|
||||
codfis = clifo.get(CLI_COFI);
|
||||
if (paiv == "0")
|
||||
paiv.cut(0);
|
||||
if (statopaiv == "IT" || statopaiv.empty())
|
||||
{
|
||||
idfisc << "IT";
|
||||
if (paiv.full()) // Se non ho la partita IVA e' privato quindi non metto niente solo cod. ISO
|
||||
{
|
||||
const int len = paiv.len();
|
||||
for (int i = 0; i < 11 - len; ++i) // Siccome e' numerico mi trancia via le prime cifre 0.
|
||||
paiv.add_front("0");
|
||||
idfisc << paiv;
|
||||
}
|
||||
}
|
||||
else // Esteri
|
||||
{
|
||||
idfisc << statopaiv;
|
||||
if (codfis.full())
|
||||
idfisc << codfis;
|
||||
else
|
||||
idfisc << paiv;
|
||||
}
|
||||
}
|
||||
|
||||
bool TEstrazione::is_doc_xml(const TLocalisamfile& mov)
|
||||
{
|
||||
const TString& tipocf = mov.get(MOV_TIPO);
|
||||
@ -116,6 +151,13 @@ bool TEstrazione::is_doc_xml(const TLocalisamfile& mov)
|
||||
&& clifo.get(CLI_COMCF) != "B513"; // Campione d'Italia
|
||||
}
|
||||
|
||||
bool TEstrazione::load_annessi(movimento_t& movimento)
|
||||
{
|
||||
TF9_doccart doccart;
|
||||
TString numreg; numreg << movimento.numreg;
|
||||
return doccart.mov2listann_vect(numreg, movimento.annessi);
|
||||
}
|
||||
|
||||
TString& TEstrazione::drd_attr()
|
||||
{
|
||||
static TString attr;
|
||||
@ -148,8 +190,14 @@ bool TEstrazione::insert_into_f9movestr() const
|
||||
{
|
||||
TString query;
|
||||
bool ok = true;
|
||||
|
||||
TProgress_monitor prog(_movs.size(), "Salvataggio informazioni estrazione", false);
|
||||
|
||||
for(auto it = _movs.begin(); it != _movs.end(); ++it)
|
||||
{
|
||||
if(!prog.add_status())
|
||||
break;
|
||||
|
||||
query.cut(0) << "INSERT INTO " F9_MOVESTR " (" MES_CODSOC ", IDESTR, NUMREG, DATAREG, ESTRATTO, DESCR_ERR)\nVALUES " <<
|
||||
" ('" << _head.cod_soc << "', '" << _head.id_estr << "', '" << it->numreg << "', '" << it->datareg.date2ansi() << "', " <<
|
||||
(it->estratto ? "1" : "0") << ", '" << check_str(it->get_descr_estr()) << "')";
|
||||
@ -241,6 +289,11 @@ TString TEstrazione::next_estr_today(char tipo) const
|
||||
return TString(estr);
|
||||
}
|
||||
|
||||
bool TEstrazione::pura_iva(const TLocalisamfile& mov)
|
||||
{
|
||||
return TCausale(mov.get(MOV_CODCAUS), mov.get_date(MOV_DATAREG).year()).soloiva();
|
||||
}
|
||||
|
||||
void TEstrazione::write_errorsql_log(const TString& query) const
|
||||
{
|
||||
TString msg;
|
||||
@ -295,77 +348,108 @@ const char* TEstrazione::diagnostica_mov()
|
||||
{
|
||||
if (!bar.add_status())
|
||||
break;
|
||||
#ifdef DBG
|
||||
if (it->numreg == 96153)
|
||||
bool simo = true;
|
||||
#endif
|
||||
|
||||
movimento_t& mov_i = *it;
|
||||
|
||||
// Se escluso passo avanti
|
||||
if (!it->estratto && it->descr_estr == movimento_t::escluso)
|
||||
if (!mov_i.estratto && mov_i.descr_estr == movimento_t::escluso)
|
||||
continue;
|
||||
|
||||
movimento_t& mov_i = *it;
|
||||
const int numreg = mov_i.numreg;
|
||||
const state_fppro res = check_fppro(numreg);
|
||||
switch (res)
|
||||
if (!mov_i.err && mov_i.estratto)
|
||||
{
|
||||
// OK
|
||||
case guessed:
|
||||
ok &= fppro_db().associa_mov(numreg);
|
||||
case correct:
|
||||
ok &= true;
|
||||
mov_i.err = false;
|
||||
mov_i.state = res;
|
||||
break;
|
||||
|
||||
// ERRORS
|
||||
// Errore non bloccante (skip)
|
||||
case not_fa:
|
||||
ok &= true;
|
||||
mov_i.err = false;
|
||||
mov_i.estratto = false;
|
||||
mov_i.descr_estr = movimento_t::no_fa;
|
||||
mov_i.state = res;
|
||||
++_stats.fa_skip;
|
||||
break;
|
||||
|
||||
// ERRORI BLOCCANTI
|
||||
case reg_with_err:
|
||||
ok &= false;
|
||||
mov_i.err = true;
|
||||
mov_i.estratto = false;
|
||||
mov_i.descr_err = "Errore controllo movimento: associazione movimento con fattura elettronica passiva sbagliato.";
|
||||
mov_i.state = res;
|
||||
break;
|
||||
case err_read_db:
|
||||
ok &= false;
|
||||
mov_i.err = true;
|
||||
mov_i.estratto = false;
|
||||
mov_i.descr_err = "Errore controllo movimento: errore lettura db.";
|
||||
mov_i.state = res;
|
||||
break;
|
||||
case no_guessed:
|
||||
ok &= false;
|
||||
mov_i.err = true;
|
||||
mov_i.estratto = false;
|
||||
mov_i.descr_err = "Non associato a fattura elettr. abbinamento automatico non riuscito. Abbinare manualmente, o escludere";
|
||||
mov_i.state = res;
|
||||
default: break;
|
||||
}
|
||||
const int numreg = mov_i.numreg;
|
||||
TLocalisamfile mov(LF_MOV);
|
||||
mov.put(MOV_NUMREG, numreg);
|
||||
#ifdef DBG
|
||||
if (mov_i.numreg == 95954)
|
||||
bool simo = true;
|
||||
if (mov.read() != NOERR)
|
||||
warning_box("OOOOOOOOOHH! E DICE SIII!!");
|
||||
#endif
|
||||
if (mov_i.err)
|
||||
++_stats.fa_err;
|
||||
/* Per quelli che hanno passato il primo controllo errori controllo che debba essere estratto
|
||||
* secondo le categorie documentali. */
|
||||
if(!mov_i.err && mov_i.estratto)
|
||||
{
|
||||
std::shared_ptr<TCategorie_doc::classe_doc> cd = categorie_doc().mov2cat(mov_i.numreg);
|
||||
mov_i.estratto = cd.get();
|
||||
mov_i.descr_estr = cd ? movimento_t::no_err : movimento_t::no_catdoc;
|
||||
mov_i.catdoc = cd;
|
||||
mov_i.cartaceo = !is_doc_xml(mov);
|
||||
const state_fppro res = check_fppro(numreg);
|
||||
switch (res)
|
||||
{
|
||||
// OK
|
||||
case guessed:
|
||||
ok &= fppro_db().associa_mov(numreg);
|
||||
case correct:
|
||||
ok &= true;
|
||||
mov_i.err = false;
|
||||
mov_i.state = res;
|
||||
break;
|
||||
|
||||
// ERRORS
|
||||
// Errore non bloccante (skip)
|
||||
case not_fa:
|
||||
ok &= true;
|
||||
mov_i.err = false;
|
||||
mov_i.estratto = false;
|
||||
mov_i.descr_estr = movimento_t::no_fa;
|
||||
mov_i.state = res;
|
||||
++_stats.fa_skip;
|
||||
break;
|
||||
|
||||
// ERRORI BLOCCANTI
|
||||
case reg_with_err:
|
||||
ok &= false;
|
||||
mov_i.err = true;
|
||||
mov_i.estratto = false;
|
||||
mov_i.descr_err = "Errore controllo movimento: associazione movimento con fattura elettronica passiva sbagliato.";
|
||||
mov_i.state = res;
|
||||
break;
|
||||
case err_read_db:
|
||||
ok &= false;
|
||||
mov_i.err = true;
|
||||
mov_i.estratto = false;
|
||||
mov_i.descr_err = "Errore controllo movimento: errore lettura db.";
|
||||
mov_i.state = res;
|
||||
break;
|
||||
case no_guessed:
|
||||
ok &= false;
|
||||
mov_i.err = true;
|
||||
mov_i.estratto = false;
|
||||
mov_i.descr_err = "Non associato a fattura elettr. abbinamento automatico non riuscito. Abbinare manualmente, o escludere";
|
||||
mov_i.state = res;
|
||||
default: break;
|
||||
}
|
||||
if (mov_i.err)
|
||||
++_stats.fa_err;
|
||||
/* Per quelli che hanno passato il primo controllo errori controllo che debba essere estratto
|
||||
* secondo le categorie documentali. */
|
||||
if (!mov_i.err && mov_i.estratto)
|
||||
{
|
||||
std::shared_ptr<TCategorie_doc::classe_doc> cd = categorie_doc().mov2cat(mov_i.numreg);
|
||||
mov_i.estratto = cd.get();
|
||||
mov_i.descr_estr = cd ? movimento_t::no_err : movimento_t::no_catdoc;
|
||||
mov_i.catdoc = cd;
|
||||
}
|
||||
if (mov_i.estratto)
|
||||
{
|
||||
if (mov_i.cartaceo)
|
||||
{
|
||||
TF9_doccart filecart;
|
||||
TFilename file;
|
||||
TString reg; reg << it->numreg;
|
||||
if (filecart.mov2doc(reg, file) && file.exist())
|
||||
{
|
||||
mov_i.nomefilecart << file;
|
||||
copy_file_to_webapp_fld(mov_i);
|
||||
}
|
||||
else
|
||||
{
|
||||
mov_i.err = true;
|
||||
mov_i.estratto = false;
|
||||
mov_i.descr_err = "Non e' stato possibile reperire il file del documento cartaceo per questo movimento.";
|
||||
mov_i.descr_estr = movimento_t::no_filecart;
|
||||
}
|
||||
}
|
||||
bool loaded = load_annessi(mov_i);
|
||||
#ifdef DBG
|
||||
if (loaded)
|
||||
bool simo = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
ok &= mov_i.err;
|
||||
}
|
||||
}
|
||||
else if (tipo == iva_vendite)
|
||||
@ -378,13 +462,22 @@ const char* TEstrazione::diagnostica_mov()
|
||||
break;
|
||||
//TToken_string& row = *it;
|
||||
movimento_t& mov_i = *it;
|
||||
|
||||
// Se escluso passo avanti
|
||||
if (!mov_i.estratto && mov_i.descr_estr == movimento_t::escluso)
|
||||
continue;
|
||||
|
||||
TString numreg; numreg << mov_i.numreg;
|
||||
TLocalisamfile mov(LF_MOV);
|
||||
mov.put(MOV_NUMREG, numreg);
|
||||
#ifdef DBG
|
||||
if(mov.read() != NOERR)
|
||||
warning_box("OOOOOOOOOHH! E DICE SIII!!");
|
||||
if (mov_i.numreg == 95677)
|
||||
if (it->numreg == 96956)
|
||||
bool simo = true; // Rev charge
|
||||
if (it->numreg == 95752)
|
||||
bool simo = true; // Cartaceo
|
||||
if (it->numreg == 95740) // Annessi
|
||||
bool simo = true;
|
||||
#endif
|
||||
/* Controlli per vendite cambiati:
|
||||
@ -392,19 +485,29 @@ const char* TEstrazione::diagnostica_mov()
|
||||
*/
|
||||
if (!mov_i.err && mov_i.estratto)
|
||||
{
|
||||
const bool cartacea = !is_doc_xml(mov);
|
||||
mov_i.cartaceo = !is_doc_xml(mov);
|
||||
bool exist_doc;
|
||||
if(!_has_cartacei && cartacea) // Se non devo esportare i cartacei e questa e' cartacea la salto (non errore)
|
||||
unsigned short skip = 0;
|
||||
if (!_has_cartacei && mov_i.cartaceo) skip |= 0x1;
|
||||
else if (pura_iva(mov)) skip |= 0x2;
|
||||
else if (mov_i.datadoc.empty() || mov_i.numdoc.empty()) skip |= 0x4;
|
||||
if(skip)
|
||||
{
|
||||
++_stats.fv_cart_skip;
|
||||
mov_i.err = false;
|
||||
mov_i.estratto = false;
|
||||
mov_i.descr_estr = movimento_t::no_cartaceo;
|
||||
mov_i.err = false;
|
||||
mov_i.estratto = false;
|
||||
switch(skip)
|
||||
{
|
||||
case 0x1: mov_i.descr_estr = movimento_t::no_cartaceo; break;
|
||||
case 0x2: mov_i.descr_estr = movimento_t::pura_iva; break;
|
||||
case 0x4: mov_i.descr_estr = movimento_t::no_fv;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else if(!cartacea && _has_checkvend && !check_documento_vendita(mov, exist_doc))
|
||||
else if(!mov_i.cartaceo && _has_checkvend && !check_documento_vendita(mov, exist_doc))
|
||||
{
|
||||
mov_i.err = true;
|
||||
mov_i.estratto = false;
|
||||
mov_i.err = true;
|
||||
mov_i.estratto = false;
|
||||
mov_i.descr_err = !exist_doc ?
|
||||
"Il movimento non ha un documento generatore. (Escludere? o Rimuovere flag controllo vendite)"
|
||||
: "Non e' stato trovato il documento elettronico nel database delle F.E. (Escludere? o Rimuovere flag controllo vendite)";
|
||||
@ -413,8 +516,8 @@ const char* TEstrazione::diagnostica_mov()
|
||||
else
|
||||
{
|
||||
std::shared_ptr<TCategorie_doc::classe_doc> cd = categorie_doc().mov2cat(mov_i.numreg);
|
||||
mov_i.estratto = cd.get();
|
||||
mov_i.err = false;
|
||||
mov_i.estratto = cd.get();
|
||||
mov_i.descr_estr = cd ? movimento_t::no_err : movimento_t::no_catdoc;
|
||||
mov_i.catdoc = cd;
|
||||
|
||||
@ -425,6 +528,30 @@ const char* TEstrazione::diagnostica_mov()
|
||||
else if (mov_i.estratto)
|
||||
++_stats.fv_estr;
|
||||
}
|
||||
|
||||
if (mov_i.estratto && mov_i.cartaceo)
|
||||
{
|
||||
TF9_doccart filecart;
|
||||
TFilename file;
|
||||
TString reg; reg << it->numreg;
|
||||
if (filecart.mov2doc(reg, file) && file.exist())
|
||||
{
|
||||
mov_i.nomefilecart << file;
|
||||
copy_file_to_webapp_fld(mov_i);
|
||||
}
|
||||
else
|
||||
{
|
||||
mov_i.err = true;
|
||||
mov_i.estratto = false;
|
||||
mov_i.descr_err = "Non e' stato possibile reperire il file del documento cartaceo per questo movimento.";
|
||||
mov_i.descr_estr = movimento_t::no_filecart;
|
||||
}
|
||||
}
|
||||
bool loaded = load_annessi(mov_i);
|
||||
#ifdef DBG
|
||||
if (loaded)
|
||||
bool simo = true;
|
||||
#endif
|
||||
}
|
||||
ok &= !mov_i.err;
|
||||
}
|
||||
@ -504,99 +631,168 @@ result_estr TEstrazione::estrai()
|
||||
// Se va tutto ben fino a qui, posso andare a scrivere nella
|
||||
// tabella IVA i movimenti. F9IVA
|
||||
const result_estr res = estrazione_iva() ? estr_ok : estr_err_db_iva;
|
||||
if (res == estr_err_db_iva)
|
||||
{
|
||||
_head.stato_estr = D_GEST_ERR;
|
||||
update_drd_stato_estr();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
bool TEstrazione::estrazione_iva(bool escluso)
|
||||
{
|
||||
bool stato = true;
|
||||
TString query;
|
||||
TString numdoc, statopaiv, idfisc, paiv, codfis;
|
||||
bool stato = true;
|
||||
|
||||
TProgress_monitor bar(_movs.size(), "Estrazione dati IVA");
|
||||
for (auto it = _movs.begin(); it != _movs.end() && stato; ++it)
|
||||
{
|
||||
if (!bar.add_status())
|
||||
break;
|
||||
#ifdef DBG
|
||||
if (it->numreg == 95752) // Cartaceo
|
||||
bool simo = true;
|
||||
if (it->numreg == 95747) // idfisc errato Arredamenti Riva
|
||||
bool simo = true;
|
||||
if (it->numreg == 95740) // Annessi
|
||||
bool simo = true;
|
||||
#endif
|
||||
|
||||
if (!it->estratto)
|
||||
continue;
|
||||
|
||||
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.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;
|
||||
const TString& tipodoc = _head.tipo_doc;
|
||||
const TString& name_reg = TRegistro(TCausale(mov.get(MOV_CODCAUS), mov.get_date(MOV_DATAREG).year()).reg()).name();
|
||||
fill_id(cli, statopaiv, idfisc, paiv, codfis);
|
||||
numdoc.cut(0) << (mov.get(MOV_NUMDOCEXT).full() ? mov.get(MOV_NUMDOCEXT) : mov.get(MOV_NUMDOC));
|
||||
TString datadoc; datadoc << mov.get_date(MOV_DATADOC).date2ansi();
|
||||
TString datareg; datareg << mov.get_date(MOV_DATAREG).date2ansi();
|
||||
|
||||
TIva_insert_prepared_stat iva_query;
|
||||
|
||||
iva_query.add(IVA_CODSOC, _head.cod_soc);
|
||||
iva_query.add(IVA_IDLAN, _head.id_estr);
|
||||
iva_query.add(IVA_FLAG_PD, _head.flag_prov ? "P" : "D");
|
||||
iva_query.add(IVA_ANNOES, mov.get(MOV_ANNOES));
|
||||
iva_query.add(IVA_GIVA, tipodoc);
|
||||
iva_query.add(IVA_TIPOG, name_reg);
|
||||
iva_query.add(IVA_DOCXML, it->cartaceo ? "N" : "S");
|
||||
iva_query.add(IVA_TIPOCF, mov.get(MOV_TIPO));
|
||||
iva_query.add(IVA_CODCF, mov.get(MOV_CODCF));
|
||||
|
||||
iva_query.add(IVA_RAGSOC, check_str(cli.get(CLI_RAGSOC)));
|
||||
iva_query.add(IVA_IDFISC, idfisc);
|
||||
iva_query.add(IVA_PIVA, paiv);
|
||||
iva_query.add(IVA_CODFIS, codfis);
|
||||
iva_query.add(IVA_CATDOC, it->catdoc->catdoc);
|
||||
iva_query.add(IVA_CAUSSOS, it->catdoc->caus_sost);
|
||||
|
||||
iva_query.add(IVA_NUMDOC, numdoc);
|
||||
iva_query.add(IVA_DATADOC, datadoc);
|
||||
iva_query.add(IVA_SEZIVA, mov.get(MOV_REG));
|
||||
iva_query.add(IVA_TIPOREG, "");
|
||||
iva_query.add(IVA_NPROT, mov.get(MOV_PROTIVA));
|
||||
iva_query.add(IVA_DATPROT, datareg);
|
||||
|
||||
/*if(is_autofattura(mov))
|
||||
{
|
||||
query << ",\n"
|
||||
IVA_FORNOR ", " IVA_REGOR ", " IVA_NUMOR ", " IVA_DATAOR;
|
||||
iva_query.add(IVA_FORNOR, "");
|
||||
iva_query.add(IVA_REGOR, "");
|
||||
iva_query.add(IVA_NUMOR, N ORI);
|
||||
iva_query.add(IVA_DATAOR, 20010101);
|
||||
}*/
|
||||
query << ",\n"
|
||||
IVA_CLASDOC ", " IVA_USERELA ", " IVA_TIMEELA ", " IVA_NOMF1;
|
||||
|
||||
if (_head.tipo_doc == 'A')
|
||||
iva_query.add(IVA_CLASDOC, it->catdoc->class_sost);
|
||||
iva_query.add(IVA_NOMFD, it->nomefilecart.name());
|
||||
|
||||
// Load annessi...
|
||||
if(!it->annessi.empty())
|
||||
{
|
||||
query << ",\n"
|
||||
IVA_TIPPROT ", " IVA_NUMPROT ", " IVA_ANNPROT ", " IVA_TIMERIC;
|
||||
vector<annesso_t>& ann = it->annessi;
|
||||
TCategorie_doc cd;
|
||||
auto classost = [&](const int i)
|
||||
{
|
||||
const std::shared_ptr<TCategorie_doc::classe_doc> as = cd.get_classe_doc(ann[i].catdocann);
|
||||
if (as != nullptr)
|
||||
return as->class_sost;
|
||||
return TString("");
|
||||
};
|
||||
size_t i = 0;
|
||||
size_t size = ann.size();
|
||||
iva_query.add(IVA_CLASAN1, classost(i));
|
||||
iva_query.add(IVA_NOMF1, ann[i++].filename);
|
||||
// HOW DID MY LIFE COME TO THIS?....
|
||||
if (size > i)
|
||||
{
|
||||
iva_query.add(IVA_CLASAN2, classost(i));
|
||||
iva_query.add(IVA_NOMF2, ann[i++].filename);
|
||||
}
|
||||
if (size > i)
|
||||
{
|
||||
iva_query.add(IVA_CLASAN3, classost(i));
|
||||
iva_query.add(IVA_NOMF3, ann[i++].filename);
|
||||
}
|
||||
if (size > i)
|
||||
{
|
||||
iva_query.add(IVA_CLASAN4, classost(i));
|
||||
iva_query.add(IVA_NOMF4, ann[i++].filename);
|
||||
}
|
||||
if (size > i)
|
||||
{
|
||||
iva_query.add(IVA_CLASAN5, classost(i));
|
||||
iva_query.add(IVA_NOMF5, ann[i++].filename);
|
||||
}
|
||||
if (size > i)
|
||||
{
|
||||
iva_query.add(IVA_CLASAN4, classost(i));
|
||||
iva_query.add(IVA_NOMF4, ann[i++].filename);
|
||||
}
|
||||
if (size > i)
|
||||
{
|
||||
iva_query.add(IVA_CLASAN6, classost(i));
|
||||
iva_query.add(IVA_NOMF6, ann[i++].filename);
|
||||
}
|
||||
if (size > i)
|
||||
{
|
||||
iva_query.add(IVA_CLASAN7, classost(i));
|
||||
iva_query.add(IVA_NOMF7, ann[i++].filename);
|
||||
}
|
||||
if (size > i)
|
||||
{
|
||||
iva_query.add(IVA_CLASAN8, classost(i));
|
||||
iva_query.add(IVA_NOMF8, ann[i++].filename);
|
||||
}
|
||||
if (size > i)
|
||||
{
|
||||
iva_query.add(IVA_CLASAN9, classost(i));
|
||||
iva_query.add(IVA_NOMF9, ann[i++].filename);
|
||||
}
|
||||
}
|
||||
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();
|
||||
const TString classdoc = it->catdoc->class_sost;
|
||||
const TString nomefile = it->is_cartaceo() ? "nomefile.pdf" : ""; // todo:
|
||||
|
||||
// todo usare per categorie documentali caus_sos(mov, get_tipoiva());
|
||||
|
||||
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) << "', '" << it->catdoc->catdoc << "', '" << it->catdoc->caus_sost << "',\n" <<
|
||||
"'" << numdoc << "', '" << datadoc << "', '" << mov.get(MOV_REG) << "',\n" <<
|
||||
"'" << "" << "', '" << mov.get(MOV_PROTIVA) << "', '" << datareg << "'";
|
||||
//if (is_autofattura(mov))
|
||||
//{
|
||||
// query << ",\n" <<
|
||||
// "'" << "" << "', '" << "" << "', '" << "N ORI" << "', '" << "20010101" << "'";
|
||||
//}
|
||||
query << ",\n" <<
|
||||
"'" << classdoc << "', '" << user() << "', " << "GETDATE()" << ", '" << nomefile << "'";
|
||||
|
||||
// If cartaceo mettere nome file
|
||||
iva_query.add(IVA_USERELA, user());
|
||||
iva_query.add_getdate(IVA_TIMEELA);
|
||||
|
||||
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() << "'";
|
||||
iva_query.add(IVA_TIPPROT, fppro_db().get_tipoprot());
|
||||
iva_query.add(IVA_NUMPROT, fppro_db().get_numprot());
|
||||
iva_query.add(IVA_ANNPROT, fppro_db().get_annoprot());
|
||||
iva_query.add(IVA_TIMERIC, fppro_db().get_dataoraric());
|
||||
}
|
||||
query << "\n)";
|
||||
const bool ok = fp_db().sq_set_exec(query) && fp_db().sq_commit();
|
||||
|
||||
const bool ok = fp_db().sq_set_exec(iva_query.get()) && fp_db().sq_commit();
|
||||
if (!ok)
|
||||
write_errorsql_log(query);
|
||||
write_errorsql_log(iva_query.get());
|
||||
|
||||
stato &= ok;
|
||||
}
|
||||
@ -685,6 +881,14 @@ void TF9_dberr::add(const TString& string)
|
||||
add_str(str << "'" << string << "'");
|
||||
}
|
||||
|
||||
void TF9_dberr::add(const TDate& date)
|
||||
{
|
||||
if (date.ok())
|
||||
add(date.date2ansi());
|
||||
else
|
||||
add("00010101");
|
||||
}
|
||||
|
||||
void TF9_dberr::add(const long num)
|
||||
{
|
||||
TString app;
|
||||
@ -804,18 +1008,231 @@ std::shared_ptr<TCategorie_doc::classe_doc> TCategorie_doc::find_tipodoc(const T
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<pair<TString, TString>>::iterator TCategorie_doc::find_annesso(const TString& catdoc, const char* catdoc_ann)
|
||||
{
|
||||
for (auto it = _annessi.begin(); it != _annessi.end(); ++it)
|
||||
{
|
||||
if (it->first == catdoc && it->second == catdoc_ann)
|
||||
return it;
|
||||
}
|
||||
return _annessi.end();
|
||||
}
|
||||
|
||||
std::vector<pair<TString, std::shared_ptr<TArray_sheet>>>::iterator TCategorie_doc::find_sheet_annessi(const TString& catdoc)
|
||||
{
|
||||
for(auto it = _sheets_annessi.begin(); it != _sheets_annessi.end(); ++it)
|
||||
{
|
||||
if (it->first == catdoc)
|
||||
return it;
|
||||
}
|
||||
return _sheets_annessi.end();
|
||||
}
|
||||
|
||||
std::shared_ptr<TCategorie_doc::classe_doc> TCategorie_doc::get_classe_doc(const TString& catdoc)
|
||||
{
|
||||
for(auto it = _rows.begin(); it != _rows.end(); ++it)
|
||||
{
|
||||
if ((*it)->catdoc == catdoc)
|
||||
return *it;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void TCategorie_doc::load_all()
|
||||
{
|
||||
_rows.clear();
|
||||
_annessi.clear();
|
||||
int idx = 0;
|
||||
while (true)
|
||||
{
|
||||
const TString& appo = ini_get_string(CONFIG_DITTA, "F9", "CATDOC", "", idx++);
|
||||
const TString& appo = ini_get_string(CONFIG_DITTA, INI_PAR_MOD, INI_CATDOC, "", idx++);
|
||||
if (appo == "STOP" || appo.empty()) /* STOP: Riga terminatrice */
|
||||
break;
|
||||
TToken_string row(appo);
|
||||
classe_doc cd = { row.get(1), row.get(), row.get(), row.get(), row.get(), row.get(), row.get(), row.get() };
|
||||
_rows.emplace_back(std::make_shared<classe_doc>(cd));
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
while (true)
|
||||
{
|
||||
const TString& appo = ini_get_string(CONFIG_DITTA, INI_PAR_MOD, INI_ANNESSI, "", idx++);
|
||||
if (appo == "STOP" || appo.empty()) /* STOP: Riga terminatrice */
|
||||
break;
|
||||
TToken_string row(appo);
|
||||
_annessi.emplace_back(pair<TString, TString>({ row.get(0), row.get(1) }));
|
||||
}
|
||||
}
|
||||
|
||||
const char* TCategorie_doc::traduci_caus_sost(const TString& caus)
|
||||
{
|
||||
if (caus == "TD01") return "TD01 Fattura";
|
||||
if (caus == "TD02") return "TD02 Acconto/Anticipo su fattura";
|
||||
if (caus == "TD03") return "TD03 Acconto/Anticipo su parcella";
|
||||
if (caus == "TD04") return "TD04 Nota di credito";
|
||||
if (caus == "TD05") return "TD05 Nota di debito";
|
||||
if (caus == "TD06") return "TD06 Parcella";
|
||||
if (caus == "TD20") return "TD20 Autofattura";
|
||||
return "";
|
||||
}
|
||||
|
||||
const char* TCategorie_doc::traduci_class_ann(const TString& class_ann)
|
||||
{
|
||||
if (class_ann == "RC") return "Reverse Charge";
|
||||
if (class_ann == "DC") return "Doc. cartaceo";
|
||||
return "";
|
||||
}
|
||||
|
||||
const char* TCategorie_doc::traduci_class_sost(const TString& class_sost)
|
||||
{
|
||||
if (class_sost == "FTA") return "FTA - Fattura Acquisti";
|
||||
if (class_sost == "FTV") return "FTV - Fattura di Vendita";
|
||||
return "";
|
||||
}
|
||||
|
||||
void TCategorie_doc::add_annesso(const TString& catdoc, const char* catdoc_ann)
|
||||
{
|
||||
_annessi.insert(_annessi.end(), pair<TString, TString>({ catdoc, catdoc_ann }));
|
||||
|
||||
int idx = 0;
|
||||
TString iget = "start";
|
||||
while (iget != "STOP" && !iget.empty())
|
||||
{
|
||||
iget = ini_get_string(CONFIG_DITTA, INI_PAR_MOD, INI_ANNESSI, "", idx);
|
||||
ini_remove(CONFIG_DITTA, INI_PAR_MOD, INI_ANNESSI, idx++);
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
for(auto it = _annessi.begin(); it != _annessi.end(); ++it)
|
||||
{
|
||||
TToken_string row;
|
||||
row.add(it->first, 0);
|
||||
row.add(it->second);
|
||||
ini_set_string(CONFIG_DITTA, INI_PAR_MOD, INI_ANNESSI, row, idx++);
|
||||
}
|
||||
ini_set_string(CONFIG_DITTA, INI_PAR_MOD, INI_ANNESSI, "STOP", idx); // Riga terminatrice
|
||||
|
||||
reload();
|
||||
}
|
||||
|
||||
void TCategorie_doc::del_annesso(const TString& catdoc, const char* catdoc_ann)
|
||||
{
|
||||
const auto annesso = find_annesso(catdoc, catdoc_ann);
|
||||
if(annesso != _annessi.end())
|
||||
{
|
||||
_annessi.erase(annesso);
|
||||
|
||||
int idx = 0;
|
||||
TString iget = "start";
|
||||
while (iget != "STOP" && !iget.empty())
|
||||
{
|
||||
iget = ini_get_string(CONFIG_DITTA, INI_PAR_MOD, INI_ANNESSI, "", idx);
|
||||
ini_remove(CONFIG_DITTA, INI_PAR_MOD, INI_ANNESSI, idx++);
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
for (auto it = _annessi.begin(); it != _annessi.end(); ++it)
|
||||
{
|
||||
TToken_string row;
|
||||
row.add(it->first, 0);
|
||||
row.add(it->second);
|
||||
ini_set_string(CONFIG_DITTA, INI_PAR_MOD, INI_ANNESSI, row, idx++);
|
||||
}
|
||||
ini_set_string(CONFIG_DITTA, INI_PAR_MOD, INI_ANNESSI, "STOP", idx); // Riga terminatrice
|
||||
|
||||
reload();
|
||||
}
|
||||
}
|
||||
|
||||
TString_array TCategorie_doc::get_array_ann(const TString& catdoc)
|
||||
{
|
||||
TString_array sa(0);
|
||||
for(auto it = _annessi.begin(); it != _annessi.end(); ++it)
|
||||
{
|
||||
if (it->first == catdoc)
|
||||
{
|
||||
TToken_string row(it->second);
|
||||
sa.add(row);
|
||||
}
|
||||
}
|
||||
return sa;
|
||||
}
|
||||
|
||||
TString_array TCategorie_doc::get_array_rows(bool traduci)
|
||||
{
|
||||
TString_array sa(_rows.size());
|
||||
for(auto it = _rows.begin(); it != _rows.end(); ++it)
|
||||
{
|
||||
const shared_ptr<classe_doc>& row = *it;
|
||||
TToken_string ts;
|
||||
ts.add(row->catdoc);
|
||||
ts.add(row->descr);
|
||||
ts.add(!traduci ? row->class_sost : traduci_class_sost(row->class_sost));
|
||||
ts.add(!traduci ? row->caus_sost : traduci_caus_sost(row->caus_sost));
|
||||
ts.add(row->causcont);
|
||||
ts.add(row->tipocaus);
|
||||
ts.add(!traduci ? row->tipomov : traduci_class_ann(row->tipomov));
|
||||
|
||||
sa.add(ts);
|
||||
}
|
||||
return sa;
|
||||
}
|
||||
|
||||
std::shared_ptr<TArray_sheet> TCategorie_doc::get_sheet_catdocs()
|
||||
{
|
||||
if (_sheet_catdocs == nullptr)
|
||||
{
|
||||
_sheet_catdocs = make_shared<TArray_sheet>(-1, -1, 78, 13, "cat.docs",
|
||||
"Categoria\nDocumento(Codice)@15|Descrizione\nDocumento@26|"
|
||||
"Classe Documentale\nSostitutiva@25|Causale per\nSostitutiva (TD01...)@34|"
|
||||
"Causale\nContabile@8|Tipo\nDocumento@6|Classificazione\nAnnesso@15",
|
||||
MODE_SHEETS);
|
||||
if (!_name_catdocs)
|
||||
_name_catdocs = make_shared<set<TString>>();
|
||||
else
|
||||
_name_catdocs->clear();
|
||||
//_sheet_catdocs->add_button(DLG_CANCEL, "Annulla", K_ESC, TOOL_CANCEL, TOOL_CANCEL);
|
||||
const TString_array ar = get_array_rows(true);
|
||||
FOR_EACH_ARRAY_ITEM(ar, nr, row)
|
||||
{
|
||||
_sheet_catdocs->add(*(TToken_string*)row);
|
||||
_name_catdocs->insert(((TToken_string*)row)->get(0));
|
||||
}
|
||||
}
|
||||
return _sheet_catdocs;
|
||||
}
|
||||
|
||||
std::shared_ptr<TArray_sheet> TCategorie_doc::get_sheet_ann(const TString& catdoc)
|
||||
{
|
||||
auto it = find_sheet_annessi(catdoc);
|
||||
if (it == _sheets_annessi.end())
|
||||
{
|
||||
const auto inserted = _sheets_annessi.insert(_sheets_annessi.end(), {
|
||||
catdoc, make_shared<TArray_sheet>(-1, -1, 78, 13, "Annessi",
|
||||
"Categoria\nAnnesso(Codice)@15|Descrizione\nDocumento@26|"
|
||||
"Classe Documentale\nSostitutiva@25|Classificazione\nAnnesso@14",
|
||||
MODE_SHEETS)
|
||||
});
|
||||
const TString_array aann = get_array_ann(catdoc);
|
||||
if (!aann.empty())
|
||||
{
|
||||
TArray_sheet* as = inserted->second.get();
|
||||
TRecord_categorie rec;
|
||||
FOR_EACH_ARRAY_ITEM(aann, nr, row)
|
||||
{
|
||||
rec.put("NAME", ((TToken_string*)row)->get(0));
|
||||
rec.read(true);
|
||||
TToken_string t;
|
||||
t.add(((TToken_string*)row)->get(0));
|
||||
t.add(rec.get("DESCR"));
|
||||
t.add(rec.get("CLASSDOCSOS"));
|
||||
t.add(rec.get("CLASSANN"));
|
||||
as->add(t);
|
||||
}
|
||||
}
|
||||
it = inserted;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
std::shared_ptr<TCategorie_doc::classe_doc> TCategorie_doc::mov2cat(const int numreg)
|
||||
@ -827,7 +1244,7 @@ std::shared_ptr<TCategorie_doc::classe_doc> TCategorie_doc::mov2cat(const int nu
|
||||
mov.read();
|
||||
|
||||
const TString& caus = mov.get(MOV_CODCAUS);
|
||||
const TCausale c(caus);
|
||||
const TCausale c(caus, mov.get_date(MOV_DATAREG).year());
|
||||
const TString& tipodoc = c.tipo_doc();
|
||||
|
||||
// Cerco se ho un record che abbia specificata quella caus. contabile
|
||||
@ -838,7 +1255,88 @@ std::shared_ptr<TCategorie_doc::classe_doc> TCategorie_doc::mov2cat(const int nu
|
||||
return find_tipodoc(tipodoc);
|
||||
}
|
||||
|
||||
void TCategorie_doc::reload()
|
||||
{
|
||||
load_all();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// TRecord_categorie
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TString TRecord_categorie::get(const char* field)
|
||||
{
|
||||
recordtype& rec = _table == 0 ? _categorie : _annessi;
|
||||
const int i = rec.head.find(field);
|
||||
if (i != -1)
|
||||
return rec.record.get(i);
|
||||
return "";
|
||||
}
|
||||
|
||||
bool TRecord_categorie::next()
|
||||
{
|
||||
recordtype& rec = _table == 0 ? _categorie : _annessi;
|
||||
TToken_string* p = (TToken_string*)_result_set.objptr(_next_pos++);
|
||||
rec.record = p ? *p : "";
|
||||
return p;
|
||||
}
|
||||
|
||||
void TRecord_categorie::put(const char* field, const char* value)
|
||||
{
|
||||
recordtype& rec = _table == 0 ? _categorie : _annessi;
|
||||
const int i = rec.head.find(field);
|
||||
if (i != -1)
|
||||
rec.record.add(value, i);
|
||||
}
|
||||
|
||||
bool TRecord_categorie::read(bool traduci)
|
||||
{
|
||||
_next_pos = 0;
|
||||
_result_set.destroy();
|
||||
if (_table == 0)
|
||||
{
|
||||
const TString_array sa = get_array_rows(traduci);
|
||||
FOR_EACH_ARRAY_ITEM(sa, nr, str)
|
||||
{
|
||||
TString s = (*(TToken_string*)str).get(0);
|
||||
if (s == _categorie.record.get(0))
|
||||
_result_set.add(*(TToken_string*)str);
|
||||
}
|
||||
return next();
|
||||
}
|
||||
else
|
||||
{
|
||||
const TString catdoc = _annessi.record.get(0);
|
||||
const TString name = _annessi.record.get(1);
|
||||
const TString_array sa = get_array_ann(catdoc);
|
||||
FOR_EACH_ARRAY_ITEM(sa, nr, str)
|
||||
{
|
||||
TString n = (*(TToken_string*)str).get(0);
|
||||
if (name.empty() || n == name)
|
||||
{
|
||||
TToken_string t;
|
||||
t.add(catdoc);
|
||||
t.add(n);
|
||||
_result_set.add(t);
|
||||
}
|
||||
}
|
||||
return next();
|
||||
}
|
||||
}
|
||||
|
||||
TRecord_categorie::TRecord_categorie(type table): _table(table)
|
||||
{
|
||||
_categorie.head.add("NAME");
|
||||
_categorie.head.add("DESCR");
|
||||
_categorie.head.add("CLASSDOCSOS");
|
||||
_categorie.head.add("CAUSSOS");
|
||||
_categorie.head.add("CAUSCONT");
|
||||
_categorie.head.add("TIPODOC");
|
||||
_categorie.head.add("CLASSANN");
|
||||
|
||||
_annessi.head.add("CATDOC");
|
||||
_annessi.head.add("NAME");
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
135
src/f9/f9lib01.h
135
src/f9/f9lib01.h
@ -1,17 +1,33 @@
|
||||
#ifndef _F901001_H_
|
||||
#define _F901001_H_
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "strings.h"
|
||||
#include "date.h"
|
||||
#include "real.h"
|
||||
#include "cglib01.h"
|
||||
#include "sheet.h"
|
||||
|
||||
#define INI_PAR_MOD "F9"
|
||||
#define INI_CATDOC "CATDOC"
|
||||
#define INI_ANNESSI "ANNCAT"
|
||||
|
||||
const TDate today(TODAY);
|
||||
|
||||
struct annesso_t
|
||||
{
|
||||
TString numreg; // TString ez-pz
|
||||
TString filename;
|
||||
TString catdocpad;
|
||||
TString catdocann;
|
||||
TDate loaddate;
|
||||
TString user;
|
||||
};
|
||||
|
||||
struct statistics
|
||||
{
|
||||
size_t total;
|
||||
@ -127,33 +143,70 @@ public:
|
||||
TString opcee;
|
||||
};
|
||||
private:
|
||||
std::vector<std::shared_ptr<classe_doc>> _rows;
|
||||
std::vector<std::shared_ptr<classe_doc>> _rows;
|
||||
std::vector<std::pair<TString, TString>> _annessi;
|
||||
std::vector<std::pair<TString, std::shared_ptr<TArray_sheet>>> _sheets_annessi;
|
||||
std::shared_ptr<TArray_sheet> _sheet_catdocs;
|
||||
std::shared_ptr<std::set<TString>> _name_catdocs;
|
||||
|
||||
std::vector<std::shared_ptr<classe_doc>>::iterator find(const TString& class_sost, const TString& caus_sost,
|
||||
const TString& op_cee);
|
||||
const TString& op_cee);
|
||||
std::shared_ptr<classe_doc> find_causcont(const TString& caus);
|
||||
std::shared_ptr<classe_doc> find_tipodoc(const TString& tipodoc);
|
||||
|
||||
std::vector<pair<TString, TString>>::iterator find_annesso(const TString& catdoc, const char* catdoc_ann);
|
||||
std::vector<pair<TString, std::shared_ptr<TArray_sheet>>>::iterator find_sheet_annessi(const TString& catdoc);
|
||||
|
||||
|
||||
void load_all();
|
||||
|
||||
static const char* traduci_caus_sost(const TString& caus);
|
||||
static const char* traduci_class_ann(const TString& class_ann);
|
||||
static const char* traduci_class_sost(const TString& class_sost);
|
||||
public:
|
||||
std::shared_ptr<classe_doc> causcont2cat(const char* caus, bool force_cartacea);
|
||||
std::shared_ptr<classe_doc> mov2cat(int numreg);
|
||||
void reload()
|
||||
{
|
||||
_rows.clear();
|
||||
load_all();
|
||||
}
|
||||
//std::shared_ptr<classe_doc> causcont2cat(const char* caus, bool force_cartacea);
|
||||
void add_annesso(const TString& catdoc, const char* catdoc_ann);
|
||||
void del_annesso(const TString& catdoc, const char* catdoc_ann);
|
||||
TString_array get_array_ann(const TString& catdoc);
|
||||
TString_array get_array_rows(bool traduci = false);
|
||||
std::shared_ptr<classe_doc> get_classe_doc(const TString& catdoc);
|
||||
std::set<TString>& get_name_catdocs() { get_sheet_catdocs(); return *_name_catdocs; }
|
||||
std::shared_ptr<TArray_sheet> get_sheet_catdocs();
|
||||
std::shared_ptr<TArray_sheet> get_sheet_ann(const TString& catdoc);
|
||||
std::shared_ptr<classe_doc> mov2cat(int numreg);
|
||||
void reload();
|
||||
|
||||
TCategorie_doc() { load_all(); }
|
||||
};
|
||||
|
||||
class TRecord_categorie : public TCategorie_doc
|
||||
{
|
||||
public:
|
||||
enum type { catdocs = 0, annessi = 1 };
|
||||
private:
|
||||
type _table;
|
||||
struct recordtype
|
||||
{
|
||||
TString_array head;
|
||||
TToken_string record;
|
||||
} _categorie, _annessi;
|
||||
TString_array _result_set;
|
||||
int _next_pos{ 0 };
|
||||
|
||||
public:
|
||||
TString get(const char* field);
|
||||
bool next();
|
||||
void put(const char* field, const char* value);
|
||||
bool read(bool traduci = false);
|
||||
|
||||
TRecord_categorie(type table = catdocs);
|
||||
};
|
||||
|
||||
inline TCategorie_doc& categorie_doc()
|
||||
{
|
||||
static unique_ptr<TCategorie_doc> cd = nullptr;
|
||||
if (cd == nullptr)
|
||||
cd = make_unique<TCategorie_doc>();
|
||||
else
|
||||
cd->reload();
|
||||
return *cd;
|
||||
}
|
||||
|
||||
@ -167,7 +220,10 @@ struct movimento_t
|
||||
no_doc, // Il mov. di vendita non ha un documento generatore.
|
||||
notfound_elet, // Non trovata fatt. elettronica mov vendita.
|
||||
no_fa, // Movimento di acquisto non e' una fattura.
|
||||
no_cartaceo // Movimento cartaceo che non ha bisogno di essere estratto.
|
||||
no_fv, // Movimento di vendita non e' una fattura.
|
||||
no_cartaceo, // Movimento cartaceo che non ha bisogno di essere estratto.
|
||||
pura_iva, // Movimento di sola IVA (integrazione Rev. Charge)
|
||||
no_filecart // Il documento cartaceo non ha associato un file, o questo non e' stato trovato.
|
||||
};
|
||||
|
||||
bool err;
|
||||
@ -183,10 +239,13 @@ struct movimento_t
|
||||
TString reg_protiva;
|
||||
TString descr;
|
||||
state_fppro state{ null_state };
|
||||
TString descr_err;
|
||||
TString descr_err; // Messaggio di errore visibile dal controllo estrazion
|
||||
bool estratto{ true };
|
||||
err_mov descr_estr{ no_err };
|
||||
err_mov descr_estr{ no_err }; // Messaggio di informazioni visibile dal 'Apri Estr.'
|
||||
std::shared_ptr<TCategorie_doc::classe_doc> catdoc;
|
||||
bool cartaceo{ false };
|
||||
TFilename nomefilecart;
|
||||
vector<annesso_t> annessi;
|
||||
|
||||
static const char* err_mov2name(const err_mov descr_estr)
|
||||
{
|
||||
@ -204,8 +263,12 @@ struct movimento_t
|
||||
return "Non trovata fatt. elettronica mov vendita";
|
||||
case no_fa:
|
||||
return "Questo movimento di acquisto non e' una fattura";
|
||||
case no_fv:
|
||||
return "Movimento di vendita non e' una fattura.";
|
||||
case no_cartaceo:
|
||||
return "Movimento cartaceo che non ha bisogno di essere estratto";
|
||||
case pura_iva:
|
||||
return "Movimento di sola IVA. (Le integrazioni Rev. Charge sono gestite come annessi alle vendite)";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
@ -271,10 +334,13 @@ class TEstrazione : public TObject
|
||||
* \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 state_fppro check_fppro(int numreg);
|
||||
bool check_periodo_def() const;
|
||||
void copy_file_to_webapp_fld(const movimento_t& movimento) const;
|
||||
static void fill_id(TLocalisamfile& clifo, TString& statopaiv, TString& idfisc, TString& paiv, TString& codfis);
|
||||
TipoIVA get_tipoiva() const { return _head.tipo_doc == 'A' ? iva_acquisti : iva_vendite; }
|
||||
static bool is_doc_xml(const TLocalisamfile& mov);
|
||||
static bool load_annessi(movimento_t& movimento);
|
||||
|
||||
static TString& drd_attr();
|
||||
TString& drd_tovalues() const;
|
||||
@ -285,8 +351,9 @@ class TEstrazione : public TObject
|
||||
/** 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;
|
||||
TString next_estr_today(char tipo) const;
|
||||
static bool pura_iva(const TLocalisamfile& mov);
|
||||
void write_errorsql_log(const TString& query) const;
|
||||
|
||||
public:
|
||||
|
||||
@ -350,7 +417,7 @@ protected:
|
||||
void write_sqlerrlog(const TString& query) const;
|
||||
public:
|
||||
void add(const TString& string);
|
||||
void add(const TDate& date) { add(date.date2ansi()); }
|
||||
void add(const TDate& date);
|
||||
void add(const char* string) { add(TString(string)); }
|
||||
void add(long num);
|
||||
void add() { add_str("NULL"); }
|
||||
@ -360,12 +427,30 @@ public:
|
||||
TF9_dberr();
|
||||
};
|
||||
|
||||
class TF9_doccart : public TLocalisamfile
|
||||
class TIva_insert_prepared_stat
|
||||
{
|
||||
public:
|
||||
bool mov2doc(int numreg, _Out_ TFilename& doc);
|
||||
TString _query;
|
||||
vector<pair<TString, TString>> _fields;
|
||||
|
||||
TF9_doccart() : TLocalisamfile(LF_F9CART) { }
|
||||
void write();
|
||||
public:
|
||||
void add(const char* field, const TString& value);
|
||||
void add_getdate(const char* field);
|
||||
const char* get() { if(_query.empty()) write(); return _query; }
|
||||
void reset();
|
||||
};
|
||||
|
||||
class TF9_doccart
|
||||
{
|
||||
TLocalisamfile _tdocs;
|
||||
TLocalisamfile _tannessi;
|
||||
public:
|
||||
bool doc_already_exists(const TFilename& file, _Out_ TString& numreg, _Out_ bool& annesso);
|
||||
bool mov2doc(const TString& numreg, _Out_ TFilename& doc);
|
||||
bool mov2listann(const TString& numreg, _Out_ TString_array& list_annessi);
|
||||
bool mov2listann_vect(const TString& numreg, _Out_ vector<annesso_t>& list_annessi);
|
||||
|
||||
TF9_doccart() : _tdocs(LF_F9DOCS), _tannessi(LF_F9ANNESSI) { }
|
||||
};
|
||||
|
||||
#endif // #ifndef _F901001_H_
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include <f9cart.h>
|
||||
|
||||
#include "f9lib01.h"
|
||||
|
||||
#include "applicat.h"
|
||||
#include "docf9.h"
|
||||
#include "annessif9.h"
|
||||
#include "f901tab.h"
|
||||
|
||||
#define AMBIENTE_F9 "CODSOC" // Codice ambiente (codsoc)
|
||||
#define ADDRCART_F9 "ADDRCART"
|
||||
@ -10,7 +11,7 @@
|
||||
#define ESTENSIONI_F9 "DOCUMENTI_EXT" //
|
||||
#define CARTEXP_F9 "CARTEXP" // Flag esporta documenti cartacei
|
||||
#define CHECKVEND_F9 "CHECKVEND" // Flag controlli per vendite (quando hai fatt. con Campo)
|
||||
#define VIEWMOV_F9 "VIEWMOVPRE" // Flag visualizza moviementi prima di estrarre
|
||||
#define VIEWMOV_F9 "VIEWMOVPRE" // Flag visualizza movimenti prima di estrarre
|
||||
|
||||
TF9_config F9CONF;
|
||||
|
||||
@ -71,14 +72,147 @@ TF9_config::TF9_config()
|
||||
// TF9_doccart
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TF9_doccart::mov2doc(int numreg, _Out_ TFilename& doc)
|
||||
bool TF9_doccart::doc_already_exists(const TFilename& file, _Out_ TString& numreg, _Out_ bool& annesso)
|
||||
{
|
||||
zero();
|
||||
setkey(2); // Ricerca per NUMREG
|
||||
put(F9C_NUMREG, numreg);
|
||||
const bool ok = read() == NOERR;
|
||||
numreg = "";
|
||||
annesso = false;
|
||||
_tdocs.zero();
|
||||
_tdocs.setkey(2);
|
||||
_tdocs.put(F9C_FILENAME, file.name());
|
||||
bool ok = _tdocs.read() == NOERR;
|
||||
if (ok)
|
||||
numreg = _tdocs.get(F9C_NUMREG);
|
||||
else
|
||||
{
|
||||
_tannessi.zero();
|
||||
_tannessi.setkey(2);
|
||||
_tannessi.put(F9A_FILENAME, file.name());
|
||||
ok = _tannessi.read() == NOERR;
|
||||
if (ok)
|
||||
{
|
||||
numreg = _tannessi.get(F9A_NUMREG);
|
||||
annesso = true;
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TF9_doccart::mov2doc(const TString& numreg, _Out_ TFilename& doc)
|
||||
{
|
||||
_tdocs.zero();
|
||||
_tdocs.setkey(1); // Ricerca per NUMREG
|
||||
_tdocs.put(F9C_NUMREG, numreg);
|
||||
const bool ok = _tdocs.read() == NOERR;
|
||||
doc.cut(0);
|
||||
if (ok)
|
||||
doc << TFilename(F9CONF.get_addr_cart()).slash_terminate() << get(F9C_FILENAME);
|
||||
doc << TFilename(F9CONF.get_addr_cart()).slash_terminate() << _tdocs.get(F9C_FILENAME);
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
bool TF9_doccart::mov2listann(const TString& numreg, _Out_ TString_array& list_annessi)
|
||||
{
|
||||
list_annessi.destroy();
|
||||
_tannessi.zero();
|
||||
_tannessi.setkey(1);
|
||||
_tannessi.put(F9A_NUMREG, numreg);
|
||||
|
||||
TString numreg_fetched;
|
||||
bool ok = false;
|
||||
// Si posiziona nl primo record giusto. Poi per sapere quando terminare guardo se la chiave e' ancora quella giusta.
|
||||
for (_tannessi.read(_isgteq); (numreg_fetched = _tannessi.get(F9A_NUMREG)) == numreg; _tannessi.next())
|
||||
{
|
||||
ok = true;
|
||||
TString filename = _tannessi.get(F9A_FILENAME);
|
||||
TToken_string t;
|
||||
t.add(numreg_fetched);
|
||||
t.add(_tannessi.get(F9A_FILENAME));
|
||||
t.add(_tannessi.get(F9A_CATDOCPAD));
|
||||
t.add(_tannessi.get(F9A_CATDOCANN));
|
||||
t.add(_tannessi.get(F9A_LOADDATE));
|
||||
t.add(_tannessi.get(F9A_USER));
|
||||
list_annessi.add(t);
|
||||
#ifdef DBG
|
||||
CHECK(numreg_fetched == numreg_fetched, "*Maledetooo*");
|
||||
#endif
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TF9_doccart::mov2listann_vect(const TString& numreg, vector<annesso_t>& list_annessi)
|
||||
{
|
||||
list_annessi.clear();
|
||||
_tannessi.zero();
|
||||
_tannessi.setkey(1);
|
||||
_tannessi.put(F9A_NUMREG, numreg);
|
||||
|
||||
TString numreg_fetched;
|
||||
bool ok = false;
|
||||
// Si posiziona nl primo record giusto. Poi per sapere quando terminare guardo se la chiave e' ancora quella giusta.
|
||||
for (bool r = _tannessi.read(_isgteq) == NOERR; (numreg_fetched = _tannessi.get(F9A_NUMREG)) == numreg && r; r = _tannessi.next() == NOERR)
|
||||
{
|
||||
ok = true;
|
||||
TString filename = _tannessi.get(F9A_FILENAME);
|
||||
annesso_t t;
|
||||
t.numreg = numreg_fetched;
|
||||
t.filename = _tannessi.get(F9A_FILENAME);
|
||||
t.catdocpad = _tannessi.get(F9A_CATDOCPAD);
|
||||
t.catdocann = _tannessi.get(F9A_CATDOCANN);
|
||||
t.loaddate = _tannessi.get(F9A_LOADDATE);
|
||||
t.user = _tannessi.get(F9A_USER);
|
||||
list_annessi.emplace_back(t);
|
||||
#ifdef DBG
|
||||
CHECK(numreg_fetched == numreg_fetched, "*Maledetooo*");
|
||||
#endif
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// TIva_insert_prepared_stat
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TIva_insert_prepared_stat::write()
|
||||
{
|
||||
TString vals_appo;
|
||||
_query.cut(0) << "INSERT INTO " F9_IVA " (\n";
|
||||
int count = 0;
|
||||
bool first = true;
|
||||
for(auto it = _fields.begin(); it != _fields.end(); ++it)
|
||||
{
|
||||
if (!first)
|
||||
{
|
||||
_query << ", ";
|
||||
vals_appo << ", ";
|
||||
}
|
||||
if (!first && count == 0)
|
||||
{
|
||||
_query << "\n";
|
||||
vals_appo << "\n";
|
||||
}
|
||||
_query << it->first;
|
||||
vals_appo << it->second;
|
||||
first = false;
|
||||
count = ++count % 3;
|
||||
}
|
||||
_query << "\n)\nVALUES (\n" << vals_appo << "\n)";
|
||||
bool simo = true;
|
||||
}
|
||||
|
||||
void TIva_insert_prepared_stat::add(const char* field, const TString& value)
|
||||
{
|
||||
_fields.insert(_fields.end(), { field, TString("'") << value << "'" });
|
||||
}
|
||||
|
||||
void TIva_insert_prepared_stat::add_getdate(const char* field)
|
||||
{
|
||||
_fields.insert(_fields.end(), { field, "GETDATE()" });
|
||||
}
|
||||
|
||||
void TIva_insert_prepared_stat::reset()
|
||||
{
|
||||
_query.cut(0);
|
||||
_fields.clear();
|
||||
}
|
||||
|
11
src/include/annessif9.h
Normal file
11
src/include/annessif9.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __ANNESSIF9_H_
|
||||
#define __ANNESSIF9_H_
|
||||
|
||||
#define F9A_NUMREG "NUMREG"
|
||||
#define F9A_FILENAME "FILENAME"
|
||||
#define F9A_CATDOCPAD "CATDOCPAD"
|
||||
#define F9A_CATDOCANN "CATDOCANN"
|
||||
#define F9A_LOADDATE "LOADDATE"
|
||||
#define F9A_USER "USER"
|
||||
|
||||
#endif // __ANNESSIF9_H_
|
9
src/include/docf9.h
Normal file
9
src/include/docf9.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef __DOCF9_H_
|
||||
#define __DOCF9_H_
|
||||
|
||||
#define F9C_FILENAME "FILENAME"
|
||||
#define F9C_NUMREG "NUMREG"
|
||||
#define F9C_LOADDATE "LOADDATE"
|
||||
#define F9C_USER "USER"
|
||||
|
||||
#endif // __DOCF9_H_
|
@ -54,7 +54,8 @@ long TExternal_app::run(
|
||||
if (our_app && atoi(name) < 70)
|
||||
{
|
||||
our_app = (isalpha(name[0]) && isalpha(name[1])) &&
|
||||
(isdigit(name[2]) || name.ends_with("cnv"));
|
||||
(isdigit(name[2]) || name.ends_with("cnv"))
|
||||
|| name.starts_with("f9");
|
||||
}
|
||||
if (!our_app) // Non e' un programma di campo per cui ...
|
||||
utente = 0; // ... non aggiungo il codice utente al comando
|
||||
|
@ -198,8 +198,9 @@
|
||||
#define LF_FPCART 178
|
||||
#define LF_FPCADG 179
|
||||
#define LF_CONART 180
|
||||
#define LF_F9CART 181
|
||||
#define LF_DBLOG 182
|
||||
#define LF_F9DOCS 181
|
||||
#define LF_DBLOG 182
|
||||
#define LF_F9ANNESSI 183
|
||||
|
||||
#define LF_EXTERNAL 1000 // Files with id >= are considered to be externals
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user