Merge branch 'R_10_00' of http://10.65.20.33/sirio/CAMPO/campo into R_10_00

# Conflicts:
#	src/fp/fplib01.cpp
This commit is contained in:
Simone Palacino 2019-04-02 17:28:28 +02:00
commit f7e5294b2e
22 changed files with 605 additions and 221 deletions

View File

@ -178,6 +178,8 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\src\fp\fplib04.cpp" />
<ClCompile Include="..\src\ve\velib01.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -21,6 +21,12 @@
<ClCompile Include="..\src\fe\felib.cpp">
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="..\src\ve\velib01.cpp">
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="..\src\fp\fplib04.cpp">
<Filter>Sources</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\fp\fplib.h">

9
cd/test/fp0752.txt Normal file
View File

@ -0,0 +1,9 @@
fp0.exe
fp0100a.msk
fp0300a.msk
- Messo come default programma fp0100
- Aggiunta la possibilità di esportare i documenti in stato "Diagnosticato" e non "Pronto" così da poter eliminarli prima che l'XML venga generato
- Aggiunta funzione di collegamento chiavi per i documenti persi nel limbo
- Rifatta funzione "imposta pronto", adesso non cambia lo stato a tutti i doc ma solo quelli segnati
- Sistemato errore che riportava la qta a zero

21
cd/test/fp0752a.ini Normal file
View File

@ -0,0 +1,21 @@
[Main]
Demo=0
[fp1]
File(0) = fp0.exe|X
File(1) = fp0100a.msk|X
File(3) = fp0300a.msk|X
Patch = 752
Versione = 21511200
[fp]
Data = 02-04-2019
Descrizione = Fattura Elettronica
Dischi = 1
Moduli = cg,ve
OEM =
Patch = 752
PostProcess =
PreProcess =
Versione = 21511200

BIN
cd/test/fp0752a1.zip Normal file

Binary file not shown.

3
cd/test/sy0752.txt Normal file
View File

@ -0,0 +1,3 @@
xvtdb.dll
Ottimizzata esecuzione queries

21
cd/test/sy0752a.ini Normal file
View File

@ -0,0 +1,21 @@
[Main]
Demo=0
[sy1]
File(53) = xvtdb.dll|X
Patch = 752
Versione = 21511200
[sy]
Data = 02-04-2019
Descrizione = Sistema
Dischi = 1
Moduli =
OEM =
Patch = 752
PostProcess =
PreProcess =
Prezzo(1) =
Prezzo(2) =
Versione = 21511200

BIN
cd/test/sy0752a1.zip Normal file

Binary file not shown.

View File

@ -4,7 +4,7 @@
int main(int argc, char** argv)
{
int rt = -1;
const int r = (argc > 1) ? atoi( &argv[1][1] ) : 1;
const int r = (argc > 1) ? atoi( &argv[1][1] ) : 0;
switch (r)
{

View File

@ -47,6 +47,7 @@ void TParametri_mask::save_all() const
fp_settings().set_f8(get_bool(F_F8));
fp_settings().set_check_not_block(get_bool(F_CHECK_NOT_BLOCK));
fp_settings().set_no_sconti_fatt(get_bool(F_CHECK_NO_SCONTI));
fp_settings().set_no_export_pronto(get_bool(F_CHECK_NO_EXPORT_PRONTO));
TFP_righe_custom().save_sheet(sfield(F_FORMPERS));
TFP_nota_piede_f().save_sheet(sfield(F_NPFSHEET));
}
@ -65,6 +66,7 @@ void TParametri_mask::load_all()
set(F_F8, fp_settings().is_f8());
set(F_CHECK_NOT_BLOCK, fp_settings().get_check_not_block());
set(F_CHECK_NO_SCONTI, fp_settings().get_no_sconti_fatt());
set(F_CHECK_NO_EXPORT_PRONTO, fp_settings().get_no_export_pronto());
TFP_righe_custom().load_sheet(sfield(F_FORMPERS));
TFP_nota_piede_f().load_sheet(sfield(F_NPFSHEET));
}
@ -109,30 +111,15 @@ TMask & TParametri_mask::get_tmp_msk(const char * title)
return *m;
}
bool TParametri_mask::on_key(KEY key)
bool TParametri_mask::on_key(const KEY key)
{
switch(key)
if (key == K_SHIFT + K_F12)
{
case K_SHIFT + K_F12:
if (run_fp_psw_mask())
{
TMask& m = get_tmp_msk("Password");
m.add_string(101, 0, "Password ", 1, 1, 15, "*");
m.field(101).check_type(CHECK_REQUIRED);
while(m.run() == K_ENTER)
{
if (m.get(101) == "sirioFATT99") // Hardcoded password are the best!
{
for (int i = F_SETPATCH; i <= F_REBORNDB; i++)
enable(i);
break;
}
else
error_box("Password errata");
}
break;
for (int i = F_SETPATCH; i <= F_REBORNDB; i++)
enable(i);
}
default:
break;
}
return true;
}

View File

@ -1,32 +1,33 @@
#define F_INDIRIZZO 201
#define F_DATABASE 202
#define F_USER 203
#define F_PASSWORD 204
#define F_FLDDEST 205
#define F_FLDUSRDEST 206
#define F_COFI 207
#define F_ESPORTAALLEG 208
#define F_ESPORTADOC 209
#define F_F8 210
#define F_CHECK_NOT_BLOCK 211
#define F_CHECK_NO_SCONTI 212
#define F_INDIRIZZO 201
#define F_DATABASE 202
#define F_USER 203
#define F_PASSWORD 204
#define F_FLDDEST 205
#define F_FLDUSRDEST 206
#define F_COFI 207
#define F_ESPORTAALLEG 208
#define F_ESPORTADOC 209
#define F_F8 210
#define F_CHECK_NOT_BLOCK 211
#define F_CHECK_NO_SCONTI 212
#define F_CHECK_NO_EXPORT_PRONTO 213
#define F_SETPATCH 301
#define F_ENPTYTABLE 302
#define F_DROPTABLE 303
#define F_REBORNDB 304
#define F_SETPATCH 301
#define F_ENPTYTABLE 302
#define F_DROPTABLE 303
#define F_REBORNDB 304
#define F_FORMPERS 401
#define F_FORMPERS 401
#define S_TIPODOC 101
#define S_TIPORIGA 102
#define S_QTA 103
#define S_PREZZO 104
#define S_IMPONIBILE 105
#define S_TIPODOC 101
#define S_TIPORIGA 102
#define S_QTA 103
#define S_PREZZO 104
#define S_IMPONIBILE 105
#define F_NPFSHEET 501
#define F_NPFSHEET 501
#define S_DOC 101
#define S_NOTAPF 102
#define S_DOC 101
#define S_NOTAPF 102

View File

@ -101,7 +101,7 @@ BEGIN
ITEM "Imponibile"
END
GROUPBOX DLG_NULL 78 3
GROUPBOX DLG_NULL 78 4
BEGIN
PROMPT 1 8 "@BControlli preventivi"
END
@ -111,19 +111,24 @@ BEGIN
PROMPT 2 9 "Rendi controlli XML non bloccanti"
END
BOOLEAN F_CHECK_NO_EXPORT_PRONTO
BEGIN
PROMPT 2 10 "Esporta i documenti in stato diagnosticato"
END
GROUPBOX DLG_NULL 78 3
BEGIN
PROMPT 1 11 "@BPersonalizzazioni documento"
PROMPT 1 12 "@BPersonalizzazioni documento"
END
BOOLEAN F_CHECK_NO_SCONTI
BEGIN
PROMPT 2 12 "Non esporre sconti in fattura"
PROMPT 2 13 "Non esporre sconti in fattura"
END
SPREADSHEET F_NPFSHEET 60 6
BEGIN
PROMPT 1 14 "Inserimento\nNote piede fattura"
PROMPT 1 15 "Inserimento\nNote piede fattura"
ITEM "Tipo\nDoc@4"
ITEM "Nota piede\nFattura@15"
END

View File

@ -12,6 +12,7 @@
#include "fp0.h"
#include "fp0300a.h"
#include "fp0100a.h"
/////////////////////////////////////////////////////////////////////////////////////
// Globals
@ -29,23 +30,28 @@ class TPA_mask : public TAutomask
protected:
enum {_codnum, _tipodoc, _dastato, _astato, _tiposdi};
void set_filter_changed();
void set_pronto();
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
void next_page(int p);
bool check_not_empty();
bool check_full_fields() const;
bool check_doc_filter(const TDocumentoEsteso& td) const;
void set_err_paf();
void fill();
void init();
void set_filter_changed();
void set_pronto();
void connect_keys();
void export_paf();
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
void next_page(int p) override;
bool on_key(KEY key) override;
bool check_not_empty();
bool check_full_fields() const;
bool check_doc_filter(const TDocumentoEsteso& td) const;
void set_err_paf();
void fill();
void init();
void force_reload_sheet();
void load_all_fields();
bool _filter_changed;
bool _enable_chiave_fixer;
public:
TPA_mask() : TAutomask("fp0300a"), _filter_changed(true)
TPA_mask() : TAutomask("fp0300a"), _filter_changed(true), _enable_chiave_fixer(false)
{
disable(DLG_OK);
disable(DLG_SAVEREC);
@ -70,6 +76,16 @@ void TPA_mask::save_all_fields() const
fp_settings().set_esp_est_cod(get(F_VALCODEST));
}
void TPA_mask::force_reload_sheet()
{
// Mi sposto nella prima pagina, setto il flag di dirty sul filtro e mi risposto
// Lo faccio perché eliminando la riga direttamente e chiamando la force_update() si crea un bug che cliccando sulla prima riga viene mostrata quella che c'era prima della eliminazione
TAutomask::next_page(0);
set_focus_field(F_DATAINI);
_filter_changed = true;
next_page(1);
}
void TPA_mask::load_all_fields()
{
set(F_DATAINI, ini_get_string(CONFIG_DITTA, "fp", "dataini"));
@ -140,10 +156,12 @@ void TPA_mask::fill()
enable(DLG_OK);
enable(DLG_SAVEREC);
enable(DLG_FINDREC);
enable(DLG_PRINT);
#else
enable(DLG_OK, filter_selected != "X" && filter_selected != "P");
enable(DLG_SAVEREC, fp_settings().is_f8() && filter_selected == "X");
enable(DLG_SAVEREC, (fp_settings().is_f8() && filter_selected == "X") || filter_selected == "P");
enable(DLG_FINDREC, filter_selected == "P");
enable(DLG_PRINT, _enable_chiave_fixer && filter_selected == "X");
#endif
// Record di controllo per eventuali elaborazioni precedenti
@ -264,10 +282,199 @@ void TPA_mask::set_filter_changed()
void TPA_mask::set_pronto()
{
if(fp_db().sq_set_exec("UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_GESTIONE = 'D'") && fp_db().sq_commit())
TString_array& sht = sfield(F_DOCS).rows_array();
TProgress_monitor pi(sht.items(), "Esportazione Fatture");
FOR_EACH_ARRAY_ROW(sht, r, riga)
{
message_box("Fatture esportate!");
if (!pi.add_status())
break;
if (!riga->starts_with("X"))
continue;
static TString campo_hfatt, campo_bfatt, query;
TDocumento doc('D', riga->get_int(xvtil_cid2index(S_ANNO)), riga->get(xvtil_cid2index(S_CODNUM)), riga->get_long(xvtil_cid2index(S_NDOC)));
if (chiave_paf(doc, campo_hfatt, campo_bfatt))
{
// Come prima cosa controllo che effettivamente la chiave di questo doc sia in giro per il mondo
query.cut(0) << "UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_KEYHEADERFATT = '" << campo_hfatt << "' AND P1_KEYBODYFATT = '" << campo_bfatt << "'";
fp_db().sq_set_exec(query);
}
}
// Committo tutto
fp_db().sq_commit();
force_reload_sheet();
}
void TPA_mask::connect_keys()
{
TString_array& sht = sfield(F_DOCS).rows_array();
TLog_report legno("Allineamento chiavi documento");
// Non sto a fare 8000 variabili, oggi mi sento a corto di Byte
static TString msg_log;
int updated = 0;
if (sht.empty())
{
warning_box("Impossibile allineare le chiavi di uno sheet vuoto!");
return;
}
TProgress_monitor pi(sht.items(), "Esportazione Fatture");
FOR_EACH_ARRAY_ROW(sht, r, riga)
{
if (!pi.add_status())
break;
if (!riga->starts_with("X"))
continue;
TDocumento doc('D', riga->get_int(xvtil_cid2index(S_ANNO)), riga->get(xvtil_cid2index(S_CODNUM)), riga->get_long(xvtil_cid2index(S_NDOC)));
static TString campo_hfatt, campo_bfatt, query;
if (chiave_paf(doc, campo_hfatt, campo_bfatt))
{
// Come prima cosa controllo che effettivamente la chiave di questo doc sia in giro per il mondo
query.cut(0) << "SELECT * FROM PAF0100F WHERE P1_KEYHEADERFATT = '" << campo_hfatt << "' AND P1_KEYBODYFATT = '" << campo_bfatt << "'";
if(fp_db().sq_set_exec(query))
{
msg_log.cut(0) << "Il documento " << campo_bfatt << " è già presente nel DB, verrà saltato";
legno.log(9000, msg_log);
continue;
}
// Provo a cercare il documento nel paf07 come un vero uomo
query.cut(0) << "SELECT P7_KEYPRGINVIO, P7_KEYHEADERFATT, P7_KEYBODYFATT FROM PAF0700F WHERE P7_KEYHEADERFATT = '" << campo_hfatt
<< "' AND P7_TIPODOC = '" << tipo_doc_sdi(doc) << "' AND P7_DATA = '" << doc.data().date2ansi() << "' AND P7_NUMERO LIKE '%" << doc.numero() << "%'";
if (fp_db().sq_set_exec(query, false))
{
bool found = false;
// Valori nel db
static TString db_prginv, db_hfatt, db_bfatt;
// Posso avere più di un risulatato, per esempio se effettuo la fatturazione di gennaio potrei avere la fattura 1, 10 e 11 del cliente 100.
for (bool ok = fp_db().sq_set_exec(query); ok && !found; ok = fp_db().sq_next())
{
db_prginv.cut(0) << fp_db().sq_get("P7_KEYPRGINVIO");
db_hfatt.cut(0) << fp_db().sq_get("P7_KEYHEADERFATT");
db_bfatt.cut(0) << fp_db().sq_get("P7_KEYBODYFATT");
// Adesso che ho trovato il documento vado a verificare per scrupolo anche le righe documento
query.cut(0) << "SELECT * FROM PAF1800F WHERE PI_KEYPRGINVIO = '" << db_prginv
<< "' AND PI_KEYHEADERFATT = '" << db_hfatt
<< "' AND PI_KEYBODYFATT = '" << db_bfatt << "'";
// Setto momentaneamente a true per ciclare sotto
found = true;
for (bool move_ok = fp_db().sq_set_exec(query); move_ok && found; move_ok = fp_db().sq_next())
{
const TRiga_documento& rigadoc = doc[fp_db().sq_get_int("PI_NUMEROLINEA")];
// Testo solo la qta, il prezzo è troppo complicato
const real& qta = rigadoc.quantita();
found &= !qta.is_zero() ? qta == fp_db().sq_get_real("PI_QUANTITA") : fp_db().sq_get_real("PI_QUANTITA") <= UNO;
}
}
if(!found)
{
msg_log.cut(0) << "Il documento " << campo_bfatt << " non è presente nel DB PAF, verrà saltato";
legno.log(9000, msg_log);
continue;
}
else
{
query.cut(0) <<
"UPDATE PAF0100F SET P1_KEYHEADERFATT = '" << campo_hfatt << "', P1_KEYBODYFATT = '" << campo_bfatt << "' WHERE P1_KEYPRGINVIO = '" << db_prginv << "' AND P1_KEYHEADERFATT = '" << db_hfatt << "' AND P1_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF0200F SET P2_KEYHEADERFATT = '" << campo_hfatt << "', P2_KEYBODYFATT = '" << campo_bfatt << "' WHERE P2_KEYPRGINVIO = '" << db_prginv << "' AND P2_KEYHEADERFATT = '" << db_hfatt << "' AND P2_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF0400F SET P4_KEYHEADERFATT = '" << campo_hfatt << "', P4_KEYBODYFATT = '" << campo_bfatt << "' WHERE P4_KEYPRGINVIO = '" << db_prginv << "' AND P4_KEYHEADERFATT = '" << db_hfatt << "' AND P4_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF0700F SET P7_KEYHEADERFATT = '" << campo_hfatt << "', P7_KEYBODYFATT = '" << campo_bfatt << "' WHERE P7_KEYPRGINVIO = '" << db_prginv << "' AND P7_KEYHEADERFATT = '" << db_hfatt << "' AND P7_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF0800F SET P8_KEYHEADERFATT = '" << campo_hfatt << "', P8_KEYBODYFATT = '" << campo_bfatt << "' WHERE P8_KEYPRGINVIO = '" << db_prginv << "' AND P8_KEYHEADERFATT = '" << db_hfatt << "' AND P8_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF1000F SET P0_KEYHEADERFATT = '" << campo_hfatt << "', P0_KEYBODYFATT = '" << campo_bfatt << "' WHERE P0_KEYPRGINVIO = '" << db_prginv << "' AND P0_KEYHEADERFATT = '" << db_hfatt << "' AND P0_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF1100F SET PA_KEYHEADERFATT = '" << campo_hfatt << "', PA_KEYBODYFATT = '" << campo_bfatt << "' WHERE PA_KEYPRGINVIO = '" << db_prginv << "' AND PA_KEYHEADERFATT = '" << db_hfatt << "' AND PA_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF1200F SET PB_KEYHEADERFATT = '" << campo_hfatt << "', PB_KEYBODYFATT = '" << campo_bfatt << "' WHERE PB_KEYPRGINVIO = '" << db_prginv << "' AND PB_KEYHEADERFATT = '" << db_hfatt << "' AND PB_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF1600F SET PF_KEYHEADERFATT = '" << campo_hfatt << "', PF_KEYBODYFATT = '" << campo_bfatt << "' WHERE PF_KEYPRGINVIO = '" << db_prginv << "' AND PF_KEYHEADERFATT = '" << db_hfatt << "' AND PF_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF1700F SET PG_KEYHEADERFATT = '" << campo_hfatt << "', PG_KEYBODYFATT = '" << campo_bfatt << "' WHERE PG_KEYPRGINVIO = '" << db_prginv << "' AND PG_KEYHEADERFATT = '" << db_hfatt << "' AND PG_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF1800F SET PI_KEYHEADERFATT = '" << campo_hfatt << "', PI_KEYBODYFATT = '" << campo_bfatt << "' WHERE PI_KEYPRGINVIO = '" << db_prginv << "' AND PI_KEYHEADERFATT = '" << db_hfatt << "' AND PI_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF1900F SET PY_KEYHEADERFATT = '" << campo_hfatt << "', PY_KEYBODYFATT = '" << campo_bfatt << "' WHERE PY_KEYPRGINVIO = '" << db_prginv << "' AND PY_KEYHEADERFATT = '" << db_hfatt << "' AND PY_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF2000F SET PJ_KEYHEADERFATT = '" << campo_hfatt << "', PJ_KEYBODYFATT = '" << campo_bfatt << "' WHERE PJ_KEYPRGINVIO = '" << db_prginv << "' AND PJ_KEYHEADERFATT = '" << db_hfatt << "' AND PJ_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF2100F SET PK_KEYHEADERFATT = '" << campo_hfatt << "', PK_KEYBODYFATT = '" << campo_bfatt << "' WHERE PK_KEYPRGINVIO = '" << db_prginv << "' AND PK_KEYHEADERFATT = '" << db_hfatt << "' AND PK_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF2200F SET PL_KEYHEADERFATT = '" << campo_hfatt << "', PL_KEYBODYFATT = '" << campo_bfatt << "' WHERE PL_KEYPRGINVIO = '" << db_prginv << "' AND PL_KEYHEADERFATT = '" << db_hfatt << "' AND PL_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF2400F SET PN_KEYHEADERFATT = '" << campo_hfatt << "', PN_KEYBODYFATT = '" << campo_bfatt << "' WHERE PN_KEYPRGINVIO = '" << db_prginv << "' AND PN_KEYHEADERFATT = '" << db_hfatt << "' AND PN_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF2500F SET PO_KEYHEADERFATT = '" << campo_hfatt << "', PO_KEYBODYFATT = '" << campo_bfatt << "' WHERE PO_KEYPRGINVIO = '" << db_prginv << "' AND PO_KEYHEADERFATT = '" << db_hfatt << "' AND PO_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF2600F SET PP_KEYHEADERFATT = '" << campo_hfatt << "', PP_KEYBODYFATT = '" << campo_bfatt << "' WHERE PP_KEYPRGINVIO = '" << db_prginv << "' AND PP_KEYHEADERFATT = '" << db_hfatt << "' AND PP_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF2700F SET PQ_KEYHEADERFATT = '" << campo_hfatt << "', PQ_KEYBODYFATT = '" << campo_bfatt << "' WHERE PQ_KEYPRGINVIO = '" << db_prginv << "' AND PQ_KEYHEADERFATT = '" << db_hfatt << "' AND PQ_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF3000F SET PT_KEYHEADERFATT = '" << campo_hfatt << "', PT_KEYBODYFATT = '" << campo_bfatt << "' WHERE PT_KEYPRGINVIO = '" << db_prginv << "' AND PT_KEYHEADERFATT = '" << db_hfatt << "' AND PT_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAF3200F SET PU_KEYHEADERFATT = '" << campo_hfatt << "', PU_KEYBODYFATT = '" << campo_bfatt << "' WHERE PU_KEYPRGINVIO = '" << db_prginv << "' AND PU_KEYHEADERFATT = '" << db_hfatt << "' AND PU_KEYBODYFATT = '" << db_bfatt << "'\n" <<
"UPDATE PAFW300F SET PW_KEYHEADERFATT = '" << campo_hfatt << "', PW_KEYBODYFATT = '" << campo_bfatt << "' WHERE PW_KEYPRGINVIO = '" << db_prginv << "' AND PW_KEYHEADERFATT = '" << db_hfatt << "' AND PW_KEYBODYFATT = '" << db_bfatt << "'\n";
if(fp_db().sq_set_exec(query))
{
msg_log.cut(0) << "Il documento " << campo_bfatt << " e' stato aggiornato correttamente\nChiave precedente: " << db_bfatt << " chiave nuova: " << campo_bfatt;
legno.log(0, msg_log);
updated++;
}
}
}
}
}
if (fp_db().sq_commit())
{
msg_log.cut(0) << "Aggiornati " << updated << " documenti";
legno.log(0, msg_log);
}
legno.preview();
force_reload_sheet();
}
void TPA_mask::export_paf()
{
int ndocs = 0;
TLocalisamfile doc(LF_DOC);
static const int col_cod_sdi = sfield(F_DOCS).cid2index(S_CODSDI);
TString_array& sht = sfield(F_DOCS).rows_array();
TDoc_fp elab;
//elab.set_cache_insert(true);
if (!sht.empty())
{
TProgress_monitor pi(sht.items(), "Esportazione Fatture");
FOR_EACH_ARRAY_ROW(sht, r, riga)
{
if (!pi.add_status())
break;
if (riga->starts_with("X"))
{
const int anno = riga->get_int(sfield(F_DOCS).cid2index(S_ANNO));
const long ndoc = riga->get_long(sfield(F_DOCS).cid2index(S_NDOC));
const TFixed_string codnum(riga->get(sfield(F_DOCS).cid2index(S_CODNUM))); // lascio sapientemente per ultima la get di una stringa
const TDoc_key key(anno, codnum, ndoc);
// Verifico che il codice sdi nello sheet sia lo stesso sulla testata del documento in caso contrario lo aggiorno
TRectype rec_doc = elab.key_to_doc(key);
if (rec_doc.read(doc) == NOERR)
{
if (rec_doc.get(DOC_TIPODOCSDI).compare(riga->get(col_cod_sdi)) != 0)
{
rec_doc.put(DOC_TIPODOCSDI, riga->get(col_cod_sdi));
rec_doc.rewrite(doc);
}
if (elab.doc_to_paf(key))
ndocs++;
else
{
if (!yesno_box("L'ultima fattura non è stata esportata, continuare?"))
break;
}
}
}
}
}
if (elab.force_commit() <= 0)
error_box("Errore durante il cambiamento di stato finale, potrebbero esser rimaste delle fatture in Pronto");
elab.show_log();
}
bool TPA_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
@ -291,6 +498,10 @@ bool TPA_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
if (e == se_query_add || e == se_query_del)
return false;
break;
case DLG_OK:
if (e == fe_button)
export_paf();
break;
case DLG_USER:
if (e == fe_button && jolly > 0)
{
@ -335,6 +546,13 @@ bool TPA_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
if (e == fe_button)
set_pronto();
}
break;
case DLG_PRINT:
{
if (e == fe_button)
connect_keys();
}
break;
default: break;
}
if((e == fe_modify || e >= se_enter) && jolly == 0)
@ -363,6 +581,20 @@ void TPA_mask::next_page(int p)
TAutomask::next_page(p);
}
bool TPA_mask::on_key(const KEY key)
{
if (key == K_SHIFT + K_F12)
{
if (run_fp_psw_mask())
{
_enable_chiave_fixer = true;
if (curr_page() > 0)
force_reload_sheet();
}
}
return true;
}
bool TPA_mask::check_not_empty()
{
TSheet_field& sheet = sfield(F_DOCS);
@ -393,8 +625,8 @@ bool TPA_mask::check_full_fields() const
bool TPA_mask::check_doc_filter(const TDocumentoEsteso& d) const
{
const TString codnum = d.get(DOC_CODNUM);
const TString tipodoc = d.get(DOC_TIPODOC);
const TString& codnum = d.get(DOC_CODNUM);
const TString& tipodoc = d.get(DOC_TIPODOC);
const char stato = d.stato();
const TTipo_documento& td = cached_tipodoc(d.get(DOC_TIPODOC));
// Mi precarico la tabella dei documenti scelti
@ -402,7 +634,7 @@ bool TPA_mask::check_doc_filter(const TDocumentoEsteso& d) const
{
if (codnum.compare(row->get(_codnum)) == 0 && // Codice numerazione
tipodoc.compare(row->get(_tipodoc)) == 0 && // Tipo documento
td.reg_fisc().full() && // Regime fiscale
td.reg_fisc().full() && // Regime fiscale
row->get_char(_dastato) <= stato && // Da stato
row->get_char(_astato) >= stato) // A stato
return true;
@ -442,7 +674,31 @@ void TPA_mask::set_err_paf()
TPaf_record paf0100f("PAF0100F");
if (fdoc.read() == NOERR && chiave_paf(fdoc.curr(), hfatt, bfatt) && paf0100f.search(nullptr, hfatt, bfatt))
{
TString query = "UPDATE PAF0100F SET P1_GESTIONE = 'E' WHERE P1_KEYHEADERFATT = '"; query << hfatt << "' AND P1_KEYBODYFATT = '" << bfatt << "';";
static TString query;
query.cut(0) <<
"UPDATE PAF0100F SET P1_GESTIONE = 'E', P1_KEYPRGINVIO = 'DELETED' WHERE P1_KEYHEADERFATT = '" << hfatt << "' AND P1_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF0200F SET P2_GESTIONE = 'E', P2_KEYPRGINVIO = 'DELETED' WHERE P2_KEYHEADERFATT = '" << hfatt << "' AND P2_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF0400F SET P4_GESTIONE = 'E', P4_KEYPRGINVIO = 'DELETED' WHERE P4_KEYHEADERFATT = '" << hfatt << "' AND P4_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF0700F SET P7_GESTIONE = 'E', P7_KEYPRGINVIO = 'DELETED' WHERE P7_KEYHEADERFATT = '" << hfatt << "' AND P7_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF0800F SET P8_GESTIONE = 'E', P8_KEYPRGINVIO = 'DELETED' WHERE P8_KEYHEADERFATT = '" << hfatt << "' AND P8_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF1000F SET P0_GESTIONE = 'E', P0_KEYPRGINVIO = 'DELETED' WHERE P0_KEYHEADERFATT = '" << hfatt << "' AND P0_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF1100F SET PA_GESTIONE = 'E', PA_KEYPRGINVIO = 'DELETED' WHERE PA_KEYHEADERFATT = '" << hfatt << "' AND PA_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF1200F SET PB_GESTIONE = 'E', PB_KEYPRGINVIO = 'DELETED' WHERE PB_KEYHEADERFATT = '" << hfatt << "' AND PB_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF1600F SET PF_GESTIONE = 'E', PF_KEYPRGINVIO = 'DELETED' WHERE PF_KEYHEADERFATT = '" << hfatt << "' AND PF_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF1700F SET PG_GESTIONE = 'E', PG_KEYPRGINVIO = 'DELETED' WHERE PG_KEYHEADERFATT = '" << hfatt << "' AND PG_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF1800F SET PI_GESTIONE = 'E', PI_KEYPRGINVIO = 'DELETED' WHERE PI_KEYHEADERFATT = '" << hfatt << "' AND PI_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF1900F SET PY_GESTIONE = 'E', PY_KEYPRGINVIO = 'DELETED' WHERE PY_KEYHEADERFATT = '" << hfatt << "' AND PY_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF2000F SET PJ_GESTIONE = 'E', PJ_KEYPRGINVIO = 'DELETED' WHERE PJ_KEYHEADERFATT = '" << hfatt << "' AND PJ_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF2100F SET PK_GESTIONE = 'E', PK_KEYPRGINVIO = 'DELETED' WHERE PK_KEYHEADERFATT = '" << hfatt << "' AND PK_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF2200F SET PL_GESTIONE = 'E', PL_KEYPRGINVIO = 'DELETED' WHERE PL_KEYHEADERFATT = '" << hfatt << "' AND PL_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF2400F SET PN_GESTIONE = 'E', PN_KEYPRGINVIO = 'DELETED' WHERE PN_KEYHEADERFATT = '" << hfatt << "' AND PN_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF2500F SET PO_GESTIONE = 'E', PO_KEYPRGINVIO = 'DELETED' WHERE PO_KEYHEADERFATT = '" << hfatt << "' AND PO_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF2600F SET PP_GESTIONE = 'E', PP_KEYPRGINVIO = 'DELETED' WHERE PP_KEYHEADERFATT = '" << hfatt << "' AND PP_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF2700F SET PQ_GESTIONE = 'E', PQ_KEYPRGINVIO = 'DELETED' WHERE PQ_KEYHEADERFATT = '" << hfatt << "' AND PQ_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF3000F SET PT_GESTIONE = 'E', PT_KEYPRGINVIO = 'DELETED' WHERE PT_KEYHEADERFATT = '" << hfatt << "' AND PT_KEYBODYFATT = '" << bfatt << "';\n" <<
"UPDATE PAF3200F SET PU_GESTIONE = 'E', PU_KEYPRGINVIO = 'DELETED' WHERE PU_KEYHEADERFATT = '" << hfatt << "' AND PU_KEYBODYFATT = '" << bfatt << "';\n" <<
// PAFW3 non ha il flag di gestione
"UPDATE PAFW300F SET PW_KEYPRGINVIO = 'DELETED' WHERE PW_KEYHEADERFATT = '" << hfatt << "' AND PW_KEYBODYFATT = '" << bfatt << "';\n";
if(!fp_db().sq_set_exec(query))
{
TString err = "Impossibile salvare la fattura "; err << anno << " " << codnum << " " << ndoc << "\nVerrà saltata.";
@ -459,13 +715,7 @@ void TPA_mask::set_err_paf()
}
fp_db().sq_commit();
}
// Mi sposto nella prima pagina, setto il flag di dirty sul filtro e mi risposto
// Lo faccio perché eliminando la riga direttamente e chiamando la force_update() si crea un bug che cliccando sulla prima riga viene mostrata quella che c'era prima della eliminazione
TAutomask::next_page(0);
set_focus_field(F_DATAINI);
_filter_changed = true;
next_page(1);
force_reload_sheet();
}
@ -486,56 +736,7 @@ public:
void TDoc2Paf::main_loop()
{
int ndocs = 0;
TPA_mask mask;
TLocalisamfile doc(LF_DOC);
static const int col_cod_sdi = mask.sfield(F_DOCS).cid2index(S_CODSDI);
while (mask.run() == K_ENTER)
{
TString_array& sht = mask.sfield(F_DOCS).rows_array();
TDoc_fp elab;
//elab.set_cache_insert(true);
if (!sht.empty())
{
TProgress_monitor pi(sht.items(), "Esportazione Fatture");
ndocs = 0;
FOR_EACH_ARRAY_ROW(sht, r, riga)
{
if (!pi.add_status(1))
break;
if (riga->starts_with("X"))
{
const int anno = riga->get_int(mask.sfield(F_DOCS).cid2index(S_ANNO));
const long ndoc = riga->get_long(mask.sfield(F_DOCS).cid2index(S_NDOC));
const TFixed_string codnum(riga->get(mask.sfield(F_DOCS).cid2index(S_CODNUM))); // lascio sapientemente per ultima la get di una stringa
const TDoc_key key(anno, codnum, ndoc);
// Verifico che il codice sdi nello sheet sia lo stesso sulla testata del documento in caso contrario lo aggiorno
TRectype rec_doc = elab.key_to_doc(key);
if(rec_doc.read(doc) == NOERR)
{
if(rec_doc.get(DOC_TIPODOCSDI).compare(riga->get(col_cod_sdi)) != 0)
{
rec_doc.put(DOC_TIPODOCSDI, riga->get(col_cod_sdi));
rec_doc.rewrite(doc);
}
if (elab.doc_to_paf(key))
ndocs++;
else
{
if (!yesno_box("L'ultima fattura non è stata esportata, continuare?"))
break;
}
}
}
}
}
if (elab.force_commit() <= 0)
error_box("Errore durante il cambiamento di stato finale, potrebbero esser rimaste delle fatture in Pronto");
elab.show_log();
}
while (TPA_mask().run() == K_ENTER) {}
}
bool TDoc2Paf::create()

View File

@ -15,6 +15,12 @@ BEGIN
FLAGS "D"
END
BUTTON DLG_NULL 2 2
BEGIN
PROMPT -1 1 ""
PICTURE 0
END
BUTTON DLG_SAVEREC 2 2
BEGIN
PROMPT 1 1 "Elimina"
@ -29,6 +35,13 @@ BEGIN
FLAGS "D"
END
BUTTON DLG_PRINT 2 2
BEGIN
PROMPT 1 1 "Correggi chiavi"
PICTURE TOOL_SMILE
FLAGS "D"
END
#include <helpbar.h>
ENDPAGE

View File

@ -381,7 +381,7 @@ void TMancati_app::main_loop()
const TString mail = row->get(mask.sfield(F_DOCS).cid2index(S_DOCMAIL));
bool accord = TString(row->get(mask.sfield(F_DOCS).cid2index(S_BYMAIL))) == "X";
if (row->starts_with("X") && (mail.blank() || !accord)) {
error_box("Attenzione: c'è almeno un cliente senza indirizzo email o senza il consenso per l'invio email.");
error_box("Attenzione: è presente almeno un cliente senza indirizzo email o senza il consenso per l'invio email.");
break;
}
}

View File

@ -16,6 +16,8 @@
#define SQL_FLD "sql/"
#define MANCATA_SEND "S" // Se la mail di mancata consegna è già stata inviata P1_ERRINT è segnato con "S"
class TFPRiga_documento;
// Typedef per aiutare a capire cosa sono le chiavi
typedef TString MCodice_riga;
typedef TString MTipo_documento;
@ -78,6 +80,8 @@ enum { no_pdf = -1, pdf_ok = 0, no_alleg = -2};
// Ritorna la connessione al DB paf secondo i parametri impostati nel programma di configurazione
SSimple_query& fp_db();
// Lancia una maschera di password FP
bool run_fp_psw_mask();
// Controlla il livello di patch installato e aggiorna le tabelle se necessario
bool check_tables();
// Compila il numero di documento per la scrittura sui paf
@ -196,7 +200,6 @@ private:
TPaf_container _paf_container;
int _count_r_conai;
bool _nascondi_sconti_righe_fatt;
TFP_righe_custom _righe_custom;
TFP_nota_piede_f _riga_npf;
// Classe interna per gestire righe aggiuntive in riepilogo
@ -256,7 +259,7 @@ protected:
bool add_row_art(long& riga_art, const TString& codice_tipo, const TString& codice_valore, TPaf_record& paf);
bool add_row_alleg(TFilename& file, long& nprogr, TPaf_record& paf);
const TString& converti_prezzo(const real& prezzo) const;
void set_qta_prezzo(TPaf_record& paf1800f, TRiga_documento* rdoc);
void set_qta_prezzo(TPaf_record& paf1800f, TFPRiga_documento* rdoc) const;
void add_ritenuta(const TDocumentoEsteso& doc, const TSpesa_prest& sp, TPaf_record& paf0700f) const;
bool add_riepilogo_iva(TPaf_record& paf2200f, const TCodiceIVA& cod_iva, const char* eiva, const real& imponibile = ZERO, const real& imposta = ZERO);
bool add_cassa_previdenziale(TRiga_documento& rdoc);
@ -278,8 +281,8 @@ public:
TRectype& key_to_doc(const TDoc_key& key);
// Mostra il log a fine esecuzione
bool show_log();
const int commit();
const int force_commit();
int commit();
int force_commit();
void set_cache_insert(const bool v) { _cache_insert = v; }
@ -309,6 +312,7 @@ public:
const TString& get_body_mail(int idx = -1) const;
const TString& get_npf(const char* tipodoc, int idx) const;
const bool get_no_sconti_fatt() const;
bool get_no_export_pronto() const;
// Get tipidoc per NotaPiedeFattura
const TString get_npf_tipodoc(int indx) const;
@ -329,6 +333,8 @@ public:
void set_check_not_block(bool not_block) const;
void set_body_mail(const char* msg, int idx = -1) const;
void set_no_sconti_fatt(const bool no_sconti_fatt) const;
void set_no_export_pronto(const bool no_export_pronto) const;
void set_npf(const char * tipodoc, const char* msg, int idx) const;
void set_npf_tipodoc(const TString& tipodoc, int indx) const;
@ -393,4 +399,20 @@ public:
TFp_mail_sender(const int anno, const long ndoc, const TFixed_string& codnum, const TFixed_string& tipodoc, const long codcf, TString mail, bool accord, TString ragsoc, bool sent)
{ set_doc(anno, ndoc, codnum, tipodoc, codcf, mail, accord, ragsoc, sent); }
};
class TFPRiga_documento : public TRiga_documento
{
public:
real prezzo(bool scontato, bool lordo, int ndec = AUTO_DECIMALS) const;
real importo(bool scontato, bool lordo, int ndec = AUTO_DECIMALS) const;
real quantita() const;
TString& quantita_string() const;
TFPRiga_documento(const TRiga_documento& rd) : TRiga_documento(rd) {}
};
#define FOR_EACH_PHYSICAL_FPRDOC(__doc, __r, __rdoc) TFPRiga_documento* __rdoc=NULL; \
TRecord_array& bodyof##__rdoc = (__doc).body(); \
for (int __r = bodyof##__rdoc.first_row(); bodyof##__rdoc.exist(__r) && (__rdoc=&(TFPRiga_documento&)bodyof##__rdoc.row(__r))!=NULL; __r=bodyof##__rdoc.succ_row(__r))
#endif // __FPLIB_H

View File

@ -2,25 +2,23 @@
#include <prefix.h>
#include <config.h>
#include <utility.h>
#include <scanner.h>
#include <xvt.h>
#include <diction.h>
#include "text.h"
#include <isam.h>
#include <tabutil.h>
#include <dongle.h>
#include <execp.h>
#include "../fe/felib.h"
#include "../cg/cglib03.h"
#include "../ve/velib04.h"
#include <anagiu.h>
#include <comuni.h>
#include <cfven.h>
#include <nditte.h>
#include <unloc.h>
#include <causali.h>
#include "../cg/cfban.h"
#include "modaut.h"
#include <modaut.h>
#include <urldefid.h>
bool set_connection(SSimple_query& s)
{
bool ok = true;
@ -67,6 +65,31 @@ SSimple_query& fp_db()
}
return *db;
}
bool run_fp_psw_mask()
{
static TMask* m;
// Cancello la maschera se esiste
delete m;
m = new TMask("Password", 1, 30, 5);
m->add_button_tool(DLG_OK, "~Conferma", TOOL_OK);
m->add_button_tool(DLG_CANCEL, "Annulla", TOOL_CANCEL);
m->add_string(101, 0, "Password ", 1, 1, 15, "*");
m->field(101).check_type(CHECK_REQUIRED);
while (m->run() == K_ENTER)
{
if (m->get(101) == "sirioFATT99") // Hardcoded password are the best!
{
return true;
}
else
{
error_box("Password errata");
}
}
return false;
}
string getline(ifstream& f)
{
string app;
@ -171,9 +194,9 @@ bool chiave_paf(const TDocumento& doc, TString& hfatt, TString& bfatt)
// Crea la coppia di chiavi per il db PAF a partire da un semplice record di testata documento
bool chiave_paf(const TRectype& doc, TString& hfatt, TString& bfatt)
{
TDocumento d(doc);
chiave_paf(d, hfatt, bfatt);
return hfatt.full();
const TDocumento d(doc);
chiave_paf(d, hfatt, bfatt);
return hfatt.full();
}
TString get_dest_sdi(const char tipocf, const long codcf)
{
@ -367,7 +390,7 @@ const TString& TPaf_record::var2str(const TString& fldname, const TVariant& var)
}
return tmp;
}
TString& TPaf_record::remove_string(bool id_riga)
TString& TPaf_record::remove_string(const bool id_riga)
{
TString& query = get_tmp_string().cut(0);
query << "DELETE FROM " << _table << " WHERE ";
@ -881,7 +904,7 @@ bool TDoc_fp::check_initial(TDocumentoEsteso& doc)
if(pag.cond_pag_sdi().empty())
{
msg.cut(0) << "Non è valorizzata la condizione di pagamento SDI (TP01, TP02, TP03) per la condizione di pagamento " << pag.code();
msg.cut(0) << "Non e' valorizzata la condizione di pagamento SDI (TP01, TP02, TP03) per la condizione di pagamento " << pag.code();
log(1, msg);
ok = false;
}
@ -893,11 +916,10 @@ bool TDoc_fp::check_initial(TDocumentoEsteso& doc)
if(cache().get("%CLR", key_class, "S12").empty())
{
msg.cut(0) << "Non è valorizzata la tipologia di pagamento SDI (MPXX) per la condizione di pagamento " << pag.code();
msg.cut(0) << "Non e' valorizzata la tipologia di pagamento SDI (MPXX) per la condizione di pagamento " << pag.code();
log(1, msg);
ok = false;
}
}
return ok;
@ -913,7 +935,7 @@ bool TDoc_fp::check_row(const TRiga_documento& rdoc)
const TSpesa_prest& spesa = rdoc.spesa();
if(spesa.is_percentuale() && spesa.perc().is_zero())
{
msg.cut(0) << "É corretto che per la spesa " << spesa.codice() << " la percentuale sia zero?";
msg.cut(0) << "E' corretto che per la spesa " << spesa.codice() << " la percentuale sia zero?";
log(1, msg);
}
}
@ -1070,14 +1092,33 @@ bool TDoc_fp::show_log()
return true;
}
const int TDoc_fp::commit()
int TDoc_fp::commit()
{
int r = 0;
if (_to_commit)
{
if(fp_db().sq_set_exec("UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_GESTIONE = 'D'") && fp_db().sq_commit())
// Controllo stato diagnosticato
if (!fp_settings().get_no_export_pronto())
{
r = 1;
if (fp_db().sq_set_exec("UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_GESTIONE = 'D'"))
{
r += 1;
log(2, "Le fatture sono state esportate correttamente in stato pronto");
}
else
{
r = -1;
log(2, fp_db().sq_get_token_text_error(1));
}
}
else
{
log(2, "Le fatture sono state esportate in stato diagnosticato");
}
if(r >= 0 && fp_db().sq_commit())
{
r += 2;
}
else
{
@ -1090,7 +1131,7 @@ const int TDoc_fp::commit()
return r;
}
const int TDoc_fp::force_commit()
int TDoc_fp::force_commit()
{
_to_commit = true;
return commit();
@ -1170,55 +1211,29 @@ const TString& TDoc_fp::converti_prezzo(const real& prezzo) const
ret << prezzo;
return ret;
}
void TDoc_fp::set_qta_prezzo(TPaf_record& paf1800f, TRiga_documento* rdoc)
void TDoc_fp::set_qta_prezzo(TPaf_record& paf1800f, TFPRiga_documento* rdoc) const
{
// Setto l'unità di misura
paf1800f.set("PI_UNITAMISURA", rdoc->get(RDOC_UMQTA));
const TString& field_qta = _righe_custom.get_qta(rdoc->tipo().codice(), rdoc->doc().tipo().codice());
const TString& field_prezzo = _righe_custom.get_prezzo(rdoc->tipo().codice(), rdoc->doc().tipo().codice());
const TString& field_imponibile = _righe_custom.get_imponibile(rdoc->tipo().codice(), rdoc->doc().tipo().codice());
const bool custom_prezzo = field_prezzo.full();
real qta = rdoc->get_real(field_qta);
const real qta = rdoc->quantita();
// Prendendo la stringa non ho problemi in scrittura della query, a volte accadono cose stupide
const TString& qta_string = rdoc->get(field_qta);
real prezzo_unit;
real prezzo_tot;
if (qta >= ZERO)
{
if (qta == ZERO)
qta = UNO;
paf1800f.set("PI_QUANTITA", qta_string);
if(custom_prezzo)
{
prezzo_unit = rdoc->get_real(field_prezzo);
prezzo_tot = rdoc->get_real(field_imponibile);
}
else
{
prezzo_unit = rdoc->prezzo(_nascondi_sconti_righe_fatt, false, 5);
prezzo_tot = rdoc->importo(true, false);
}
}
else if(qta < ZERO)
TString& qta_string = rdoc->quantita_string();
real prezzo_unit = rdoc->prezzo(_nascondi_sconti_righe_fatt, false, 5);
real prezzo_tot = rdoc->importo(true, false);
if(qta < ZERO)
{
// Metto la qualità senza il segno
paf1800f.set("PI_QUANTITA", qta_string.mid(1));
// E i prezzi in negativo, perchè l'importo non ha lo stesso segno del prezzo?
if (custom_prezzo)
{
prezzo_unit = -abs(rdoc->get_real(field_prezzo));
prezzo_tot = -abs(rdoc->get_real(field_imponibile));
}
else
{
prezzo_unit = -abs(rdoc->prezzo(_nascondi_sconti_righe_fatt, false, 5));
prezzo_tot = -abs(rdoc->importo(true, false));
}
qta_string = qta_string.mid(1);
// E i prezzi in negativo
prezzo_unit = -abs(prezzo_unit);
prezzo_tot = -abs(prezzo_tot);
}
// Salvo tutto
paf1800f.set("PI_QUANTITA", qta_string);
paf1800f.set("PI_PREZZOUNIT", converti_prezzo(prezzo_unit));
paf1800f.set("PI_PRZTOTALE", converti_prezzo(prezzo_tot));
}
@ -1252,7 +1267,7 @@ void TDoc_fp::add_ritenuta(const TDocumentoEsteso& doc, const TSpesa_prest& sp,
paf0700f.set("P7_TIPORITENUTA", _rec_clifo.get_char(CLI_TIPOPERS) == 'F' ? "RT01" : "RT02");
TString doc_imponibile = doc.imponibile().string();
const real imponibile = calc_ritenuta(doc);
const real imponibile = doc.ritenute();
paf0700f.set("P7_IMPORTORIT", converti_prezzo(imponibile * sp.perc() / CENTO));
paf0700f.set("P7_ALIQUOTARIT", sp.perc());
@ -1349,7 +1364,7 @@ bool TDoc_fp::export_paf0100f()
TPaf_record& paf0100f = _paf_container.get_paf("PAF0100F");
paf0100f.set("P1_TRASMITTPAESE", _paese);
paf0100f.set("P1_TRASMITTCOD", _cofi);
paf0100f.set("P1_FMTTRASMISS", _privato ? "FPR12" : "FPA12"); // SDI11 si usa dal 2015 per lo split payment (prima era SDI10)
paf0100f.set("P1_FMTTRASMISS", _privato ? "FPR12" : "FPA12");
paf0100f.set("P1_CODDEST", _coddest);
TString80 tel;
@ -1475,8 +1490,8 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
{
paf0400f.set("P4_ANADENOM", cliente.ragione_sociale());
}
// DatiSede
paf0400f.set("P4_SEDEIND", cliente.via_residenza());
paf0400f.set("P4_SEDENRCIVICO", cliente.civico_residenza().left(8));
paf0400f.set("P4_SEDECOMUNE", cliente.comune_residenza());
@ -1625,7 +1640,7 @@ bool TDoc_fp::doc_to_paf(TDocumentoEsteso& doc)
long riga = 1;
FOR_EACH_PHYSICAL_RDOC(doc, r, rdoc)
FOR_EACH_PHYSICAL_FPRDOC(doc, r, rdoc)
{
// Controllo la riga
if (check_row(*rdoc) && !fp_settings().get_check_not_block())

View File

@ -6,23 +6,24 @@
#define FP_IP "ip"
#define FP_DB "db"
#define FP_USR "usr"
#define FP_PSW "psw"
#define FP_FLD_DEST "flddest"
#define FP_FLD_USR_DEST "fldusrdest"
#define FP_COFI_TRAS "cofitras"
#define FP_GEST_ALLEG "gestioneallegati"
#define FP_ALLEG_FAT "allegafatt"
#define FP_ESP_PRI "esppri"
#define FP_ESP_EST "espest"
#define FP_ESP_EST_COD "espestcod"
#define FP_F8 "f8"
#define FP_CHECK_NOT_BLOCK "checknotblock"
#define FP_MAIL "mail"
#define FP_NOTA_PIEDE_F "npf" // Nota piede fattura
#define FP_CHECK_NO_SCONTI_FATT "noscontifatt"
#define FP_IP "ip"
#define FP_DB "db"
#define FP_USR "usr"
#define FP_PSW "psw"
#define FP_FLD_DEST "flddest"
#define FP_FLD_USR_DEST "fldusrdest"
#define FP_COFI_TRAS "cofitras"
#define FP_GEST_ALLEG "gestioneallegati"
#define FP_ALLEG_FAT "allegafatt"
#define FP_ESP_PRI "esppri"
#define FP_ESP_EST "espest"
#define FP_ESP_EST_COD "espestcod"
#define FP_F8 "f8"
#define FP_CHECK_NOT_BLOCK "checknotblock"
#define FP_MAIL "mail"
#define FP_NOTA_PIEDE_F "npf" // Nota piede fattura
#define FP_CHECK_NO_SCONTI_FATT "noscontifatt"
#define FP_CHECK_NO_EXPORT_PRONTO "noexportpronto"
// Sheet fp0300
#define FP_SLD_COD "SLD"
@ -143,6 +144,11 @@ const bool TFP_settings::get_no_sconti_fatt() const
return ini_get_bool(FILE_CONFIG, FILE_SECTION, FP_CHECK_NO_SCONTI_FATT, false);
}
bool TFP_settings::get_no_export_pronto() const
{
return ini_get_bool(FILE_CONFIG, FILE_SECTION, FP_CHECK_NO_EXPORT_PRONTO, false);
}
void TFP_settings::set_db_indirizzo(const TString& ind) const
{
ini_set_string(FILE_CONFIG, FILE_SECTION, FP_IP, ind);
@ -230,6 +236,11 @@ void TFP_settings::set_no_sconti_fatt(const bool no_sconti_fatt) const
ini_set_bool(FILE_CONFIG, FILE_SECTION, FP_CHECK_NO_SCONTI_FATT, no_sconti_fatt);
}
void TFP_settings::set_no_export_pronto(const bool no_export_pronto) const
{
ini_set_bool(FILE_CONFIG, FILE_SECTION, FP_CHECK_NO_EXPORT_PRONTO, no_export_pronto);
}
void TFP_settings::remove_para_ini(int idx)
{
ini_remove(FILE_CONFIG, FILE_SECTION, FP_MAIL, idx);

View File

@ -1,9 +1,5 @@
#include "fplib.h"
#include "execp.h"
#include <spotlite.h>
#include <xvt_env.h>
#include "modaut.h"
#include "fp1200a.h"
class TExternal_app;

37
src/fp/fplib04.cpp Normal file
View File

@ -0,0 +1,37 @@
#include "fplib.h"
TFP_righe_custom& fp_righe_custom()
{
static TFP_righe_custom* fidel_custom = nullptr;
if(fidel_custom == nullptr)
{
fidel_custom = new TFP_righe_custom;
}
return *fidel_custom;
}
real TFPRiga_documento::prezzo(const bool scontato, const bool lordo, const int ndec) const
{
const TString& field_prezzo = fp_righe_custom().get_prezzo(tipo().codice(), doc().tipo().codice());
return field_prezzo.full() ? get_real(field_prezzo) : TRiga_documento::prezzo(scontato, lordo, ndec);
}
real TFPRiga_documento::importo(const bool scontato, const bool lordo, const int ndec) const
{
const TString& field_importo = fp_righe_custom().get_imponibile(tipo().codice(), doc().tipo().codice());
return field_importo.full() ? get_real(field_importo) : TRiga_documento::importo(scontato, lordo, ndec);
}
real TFPRiga_documento::quantita() const
{
const TString& field_qta = fp_righe_custom().get_qta(tipo().codice(), doc().tipo().codice());
real qta = field_qta.full() ? get_real(field_qta) : TRiga_documento::quantita();
return qta.is_zero() ? UNO : qta;
}
TString& TFPRiga_documento::quantita_string() const
{
static TString qta_string;
qta_string.cut(0) << quantita().string();
return qta_string;
}

View File

@ -746,15 +746,44 @@ real TRiga_documento::ritenuta(const char tipor, bool lordo, int ndec) const
real val;
if (tipo().tipo() == RIGA_SPESEDOC)
{
const char tipo_rit = spesa().tipo_ritenuta();
{
const char tipo_rit = spesa().tipo_ritenuta();
if ((tipor != '\0' && tipo_rit == tipor) || (tipor == '\0' && tipo_rit != '\0'))
{
if ((tipor != '\0' && tipo_rit == tipor) || (tipor == '\0' && tipo_rit != '\0'))
{
_rit_calc = true;
val = importo(true, lordo, ndec);
if (spesa().is_percentuale() && spesa().field_perc().blank())
{
real imponibile;
FOR_EACH_PHYSICAL_RDOC(doc(), r, rdoc1)
{
if (rdoc1->is_prestazione())
{
imponibile += rdoc1->imponibile();
}
}
// Riciclo per sommare la % delle spese da sommare
FOR_EACH_PHYSICAL_RDOC(doc(), r, rdoc2)
{
if (rdoc2->is_spese() && rdoc2->spesa().spe_cal_rit())
{
if (rdoc2->spesa().is_percentuale())
val += imponibile * rdoc2->spesa().perc() / CENTO;
else
val = rdoc2->importo(true, lordo, ndec);
}
}
val += imponibile;
val *= spesa().perc() / CENTO;
val.round(2);
}
else
val = importo(true, lordo, ndec);
_rit_calc = false;
}
}
}
return val;
}

View File

@ -378,9 +378,14 @@ bool TXvt_recordset::exec(const bool auto_f)
_RCS(_recset)->Execute();
_loaded = true;
_recno = -1;
// Se trovo almeno un "select" faccio l'autofetch
SAString s = _RCS(_recset)->CommandText(); s.MakeUpper();
ok = s.Find("SELECT") != SIZE_MAX && auto_f ? next() : true;
// Se trovo almeno un "select" faccio l'autofetch, ovviamente non mi sbatto se auto_f è disattivato
if (auto_f)
{
SAString s = _RCS(_recset)->CommandText(); s.MakeUpper();
ok = s.Find("SELECT") != SIZE_MAX ? next() : true;
}
else
ok = true;
}
catch (SAException &x)
{