Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@19875 c028cbd2-c16b-5b4b-a496-9718f37d4682
261 lines
6.5 KiB
C++
Executable File
261 lines
6.5 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <automask.h>
|
|
#include <clifo.h>
|
|
#include <execp.h>
|
|
#include <lffiles.h>
|
|
#include <progind.h>
|
|
#include <real.h>
|
|
#include <recarray.h>
|
|
#include <reputils.h>
|
|
#include <utility.h>
|
|
#include <relation.h>
|
|
#include <reprint.h>
|
|
#include <textset.h>
|
|
#include <tabutil.h>
|
|
|
|
#include "../cg/cglib01.h"
|
|
#include "../cg/cg2103.h"
|
|
#include "../cg/cgsaldac.h"
|
|
#include "../cg/cgpagame.h"
|
|
|
|
#include "lv4.h"
|
|
#include "lv4100.h"
|
|
#include "lv4200a.h"
|
|
|
|
#include <pconti.h>
|
|
#include <mov.h>
|
|
#include <rmov.h>
|
|
#include <rmoviva.h>
|
|
|
|
#define CGC_TIPO 0
|
|
#define CGC_ANNO 1
|
|
#define CGC_NUMEROPARTITA 2
|
|
#define CGC_CODCF 3
|
|
#define CGC_NUMERO REC. 4
|
|
#define CGC_CAMBIO 5
|
|
#define CGC_VALUTA 6
|
|
#define CGC_TIPODOC 7
|
|
#define CGC_DATA_DOCUM 8
|
|
#define CGC_SCADENZA 9
|
|
#define CGC_IMPORTO 10
|
|
#define CGC_IMPORTO_VAL 11
|
|
|
|
class TCausali_cache : public TCache
|
|
{
|
|
protected:
|
|
virtual TObject* key2obj(const char* key);
|
|
|
|
public:
|
|
const TCausale& causale(const char* codice, int annoiva);
|
|
};
|
|
|
|
TObject* TCausali_cache::key2obj(const char* key)
|
|
{
|
|
// Metodo bastardo per evitare TToken_string temporanee "a randa"
|
|
// sfrutto chiave a lunghezza fissa
|
|
const int anno = atoi(key);
|
|
const char* codice = key+5;
|
|
TCausale* pcaus = new TCausale(codice, anno);
|
|
return pcaus;
|
|
}
|
|
|
|
const TCausale& TCausali_cache::causale(const char* codice, int annoiva)
|
|
{
|
|
// Metodo bastardo per evitare TToken_string temporanee "a randa"
|
|
// creo chiave a lunghezza fissa anno+codice = 9999|AAA
|
|
TString8 key;
|
|
key.format("%04d|%s", annoiva, codice);
|
|
return *(const TCausale*)objptr(key);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TAutomask
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TImporta_sc_mask : public TAutomask
|
|
{
|
|
protected:
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
public:
|
|
TImporta_sc_mask();
|
|
};
|
|
|
|
TImporta_sc_mask::TImporta_sc_mask() :TAutomask ("lv4200a")
|
|
{
|
|
}
|
|
|
|
bool TImporta_sc_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_sc : public TSkeleton_application
|
|
{
|
|
TImporta_sc_mask* _msk;
|
|
|
|
public:
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
virtual void main_loop();
|
|
void transfer(const TFilename& file);
|
|
|
|
};
|
|
|
|
void TImporta_sc::transfer(const TFilename& file)
|
|
{
|
|
TImporta_cogeco_recset s(file);
|
|
TProgind pi(s.items(),"Importazione saldaconto in corso ...",true,true);
|
|
TConfig* conf = NULL;
|
|
int anno = 0;
|
|
int part = 0;
|
|
char tipocf = ' ';
|
|
long sottoconto = 0L;
|
|
TPartita* game = NULL;
|
|
TCausali_cache cache_causali;
|
|
TToken_string key;
|
|
const TString4 codcausc(_msk->get(F_CODCAUSC));
|
|
const TString4 codcausf(_msk->get(F_CODCAUSF));
|
|
TImporto totdoc;
|
|
for (bool ok=s.move_to(1);ok;ok=s.move_next())
|
|
{
|
|
if (!pi.addstatus(1))
|
|
break;
|
|
const int a = s.get(CGC_ANNO).as_int();
|
|
const long p = s.get(CGC_NUMEROPARTITA).as_int();
|
|
const char t = s.get(CGC_CODCF).as_string()[0];
|
|
const long s = s.get(CGC_CODCF).as_int();
|
|
// leggo tutte le righe di partita e le metto in un array
|
|
if (anno != a || p != part || tipo != t || sottoconto != s)
|
|
{
|
|
anno = a;
|
|
part = p;
|
|
tipocf = t;
|
|
sottoconto = s;
|
|
|
|
if (game != NULL)
|
|
{
|
|
for (int r = game->first(); r >= 0; r = game->succ(r))
|
|
game->riga(r).put(PART_IMPTOTDOC, totdoc.valore());
|
|
game->write();
|
|
delete game;
|
|
game = NULL;
|
|
}
|
|
totdoc.reset();
|
|
}
|
|
TToken_string key;
|
|
key.cut(0);
|
|
key.add(tipocf);
|
|
key.add(sottoconto);
|
|
const TRectype & clifo = cache().get(LF_CLIFO, key);
|
|
int gruppo = clifo.get_int(CLI_GRUPPO);
|
|
int conto = clifo.get_int(CLI_CONTO);
|
|
const TCausale& c = cache_causali.causale(tipocf == 'C' ? codcausc : codcausf, anno);
|
|
if (gruppo == 0)
|
|
{
|
|
TBill cc;
|
|
c.bill(1, cc);
|
|
gruppo = cc.gruppo();
|
|
conto = cc.conto();
|
|
}
|
|
TBill codclifo(gruppo, conto, sottoconto);
|
|
const int tipodoc = s.get(CGC_TIPODOC).as_int();
|
|
const TDate datadoc = s.get(CGC_DATA_DOCUM).as_date();
|
|
if (game == NULL)
|
|
game = new TPartita(codclifo, anno, format("%7d", part));
|
|
TRiga_partite& partita = game->new_row();
|
|
partita.put(PART_TIPOMOV, c.tipomov());
|
|
partita.put(PART_DATAREG, datadoc);
|
|
partita.put(PART_DATADOC, datadoc);
|
|
partita.put(PART_CODCAUS, c.codice());
|
|
partita.put(PART_REG, c.reg().name());
|
|
partita.put(PART_SEZ, c.sezione(1));
|
|
partita.put(PART_SOTTOCONTO, codclifo.sottoconto());
|
|
const TString8 codpag(clifo.get(CLIFO_CODPAG)); // ?? verificare
|
|
TPagamento pag(codpag);
|
|
//partita.put(PART_CODPAG, codpag);
|
|
partita.put(PART_TIPOPAG, pag.tipo_rata(0));
|
|
partita.put(PART_GRUPPOCL, codclifo.gruppo());
|
|
partita.put(PART_CONTOCL, codclifo.conto());
|
|
|
|
const real val = s.get(CGC_IMPORTO).as_real();
|
|
TImporto importo(val.sign() < 0 ? 'A' : 'D', abs(val));
|
|
importo.normalize(c.sezione(1));
|
|
totdoc += importo; // somma se e' fattura ??? verificare
|
|
partita.put(PART_IMPORTO, importo.valore());
|
|
|
|
TRiga_scadenze& scadenza = partita.new_row(); // ?? da fare
|
|
scadenza.put(SCAD_CODPAG, codpag);
|
|
scadenza.put(SCAD_DATASCAD, s.get(CGC_SCADENZA).as_string());
|
|
scadenza.put(SCAD_IMPORTO, importo.valore());
|
|
scadenza.put(SCAD_TIPOPAG, partita.get(PART_TIPOPAG));
|
|
}
|
|
if (game != NULL)
|
|
{
|
|
for (int r = game->first(); r >= 0; r = game->succ(r))
|
|
game->riga(r).put(PART_IMPTOTDOC, totdoc.valore());
|
|
game->write();
|
|
delete game;
|
|
}
|
|
}
|
|
|
|
bool TImporta_sc::create()
|
|
{
|
|
_msk = new TImporta_sc_mask();
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
bool TImporta_sc::destroy()
|
|
{
|
|
delete _msk;
|
|
return TApplication::destroy();
|
|
}
|
|
|
|
void TImporta_sc::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);
|
|
}
|
|
}
|
|
|
|
int lv4200 (int argc, char* argv[])
|
|
{
|
|
TImporta_sc main_app;
|
|
main_app.run(argc, argv, TR("Importazione saldaconto COGECO"));
|
|
return true;
|
|
} |