Patch level : 10.0 NO PATCH
Files correlati : pd6342 Ricompilazione Demo : [ ] Commento : Importatore movimenti di analitica git-svn-id: svn://10.65.10.50/branches/R_10_00@20929 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
f7efda87b4
commit
4d8165fcae
@ -39,6 +39,7 @@ PD6342
|
|||||||
Stampa dei costi/ricavi analitici per anno riproporzionati per mese (Habilita)
|
Stampa dei costi/ricavi analitici per anno riproporzionati per mese (Habilita)
|
||||||
Importazione di movimenti in Analitica (Habilita)
|
Importazione di movimenti in Analitica (Habilita)
|
||||||
Ribaltamento ricorsivo movimenti di Analitica (Habilita)
|
Ribaltamento ricorsivo movimenti di Analitica (Habilita)
|
||||||
|
Quadratore dei movimenti di Analitica (Habilita)
|
||||||
|
|
||||||
|
|
||||||
- PG -------------------------------------------------------------------------------------------------------------
|
- PG -------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -10,6 +10,7 @@ int main(int argc, char** argv)
|
|||||||
case 0: pd6342100(argc, argv); break; //stampa costi/ricavi mensili per Habilita
|
case 0: pd6342100(argc, argv); break; //stampa costi/ricavi mensili per Habilita
|
||||||
case 1: pd6342200(argc, argv); break; //importatore di movimenti in analitica per Habilita
|
case 1: pd6342200(argc, argv); break; //importatore di movimenti in analitica per Habilita
|
||||||
case 2: pd6342300(argc, argv); break; //ribaltamento ricorsivo movimenti per Habilita
|
case 2: pd6342300(argc, argv); break; //ribaltamento ricorsivo movimenti per Habilita
|
||||||
|
case 3: pd6342400(argc, argv); break; //quadratore dei movimenti analitici per Habilita
|
||||||
default: pd6342100(argc, argv); break; //stampa costi/ricavi mensili per Habilita
|
default: pd6342100(argc, argv); break; //stampa costi/ricavi mensili per Habilita
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
int pd6342100(int argc, char* argv[]);
|
int pd6342100(int argc, char* argv[]);
|
||||||
int pd6342200(int argc, char* argv[]);
|
int pd6342200(int argc, char* argv[]);
|
||||||
int pd6342300(int argc, char* argv[]);
|
int pd6342300(int argc, char* argv[]);
|
||||||
|
int pd6342400(int argc, char* argv[]);
|
154
ps/pd6342200.cpp
154
ps/pd6342200.cpp
@ -18,19 +18,19 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
TImporta_da_BCS_rec::TImporta_da_BCS_rec(const char* filename)
|
TImporta_da_BCS_rec::TImporta_da_BCS_rec(const char* filename)
|
||||||
: TAS400_recordset(TString("AS400(121,0,0)\n") << filename)
|
: TAS400_recordset(TString("AS400(130)\n") << filename)
|
||||||
{
|
{
|
||||||
create_field("ANNO", -1, 4, _intfld); //anno di competenza
|
create_field("ANNO", 0, 4, _intfld); //anno di competenza
|
||||||
create_field("MESE", -1, 2, _intfld); //mese di competenza
|
create_field("MESE", 5, 2, _intfld); //mese di competenza
|
||||||
create_field("GIORNO", -1, 2, _intfld); //giorno di competenza
|
create_field("GIORNO", 8, 2, _intfld); //giorno di competenza
|
||||||
create_field("CODCOSTO", -1, 15, _alfafld); //centro di costo
|
create_field("CODCOSTO", 11, 15, _alfafld); //centro di costo
|
||||||
create_field("PCONTI", -1, 15, _alfafld); //centro di ricavo (o piano dei conti)
|
create_field("PCONTI", 27, 15, _alfafld); //centro di ricavo (o piano dei conti)
|
||||||
create_field("IMPORTO", -1, 12, _realfld); //importo lordo della prestazione moltiplicato per quantità
|
create_field("IMPORTO", 43, 12, _realfld); //importo lordo della prestazione moltiplicato per quantità
|
||||||
create_field("SEGNO", -1, 1, _alfafld); //segno importo (+ o -)
|
create_field("SEGNO", 56, 1, _alfafld); //segno importo (+ o -)
|
||||||
create_field("PROV", -1, 3, _alfafld, true, "FAT"); //provenienza (valore fisso FAT)
|
create_field("PROV", 59, 3, _alfafld, true, "FAT"); //provenienza (valore fisso FAT)
|
||||||
create_field("IDPROC", -1, 15, _alfafld); //ID della procedura inviante
|
create_field("IDPROC", 62, 15, _alfafld); //ID della procedura inviante
|
||||||
create_field("CODPRES", -1, 8, _alfafld); //codice della prestazione
|
create_field("CODPRES", 78, 8, _alfafld); //codice della prestazione
|
||||||
create_field("DESPRES", -1, 40, _alfafld); //descrizione della prestazione
|
create_field("DESPRES", 87, 40, _alfafld); //descrizione della prestazione
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sort_by_date(const TObject** o1, const TObject** o2)
|
static int sort_by_date(const TObject** o1, const TObject** o2)
|
||||||
@ -38,8 +38,8 @@ static int sort_by_date(const TObject** o1, const TObject** o2)
|
|||||||
const TString& r1 = *(TString*)*o1;
|
const TString& r1 = *(TString*)*o1;
|
||||||
const TString& r2 = *(TString*)*o2;
|
const TString& r2 = *(TString*)*o2;
|
||||||
|
|
||||||
const long d1 = atol(r1.left(8));
|
const long d1 = (atol(r1.left(4)) * 10000) + (atol(r1.mid(5, 2)) * 100) + (atol(r1.mid(8, 2)));
|
||||||
const long d2 = atol(r2.left(8));
|
const long d2 = (atol(r2.left(4)) * 10000) + (atol(r2.mid(5, 2)) * 100) + (atol(r2.mid(8, 2)));;
|
||||||
|
|
||||||
return d1 - d2;
|
return d1 - d2;
|
||||||
}
|
}
|
||||||
@ -81,14 +81,22 @@ TImporta_da_BCS_msk::TImporta_da_BCS_msk() : TAutomask("pd6342200a")
|
|||||||
class TImporta_da_BCS_app : public TSkeleton_application
|
class TImporta_da_BCS_app : public TSkeleton_application
|
||||||
{
|
{
|
||||||
TImporta_da_BCS_msk* _mask;
|
TImporta_da_BCS_msk* _mask;
|
||||||
|
TConfig* _configfile;
|
||||||
bool _has_ca;
|
bool _has_ca;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool check_autorization() const {return false;}
|
virtual bool check_autorization() const {return false;}
|
||||||
virtual const char * extra_modules() const {return "ca";}
|
virtual const char * extra_modules() const {return "ca";}
|
||||||
|
|
||||||
|
virtual bool create(void);
|
||||||
|
virtual bool destroy(void);
|
||||||
|
|
||||||
void sposta_file(const TString& file);
|
void sposta_file(const TString& file);
|
||||||
void genera_movana(TImporta_da_BCS_rec& recset);
|
void genera_movana(const TFilename& file);
|
||||||
|
|
||||||
|
void ini2mask();
|
||||||
|
void mask2ini();
|
||||||
|
|
||||||
bool elabora();
|
bool elabora();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -96,6 +104,35 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void TImporta_da_BCS_app::mask2ini()
|
||||||
|
{
|
||||||
|
//carica i parametri del file di configurazione
|
||||||
|
_configfile->set_paragraph("MAIN");
|
||||||
|
for (int i = 0; i < _mask->fields() ; i++)
|
||||||
|
{
|
||||||
|
TMask_field& f = _mask->fld(i);
|
||||||
|
const TFieldref* fr = f.field();
|
||||||
|
if (fr != NULL)
|
||||||
|
_configfile->set(fr->name(), f.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TImporta_da_BCS_app::ini2mask()
|
||||||
|
{
|
||||||
|
//carica i parametri del file di configurazione
|
||||||
|
_configfile->set_paragraph("MAIN");
|
||||||
|
for (int i = 0; i < _mask->fields() ; i++)
|
||||||
|
{
|
||||||
|
TMask_field& f = _mask->fld(i);
|
||||||
|
const TFieldref* fr = f.field();
|
||||||
|
if (fr != NULL)
|
||||||
|
{
|
||||||
|
const TString& val = _configfile->get(fr->name());
|
||||||
|
f.set(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TImporta_da_BCS_app::sposta_file(const TString& file)
|
void TImporta_da_BCS_app::sposta_file(const TString& file)
|
||||||
{
|
{
|
||||||
TFilename fileori = file;
|
TFilename fileori = file;
|
||||||
@ -107,54 +144,57 @@ void TImporta_da_BCS_app::sposta_file(const TString& file)
|
|||||||
strname.format("%06d_%06d_%s", TDate(TODAY).date2ansi(), daytime(), (const char*)fileori.name());
|
strname.format("%06d_%06d_%s", TDate(TODAY).date2ansi(), daytime(), (const char*)fileori.name());
|
||||||
TFilename filedest = path;
|
TFilename filedest = path;
|
||||||
filedest.add(strname);
|
filedest.add(strname);
|
||||||
|
fcopy(fileori, filedest);
|
||||||
//se la copia è andata a buon fine, creo un file .old vuoto e cancello il file .dat
|
|
||||||
if (fcopy(fileori, filedest))
|
|
||||||
{
|
|
||||||
TFilename fileold;
|
|
||||||
fileold = fileori.path();
|
|
||||||
|
|
||||||
TString strn = fileori.name_only();
|
|
||||||
strn << ".old";
|
|
||||||
|
|
||||||
fileold.add(strn);
|
|
||||||
|
|
||||||
fclose(fopen(fileold, "w"));
|
|
||||||
|
|
||||||
fileori.fremove();
|
fileori.fremove();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TImporta_da_BCS_app::genera_movana(TImporta_da_BCS_rec& recset)
|
void TImporta_da_BCS_app::genera_movana(const TFilename& file)
|
||||||
{
|
{
|
||||||
TLocalisamfile fmov(LF_MOVANA);
|
TLocalisamfile fmov(LF_MOVANA);
|
||||||
|
|
||||||
TDate dataold(NULLDATE);
|
TDate dataold(NULLDATE);
|
||||||
|
|
||||||
const TDate oggi(TODAY);
|
const TDate oggi(TODAY);
|
||||||
const TString4 codcau = "CAUS";
|
const TString4 codcau = _mask->get(F_CODCAU);
|
||||||
|
|
||||||
TAnal_mov ana(0);
|
TAnal_mov ana(0);
|
||||||
|
|
||||||
//TProgind pi(recset.items(), "Importazione in corso...", true, true);
|
TImporta_da_BCS_rec recset(file);
|
||||||
|
recset.sort(sort_by_date);
|
||||||
|
|
||||||
for(bool ok = recset.move_first(); ok; ok = recset.move_next());
|
TImporto totale;
|
||||||
|
|
||||||
|
TProgind pi(recset.items(), "Importazione in corso...", true, true);
|
||||||
|
|
||||||
|
for(bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||||||
{
|
{
|
||||||
//if (!pi.addstatus(1))
|
if (!pi.addstatus(1))
|
||||||
//break;
|
break;
|
||||||
|
|
||||||
const int anno = recset.get("ANNO").as_int();
|
const int anno = recset.get("ANNO").as_int();
|
||||||
|
const int mese = recset.get("MESE").as_int();
|
||||||
|
const int giorno = recset.get("GIORNO").as_int();
|
||||||
const TDate data(recset.get("GIORNO").as_int(), recset.get("MESE").as_int(), anno);
|
const TDate data(recset.get("GIORNO").as_int(), recset.get("MESE").as_int(), anno);
|
||||||
|
|
||||||
if(data != dataold)
|
if(data != dataold)
|
||||||
{
|
{
|
||||||
|
if (!ana.empty())
|
||||||
|
{
|
||||||
|
ana.put(MOVANA_SEZIONE, totale.sezione());
|
||||||
|
ana.put(MOVANA_TOTDOC, totale.valore());
|
||||||
ana.rewrite_write(fmov);
|
ana.rewrite_write(fmov);
|
||||||
|
|
||||||
|
totale.reset();
|
||||||
|
}
|
||||||
|
|
||||||
ana.zero();
|
ana.zero();
|
||||||
ana.put(MOVANA_ANNOES, anno);
|
ana.put(MOVANA_ANNOES, anno);
|
||||||
ana.put(MOVANA_DATAREG, oggi);
|
ana.put(MOVANA_DATAREG, oggi);
|
||||||
ana.put(MOVANA_DATACOMP, data);
|
ana.put(MOVANA_DATACOMP, data);
|
||||||
ana.put(MOVANA_CODCAUS, codcau);
|
ana.put(MOVANA_CODCAUS, codcau);
|
||||||
|
ana.put(MOVANA_DESCR, "Movimento Importato");
|
||||||
|
ana.put(MOVANA_TRASFERITO, true);
|
||||||
|
|
||||||
dataold = data;
|
dataold = data;
|
||||||
}
|
}
|
||||||
@ -168,8 +208,9 @@ void TImporta_da_BCS_app::genera_movana(TImporta_da_BCS_rec& recset)
|
|||||||
TImporto importo('A', imp);
|
TImporto importo('A', imp);
|
||||||
importo.normalize();
|
importo.normalize();
|
||||||
|
|
||||||
|
TString16 cod = recset.get("CODPRES").as_string(); cod.trim();
|
||||||
TString80 descrizione;
|
TString80 descrizione;
|
||||||
descrizione << recset.get("CODPRES").as_string() << '-' << recset.get("DESPRES").as_string();
|
descrizione << cod << '-' << recset.get("DESPRES").as_string();
|
||||||
|
|
||||||
riga.put(RMOVANA_ANNOES, anno);
|
riga.put(RMOVANA_ANNOES, anno);
|
||||||
riga.put(RMOVANA_SEZIONE, importo.sezione());
|
riga.put(RMOVANA_SEZIONE, importo.sezione());
|
||||||
@ -178,8 +219,16 @@ void TImporta_da_BCS_app::genera_movana(TImporta_da_BCS_rec& recset)
|
|||||||
riga.put(RMOVANA_CODCONTO, recset.get("PCONTI").as_string());
|
riga.put(RMOVANA_CODCONTO, recset.get("PCONTI").as_string());
|
||||||
riga.put(RMOVANA_DESCR, descrizione);
|
riga.put(RMOVANA_DESCR, descrizione);
|
||||||
riga.put(RMOVANA_IMPORTO, importo.valore());
|
riga.put(RMOVANA_IMPORTO, importo.valore());
|
||||||
|
|
||||||
|
totale += importo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ana.empty())
|
||||||
|
{
|
||||||
|
ana.put(MOVANA_SEZIONE, totale.sezione());
|
||||||
|
ana.put(MOVANA_TOTDOC, totale.valore());
|
||||||
ana.rewrite_write(fmov);
|
ana.rewrite_write(fmov);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -187,27 +236,42 @@ bool TImporta_da_BCS_app::elabora()
|
|||||||
{
|
{
|
||||||
TFilename file = _mask->get(F_FILE);
|
TFilename file = _mask->get(F_FILE);
|
||||||
|
|
||||||
TFilename filename = _mask->get(F_PATH);
|
if(file.exist())
|
||||||
filename << file.name();
|
{
|
||||||
|
genera_movana(file);
|
||||||
TImporta_da_BCS_rec recset(filename);
|
sposta_file(file);
|
||||||
recset.sort(sort_by_date);
|
}
|
||||||
genera_movana(recset);
|
else
|
||||||
|
{
|
||||||
sposta_file(filename);
|
error_box(TR("Il file selezionato non esiste; si prega di controllare"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TImporta_da_BCS_app::create()
|
||||||
|
{
|
||||||
|
_configfile = new TConfig("pd6342conf.ini", "INVIO");
|
||||||
|
return TSkeleton_application::create();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TImporta_da_BCS_app::destroy()
|
||||||
|
{
|
||||||
|
delete _configfile;
|
||||||
|
return TSkeleton_application::destroy();
|
||||||
|
}
|
||||||
|
|
||||||
void TImporta_da_BCS_app::main_loop()
|
void TImporta_da_BCS_app::main_loop()
|
||||||
{
|
{
|
||||||
|
|
||||||
_mask = new TImporta_da_BCS_msk;
|
_mask = new TImporta_da_BCS_msk;
|
||||||
|
|
||||||
|
ini2mask();
|
||||||
|
|
||||||
if (_mask->run() == K_ENTER)
|
if (_mask->run() == K_ENTER)
|
||||||
{
|
{
|
||||||
|
mask2ini();
|
||||||
if (elabora())
|
if (elabora())
|
||||||
message_box(TR("Importazione righe terminata"));
|
message_box(TR("Importazione righe terminata"));
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
//Campi per la maschera pd6342200a - importatore di movimenti in analitica per Habilita
|
//Campi per la maschera pd6342200a - importatore di movimenti in analitica per Habilita
|
||||||
#define F_PATH 100
|
|
||||||
#define F_FILE 101
|
#define F_FILE 101
|
||||||
|
#define F_CODCAU 102
|
||||||
|
#define F_DESCAU 103
|
@ -17,23 +17,39 @@ END
|
|||||||
|
|
||||||
GROUPBOX DLG_NULL 90 4
|
GROUPBOX DLG_NULL 90 4
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 1 1 "@bParametri Sorgente"
|
PROMPT 1 1 "@bParametri Importazione"
|
||||||
END
|
END
|
||||||
|
|
||||||
STRING F_PATH 255 50
|
STRING F_FILE 255 50
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 2 2 "Cartella "
|
PROMPT 2 2 "File "
|
||||||
DSELECT
|
DSELECT
|
||||||
CHECKTYPE REQUIRED
|
CHECKTYPE REQUIRED
|
||||||
FIELD ComInPath
|
FIELD ComInPath
|
||||||
END
|
END
|
||||||
|
|
||||||
STRING F_NAME 255 50
|
STRING F_CODCAU 4
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 2 3 "File "
|
PROMPT 2 3 "Cod. cau. "
|
||||||
FSELECT "*.txt"
|
USE LF_CAUSALI
|
||||||
FIELD ComInFile
|
INPUT CODCAUS F_CODCAU
|
||||||
|
DISPLAY "Codice " CODCAUS
|
||||||
|
DISPLAY "Descrizione@50" DESCR
|
||||||
|
OUTPUT F_CODCAU CODCAUS
|
||||||
|
OUTPUT F_DESCAU DESCR
|
||||||
CHECKTYPE REQUIRED
|
CHECKTYPE REQUIRED
|
||||||
|
FIELD CodCau
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_DESCAU 50
|
||||||
|
BEGIN
|
||||||
|
PROMPT 25 3 ""
|
||||||
|
USE LF_CAUSALI KEY 2
|
||||||
|
INPUT DESCR F_DESCAU
|
||||||
|
DISPLAY "Descrizione@50" DESCR
|
||||||
|
DISPLAY "Codice " CODCAUS
|
||||||
|
COPY OUTPUT F_CODCAU
|
||||||
|
CHECKTYPE NORMAL
|
||||||
END
|
END
|
||||||
|
|
||||||
ENDPAGE
|
ENDPAGE
|
||||||
|
3
ps/pd6342conf.ini
Executable file
3
ps/pd6342conf.ini
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
[MAIN]
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user