diff --git a/lv/lv4.cpp b/lv/lv4.cpp new file mode 100755 index 000000000..f4019a173 --- /dev/null +++ b/lv/lv4.cpp @@ -0,0 +1,20 @@ +#include + +#include "lv4.h" + +int main(int argc, char** argv) +{ + int n = argc > 1 ? atoi(argv[1]+1) : 0; + switch(n) + { + case 1: + lv4200(argc, argv); break; //importazione saldaconto + case 2: + lv4300(argc, argv); break; //importazione cespiti + case 0: + default: + lv4100(argc, argv); break; //importazione movimenti contabili + } + exit(0); + return 0; +} diff --git a/lv/lv4.h b/lv/lv4.h new file mode 100755 index 000000000..b594c19ae --- /dev/null +++ b/lv/lv4.h @@ -0,0 +1,3 @@ +int lv4100(int argc, char* argv[]); // importazione movimenti contabili +int lv4200(int argc, char* argv[]); // importazione saldaconto +int lv4300(int argc, char* argv[]); // importazione cespiti \ No newline at end of file diff --git a/lv/lv4100.cpp b/lv/lv4100.cpp new file mode 100755 index 000000000..d4222ef8c --- /dev/null +++ b/lv/lv4100.cpp @@ -0,0 +1,288 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../cg/cglib01.h" + +#include "lv4.h" +#include "lv4100.h" +#include "lv4100a.h" + +#include +#include +#include +#include + + #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 + + +/*const TVariant& TImporta_saldi_recset::get(unsigned int column) const +{ + TString str = TCSV_recordset::get(column).as_string(); + TVariant& var = get_tmp_var(); + int len = str.len(); + + 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 +/////////////////////////////////////////////////////////// + +class TImporta_saldi_mask : public TAutomask +{ +protected: + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + +public: + TImporta_saldi_mask(); +}; + +TImporta_saldi_mask::TImporta_saldi_mask() :TAutomask ("lv4100a") +{ +} + +bool TImporta_saldi_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_saldi : public TSkeleton_application +{ + virtual bool check_autorization() const {return false;} + virtual const char * extra_modules() const {return "ba";} + + TImporta_saldi_mask* _msk; + +//protected: + +public: + virtual bool create(); + virtual bool destroy(); + virtual void main_loop(); + void transfer(const TFilename& file); + + TImporta_saldi() {}; +}; + +void TImporta_saldi::transfer(const TFilename& file) +{ + TFilename outdir(_msk->get(F_PATHOUT)); + TImporta_cogeco_recset s(file); + TProgind pi(s.items(),"Importazione saldi in corso ...",true,true); + TConfig * conf = NULL; + long ntran = 1L; + int nrow = 1; + int anno = 0; + TString8 reg; + TDate dataop = _msk->get_date(F_DATAMOV); + TImporto totmov; + 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"); + + 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()) + { + if (!pi.addstatus(1)) + break; + + const long dt = s.get(DITTA_PK).as_int(); + + if (ditta != dt) + continue; + + const int es = s.get(ANNO).as_int(); + + if (codes != es) + continue; + + if (ctypes.find(s.get(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) + { + 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); + delete conf; + } + conf = NULL; + TFilename temp(outdir); + + 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"); + conf->set("Mode","AUTO"); + + 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"); + nrow = 1; + lastgruppo = gruppo; + } + + real val = s.get(SALDO_APERTURA).as_real(); + + 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()); + + impmov += pdare; + impmov += pavere; + + if (impmov.valore() != 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); + 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); + delete conf; + } + + if (yesno_box(FR("Si desidera confermare l'importazione di %ld movimenti"), ntran -1)) + { + TString app; + + app << "cg2 -0 -i" << outdir << "/*.ini"; + TExternal_app primanota(app); + primanota.run(true); + } +} + + +bool TImporta_saldi::create() +{ + _msk = new TImporta_saldi_mask(); + + return TSkeleton_application::create(); +} + +bool TImporta_saldi::destroy() +{ + delete _msk; + return TApplication::destroy(); +} + +void TImporta_saldi::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_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")); + return true; +} \ No newline at end of file diff --git a/lv/lv4100.h b/lv/lv4100.h new file mode 100755 index 000000000..bae32ba87 --- /dev/null +++ b/lv/lv4100.h @@ -0,0 +1,8 @@ + +class TImporta_cogeco_recset : public TCSV_recordset +{ + +public: + TImporta_cogeco_recset(const char* query = "") : TCSV_recordset(TString("CSV(\";)\n") << query) {} + virtual ~TImporta_cogeco_recset() {} +}; diff --git a/lv/lv4100a.h b/lv/lv4100a.h new file mode 100755 index 000000000..5ab227766 --- /dev/null +++ b/lv/lv4100a.h @@ -0,0 +1,9 @@ +//campi maschera lv4100a + +#define F_CODITTA 101 +#define F_RAGSOC 102 +#define F_PATH 103 +#define F_NAME 104 +#define F_ANNOES 105 +#define F_DATAMOV 106 +#define F_PATHOUT 107 diff --git a/lv/lv4100a.uml b/lv/lv4100a.uml new file mode 100755 index 000000000..8616db222 --- /dev/null +++ b/lv/lv4100a.uml @@ -0,0 +1,108 @@ +#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 + +ENDPAGE + +TOOLBAR "" 0 21 0 2 + +STRING DLG_PROFILE 50 +BEGIN + PROMPT 9 -1 "Profilo " + PSELECT +END + +ENDPAGE + +PAGE "Importazione contabilità Galileo" 0 0 0 -3 + +GROUPBOX DLG_NULL 90 3 +BEGIN + PROMPT 2 1 "@bDitta corrente" +END + +NUMBER F_CODITTA 5 +BEGIN + PROMPT 3 2 "Codice " + FLAGS "FD" + USE LF_NDITTE + INPUT CODDITTA F_CODITTA + OUTPUT F_RAGSOC RAGSOC + CHECKTYPE REQUIRED +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 23 2 "" + FLAGS "D" +END + +GROUPBOX DLG_NULL 90 5 +BEGIN + PROMPT 2 4 "@bSorgente" +END + +STRING F_PATH 256 39 +BEGIN + PROMPT 3 5 "Cartella " + DSELECT + CHECKTYPE REQUIRED + FIELD ComInPath +END + +STRING F_NAME 18 +BEGIN + PROMPT 3 6 "File " + FIELD ComInFile + CHECKTYPE REQUIRED +END + +NUMBER F_ANNOES 4 +BEGIN + PROMPT 3 7 "Esercizio " + USE ESC + INPUT CODTAB F_ANNOES + DISPLAY "Codice Esercizio" CODTAB + DISPLAY "Data inizio esercizio" D0 + DISPLAY "Data fine esercizio " D1 + OUTPUT F_ANNOES CODTAB + FIELD AnnoEs + CHECKTYPE REQUIRED +END + +DATE F_DATAMOV +BEGIN + PROMPT 3 7 "Data mov. " + FIELD DataMov + CHECKTYPE REQUIRED +END + + +GROUPBOX DLG_NULL 90 4 +BEGIN + PROMPT 2 10 "@bDestinazione" +END + +STRING F_PATHOUT 256 39 +BEGIN + PROMPT 3 11 "Cartella " + DSELECT + CHECKTYPE REQUIRED + FIELD ComOutPath +END + +ENDPAGE + +ENDMASK \ No newline at end of file diff --git a/lv/lv4200.cpp b/lv/lv4200.cpp new file mode 100755 index 000000000..2b44de3a5 --- /dev/null +++ b/lv/lv4200.cpp @@ -0,0 +1,288 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 +#include +#include +#include + +#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 + +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 +{ + 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; + int anno = 0; + int part; + TPartita * game; + TCausali_cache cache_causali; + TToken_string key; + const TString8 codcausc(_msk->get(F_CODCAUSC)); + const TString8 codcausf(_msk->get(F_CODCAUSF)); + TImporto totdoc; + + + for (bool ok=s.move_first();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 ) + { + anno = a; + part = p; + + 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(); + } + + 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); + + 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(); + + 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 + 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(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_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); + } +} + + +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")); + return true; +} \ No newline at end of file diff --git a/lv/lv4200a.h b/lv/lv4200a.h new file mode 100755 index 000000000..2e149be83 --- /dev/null +++ b/lv/lv4200a.h @@ -0,0 +1,8 @@ +//campi maschera lv4200a + +#define F_CODITTA 101 +#define F_RAGSOC 102 +#define F_PATH 103 +#define F_NAME 104 +#define F_CODCAUSC 105 +#define F_CODCAUSF 106 \ No newline at end of file diff --git a/lv/lv4200a.uml b/lv/lv4200a.uml new file mode 100755 index 000000000..92a923309 --- /dev/null +++ b/lv/lv4200a.uml @@ -0,0 +1,74 @@ +#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 + +ENDPAGE + +TOOLBAR "" 0 21 0 2 + +STRING DLG_PROFILE 50 +BEGIN + PROMPT 9 -1 "Profilo " + PSELECT +END + +ENDPAGE + +PAGE "Importazione saldaconto" 0 0 0 -3 + +GROUPBOX DLG_NULL 90 3 +BEGIN + PROMPT 2 1 "@bDitta corrente" +END + +NUMBER F_CODITTA 5 +BEGIN + PROMPT 3 2 "Codice " + FLAGS "FD" + USE LF_NDITTE + INPUT CODDITTA F_CODITTA + OUTPUT F_RAGSOC RAGSOC + CHECKTYPE REQUIRED +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 23 2 "" + FLAGS "D" +END + +GROUPBOX DLG_NULL 90 4 +BEGIN + PROMPT 2 4 "@bSorgente" +END + +STRING F_PATH 256 39 +BEGIN + PROMPT 3 5 "Cartella " + DSELECT + CHECKTYPE REQUIRED + FIELD ComInPath +END + +STRING F_NAME 18 +BEGIN + PROMPT 3 6 "File " + FIELD ComInFile + CHECKTYPE REQUIRED +END + +ENDPAGE + +ENDMASK \ No newline at end of file diff --git a/lv/lv4300.cpp b/lv/lv4300.cpp new file mode 100755 index 000000000..cd75ca4ea --- /dev/null +++ b/lv/lv4300.cpp @@ -0,0 +1,387 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../ce/ammce.h" +#include "../ce/cespi.h" +#include "../ce/salce.h" + +#include "../cg/cglib01.h" + +#include "lv4.h" +#include "lv4100.h" +#include "lv4300a.h" + +#include +#include +#include +#include + +#define DITTA 0 +#define GRUPPO 1 +#define SPECIE 2 +#define CESPITE 3 +#define CODPADRE 4 +#define CEINCR 5 +#define NPROGR 6 +#define DESCR 7 +#define CEALIQ1 8 +#define PERCAMMANTIC 9 +#define COSTOACQ 10 +#define COSTODAAMM 11 +#define RIVALUTAZIONE 12 +#define RETTIFICHE 13 +#define FONDOAMMORT 14 +#define TOTAMMANTIC 15 +#define RIVALUTAMM 16 +#define CEDIMRIVALUTAMM 17 +#define AMMORTINDEDUCIBILE 18 +#define CREDIMPOSTA 19 +#define VENDCOSTOACQ 20 +#define VENDFDOAMM 21 +#define PLUSREINVEST 22 +#define VALORVEN 23 +#define DATAINIZAMM 24 +#define DATAACCANTONAM 25 +#define DATAALIENENAZIONE 26 +#define PERCDAAMM 27 +#define RIFERFATTVEN 28 +#define RIFERFATTACQ 29 +#define CODFOR 30 +#define CEDITFIL 31 +#define RIFERACQ 32 +#define CODCLI 33 +#define INAMMCOSTOES 34 +#define IMMATERIALI 35 +#define TIPOAMMORT 36 +#define CESSIONE 37 +#define RIFERVEN 38 +#define CEMANRIP 39 +#define PERCAMMSTD 40 +#define NQUOTEANTCALC 41 +#define NUMMOVCESP 42 +#define VENDFDOANT 43 +#define AMMDIPPADRE 44 + +/////////////////////////////////////////////////////////// +// TAutomask +/////////////////////////////////////////////////////////// + +class TImporta_cesp_mask : public TAutomask +{ +protected: + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + +public: + TImporta_cesp_mask(); +}; + +TImporta_cesp_mask::TImporta_cesp_mask() :TAutomask ("lv4300a") +{ +} + +bool TImporta_cesp_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_cesp : public TSkeleton_application +{ + virtual bool check_autorization() const {return false;} + virtual const char * extra_modules() const {return "ve";} + + TImporta_cesp_mask* _msk; + +//protected: + + +public: + virtual bool create(); + virtual bool destroy(); + virtual void main_loop(); + void transfer(const TFilename& file); + + TImporta_cesp() {}; +}; + +void TImporta_cesp::transfer(const TFilename& file) +{ + TFilename outdir(_msk->get(F_PATHOUT)); + TImporta_cogeco_recset s(file); + TProgind pi(s.items(),"Importazione cespiti in corso ...",true,true); + const long ditta = _msk->get_long(F_CODITTA); + long ntran = 1; + TString str(50); + const TEsercizi_contabili esc; + int lastes = esc.last(); + + for (bool ok = s.move_first(); ok ; ok = s.move_next()) + { + if (!pi.addstatus(1)) + break; + + const long dt = s.get(DITTA).as_int(); + + if (ditta != dt) + continue; + + TFilename temp(outdir); + + temp << '/' << format("%05ld", ntran++); + temp.ext("ini"); + if (fexist(temp)) + remove_file(temp); + TConfig conf(temp); + conf.set_paragraph("Transaction"); //setto il paragrafo [Transaction] del file ini + conf.set("Action","INSERT"); + conf.set("Mode","AUTO"); + + conf.set_paragraph("139"); // setto il paragrafo cespi + const long codces = s.get(NPROGR).as_int(); + + conf.set(CESPI_IDCESPITE, format("%010ld", codces)); + conf.set(CESPI_CODCGR, s.get(GRUPPO).as_string()); + conf.set(CESPI_CODSP, s.get(SPECIE).as_string()); + conf.set(CESPI_CODCAT, s.get(CESPITE).as_string()); + conf.set(CESPI_DESC, s.get(DESCR).as_string()); + + conf.set(CESPI_DTFUNZ, s.get(DATAINIZAMM).as_string()); + conf.set(CESPI_DTALIEN, s.get(DATAALIENENAZIONE).as_string()); + conf.set(CESPI_TPSPEMAN, 1); + +/* +#define CESPI_CODCGRA "CODCGRA" +#define CESPI_CODSPA "CODSPA" +#define CESPI_CODIMP "CODIMP" +#define CESPI_CODLOC "CODLOC" +#define CESPI_CODORIG "CODORIG" +#define CESPI_DTCOMP "DTCOMP" +#define CESPI_AMMPROP "AMMPROP" +#define CESPI_ESCLPR "ESCLPR" +#define CESPI_TPSPEMAN "TPSPEMAN" +#define CESPI_USOPROM "USOPROM" +#define CESPI_LEASING "LEASING" +#define CESPI_TUIR "TUIR" +#define CESPI_USATO "USATO" +#define CESPI_ANNIRIC "ANNIRIC" +#define CESPI_PMAT "PMAT" +#define CESPI_PIMM "PIMM" +#define CESPI_VINCOLO "VINCOLO" +#define CESPI_PMINP "PMINP" +#define CESPI_PMAXP "PMAXP" +#define CESPI_CODVAL "CODVAL" +#define CESPI_FLGTPVEI "FLGTPVEI" +#define CESPI_VEIDIP "VEIDIP" +#define CESPI_STABILIM "STABILIM" +#define CESPI_REPARTO "REPARTO" +#define CESPI_IDIMP "IDIMP" +#define CESPI_PERCIMP "PERCIMP" +#define CESPI_FABBR06 "FABBR06" + +#define CEALIQ1 8 +#define PERCAMMANTIC 9 +#define COSTODAAMM 11 +#define RIVALUTAZIONE 12 +#define RETTIFICHE 13 +#define FONDOAMMORT 14 +#define TOTAMMANTIC 15 +#define RIVALUTAMM 16 +#define CEDIMRIVALUTAMM 17 +#define AMMORTINDEDUCIBILE 18 +#define CREDIMPOSTA 19 +#define VENDCOSTOACQ 20 +#define VENDFDOAMM 21 +#define PLUSREINVEST 22 +#define VALORVEN 23 +#define PERCDAAMM 27 +#define RIFERFATTVEN 28 +#define RIFERFATTACQ 29 +#define CODFOR 30 +#define CEDITFIL 31 +#define RIFERACQ 32 +#define CODCLI 33 +#define INAMMCOSTOES 34 +#define IMMATERIALI 35 +#define TIPOAMMORT 36 +#define CESSIONE 37 +#define RIFERVEN 38 +#define CEMANRIP 39 +#define PERCAMMSTD 40 +#define NQUOTEANTCALC 41 +#define NUMMOVCESP 42 +#define VENDFDOANT 43 +#define AMMDIPPADRE 44 +*/ + conf.set_paragraph("143"); // setto il paragrafo del file salce + conf.set(SALCE_NUMELE, 1); + conf.set(SALCE_CSTO, s.get(COSTOACQ).as_string()); +/* +#define SALCE_IDCESPITE "IDCESPITE" +#define SALCE_CODES "CODES" +#define SALCE_TPSALDO "TPSALDO" +#define SALCE_NUMELE "NUMELE" +#define SALCE_CSTO "CSTO" +#define SALCE_VNONAMM "VNONAMM" +#define SALCE_VNONAMM06 "VNONAMM06" +#define SALCE_VNONAMMC "VNONAMMC" +#define SALCE_PLUSREIN "PLUSREIN" +#define SALCE_RIV75 "RIV75" +#define SALCE_RIV83 "RIV83" +#define SALCE_RIV90 "RIV90" +#define SALCE_ANNIPOST90 "ANNIPOST90" +#define SALCE_ANNIPOST91 "ANNIPOST91" +#define SALCE_RIV91 "RIV91" +#define SALCE_RIVGF "RIVGF" +#define SALCE_RIVGC "RIVGC" +#define SALCE_VSPMANU "VSPMANU" +#define SALCE_ANNIAMM "ANNIAMM" +#define SALCE_DTSTBOLL "DTSTBOLL" + + val = s.get(VLICAS).as_real() + s.get(VVICAS).as_real(); // civ + val = s.get(VLINAS2).as_real() + s.get(VAVIAS2).as_real(); // gest */ + conf.set_paragraph("136"); // setto il paragrafo del file ammce +/* +#define AMMCE_IDCESPITE "IDCESPITE" +#define AMMCE_CODES "CODES" +#define AMMCE_TPSALDO "TPSALDO" +#define AMMCE_TPAMM "TPAMM" +#define AMMCE_SCELTE "SCELTE" +#define AMMCE_AMMRIT "AMMRIT" +#define AMMCE_CSCEN "CSCEN" +#define AMMCE_FZPER "FZPER" +#define AMMCE_PNOR "PNOR" +#define AMMCE_PACC "PACC" +#define AMMCE_PANT "PANT" +#define AMMCE_FZQUO "FZQUO" +#define AMMCE_QNOR "QNOR" +#define AMMCE_QACC "QACC" +#define AMMCE_QANT "QANT" +#define AMMCE_QPERSE "QPERSE" +#define AMMCE_FPRIVATO "FPRIVATO" +#define AMMCE_QPPRIVATE "QPPRIVATE" +#define AMMCE_QNORP "QNORP" +#define AMMCE_QACCP "QACCP" +#define AMMCE_QANTP "QANTP" +#define AMMCE_QPERSEP "QPERSEP" +#define AMMCE_FPRIVATOP "FPRIVATOP" +#define AMMCE_QPPRIVATEP "QPPRIVATEP" +#define AMMCE_MSG01 "MSG01" +#define AMMCE_MSG02 "MSG02" +#define AMMCE_MSG03 "MSG03" +#define AMMCE_MSG04 "MSG04" +#define AMMCE_MSG05 "MSG05" +#define AMMCE_MSGD05 "MSGD05" +#define AMMCE_MSG06 "MSG06" +#define AMMCE_FRINGEBEN "FRINGEBEN" + + val = s.get(VAMNAS).as_real(); val amm norm fisc + val = s.get(PFANAS).as_real() + s.get(VAFNAS).as_real(); prog amm norm fisc + val = s.get(VAMAAS).as_real(); val amm ant fisc + val = s.get(PFAAAS).as_real() + s.get(VAFAAS).as_real(); prog amm ant fisc + val = s.get(VALFAS).as_real(); val amm acc fisc + + val = s.get(VANCAS).as_real(); val amm norm civ + val = s.get(FANCAS).as_real() + s.get(VFNCAS).as_real(); prog amm norm civ + val = s.get(VAACAS).as_real(); val amm ant civ + val = s.get(FAACAS).as_real() + s.get(VFACAS).as_real(); prog amm ant civ + val = s.get(VALCAS).as_real(); val amm acc civ + + val = s.get(VAMNAS2).as_real(); val amm norm gest + val = s.get(PFANAS2).as_real() + s.get(VAFNAS2).as_real(); prog amm norm gest + val = s.get(VAMAAS2).as_real(); val amm ant gest + val = s.get(PFAAAS2).as_real() + s.get(VAFAAS2).as_real(); prog amm ant gest + val = s.get(VALCAS).as_real(); val amm acc gest + ??? conf.set(, s.get(VLICAS2 51 // Valore Iniziale Civil.2 DIZSMAS - VLIN + conf.set(, s.get(VVICAS2 52 // Variaz. Valore Iniz. Civ.2 DIZSMAS - VAVI + conf.set(, s.get(VANCAS2 53 // Valore Ammort.Normale Civ.2 DIZSMAS - VAMN + conf.set(, s.get(VAACAS2 54 // Valore Ammort.Anti.Civil.2 DIZSMAS - VAMA + conf.set(, s.get(FANCAS2 55 // Progr.Fondo Amm.Norm Civ.2 DIZSMAS - PFAN + */ + } + if (yesno_box(FR("Si desidera confermare l'importazione di %ld record di cespiti"), ntran - 1)) + { + TString app; + + app << "ce0 -4 -i" << outdir << "/*.ini"; + TExternal_app primanota(app); + primanota.run(true); + } +} + + +bool TImporta_cesp::create() +{ + _msk = new TImporta_cesp_mask(); + + return TSkeleton_application::create(); +} + +bool TImporta_cesp::destroy() +{ + delete _msk; + return TApplication::destroy(); +} + +void TImporta_cesp::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_cesp& app() { return (TImporta_cesp&) main_app(); } + + +int lv4300 (int argc, char* argv[]) +{ + TImporta_cesp main_app; + main_app.run(argc, argv, TR("Importazione cespiti")); + return true; +} \ No newline at end of file diff --git a/lv/lv4300a.h b/lv/lv4300a.h new file mode 100755 index 000000000..15dea2787 --- /dev/null +++ b/lv/lv4300a.h @@ -0,0 +1,7 @@ +//campi maschera lv4300a + +#define F_CODITTA 101 +#define F_RAGSOC 102 +#define F_PATH 103 +#define F_NAME 104 +#define F_PATHOUT 105 diff --git a/lv/lv4300a.uml b/lv/lv4300a.uml new file mode 100755 index 000000000..a67c445c9 --- /dev/null +++ b/lv/lv4300a.uml @@ -0,0 +1,87 @@ +#include "lv4300a.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 + +ENDPAGE + +TOOLBAR "" 0 21 0 2 + +STRING DLG_PROFILE 50 +BEGIN + PROMPT 9 -1 "Profilo " + PSELECT +END + +ENDPAGE + +PAGE "Importazione cespiti" 0 0 0 -3 + +GROUPBOX DLG_NULL 90 3 +BEGIN + PROMPT 2 1 "@bDitta corrente" +END + +NUMBER F_CODITTA 5 +BEGIN + PROMPT 3 2 "Codice " + FLAGS "FD" + USE LF_NDITTE + INPUT CODDITTA F_CODITTA + OUTPUT F_RAGSOC RAGSOC + CHECKTYPE REQUIRED +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 23 2 "" + FLAGS "D" +END + +GROUPBOX DLG_NULL 90 4 +BEGIN + PROMPT 2 4 "@bSorgente" +END + +STRING F_PATH 256 39 +BEGIN + PROMPT 3 5 "Cartella " + DSELECT + CHECKTYPE REQUIRED + FIELD ComInPath +END + +STRING F_NAME 18 +BEGIN + PROMPT 3 6 "File " + FIELD ComInFile + CHECKTYPE REQUIRED +END + +GROUPBOX DLG_NULL 90 4 +BEGIN + PROMPT 2 8 "@bDestinazione" +END + +STRING F_PATHOUT 256 39 +BEGIN + PROMPT 3 9 "Cartella " + DSELECT + CHECKTYPE REQUIRED + FIELD ComOutPath +END + +ENDPAGE + +ENDMASK \ No newline at end of file