Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :


git-svn-id: svn://10.65.10.50/trunk@19875 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
cris 2010-01-05 14:32:48 +00:00
parent fa3bf76463
commit 6c6dee8c47
6 changed files with 215 additions and 199 deletions

View File

@ -1,7 +1,6 @@
#include <applicat.h>
#include <automask.h>
#include <execp.h>
#include <lffiles.h>
#include <progind.h>
#include <real.h>
#include <recarray.h>
@ -9,8 +8,7 @@
#include <utility.h>
#include <relation.h>
#include <reprint.h>
#include <textset.h>
#include <tabutil.h>
//#include <tabutil.h>
#include "../cg/cglib01.h"
@ -23,39 +21,40 @@
#include <rmov.h>
#include <rmoviva.h>
#define DITTA_PK 0
#define TIPO 1
#define GRUPPO 2
#define CONTO 3
#define SOTTOCONTO 4
#define ANNO 5
#define VALUTA 6
#define CREAZIONE 7
#define PROGR_DARE 8
#define PROGR_AVERE 9
#define SALDO_APERTURA 10
#define SALDO_CHIUSURA 11
#define ULT_PAG_PART 12
#define DARE_PARTITARIO 13
#define AVERE_PARTITARIO 14
#define DATAAGG_PARTITARIO 15
#define CGC_DITTA_PK 0
#define CGC_TIPO 1
#define CGC_GRUPPO 2
#define CGC_CONTO 3
#define CGC_SOTTOCONTO 4
#define CGC_ANNO 5
#define CGC_VALUTA 6
#define CGC_CREAZIONE 7
#define CGC_PROGR_DARE 8
#define CGC_PROGR_AVERE 9
#define CGC_SALDO_APERTURA 10
#define CGC_SALDO_CHIUSURA 11
#define CGC_ULT_PAG_PART 12
#define CGC_DARE_PARTITARIO 13
#define CGC_AVERE_PARTITARIO 14
#define CGC_DATAAGG_PARTITARIO 15
/*const TVariant& TImporta_saldi_recset::get(unsigned int column) const
real TImporta_cogeco_recset::get_real(int idx) const
{
TString str = TCSV_recordset::get(column).as_string();
TVariant& var = get_tmp_var();
int len = str.len();
TString80 imp = get(idx).as_string();
imp.strip(".");
imp.replace(',', '.');
return real(imp);
}
bool TImporta_cogeco_recset::get_bill(TBill& bill) const
{
const int g = get(CGC_GRUPPO).as_int();
const int c = get(CGC_CONTO).as_int();
const long s = get(CGC_SOTTOCONTO).as_int();
bill.set(g, c, s);
return bill.ok();
}
if (len == 0)
return NULL_VARIANT;
if (str[len -1] == '"')
str.rtrim(1);
if (str[0] == '"')
str.ltrim(1);
var.set(str);
return var;
} */
///////////////////////////////////////////////////////////
// TAutomask
@ -105,31 +104,60 @@ bool TImporta_saldi_mask::on_field_event(TOperable_field& f, TField_event e, lon
return true;
}
///////////////////////////////////////
// TSkeleton_application
///////////////////////////////////////
class TImporta_saldi : public TSkeleton_application
{
virtual bool check_autorization() const {return false;}
virtual const char * extra_modules() const {return "ba";}
TImporta_saldi_mask* _msk;
//protected:
protected:
void set_rmov(TConfig& conf, const int nrow, const TImporto& imp,
const TBill& bill) const;
void delete_ini(const TFilename& outdir) const;
public:
virtual bool create();
virtual bool destroy();
virtual void main_loop();
void transfer(const TFilename& file);
TImporta_saldi() {};
};
void TImporta_saldi::set_rmov(TConfig& conf, const int nrow, const TImporto& imp,
const TBill& bill) const
{
TString8 paragraph;
paragraph.format("%d,%d", LF_RMOV, nrow);
conf.set_paragraph(paragraph);
const char strsez[2] = {imp.sezione(), '\0'};
conf.set(RMV_SEZIONE, strsez);
conf.set(RMV_IMPORTO, imp.valore().string());
conf.set(RMV_GRUPPO, bill.gruppo());
conf.set(RMV_CONTO, bill.conto());
conf.set(RMV_SOTTOCONTO, bill.sottoconto());
}
void TImporta_saldi::delete_ini(const TFilename& outdir) const
{
if (outdir.exist())
{
for (int ntran=1;;ntran++)
{
TFilename temp(outdir);
temp.add(format("lv41%05ld.ini", ntran++));
if (!temp.fremove())
break;
}
}
else
make_dir(outdir);
}
void TImporta_saldi::transfer(const TFilename& file)
{
TFilename outdir(_msk->get(F_PATHOUT));
const TFilename outdir(_msk->get(F_PATHOUT));
TImporta_cogeco_recset s(file);
TProgind pi(s.items(),"Importazione saldi in corso ...",true,true);
TConfig * conf = NULL;
@ -142,57 +170,49 @@ void TImporta_saldi::transfer(const TFilename& file)
TConfig cditta(CONFIG_DITTA, "cg");
const TString4 ctypes("GCF");
const TString8 causale = cditta.get("CoCaAp");
const int gruppoap = cditta.get_int("CsBiApG");
const int contoap = cditta.get_int("CsBiApC");
const long sottocontoap = cditta.get_long("CsBiApS");
const TBill conto_ap(cditta.get_int("CsBiApG"),
cditta.get_int("CsBiApC"),
cditta.get_long("CsBiApS"));
int lastgruppo = 0;
const int codes = _msk->get_int(F_ANNOES);
const long ditta = _msk->get_long(F_CODITTA);
const TEsercizi_contabili esc;
TString8 paragraph;
for (bool ok=s.move_first();ok;ok=s.move_next())
delete_ini(outdir);
for (bool ok=s.move_to(1);ok;ok=s.move_next())
{
if (!pi.addstatus(1))
break;
const long dt = s.get(DITTA_PK).as_int();
const long dt = s.get(CGC_DITTA_PK).as_int();
if (ditta != dt)
continue;
const int es = s.get(ANNO).as_int();
const int es = s.get(CGC_ANNO).as_int();
if (codes != es)
continue;
if (ctypes.find(s.get(TIPO).as_string()[0]) < 0)
if (ctypes.find(s.get(CGC_TIPO).as_string()[0]) < 0)
continue;
int gruppo = s.get(GRUPPO).as_int();
int conto = s.get(CONTO).as_int();
long sottoconto = s.get(SOTTOCONTO).as_int();
if (lastgruppo != gruppo && nrow >= 99)
TBill bill;
if (!s.get_bill(bill))
continue;
if (lastgruppo != bill.gruppo() || nrow >= 99)
{
if (conf != NULL)
{
paragraph.format("%d,%d",LF_RMOV,nrow++);
conf->set_paragraph(paragraph);
conf->set(RMV_SEZIONE, totmov.sezione());
conf->set(RMV_IMPORTO, totmov.valore().string());
conf->set(RMV_GRUPPO, gruppoap);
conf->set(RMV_CONTO, contoap);
conf->set(RMV_SOTTOCONTO, sottocontoap);
set_rmov(*conf, nrow++, totmov, conto_ap);
delete conf;
}
conf = NULL;
TFilename temp(outdir);
}
TFilename temp(outdir);
temp.add(format("lv41%05ld.ini", ntran++));
temp << '/' << format("%05ld", ntran++);
temp.ext("ini");
if (fexist(temp))
remove_file(temp);
conf = new TConfig(temp);
conf->set_paragraph("Transaction"); //setto il paragrafo [Transaction] del file ini
conf->set("Action","INSERT");
@ -201,55 +221,41 @@ void TImporta_saldi::transfer(const TFilename& file)
conf->set_paragraph("23"); //setto il paragrafo [23] del file ini (testata)
conf->set(MOV_CODCAUS, causale);
conf->set(MOV_DATAREG, dataop.stringa());
conf->set(MOV_DESCR, "Ripresa Saldi");
conf->set(MOV_DESCR, TR("Ripresa Saldi"));
nrow = 1;
lastgruppo = gruppo;
lastgruppo = bill.gruppo();
}
real val = s.get(SALDO_APERTURA).as_real();
const real val = s.get_real(CGC_SALDO_APERTURA);
TImporto impmov(val > ZERO ? 'D' : 'A', abs(val));
const TImporto pdare('D', s.get(PROGR_DARE).as_real());
const TImporto pavere('A', s.get(PROGR_AVERE).as_real());
const TImporto pdare('D', s.get_real(CGC_PROGR_DARE));
const TImporto pavere('A', s.get_real(CGC_PROGR_AVERE));
impmov += pdare;
impmov += pavere;
if (impmov.valore() != ZERO)
if (!impmov.is_zero())
{
paragraph.format("%d,%d",LF_RMOV,nrow++);
conf->set_paragraph(paragraph);
conf->set(RMV_SEZIONE, impmov.sezione());
conf->set(RMV_IMPORTO, impmov.valore().string());
conf->set(RMV_GRUPPO, gruppo);
conf->set(RMV_CONTO, conto);
conf->set(RMV_SOTTOCONTO, sottoconto);
set_rmov(*conf, nrow++, impmov, bill);
totmov -= impmov;
}
}
if (conf != NULL)
{
paragraph.format("%d,%d",LF_RMOV,nrow++);
conf->set_paragraph(paragraph);
conf->set(RMV_SEZIONE, totmov.sezione());
conf->set(RMV_IMPORTO, totmov.valore().string());
conf->set(RMV_GRUPPO, gruppoap);
conf->set(RMV_CONTO, contoap);
conf->set(RMV_SOTTOCONTO, sottocontoap);
set_rmov(*conf, nrow++, totmov, conto_ap);
delete conf;
}
if (yesno_box(FR("Si desidera confermare l'importazione di %ld movimenti"), ntran -1))
{
TString app;
app << "cg2 -0 -i" << outdir << "/*.ini";
TFilename app = outdir;
app.add("lv41*.ini");
app.insert("cg2 -0 -i");
TExternal_app primanota(app);
primanota.run(true);
}
}
bool TImporta_saldi::create()
{
_msk = new TImporta_saldi_mask();
@ -277,12 +283,10 @@ void TImporta_saldi::main_loop()
}
TImporta_saldi& app() { return (TImporta_saldi&) main_app(); }
int lv4100 (int argc, char* argv[])
{
TImporta_saldi main_app;
main_app.run(argc, argv, TR("Importazione contabilità Galileo"));
main_app.run(argc, argv, TR("Importazione contabilità COGECO"));
return true;
}

View File

@ -1,8 +1,18 @@
#ifndef __LV4100_H__
#define __LV4100_H__
#ifndef __TEXTSET_H__
#include <textset.h>
#endif
class TImporta_cogeco_recset : public TCSV_recordset
{
protected:
public:
real get_real(int idx) const;
bool get_bill(TBill& bill) const;
TImporta_cogeco_recset(const char* query = "") : TCSV_recordset(TString("CSV(\";)\n") << query) {}
virtual ~TImporta_cogeco_recset() {}
};
#endif

View File

@ -1,19 +1,7 @@
#include "lv4100a.h"
TOOLBAR "" 0 0 0 2
BUTTON DLG_ELABORA 10 2
BEGIN
PICTURE BMP_ELABORA
MESSAGE EXIT,K_ENTER
PROMPT -12 -1 "E~labora"
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -22 -1 ""
END
#include "elabar.h"
ENDPAGE
TOOLBAR "" 0 21 0 2
@ -26,7 +14,7 @@ END
ENDPAGE
PAGE "Importazione contabilità Galileo" 0 0 0 -3
PAGE "Importazione contabilità COGECO" 0 0 0 -3
GROUPBOX DLG_NULL 90 3
BEGIN
@ -49,7 +37,7 @@ BEGIN
FLAGS "D"
END
GROUPBOX DLG_NULL 90 5
GROUPBOX DLG_NULL 90 6
BEGIN
PROMPT 2 4 "@bSorgente"
END
@ -84,7 +72,7 @@ END
DATE F_DATAMOV
BEGIN
PROMPT 3 7 "Data mov. "
PROMPT 3 8 "Data mov. "
FIELD DataMov
CHECKTYPE REQUIRED
END

View File

@ -27,18 +27,18 @@
#include <rmov.h>
#include <rmoviva.h>
#define TIPO 0
#define ANNO 1
#define NUMEROPARTITA 2
#define CODCF 3
#define NUMERO REC. 4
#define CAMBIO 5
#define VALUTA 6
#define TIPODOC 7
#define DATA_DOCUM 8
#define SCADENZA 9
#define IMPORTO 10
#define IMPORTO_VAL 11
#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
{
@ -116,56 +116,51 @@ bool TImporta_sc_mask::on_field_event(TOperable_field& f, TField_event e, long j
return true;
}
///////////////////////////////////////
// TSkeleton_application
///////////////////////////////////////
class TImporta_sc : public TSkeleton_application
{
virtual bool check_autorization() const {return false;}
virtual const char * extra_modules() const {return "ba";}
TImporta_sc_mask* _msk;
//protected:
public:
virtual bool create();
virtual bool destroy();
virtual void main_loop();
void transfer(const TFilename& file);
TImporta_sc() {};
};
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;
TConfig* conf = NULL;
int anno = 0;
int part;
TPartita * game;
int part = 0;
char tipocf = ' ';
long sottoconto = 0L;
TPartita* game = NULL;
TCausali_cache cache_causali;
TToken_string key;
const TString8 codcausc(_msk->get(F_CODCAUSC));
const TString8 codcausf(_msk->get(F_CODCAUSF));
const TString4 codcausc(_msk->get(F_CODCAUSC));
const TString4 codcausf(_msk->get(F_CODCAUSF));
TImporto totdoc;
for (bool ok=s.move_first();ok;ok=s.move_next())
for (bool ok=s.move_to(1);ok;ok=s.move_next())
{
if (!pi.addstatus(1))
break;
const int a = s.get(ANNO).as_int();
const long p = s.get(NUMEROPARTITA).as_int();
if (anno != a || p != part )
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)
{
@ -173,69 +168,54 @@ void TImporta_sc::transfer(const TFilename& file)
game->riga(r).put(PART_IMPTOTDOC, totdoc.valore());
game->write();
delete game;
}
game = NULL;
}
totdoc.reset();
}
const char tipocf = s.get(CODCF).as_string()[0]; // ?? verificare
const long sottoconto = s.get(CODCF).as_int();
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);
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(TIPODOC).as_int();
const TDate datadoc = s.get(DATA_DOCUM).as_date();
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(MOV_CODPAG)); // ?? verificare
const TString8 codpag(clifo.get(CLIFO_CODPAG)); // ?? verificare
TPagamento pag(codpag);
partita.put(PART_CODPAG, 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(IMPORTO).as_real();
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(SCADENZA).as_string());
scadenza.put(SCAD_DATASCAD, s.get(CGC_SCADENZA).as_string());
scadenza.put(SCAD_IMPORTO, importo.valore());
scadenza.put(SCAD_TIPOPAG, partita.get(PART_TIPOPAG));
}
@ -246,14 +226,11 @@ void TImporta_sc::transfer(const TFilename& file)
game->write();
delete game;
}
}
bool TImporta_sc::create()
{
_msk = new TImporta_sc_mask();
return TSkeleton_application::create();
}
@ -276,13 +253,9 @@ void TImporta_sc::main_loop()
}
}
TImporta_sc& app() { return (TImporta_sc&) main_app(); }
int lv4200 (int argc, char* argv[])
{
TImporta_sc main_app;
main_app.run(argc, argv, TR("Importazione saldaconto"));
main_app.run(argc, argv, TR("Importazione saldaconto COGECO"));
return true;
}

View File

@ -6,3 +6,5 @@
#define F_NAME 104
#define F_CODCAUSC 105
#define F_CODCAUSF 106
#define F_DESCRCAUSC 107
#define F_DESCRCAUSF 108

View File

@ -1,19 +1,7 @@
#include "lv4200a.h"
TOOLBAR "" 0 0 0 2
BUTTON DLG_ELABORA 10 2
BEGIN
PICTURE BMP_ELABORA
MESSAGE EXIT,K_ENTER
PROMPT -12 -1 "E~labora"
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -22 -1 ""
END
#include "elabar.h"
ENDPAGE
TOOLBAR "" 0 21 0 2
@ -26,7 +14,7 @@ END
ENDPAGE
PAGE "Importazione saldaconto" 0 0 0 -3
PAGE "Importazione saldaconto COGECO" 0 0 0 -3
GROUPBOX DLG_NULL 90 3
BEGIN
@ -69,6 +57,57 @@ BEGIN
CHECKTYPE REQUIRED
END
GROUPBOX DLG_NULL 90 6
BEGIN
PROMPT 2 8 "Causali"
END
STRING F_CODCAUSC 3
BEGIN
PROMPT 3 9 "Clienti "
FLAGS "UZ"
USE LF_CAUSALI
INPUT CODCAUS F_CODCAUSC
DISPLAY "Codice" CODCAUS
DISPLAY "Descrizione@60" DESCR
OUTPUT F_CODCAUSC CODCAUS
OUTPUT F_DESCRCAUSC DESCR
CHECKTYPE REEQUIRED
END
STRING F_DESCRCAUSC 50
BEGIN
PROMPT 20 9 ""
USE LF_CAUSALI KEY 2
INPUT DESCR F_DESCRCAUSC
DISPLAY "Descrizione@60" DESCR
DISPLAY "Codice" CODCAUS
COPY OUTPUT F_CODCAUSC
CHECKTYPE REQUIRED
END
STRING F_CODCAUSF 3
BEGIN
PROMPT 3 10 "Fornitori "
FLAGS "UZ"
COPY USE F_CODCAUSC
INPUT CODCAUS F_CODCAUSF
COPY DISPLAY F_CODCAUSC
OUTPUT F_CODCAUSF CODCAUS
OUTPUT F_DESCRCAUSF DESCR
CHECKTYPE REQUIRED
END
STRING F_DESCRCAUSF 50
BEGIN
PROMPT 20 10 ""
COPY USE F_DESCRCAUSC
INPUT DESCR F_DESCRCAUSF
COPY DISPLAY F_DESCRCAUSC
COPY OUTPUT F_CODCAUSF
CHECKTYPE REQUIRED
END
ENDPAGE
ENDMASK