Patch level : 12.0 no-patch
Files correlati : cg2.exe Commento : - Corrette write e rewrite spostando controlli per F1-FPPRO prima della scrittura - Corretta registrazione se collego un movimento gia registrato e il doc ext non e' valorizzato
This commit is contained in:
parent
08511f151b
commit
4a6b8875d4
@ -28,7 +28,9 @@ enum
|
||||
pro_err = -86552,
|
||||
pro_noerr = 1,
|
||||
pro_notsaved = 0,
|
||||
pro_nofp = -1
|
||||
pro_nofp = -1,
|
||||
pro_dataric_err = -2,
|
||||
pro_numreg_err = -3
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1449,7 +1451,9 @@ void TPrimanota_application::write_fppro()
|
||||
{
|
||||
// Controllo se la registrazione ha avuto effetto anche su FPPRO allora salvo riferimento sul mov
|
||||
if (save_fppro() > 0 && !save_dbmov())
|
||||
message_box(TString("ATTENZIONE:") << " non è stato possibile salvare i riferimenti del documento in ingresso per questo movimento.\n" <<
|
||||
message_box(
|
||||
TString("ATTENZIONE:") <<
|
||||
" non è stato possibile salvare i riferimenti del documento in ingresso per questo movimento.\n" <<
|
||||
"Movimento registrato senza collegamento ai documenti in ingresso.");
|
||||
}
|
||||
|
||||
@ -1463,10 +1467,43 @@ bool TPrimanota_application::has_tot_doc(TToken_string& fppro_keys)
|
||||
return tot.full() && real(tot) != 0;
|
||||
}
|
||||
|
||||
int TPrimanota_application::controlli_f1(const TMask& m)
|
||||
{
|
||||
if (m.find_by_id(F_PROKEY) != NULL && m.get(F_PROKEY).full() && has_f1_db((TMask*)&m) && fp_db().sq_is_connect() && check_causale(m.get(F_CODCAUS)))
|
||||
{
|
||||
TToken_string keys(m.get(F_PROKEY), ';');
|
||||
const TDate dataoraric = fppro_db().set_keys(keys).get_dataorarioric();
|
||||
// Devo controllare che la data operazione sia maggiore della data ric
|
||||
const TDate data_operazione(m.get(F_DATAREG));
|
||||
if (data_operazione < dataoraric)
|
||||
return pro_dataric_err;
|
||||
const int numreg = fppro_db().set_keys(keys).get_numregcont();
|
||||
if (numreg != 0)
|
||||
{
|
||||
const TDate data_documento(m.get(F_DATADOC));
|
||||
TString msg; msg << "Attenzione il documento " << data_documento.year() << " / " << m.get(F_NUMDOCEXT) <<
|
||||
" appena registrato e' gia' stato inserito con la registrazione numero " << numreg <<
|
||||
"\nSe si vuole registrare questo documento in ingresso, scollegarlo prima dalla precedente registrazione.";
|
||||
error_box(msg);
|
||||
return pro_numreg_err;
|
||||
}
|
||||
}
|
||||
return pro_noerr;
|
||||
}
|
||||
|
||||
int TPrimanota_application::write(const TMask& m)
|
||||
{
|
||||
static int lasterr = NOERR;
|
||||
|
||||
switch (controlli_f1(m)) // Solo con F1
|
||||
{
|
||||
case pro_dataric_err:
|
||||
error_box("Attenzione non è possibile registrare una fattura\ncon data operazione minore della data di ricezione.");
|
||||
case pro_numreg_err:
|
||||
return _isnowarning;
|
||||
default: case pro_noerr: break;
|
||||
}
|
||||
|
||||
const long numreg = m.get_long(F_NUMREG);
|
||||
if (numreg > _lastreg) _lastreg = numreg; // Aggiorna ultima registrazione libera
|
||||
|
||||
@ -1569,10 +1606,19 @@ int TPrimanota_application::write(const TMask& m)
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
int TPrimanota_application::rewrite(const TMask& m)
|
||||
{
|
||||
mask2rel(m);
|
||||
|
||||
switch (controlli_f1(m)) // Solo con F1
|
||||
{
|
||||
case pro_dataric_err:
|
||||
error_box("Attenzione non è possibile registrare una fattura\ncon data operazione minore della data di ricezione.");
|
||||
case pro_numreg_err:
|
||||
return _isnowarning;
|
||||
default: case pro_noerr: break;
|
||||
}
|
||||
|
||||
const int err = _rel->rewrite(true);
|
||||
if (err == NOERR)
|
||||
{
|
||||
@ -2414,11 +2460,6 @@ int TPrimanota_application::save_fppro()
|
||||
// Provo a vedere se hanno l'FP: se c'è l'indirizzo controllo che non sia F8 se non c'è non hanno l'FP
|
||||
if (!has_f1_db(&msk))
|
||||
return pro_nofp;
|
||||
if (!fp_db().sq_is_connect())
|
||||
{
|
||||
message_box("Attenzione connesione al database non riuscita.\nImpossibile collegarsi ai documenti in entrata.");
|
||||
return pro_nofp;
|
||||
}
|
||||
|
||||
// Anzitutto guardo la modalita' in cui sono
|
||||
// Se in modalita' inserimento continuo normalmente o in mod. modifica
|
||||
@ -2448,9 +2489,8 @@ int TPrimanota_application::save_fppro()
|
||||
const TDate data_operazione(msk.get(F_DATAREG));
|
||||
const TDate data_documento(msk.get(F_DATADOC));
|
||||
const TString& numero_docext = msk.get(F_NUMDOCEXT);
|
||||
const TString& numero_doc = msk.get(F_NUMDOC);
|
||||
real tot_doc = msk.get_real(F_TOTALE);
|
||||
real ritenute = msk.get_real(F_RITFIS);
|
||||
const real ritenute = msk.get_real(F_RITFIS);
|
||||
tot_doc += ritenute;
|
||||
TToken_string fppro_keys(msk.get(F_PROKEY), ';');
|
||||
const TString& keyprginvio = fppro_keys.get();
|
||||
@ -2459,35 +2499,25 @@ int TPrimanota_application::save_fppro()
|
||||
|
||||
// Controllo che i dati corrispondano a quelli nella fattura in ingresso
|
||||
TString where_str;
|
||||
where_str << " (PZ_DATA = \'" << data_documento.date2ansi() << "\'";
|
||||
if (has_tot_doc(fppro_keys))
|
||||
where_str << " (PZ_DATA = \'" << data_documento.date2ansi() << "\' AND PQ_IMPTOTDOC = \'" << tot_doc << "\' AND PZ_NUMERO = \'" << (!numero_docext.empty() ? numero_docext : numero_doc) << "\') ";
|
||||
else
|
||||
where_str << " (PZ_DATA = \'" << data_documento.date2ansi() << "\' AND PZ_NUMERO = \'" << (!numero_docext.empty() ? numero_docext : numero_doc) << "\') ";
|
||||
TString& query = TPro_msk::query_fppro(keyprginvio, keyheaderfatt, keybodyfatt, where_str);
|
||||
where_str << " AND PQ_IMPTOTDOC = \'" << tot_doc << "\'";
|
||||
if(!numero_docext.empty())
|
||||
where_str << " AND PZ_NUMERO = \'" << numero_docext << "\'";
|
||||
where_str << ") ";
|
||||
TString& query = TPro_msk::query_string();
|
||||
query << "WHERE PZ_KEYPRGINVIO = '" << keyprginvio << "' AND PZ_KEYHEADERFATT = '" << keyheaderfatt << "' AND PZ_KEYBODYFATT = '" << keybodyfatt << "'";
|
||||
query << " AND " << where_str;
|
||||
|
||||
fp_db().sq_set_exec(query);
|
||||
if(has_f1_db(&msk) && fp_db().sq_items() != 1)
|
||||
{
|
||||
warning_box(TString("Attenzione, ") << "al movimento non è stato abbinato nessun documento elettronico.\n" <<
|
||||
"Per consentire una corretta archiviazione sostitutiva si consiglia di non confermare la registrazione e di procedere\n" <<
|
||||
"all'identificazione del fornitore tramite il monitor fatture passive.\n" <<
|
||||
"Per consentire una corretta archiviazione sostitutiva si consiglia di provvedere al controllo della registrazione e di procedere\n" <<
|
||||
"all'inserimento dei dati riportati sulla fattura per la corretta identificazione del documento in entrata.\n" <<
|
||||
"Se possibile utilizzare il 'Riporta documento' o la contabilizzazione dal monitor delle fatture passive per evitare errori.\n"
|
||||
"In caso di documento escluso dalla fatturazione elettronica ignorate questo messaggio.");
|
||||
return pro_notsaved;
|
||||
}
|
||||
const int numreg = fp_db().sq_get_int("PZ_NUMREGCONT");
|
||||
if (numreg != 0)
|
||||
{
|
||||
TString msg; msg << "Attenzione il documento " << data_documento.year() << " / " << numero_doc <<
|
||||
" appena registrato e' gia' stato inserito con la registrazione numero " << numreg <<
|
||||
"\nControllare e nel caso provvedere a correggere l'associazione del movimento ai documenti in ingresso.";
|
||||
warning_box(msg);
|
||||
}
|
||||
|
||||
// Devo controllare che la data operazione sia maggiore della data ric
|
||||
const TDate dataoraric = fp_db().sq_get_date("P1_DATAORARIC");
|
||||
if(data_operazione < dataoraric)
|
||||
{
|
||||
error_box("Attenzione non è possibile registrare una fattura\ncon data operazione minore della data di ricezione.");
|
||||
save_dbmov(true);
|
||||
return pro_notsaved;
|
||||
}
|
||||
|
||||
@ -2496,13 +2526,17 @@ int TPrimanota_application::save_fppro()
|
||||
|
||||
TString update_query;
|
||||
update_query << "UPDATE FPPRO00F\n" <<
|
||||
"SET PZ_TIPOCF = 'F', PZ_CLIFOR = \'" << clifor << "\', PZ_DATACONT = \'" << TDate(TODAY).date2ansi() << "\', PZ_NUMREGCONT = \'" << numregcont << "\', PZ_DATAREGCONT = \'" << data_operazione.date2ansi() << "\'\n" <<
|
||||
"WHERE PZ_KEYPRGINVIO = \'" << keyprginvio << "\' AND PZ_KEYHEADERFATT = \'" << keyheaderfatt << "\' AND PZ_KEYBODYFATT = \'" << keybodyfatt << "\';";
|
||||
"SET PZ_TIPOCF = 'F', PZ_CLIFOR = \'" << clifor << "\', PZ_DATACONT = \'" << TDate(TODAY).date2ansi() << "\', " <<
|
||||
"PZ_NUMREGCONT = \'" << numregcont << "\', PZ_DATAREGCONT = \'" << data_operazione.date2ansi() << "\'\n" <<
|
||||
"WHERE PZ_KEYPRGINVIO = \'" << keyprginvio << "\' AND PZ_KEYHEADERFATT = \'" << keyheaderfatt << "\' AND PZ_KEYBODYFATT = \'" << keybodyfatt << "\';";
|
||||
|
||||
fp_db().sq_set_exec(update_query);
|
||||
const bool saved = fp_db().sq_commit();
|
||||
if (!saved)
|
||||
{
|
||||
error_box("Attenzione non è stato possibile registrare la fattura nel database.");
|
||||
save_dbmov(true);
|
||||
}
|
||||
return saved? pro_noerr : pro_notsaved;
|
||||
}
|
||||
|
||||
|
@ -4029,8 +4029,6 @@ bool TPro_msk::load_fppro_mask(TMask* msk, KEY k)
|
||||
row.add(fp_db().sq_get("PZ_TIPOPROT"));
|
||||
row.add(fp_db().sq_get("PZ_NUMPROT"));
|
||||
row.add(keys);
|
||||
|
||||
|
||||
}
|
||||
sf.force_update();
|
||||
sf.show();
|
||||
@ -4204,12 +4202,6 @@ void TPro_msk::add_scad(const TDate& date, const real& importo)
|
||||
_scadenze.insert(_scadenze.end(), { date, importo });
|
||||
}
|
||||
|
||||
TString& TPro_msk::query_fppro(const TString& keyprginvio, const TString& keyheaderfatt, const TString& keybodyfatt,
|
||||
const TString& where_str)
|
||||
{
|
||||
return query_fppro("", "", "", where_str, "", keyprginvio, keyheaderfatt, keybodyfatt, false, false);
|
||||
}
|
||||
|
||||
TString& TPro_msk::query_fppro(const TString& codforn, const TString& date)
|
||||
{
|
||||
return query_fppro(codforn, "", "", "", date, "", "", "", true, false);
|
||||
@ -4280,6 +4272,18 @@ TString& TPro_msk::query_fppro(const TString& codforn, const TString& stato_piva
|
||||
return query;
|
||||
}
|
||||
|
||||
TString& TPro_msk::query_string()
|
||||
{
|
||||
static TString query;
|
||||
query.cut(0) << "SELECT PZ_CLIFOR, PZ_DATA, CAST(P1_DATAORARIC AS DATE) AS P1_DATAORARIC, P7_TIPODOC, PQ_IMPTOTDOC, PZ_NUMERO, PZ_NUMREGCONT, PZ_TIPOPROT, " <<
|
||||
"PZ_NUMPROT, P2_FISCIVAPAESE, P2_FISCIVACOD, P2_CODFISCALE, PZ_KEYPRGINVIO, PZ_KEYHEADERFATT, PZ_KEYBODYFATT\n" <<
|
||||
"FROM PAA0200F \nJOIN FPPRO00F\n" << " ON P2_KEYPRGINVIO = PZ_KEYPRGINVIO AND P2_KEYHEADERFATT = PZ_KEYHEADERFATT AND P2_KEYBODYFATT = PZ_KEYBODYFATT\n" <<
|
||||
"JOIN PAA0100F \nON P2_KEYPRGINVIO = P1_KEYPRGINVIO AND P2_KEYHEADERFATT = P1_KEYHEADERFATT AND P2_KEYBODYFATT = P1_KEYBODYFATT\n" <<
|
||||
"JOIN PAA2700F \nON P2_KEYPRGINVIO = PQ_KEYPRGINVIO AND P2_KEYHEADERFATT = PQ_KEYHEADERFATT AND P2_KEYBODYFATT = PQ_KEYBODYFATT\n" <<
|
||||
"JOIN PAA0700F \nON P7_KEYPRGINVIO = PQ_KEYPRGINVIO AND P7_KEYHEADERFATT = PQ_KEYHEADERFATT AND P7_KEYBODYFATT = PQ_KEYBODYFATT\n";
|
||||
return query;
|
||||
}
|
||||
|
||||
void TPro_msk::abilita_piva(TMask* msk)
|
||||
{
|
||||
if (msk->get_bool(F_ENABSEARCH))
|
||||
|
@ -227,6 +227,8 @@ protected: // TApplication
|
||||
// setta variabili prima del controllo has_f1_db
|
||||
void set_has_f1_db(TMask* m);
|
||||
bool has_f1_db(TMask* m);
|
||||
// Controlli prima di write e rewrite
|
||||
int controlli_f1(const TMask& m);
|
||||
|
||||
virtual bool save(bool check_dirty);
|
||||
|
||||
@ -459,11 +461,10 @@ public:
|
||||
void add_scad(const TDate& date, const real& importo);
|
||||
bool should_bring_back() const { return _riporta; }
|
||||
|
||||
|
||||
static TString& query_fppro(const TString& keyprginvio, const TString& keyheaderfatt, const TString& keybodyfatt, const TString& where_str);
|
||||
static TString& query_fppro(const TString& codforn, const TString& date);
|
||||
static TString& query_fppro(const TString& stato_piva, const TString& piva, const TString& date);
|
||||
static TString& query_fppro(const TString& codforn, const TString& stato_piva, const TString& piva, const TString& where_str, const TString& date, const TString& keyprginvio, const TString& keyheaderfatt, const TString& keybodyfatt, bool order = true, bool piva_research = false);
|
||||
static TString& query_string();
|
||||
static void abilita_piva(TMask* msk);
|
||||
//bool is_fp();
|
||||
// Carica documenti FPPRO sulla maschera
|
||||
|
@ -155,6 +155,23 @@ TDate TFppro::get_data_first_doc() const
|
||||
return _db->sq_get_date("DATA");
|
||||
}
|
||||
|
||||
TDate TFppro::get_dataorarioric() const
|
||||
{
|
||||
TString query;
|
||||
query << "SELECT P1_DATAORARIC \nFROM PAA0100F \n" <<
|
||||
"WHERE P1_KEYPRGINVIO = '" << _keys.prginvio << "' AND P1_KEYHEADERFATT = '" << _keys.headerfatt << "' AND P1_KEYBODYFATT = '" << _keys.bodyfatt << "'";
|
||||
_db->sq_set_exec(query);
|
||||
return _db->sq_get_date("P1_DATAORARIC");
|
||||
}
|
||||
|
||||
int TFppro::get_numregcont() const
|
||||
{
|
||||
TString query;
|
||||
query << "SELECT PZ_NUMREGCONT FROM FPPRO00F\n" << where_str();
|
||||
_db->sq_set_exec(query);
|
||||
return _db->sq_get_int("PZ_NUMREGCONT");
|
||||
}
|
||||
|
||||
bool TFppro::set_query()
|
||||
{
|
||||
if (_keys_setted)
|
||||
@ -167,8 +184,8 @@ bool TFppro::set_query()
|
||||
|
||||
const char* TFppro::where_str() const
|
||||
{
|
||||
TString str;
|
||||
str << " WHERE PZ_KEYPRGINVIO = '" << _keys.prginvio << "' AND PZ_KEYHEADERFATT = '" << _keys.headerfatt << "' AND PZ_KEYBODYFATT = '" << _keys.bodyfatt << "'";
|
||||
static TString str;
|
||||
str.cut(0) << " WHERE PZ_KEYPRGINVIO = '" << _keys.prginvio << "' AND PZ_KEYHEADERFATT = '" << _keys.headerfatt << "' AND PZ_KEYBODYFATT = '" << _keys.bodyfatt << "'";
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -45,20 +45,23 @@ public:
|
||||
|
||||
bool check_reg(TToken_string& keys, int numreg);
|
||||
// Se un mov. registrato non e' collegato all'FPPRO cerco di capire qual'e`
|
||||
bool guess_the_doc(const TLocalisamfile& mov);
|
||||
bool guess_the_doc(const TLocalisamfile& mov);
|
||||
// Getters
|
||||
void get_keys_fppro();
|
||||
int get_numreg();
|
||||
int get_numreg(TToken_string& keys);
|
||||
TDate get_datareg();
|
||||
TDate get_datareg(TToken_string& keys);
|
||||
real get_ritenute() const;
|
||||
TDate get_data_first_doc() const;
|
||||
void get_keys_fppro();
|
||||
int get_numreg();
|
||||
int get_numreg(TToken_string& keys);
|
||||
TDate get_datareg();
|
||||
TDate get_datareg(TToken_string& keys);
|
||||
real get_ritenute() const;
|
||||
TDate get_data_first_doc() const;
|
||||
TDate get_dataorarioric() const;
|
||||
int get_numregcont() const;
|
||||
// Setters
|
||||
bool set_query();
|
||||
TFppro& set_keys(TToken_string& keys);
|
||||
TFppro& set_keys(keys_s keys);
|
||||
|
||||
|
||||
static bool set_connection(SSimple_query& s);
|
||||
|
||||
TFppro();
|
||||
|
Loading…
x
Reference in New Issue
Block a user