diff --git a/tc/tc0.cpp b/tc/tc0.cpp index ebf5ad6c1..0d3c669d3 100755 --- a/tc/tc0.cpp +++ b/tc/tc0.cpp @@ -11,7 +11,7 @@ int main(int argc, char** argv) case 2: tc0300(argc,argv); break; // parametri ditta // case 3: tc0400(argc,argv); break; case 4: tc0500(argc,argv); break; //gestore tabelle multirel -// case 5: tc0600(argc,argv); break; + case 5: tc0600(argc,argv); break; //importazione PCon, Cuas, CodIVA case 6: tc0700(argc,argv); break; //esportazione contabilita' a TeamSystem case 7: tc0800(argc,argv); break; // Riclassificazione conti TeamSystem case 8: tc0900(argc,argv); break; //importazione di clifo, fatture e ricevute da TeamSystem diff --git a/tc/tc0.h b/tc/tc0.h index 370c14496..ad9ccb883 100755 --- a/tc/tc0.h +++ b/tc/tc0.h @@ -3,6 +3,7 @@ int tc0300(int argc, char* argv[]); int tc0500(int argc, char* argv[]); +int tc0600(int argc, char* argv[]); int tc0700(int argc, char* argv[]); int tc0800(int argc, char* argv[]); int tc0900(int argc, char* argv[]); diff --git a/tc/tc0300a.uml b/tc/tc0300a.uml index ab5f6204b..6cbc779f8 100755 --- a/tc/tc0300a.uml +++ b/tc/tc0300a.uml @@ -133,6 +133,12 @@ BEGIN FIELD TSPROFESS END +BOOLEAN F_VENT +BEGIN + PROMPT 42 18 "Ventilazione" + FIELD TSVENT +END + BOOLEAN F_RIPRISTINO BEGIN PROMPT 2 19 "Ripristina alla data" diff --git a/tc/tc0600.cpp b/tc/tc0600.cpp new file mode 100755 index 000000000..902c6ccaa --- /dev/null +++ b/tc/tc0600.cpp @@ -0,0 +1,406 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tc0.h" +#include "tc0600a.h" + +#include "pconti.h" +#include "causali.h" +#include "tabutil.h" + + /////////////////////////////////////////////// + //// CLASSI DERIVATE PER IMPORTAZIONE DATI //// + /////////////////////////////////////////////// + +///////////////////////////////////////////////////////////// +// Recordset specifici per i dati da trasferire +///////////////////////////////////////////////////////////// + +//Piano dei conti +class TImporta_pconto_recordset : public TCSV_recordset +{ + public: + TImporta_pconto_recordset(const char * fileName); +}; + +TImporta_pconto_recordset::TImporta_pconto_recordset(const char * fileName) + : TCSV_recordset("CSV(\"|\")") +{ + load_file(fileName); +} + + /////////////////////////////////////////////// + //// DEFINIZIONE CLASSE TAutomask //// + /////////////////////////////////////////////// + +class TImportaTS_mask : public TAutomask +{ +protected: + virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + +public: + TImportaTS_mask(); +}; + +TImportaTS_mask::TImportaTS_mask() :TAutomask ("tc0600a") +{ +} + +bool TImportaTS_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_PCONTI: + 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; + case F_CAUSALI: + 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; + case F_CODIVA: + 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 TDocTS : public TSkeleton_application +{ + TImportaTS_mask* _msk; + +protected: + //metodi che fanno gli inserimenti sulle tabelle di campo + void upload_pconti (const TFilename& file, TLog_report& log) const; + void upload_causali(const TFilename& file, TLog_report& log) const; + void upload_codiva (const TFilename& file, TLog_report& log) const; + +public: + virtual bool create(); + virtual bool destroy(); + virtual void main_loop(); + bool transfer(); + + TDocTS() {}; +}; + +TDocTS& app() { return (TDocTS&) main_app(); } + +//funzione che importa il piano dei conto sulla tabella corretta +void TDocTS::upload_pconti (const TFilename& file, TLog_report& log) const +{ + TImporta_pconto_recordset s(file); //crea un recordset con struttura predefinita come indicato nella classe opportuna + + TLocalisamfile pconti(LF_PCON); //instanzio l'ISAM file che lavota sulla tabella PCON + + TProgind pi(s.items(),"Importazione Piano dei Conti in Corso...",true,true); + + for (bool ok=s.move_first();ok;ok=s.move_next()) + { + if (!pi.addstatus(1)) + break; + + //salto le righe di testata del file + //per farlo leggo il gruppo e controllo che sia numerico + TString dconto = s.get(1).as_string(); + if (!isdigit(dconto[1])) + continue; + + TString4 gr = dconto.mid(0,2); //leggo il gruppo + TString4 co = dconto.mid(3,2); //leggo il conto + TString4 sc = dconto.mid(6,3); //leggo il sottoconto + TString desc = s.get(2).as_string(); //leggo la descrizione + + if (co == " " || co == "**") + { + co = "00"; + atoi(co); + } + + if (sc == " " || sc == "***") + { + sc = "000"; + atoi(sc); + } + + pconti.zero(); + + pconti.put(PCN_GRUPPO,gr); //put del gruppo + pconti.put(PCN_CONTO,co); //put del conto + pconti.put(PCN_SOTTOCONTO,sc); //put del sottoconto + pconti.put(PCN_DESCR,desc); //put della descrizione + + TString str = "Il Conto "; + str << gr << " " << " " << co << " " << sc; + + + //pconti.put(PCN_???,s.get("TCONTO").as_string()); + + int err = pconti.write_rewrite(); //Tenta di aggiungere un record ma se esiste gia' lo aggiorna + + if (err == NOERR) + { + str << " è stato inserito"; + log.log(0,str); + } + else + { + str << " non è stato inserito, errore " << err; + log.log(2,str); + } + } + return; +} + +//funzione che importa il piano dei conto sulla tabella corretta +void TDocTS::upload_causali(const TFilename& file, TLog_report& log) const +{ + TScanner s(file); //legge il file che gli passo riga per riga + TString curr = s.line(); + + TLocalisamfile causa(LF_CAUSALI); //instanzio l'ISAM file che lavota sulla tabella CAUS + + TProgind pi(fsize(file),"Importazione Causali in Corso...",true,true); + + while (s.ok()) + { + if (!pi.addstatus(s.tellg())) + break; + + curr = s.line(); + TString8 cod = curr.mid(1,6); + cod.trim(); + TString desc = curr.mid(7,16); + + //salto le righe di testata del file + if (!real::is_natural(cod)) + continue; + + if (cod.len() > 3) + { + TString errore = "ERRORE:"; + errore <<" la causale con codice " << cod << " non può essere inserita (codice max 3 caratteri)"; + log.log(2,errore); + } + + causa.zero(); + + causa.put(CAU_CODCAUS,cod); + causa.put(CAU_DESCR,desc); + + int err = causa.write_rewrite(); //Tenta di aggiungere un record ma se esiste gia' lo aggiorna + + TString str = "La Causale con codice "; + str << cod; + + if (err == NOERR) + { + str << " è stata inserita"; + log.log(0,str); + } + else + { + str << " non è stata inserita, errore " << err; + log.log(2,str); + } + + + } + return; +}; + +//funzione che importa i codici IVA sulla tabella corretta +void TDocTS::upload_codiva(const TFilename& file, TLog_report& log) const +{ + TScanner s(file); //crea un recordset con struttura predefinita come indicato nella classe opportuna + + TTable iva("%IVA"); //instanzio l'ISAM file che lavota sulla tabella IVA + + TProgind pi(fsize(file),"Importazione Dati IVA in Corso...",true,true); + + while(s.ok()) + { + if (!pi.addstatus(s.tellg())) + break; + + //salto le righe di testata del file + TString curr = s.line(); + TString8 cod = curr.mid(1,8); + cod.trim(); + TString desc = curr.mid(9,20); + + //salto le righe di testata del file + if (!real::is_natural(cod)) + continue; + + if (cod.len() > 4) + { + TString errore = "ERRORE:"; + errore <<" i dati IVA con codice " << cod << " non possono essere inseriti (codice max 4 caratteri)"; + log.log(2,errore); + } + + iva.zero(); + + iva.put("CODTAB",cod); + iva.put("S0",desc); + + int err = iva.write_rewrite(); //Tenta di aggiungere un record ma se esiste gia' lo aggiorna + + TString str = "I dati IVA con codice "; + str << cod; + + + if (err == NOERR) + { + str << " sono stati inseriti"; + log.log(0,str); + } + else + { + str << " non sono stati inseriti, errore " << err; + log.log(2,str); + } + } + return; +}; + +bool TDocTS::transfer() +{ + TLog_report log("Importazione documenti da TeamSystem"); + + //prelevo il path dei file da caricare dalla maschera + TFilename path = _msk->get(F_PATH); + + const short ids [] = {F_PCONTI,F_CAUSALI,F_CODIVA,0}; + + //eseguo tutte le importazioni (una alla volta) + for (int i = 0; ids[i]; i++) + { + //prelevo di volta in volta il nome del file giusto dalla maschera: + //prima il file Anagrafiche, poi quello delle fatture e poi quello delle ricevute + TFilename name = _msk->get(ids[i]); + + //se sono riuscito a prelevare un nome di file, allora: + if (name.full()) + { + //costruisco il nome del file + TFilename full = path; + full.add(name); + + //se eiste il file, esegui l'elaborazione corretta + if (full.exist()) + { + switch (i) + { + case 0: upload_pconti (full, log); break; + case 1: upload_causali(full, log); break; + case 2: upload_codiva (full, log); break; + default: break; + } + } + } + } + + TReport_book buc; + + buc.add(log); + if (buc.pages()>0) + buc.preview(); //visualizzo il log di importazione dei documenti + + return true; +} + +bool TDocTS::create() +{ + _msk = new TImportaTS_mask(); + + return TSkeleton_application::create(); +} + +bool TDocTS::destroy() +{ + delete _msk; + return TApplication::destroy(); +} + +void TDocTS::main_loop() +{ + KEY tasto; + tasto = _msk->run(); + if (tasto == K_ENTER) + { + if (transfer()) + { + message_box(TR("Importazione documenti completata")); + } + } +} + +int tc0600 (int argc, char* argv[]) +{ + TDocTS main_app; + main_app.run(argc, argv, TR("Importazione Clienti/Fornitori")); + return true; +} diff --git a/tc/tc0600a.h b/tc/tc0600a.h new file mode 100755 index 000000000..5ec671d0d --- /dev/null +++ b/tc/tc0600a.h @@ -0,0 +1,8 @@ +//Trasferimento dati da TeamSystem + +#define F_CODDITTA 101 +#define F_RAGSOC 102 +#define F_PATH 103 +#define F_PCONTI 104 +#define F_CAUSALI 105 +#define F_CODIVA 106 \ No newline at end of file diff --git a/tc/tc0600a.uml b/tc/tc0600a.uml new file mode 100755 index 000000000..7200b422f --- /dev/null +++ b/tc/tc0600a.uml @@ -0,0 +1,82 @@ +#include "tc0600a.h" + +TOOLBAR "" 0 -3 0 3 + +BUTTON DLG_ELABORA 10 2 +BEGIN + PROMPT -12 -11 "" + PICTURE BMP_ELABORA + MESSAGE EXIT,K_ENTER +END + +BUTTON DLG_QUIT 10 2 +BEGIN + PROMPT -22 -11 "" +END + +STRING DLG_PROFILE 50 +BEGIN + PROMPT 9 0 "Profilo " + PSELECT + FLAGS "H" +END + +ENDPAGE + +PAGE "Trasferimento dati da TeamSystem" 0 0 0 -3 + +GROUPBOX DLG_NULL 76 3 +BEGIN + PROMPT 2 1 "@bDitta corrente" +END + +NUMBER F_CODDITTA 5 +BEGIN + PROMPT 3 2 "Codice " + FLAGS "FD" + USE LF_NDITTE + INPUT CODDITTA F_CODDITTA + OUTPUT F_RAGSOC RAGSOC + CHECKTYPE REQUIRED +END + +STRING F_RAGSOC 50 +BEGIN + PROMPT 23 2 "" + FLAGS "D" +END + +GROUPBOX DLG_NULL 76 6 +BEGIN + PROMPT 2 4 "@bSorgente" +END + +STRING F_PATH 256 50 +BEGIN + PROMPT 3 5 "Cartella " + DSELECT + CHECKTYPE REQUIRED + FIELD FileInPath +END + +STRING F_PCONTI 25 +BEGIN + PROMPT 3 6 "Piano dei Conti " + FIELD PCONTI +END + +STRING F_CAUSALI 25 +BEGIN + PROMPT 3 7 "Causali " + FIELD CAUSALI +END + +STRING F_CODIVA 25 +BEGIN + PROMPT 3 8 "Codici IVA " + FIELD CODIVA +END + +ENDPAGE + +ENDMASK \ No newline at end of file diff --git a/tc/tc0700.cpp b/tc/tc0700.cpp index 3b924aead..a0bdff6ba 100755 --- a/tc/tc0700.cpp +++ b/tc/tc0700.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -318,9 +319,15 @@ bool TTS_campo_sender::find_regolarizzazione(TRecordset& mov) const TRecordset& cli = clirecset(mov.get(MOV_TIPO).as_string()[0], mov.get(MOV_CODCF).as_int()); const TString16 paiv = cli.get(CLI_PAIV).as_string(); const TString16 cf = cli.get(CLI_COFI).as_string(); + TEsercizi_contabili esc; + const TEsercizio & e = esc.esercizio(esc.date2esc(mov.get(MOV_DATAREG).as_date())); + const TDate to(e.fine()); for (bool ok = mov.move_next(); ok && ! found; ok = mov.move_next()) { + const TDate dreg = mov.get(MOV_DATAREG).as_date(); + if (dreg >to) + break; const TRectype& caus = cache().get(LF_CAUSALI, mov.get(MOV_CODCAUS).as_string()); const TString4 cod = caus.get(CAU_CODCAUS); diff --git a/tc/tc0701.cpp b/tc/tc0701.cpp index 4b7e4a740..a56322e2a 100755 --- a/tc/tc0701.cpp +++ b/tc/tc0701.cpp @@ -941,6 +941,8 @@ void TTS_sender::add_datiiva(const TRecordset& mov) long codiva11 = 0L; //da modificare nella 3.1 const bool indetraibile = rmoviva.get(RMI_TIPODET).as_int() > 0; + const TString4 tipocr = rmoviva.get(RMI_TIPOCR).as_string(); + const bool acqvent = _ventilazione && (imposta != ZERO) && tipocr == "1"; if (indetraibile) codiva += TSMAIALCONST; // maialata @@ -948,7 +950,7 @@ void TTS_sender::add_datiiva(const TRecordset& mov) codiva11 = codiva11rev; else if (rmoviva.get(RMI_TIPOCR).as_int() > 0) - codiva11 = cod2ricl("TSI11", rmoviva.get(RMI_TIPOCR)); + codiva11 = cod2ricl("TSI11", tipocr); key.format("%04ld%04ld", codiva, codiva11); TIVA_item * item = (TIVA_item *) _iva.objptr(key); @@ -1313,6 +1315,7 @@ void TTS_sender::set_parameters() _dittamulti = configtc.get("TSDitta"); _professionista = configtc.get_bool("TSPROFESS"); + _ventilazione = configtc.get_bool("TSVENT"); for (int j = 0; configtc.exist("TSDATT", j); j++) { diff --git a/tc/tc0701.h b/tc/tc0701.h index e16d71dfe..7fd6fc198 100755 --- a/tc/tc0701.h +++ b/tc/tc0701.h @@ -26,6 +26,7 @@ class TTS_sender : public TSkeleton_application TAssoc_array _contiiva; TAssoc_array _contirit; bool _professionista; + bool _ventilazione; real _rit_acc; protected: diff --git a/tc/tcconf.h b/tc/tcconf.h index 47ae42912..a5a8ef152 100755 --- a/tc/tcconf.h +++ b/tc/tcconf.h @@ -20,6 +20,7 @@ #define F_EMCAU 129 #define F_SHEET_ATTIV 130 #define F_PROFESS 131 +#define F_VENT 132 #define SI_GRUPPO 101 #define SI_CONTO 102 diff --git a/tc/tcmenu.men b/tc/tcmenu.men index 41ad5d63e..adc897828 100755 --- a/tc/tcmenu.men +++ b/tc/tcmenu.men @@ -14,9 +14,10 @@ Picture = Module = 27 Flags = "" Item_01 = "Trasferimento", "tc0 -6", "" -Item_02 = "Imporytazione", "tc0 -8", "" -Item_03 = "Tabelle di riclassificazione", [TCMENU_003] -Item_04 = "Configurazione modulo", [TCMENU_004] +Item_02 = "Importazione documenti", "tc0 -8", "" +Item_03 = "Importazione causali,p.d.c.,cod.iva", "tc0 -5", "" +Item_04 = "Tabelle di riclassificazione", [TCMENU_003] +Item_05 = "Configurazione modulo", [TCMENU_004] [TCMENU_003] Caption = "Tabelle di riclassificazione" diff --git a/tc/tctsiva.uml b/tc/tctsiva.uml index c1b1ee47c..61d8fe82c 100755 --- a/tc/tctsiva.uml +++ b/tc/tctsiva.uml @@ -71,7 +71,7 @@ BEGIN GROUP 1 10 END -STRING F_COD_CAMPO1 4 +STRING F_COD_CAMPO1 5 BEGIN PROMPT 2 4 "Codice IVA collegato " FIELD SECOND diff --git a/vd/vdlib.cpp b/vd/vdlib.cpp index e246a0bef..2c1fc3d59 100755 --- a/vd/vdlib.cpp +++ b/vd/vdlib.cpp @@ -395,7 +395,7 @@ bool TTurno_vendita::chiudi() rep.recordset()->set_var("#PROGR", var); book.add(rep); - book.print(); + book.print_or_preview(); return true; } else