#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 CGC_DITTA 0 #define CGC_GRUPPO 1 #define CGC_SPECIE 2 #define CGC_CESPITE 3 #define CGC_CODPADRE 4 #define CGC_CEINCR 5 #define CGC_NPROGR 6 #define CGC_DESCR 7 #define CGC_CEALIQ1 8 #define CGC_PERCAMMANTIC 9 #define CGC_COSTOACQ 10 #define CGC_COSTODAAMM 11 #define CGC_RIVALUTAZIONE 12 #define CGC_RETTIFICHE 13 #define CGC_FONDOAMMORT 14 #define CGC_TOTAMMANTIC 15 #define CGC_RIVALUTAMM 16 #define CGC_CEDIMRIVALUTAMM 17 #define CGC_AMMORTINDEDUCIBILE 18 #define CGC_CREDIMPOSTA 19 #define CGC_VENDCOSTOACQ 20 #define CGC_VENDFDOAMM 21 #define CGC_PLUSREINVEST 22 #define CGC_VALORVEN 23 #define CGC_DATAINIZAMM 24 #define CGC_DATAACCANTONAM 25 #define CGC_DATAALIENENAZIONE 26 #define CGC_PERCDAAMM 27 #define CGC_RIFERFATTVEN 28 #define CGC_RIFERFATTACQ 29 #define CGC_CODFOR 30 #define CGC_CEDITFIL 31 #define CGC_RIFERACQ 32 #define CGC_CODCLI 33 #define CGC_INAMMCOSTOES 34 #define CGC_IMMATERIALI 35 #define CGC_TIPOAMMORT 36 #define CGC_CESSIONE 37 #define CGC_RIFERVEN 38 #define CGC_CEMANRIP 39 #define CGC_PERCAMMSTD 40 #define CGC_NQUOTEANTCALC 41 #define CGC_NUMMOVCESP 42 #define CGC_VENDFDOANT 43 #define CGC_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 { TImporta_cesp_mask* _msk; public: virtual bool create(); virtual bool destroy(); virtual void main_loop(); void transfer(const TFilename& file); }; 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); const long ditta = _msk->get_long(F_CODITTA); const TEsercizi_contabili esc; int lastesc = esc.last(); long ntran = 1; for (bool ok = s.move_to(1); ok ; ok = s.move_next()) { if (!pi.addstatus(1)) break; const long dt = s.get(CGC_DITTA).as_int(); if (ditta != dt) continue; const long codces = s.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 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); // 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 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()); // scrivo i record dei cespiti int err = cespi.write(); if (err == NOERR) err = salce.write(); if (err == NOERR) err = ammce.write(); } else { // chiedere cosa fare perche' non ho capito cosa devo sommare!! } } } 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); } } int lv4300 (int argc, char* argv[]) { TImporta_cesp main_app; main_app.run(argc, argv, TR("Importazione cespiti COGECO")); return true; }