Patch level : nopatch
Files correlati : Commento : Implementazione nuovo modulo FP
This commit is contained in:
parent
0ec93baccd
commit
db711b01c9
@ -33,7 +33,6 @@ protected:
|
||||
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();
|
||||
@ -123,9 +122,25 @@ void TPAR_mask::fill()
|
||||
enable(DLG_FINDREC, filter_selected == "D");
|
||||
enable(DLG_PRINT, _enable_chiave_fixer && filter_selected.empty());
|
||||
|
||||
query << "USE " << LF_MOV << " KEY 3 SELECT (BETWEEN(" << MOV_DATAREG << ","
|
||||
<< dal.date2ansi() << ',' << al.date2ansi() << "))&&(REG!=\"\")"
|
||||
<< "\nFROM " << MOV_TIPO << "=C\nTO " << MOV_TIPO "=C";
|
||||
|
||||
/*
|
||||
VECCHIA QUERY
|
||||
|
||||
query << "USE " << LF_MOV << " KEY 3 SELECT (BETWEEN(" << MOV_DATAREG << ","
|
||||
<< dal.date2ansi() << ',' << al.date2ansi() << "))&&(REG!=\"\")"
|
||||
<< "\nFROM " << MOV_TIPO << "=C\nTO " << MOV_TIPO "=C";
|
||||
*/
|
||||
|
||||
//MY QUERY
|
||||
|
||||
query << "USE " << LF_MOV << " KEY 2\n";
|
||||
if (dal.ok())
|
||||
query << "FROM " << MOV_DATAREG << "=" << dal << "\n";
|
||||
if (al.ok())
|
||||
query << "TO " << MOV_DATAREG << "=" << al << "\n";
|
||||
|
||||
|
||||
//query << "USE " << LF_MOV << " WHERE CODCAUS IN ('A01') AND DATADOC BETWEEN " << dal.date2ansi() << " AND " << al.date2ansi();
|
||||
|
||||
TISAM_recordset rec(query);
|
||||
|
||||
@ -169,6 +184,7 @@ void TPAR_mask::fill()
|
||||
regs.set_row_cell(S_DATAREG, rec.get(MOV_DATAREG).as_date(), r);
|
||||
regs.set_row_cell(S_CLIENTE, rec.get_long(MOV_CODCF), r);
|
||||
regs.set_row_cell(S_RAGSOC, cli.get(CLI_RAGSOC), r);
|
||||
regs.set_row_cell(S_TIPODOC, rec.get_string(MOV_TIPODOC), r);
|
||||
|
||||
// non c'è ? TString cod_ind_sped = rec.get(DOC_CODINDSP).as_string();
|
||||
TString rif = get_dest_sdi(rec.get_string(CFV_TIPOCF)[0], rec.get_long(CFV_CODCF), EMPTY_STRING);
|
||||
@ -370,50 +386,50 @@ void TPAR_mask::connect_keys()
|
||||
void TPAR_mask::export_paf()
|
||||
{
|
||||
int ndocs = 0;
|
||||
TLocalisamfile doc(LF_DOC);
|
||||
TString_array& sht = sfield(F_REGS).rows_array();
|
||||
TDoc_fp elab;
|
||||
TSheet_field& sht = sfield(F_REGS);
|
||||
TReg_fp elab(get(F_TIPO_SDI));
|
||||
|
||||
//elab.set_cache_insert(true);
|
||||
if (!sht.empty())
|
||||
{
|
||||
TProgress_monitor pi(sht.items(), "Esportazione Fatture");
|
||||
FOR_EACH_ARRAY_ROW(sht, r, riga)
|
||||
TProgress_monitor pi(sht.items(), "Esportazione Regolarizzazioni");
|
||||
|
||||
FOR_EACH_SHEET_ROW_LOOP(sht, r)
|
||||
{
|
||||
if (!pi.add_status())
|
||||
break;
|
||||
|
||||
if (riga->starts_with("X"))
|
||||
if (sht.get_bool_row_cell(r, S_SELECTED))
|
||||
{
|
||||
const int anno = riga->get_int(sfield(F_REGS).cid2index(S_ANNO));
|
||||
const long nreg = riga->get_long(sfield(F_REGS).cid2index(S_NUMREG));
|
||||
const TDoc_key key(anno, EMPTY_STRING, nreg); //da fare
|
||||
const long nreg = sht.get_long_row_cell(r, S_NUMREG);
|
||||
|
||||
// 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)
|
||||
TMovimento_contabile mov(nreg);
|
||||
|
||||
if (elab.reg_to_paf(mov))
|
||||
ndocs++;
|
||||
else
|
||||
{
|
||||
/*
|
||||
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;
|
||||
}
|
||||
TString msg;
|
||||
|
||||
msg.format("La registrazione numero %ld non è stata esportata, continuare?", nreg);
|
||||
elab.log().log(2, msg);
|
||||
if (!yesno_box(msg))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (elab.force_commit() <= 0)
|
||||
{
|
||||
TString msg;
|
||||
|
||||
msg.format("Errore durante il cambiamento di stato finale, potrebbero esser rimaste delle fatture in Pronto");
|
||||
elab.log().log(2, msg);
|
||||
error_box(msg);
|
||||
}
|
||||
elab.show_log();
|
||||
}
|
||||
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 TPAR_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
@ -446,9 +462,10 @@ bool TPAR_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
TSheet_field& regs = sfield(F_REGS);
|
||||
TToken_string& row = regs.row(regs.selected());
|
||||
// Salvo subito su file le impostazioni di esportazione, in fplib accedo ai file
|
||||
save_all_fields();
|
||||
fill();
|
||||
TMovimento_contabile mov(regs.get_long_row_cell(regs.selected(), S_NUMREG));
|
||||
|
||||
if (mov.edit()) // Perchè prima andava senza dovergli mettere nulla?
|
||||
fill();
|
||||
}
|
||||
break;
|
||||
case DLG_ALL:
|
||||
@ -557,27 +574,6 @@ bool TPAR_mask::check_full_fields() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TPAR_mask::check_doc_filter(const TDocumentoEsteso& d) const
|
||||
{
|
||||
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));
|
||||
TSheet_field & scaus = sfield(F_CAUSALI_TIPO);
|
||||
|
||||
// Mi precarico la tabella dei documenti scelti
|
||||
FOR_EACH_SHEET_ROW(scaus, nr, row)
|
||||
{
|
||||
if (codnum.compare(row->get(_codnum)) == 0 && // Codice numerazione
|
||||
tipodoc.compare(row->get(_tipodoc)) == 0 && // Tipo documento
|
||||
td.reg_fisc().full() && // Regime fiscale
|
||||
row->get_char(_dastato) <= stato && // Da stato
|
||||
row->get_char(_astato) >= stato) // A stato
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void TPAR_mask::set_err_paf()
|
||||
{
|
||||
// Vado a riportare sui paf l'errore
|
||||
|
@ -26,3 +26,4 @@
|
||||
#define S_SPLITPAY 110
|
||||
#define S_ATTACH 111
|
||||
#define S_ONLYGEN 112
|
||||
#define S_TIPODOC 113
|
||||
|
@ -642,6 +642,7 @@ private:
|
||||
bool _nascondi_sconti_righe_fatt;
|
||||
TFP_nota_piede_f _riga_npf;
|
||||
bool _has_cust;
|
||||
TString _tipo_doc_sdi;
|
||||
|
||||
bool insert(TPaf_record& p);
|
||||
bool remove(TPaf_record& p);
|
||||
@ -688,12 +689,14 @@ public:
|
||||
bool reg_to_paf(const TMovimento_contabile& mov);
|
||||
bool reg_to_paf(long n_mov);
|
||||
// Mostra il log a fine esecuzione
|
||||
TLog_report& log() { return _log; }
|
||||
bool show_log();
|
||||
int commit();
|
||||
int force_commit();
|
||||
void set_cache_insert(const bool v) { _cache_insert = v; }
|
||||
|
||||
TReg_fp();
|
||||
|
||||
TReg_fp(const char* tipo_doc_sdi );
|
||||
~TReg_fp();
|
||||
};
|
||||
#endif // __FPLIB_H
|
||||
|
@ -88,13 +88,17 @@ bool check_tables()
|
||||
tabmod.put("MOD", "FP");
|
||||
tabmod.put("COD", "SQL");
|
||||
tabmod.put("CODTAB", "VERSION");
|
||||
TString version;
|
||||
int version;
|
||||
if (tabmod.read() == NOERR)
|
||||
version = tabmod.get("S0");
|
||||
version = tabmod.get_int("S0");
|
||||
for (SLIST_ELT file = xvt_slist_get_first(files); file; file = xvt_slist_get_next(files, file))
|
||||
{
|
||||
TString file_version = TFilename(file->str).name_only();
|
||||
file_version = file_version.mid(2, 4);
|
||||
TFilename fn(file->str);
|
||||
|
||||
fn = fn.name_only();
|
||||
|
||||
int file_version = atoi(fn.mid(2, 4));
|
||||
|
||||
|
||||
if (file_version <= version)
|
||||
continue;
|
||||
@ -117,7 +121,7 @@ bool check_tables()
|
||||
s.erase(0, limiter);
|
||||
if (!fp_db().sq_set_exec(query, false) || !fp_db().sq_commit())
|
||||
{
|
||||
fatal_box("Impossibile eseguire/salvare la query:\n%s\n%s", query.c_str(), fp_db().sq_get_text_error(false));
|
||||
error_box("Impossibile eseguire/salvare la query:\n%s\n%s", query.c_str(), fp_db().sq_get_text_error(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3076,7 +3080,7 @@ bool TReg_fp::reg_to_paf(const TMovimento_contabile& mov)
|
||||
// </CessionarioCommittente>
|
||||
// <DatiGenerali>
|
||||
TPaf_record& paf0700f = _paf_container.get_paf("PAF0700F");
|
||||
paf0700f.set("P7_TIPODOC", tipo_doc_sdi(mov));
|
||||
paf0700f.set("P7_TIPODOC", _tipo_doc_sdi);
|
||||
paf0700f.set("P7_DIVISA", "EUR"); // Fisso su euro in quanto effettuiamo il cambio
|
||||
paf0700f.set("P7_DATA", mov.get_date(MOV_DATADOC));
|
||||
paf0700f.set("P7_NUMERO", ""); //da chiedere ad ilaria
|
||||
@ -3097,112 +3101,25 @@ bool TReg_fp::reg_to_paf(const TMovimento_contabile& mov)
|
||||
TPaf_record& paf1800f = _paf_container.get_paf("PAF1800F");
|
||||
TPaf_record& paf2000f = _paf_container.get_paf("PAF2000F");
|
||||
TPaf_record& paf2100f = _paf_container.get_paf("PAF2100F");
|
||||
TPaf_record& paf1900f = _paf_container.get_paf("PAF1900F");
|
||||
TPaf_record& paf3000f = _paf_container.get_paf("PAF3000F");
|
||||
int n_righe_iva = mov.iva().rows();
|
||||
|
||||
for (int i = 0; i < n_righe_iva; i++)
|
||||
for (int i = 1; i <= n_righe_iva; i++)
|
||||
{
|
||||
reset(paf1800f);
|
||||
paf1800f.set("PI_NUMEROLINEA", (long)i);
|
||||
add_riepilogo_iva(mov, i);
|
||||
ok &= insert(paf1800f);
|
||||
|
||||
reset(paf3000f);
|
||||
paf3000f.set("PT_RIFNUMLINEA", (long)i);
|
||||
paf3000f.set("PT_COMMENTO", "");//TODO COSA DOBBIAMO METTERE NELLA DESCRIZIONE IVA CHE NON C'è
|
||||
// <CodiceArticolo>
|
||||
|
||||
reset(paf2100f);
|
||||
paf2100f.set("PK_KEYNLINEA", (long)i); //TODO va bene???
|
||||
paf2100f.set("PK_KEYNLINAR", (long)i);// qui???? CHE DIFF C'è TRA KEYLINEA E KEYLINEAR
|
||||
|
||||
|
||||
add_riepilogo_iva(mov, i);
|
||||
|
||||
|
||||
/* Se ho una fattura che deriva dalla fatturazione differita delle lavanderie prendo
|
||||
* dalla relativa riga descrizione tutti i riferimenti alle bolle che mancano */
|
||||
|
||||
ok &= insert(paf1800f);
|
||||
if (ok) ok &= insert(paf3000f);
|
||||
|
||||
if (ok) ok &= insert(paf0700f);
|
||||
|
||||
// </DatiRiepilogo>
|
||||
// <DatiPagamento>
|
||||
/*
|
||||
if (_gestioneallegati)
|
||||
{
|
||||
TPaf_record& paf2600f = _paf_container.get_paf("PAF2600F");
|
||||
long nprogr = 0; // Numero di file allegati
|
||||
// Se abilitato stampo il documento e lo allego
|
||||
TFilename rep;
|
||||
|
||||
if (_allegafattura)
|
||||
{
|
||||
if (!dongle().active(RSAUT))
|
||||
{
|
||||
_log.log(1, "Impossibile generare la fattura, il modulo RS non abilitato!");
|
||||
}
|
||||
else if (!doc.tipo().main_print_profile(rep, 2))
|
||||
{
|
||||
_log.log(1, "Impossibile generare la fattura, non disponibile un profilo di stampa per questo tipo documento!");
|
||||
}
|
||||
else
|
||||
{
|
||||
//ve1 -2 {CODNUM} {ANNO} {PROVV} {NDOC}(-{ANDOC}) {TIPO_ELABORAZIONE} {TIPO_STAMPA} {NUM_COPIE} {ARCHIVIAZIONE}
|
||||
// Costruisco la chiamata
|
||||
static TString commandline;
|
||||
commandline.cut(0) << "ve1 -2 " << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO)
|
||||
<< ' ' << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC) << " X P 1 D"; // X: stampa su disco, P: provvisorio, 1: 1 copia, D: disabilita archiviazione
|
||||
TExternal_app interattivo(commandline);
|
||||
if (interattivo.run() != NOERR)
|
||||
{
|
||||
TString msgerr = "Fallita generazione PDF documento ";
|
||||
msgerr << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO)
|
||||
<< ' ' << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC);
|
||||
error_box(msgerr);
|
||||
}
|
||||
else
|
||||
{
|
||||
TFilename pdf; pdf.tempdir();
|
||||
pdf << SLASH << doc.get(DOC_ANNO) << '_' << doc.get(DOC_CODNUM) << '_' << doc.get(DOC_NDOC) << ".pdf";
|
||||
if (!pdf.exist() && !yesno_box("Attenzione! Non stato possibile creare il pdf, continuare?"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!add_row_alleg(pdf, nprogr, paf2600f))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
TToken_string allegati(doc.get("COLL_GOLEM"), '\n');
|
||||
bool load_allegati = true;
|
||||
if (allegati.full())
|
||||
{
|
||||
if (_def_fld.empty())
|
||||
{
|
||||
TString msgerr; msgerr << "Errore: il documento " << _bfatt << " ha degli allegati ma nella configurazione non stato impostato come trametterli\nCaricare il documento senza allegati?";
|
||||
load_allegati = false;
|
||||
if (!yesno_box(msgerr))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
TFilename fname;
|
||||
FOR_EACH_TOKEN(allegati, row)
|
||||
{
|
||||
const TToken_string entry(row);
|
||||
if (entry.get(0, fname) && fname.exist())
|
||||
{
|
||||
if (!add_row_alleg(fname, nprogr, paf2600f))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Tabella di non invio XML
|
||||
TPaf_record& pafw300f = _paf_container.get_paf("PAFW300F");
|
||||
pafw300f.set("PW_TIPODOC", ""); //TODO PASSARE IL TIPO DOCUMENTO DELLA MASK NEL COSTRUTTORE
|
||||
@ -3242,7 +3159,7 @@ bool TReg_fp::reg_to_paf(long n_mov)
|
||||
|
||||
//NON LE CAPISCO
|
||||
|
||||
TReg_fp::TReg_fp() : _cache_insert(false)
|
||||
TReg_fp::TReg_fp(const char* tipo_doc_sdi) : _cache_insert(false) , _tipo_doc_sdi(tipo_doc_sdi)
|
||||
{
|
||||
_ditta.init(LF_NDITTE, prefix().get_codditta());
|
||||
_cofi = get_cofi_tras();
|
||||
@ -3271,3 +3188,13 @@ TReg_fp::~TReg_fp()
|
||||
{
|
||||
commit();
|
||||
}
|
||||
|
||||
bool TReg_fp::show_log()
|
||||
{
|
||||
TReport_book b;
|
||||
TFilename name = "fp_err.log";
|
||||
|
||||
b.add(_log);
|
||||
b.export_text(name, false, 132);
|
||||
return _log.preview();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user