Patch level : 12.0 836
Files correlati : fp0.exe Commento : - Esportazione da f1-fp delle ritenute di acconto - Correzione se importo e' nullo
This commit is contained in:
parent
ff97af3473
commit
82c61d5f93
@ -8,6 +8,7 @@
|
||||
#include "../fp/fp0400a.h"
|
||||
#include "reputils.h"
|
||||
#include "../fp/fplib.h"
|
||||
#include "causali.h"
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// TFppro
|
||||
@ -107,6 +108,17 @@ TDate TFppro::get_datareg(TToken_string& keys)
|
||||
return TDate();
|
||||
}
|
||||
|
||||
real TFppro::get_ritenute() const
|
||||
{
|
||||
TString query;
|
||||
query << "SELECT P7_IMPORTORIT AS IMPORTO FROM PAA0700F\n" <<
|
||||
"WHERE P7_KEYPRGINVIO = '" << _keys.prginvio << "' AND P7_KEYHEADERFATT = '" << _keys.headerfatt << "' AND P7_KEYBODYFATT = '" << _keys.bodyfatt << "'";
|
||||
fp_db().sq_set_exec(query);
|
||||
if(fp_db().sq_items() >= 1)
|
||||
return fp_db().sq_get_real("IMPORTO");
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
bool TFppro::set_keys(TToken_string& keys)
|
||||
{
|
||||
if(keys.items() == 3)
|
||||
@ -306,6 +318,14 @@ bool check_causale(const TString& cod_caus, const TString& tipo_doc, bool acq)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool check_caus_has_rit(const TString& cod_caus, bool rit)
|
||||
{
|
||||
TLocalisamfile causali(LF_CAUSALI);
|
||||
causali.put(CAU_CODCAUS, cod_caus);
|
||||
causali.read();
|
||||
return *causali.get(CAU_M770) != '\0';
|
||||
}
|
||||
|
||||
void run_cont_ini(bool liq)
|
||||
{
|
||||
static TString run_string;
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
int get_numreg(TToken_string& keys);
|
||||
TDate get_datareg();
|
||||
TDate get_datareg(TToken_string& keys);
|
||||
real get_ritenute() const;
|
||||
bool set_query();
|
||||
bool set_keys(TToken_string& keys);
|
||||
bool set_keys(keys_s keys);
|
||||
@ -56,7 +57,7 @@ public:
|
||||
static TDate get_data_first_doc();
|
||||
|
||||
TFppro() : _keys({"\0", "\0", "\0" }), _guess(false), _keys_setted(false), _is_set(false) { }
|
||||
|
||||
TFppro::TFppro(TToken_string& keys) : TFppro() { set_keys(keys); }
|
||||
};
|
||||
|
||||
class TProtocollo : TObject
|
||||
@ -110,5 +111,6 @@ void set_periodprec(bool flag);
|
||||
bool check_causale(const TString& cod_caus, bool acq = true);
|
||||
// Controlla se il "cod_caus" ha come "tipo_doc" FA o NC (di acquisto)
|
||||
bool check_causale(const TString& cod_caus, const TString& tipo_doc, bool acq = true);
|
||||
bool check_caus_has_rit(const TString& cod_caus, bool rit);
|
||||
void run_cont_ini(bool liq);
|
||||
#endif
|
@ -35,6 +35,12 @@ enum { filtri = 0, elenco_fe = 1, elenco_err = 2 }; // Enum per bottoni toolbar
|
||||
|
||||
class TPassive_mask : public TAutomask
|
||||
{
|
||||
struct iva
|
||||
{
|
||||
real imponibile;
|
||||
real imposta;
|
||||
};
|
||||
|
||||
TLog_report* _log;
|
||||
bool _f1;
|
||||
|
||||
@ -61,6 +67,8 @@ protected:
|
||||
void run_cg0(const TString& filename) const;
|
||||
void elenco_prots_sel(TString& string) const;
|
||||
|
||||
vector<iva>& get_righe_iva(TToken_string& keys) const;
|
||||
real calcola_importo(vector<iva> riva) const;
|
||||
// Gestione F1
|
||||
int prepara_contab() const;
|
||||
void log_contab();
|
||||
@ -195,6 +203,36 @@ void TPassive_mask::elenco_prots_sel(TString& string) const
|
||||
string = "";
|
||||
}
|
||||
|
||||
vector<TPassive_mask::iva>& TPassive_mask::get_righe_iva(TToken_string& keys) const
|
||||
{
|
||||
static vector<iva> riva;
|
||||
riva.clear();
|
||||
TString where_q; where_q << "WHERE PL_KEYPRGINVIO = '" << keys.get(0);
|
||||
where_q << "' AND PL_KEYHEADERFATT = '" << keys.get();
|
||||
where_q << "' AND PL_KEYBODYFATT = '" << keys.get() << "'";
|
||||
TString query; query << "SELECT PL_IMPONIBILE AS IMPONIBILE, PL_IMPOSTA AS IMPOSTA \nFROM PAA2200F \n" << where_q;
|
||||
fp_db().sq_set_exec(query, false);
|
||||
for (bool ok = fp_db().sq_next(); ok; ok = fp_db().sq_next())
|
||||
{
|
||||
TString imponibile = fp_db().sq_get("IMPONIBILE");
|
||||
TString imposta = fp_db().sq_get("IMPOSTA");
|
||||
if (imponibile.full() || imposta.full())
|
||||
riva.insert(riva.end(), { real(imponibile), real(imposta) });
|
||||
}
|
||||
return riva;
|
||||
}
|
||||
|
||||
real TPassive_mask::calcola_importo(vector<iva> riva) const
|
||||
{
|
||||
real tot = ZERO;
|
||||
for(auto it = riva.begin(); it != riva.end(); ++it)
|
||||
{
|
||||
tot += it->imponibile;
|
||||
tot += it->imposta;
|
||||
}
|
||||
return tot;
|
||||
}
|
||||
|
||||
void TPassive_mask::aggiungi_riga(TLocalisamfile& clifo, TSheet_field& sf, TSheet_field& sf_err)
|
||||
{
|
||||
TString denom = fp_db().sq_get("RAG_SOC");
|
||||
@ -515,11 +553,15 @@ int TPassive_mask::prepara_contab() const
|
||||
FOR_EACH_SHEET_ROW(sf, n, row) {
|
||||
if (row->starts_with("X"))
|
||||
{
|
||||
TString prokeys = row->get(sf.cid2index(S_PROKEY));
|
||||
TToken_string keys(prokeys, ';');
|
||||
TString codcaus(get_codcaus(row->get(2), row->get(10)));
|
||||
|
||||
if(!TString(row->get(sf.cid2index(S_NUMREGCONT))).empty())
|
||||
return n+1000;
|
||||
TString codcaus(get_codcaus(row->get(2), row->get(10)));
|
||||
if (codcaus.empty())
|
||||
return no_codcaus;
|
||||
|
||||
TString tipodoc(row->get(sf.cid2index(S_TIPODOCSDI)));
|
||||
if(tipodoc == "TD01" && !check_causale(codcaus, "FA"))
|
||||
if(!yesno_box("Attenzione, per un documento di tipo TD01 e' stata selezionata \nuna causale diversa da Fattura d'Acquisto.\nContinuare?"))
|
||||
@ -528,6 +570,8 @@ int TPassive_mask::prepara_contab() const
|
||||
if(!yesno_box("Attenzione, per un documento di tipo TD04 e' stata selezionata \nuna causale diversa da Nota Credito di Acquisto.\nContinuare?"))
|
||||
return cancel;
|
||||
n_sel++;
|
||||
|
||||
vector<iva>& riva = get_righe_iva(keys);
|
||||
TString num; num.format("%04d", n);
|
||||
TFilename newf_ini;
|
||||
#ifndef DBG
|
||||
@ -536,10 +580,9 @@ int TPassive_mask::prepara_contab() const
|
||||
newf_ini << F1_INIREGCONT << num << ".ini";
|
||||
#endif
|
||||
TConfig contab_ini(newf_ini, "Transaction");
|
||||
TString prokeys = row->get(sf.cid2index(S_PROKEY));
|
||||
|
||||
contab_ini.set("Action", "INSERT");
|
||||
|
||||
// Esporto dati di testata
|
||||
contab_ini.set_paragraph(LF_MOV); // [23]
|
||||
contab_ini.set("CODCAUS", codcaus);
|
||||
contab_ini.set("CODCF", row->get(sf.cid2index(S_FORNITORE)));
|
||||
@ -547,16 +590,38 @@ int TPassive_mask::prepara_contab() const
|
||||
contab_ini.set("DATADOC", row->get(sf.cid2index(S_DATADOC)));
|
||||
contab_ini.set("NUMDOCEXT", row->get(sf.cid2index(S_NDOC)));
|
||||
contab_ini.set("NUMDOC", TString(row->get(sf.cid2index(S_NDOC))).right(7));
|
||||
contab_ini.set("TOTDOC", abs(real(row->get(sf.cid2index(S_TOTDOC)))).string());
|
||||
TString totdoc = row->get(sf.cid2index(S_TOTDOC));
|
||||
if(totdoc.empty())
|
||||
{
|
||||
real imp = calcola_importo(riva);
|
||||
totdoc.cut(0) << imp;
|
||||
}
|
||||
real rit = TFppro(keys).get_ritenute();
|
||||
if(rit != ZERO)
|
||||
{
|
||||
contab_ini.set("TOTDOC", (abs(real(totdoc)) - rit).string());
|
||||
contab_ini.set("RITFIS", rit.string());
|
||||
}
|
||||
else
|
||||
contab_ini.set("TOTDOC", abs(real(totdoc)).string());
|
||||
contab_ini.set("KEYFPPRO", prokeys);
|
||||
|
||||
// Esporto righe iva
|
||||
int i = 1;
|
||||
for (auto it = riva.begin(); it != riva.end(); ++it)
|
||||
{
|
||||
contab_ini.set_paragraph(LF_RMOVIVA, i);
|
||||
contab_ini.set("IMPONIBILE", it->imponibile.string());
|
||||
contab_ini.set("IMPOSTA", it->imposta.string());
|
||||
contab_ini.set("NRIGA", i);
|
||||
i++;
|
||||
}
|
||||
|
||||
// Se ci sono le scadenze esporto anche quelle
|
||||
TToken_string keys(prokeys, ';');
|
||||
TString where_q;
|
||||
where_q << "WHERE PO_KEYPRGINVIO = '" << keys.get() << "'";
|
||||
where_q << "WHERE PO_KEYPRGINVIO = '" << keys.get(0) << "'";
|
||||
where_q << " AND PO_KEYHEADERFATT = '" << keys.get() << "'";
|
||||
where_q << " AND PO_KEYBODYFATT = '" << keys.get() << "'";
|
||||
|
||||
TString query; query << "SELECT PO_RIGA AS RIGA, PO_DATASCADENZA AS DATA, PO_IMPORTO AS IMPORTO \nFROM PAA2500F \n" << where_q;
|
||||
|
||||
fp_db().sq_set_exec(query,false);
|
||||
@ -569,26 +634,7 @@ int TPassive_mask::prepara_contab() const
|
||||
contab_ini.set("NRATA", riga);
|
||||
contab_ini.set("NRIGA", "1");
|
||||
}
|
||||
|
||||
where_q.cut(0) << "WHERE PL_KEYPRGINVIO = '" << keys.get(0);
|
||||
where_q << "' AND PL_KEYHEADERFATT = '" << keys.get();
|
||||
where_q << "' AND PL_KEYBODYFATT = '" << keys.get() << "'";
|
||||
query.cut(0) << "SELECT PL_IMPONIBILE AS IMPONIBILE, PL_IMPOSTA AS IMPOSTA \nFROM PAA2200F \n" << where_q;
|
||||
fp_db().sq_set_exec(query, false);
|
||||
int i = 1;
|
||||
for (bool ok = fp_db().sq_next(); ok; ok = fp_db().sq_next())
|
||||
{
|
||||
TString imponibile = fp_db().sq_get("IMPONIBILE");
|
||||
TString imposta = fp_db().sq_get("IMPOSTA");
|
||||
if(imponibile.full() || imposta.full())
|
||||
{
|
||||
contab_ini.set_paragraph(LF_RMOVIVA, i);
|
||||
contab_ini.set("IMPONIBILE", imponibile);
|
||||
contab_ini.set("IMPOSTA", imposta);
|
||||
contab_ini.set("NRIGA", i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
row->add("", 0);
|
||||
}
|
||||
}
|
||||
@ -687,7 +733,7 @@ void TPassive_mask::contabilizza()
|
||||
break;
|
||||
case no_codcaus:
|
||||
message_box("Attenzione, il fornitore non ha associato nessun codice causale predefinito.\nPrego selezionare un codice causale per la contabilizzazione.");
|
||||
next_page(1000);
|
||||
fill();
|
||||
break;
|
||||
case no_selected:
|
||||
message_box("Selezionare almeno un documento.");
|
||||
@ -743,7 +789,7 @@ void TPassive_mask::new_forn()
|
||||
{
|
||||
TString query; query << "SELECT PU_PEC AS PEC\n" <<
|
||||
"FROM PAA3200F\n" <<
|
||||
"WHERE PU_KEYPRGINVIO = '" << keys.get();
|
||||
"WHERE PU_KEYPRGINVIO = '" << keys.get(0);
|
||||
query << "' AND PU_KEYHEADERFATT = '" << keys.get();
|
||||
query << "' AND PU_KEYBODYFATT = '" << keys.get() << "'";
|
||||
fp_db().sq_set_exec(query);
|
||||
|
Loading…
x
Reference in New Issue
Block a user