Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@19894 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
cris 2010-01-08 14:03:26 +00:00
parent 271dbdf96a
commit f5c157abf6

View File

@ -1,6 +1,7 @@
#include <applicat.h>
#include <automask.h>
#include <progind.h>
#include <reputils.h>
#include <utility.h>
#include "../ce/ammce.h"
@ -13,11 +14,6 @@
#include "lv4100.h"
#include "lv4300a.h"
#include <pconti.h>
#include <mov.h>
#include <rmov.h>
#include <rmoviva.h>
#define CGC_DITTA 0
#define CGC_GRUPPO 1
#define CGC_SPECIE 2
@ -120,6 +116,10 @@ class TImporta_cesp : public TSkeleton_application
{
TImporta_cesp_mask* _msk;
protected:
bool log_error(TLog_report& log, const char* msg, const TRecordset& recset, const int err=NOERR);
bool search_gr_sp_ca(const int gruppo, const char* specie, const int categoria);
public:
virtual bool create();
virtual bool destroy();
@ -127,74 +127,110 @@ public:
void transfer(const TFilename& file);
};
bool TImporta_cesp::search_gr_sp_ca(const int gruppo, const char* specie, const int categoria)
{
return true;
}
bool TImporta_cesp::log_error(TLog_report& log, const char* msg, const TRecordset& recset, const int err)
{
TString message;
message << TR("Riga") << ' ' << recset.current_row() << ": " << msg << err=NOERR ? " " : format("%d", err);
log.log(2, message);
return false;
}
void TImporta_cesp::transfer(const TFilename& file)
{
const TFilename outdir(_msk->get(F_PATHOUT));
TImporta_cogeco_recset s(file);
TProgind pi(s.items(),"Importazione cespiti in corso ...",true,true);
TImporta_cogeco_recset recset(file);
TString caption; _msk->get_caption(caption);
TProgind pi(recset.items(), caption, true, true);
const long ditta = _msk->get_long(F_CODITTA);
const TEsercizi_contabili esc;
int lastesc = esc.last();
long ntran = 1;
TLog_report log(caption);
for (bool ok = s.move_to(1); ok ; ok = s.move_next())
for (bool ok = recset.move_to(1); ok ; ok = recset.move_next())
{
if (!pi.addstatus(1))
break;
const long dt = s.get(CGC_DITTA).as_int();
const long dt = recset.get(CGC_DITTA).as_int();
if (ditta != dt)
continue;
const long codces = s.get(CGC_NPROGR).as_int();
const long codces = recset.get(CGC_NPROGR).as_int();
// verifico il codice cespite padre
const long codpadre = s.get(CGC_CEINCR).as_int();
//const long codpadre = s.get(CGC_CODPADRE); secondo me e' corretto questo! chiedere
const long codpadre = recset.get(CGC_CEINCR).as_int();
//const long codpadre = recset.get(CGC_CODPADRE); secondo me e' corretto questo! chiedere
if (codpadre == ZERO) // nuovo cespite
{
// creo record anagrafica cespi
TLocalisamfile cespi(LF_CESPI);
cespi.put(CESPI_IDCESPITE, format("%010ld", codces));
cespi.put(CESPI_CODCGR, s.get(CGC_GRUPPO).as_string());
cespi.put(CESPI_CODSP, s.get(CGC_SPECIE).as_string());
cespi.put(CESPI_CODCAT, s.get(CGC_CESPITE).as_string());
cespi.put(CESPI_DESC, s.get(CGC_DESCR).as_string());
cespi.put(CESPI_DTFUNZ, s.get(CGC_DATAINIZAMM).as_string());
cespi.put(CESPI_DTALIEN, s.get(CGC_DATAALIENENAZIONE).as_string());
cespi.put(CESPI_TPSPEMAN, 1);
const int gr = recset.get(CGC_GRUPPO).as_int();
const char* sp = recset.get(CGC_SPECIE).as_string();
const int ca = recset.get(CGC_CESPITE).as_int();
if (search_gr_sp_ca(gr, sp, ca))
{
cespi.put(CESPI_CODCGR, recset.get(CGC_GRUPPO).as_string());
cespi.put(CESPI_CODSP, recset.get(CGC_SPECIE).as_string());
cespi.put(CESPI_CODCAT, recset.get(CGC_CESPITE).as_string());
cespi.put(CESPI_DESC, recset.get(CGC_DESCR).as_string());
TDate data(recset.get(CGC_DATAINIZAMM).as_string());
if (data.ok())
cespi.put(CESPI_DTFUNZ, data);
data = TDate(recset.get(CGC_DATAALIENENAZIONE).as_string());
if (data.ok())
cespi.put(CESPI_DTALIEN, data);
cespi.put(CESPI_TPSPEMAN, 1);
// creo record salce
TLocalisamfile salce(LF_SALCE);
salce.put(SALCE_IDCESPITE, cespi.get(CESPI_IDCESPITE));
salce.put(SALCE_CODES, lastesc); // verificare se ultimo esercizio va bene (2010?)
salce.put(SALCE_TPSALDO, 1); // verificare se saldo iniziale (1) va bene
salce.put(SALCE_NUMELE, 1);
salce.put(SALCE_CSTO, s.get(CGC_COSTOACQ).as_string());
// creo record salce
TLocalisamfile salce(LF_SALCE);
salce.put(SALCE_IDCESPITE, cespi.get(CESPI_IDCESPITE));
salce.put(SALCE_CODES, lastesc); // verificare se ultimo esercizio va bene (2010?)
salce.put(SALCE_TPSALDO, 1); // verificare se saldo iniziale (1) va bene
salce.put(SALCE_NUMELE, 1);
salce.put(SALCE_CSTO, recset.get(CGC_COSTOACQ).as_string());
// creo record ammce
TLocalisamfile ammce(LF_AMMCE);
ammce.put(AMMCE_IDCESPITE, salce.get(CESPI_IDCESPITE));
ammce.put(AMMCE_CODES, salce.get(SALCE_CODES));
ammce.put(AMMCE_TPSALDO, salce.get(SALCE_TPSALDO));
ammce.put(AMMCE_TPAMM, 1); // verificare se tipo amm = 1 va bene
ammce.put(AMMCE_QNORP, s.get(CGC_FONDOAMMORT).as_real());
ammce.put(AMMCE_QANTP, s.get(CGC_TOTAMMANTIC).as_real());
// creo record ammce
TLocalisamfile ammce(LF_AMMCE);
ammce.put(AMMCE_IDCESPITE, salce.get(CESPI_IDCESPITE));
ammce.put(AMMCE_CODES, salce.get(SALCE_CODES));
ammce.put(AMMCE_TPSALDO, salce.get(SALCE_TPSALDO));
ammce.put(AMMCE_TPAMM, 1); // verificare se tipo amm = 1 va bene
ammce.put(AMMCE_QNORP, recset.get(CGC_FONDOAMMORT).as_real());
ammce.put(AMMCE_QANTP, recset.get(CGC_TOTAMMANTIC).as_real());
// scrivo i record dei cespiti
int err = cespi.write();
if (err == NOERR)
err = salce.write();
if (err == NOERR)
err = ammce.write();
// scrivo i record dei cespiti
int err = cespi.write();
if (err != NOERR)
log_error(log, TR("Errore in scrittura anagrafica cespiti "), recset, err);
else
{
err = salce.write();
if (err != NOERR)
log_error(log, TR("Errore in scrittura saldi cespiti "), recset, err);
else
{
err = ammce.write();
if (err != NOERR)
log_error(log, TR("Errore in scrittura ammortamento cespiti "), recset, err);
}
}
}
}
else
{
// chiedere cosa fare perche' non ho capito cosa devo sommare!!
}
}
if (log.recordset()->items() > 0)
log.preview();
}
bool TImporta_cesp::create()