Patch level : 10.0 888
Files correlati : lv4.exe Ricompilazione Demo : [ ] Commento : Aggiunti creazione effetti all' importazione fatture (CHIMA) git-svn-id: svn://10.65.10.50/branches/R_10_00@21486 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
9e794a712a
commit
7f11a0ad9d
108
lv/lv4500.cpp
108
lv/lv4500.cpp
@ -7,8 +7,10 @@
|
|||||||
#include <reputils.h>
|
#include <reputils.h>
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
|
|
||||||
|
#include <effetti.h>
|
||||||
#include <mov.h>
|
#include <mov.h>
|
||||||
#include <partite.h>
|
#include <partite.h>
|
||||||
|
#include <reffetti.h>
|
||||||
#include <scadenze.h>
|
#include <scadenze.h>
|
||||||
#include <rmoviva.h>
|
#include <rmoviva.h>
|
||||||
|
|
||||||
@ -348,11 +350,16 @@ class TImporta_fat_app : public TSkeleton_application
|
|||||||
TArray _conti;
|
TArray _conti;
|
||||||
TArray _importi;
|
TArray _importi;
|
||||||
TLog_report * _log;
|
TLog_report * _log;
|
||||||
|
int _prog;
|
||||||
|
long _codcf;
|
||||||
|
TString8 _abi;
|
||||||
|
TString8 _cab;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool search_gr_sp_ca(const int gruppo, const char* specie, const int categoria);
|
bool search_gr_sp_ca(const int gruppo, const char* specie, const int categoria);
|
||||||
|
|
||||||
const TFilename crea_tmpdir() const;
|
const TFilename crea_tmpdir() const;
|
||||||
|
const TFilename crea_tmpdireff() const;
|
||||||
const TFilename crea_nomefile(const long ndoc) const;
|
const TFilename crea_nomefile(const long ndoc) const;
|
||||||
|
|
||||||
const int segno_testata(const char sezione, const TCausale& cau) const;
|
const int segno_testata(const char sezione, const TCausale& cau) const;
|
||||||
@ -364,9 +371,10 @@ protected:
|
|||||||
TConfig* genera_testata(TImporta_fat_rec& recset, TFilename& tmpdir);
|
TConfig* genera_testata(TImporta_fat_rec& recset, TFilename& tmpdir);
|
||||||
void leggi_righe_cg(TImporta_fat_rec& recset, const TString& codcau);
|
void leggi_righe_cg(TImporta_fat_rec& recset, const TString& codcau);
|
||||||
void genera_righe_iva(TImporta_fat_rec& recset, TConfig& conf, int & nriga, const TString& codcau);
|
void genera_righe_iva(TImporta_fat_rec& recset, TConfig& conf, int & nriga, const TString& codcau);
|
||||||
void genera_rate(TImporta_fat_rec& recset, TConfig& conf, int & nriga);
|
void genera_rate(TImporta_fat_rec& recset, TConfig& conf, int & nriga, const TString & tmpdireff);
|
||||||
|
|
||||||
void elabora_file(const TFilename& tmpdir);
|
void elabora_file(const TFilename& tmpdir);
|
||||||
|
void elabora_effetti(const TFilename& tmpdir);
|
||||||
void elimina_file(const TFilename& tmpdir);
|
void elimina_file(const TFilename& tmpdir);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -392,6 +400,16 @@ const TFilename TImporta_fat_app::crea_tmpdir() const
|
|||||||
return tmpdir;
|
return tmpdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TFilename TImporta_fat_app::crea_tmpdireff() const
|
||||||
|
{
|
||||||
|
TFilename tmpdir;
|
||||||
|
tmpdir.tempdir();
|
||||||
|
tmpdir.add("effetti");
|
||||||
|
make_dir(tmpdir);
|
||||||
|
|
||||||
|
return tmpdir;
|
||||||
|
}
|
||||||
|
|
||||||
//CREA_NOMEFILE: genera il nome del file dal numero documento
|
//CREA_NOMEFILE: genera il nome del file dal numero documento
|
||||||
const TFilename TImporta_fat_app::crea_nomefile(const long ndoc) const
|
const TFilename TImporta_fat_app::crea_nomefile(const long ndoc) const
|
||||||
{
|
{
|
||||||
@ -459,7 +477,12 @@ TConfig* TImporta_fat_app::genera_testata(TImporta_fat_rec& recset, TFilename& t
|
|||||||
if (!::is_firm_value(codval) && codval != "EURO")
|
if (!::is_firm_value(codval) && codval != "EURO")
|
||||||
conf->set(MOV_CODVAL, codval);
|
conf->set(MOV_CODVAL, codval);
|
||||||
conf->set(MOV_TIPO, 'C');
|
conf->set(MOV_TIPO, 'C');
|
||||||
conf->set(MOV_CODCF, recset.get("C.CODCF").as_int());
|
_codcf = recset.get("C.CODCF").as_int();
|
||||||
|
conf->set(MOV_CODCF, _codcf);
|
||||||
|
const TString abicab = recset.get("C.ABICAB").as_string();
|
||||||
|
|
||||||
|
_abi = abicab.left(6);
|
||||||
|
_cab = abicab.mid(6);
|
||||||
conf->set(MOV_TOTDOC, genera_real(recset.get("C.IMPORTO"), segno));
|
conf->set(MOV_TOTDOC, genera_real(recset.get("C.IMPORTO"), segno));
|
||||||
conf->set(MOV_CODPAG, _msk->get_bool(F_DECCDP) ? atol(_codici->decodifica_condpag(recset.get("C.CODPAG").as_int())) : recset.get("C.CODPAG").as_int());
|
conf->set(MOV_CODPAG, _msk->get_bool(F_DECCDP) ? atol(_codici->decodifica_condpag(recset.get("C.CODPAG").as_int())) : recset.get("C.CODPAG").as_int());
|
||||||
conf->set(PART_ANNO, datadoc.year());
|
conf->set(PART_ANNO, datadoc.year());
|
||||||
@ -522,7 +545,7 @@ void TImporta_fat_app::genera_righe_iva(TImporta_fat_rec& recset, TConfig& conf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//GENERA_RATE: genero le righe su SCAD
|
//GENERA_RATE: genero le righe su SCAD
|
||||||
void TImporta_fat_app::genera_rate(TImporta_fat_rec& recset, TConfig& conf, int & nriga)
|
void TImporta_fat_app::genera_rate(TImporta_fat_rec& recset, TConfig& conf, int & nriga, const TString & tmpdireff)
|
||||||
{
|
{
|
||||||
const TDate datadoc = recset.get("R.DATADOC").as_date();
|
const TDate datadoc = recset.get("R.DATADOC").as_date();
|
||||||
TString paragraph;
|
TString paragraph;
|
||||||
@ -535,32 +558,84 @@ void TImporta_fat_app::genera_rate(TImporta_fat_rec& recset, TConfig& conf, int
|
|||||||
conf.set(SCAD_NRIGA, nriga);
|
conf.set(SCAD_NRIGA, nriga);
|
||||||
conf.set(SCAD_NRATA, recset.get("R.NRATA").as_int());
|
conf.set(SCAD_NRATA, recset.get("R.NRATA").as_int());
|
||||||
//??? CODPAG ???//
|
//??? CODPAG ???//
|
||||||
conf.set(SCAD_TIPOPAG, recset.get("R.TIPOPAG").as_int());
|
int tipopag = recset.get("R.TIPORATA").as_int();
|
||||||
|
|
||||||
|
if (tipopag == 3)
|
||||||
|
tipopag = 0;
|
||||||
|
else
|
||||||
|
if (tipopag == 2)
|
||||||
|
tipopag = 3;
|
||||||
|
|
||||||
|
conf.set(SCAD_TIPOPAG, tipopag);
|
||||||
conf.set(SCAD_IMPORTO, genera_real(recset.get("R.IMPORTO")));
|
conf.set(SCAD_IMPORTO, genera_real(recset.get("R.IMPORTO")));
|
||||||
// conf.set(SCAD_IMPORTOVAL, genera_real(recset.get("R.IMPORTO"))); //NON SO IN QUALE DEI DUE VADA
|
// conf.set(SCAD_IMPORTOVAL, genera_real(recset.get("R.IMPORTO"))); //NON SO IN QUALE DEI DUE VADA
|
||||||
conf.set(SCAD_DATASCAD, recset.get("R.DATASCAD").as_date());
|
conf.set(SCAD_DATASCAD, recset.get("R.DATASCAD").as_date());
|
||||||
//??? ABI CAB GRUPPO CONTO SOTTOCONTO ???//
|
//??? ABI CAB GRUPPO CONTO SOTTOCONTO ???//
|
||||||
|
if (tipopag == 3)
|
||||||
|
{
|
||||||
|
TString tmp(tmpdireff); tmp << "/" << ++_prog << ".ini" ;
|
||||||
|
TConfig confeff(tmp);
|
||||||
|
|
||||||
|
confeff.set_paragraph("Transaction"); //setto il paragrafo [Transaction] del file ini
|
||||||
|
confeff.set("Action","INSERT");
|
||||||
|
confeff.set("Mode", "AUTO");
|
||||||
|
|
||||||
|
TString paragraph;
|
||||||
|
|
||||||
|
paragraph.format("%d", LF_EFFETTI);
|
||||||
|
|
||||||
|
confeff.set_paragraph(paragraph);
|
||||||
|
confeff.set(EFF_DATASCAD, recset.get("R.DATASCAD").as_date());
|
||||||
|
confeff.set(EFF_TIPOPAG, tipopag);
|
||||||
|
confeff.set(EFF_TIPOCF, "C");
|
||||||
|
confeff.set(EFF_CODCF, _codcf);
|
||||||
|
confeff.set(EFF_CODABI, _abi);
|
||||||
|
confeff.set(EFF_CODCAB, _cab);
|
||||||
|
confeff.set(EFF_EFFCOMP, "X");
|
||||||
|
paragraph.format("%d,1", LF_REFFETTI);
|
||||||
|
|
||||||
|
confeff.set_paragraph(paragraph);
|
||||||
|
conf.set(REFF_NRIGATR, "1");
|
||||||
|
conf.set(REFF_IMPORTO, genera_real(recset.get("R.IMPORTO")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//ELABORA_FILE: chiamo la prima nota su tutti gli ini che ho generato
|
//ELABORA_FILE: chiamo la prima nota su tutti gli ini che ho generato
|
||||||
void TImporta_fat_app::elabora_file(const TFilename& tmpdir)
|
void TImporta_fat_app::elabora_file(const TFilename& tmpdir)
|
||||||
{
|
{
|
||||||
TString app;
|
TString_array res;
|
||||||
app << "cg2 -0 -i" << tmpdir << "/*.ini";
|
|
||||||
TExternal_app primanota(app);
|
|
||||||
primanota.run();
|
|
||||||
TString files;
|
TString files;
|
||||||
files << tmpdir << "/*.ini";
|
files << tmpdir << "/*.ini";
|
||||||
TString_array res;
|
|
||||||
|
|
||||||
list_files(files, res);
|
list_files(files, res);
|
||||||
FOR_EACH_ARRAY_ROW(res, r, f)
|
|
||||||
remove_file((const char *) *f);
|
if (res.items() > 0)
|
||||||
|
{
|
||||||
|
TString app;
|
||||||
|
app << "cg2 -0 -i" << tmpdir << "/*.ini";
|
||||||
|
TExternal_app primanota(app);
|
||||||
|
primanota.run();
|
||||||
|
FOR_EACH_ARRAY_ROW(res, r, f)
|
||||||
|
remove_file((const char *) *f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//ELIMINA_FILE: elimino tutti i file che ho elaborato DA IMPLEMENTARE
|
void TImporta_fat_app::elabora_effetti(const TFilename& tmpdir)
|
||||||
void TImporta_fat_app::elimina_file(const TFilename& tmpdir)
|
|
||||||
{
|
{
|
||||||
|
TString_array res;
|
||||||
|
TString files;
|
||||||
|
|
||||||
|
files << tmpdir << "/*.ini";
|
||||||
|
list_files(files, res);
|
||||||
|
if (res.items() > 0)
|
||||||
|
{
|
||||||
|
TString app;
|
||||||
|
app << "ef0 -0 -i" << tmpdir << "/*.ini";
|
||||||
|
TExternal_app effetti(app);
|
||||||
|
effetti.run();
|
||||||
|
FOR_EACH_ARRAY_ROW(res, r, f)
|
||||||
|
remove_file((const char *) *f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TImporta_fat_app::transfer(const TFilename& file)
|
void TImporta_fat_app::transfer(const TFilename& file)
|
||||||
@ -570,8 +645,10 @@ void TImporta_fat_app::transfer(const TFilename& file)
|
|||||||
TConfig* configfile = NULL;
|
TConfig* configfile = NULL;
|
||||||
|
|
||||||
TFilename tmpdir = crea_tmpdir();
|
TFilename tmpdir = crea_tmpdir();
|
||||||
|
TFilename tmpdireff = crea_tmpdireff();
|
||||||
|
|
||||||
int nrigai, nrigar;
|
int nrigai, nrigar;
|
||||||
|
_prog = 0;
|
||||||
|
|
||||||
TProgind pi(recset.items(), "Importazione in corso...", true, true);
|
TProgind pi(recset.items(), "Importazione in corso...", true, true);
|
||||||
TString16 codcau;
|
TString16 codcau;
|
||||||
@ -600,7 +677,7 @@ void TImporta_fat_app::transfer(const TFilename& file)
|
|||||||
genera_righe_iva(recset, *configfile, nrigai, codcau);
|
genera_righe_iva(recset, *configfile, nrigai, codcau);
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
genera_rate(recset, *configfile, nrigar);
|
genera_rate(recset, *configfile, nrigar, tmpdireff);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -619,7 +696,10 @@ void TImporta_fat_app::transfer(const TFilename& file)
|
|||||||
if (_codici->errors())
|
if (_codici->errors())
|
||||||
ok = yesno_box("Sono stati rilevati errori, si desidera proseguire con l'importazione");
|
ok = yesno_box("Sono stati rilevati errori, si desidera proseguire con l'importazione");
|
||||||
if (ok)
|
if (ok)
|
||||||
|
{
|
||||||
elabora_file(tmpdir);
|
elabora_file(tmpdir);
|
||||||
|
elabora_effetti(tmpdireff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TImporta_fat_app::create()
|
bool TImporta_fat_app::create()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user