585 lines
18 KiB
C++
585 lines
18 KiB
C++
/////////////////////////////////////////////////////////////////////////////////////
|
|
// 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"
|
|
|
|
enum
|
|
{
|
|
no_cf = -14, // Non trovato con cod. fisc. (se non ho nemmeno la p.iva)
|
|
no_match_cf = -15, // Trovato forn. ma il cod. fisc non corrisponde
|
|
no_forn = -5, // Non trovato forn. con p.iva
|
|
err_match_db = -3, // Salvato in db ma non corrisponde a un fornitore
|
|
saved_db = 0, // Salvato già in db FPPRO
|
|
found_piva = 2, // Lo trovo con p.iva
|
|
found_cf = 4, // Non ho p.iva lo trovo con cod.fisc
|
|
};
|
|
enum { filtri = 0, elenco_fe = 1, elenco_err = 2 }; // Enum per bottoni toolbar (numero pagina in cui mi trovo)
|
|
|
|
class TPassive_mask : public TAutomask
|
|
{
|
|
protected:
|
|
|
|
void set_filter_changed();
|
|
void select_all(int sheet_field);
|
|
// Tasto nuovo: apre nuovo fornitore valorizzando già i dati dalla fattura
|
|
void new_forn();
|
|
// Tasto aggiorna: aggiorna cliente che non corrisponde.
|
|
void aggiorna_forn();
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
|
void next_page(int p) override;
|
|
// Elenco dei protocolli selezionati
|
|
void elenco_prots_sel(TString& string) const;
|
|
void fill();
|
|
static int find_fornitore(TLocalisamfile& clifo);
|
|
static void add_row_err_forn(int forn_code, TSheet_field& sf_err, TString& denom);
|
|
void aggiungi_riga(TLocalisamfile& clifo, TSheet_field& sf, TSheet_field& sf_err);
|
|
// 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();
|
|
|
|
TToken_string _forn_code;
|
|
TToken_string _list_fatt_err;
|
|
bool _filter_changed;
|
|
void salva_for() const;
|
|
|
|
public:
|
|
void save_all_fields() const;
|
|
|
|
TPassive_mask() : TAutomask("fp0400a"), _filter_changed(true)
|
|
{
|
|
load_all_fields();
|
|
_forn_code = "";
|
|
_forn_code.separator('|');
|
|
_list_fatt_err = "";
|
|
_list_fatt_err.separator('|');
|
|
}
|
|
};
|
|
|
|
void TPassive_mask::set_filter_changed()
|
|
{
|
|
_filter_changed = true;
|
|
}
|
|
|
|
void TPassive_mask::next_page(int p)
|
|
{
|
|
//if(true)
|
|
if (_filter_changed && p != 1000)
|
|
{
|
|
fill();
|
|
_filter_changed = false;
|
|
}
|
|
TAutomask::next_page(p);
|
|
}
|
|
|
|
void TPassive_mask::fill()
|
|
{
|
|
TSheet_field& sf = sfield(F_DOCS);
|
|
TSheet_field& sf_err = sfield(F_ERR);
|
|
TString query;
|
|
TString prots_query;
|
|
TLocalisamfile clifo(LF_CLIFO);
|
|
|
|
const TDate dal = get(F_DATAINI);
|
|
const TDate al = get(F_DATAEND);
|
|
|
|
sf.hide();
|
|
sf.destroy();
|
|
sf_err.hide();
|
|
sf_err.destroy();
|
|
|
|
elenco_prots_sel(prots_query);
|
|
|
|
query << "SELECT PZ_TIPOPROT AS TIPO_PROT, YEAR(P7_DATA) AS ANNO, P7_TIPODOC AS [TIPO_SDI], P7_NUMERO AS [NUM_DOC], " <<
|
|
"P7_DATA AS [DATA_DOC], PQ_IMPTOTDOC AS [TOT_DOC], P2_ANADENOMIN AS [RAG_SOC], P2_ANANOME AS NOME, " <<
|
|
"P2_ANACOGNOME AS COGNOME, P2_FISCIVACOD AS [P_IVA], P2_CODFISCALE AS [COD_FISC], P2_FISCIVAPAESE AS [COD_PAESE],\n" <<
|
|
"COUNT(PP_ATTACHMENT) AS ATTACHMENT, P1_CODDEST AS [COD_SDI], PU_PEC AS PEC, P1_KEYPRGINVIO AS KEYPROG, P1_KEYHEADERFATT AS KEYHEAD, P1_KEYBODYFATT AS KEYFATT, " <<
|
|
"PZ_TIPOPROT AS [TIPO_PROT], PZ_NUMPROT AS [NUM_PROT], PZ_ANNOPROT AS [ANNO_PROT], PZ_TIPOCF AS [TIPO_CF], PZ_CLIFOR AS [COD_CLIFOR]\n" <<
|
|
"FROM PAA0100F PAA01\n" <<
|
|
"JOIN PAA0200F PAA02 ON P1_KEYPRGINVIO = P2_KEYPRGINVIO and P1_KEYHEADERFATT = P2_KEYHEADERFATT and P1_KEYBODYFATT = P2_KEYBODYFATT\n" <<
|
|
"JOIN PAA0700F PAA07 ON P1_KEYPRGINVIO = P7_KEYPRGINVIO and P1_KEYHEADERFATT = P7_KEYHEADERFATT and P1_KEYBODYFATT = P7_KEYBODYFATT\n" <<
|
|
"JOIN PAA2700F PAA27 ON P1_KEYPRGINVIO = PQ_KEYPRGINVIO and P1_KEYHEADERFATT = PQ_KEYHEADERFATT and P1_KEYBODYFATT = PQ_KEYBODYFATT\n" <<
|
|
"LEFT JOIN PAA2600F PAA26 ON P1_KEYPRGINVIO = PP_KEYPRGINVIO and P1_KEYHEADERFATT = PP_KEYHEADERFATT and P1_KEYBODYFATT = PP_KEYBODYFATT\n" <<
|
|
"LEFT JOIN PAA3200F PAA32 ON P1_KEYPRGINVIO = PU_KEYPRGINVIO and P1_KEYHEADERFATT = PU_KEYHEADERFATT and P1_KEYBODYFATT = PU_KEYBODYFATT\n" <<
|
|
"LEFT JOIN FPPRO00F FPPRO ON P1_KEYPRGINVIO = PZ_KEYPRGINVIO and P1_KEYHEADERFATT = PZ_KEYHEADERFATT and P1_KEYBODYFATT = PZ_KEYBODYFATT\n" <<
|
|
"WHERE P7_DATA >= \'" << dal.date2ansi() << "\' AND P7_DATA <= \'" << al.date2ansi() << "\'" << prots_query << "\n" <<
|
|
"GROUP BY YEAR(P7_DATA), P7_TIPODOC, P7_NUMERO, P7_DATA, PQ_IMPTOTDOC, P2_ANADENOMIN, P2_ANANOME, P2_ANACOGNOME, P2_FISCIVACOD, P2_CODFISCALE, P2_FISCIVAPAESE,\n" <<
|
|
"P1_CODDEST, PU_PEC, P1_KEYPRGINVIO, P1_KEYHEADERFATT, P1_KEYBODYFATT, PZ_TIPOPROT, PZ_NUMPROT, PZ_ANNOPROT, PZ_TIPOCF, PZ_CLIFOR\n" <<
|
|
"ORDER BY PZ_ANNOPROT DESC, PZ_TIPOPROT ASC, PZ_NUMPROT DESC";
|
|
fp_db().sq_set_exec(query, false);
|
|
|
|
_forn_code = "";
|
|
_list_fatt_err = "";
|
|
while(fp_db().sq_next())
|
|
{
|
|
aggiungi_riga(clifo, sf, sf_err);
|
|
}
|
|
|
|
sf.force_update();
|
|
sf.show();
|
|
sf_err.force_update();
|
|
sf_err.show();
|
|
}
|
|
|
|
void TPassive_mask::elenco_prots_sel(TString& string) const
|
|
{
|
|
TString_array elenco;
|
|
TSheet_field& sf = sfield(F_PROT);
|
|
|
|
string << " AND PZ_TIPOPROT IN (";
|
|
|
|
FOR_EACH_SHEET_ROW(sf, nr, row)
|
|
{
|
|
if (*row->get(0) == 'X')
|
|
elenco.add(row->get());
|
|
}
|
|
|
|
// Creo una stringa da aggiungere alla query per la ricerca col codice protocollo, così fatta:
|
|
// " AND PZ_TIPOPROT IN ('a', 'b', 'c')". (con elenco avente "a", "b" e "c" come stringhe)
|
|
if (elenco.items() > 0)
|
|
{
|
|
for (int i = 0; i < elenco.items() - 1; i++)
|
|
string << "\'" << elenco.row(i) << "\', ";
|
|
string << "\'" << elenco.row(elenco.items() - 1) << "\')";
|
|
}
|
|
else
|
|
string = "";
|
|
}
|
|
|
|
void TPassive_mask::aggiungi_riga(TLocalisamfile& clifo, TSheet_field& sf, TSheet_field& sf_err)
|
|
{
|
|
int forn_code = -1;
|
|
TString denom = fp_db().sq_get("RAG_SOC");
|
|
const TString paa_codfisc = fp_db().sq_get("COD_FISC");
|
|
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");
|
|
TString prot = fp_db().sq_get("TIPO_PROT");
|
|
|
|
TToken_string& row = sf.row(-1);
|
|
|
|
clifo.zero();
|
|
clifo.put(CLI_TIPOCF, 'F');
|
|
|
|
if (denom.blank()) {
|
|
denom = fp_db().sq_get("NOME");
|
|
denom << " " << fp_db().sq_get("COGNOME");
|
|
}
|
|
denom.cut(50);
|
|
|
|
row.add(fp_db().sq_get_int("ANNO"), 1);
|
|
row.add(fp_db().sq_get("TIPO_SDI"));
|
|
row.add(fp_db().sq_get("NUM_DOC"));
|
|
// Trasformo formato data da yyyy-mm-gg a italiano
|
|
TDate date_t(fp_db().sq_get_date("DATA_DOC"));
|
|
row.add(date_t);
|
|
row.add(fp_db().sq_get("TOT_DOC"));
|
|
|
|
// Dopo aver fatto le ricerche se lo trovo lo segno e lo aggiungo, se no coloro la cella
|
|
forn_code = find_fornitore(clifo);
|
|
TString forn_str; forn_str << forn_code;
|
|
TString nr_row; nr_row << sf.items();
|
|
_forn_code.add(forn_str);
|
|
|
|
_list_fatt_err.add(nr_row);
|
|
if (forn_code == 0) row.add("X");
|
|
else row.add("");
|
|
|
|
if(forn_code >= 0)
|
|
{
|
|
row.add(clifo.get(CLI_CODCF));
|
|
row.add(clifo.get(CLI_RAGSOC));
|
|
}
|
|
else
|
|
{
|
|
//sf.set_back_and_fore_color(COLOR_RED, COLOR_WHITE, 2, sf.cid2index(S_FORNITORE));
|
|
//sf.set_back_and_fore_color(COLOR_RED, COLOR_WHITE, 2, sf.cid2index(S_RAGSOC));
|
|
add_row_err_forn(forn_code, sf_err, denom);
|
|
}
|
|
|
|
row.add(paa_codpaese, sf.cid2index(S_STATOPAIV));
|
|
row.add(paa_piva);
|
|
row.add(paa_codfisc);
|
|
|
|
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.)" : ""));
|
|
TString key_prot; key_prot << fp_db().sq_get("KEYPROG") << ";" << fp_db().sq_get("KEYHEAD") << ";" << fp_db().sq_get("KEYFATT");
|
|
row.add(key_prot);
|
|
}
|
|
|
|
void TPassive_mask::aggiungi_prot() const
|
|
{
|
|
TSheet_field& sf_prot = sfield(F_PROT);
|
|
TString query = "";
|
|
TString prot = "";
|
|
|
|
query << "SELECT DISTINCT(PZ_TIPOPROT) AS TIPO_PROT \nFROM FPPRO00F";
|
|
fp_db().sq_set_exec(query, false);
|
|
|
|
while (fp_db().sq_next())
|
|
{
|
|
TToken_string& row = sf_prot.row(sf_prot.items()+1);
|
|
prot = fp_db().sq_get("TIPO_PROT");
|
|
|
|
row.add("", 0);
|
|
row.add(prot.empty() ? "no-prot." : prot );
|
|
}
|
|
|
|
sf_prot.force_update();
|
|
}
|
|
|
|
void TPassive_mask::add_row_err_forn(int forn_code, TSheet_field& sf_err, TString& denom)
|
|
{
|
|
TToken_string& row_err = sf_err.row(-1);
|
|
row_err.add(fp_db().sq_get("COD_PAESE"), 1);
|
|
row_err.add(fp_db().sq_get("P_IVA"));
|
|
row_err.add(fp_db().sq_get("COD_FISC"));
|
|
row_err.add(denom);
|
|
|
|
switch (forn_code){
|
|
case err_match_db:
|
|
row_err.add("Salvato in database ma non corrisponde a un fornitore codificato. (Nuovo fornitore disabilitato)");
|
|
break;
|
|
case no_forn:
|
|
row_err.add("Non trovato fornitore per la P.IVA.");
|
|
break;
|
|
case no_match_cf:
|
|
row_err.add("Trovato fornitore ma il codice fiscale non corrisponde. Aggiornare?");
|
|
break;
|
|
case no_cf:
|
|
row_err.add("Fornitore senza P. IVA, non trovato il codice fiscale");
|
|
break;
|
|
default:
|
|
row_err.add("Errore durante identificazione fornitore.");
|
|
break;
|
|
}
|
|
}
|
|
|
|
int TPassive_mask::find_fornitore(TLocalisamfile& clifo)
|
|
{
|
|
TString paa_codfisc = fp_db().sq_get("COD_FISC");
|
|
const TString paa_piva = fp_db().sq_get("P_IVA");
|
|
TString paa_codpaese = fp_db().sq_get("COD_PAESE");
|
|
const TString fppro_tipocf = fp_db().sq_get("TIPO_CF");
|
|
TString fppro_codcf = fp_db().sq_get("COD_CLIFOR");
|
|
|
|
// Cerco se il fornitore è presente in Campo
|
|
int found_clifo = -1;
|
|
|
|
if (fppro_codcf == "17")
|
|
bool simo = true;
|
|
|
|
TString piva;
|
|
// Leggo dall FPPRO se è già stato salvato il fornitore
|
|
// Se è già salvato nell FPPRO ricerco in Campo col codice fornitore (chiave 1)
|
|
if (fppro_tipocf == "F" && !fppro_codcf.blank())
|
|
{
|
|
clifo.setkey(1);
|
|
clifo.put(CLI_CODCF, fppro_codcf);
|
|
// Se trovo dall FPPRO setto a 0
|
|
clifo.read() == NOERR ? found_clifo = 0 : found_clifo = -3;
|
|
}
|
|
else if (paa_codpaese.full() && (piva = paa_piva).full()) // Se non c'è nell FPPRO ricerco con chiave 5
|
|
{
|
|
if (piva == "01903590154")
|
|
bool simo = true;
|
|
clifo.setkey(5);
|
|
clifo.put(CLI_STATOPAIV, paa_codpaese);
|
|
clifo.put(CLI_PAIV, paa_piva);
|
|
clifo.read() == NOERR ? found_clifo = 2 : found_clifo = -1; // Se trovo con partita iva setto a 2
|
|
|
|
if (found_clifo != 2 && paa_codpaese == "IT") // Se non l'ho trovato potrebbe essere italiano e ha codice paese blank
|
|
{
|
|
clifo.put(CLI_PAIV, paa_piva);
|
|
clifo.put(CLI_STATOPAIV, "");
|
|
clifo.read() == NOERR ? found_clifo = 2 : found_clifo = -5; // Se trovo con partita iva setto a 2
|
|
}
|
|
// Se trovo con p.iva controllo il cod. fisc. e, se c'è da db e se c'è in clienti-fornitori, altrimenti vado avanti
|
|
if (found_clifo == 2 && paa_codfisc.full() && clifo.get(CLI_COFI).full())
|
|
{
|
|
if (clifo.get(CLI_COFI) == paa_codfisc) // Controllo che il cod fisc (se c'è) corrisponda
|
|
found_clifo = 2;
|
|
else
|
|
found_clifo = -15;
|
|
}
|
|
}
|
|
// Altrimenti lo cerco con chiave 4, se ho il codice fiscale o ho il cod fisc e l'ho trovato con p iva
|
|
else if (paa_codfisc.full())
|
|
{
|
|
clifo.setkey(4);
|
|
clifo.put(CLI_COFI, paa_codfisc);
|
|
clifo.read() == NOERR ? found_clifo = 4 : found_clifo = -14; // Se il cod fisc corrisponde setto a 2
|
|
}
|
|
|
|
return found_clifo;
|
|
}
|
|
|
|
void TPassive_mask::init()
|
|
{
|
|
aggiungi_prot();
|
|
}
|
|
|
|
void TPassive_mask::load_all_fields()
|
|
{
|
|
}
|
|
|
|
void TPassive_mask::select_all(int sheet_field)
|
|
{
|
|
TSheet_field& docs = sfield(sheet_field);
|
|
TString_array& sht = docs.rows_array();
|
|
const int items = sht.items();
|
|
|
|
if (items > 0)
|
|
{
|
|
const TString4 select = *sht.row(0).get(0) == 'X' ? "" : "X";
|
|
for (int i = 0; i < items; i++)
|
|
sht.row(i).add(select, 0);
|
|
docs.force_update();
|
|
}
|
|
}
|
|
|
|
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
|
|
|
|
FOR_EACH_SHEET_ROW(sf, nr, row)
|
|
{
|
|
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 != "")
|
|
{
|
|
clifo.zero();
|
|
clifo.setkey(1);
|
|
clifo.put(CLI_TIPOCF, "F");
|
|
clifo.put(CLI_CODCF, cod_forn);
|
|
if(clifo.read() == NOERR)
|
|
{
|
|
q_update = "";
|
|
TToken_string key(row->get(sf.cid2index(S_PROKEY)), ';');
|
|
TString clifo_cofi = clifo.get(CLI_COFI);
|
|
TString clifo_paiv = clifo.get(CLI_PAIV);
|
|
if (clifo_cofi != "" && strcmp(row->get(sf.cid2index(S_CODFISC)), clifo_cofi) == 0 || clifo_paiv != "" && strcmp(row->get(sf.cid2index(S_PARIVA)), clifo_paiv) == 0)
|
|
{
|
|
q_update << "UPDATE FPPRO00F SET PZ_TIPOCF = 'F', PZ_CLIFOR = '" << row->get(sf.cid2index(S_FORNITORE)) << "' WHERE PZ_KEYPRGINVIO = '" << key.get(0) << "' AND PZ_KEYHEADERFATT = '" << key.get(1) << "' AND PZ_KEYBODYFATT = '" << key.get(2) << "'";
|
|
fp_db().sq_set_exec(q_update, false);
|
|
row->add("X", sf.cid2index(S_FPPRO));
|
|
sf.force_update();
|
|
}
|
|
}
|
|
}
|
|
row->add("", 0);
|
|
}
|
|
fp_db().sq_commit();
|
|
sf.force_update();
|
|
}
|
|
}
|
|
|
|
void TPassive_mask::new_forn()
|
|
{
|
|
TSheet_field& sf = sfield(F_ERR);
|
|
TString newf = "fpnewf";
|
|
FOR_EACH_SHEET_ROW(sf, nr, row)
|
|
{
|
|
int cod_forn = _forn_code.get_int(nr); // Prendo codice di errore associazione fornitore
|
|
|
|
int n_row_elenco = _list_fatt_err.get_int(nr); // Prendo che numero di riga a cui mi riferisco in fatture
|
|
TSheet_field& f_docs = sfield(F_DOCS); // Prendo SheetField da elenco fatture
|
|
TToken_string& row_elenco_fatt = f_docs.row(n_row_elenco); // Prendo riga dall'elenco delle fatture
|
|
TToken_string keys(row_elenco_fatt.get(f_docs.cid2index(S_PROKEY)), ';'); // Dalla riga leggo la chiave del db
|
|
|
|
if (row->starts_with("X") && (cod_forn == no_forn || cod_forn == no_match_cf || cod_forn == no_cf))
|
|
{
|
|
TString query; query << "SELECT PU_PEC AS PEC\n" <<
|
|
"FROM PAA3200F\n" <<
|
|
"WHERE PU_KEYPRGINVIO = '" << keys.get();
|
|
query << "' AND PU_KEYHEADERFATT = '" << keys.get();
|
|
query << "' AND PU_KEYBODYFATT = '" << keys.get() << "'";
|
|
fp_db().sq_set_exec(query);
|
|
TString pec = fp_db().sq_get("PEC");
|
|
|
|
TString num; num.format("%04d", nr);
|
|
TFilename newf_ini;
|
|
TString temp_path = newf_ini.tempdir();
|
|
newf_ini.tempdir() << "\\" << newf << num << ".ini";
|
|
TConfig forn_conf(newf_ini, "Transaction");
|
|
|
|
|
|
forn_conf.set("Action", "INSERT");
|
|
|
|
forn_conf.set_paragraph("20");
|
|
forn_conf.set("TIPOCF", "F");
|
|
forn_conf.set("COFI", row->get(sf.cid2index(S_CODFIERR)));
|
|
forn_conf.set("PAIV", row->get(sf.cid2index(S_PIVAERR)));
|
|
forn_conf.set("PEC", pec);
|
|
forn_conf.set("RAGSOC", row->get(sf.cid2index(S_RAGSERR)));
|
|
forn_conf.set("STATOPAIV", row_elenco_fatt.get(sf.cid2index(S_STATOPAIV)));
|
|
|
|
forn_conf.set_paragraph("17");
|
|
forn_conf.set("TIPOCF", "F");
|
|
forn_conf.set("RAGGOR", "O");
|
|
forn_conf.set("PADESTIN", row_elenco_fatt.get(sf.cid2index(S_CODSDI)));
|
|
|
|
TExternal_app app(TString("cg0 -1 -i") << temp_path << "\\" << newf << "*" << ".ini" << " /u" << user());
|
|
app.run();
|
|
row->add("", 0);
|
|
}
|
|
}
|
|
|
|
sf.force_update();
|
|
}
|
|
|
|
void TPassive_mask::aggiorna_forn()
|
|
{
|
|
TSheet_field& sf = sfield(F_ERR);
|
|
TString newf = "fpaggf";
|
|
FOR_EACH_SHEET_ROW(sf, nr, row)
|
|
{
|
|
int cod_forn = _forn_code.get_int(nr); // Prendo codice di errore associazione fornitore
|
|
|
|
int n_row_elenco = _list_fatt_err.get_int(nr); // Prendo che numero di riga a cui mi riferisco in fatture
|
|
TSheet_field& f_docs = sfield(F_DOCS); // Prendo SheetField da elenco fatture
|
|
TToken_string& row_elenco_fatt = f_docs.row(n_row_elenco); // Prendo riga dall'elenco delle fatture
|
|
|
|
if (row->starts_with("X") && cod_forn == no_match_cf)
|
|
{
|
|
TLocalisamfile clifo(LF_CLIFO);
|
|
bool is_not_gruppo_iva = false;
|
|
clifo.setkey(5);
|
|
clifo.put(CLI_TIPOCF, 'F');
|
|
clifo.put(CLI_STATOPAIV, row->get(1));
|
|
clifo.put(CLI_PAIV, row->get(2));
|
|
is_not_gruppo_iva = (clifo.read() == NOERR && clifo.get(CLI_ALLEG) != 'G');
|
|
if(is_not_gruppo_iva)
|
|
{
|
|
TString num; num.format("%04d", nr);
|
|
TFilename newf_ini;
|
|
TString temp_path = newf_ini.tempdir();
|
|
newf_ini.tempdir() << "\\" << newf << num << ".ini";
|
|
TConfig forn_conf(newf_ini, "Transaction");
|
|
|
|
forn_conf.set("Action", "MODIFY");
|
|
|
|
forn_conf.set_paragraph("20");
|
|
forn_conf.set("TIPOCF", "F");
|
|
forn_conf.set("COFI", row->get(sf.cid2index(S_CODFIERR)));
|
|
forn_conf.set("CODCF", row_elenco_fatt.get(sf.cid2index(S_FORNITORE)));
|
|
|
|
TExternal_app app(TString("cg0 -1 -i") << temp_path << "\\" << newf << "*" << ".ini" << " /u" << user());
|
|
message_box(TString("Sto andando a modificare il codice fiscale del fornitore:\n") << row->get(sf.cid2index(S_RAGSERR)));
|
|
app.run();
|
|
row->add("", 0);
|
|
}
|
|
}
|
|
}
|
|
sf.force_update();
|
|
}
|
|
|
|
|
|
bool TPassive_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
switch (o.dlg())
|
|
{
|
|
case S_SELCODPROT:
|
|
if(e == fe_modify)
|
|
set_filter_changed();
|
|
break;
|
|
case F_PROT:
|
|
if(e == fe_init)
|
|
init();
|
|
break;
|
|
case DLG_ALL:
|
|
if (e == fe_button)
|
|
switch (curr_page())
|
|
{
|
|
case filtri:
|
|
select_all(F_PROT);
|
|
set_filter_changed();
|
|
break;
|
|
case elenco_fe:
|
|
select_all(F_DOCS);
|
|
break;
|
|
case elenco_err:
|
|
select_all(F_ERR);
|
|
break;
|
|
default: break;
|
|
}
|
|
break;
|
|
case DLG_SAVEREC:
|
|
if (e == fe_button)
|
|
if(curr_page() == elenco_fe)
|
|
salva_for();
|
|
break;
|
|
case DLG_NEWREC:
|
|
if(e == fe_button)
|
|
if(curr_page() == elenco_err)
|
|
new_forn();
|
|
break;
|
|
case DLG_RECALC:
|
|
if (e == fe_button)
|
|
if (curr_page() == elenco_err)
|
|
aggiorna_forn();
|
|
break;
|
|
case F_DATAINI:
|
|
if (e == fe_init)
|
|
o.set(ini_get_string(CONFIG_DITTA, "fp", "LastXML", "01-01-2019"));
|
|
else if (e == fe_close)
|
|
ini_set_string(CONFIG_DITTA, "fp", "LastXML", o.get());
|
|
break;
|
|
case F_DATAEND:
|
|
if (e == fe_init)
|
|
o.set(TDate(TODAY));
|
|
break;
|
|
default: break;
|
|
}
|
|
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();
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////
|
|
// TPassive_app
|
|
/////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class TPassive_app : public TSkeleton_application
|
|
{
|
|
public:
|
|
void main_loop() override;
|
|
|
|
TPassive_app() = default;
|
|
};
|
|
|
|
void TPassive_app::main_loop()
|
|
{
|
|
TPassive_mask mask;
|
|
while(mask.run() == K_ENTER)
|
|
{
|
|
}
|
|
}
|
|
|
|
int fp0400(int argc, char * argv[])
|
|
{
|
|
TPassive_app fpas;
|
|
fpas.run(argc, argv, TR("Fatturazione F.P."));
|
|
return 0;
|
|
} |