campo-sirio/ps/pe0001100.cpp
alex b630af6d91 Patch level : 10.0 no patch
Files correlati     :
Ricompilazione Demo : [ ]

importazione galileo cantieri


git-svn-id: svn://10.65.10.50/trunk@19775 c028cbd2-c16b-5b4b-a496-9718f37d4682
2009-12-14 22:52:10 +00:00

295 lines
10 KiB
C++
Executable File
Raw Blame History

#include <applicat.h>
#include <automask.h>
#include <execp.h>
#include <progind.h>
#include <real.h>
#include <reputils.h>
#include <utility.h>
#include <relation.h>
#include <reprint.h>
#include <textset.h>
#include "tabutil.h"
#include "pe0001.h"
#include "pe0001100a.h"
#include <causali.h>
#include <clifo.h>
#include <mov.h>
#include <rmov.h>
#include <rmoviva.h>
#define AT01CM 0 // Record attivo/sospeso/annullato DIZSMAS - ATTI
#define DT01CM 1 // Data stampa per G.Gen.le DIZSMAS - DATS
#define NR01CM 2 // Numero azione di aggiornamento DIZSMAS - NRAZ
#define TPMVCM 3 // Flag IVA I=IVA =no IVA DIZSMAS - TPMV
#define CDDTCM 4 // Codice Ditta DIZSMAS - CDDT
#define AAPRCM 5 // Anno Operazione DIZSMAS - AAPR
#define ANNPCM 6 // Anno Reg.DA GESTIRE DIZSMAS - ANNP
#define TPGICM 7 // Giornale IVA TB=GI DIZSMAS - TPGI
#define DTOPCM 8 // Data operazione DIZSMAS - DATS
#define NONPCM 9 // Nr. Operaz./Nr. Prot. DIZSMAS - NONP
#define NRRGCM 10 // Numero Riga 2 DIZSMAS - NRR2
#define NRGICM 11 // Nr Riga Giornale DIZSMAS - NRGI
#define CONTCM 12 // Gr. Conto Sottoconto DIZSMAS - CONT
#define DIVICM 13 // Divisione TB=DI DIZSMAS - DIVI
#define NPARCM 14 // Nr Partita DIZSMAS - NPAR
#define AAOPCM 15 // Anno partita DIZSMAS - ANNO
#define DTRGCM 16 // Data registrazione DIZSMAS - DATS
#define CAUSCM 17 // Causale TB=CA DIZSMAS - CAUS
#define DSUPCM 18 // Descrizione Supplementare DIZSMAS - DSUP
#define IMPOCM 19 // Importo "-"=Avere DIZSMAS - IMPO
#define CDVACM 19 // Codice Valuta TB=VA DIZSMAS - CDVA
#define CAMBCM 20 // Cambio DIZSMAS - CAMB
#define IMVACM 21 // Importo Valuta DIZSMAS - IMVA
#define CDPGCM 22 // Codice di Pagamento TB=CP DIZSMAS - CDPG
#define DT1SCM 23 // Data I^ scadenza DIZSMAS - DATS
#define DTDOCM 24 // Data documento DIZSMAS - DATS
#define NRDOCM 25 // N<> Documento DIZSMAS - NUDO
#define CCTPCM 26 // Centri Costo Tipico TB=CC DIZSMAS - CCTP
#define NCOMCM 27 // Numero Commessa DIZSMAS - NCOM
#define CDSCCM 28 // Codice Sottocommessa DIZSMAS - CDSC
#define INDECM 29 // Indetraibilit<69> % DIZSMAS - INDE
#define CDIVCM 30 // Codice IVA DIZSMAS - CDIV
#define IMPSCM 31 // Imposta DIZSMAS - IMPS
#define CDAGCM 32 // Codice Agente DIZSMAS - CDAG
#define DTVBCM 33 // Data Liquidazione Iva Sospesa DIZSMAS - DATS
#define FLSBCM 34 // Flag *=Stampato Bollato DIZSMAS - FLSB
#define FSBICM 35 // Flag *=Stampato Boll.IVA DIZSMAS - FSBI
#define FLVZCM 36 // V=Var.S=Storno P=Liq.prec. E=Esig.Sosp. DIZSMAS - FLVZ
#define FLIICM 37 // Flag IVA Irrecup. " "=I irr. DIZSMAS - FLII
#define FLTSCM 38 // Flag Tipo Sollecito DIZSMAS - FLTS
#define FLEPCM 39 // *=Est.EP Non <20> pi<70> usato DIZSMAS - FLEP
#define DPERCM 40 // Dati Personalizzabili DIZSMAS - DPER
#define CONSCM 41 // Gr.Co.Sottoc.Sostitutivo DIZSMAS - CONS
#define DTSTCM 42 // Nr.progr. rateo/risconto -
#define USERCM 43 // Utente DIZSMAS - NOMU
#define DTUMCM 44 // Data ultima manutenzione DIZSMAS - DATS
#define TPUMCM 45 // Tipo ultima manutenzione DIZSMAS - FLAG
#define FL01CM 46 // Flag Generico DIZSMAS - FLAG
#define FL02CM 47 // Flag Generico DIZSMAS - FLAG
#define FL03CM 48 // Flag Generico DIZSMAS - FLAG
#define FL04CM 49 // Flag Generico DIZSMAS - FLAG
#define FL05CM 50 // Flag Generico DIZSMAS - FLAG
#define CMBECM 51 // Cambio EURO DIZSMAS - CAME
#define IMVACM2 52 // Importo Val 2 DIZSMAS - IMPO
#define IMPSCM2 53 // Imposta 2 DIZSMAS - IMPS
class TImporta_mov_recset : public TCSV_recordset
{
public:
TImporta_mov_recset(const char* query = "") : TCSV_recordset(TString("CSV(;)\n") << query) {}
virtual ~TImporta_mov_recset() {}
};
///////////////////////////////////////////////////////////
// TAutomask
///////////////////////////////////////////////////////////
class TImporta_mov_mask : public TAutomask
{
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
public:
TImporta_mov_mask();
};
TImporta_mov_mask::TImporta_mov_mask() :TAutomask ("pe0001100a")
{
}
bool TImporta_mov_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
{
switch (f.dlg())
{
//giochetto per avere la lista dei files validi nella directory di trasferimento!
case F_NAME:
if (e == fe_button)
{
TArray_sheet as(-1, -1, 72, 20, TR("Selezione file"),
"File@32");
TFilename path = get(F_PATH);
path.add("*.txt"); //files delle testate
list_files(path, as.rows_array());
TFilename name;
FOR_EACH_ARRAY_ROW(as.rows_array(), i, row)
{
name = *row;
*row = name.name();
}
if (as.run() == K_ENTER)
{
f.set(as.row(as.selected()));
}
}
break;
default:
break;
}
return true;
}
///////////////////////////////////////
// TSkeleton_application
///////////////////////////////////////
class TImporta_mov : public TSkeleton_application
{
virtual bool check_autorization() const {return false;}
virtual const char * extra_modules() const {return "ve";}
TImporta_mov_mask* _msk;
//protected:
public:
virtual bool create();
virtual bool destroy();
virtual void main_loop();
bool transfer(const TFilename& file);
TImporta_mov() {};
};
bool TImporta_mov::transfer(const TFilename& file)
{
TFilename tempdir;
TImporta_mov_recset s(file);
TProgind pi(s.items(),"Importazione movimenti in corso ...",true,true);
TConfig * _conf = NULL;
long nmov = - 1;
int nrigac = 0;
int nrigai = 0;
tempdir.tempdir();
for (bool ok=s.move_first();ok;ok=s.move_next())
{
if (!pi.addstatus(1))
break;
const long n = s.get(NONPCM).as_int();
if (n != nmov )
{
nmov = n;
delete _conf;
_conf = NULL;
}
if (_conf = NULL)
{
TFilename temp;
temp.temp(tempdir,"trn");
_conf = new TConfig(temp);
_conf->set_paragraph("Transaction"); //setto il paragrafo [Transaction] del file ini
_conf->set("Action","INSERT");
_conf->set("Mode","AUTO");
_conf->set_paragraph("23"); //setto il paragrafo [23] del file ini (testata)
_conf->set(MOV_TIPO,"F"); // come
_conf->set(MOV_CODCF, _msk->get(F_CODCF));
_conf->set(MOV_CODCAUS, s.get(CAUSCM).as_string());
_conf->set(MOV_DATAREG, s.get(DTRGCM).as_string());
_conf->set(MOV_CODPAG, s.get(CDPGCM).as_string());
_conf->set(MOV_DATADOC, s.get(DTDOCM).as_string());
_conf->set(MOV_NUMDOC, s.get(NRDOCM).as_string());
nrigac = 0;
nrigai = 0;
}
const TString conto = s.get(CONTCM).as_string();
if (conto.full())
{
TString8 paragraph;
paragraph.format("%d,%d",LF_RMOV,nrigac++);
_conf->set_paragraph(paragraph);
real importo = s.get(IMPOCM).as_real();
char sez = 'D';
if (importo < ZERO)
{
importo = -importo;
sez = 'A';
}
_conf->set(RMV_SEZIONE, sez);
_conf->set(RMV_IMPORTO, importo.string());
}
else
{
TString8 paragraph;
real importo = s.get(IMPOCM).as_real();
char sez = 'D';
paragraph.format("%d,%d",LF_RMOVIVA,nrigai++);
_conf->set_paragraph(paragraph);
if (importo < ZERO)
{
importo = -importo;
sez = 'A';
}
_conf->set(RMI_IMPONIBILE, importo.string());
// INDECM 29 come si fa ?
_conf->set(RMI_CODIVA, s.get(CDIVCM).as_string());
real imposta = s.get(IMPSCM).as_real();
paragraph.format("%d,%d",LF_RMOVIVA,nrigai++);
_conf->set_paragraph(paragraph);
if (imposta < ZERO) // giusto ?
imposta = -imposta;
_conf->set(RMI_IMPOSTA, imposta.string());
}
}
delete _conf;
TString app;
app << "cg2 -0 -i" << tempdir << "/*.trn";
TExternal_app primanota(app);
primanota.run();
message_box(TR("Importazione movimenti completata"));
return true;
}
bool TImporta_mov::create()
{
_msk = new TImporta_mov_mask();
return TSkeleton_application::create();
}
bool TImporta_mov::destroy()
{
delete _msk;
return TApplication::destroy();
}
void TImporta_mov::main_loop()
{
KEY tasto;
tasto = _msk->run();
if (tasto == K_ENTER)
{
//genero il nome del file da caricare
TFilename name = _msk->get(F_PATH);
name.add(_msk->get(F_NAME));
transfer(name);
}
}
TImporta_mov& app() { return (TImporta_mov&) main_app(); }
int pe0001100 (int argc, char* argv[])
{
TImporta_mov main_app;
main_app.run(argc, argv, TR("Importazione movimenti di contab."));
return true;
}