Patch level : 12.0 790

Files correlati     : fp0400
Commento            :
- Rifatta maschera per separare meglio parte fp da f1
- Aggiunti controlli sui bottoni
- Aggiustati filtri elenco fatture
- Aggiunta possibilita' di aprire registrazione da elenco fatture contabilizzate
This commit is contained in:
Simone Palacino 2019-05-16 17:50:11 +02:00
parent 061f491938
commit 952eeb374f
3 changed files with 207 additions and 122 deletions

View File

@ -1,20 +1,19 @@
/////////////////////////////////////////////////////////////////////////////////////
// TPassive_mask
/////////////////////////////////////////////////////////////////////////////////////
#include "defmask.h"
#include "automask.h"
#include "applicat.h"
#include <progind.h>
#include "tsdb.h"
#include "fp0400a.h"
#include "fplib.h"
#include "sheet.h"
#include "execp.h"
#include "dongle.h"
#include <map>
#include "../f1/f1lib.h"
#include "../ba/bafrm.h"
#include "mov.h"
#define FILTER_NOASS ""
#define FILTER_ASS "E"
#define FILTER_ALL "A"
#define FILTER_CONT "C"
enum
{
@ -28,12 +27,16 @@ enum
};
enum { filtri = 0, elenco_fe = 1, elenco_err = 2 }; // Enum per bottoni toolbar (numero pagina in cui mi trovo)
/////////////////////////////////////////////////////////////////////////////////////
// TPassive_mask
/////////////////////////////////////////////////////////////////////////////////////
class TPassive_mask : public TAutomask
{
bool _f1;
protected:
bool _filter_changed;
TFilename tmp_dir;
TFilename _tmp_dir;
struct TForn_err
{
int forn_code;
@ -55,14 +58,16 @@ protected:
void elenco_prots_sel(TString& string) const;
// Gestione F1
int prepara_contab();
int prepara_contab() const;
void contabilizza();
TDate load_data() const;
// Handlers
static bool causfa_handler(TMask_field& f, KEY k);
static bool causnc_handler(TMask_field& f, KEY k);
void fattsel(int dlg, TField_event& e);
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
void check_buttons(int p);
void next_page(int p) override;
// Elenco dei protocolli selezionati
@ -73,10 +78,9 @@ protected:
// Aggiunge i protocolli che sono già presenti per le fatture nel db alla tabellina per il filtro
void aggiungi_prot() const;
void init();
void load_all_fields();
public:
void save_all_fields() const;
TString& get_fattsel() const;
TPassive_mask(bool f1);
};
@ -88,19 +92,7 @@ void TPassive_mask::set_filter_changed()
void TPassive_mask::next_page(int p)
{
field(DLG_EXPORT).enable((curr_page() + p == 1 || p == 1001) && _f1);
field(DLG_SAVEREC).enable(curr_page() + p == 1 || p == 1001);
if(p >= 1000)
{
field(DLG_NEWREC).enable(p == 1002);
field(DLG_RECALC).enable(p == 1002);
}
else
{
field(DLG_NEWREC).enable(curr_page() + p == 2 || curr_page() + p == 3);
field(DLG_RECALC).enable(curr_page() + p == 2 || curr_page() + p == 3);
}
check_buttons(p);
if (_filter_changed && p != 1000)
{
@ -118,10 +110,24 @@ void TPassive_mask::fill()
TString prots_query;
TLocalisamfile clifo(LF_CLIFO);
const TDate dal = get(F_DATAINI);
const TDate al = get(F_DATAEND);
const TString& ordin = get(F_FATTORD);
const TString& verso_ord = get(F_VERSOORD);
TDate dal;
TDate al;
const TString& filter_elab = get_fattsel();
const TDate reg_dal(get(F_DATAINI));
const TDate reg_al(get(F_DATAEND));
const TString& ordin = get(F_FATTORD);
const TString& verso_ord = get(F_VERSOORD);
if(get_fattsel() == FILTER_CONT)
{
dal = "20010101";
al = TDate(TODAY);
}
else
{
dal = get(F_DATAINI);
al = get(F_DATAEND);
}
sf.hide();
sf.destroy();
@ -192,16 +198,19 @@ void TPassive_mask::aggiungi_riga(TLocalisamfile& clifo, TSheet_field& sf, TShee
const TString& paa_piva = fp_db().sq_get("P_IVA");
const TString& paa_codpaese = fp_db().sq_get("COD_PAESE");
const TString& paa_codsdi = fp_db().sq_get("COD_SDI");
const TString& prot = fp_db().sq_get("TIPO_PROT");
const TDate& dataregcont = fp_db().sq_get_date("DATAREGCONT");
const TString& filter_elab = get(F_FATTSEL);
const TString& filter_elab = get_fattsel();
const bool is_contab = dataregcont != TDate("20010101");
clifo.zero();
clifo.put(CLI_TIPOCF, 'F');
const int forn_code = find_fornitore(clifo);
const bool data_range = !get_bool(F_ENDATAREG) || dataregcont >= TDate(get(F_DATAINIREG)) && dataregcont <= TDate(get(F_DATAENDREG));
if( filter_elab.blank() && forn_code != 0 || filter_elab == "E" && forn_code == 0 && data_range || filter_elab == "A")
const bool data_range = dataregcont >= TDate(get(F_DATAINIREG)) && dataregcont <= TDate(get(F_DATAENDREG));
if( filter_elab.blank() && forn_code != 0 // Filtro sui non associati
|| filter_elab == FILTER_ASS && forn_code == 0 && !is_contab // Filtro sui associati e non contab.
|| filter_elab == FILTER_CONT && forn_code == 0 && is_contab && data_range // Filtro solo contabilizzati e data
|| filter_elab == FILTER_ALL) // Tutte
{
TToken_string& row = sf.row(-1);
if (denom.blank()) {
@ -250,7 +259,7 @@ void TPassive_mask::aggiungi_riga(TLocalisamfile& clifo, TSheet_field& sf, TShee
row.add(fp_db().sq_get("ATTACHMENT") != "0" ? "" : "X");
row.add(paa_codsdi.blank() ? fp_db().sq_get("PEC") : paa_codsdi);
row.add(denom);
row.add(fp_db().sq_get("ANNO_PROT") << (prot.empty() ? "" : "-") << prot << "/" << fp_db().sq_get("NUM_PROT") << (prot.empty() ? " (no prot.)" : ""));
row.add(TProtocollo(fp_db().sq_get_int("ANNO_PROT"), fp_db().sq_get("TIPO_PROT"), fp_db().sq_get("NUM_PROT")));
TString key_prot; key_prot << fp_db().sq_get("KEYPROG") << ";" << fp_db().sq_get("KEYHEAD") << ";" << fp_db().sq_get("KEYFATT");
row.add(key_prot);
}
@ -305,6 +314,21 @@ void TPassive_mask::add_row_err_forn(const int forn_code, TSheet_field& sf_err,
}
}
TString& TPassive_mask::get_fattsel() const
{
static TString fattsel;
fattsel.cut(0);
if (get_bool(F_FORNOTASS))
return fattsel;
if (get_bool(F_FORASS))
return fattsel << FILTER_ASS;
if (get_bool(F_FORALL))
return fattsel << FILTER_ALL;
if (get_bool(F_CONTABIL))
return fattsel << FILTER_CONT;
return fattsel;
}
int TPassive_mask::find_fornitore(TLocalisamfile& clifo)
{
TString paa_codfisc = fp_db().sq_get("COD_FISC");
@ -386,16 +410,12 @@ void TPassive_mask::init()
aggiungi_prot();
}
void TPassive_mask::load_all_fields()
{
}
bool TPassive_mask::causfa_handler(TMask_field& f, KEY k)
{
if (k == K_TAB && f.focusdirty())
{
TMask& msk = f.mask();
TString codcaus(msk.get(F_CAUSFA));
const TString& codcaus = msk.get(F_CAUSFA);
if (!check_causale(codcaus, "FA"))
{
warning_box("Impossibile selezionare questa causale registrazione.\nPrego inserire una causale di Fattura Acquisti");
@ -414,7 +434,7 @@ bool TPassive_mask::causnc_handler(TMask_field& f, KEY k)
if (k == K_TAB && f.focusdirty())
{
TMask& msk = f.mask();
TString codcaus(msk.get(F_CAUSNC));
const TString& codcaus = msk.get(F_CAUSNC);
if (!check_causale(codcaus, "NC"))
{
warning_box("Impossibile selezionare questa causale registrazione.\nPrego inserire una causale di Nota Credito Acquisti.");
@ -428,7 +448,7 @@ bool TPassive_mask::causnc_handler(TMask_field& f, KEY k)
return true;
}
void TPassive_mask::select_all(int sheet_field)
void TPassive_mask::select_all(const int sheet_field)
{
TSheet_field& docs = sfield(sheet_field);
TString_array& sht = docs.rows_array();
@ -447,7 +467,6 @@ void TPassive_mask::salva_for() const
{
if(fp_db().sq_is_connect())
{
TString q_update; // Query per update
TSheet_field& sf = sfield(F_DOCS);
TLocalisamfile clifo(LF_CLIFO); // Leggo in Campo per controllare che il codice cliente non sia errato
@ -456,7 +475,7 @@ void TPassive_mask::salva_for() const
if (row->starts_with("X") && strcmp(clifo.get(CLI_CODCF), "17") == 0)
bool simo = true;
TString cod_forn = row->get(sf.cid2index(S_FORNITORE));
if(row->starts_with("X") && cod_forn != "")
if(row->starts_with("X") && !cod_forn.empty())
{
clifo.zero();
clifo.setkey(1);
@ -464,7 +483,7 @@ void TPassive_mask::salva_for() const
clifo.put(CLI_CODCF, cod_forn);
if(clifo.read() == NOERR)
{
q_update = "";
TString q_update = "";
TToken_string key(row->get(sf.cid2index(S_PROKEY)), ';');
const TString& clifo_cofi = clifo.get(CLI_COFI);
const TString& clifo_paiv = clifo.get(CLI_PAIV);
@ -498,11 +517,11 @@ void TPassive_mask::clean_ini(const TString& filename) const
void TPassive_mask::run_cg0(const TString& filename) const
{
static TString run_string;
run_string.cut(0) << "cg0 -1 -i" << tmp_dir << "\\" << filename << "*" << ".ini" << " /u" << user();
run_string.cut(0) << "cg0 -1 -i" << _tmp_dir << "\\" << filename << "*" << ".ini" << " /u" << user();
TExternal_app(run_string).run();
}
int TPassive_mask::prepara_contab()
int TPassive_mask::prepara_contab() const
{
int n_sel = 0;
TSheet_field& sf = sfield(F_DOCS);
@ -706,6 +725,28 @@ void TPassive_mask::aggiorna_forn()
}
void TPassive_mask::fattsel(const int dlg, TField_event& e)
{
if (e == fe_init)
{
set(F_FORNOTASS, "X");
set(F_FORASS, "");
set(F_FORALL, "");
set(F_CONTABIL, "");
}
else
{
set(F_FORNOTASS, dlg == F_FORNOTASS ? "X" : "");
set(F_FORASS, dlg == F_FORASS ? "X" : "");
set(F_FORALL, dlg == F_FORALL ? "X" : "");
set(F_CONTABIL, dlg == F_CONTABIL ? "X" : "");
}
field(F_DATAINI).enable(!get_bool(F_CONTABIL));
field(F_DATAEND).enable(!get_bool(F_CONTABIL));
field(F_DATAINIREG).enable(get_bool(F_CONTABIL));
field(F_DATAENDREG).enable(get_bool(F_CONTABIL));
}
bool TPassive_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
switch (o.dlg())
@ -718,6 +759,20 @@ bool TPassive_mask::on_field_event(TOperable_field& o, TField_event e, long joll
if(e == fe_init)
init();
break;
case F_DOCS:
if (e == se_query_modify)
break;
case DLG_USER:
if (e == fe_button && jolly > 0 && get_fattsel() == FILTER_CONT)
{
TSheet_field& sf = sfield(F_DOCS);
TToken_string& row = sf.row(sf.selected());
TRectype mov(LF_MOV);
mov.put(MOV_NUMREG, row.get(sf.cid2index(S_NUMREGCONT)));
if (mov.edit())
fill();
}
break;
case DLG_ALL:
if (e == fe_button)
switch (curr_page())
@ -752,21 +807,11 @@ bool TPassive_mask::on_field_event(TOperable_field& o, TField_event e, long joll
break;
case DLG_EXPORT:
if (e == fe_button && curr_page() == elenco_fe)
{
contabilizza();
}
break;
case F_DATAINI:
if (e == fe_init)
{
if (e == fe_init)
o.set(load_data());
}
case F_ENDATAREG:
if (e == fe_modify)
{
field(F_DATAINIREG).enable(get_bool(F_ENDATAREG));
field(F_DATAENDREG).enable(get_bool(F_ENDATAREG));
}
break;
case F_DATAEND:
if (e == fe_init)
@ -774,6 +819,9 @@ bool TPassive_mask::on_field_event(TOperable_field& o, TField_event e, long joll
break;
default: break;
}
if (o.dlg() >= F_FORNOTASS && o.dlg() <= F_CONTABIL)
if (e == fe_modify || e == fe_init)
fattsel(o.dlg(), e);
if ((e == fe_modify || e >= se_enter) && jolly == 0)
if (o.dlg() >= START_MASK && o.dlg() <= END_MASK || o.dlg() == F_PROT)
set_filter_changed();
@ -781,10 +829,28 @@ bool TPassive_mask::on_field_event(TOperable_field& o, TField_event e, long joll
return true;
}
void TPassive_mask::check_buttons(const int p)
{
const TString& fattsel = get_fattsel();
const bool err_forn = fattsel.empty() || fattsel == FILTER_ALL;
field(DLG_EXPORT).enable((curr_page() + p == 1 || p == 1001) && _f1 && fattsel != FILTER_CONT);
field(DLG_SAVEREC).enable((curr_page() + p == 1 || p == 1001) && (fattsel.empty() || fattsel == FILTER_ASS));
if (p >= 1000)
{
field(DLG_NEWREC).enable(p == 1002 && err_forn);
field(DLG_RECALC).enable(p == 1002 && err_forn);
}
else
{
field(DLG_NEWREC).enable((curr_page() + p == 2 || curr_page() + p == 3) && err_forn);
field(DLG_RECALC).enable((curr_page() + p == 2 || curr_page() + p == 3) && err_forn);
}
}
TPassive_mask::TPassive_mask(bool f1) : TAutomask("fp0400a"), _f1(f1), _filter_changed(true)
{
tmp_dir = tmp_dir.tempdir();
load_all_fields();
_tmp_dir = _tmp_dir.tempdir();
TMask::set_handler(F_CAUSFA, causfa_handler);
TMask::set_handler(F_CAUSNC, causnc_handler);
}
@ -812,11 +878,21 @@ void TPassive_app::load_mask(const TPassive_mask& mask) const
{
mask.field(F_CAUSFA).set(get_ini_codcaus());
mask.field(F_CAUSNC).set(get_ini_codcaus(true));
mask.field(F_ENDATAREG).set(get_endatareg());
mask.field(F_DATAINIREG).enable(mask.get_bool(F_ENDATAREG));
mask.field(F_DATAINIREG).enable(mask.get_fattsel() == FILTER_CONT);
mask.field(F_DATAINIREG).set(get_datainireg());
mask.field(F_DATAENDREG).enable(mask.get_bool(F_ENDATAREG));
mask.field(F_DATAENDREG).set(get_dataendreg());
if(mask.field(F_DATAINIREG).get().empty())
{
TDate start(TODAY);
start.set_day(1);
mask.field(F_DATAINIREG).set(start);
}
mask.field(F_DATAENDREG).enable(mask.get_fattsel() == FILTER_CONT);
mask.field(F_DATAENDREG).set(TDate(TODAY));
}
else
{
mask.field(F_GROUPCON).hide();
mask.field(F_GROUPCAU).hide();
}
}
@ -830,9 +906,7 @@ void TPassive_app::save_field(const TPassive_mask& mask)
if (check_f1())
{
set_ini_codcaus(mask.get(F_CAUSFA));
set_endatareg(mask.get_bool(F_ENDATAREG));
set_datainireg(mask.get(F_DATAINIREG));
set_dataendreg(mask.get(F_DATAENDREG));
}
ini_set_string(CONFIG_DITTA, "fp", "dataini_fp04", mask.get(F_DATAINI));
}

View File

@ -1,18 +1,20 @@
#define START_MASK 501
#define F_DATAINI 501
#define F_DATAEND 502
#define F_SAVEFOR 503
#define F_FATTSEL 504
#define F_FATTORD 505
#define F_VERSOORD 506
#define F_CAUSFA 507
#define F_DESCAUSFA 508
#define F_CAUSNC 509
#define F_DESCAUSNC 510
#define F_F1CAUSALE 511
#define F_ENDATAREG 512
#define F_DATAINIREG 513
#define F_DATAENDREG 514
#define F_FORNOTASS 501
#define F_FORASS 502
#define F_FORALL 503
#define F_CONTABIL 504
#define F_DATAINI 505
#define F_DATAEND 506
#define F_DATAINIREG 507
#define F_DATAENDREG 508
#define F_FATTORD 510
#define F_VERSOORD 511
#define F_CAUSFA 512
#define F_DESCAUSFA 513
#define F_CAUSNC 514
#define F_DESCAUSNC 515
#define F_GROUPCON 516
#define F_GROUPCAU 517
#define END_MASK 599

View File

@ -40,32 +40,70 @@ ENDPAGE
PAGE "Fatture Passive" 0 2 0 0
GROUPBOX DLG_NULL 30 7
BEGIN
PROMPT 0 1 "@BFornitori"
END
BOOLEAN F_FORNOTASS
BEGIN
PROMPT 1 2 "Non Associati"
END
BOOLEAN F_FORASS
BEGIN
PROMPT 1 3 "Associati"
END
BOOLEAN F_FORALL
BEGIN
PROMPT 1 4 "Tutti"
END
DATE F_DATAINI
BEGIN
PROMPT 1 1 "Data iniziale"
PROMPT 1 5 "Data iniziale"
CHECKTYPE REQUIRED
END
DATE F_DATAEND
BEGIN
PROMPT 50 1 "Data finale "
PROMPT 1 6 "Data finale "
VALIDATE DATE_CMP_FUNC >= F_DATAINI
WARNING "La data finale non può essere minore della data iniziale"
CHECKTYPE REQUIRED
END
RADIOBUTTON F_FATTSEL 3 80
GROUPBOX F_GROUPCON 30 5
BEGIN
PROMPT 1 2 "Fatture da visualizzare"
ITEM "|Non elaborate"
ITEM "E|Elaborate"
ITEM "A|Tutte"
FLAGS "Z"
PROMPT 0 10 "@BContabilita'"
END
BOOLEAN F_CONTABIL
BEGIN
PROMPT 1 11 "Contabilizzate"
MODULE F1
END
DATE F_DATAINIREG
BEGIN
PROMPT 1 12 "Data iniziale"
CHECKTYPE REQUIRED
MODULE F1
END
DATE F_DATAENDREG
BEGIN
PROMPT 1 13 "Data finale "
VALIDATE DATE_CMP_FUNC >= F_DATAINIREG
WARNING "La data finale non può essere minore della data iniziale"
CHECKTYPE REQUIRED
MODULE F1
END
RADIOBUTTON F_FATTORD 20 20
BEGIN
PROMPT 1 5 "Ordinamento fatture per "
PROMPT 31 1 "Ordinamento fatture per "
ITEM "|Data Ricezione"
ITEM "D|Data Documento"
FLAGS ""
@ -73,56 +111,27 @@ END
RADIOBUTTON F_VERSOORD 20 20
BEGIN
PROMPT 25 5 "Ordinamento:"
PROMPT 52 1 "Ordinamento:"
ITEM "|Decrescente"
ITEM "C|Crescente"
FLAGS ""
END
SPREADSHEET F_PROT 25 6
SPREADSHEET F_PROT 25 4
BEGIN
PROMPT 1 10 "Selezionare o aggiungere un filtro sul Tipo Progressivo"
PROMPT 31 5 "Selezionare o aggiungere un filtro sul Tipo Progressivo"
ITEM "@1"
ITEM "Codice\nProtocol.@12"
END
GROUPBOX DLG_NULL 32 5
BEGIN
PROMPT 47 5 ""
MODULE F1
END
BOOLEAN F_ENDATAREG
BEGIN
PROMPT 48 6 "Abilita filtro per data registrazione contabile"
MODULE F1
END
DATE F_DATAINIREG
BEGIN
PROMPT 48 7 "Data iniziale"
CHECKTYPE REQUIRED
MODULE F1
END
DATE F_DATAENDREG
BEGIN
PROMPT 48 8 "Data finale "
VALIDATE DATE_CMP_FUNC >= F_DATAINIREG
WARNING "La data finale non può essere minore della data iniziale"
CHECKTYPE REQUIRED
MODULE F1
END
GROUPBOX F_F1CAUSALE 58 7
GROUPBOX F_GROUPCAU 59 7
BEGIN
PROMPT 31 10 "@BSelezionare Causale per Registrazione Contabile:"
MODULE F1
END
STRING F_CAUSFA 3
BEGIN
PROMPT 32 11 "Causale per Fattura Acquisti (FA)"
PROMPT 32 11 "Causale per Fattura Acquisti (FA) "
FLAGS "UZ"
FIELD CODCAUS
USE LF_CAUSALI
@ -164,7 +173,7 @@ END
STRING F_CAUSNC 3
BEGIN
PROMPT 32 13 "Causale per Nota Credito Acquisti (NC)"
PROMPT 32 13 "Causale per Nota Credito Acquisti [TD04]"
FLAGS "UZ"
FIELD CODCAUS
USE LF_CAUSALI