diff --git a/cg/cg2400.cpp b/cg/cg2400.cpp index e6dab2158..2e1b0a8d4 100755 --- a/cg/cg2400.cpp +++ b/cg/cg2400.cpp @@ -584,6 +584,6 @@ bool TRic_sistema::menu(MENU_TAG m) int cg2400 (int argc, char* argv[]) { TRic_sistema a; - a.run(argc, argv,"Ricezione da sistema"); + a.run(argc, argv,"Ricezione archivi"); return TRUE; } diff --git a/cg/cg2700.cpp b/cg/cg2700.cpp index 7dc31972b..6dc299175 100755 --- a/cg/cg2700.cpp +++ b/cg/cg2700.cpp @@ -1,1070 +1,1126 @@ -// -// Ricezione dati: lista controllo movimenti -// -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "cg2103.h" -#include "cglib04.h" -#include "cg2700.h" - -HIDDEN const char* err_msg[] = {"*** Data operazione non valida", - "--- Data competenza non compresa in alcun esercizio", - "*** Data operazione antecedente ad ultima stampa giornale", - "--- Data documento non valida", - "*** Codice causale non valido o non presente in archivio", - "--- Codice pagamento non valido o non presente in tabella", - "*** Codice registro IVA non valido o non presente in tabella", - "*** Codice cliente/fornitore non valido o non presente in anagrafica", - "--- Data 74 ter non valida", - "*** Data operazione antecedente ad ultima stampa registro IVA"}; - -HIDDEN int date2esc(const TDate& d, int* prevesc = NULL); - -class TRic_ListaMov : public TPrintapp -{ - TTable* _tab_tra,* _tab_pag,* _tab_tpd,* _tab_iva; - TIsamtempfile* _tmov,* _trmov,* _tiva; - TLocalisamfile* _caus,* _ditte,* _clifo,* _pcon; - TRelation* _rel; - TCursor* _cur; - TTransfer_file* _trasfer; - TLibro_giornale* _giornale; - TString80 _pathfile, _descr_causale, _descr_conto; - TString16 _causale, _registro, _numdoc, _tipodoc, _codval; - TString16 _codpag, _codiva, _tipo_conto; - TString _record; - bool _mov_sez, _errore_grave, _esiste_conto, _esiste_causale; - char _sdt, _sezione; - int _ae, _anno, _gruppo, _conto, _tipocr, _tipod, _tiporeg; - int _gruppoc, _contoc, _n_rec, _gruppocr, _contocr; - TDate _datacomp, _datadoc, _datareg, _data74tr; - real _importo, _impo, _impos, _tot_dare, _tot_avere, _tot_doc; - long _codcf, _numero, _protiva, _sottoconto; - long _inizioZ, _inizioU, _num_rec, _sottocontoc, _sottocontocr; - TBit_array _err; - byte _controllo; - -public: - virtual bool set_print(int m); - virtual bool user_create() ; - virtual bool user_destroy(); - virtual bool preprocess_page(int,int); - virtual print_action postprocess_page(int,int); - virtual void postclose_print(); - const char* look_sdt(); - const char* get_codiva_des(const char*); - bool DescrConto(int,int,long); - bool check_archivi(TProgind*); - bool look_pag(); - bool errori_partita(int,int,long); - bool controlla_mov(); - bool controlla_rmov(); - bool controlla_riva(); - void stampa_errori_mov(int); - void stampa_errori_rmov(int); - void stampa_errori_riva(int); - void aggiorna_trasfer_Z(); - void aggiorna_trasfer_U(); - void setta_parametri(const TString&, const TString&); - void setta_intestazione(); - TLibro_giornale& giornale() { return *_giornale; } - TTransfer_file& trasfer() { return *_trasfer; } - - TRic_ListaMov(): _err(80) {} - virtual ~TRic_ListaMov() {} -}; - -HIDDEN inline TRic_ListaMov& app() { return (TRic_ListaMov&)main_app();} - -HIDDEN int date2esc(const TDate& d, int* prevesc) -{ - if (prevesc) *prevesc = 0; - TTable esc("ESC"); - for (int err = esc.first(); err == NOERR; err = esc.next()) - { - const TDate ia(esc.get("D0")); // Data inizio esercizio - const TDate fa(esc.get("D1")); // Data fine esercizio - const anno = esc.get_int("CODTAB"); - if (d >= ia && d <= fa) - return anno; - if (prevesc) *prevesc = anno; - } - return 0; -} - -const char* TRic_ListaMov::look_sdt() -{ - TConfig conf(CONFIG_DITTA); - return conf.get("FlStTra"); -} - -bool TRic_ListaMov::look_pag() -{ - TTable t ("%CPG"); - t.zero(); - t.put("CODTAB",_codpag); - if (t.read() != NOERR) return FALSE; - return TRUE; -} - -const char* TRic_ListaMov::get_codiva_des(const char* codiva) -{ - TTable iva ("%IVA"); - - iva.zero(); - iva.put("CODTAB", codiva); - if (iva.read() == NOERR) - return iva.get("S0"); - else - return NULL; -} - -bool TRic_ListaMov::DescrConto(int g, int c, long s) -{ - TString80 ragsoc; - const char* descr = NULL; - TLocalisamfile pconti (LF_PCON); - pconti.setkey(1); - pconti.zero(); - pconti.put(PCN_GRUPPO, g); - pconti.put(PCN_CONTO, c); - pconti.put(PCN_SOTTOCONTO, 0L); - if (pconti.read() == NOERR) - { - _tipo_conto = pconti.get(PCN_TMCF); - if (_tipo_conto == "C" || _tipo_conto == "F") - { - TLocalisamfile clifo (LF_CLIFO); - clifo.setkey(1); - clifo.zero(); - clifo.put(CLI_TIPOCF, _tipo_conto); - clifo.put(CLI_CODCF, s); - if (clifo.read() != NOERR) - { - _descr_conto = ""; - return FALSE; - } - else - { - char tipoa = clifo.get_char("TIPOAPER"); - if (tipoa == 'F') //persona fisica - { - TString80 cognome, nome; - ragsoc = clifo.get("RAGSOC"); - cognome = ragsoc.mid(0,30); - nome = ragsoc.mid(30,20); - cognome.trim(); nome.trim(); - ragsoc = cognome; - ragsoc << " " << nome; - _descr_conto = ragsoc; - } - else _descr_conto = clifo.get("RAGSOC"); - } - } - else - { - pconti.zero(); - pconti.put(PCN_GRUPPO, g); - pconti.put(PCN_CONTO, c); - pconti.put(PCN_SOTTOCONTO, s); - if (pconti.read() != NOERR) - { - _descr_conto = ""; - return FALSE; - } - else _descr_conto = pconti.get(PCN_DESCR); - } - } - else - { - _descr_conto = ""; - return FALSE; - } - return TRUE; -} - -bool TRic_ListaMov::user_create() -{ - _trasfer = new TTransfer_file(); - - TProgind* pnd = NULL; - pnd = new TProgind (3,"Controllo archivi\nPrego attendere", - FALSE, TRUE, 30); - _tab_tra = new TTable ("%TRA"); - _tab_tpd = new TTable ("%TPD"); - _tab_pag = new TTable ("%CPG"); - _tab_iva = new TTable ("%IVA"); - _caus = new TLocalisamfile (LF_CAUSALI); - _ditte = new TLocalisamfile (LF_NDITTE); - _clifo = new TLocalisamfile (LF_CLIFO); - _pcon = new TLocalisamfile (LF_PCON); - - if (pnd) pnd->addstatus(1); - - if (!check_archivi(pnd)) - { - delete pnd; - return FALSE; - } - - if (pnd) pnd->addstatus(1); - - TString80 tmpmov = "%"; - tmpmov << get_firm_dir(); - tmpmov << "\\" << TEMP_MOV; - TString80 tmprmov = "%"; - tmprmov << get_firm_dir(); - tmprmov << "\\" << TEMP_RMOV; - TString80 tmprmoviva = "%"; - tmprmoviva << get_firm_dir(); - tmprmoviva << "\\" << TEMP_RMOVIVA; - - _tmov = new TIsamtempfile(LF_MOV, tmpmov, 0); - _trmov = new TIsamtempfile(LF_RMOV, tmprmov, 0); - _tiva = new TIsamtempfile(LF_RMOVIVA, tmprmoviva, 0); - - _rel = new TRelation(_tmov); - _rel->add(_trmov,"NUMREG=NUMREG",1,0,0,FALSE); - _rel->add(_tiva, "NUMREG=NUMREG",1,0,0,FALSE); - _cur = new TCursor (_rel, "", 1); - - _giornale = new TLibro_giornale(); - - add_cursor(_cur); - - add_file (LF_MOV); - add_file (LF_RMOV, LF_MOV); - add_file (LF_RMOVIVA, LF_MOV); - - printer().footerlen(5); - - delete pnd; - - return TRUE; -} - -bool TRic_ListaMov::check_archivi(TProgind* pnd) -{ - TString80 nome; - long ditta_ric = get_firm(); - - if (!prefix().exist(ditta_ric)) - return error_box("Rilevati errori gravi negli archivi: procedura interrotta"); - - TTransfer_file& tr = trasfer(); - - _pathfile = tr.path(); - - _pathfile = _pathfile << "\\trasfer"; - - if (!tr.open(_pathfile)) - return error_box("Al momento non presenti trasferimenti attivi sulla ditta selezionata"); - - if (!tr.read_control_rec()) - return error_box("Rilevati errori gravi negli archivi: procedura interrotta"); - else _record = tr.record(); - - TString16 sd = look_sdt(); - - if (sd.not_empty()) - _sdt = sd[0]; - else return error_box("Ricezione tabelle non effettuata: richiamare il programma relativo"); - - if (_sdt == 'T') - return error_box("Ricezione tabelle non effettuata: richiamare il programma relativo"); - - if (_sdt == 'M') - return yesno_box("Controllo gia' effettuato: si desidera ripeterlo ?"); - - if (_sdt != '*' && _sdt != 'C') - return error_box("Rilevati errori gravi negli archivi: procedura interrotta"); - - TString16 ult = tr.ult_file(); - TString16 key = tr.key(); - - ult.strip_spaces(); - key.strip_spaces(); - - if (_sdt == 'C') - if ( ult.not_empty() || key.not_empty() ) - return error_box("Rilevati errori gravi negli archivi: procedura interrotta"); - - if (_sdt == '*') - return warning_box("Trasferimento interamente completato: proseguire per cancellare i file"); - - if (pnd) pnd->addstatus(1); - - return TRUE; -} - -void TRic_ListaMov::stampa_errori_mov(int riga) -{ - long i = _err.first_one(); - if (i != -1) - { - for (; i <= _err.last_one(); i++) - if (_err[i]) - set_row(++riga, "@8g%s", (const char*) err_msg[i]); - } -} - -bool TRic_ListaMov::controlla_mov() -{ - bool check_reg = TRUE; - TString16 causreg; - TDate udata; - char tipocf; - - _tiporeg = 0; - - if (!_datareg.ok()) - { - _errore_grave = TRUE; - _err.set(0L); - } - else if (!_datacomp.ok()) - { - const int ae = date2esc(_datacomp); - if (ae == 0) - _err.set(1); - } - - TLibro_giornale& gio = giornale(); - bool ok = gio.read(_ae); //se _ae e' zero la read considera come anno quello corrente - if (_datareg < gio.last_print()) - { - _errore_grave = TRUE; - _err.set(2); - } - - TString16 dd = _datadoc.string(); - if (dd.not_empty()) - if (!_datadoc.ok()) - _err.set(3); - - //if (_causale.not_empty()) - //{ - TLocalisamfile caus(LF_CAUSALI); - caus.setkey(1); - caus.zero(); - caus.put(CAU_CODCAUS,_causale); - if (caus.read() == NOERR) - { - _esiste_causale = TRUE; - _tipodoc = caus.get(CAU_TIPODOC); - } - else - { - caus.zero(); - _esiste_causale = FALSE; - if (look_causale(_causale)) //se la causale e' significativa - { - _errore_grave = TRUE; - _err.set(4); - } - } - //_tipodoc = caus.get(CAU_TIPODOC); ho sempre quello letto sul movimento! - causreg = caus.get(CAU_REG); - _descr_causale = caus.get(CAU_DESCR); - _mov_sez = caus.get_bool(CAU_MOVSEZ); - //} - - if (!_codpag.blank()) - { - bool ok = look_pag(); - if (!ok) - _err.set(5); - } - - if (!_registro.blank()) //movimento iva (fattura) - { - if (!look_causale(_causale)) //se la causale non e' significativa - { - _errore_grave = TRUE; - check_reg = FALSE; - _err.set(6); - } - if (check_reg && _ae) - { - TRegistro rg (_registro, _ae); - if (rg.name().empty()) - { - _errore_grave = TRUE; - check_reg = FALSE; - _err.set(6); - } - else - { - _tiporeg = rg.tipo(); - udata = rg.last_print(); - } - } - } - else if (!causreg.blank() && _ae) - { - TRegistro rg (causreg, _ae); - if (rg.name().empty()) - { - _errore_grave = TRUE; - check_reg = FALSE; - _err.set(6); - } - else - { - _tiporeg = rg.tipo(); - udata = rg.last_print(); - } - _registro = causreg; - } - - if (check_reg && !_registro.blank()) - { - if (_tiporeg == 1) tipocf = 'C'; - else if (_tiporeg == 2) tipocf = 'F'; - if (!_tipodoc.blank()) //se esiste, uso quello della causale!!! - { - TTable tabtpd("%TPD"); - tabtpd.put("CODTAB", _tipodoc); - if (tabtpd.read() == NOERR) - { - bool cor = tabtpd.get_bool("B0"); - if (!cor) - if (_codcf != 0l) - { - TLocalisamfile clifo(LF_CLIFO); - clifo.zero(); - clifo.put(CLI_CODCF, _codcf); - clifo.put(CLI_TIPOCF,tipocf); - if (clifo.read() != NOERR) - { - _errore_grave = TRUE; - _err.set(7); - } - } - else - { - _errore_grave = TRUE; - _err.set(7); - } - } - } - } - - TString16 d74 = _data74tr.string(); - if (d74.not_empty()) - if (!_data74tr.ok()) - _err.set(8); - - if (!_registro.blank() && check_reg) - if (_datareg < udata) - { - _errore_grave = TRUE; - _err.set(9); - } - - if (_err.ones()) - return TRUE; - - return FALSE; -} - -bool TRic_ListaMov::errori_partita(int g, int c, long s) -{ - TLocalisamfile pconti (LF_PCON); - pconti.setkey(1); - pconti.zero(); - pconti.put(PCN_GRUPPO, g); - pconti.put(PCN_CONTO, c); - pconti.put(PCN_SOTTOCONTO, 0L); - if (pconti.read() == NOERR) - { - char tipo = pconti.get(PCN_TMCF)[0]; - if (tipo == 'C' || tipo == 'F') - { - TLocalisamfile clifo (LF_CLIFO); - clifo.setkey(1); - clifo.zero(); - clifo.put(CLI_TIPOCF, tipo); - clifo.put(CLI_CODCF, s); - if (clifo.read() != NOERR) - return FALSE; - } - else - { - pconti.zero(); - pconti.put(PCN_GRUPPO, g); - pconti.put(PCN_CONTO, c); - pconti.put(PCN_SOTTOCONTO, s); - if (pconti.read() != NOERR) - return FALSE; - } - } - else return FALSE; - - return TRUE; -} - -bool TRic_ListaMov::controlla_rmov() -{ - TLocalisamfile& rmov = current_cursor()->file(LF_RMOV); - int gruppo, conto, gruppoc, contoc; - long sottoconto, sottocontoc; - char sezione; - real importo, dare, avere; - - if (current_cursor()->is_first_match(LF_RMOV)) - { - dare = avere = ZERO; - TRecnotype nrec = rmov.recno(); - rmov.zero(); - rmov.setkey(1); - rmov.put(RMV_NUMREG, _numero); - TRectype recc (rmov.curr()); - for (rmov.read(_isgteq); !rmov.eof() ;rmov.next()) - { - TRectype rec (rmov.curr()); - if (rec > recc) break; - gruppo = rec.get_int(RMV_GRUPPO); - conto = rec.get_int(RMV_CONTO); - sottoconto = rec.get_long(RMV_SOTTOCONTO); - gruppoc = rec.get_int(RMV_GRUPPOC); - contoc = rec.get_int(RMV_CONTOC); - sottocontoc = rec.get_long(RMV_SOTTOCONTOC); - sezione = rec.get_char(RMV_SEZIONE); - importo = rec.get_real(RMV_IMPORTO); - - if (sezione == 'D') - dare += importo; - if (sezione == 'A') - avere += importo; - - if (gruppo == 0 || conto == 0 || sottoconto == 0l) - { - rmov.readat(nrec); - return TRUE; - } - else - { - bool ok = errori_partita(gruppo,conto,sottoconto); - if (!ok) - { - rmov.readat(nrec); - return TRUE; - } - } - - if ( (importo == ZERO && sezione != ' ') || - (sezione != 'D' && sezione != 'A') ) - { - rmov.readat(nrec); - return TRUE; - } - - if (gruppoc == 0 || contoc == 0 || sottocontoc == 0l) - { - rmov.readat(nrec); - return TRUE; - } - else - { - bool ok = errori_partita(gruppoc,contoc,sottocontoc); - if (!ok) - { - rmov.readat(nrec); - return TRUE; - } - } - - if (_esiste_causale) - if (!_mov_sez && importo == ZERO) - { - rmov.readat(nrec); - return TRUE; - } - } - if (dare != avere) - { - rmov.readat(nrec); - return TRUE; - } - rmov.readat(nrec); - } - return FALSE; -} - -void TRic_ListaMov::stampa_errori_rmov(int riga) -{ - if (_gruppo == 0 || _conto == 0 || _sottoconto == 0l) - set_row(++riga, "@8g*** Sottoconto partita non valido o non presente in archivio"); - else - { - if (!_esiste_conto) - set_row(++riga, "@8g*** Sottoconto partita non valido o non presente in archivio"); - } - - if ( (_importo == ZERO && _sezione != ' ') || - (_sezione != 'D' && _sezione != 'A') ) - set_row(++riga, "@8g*** Segnale dare/avere non valido"); - - if (_sezione == 'D') - _tot_dare += _importo; - if (_sezione == 'A') - _tot_avere += _importo; - - if (_gruppoc == 0 || _contoc == 0 || _sottocontoc == 0l) - set_row(++riga, "@8g*** Sottoconto contropartita non valido o non presente in archivio"); - else - { - bool ok = errori_partita(_gruppoc,_contoc,_sottocontoc); - if (!ok) - set_row(++riga, "@8g*** Sottoconto contropartita non valido o non presente in archivio"); - } - - if (_esiste_causale) - if (!_mov_sez && _importo == ZERO) - set_row(++riga, "@8g--- Importo riga uguale a zero"); -} - -bool TRic_ListaMov::controlla_riva() -{ - TLocalisamfile& rmoviva = current_cursor()->file(LF_RMOVIVA); - TTable tab_iva("%IVA"); - TString16 codiva; - int tipodet, tipocr, gruppocr, contocr; - long sottocontocr; - - if (current_cursor()->is_first_match(LF_RMOVIVA)) - { - TRecnotype nrec = rmoviva.recno(); - rmoviva.setkey(1); - rmoviva.zero(); - rmoviva.put(RMI_NUMREG, _numero); - TRectype recc (rmoviva.curr()); - for (rmoviva.read(_isgteq); !rmoviva.eof() ;rmoviva.next()) - { - TRectype rec (rmoviva.curr()); - if (rec > recc) break; - codiva = rec.get(RMI_CODIVA); - tipodet = rec.get_int(RMI_TIPODET); - tipocr = rec.get_int(RMI_TIPOCR); - gruppocr = rec.get_int(RMI_GRUPPO); - contocr = rec.get_int(RMI_CONTO); - sottocontocr = rec.get_long(RMI_SOTTOCONTO); - - TTable iva ("%IVA"); - iva.zero(); - iva.put("CODTAB", codiva); - if (iva.read() != NOERR) - { - rmoviva.readat(nrec); - return TRUE; - } - if (!(tipocr >= 0 && tipocr <= 9)) - { - rmoviva.readat(nrec); - return TRUE; - } - if (gruppocr == 0 || contocr == 0 || sottocontocr == 0l) - { - rmoviva.readat(nrec); - return TRUE; - } - else - { - bool ok = errori_partita(gruppocr,contocr,sottocontocr); - if (!ok) - { - rmoviva.readat(nrec); - return TRUE; - } - } - - if (tipodet != 0 && tipodet != 1 && tipodet != 3 && tipodet != 9) - { - rmoviva.readat(nrec); - return TRUE; - } - } - rmoviva.readat(nrec); - } - return FALSE; -} - -void TRic_ListaMov::stampa_errori_riva(int riga) -{ - TTable iva ("%IVA"); - - iva.zero(); - iva.put("CODTAB", _codiva); - if (iva.read() != NOERR) - set_row(++riga, "@8g--- Codice IVA non valido o non presente in tabella"); - - if (!(_tipocr >= 0 && _tipocr <= 9)) - set_row(++riga, "@8g--- Tipo costo/ricavo non valido"); - - if (_gruppocr == 0 || _contocr == 0 || _sottocontocr == 0l) - set_row(++riga, "@8g*** Sottoconto costo/ricavo non valido o non presente in archivio"); - else - { - bool ok = errori_partita(_gruppocr,_contocr,_sottocontocr); - if (!ok) - set_row(++riga, "@8g*** Sottoconto costo/ricavo non valido o non presente in archivio"); - } - - if (_tipod != 0 && _tipod != 1 && _tipod != 3 && _tipod != 9) - set_row(++riga, "@8g--- Tipo indetraibilita' non valido"); -} - -bool TRic_ListaMov::preprocess_page(int file,int counter) -{ - TCursor* cur = current_cursor(); - - if (counter) return TRUE; - - reset_print(); - - if (file == LF_MOV) - { - _anno = cur->curr(LF_MOV).get_int(MOV_ANNOES); - _datacomp = cur->curr(LF_MOV).get_date(MOV_DATACOMP); - _datadoc = cur->curr(LF_MOV).get_date(MOV_DATADOC); - _data74tr = cur->curr(LF_MOV).get_date(MOV_DATA74TER); - _causale = cur->curr(LF_MOV).get(MOV_CODCAUS); - _registro = cur->curr(LF_MOV).get(MOV_REG); - format_if_zero(_registro, 3); - _tipodoc = cur->curr(LF_MOV).get(MOV_TIPODOC); - _numdoc = cur->curr(LF_MOV).get(MOV_NUMDOC); - _datareg = cur->curr(LF_MOV).get_date(MOV_DATAREG); - _codcf = cur->curr(LF_MOV).get_long(MOV_CODCF); - _numero = cur->curr(LF_MOV).get_long(MOV_NUMREG); - _protiva = cur->curr(LF_MOV).get_long(MOV_PROTIVA); - _codval = cur->curr(LF_MOV).get(MOV_CODVALI); - _codpag = cur->curr(LF_MOV).get(MOV_CODPAG); - - _tot_dare = _tot_avere = ZERO; - _tot_doc = ZERO; - - _ae = date2esc(_datareg); - - _num_rec = cur->curr(LF_MOV).get_long(MOV_NUMGIO); - - bool controlla = controlla_mov(); //se TRUE => ci sono errori nella testata - bool verifica = (controlla_rmov() || controlla_riva()); - - if ( (_controllo == 1 && controlla) || _controllo == 2 || - (_controllo == 1 && verifica) ) - { - TString16 datareg_str = _datareg.string(); - // "Fai vedere lo stesso ..-..-.... anche se non c'e' la data..." - if (datareg_str.empty()) - datareg_str = " - - "; - TString16 datadoc_str = _datadoc.string(); - if (datadoc_str.empty()) - datadoc_str = " - - "; - int r = 1; - set_row(r++, ""); - set_row(r,"Operazione n. %-7ld", _numero); - set_row(r," del %s", (const char*)datareg_str); - set_row(r," doc. n. %-7s", (const char*)_numdoc); - set_row(r," del %s", (const char*)datadoc_str); - if (!_registro.blank()) //e' una fattura - { - set_row(r," registro IVA %-3s", (const char*)_registro); - set_row(r," protocollo n. %-5ld", _protiva); - } - set_row(r, " comp. %d", _anno); - - stampa_errori_mov(r); - - return TRUE; - } - return FALSE; - } - else if (file == LF_RMOV) - { - _gruppo = cur->curr(LF_RMOV).get_int(RMV_GRUPPO); - _conto = cur->curr(LF_RMOV).get_int(RMV_CONTO); - _sottoconto = cur->curr(LF_RMOV).get_long(RMV_SOTTOCONTO); - _gruppoc = cur->curr(LF_RMOV).get_int(RMV_GRUPPOC); - _contoc = cur->curr(LF_RMOV).get_int(RMV_CONTOC); - _sottocontoc = cur->curr(LF_RMOV).get_long(RMV_SOTTOCONTOC); - _importo = cur->curr(LF_RMOV).get_real(RMV_IMPORTO); - _sezione = cur->curr(LF_RMOV).get(RMV_SEZIONE)[0]; - TString80 descr = cur->curr(LF_RMOV).get(RMV_DESCR); - int numrig = cur->curr(LF_RMOV).get_int(RMV_NUMRIG); - - _tipo_conto = ""; - - if (_gruppo != 0 && _conto != 0 && _sottoconto != 0l) - _esiste_conto = DescrConto(_gruppo,_conto,_sottoconto); - else - { - _esiste_conto = FALSE; - _descr_conto = ""; - } - int r = 1; - set_row(r, "P%d", numrig); - set_row(r, "@5g%3s %-.20s @30g%-.24s @56g%03d %03d %06ld @71g%-.28s", (const char*) _causale, - (const char*) _descr_causale, (const char*) descr, _gruppo, _conto, _sottoconto, - (const char*) _descr_conto); - if (_sezione == 'D') - set_row(r, "@99g%r", &_importo); - else if (_sezione == 'A') - set_row(r, "@116g%r", &_importo); - else set_row(r, "@107g%r", &_importo); - - stampa_errori_rmov(r); - } - else if (file == LF_RMOVIVA) - { - real impo = cur->curr(LF_RMOVIVA).get_real(RMI_IMPONIBILE); - real impos = cur->curr(LF_RMOVIVA).get_real(RMI_IMPOSTA); - int numrig = cur->curr(LF_RMOVIVA).get_int(RMI_NUMRIG); - _tipocr = cur->curr(LF_RMOVIVA).get_int(RMI_TIPOCR); - _tipod = cur->curr(LF_RMOVIVA).get_int(RMI_TIPODET); - _codiva = cur->curr(LF_RMOVIVA).get(RMI_CODIVA); - _n_rec = cur->curr(LF_RMOVIVA).get_int(RMI_ANNOES); - _gruppocr = cur->curr(LF_RMOVIVA).get_int(RMI_GRUPPO); - _contocr = cur->curr(LF_RMOVIVA).get_int(RMI_CONTO); - _sottocontocr = cur->curr(LF_RMOVIVA).get_long(RMI_SOTTOCONTO); - - TString80 codiva_des(get_codiva_des(_codiva)); - - _tot_doc += impo + impos; - _impo = impo; - _impos = impos; - - if (!_tipodoc.blank()) - { - TTable tabtpd("%TPD"); - tabtpd.put("CODTAB", _tipodoc); - if (tabtpd.read() == NOERR) - { - bool cor = tabtpd.get_bool("B0"); - if (cor) - { - _impo = impo + impos; - _impos = ZERO; - } - } - } - - int r = 1; - set_row(r, "I%d", numrig); - set_row(r, "@5gImponibile %r Imposta %r Codice %4s %-50s %d", - &_impo, &_impos, (const char*) _codiva, (const char*) codiva_des, _tipod); - - stampa_errori_riva(r); - } - return TRUE; -} - -print_action TRic_ListaMov::postprocess_page(int file,int count) -{ - if (count) return NEXT_PAGE; - if (file == LF_MOV) - { - aggiorna_trasfer_Z(); - reset_print(); - _err.reset(); - int n = 1; - if (_tot_dare != _tot_avere) - { - set_row(n++, "@8g*** Il movimento risulta sbilanciato. Totali rilevati:@99g%r@116g%r", - &_tot_dare, &_tot_avere); - return REPEAT_PAGE; - } - } - if (file == LF_RMOVIVA) - aggiorna_trasfer_U(); - - return NEXT_PAGE; -} - -void TRic_ListaMov::postclose_print() -{ - if (_errore_grave) - message_box("Rilevati errori gravi durante il controllo movimenti: \n trasferimento interrotto"); - else - { - TConfig conf (CONFIG_DITTA); - conf.set("FlStTra", "M"); - - TTransfer_file& tr = trasfer(); - _record.overwrite("Z",240); //_record e' letto nella read_control_rec() - const int size = 256; - tr.write_control_rec(_record, size); - } -} - -void TRic_ListaMov::aggiorna_trasfer_Z() -{ - TLocalisamfile& mov = current_cursor()->file(LF_MOV); - - int i=0; - while (_registro[i]=='0' || _registro[i]==' ') i++; - - _registro = ""; - _registro << _registro[i]; - _registro.left_just(3, ' '); - - mov.put(MOV_REG, _registro); - mov.put(MOV_TIPODOC, _tipodoc); - mov.rewrite(); - - TString16 str; - TTransfer_file& tr = trasfer(); - long num = _inizioZ + _num_rec; - if (tr.read_rec_trasfer(num) > 0) - { - //tr.put(_registro, "Z1", 6); - //tr.put(_tipodoc, "Z1", 12); - if (_tiporeg != 0) - { - str = format("%d", _tiporeg); - tr.put(str, "Z1", 26); - } - str = _tot_doc.string(); - tr.put(str, "Z1", 13); - tr.put(_tipo_conto, "Z1", 11); - tr.write(num); - } -} - -void TRic_ListaMov::aggiorna_trasfer_U() -{ - TTransfer_file& tr = trasfer(); - long num = _inizioU + _n_rec; - if (tr.read_rec_trasfer(num) > 0) - { - TString16 str = _impo.string(); - tr.put(str, "U1", 14); - str = _impos.string(); - tr.put(str, "U1", 15); - tr.write(num); - } -} - -bool TRic_ListaMov::user_destroy() -{ - delete _giornale; - delete _trasfer; - delete _rel; - delete _cur; - delete _tmov; - delete _trmov; - delete _tiva; - delete _caus; - delete _ditte; - delete _clifo; - delete _pcon; - delete _tab_tra; - delete _tab_pag; - delete _tab_tpd; - delete _tab_iva; - - return TRUE; -} - -bool TRic_ListaMov::set_print(int m) -{ - TMask msk ("cg2700a"); - - TTransfer_file& tr = trasfer(); - - msk.set(F_NUMERO, tr.nultras()); - msk.set(F_DATALIMITE, tr.dataultras()); - msk.set(F_SDT, look_sdt()); - msk.set(F_SIGLA, tr.ult_file()); - msk.set(F_CHIAVE, tr.key()); - - if (msk.run() != K_ENTER) return FALSE; - - _controllo = msk.get_int(F_LISTA); - - if (_sdt == '*') - fremove(_pathfile); - - setta_parametri(" ", "C"); - - set_real_picture("###.###.###.###"); - - printer().footerlen(5); - - setta_intestazione(); - - _errore_grave = FALSE; - _err.reset(); - _inizioZ = tr.start('Z'); - _inizioU = tr.start('U'); - - return TRUE; -} - -void TRic_ListaMov::setta_intestazione() -{ - int soh = 1; - TString sep(132); - TString ragsoc(50); - - TLocalisamfile nditte(LF_NDITTE); - nditte.zero(); - nditte.put(NDT_CODDITTA, get_firm()); - if (nditte.read() == NOERR) - ragsoc = nditte.get(NDT_RAGSOC); - - reset_header(); - - sep << "Ditta " << get_firm(); - sep << " " << ragsoc; - sep.left_just(132); - - set_header (soh++, (const char*) sep); - - sep = ""; - sep << "Data @< Pag. @#"; - - sep.right_just(127); - - sep.overwrite ("LISTA DI CONTROLLO MOVIMENTI IN TRASFERIMENTO"); - set_header (soh++, (const char*)sep); - sep.fill('-'); - set_header (soh++, (const char *) sep); - set_header (soh++, "Rig Cod.causale @30gDescriz.aggiuntiva @56gCod.conto @71gDescriz.conto @99gDare @116gAvere"); - set_header (soh, (const char *) sep); -} - -void TRic_ListaMov::setta_parametri(const TString& sigla, const TString& flag) -{ - TTransfer_file& tr = trasfer(); - - TConfig conf (CONFIG_DITTA); - conf.set("FlStTra", flag); - - TString rec = tr.record(); - rec.overwrite(sigla,240); - - const int size = 256; - tr.write_control_rec(rec, size); -} - -int cg2700 (int argc, char* argv[]) -{ - TRic_ListaMov a; - a.run(argc, argv,"Lista controllo movimenti"); - return TRUE; -} +// +// Ricezione dati: lista controllo movimenti +// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cg2103.h" +#include "cglib04.h" +#include "cg2700.h" + +HIDDEN const char* err_msg[] = {"*** Data operazione non valida", + "--- Data operazione non compresa in alcun esercizio", + "*** Data competenza non valida", + "--- Data competenza non compresa in alcun esercizio", + "--- Data competenza incompatibile con data operazione", + "*** Data operazione antecedente ad ultima stampa giornale", + "--- Data documento non valida", + "*** Codice causale non valido o non presente in archivio", + "--- Codice pagamento non valido o non presente in tabella", + "*** Codice registro IVA non valido o non presente in tabella", + "*** Codice cliente/fornitore non valido o non presente in anagrafica", + "--- Data 74 ter non valida", + "*** Data operazione antecedente ad ultima stampa registro IVA"}; + +HIDDEN int date2esc(const TDate& d, int* prevesc = NULL); + +class TRic_ListaMov : public TPrintapp +{ + TTable* _tab_tra,* _tab_pag,* _tab_tpd,* _tab_iva; + TIsamtempfile* _tmov,* _trmov,* _tiva; + TLocalisamfile* _caus,* _ditte,* _clifo,* _pcon; + TRelation* _rel; + TCursor* _cur; + TTransfer_file* _trasfer; + TLibro_giornale* _giornale; + TString80 _pathfile, _descr_causale, _descr_conto; + TString16 _causale, _registro, _numdoc, _tipodoc, _codval; + TString16 _codpag, _codiva, _tipo_conto; + TString _record; + bool _mov_sez, _errore_grave, _esiste_conto, _esiste_causale; + char _sdt, _sezione; + int _ae, _anno, _gruppo, _conto, _tipocr, _tipod, _tiporeg; + int _gruppoc, _contoc, _n_rec, _gruppocr, _contocr; + TDate _datacomp, _datadoc, _datareg, _data74tr; + real _importo, _impo, _impos, _tot_dare, _tot_avere, _tot_doc; + long _codcf, _numero, _protiva, _sottoconto; + long _inizioZ, _inizioU, _num_rec, _sottocontoc, _sottocontocr; + TBit_array _err; + byte _controllo; + +public: + virtual bool set_print(int m); + virtual bool user_create() ; + virtual bool user_destroy(); + virtual bool preprocess_page(int,int); + virtual print_action postprocess_page(int,int); + virtual void postclose_print(); + const char* look_sdt(); + const char* get_codiva_des(const char*); + bool DescrConto(int,int,long); + bool check_archivi(TProgind*); + bool look_pag(); + bool errori_partita(int,int,long); + bool controlla_mov(); + bool controlla_rmov(); + bool controlla_riva(); + void stampa_errori_mov(int); + void stampa_errori_rmov(int); + void stampa_errori_riva(int); + void aggiorna_trasfer_Z(); + void aggiorna_trasfer_U(); + void setta_parametri(const TString&, const TString&); + void setta_intestazione(); + TLibro_giornale& giornale() { return *_giornale; } + TTransfer_file& trasfer() { return *_trasfer; } + + TRic_ListaMov(): _err(80) {} + virtual ~TRic_ListaMov() {} +}; + +HIDDEN inline TRic_ListaMov& app() { return (TRic_ListaMov&)main_app();} + +HIDDEN int date2esc(const TDate& d, int* prevesc) +{ + if (prevesc) *prevesc = 0; + TTable esc("ESC"); + for (int err = esc.first(); err == NOERR; err = esc.next()) + { + const TDate ia(esc.get("D0")); // Data inizio esercizio + const TDate fa(esc.get("D1")); // Data fine esercizio + const anno = esc.get_int("CODTAB"); + if (d >= ia && d <= fa) + return anno; + if (prevesc) *prevesc = anno; + } + return 0; +} + +const char* TRic_ListaMov::look_sdt() +{ + TConfig conf(CONFIG_DITTA); + return conf.get("FlStTra"); +} + +bool TRic_ListaMov::look_pag() +{ + TTable t ("%CPG"); + t.zero(); + t.put("CODTAB",_codpag); + if (t.read() != NOERR) return FALSE; + return TRUE; +} + +const char* TRic_ListaMov::get_codiva_des(const char* codiva) +{ + TTable iva ("%IVA"); + + iva.zero(); + iva.put("CODTAB", codiva); + if (iva.read() == NOERR) + return iva.get("S0"); + else + return NULL; +} + +bool TRic_ListaMov::DescrConto(int g, int c, long s) +{ + TString80 ragsoc; + const char* descr = NULL; + TLocalisamfile pconti (LF_PCON); + pconti.setkey(1); + pconti.zero(); + pconti.put(PCN_GRUPPO, g); + pconti.put(PCN_CONTO, c); + pconti.put(PCN_SOTTOCONTO, 0L); + if (pconti.read() == NOERR) + { + _tipo_conto = pconti.get(PCN_TMCF); + if (_tipo_conto == "C" || _tipo_conto == "F") + { + TLocalisamfile clifo (LF_CLIFO); + clifo.setkey(1); + clifo.zero(); + clifo.put(CLI_TIPOCF, _tipo_conto); + clifo.put(CLI_CODCF, s); + if (clifo.read() != NOERR) + { + _descr_conto = ""; + return FALSE; + } + else + { + char tipoa = clifo.get_char("TIPOAPER"); + if (tipoa == 'F') //persona fisica + { + TString80 cognome, nome; + ragsoc = clifo.get("RAGSOC"); + cognome = ragsoc.mid(0,30); + nome = ragsoc.mid(30,20); + cognome.trim(); nome.trim(); + ragsoc = cognome; + ragsoc << " " << nome; + _descr_conto = ragsoc; + } + else _descr_conto = clifo.get("RAGSOC"); + } + } + else + { + pconti.zero(); + pconti.put(PCN_GRUPPO, g); + pconti.put(PCN_CONTO, c); + pconti.put(PCN_SOTTOCONTO, s); + if (pconti.read() != NOERR) + { + _descr_conto = ""; + return FALSE; + } + else _descr_conto = pconti.get(PCN_DESCR); + } + } + else + { + _descr_conto = ""; + return FALSE; + } + return TRUE; +} + +bool TRic_ListaMov::user_create() +{ + _trasfer = new TTransfer_file(); + + TProgind* pnd = NULL; + pnd = new TProgind (3,"Controllo archivi\nPrego attendere", + FALSE, TRUE, 30); + _tab_tra = new TTable ("%TRA"); + _tab_tpd = new TTable ("%TPD"); + _tab_pag = new TTable ("%CPG"); + _tab_iva = new TTable ("%IVA"); + _caus = new TLocalisamfile (LF_CAUSALI); + _ditte = new TLocalisamfile (LF_NDITTE); + _clifo = new TLocalisamfile (LF_CLIFO); + _pcon = new TLocalisamfile (LF_PCON); + + if (pnd) pnd->addstatus(1); + + if (!check_archivi(pnd)) + { + delete pnd; + return FALSE; + } + + if (pnd) pnd->addstatus(1); + + TString80 tmpmov = "%"; + tmpmov << get_firm_dir(); + tmpmov << "\\" << TEMP_MOV; + TString80 tmprmov = "%"; + tmprmov << get_firm_dir(); + tmprmov << "\\" << TEMP_RMOV; + TString80 tmprmoviva = "%"; + tmprmoviva << get_firm_dir(); + tmprmoviva << "\\" << TEMP_RMOVIVA; + + _tmov = new TIsamtempfile(LF_MOV, tmpmov, 0); + _trmov = new TIsamtempfile(LF_RMOV, tmprmov, 0); + _tiva = new TIsamtempfile(LF_RMOVIVA, tmprmoviva, 0); + + _rel = new TRelation(_tmov); + _rel->add(_trmov,"NUMREG=NUMREG",1,0,0,FALSE); + _rel->add(_tiva, "NUMREG=NUMREG",1,0,0,FALSE); + _cur = new TCursor (_rel, "", 1); + + _giornale = new TLibro_giornale(); + + add_cursor(_cur); + + add_file (LF_MOV); + add_file (LF_RMOV, LF_MOV); + add_file (LF_RMOVIVA, LF_MOV); + + printer().footerlen(5); + + delete pnd; + + return TRUE; +} + +bool TRic_ListaMov::check_archivi(TProgind* pnd) +{ + TString80 nome; + long ditta_ric = get_firm(); + + if (!prefix().exist(ditta_ric)) + return error_box("Rilevati errori gravi negli archivi: procedura interrotta"); + + TTransfer_file& tr = trasfer(); + + _pathfile = tr.path(); + + _pathfile = _pathfile << "\\trasfer"; + + if (!tr.open(_pathfile)) + return error_box("Al momento non presenti trasferimenti attivi sulla ditta selezionata"); + + if (!tr.read_control_rec()) + return error_box("Rilevati errori gravi negli archivi: procedura interrotta"); + else _record = tr.record(); + + TString16 sd = look_sdt(); + + if (sd.not_empty()) + _sdt = sd[0]; + else return error_box("Ricezione tabelle non effettuata: richiamare il programma relativo"); + + if (_sdt == 'T') + return error_box("Ricezione tabelle non effettuata: richiamare il programma relativo"); + + if (_sdt == 'M') + return yesno_box("Controllo gia' effettuato: si desidera ripeterlo ?"); + + if (_sdt != '*' && _sdt != 'C') + return error_box("Rilevati errori gravi negli archivi: procedura interrotta"); + + TString16 ult = tr.ult_file(); + TString16 key = tr.key(); + + ult.strip_spaces(); + key.strip_spaces(); + + if (_sdt == 'C') + if ( ult.not_empty() || key.not_empty() ) + return error_box("Rilevati errori gravi negli archivi: procedura interrotta"); + + if (_sdt == '*') + return warning_box("Trasferimento interamente completato: proseguire per cancellare i file"); + + if (pnd) pnd->addstatus(1); + + return TRUE; +} + +void TRic_ListaMov::stampa_errori_mov(int riga) +{ + long i = _err.first_one(); + if (i != -1) + { + for (; i <= _err.last_one(); i++) + if (_err[i]) + set_row(++riga, "@8g%s", (const char*) err_msg[i]); + } +} + +bool TRic_ListaMov::controlla_mov() +{ + bool check_reg = TRUE; + TString16 causreg; + TDate udata; + char tipocf; + + _tiporeg = 0; + + if (!_datareg.ok()) + { + _errore_grave = TRUE; + _err.set(0L); + } + + if (_datareg.ok()) + { + int pr; + const int ar = date2esc(_datareg, &pr); // Esercizio in corso + if (ar == 0) + _err.set(1); + if (_datacomp.ok()) + { + const int ae = date2esc(_datacomp); + if (ae == 0) + _err.set(3); + else if (ae != ar && ae != pr && ar) + _err.set(4); + } + } + + if (!_datacomp.ok()) + { + _errore_grave = TRUE; + _err.set(2); + } + + TLibro_giornale& gio = giornale(); + bool ok = gio.read(_ae); //se _ae e' zero la read considera come anno quello corrente + if (_datareg < gio.last_print()) + { + _errore_grave = TRUE; + _err.set(5); + } + + TString16 dd = _datadoc.string(); + if (dd.not_empty()) + if (!_datadoc.ok()) + _err.set(6); + + //if (_causale.not_empty()) + //{ + TLocalisamfile caus(LF_CAUSALI); + caus.setkey(1); + caus.zero(); + caus.put(CAU_CODCAUS,_causale); + if (caus.read() == NOERR) + { + _esiste_causale = TRUE; + _tipodoc = caus.get(CAU_TIPODOC); + } + else + { + caus.zero(); + _esiste_causale = FALSE; + if (look_causale(_causale)) //se la causale e' significativa + { + _errore_grave = TRUE; + _err.set(7); + } + } + //_tipodoc = caus.get(CAU_TIPODOC); ho sempre quello letto sul movimento! + causreg = caus.get(CAU_REG); + _descr_causale = caus.get(CAU_DESCR); + _mov_sez = caus.get_bool(CAU_MOVSEZ); + //} + + if (!_codpag.blank()) + { + bool ok = look_pag(); + if (!ok) + _err.set(8); + } + + if (!_registro.blank()) //movimento iva (fattura) + { + if (!look_causale(_causale)) //se la causale non e' significativa + { + _errore_grave = TRUE; + check_reg = FALSE; + _err.set(9); + } + if (check_reg && _ae) + { + TRegistro rg (_registro, _ae); + if (rg.name().empty()) + { + _errore_grave = TRUE; + check_reg = FALSE; + _err.set(9); + } + else + { + _tiporeg = rg.tipo(); + udata = rg.last_print(); + } + } + } + else if (!causreg.blank() && _ae) + { + TRegistro rg (causreg, _ae); + if (rg.name().empty()) + { + _errore_grave = TRUE; + check_reg = FALSE; + _err.set(9); + } + else + { + _tiporeg = rg.tipo(); + udata = rg.last_print(); + } + _registro = causreg; + } + + if (check_reg && !_registro.blank()) + { + if (_tiporeg == 1) tipocf = 'C'; + else if (_tiporeg == 2) tipocf = 'F'; + if (_tiporeg != 0 && !_tipodoc.blank()) //se esiste, uso quello della causale!!! + { + TTable tabtpd("%TPD"); + tabtpd.put("CODTAB", _tipodoc); + if (tabtpd.read() == NOERR) + { + bool cor = tabtpd.get_bool("B0"); + if (!cor) + if (_codcf != 0l) + { + TLocalisamfile clifo(LF_CLIFO); + clifo.zero(); + clifo.put(CLI_CODCF, _codcf); + clifo.put(CLI_TIPOCF,tipocf); + if (clifo.read() != NOERR) + { + _errore_grave = TRUE; + _err.set(10); + } + } + else + { + _errore_grave = TRUE; + _err.set(10); + } + } + } + } + + TString16 d74 = _data74tr.string(); + if (d74.not_empty()) + if (!_data74tr.ok()) + _err.set(11); + + if (!_registro.blank() && check_reg) + if (_datareg < udata) + { + _errore_grave = TRUE; + _err.set(12); + } + + if (_err.ones()) + return TRUE; + + return FALSE; +} + +bool TRic_ListaMov::errori_partita(int g, int c, long s) +{ + TLocalisamfile pconti (LF_PCON); + pconti.setkey(1); + pconti.zero(); + pconti.put(PCN_GRUPPO, g); + pconti.put(PCN_CONTO, c); + pconti.put(PCN_SOTTOCONTO, 0L); + if (pconti.read() == NOERR) + { + char tipo = pconti.get(PCN_TMCF)[0]; + if (tipo == 'C' || tipo == 'F') + { + TLocalisamfile clifo (LF_CLIFO); + clifo.setkey(1); + clifo.zero(); + clifo.put(CLI_TIPOCF, tipo); + clifo.put(CLI_CODCF, s); + if (clifo.read() != NOERR) + return FALSE; + } + else + { + pconti.zero(); + pconti.put(PCN_GRUPPO, g); + pconti.put(PCN_CONTO, c); + pconti.put(PCN_SOTTOCONTO, s); + if (pconti.read() != NOERR) + return FALSE; + } + } + else return FALSE; + + return TRUE; +} + +bool TRic_ListaMov::controlla_rmov() +{ + TLocalisamfile& rmov = current_cursor()->file(LF_RMOV); + int gruppo, conto, gruppoc, contoc; + long sottoconto, sottocontoc; + char sezione; + real importo, dare, avere; + + if (current_cursor()->is_first_match(LF_RMOV)) + { + dare = avere = ZERO; + TRecnotype nrec = rmov.recno(); + rmov.zero(); + rmov.setkey(1); + rmov.put(RMV_NUMREG, _numero); + TRectype recc (rmov.curr()); + for (rmov.read(_isgteq); !rmov.eof() ;rmov.next()) + { + TRectype rec (rmov.curr()); + if (rec > recc) break; + gruppo = rec.get_int(RMV_GRUPPO); + conto = rec.get_int(RMV_CONTO); + sottoconto = rec.get_long(RMV_SOTTOCONTO); + gruppoc = rec.get_int(RMV_GRUPPOC); + contoc = rec.get_int(RMV_CONTOC); + sottocontoc = rec.get_long(RMV_SOTTOCONTOC); + sezione = rec.get_char(RMV_SEZIONE); + importo = rec.get_real(RMV_IMPORTO); + + if (sezione == 'D') + dare += importo; + if (sezione == 'A') + avere += importo; + + if (gruppo == 0 || conto == 0 || sottoconto == 0l) + { + rmov.readat(nrec); + return TRUE; + } + else + { + bool ok = errori_partita(gruppo,conto,sottoconto); + if (!ok) + { + rmov.readat(nrec); + return TRUE; + } + } + + if ( (importo == ZERO && sezione != ' ') || + (sezione != 'D' && sezione != 'A') ) + { + rmov.readat(nrec); + return TRUE; + } + + /* + if (gruppoc == 0 || contoc == 0 || sottocontoc == 0l) + { + rmov.readat(nrec); + return TRUE; + } + else + */ + if (gruppoc != 0 || contoc != 0 || sottocontoc != 0l) + { + bool ok = errori_partita(gruppoc,contoc,sottocontoc); + if (!ok) + { + rmov.readat(nrec); + return TRUE; + } + } + + if (_esiste_causale) + if (!_mov_sez && importo == ZERO) + { + rmov.readat(nrec); + return TRUE; + } + } + if (dare != avere) + { + rmov.readat(nrec); + return TRUE; + } + rmov.readat(nrec); + } + return FALSE; +} + +void TRic_ListaMov::stampa_errori_rmov(int riga) +{ + if (_gruppo == 0 || _conto == 0 || _sottoconto == 0l) + { + _errore_grave = TRUE; + set_row(++riga, "@8g*** Sottoconto partita non valido o non presente in archivio"); + } + else + { + if (!_esiste_conto) + { + _errore_grave = TRUE; + set_row(++riga, "@8g*** Sottoconto partita non valido o non presente in archivio"); + } + } + + if ( (_importo == ZERO && _sezione != ' ') || + (_sezione != 'D' && _sezione != 'A') ) + { + _errore_grave = TRUE; + set_row(++riga, "@8g*** Segnale dare/avere non valido"); + } + + if (_sezione == 'D') + _tot_dare += _importo; + if (_sezione == 'A') + _tot_avere += _importo; + + if (_gruppoc != 0 || _contoc != 0 || _sottocontoc != 0l) + // set_row(++riga, "@8g*** Sottoconto contropartita non valido o non presente in archivio"); + // else + { + bool ok = errori_partita(_gruppoc,_contoc,_sottocontoc); + if (!ok) + { + _errore_grave = TRUE; + set_row(++riga, "@8g*** Sottoconto contropartita non valido o non presente in archivio"); + } + } + + if (_esiste_causale) + if (!_mov_sez && _importo == ZERO) + set_row(++riga, "@8g--- Importo riga uguale a zero"); +} + +bool TRic_ListaMov::controlla_riva() +{ + TLocalisamfile& rmoviva = current_cursor()->file(LF_RMOVIVA); + TTable tab_iva("%IVA"); + TString16 codiva; + int tipodet, tipocr, gruppocr, contocr; + long sottocontocr; + + if (current_cursor()->is_first_match(LF_RMOVIVA)) + { + TRecnotype nrec = rmoviva.recno(); + rmoviva.setkey(1); + rmoviva.zero(); + rmoviva.put(RMI_NUMREG, _numero); + TRectype recc (rmoviva.curr()); + for (rmoviva.read(_isgteq); !rmoviva.eof() ;rmoviva.next()) + { + TRectype rec (rmoviva.curr()); + if (rec > recc) break; + codiva = rec.get(RMI_CODIVA); + tipodet = rec.get_int(RMI_TIPODET); + tipocr = rec.get_int(RMI_TIPOCR); + gruppocr = rec.get_int(RMI_GRUPPO); + contocr = rec.get_int(RMI_CONTO); + sottocontocr = rec.get_long(RMI_SOTTOCONTO); + + TTable iva ("%IVA"); + iva.zero(); + iva.put("CODTAB", codiva); + if (iva.read() != NOERR) + { + rmoviva.readat(nrec); + return TRUE; + } + if (!(tipocr >= 0 && tipocr <= 9)) + { + rmoviva.readat(nrec); + return TRUE; + } + /* + if (gruppocr != 0 || contocr != 0 || sottocontocr != 0l) + { + bool ok = errori_partita(gruppocr,contocr,sottocontocr); + if (!ok) + { + rmoviva.readat(nrec); + return TRUE; + } + } + */ + if (gruppocr == 0 || contocr == 0 || sottocontocr == 0l) + { + rmoviva.readat(nrec); + return TRUE; + } + else if (gruppocr != 0 && contocr != 0 && sottocontocr != 0l) + { + bool ok = errori_partita(gruppocr,contocr,sottocontocr); + if (!ok) + { + rmoviva.readat(nrec); + return TRUE; + } + } + if (tipodet != 0 && tipodet != 1 && tipodet != 3 && tipodet != 9) + { + rmoviva.readat(nrec); + return TRUE; + } + } + rmoviva.readat(nrec); + } + return FALSE; +} + +void TRic_ListaMov::stampa_errori_riva(int riga) +{ + TTable iva ("%IVA"); + + iva.zero(); + iva.put("CODTAB", _codiva); + if (iva.read() != NOERR) + set_row(++riga, "@8g--- Codice IVA non valido o non presente in tabella"); + + if (!(_tipocr >= 0 && _tipocr <= 9)) + set_row(++riga, "@8g--- Tipo costo/ricavo non valido"); + + if (_gruppocr == 0 || _contocr == 0 || _sottocontocr == 0l) + { + _errore_grave = TRUE; + set_row(++riga, "@8g*** Sottoconto costo/ricavo non valido o non presente in archivio"); + } + else if (_gruppocr != 0 && _contocr != 0 && _sottocontocr != 0l) + { + bool ok = errori_partita(_gruppocr,_contocr,_sottocontocr); + if (!ok) + { + _errore_grave = TRUE; + set_row(++riga, "@8g*** Sottoconto costo/ricavo non valido o non presente in archivio"); + } + } + + if (_tipod != 0 && _tipod != 1 && _tipod != 3 && _tipod != 9) + set_row(++riga, "@8g--- Tipo indetraibilita' non valido"); +} + +bool TRic_ListaMov::preprocess_page(int file,int counter) +{ + TCursor* cur = current_cursor(); + + if (counter) return TRUE; + + reset_print(); + + if (file == LF_MOV) + { + _anno = cur->curr(LF_MOV).get_int(MOV_ANNOES); + _datacomp = cur->curr(LF_MOV).get_date(MOV_DATACOMP); + _datadoc = cur->curr(LF_MOV).get_date(MOV_DATADOC); + _data74tr = cur->curr(LF_MOV).get_date(MOV_DATA74TER); + _causale = cur->curr(LF_MOV).get(MOV_CODCAUS); + _registro = cur->curr(LF_MOV).get(MOV_REG); + format_if_zero(_registro, 3); + _tipodoc = cur->curr(LF_MOV).get(MOV_TIPODOC); + _numdoc = cur->curr(LF_MOV).get(MOV_NUMDOC); + _datareg = cur->curr(LF_MOV).get_date(MOV_DATAREG); + _codcf = cur->curr(LF_MOV).get_long(MOV_CODCF); + _numero = cur->curr(LF_MOV).get_long(MOV_NUMREG); + _protiva = cur->curr(LF_MOV).get_long(MOV_PROTIVA); + _codval = cur->curr(LF_MOV).get(MOV_CODVALI); + _codpag = cur->curr(LF_MOV).get(MOV_CODPAG); + + _tot_dare = _tot_avere = ZERO; + _tot_doc = ZERO; + + _ae = date2esc(_datareg); + + _num_rec = cur->curr(LF_MOV).get_long(MOV_NUMGIO); + + bool controlla = controlla_mov(); //se TRUE => ci sono errori nella testata + bool verifica = (controlla_rmov() || controlla_riva()); + + if ( (_controllo == 1 && controlla) || _controllo == 2 || + (_controllo == 1 && verifica) ) + { + TString16 datareg_str = _datareg.string(); + // "Fai vedere lo stesso ..-..-.... anche se non c'e' la data..." + if (datareg_str.empty()) + datareg_str = " - - "; + TString16 datadoc_str = _datadoc.string(); + if (datadoc_str.empty()) + datadoc_str = " - - "; + int r = 1; + set_row(r++, ""); + set_row(r,"Operazione n. %-7ld", _numero); + set_row(r," del %s", (const char*)datareg_str); + set_row(r," doc. n. %-7s", (const char*)_numdoc); + set_row(r," del %s", (const char*)datadoc_str); + if (!_registro.blank()) //e' una fattura + { + set_row(r," registro IVA %-3s", (const char*)_registro); + set_row(r," protocollo n. %-5ld", _protiva); + } + set_row(r, " comp. %d", _anno); + + stampa_errori_mov(r); + + return TRUE; + } + return FALSE; + } + else if (file == LF_RMOV) + { + _gruppo = cur->curr(LF_RMOV).get_int(RMV_GRUPPO); + _conto = cur->curr(LF_RMOV).get_int(RMV_CONTO); + _sottoconto = cur->curr(LF_RMOV).get_long(RMV_SOTTOCONTO); + _gruppoc = cur->curr(LF_RMOV).get_int(RMV_GRUPPOC); + _contoc = cur->curr(LF_RMOV).get_int(RMV_CONTOC); + _sottocontoc = cur->curr(LF_RMOV).get_long(RMV_SOTTOCONTOC); + _importo = cur->curr(LF_RMOV).get_real(RMV_IMPORTO); + _sezione = cur->curr(LF_RMOV).get(RMV_SEZIONE)[0]; + TString80 descr = cur->curr(LF_RMOV).get(RMV_DESCR); + int numrig = cur->curr(LF_RMOV).get_int(RMV_NUMRIG); + + _tipo_conto = ""; + + if (_gruppo != 0 && _conto != 0 && _sottoconto != 0l) + _esiste_conto = DescrConto(_gruppo,_conto,_sottoconto); + else + { + _esiste_conto = FALSE; + _descr_conto = ""; + } + int r = 1; + set_row(r, "P%d", numrig); + set_row(r, "@5g%3s %-.20s @30g%-.24s @56g%03d %03d %06ld @71g%-.28s", (const char*) _causale, + (const char*) _descr_causale, (const char*) descr, _gruppo, _conto, _sottoconto, + (const char*) _descr_conto); + if (_sezione == 'D') + set_row(r, "@99g%r", &_importo); + else if (_sezione == 'A') + set_row(r, "@116g%r", &_importo); + else set_row(r, "@107g%r", &_importo); + + stampa_errori_rmov(r); + } + else if (file == LF_RMOVIVA) + { + real impo = cur->curr(LF_RMOVIVA).get_real(RMI_IMPONIBILE); + real impos = cur->curr(LF_RMOVIVA).get_real(RMI_IMPOSTA); + int numrig = cur->curr(LF_RMOVIVA).get_int(RMI_NUMRIG); + _tipocr = cur->curr(LF_RMOVIVA).get_int(RMI_TIPOCR); + _tipod = cur->curr(LF_RMOVIVA).get_int(RMI_TIPODET); + _codiva = cur->curr(LF_RMOVIVA).get(RMI_CODIVA); + _n_rec = cur->curr(LF_RMOVIVA).get_int(RMI_ANNOES); + _gruppocr = cur->curr(LF_RMOVIVA).get_int(RMI_GRUPPO); + _contocr = cur->curr(LF_RMOVIVA).get_int(RMI_CONTO); + _sottocontocr = cur->curr(LF_RMOVIVA).get_long(RMI_SOTTOCONTO); + + TString80 codiva_des(get_codiva_des(_codiva)); + + _tot_doc += impo + impos; + _impo = impo; + _impos = impos; + + if (!_tipodoc.blank()) + { + TTable tabtpd("%TPD"); + tabtpd.put("CODTAB", _tipodoc); + if (tabtpd.read() == NOERR) + { + bool cor = tabtpd.get_bool("B0"); + if (cor) + { + _impo = impo + impos; + _impos = ZERO; + } + } + } + + int r = 1; + set_row(r, "I%d", numrig); + set_row(r, "@5gImponibile %r Imposta %r Codice %4s %-50s %d", + &_impo, &_impos, (const char*) _codiva, (const char*) codiva_des, _tipod); + + stampa_errori_riva(r); + } + return TRUE; +} + +print_action TRic_ListaMov::postprocess_page(int file,int count) +{ + if (count) return NEXT_PAGE; + if (file == LF_MOV) + { + aggiorna_trasfer_Z(); + reset_print(); + _err.reset(); + int n = 1; + if (_tot_dare != _tot_avere) + { + _errore_grave = TRUE; + set_row(n++, "@8g*** Il movimento risulta sbilanciato. Totali rilevati:@99g%r@116g%r", + &_tot_dare, &_tot_avere); + return REPEAT_PAGE; + } + } + if (file == LF_RMOVIVA) + aggiorna_trasfer_U(); + + return NEXT_PAGE; +} + +void TRic_ListaMov::postclose_print() +{ + if (_errore_grave) + message_box("Rilevati errori gravi durante il controllo movimenti: \n trasferimento interrotto"); + else + { + TConfig conf (CONFIG_DITTA); + conf.set("FlStTra", "M"); + + TTransfer_file& tr = trasfer(); + _record.overwrite("Z",240); //_record e' letto nella read_control_rec() + const int size = 256; + tr.write_control_rec(_record, size); + } +} + +void TRic_ListaMov::aggiorna_trasfer_Z() +{ + TLocalisamfile& mov = current_cursor()->file(LF_MOV); + + int i=0; + while (_registro[i]=='0' || _registro[i]==' ') i++; + + _registro = ""; + _registro << _registro[i]; + _registro.left_just(3, ' '); + + mov.put(MOV_REG, _registro); + mov.put(MOV_TIPODOC, _tipodoc); + mov.rewrite(); + + TString16 str; + TTransfer_file& tr = trasfer(); + long num = _inizioZ + _num_rec; + if (tr.read_rec_trasfer(num) > 0) + { + //tr.put(_registro, "Z1", 6); + //tr.put(_tipodoc, "Z1", 12); + if (_tiporeg != 0) + { + str = format("%d", _tiporeg); + tr.put(str, "Z1", 26); + } + str = _tot_doc.string(); + tr.put(str, "Z1", 13); + tr.put(_tipo_conto, "Z1", 11); + tr.write(num); + } +} + +void TRic_ListaMov::aggiorna_trasfer_U() +{ + TTransfer_file& tr = trasfer(); + long num = _inizioU + _n_rec; + if (tr.read_rec_trasfer(num) > 0) + { + TString16 str = _impo.string(); + tr.put(str, "U1", 14); + str = _impos.string(); + tr.put(str, "U1", 15); + tr.write(num); + } +} + +bool TRic_ListaMov::user_destroy() +{ + delete _giornale; + delete _trasfer; + delete _rel; + delete _cur; + delete _tmov; + delete _trmov; + delete _tiva; + delete _caus; + delete _ditte; + delete _clifo; + delete _pcon; + delete _tab_tra; + delete _tab_pag; + delete _tab_tpd; + delete _tab_iva; + + return TRUE; +} + +bool TRic_ListaMov::set_print(int m) +{ + TMask msk ("cg2700a"); + + TTransfer_file& tr = trasfer(); + + msk.set(F_NUMERO, tr.nultras()); + msk.set(F_DATALIMITE, tr.dataultras()); + msk.set(F_SDT, look_sdt()); + msk.set(F_SIGLA, tr.ult_file()); + msk.set(F_CHIAVE, tr.key()); + + if (msk.run() != K_ENTER) return FALSE; + + _controllo = msk.get_int(F_LISTA); + + if (_sdt == '*') + fremove(_pathfile); + + setta_parametri(" ", "C"); + + set_real_picture("###.###.###.###"); + + printer().footerlen(5); + + setta_intestazione(); + + _errore_grave = FALSE; + _err.reset(); + _inizioZ = tr.start('Z'); + _inizioU = tr.start('U'); + + return TRUE; +} + +void TRic_ListaMov::setta_intestazione() +{ + int soh = 1; + TString sep(132); + TString ragsoc(50); + + TLocalisamfile nditte(LF_NDITTE); + nditte.zero(); + nditte.put(NDT_CODDITTA, get_firm()); + if (nditte.read() == NOERR) + ragsoc = nditte.get(NDT_RAGSOC); + + reset_header(); + + sep << "Ditta " << get_firm(); + sep << " " << ragsoc; + sep.left_just(132); + + set_header (soh++, (const char*) sep); + + sep = ""; + sep << "Data @< Pag. @#"; + + sep.right_just(127); + + sep.overwrite ("LISTA DI CONTROLLO MOVIMENTI IN TRASFERIMENTO"); + set_header (soh++, (const char*)sep); + sep.fill('-'); + set_header (soh++, (const char *) sep); + set_header (soh++, "Rig Cod.causale @30gDescriz.aggiuntiva @56gCod.conto @71gDescriz.conto @99gDare @116gAvere"); + set_header (soh, (const char *) sep); +} + +void TRic_ListaMov::setta_parametri(const TString& sigla, const TString& flag) +{ + TTransfer_file& tr = trasfer(); + + TConfig conf (CONFIG_DITTA); + conf.set("FlStTra", flag); + + TString rec = tr.record(); + rec.overwrite(sigla,240); + + const int size = 256; + tr.write_control_rec(rec, size); +} + +int cg2700 (int argc, char* argv[]) +{ + TRic_ListaMov a; + a.run(argc, argv,"Lista controllo movimenti"); + return TRUE; +} diff --git a/cg/cg2800.cpp b/cg/cg2800.cpp index 1e61cdbf3..d1f6b15ea 100755 --- a/cg/cg2800.cpp +++ b/cg/cg2800.cpp @@ -24,6 +24,7 @@ #include "cg2800.h" #include "cg2801.h" #include "cg2802.h" +#include "cg2803.h" HIDDEN TString80 TEMP; @@ -907,8 +908,9 @@ bool TVar_mov::controllo_contropartita(TMask_field& f, KEY k) f.mask().set(F_DESCRCPARTITA, descr); if (k == K_ENTER) - if (!tc.find()) - return warning_box("Sottoconto contropartita non presente in anagrafica Piano dei Conti oppure anagrafica Clienti / Fornitori"); + if (gruppo != 0 && conto != 0 && sottoc != 0) + if (!tc.find()) + return warning_box("Sottoconto contropartita non presente in anagrafica Piano dei Conti oppure anagrafica Clienti / Fornitori"); } return TRUE; @@ -1468,7 +1470,12 @@ break; a.run(argc, argv,"Annullamento movimenti da ricevere"); } break; - + case 'V': +{ + TVis_ric a; + a.run(argc, argv,"Visualizzazione stato ricezione"); +} +break; default: break; } diff --git a/cg/cg2802b.uml b/cg/cg2802b.uml index 0d2f18551..d81f98c9f 100755 --- a/cg/cg2802b.uml +++ b/cg/cg2802b.uml @@ -4,7 +4,7 @@ TOOLBAR "" 0 20 0 2 BUTTON DLG_SAVEREC 10 2 BEGIN -PROMPT -15 -1 "~Registra" +PROMPT -15 -1 "~Annulla" MESSAGE EXIT,K_SAVE END diff --git a/cg/cg2803.cpp b/cg/cg2803.cpp new file mode 100755 index 000000000..ac57852f0 --- /dev/null +++ b/cg/cg2803.cpp @@ -0,0 +1,321 @@ +#include "cglib04.h" +#include "cg2803.h" + +HIDDEN TVis_ric& app() { return (TVis_ric &) main_app(); } + +const char* TVis_ric::riconverti (TString& data_PC) +{ + TP = data_PC.mid(8,2); + TP << data_PC.mid(3,2); + TP << data_PC.mid(0,2); + return TP; +} + +bool TVis_ric::create() +{ + TApplication::create(); + + _tab_tra = new TTable ("%TRA"); + + _registra = FALSE; + _ftrasfer = TRUE; + + dispatch_e_menu (BAR_ITEM(1)); + + return TRUE; +} + +bool TVis_ric::destroy() +{ + delete _tab_tra; + + return TApplication::destroy(); +} + +bool TVis_ric::baipassa(TMask& m, KEY k) +{ + if (k == K_SHIFT+K_F12) + { + m.enable(F_NULTRAS); + m.enable(F_DATAULTRAS); + m.enable(F_STD); + m.enable(F_USELAB); + m.enable(F_STATO); + m.enable(F_AGGCAUSALI); + m.enable(F_AGGCLIFO); + m.enable(F_AGGPCON); + m.enable(F_AGGIVD); + m.enable(F_FATTEM); + m.enable(F_FATTRIC); + + app()._registra = TRUE; + } + + return TRUE; +} + +bool TVis_ric::stato_hnd (TMask_field& f, KEY k) +{ + if (k == K_ENTER) + { + TString std = f.get(); + TString uselab = f.mask().get(F_USELAB); + TString chiave = f.mask().get(F_STATO); + + if (!app()._ftrasfer) + { + if (std != "") + return warning_box("Valore non valido per stato ultima ricezione"); + } + else + { + if (std != "" && std != "T" && std != "C" && std != "M" && std != "*") + return warning_box("Valore non valido per stato ultima ricezione"); + + if (uselab != "" && (std == "" || std == "C" || std == "*") ) + return warning_box("Valore non valido per stato ultima ricezione"); + + if (chiave != "" && (std == "" || std == "C" || std == "*") ) + return warning_box("Valore non valido per stato ultima ricezione"); + + } + } + return TRUE; +} + +bool TVis_ric::uselab_hnd (TMask_field& f, KEY k) +{ + if (k == K_ENTER) + { + TString std = f.mask().get(F_STD); + TString uselab = f.get(); + + if (std == "" && uselab != "") + return warning_box("Lo stato ultima ricezione non e' significativo: la sigla ultimo file elaborato non puo' essere significativa"); + } + return TRUE; +} + +bool TVis_ric::chiave_hnd (TMask_field& f, KEY k) +{ + if (k == K_ENTER) + { + TString std = f.mask().get(F_STD); + TString uselab = f.mask().get(F_USELAB); + TString chiave = f.get(); + + if (std == "" && chiave != "") + return warning_box("Lo stato ultima ricezione non e' significativo: la chiave ultimo file elaborato non puo' essere significativa"); + + if (uselab == "" && chiave != "") + return warning_box("La sigla ultimo file elaborato non e' significativo: la chiave ultimo file elaborato non puo' essere significativa"); + } + return TRUE; +} + +bool TVis_ric::video() +{ + TDate dataultras; + + if (!esegui_controlli()) + return FALSE; + + TMask msk ("cg2803a"); + KEY tasto; + + ditta_ricevente(); + + setta_campi_video(msk); + + msk.set_handler(baipassa); + msk.set_handler(F_STD, stato_hnd); + msk.set_handler(F_USELAB, uselab_hnd); + msk.set_handler(F_STATO, chiave_hnd); + + tasto = msk.run(); + + if (tasto != K_ENTER) + return FALSE; + + registra(msk); + + return FALSE; +} + +void TVis_ric::setta_campi_video(TMask& msk) +{ + if (_ftrasfer) + { + msk.set(F_CODDITTARIC, _dittaric); + msk.set(F_RAGSOC, _ragsoc_dittar); + msk.set(F_NULTRAS, _nultras); + + if (_nultras != 0) + { + TString data1 = _dataultras.string(); + msk.set(F_DATAULTRAS, data1); + } + msk.set(F_USELAB, _uselab); + msk.set(F_STATO, _key); + msk.set(F_AGGCAUSALI, _agg_cau); + msk.set(F_AGGCLIFO, _agg_clifo); + msk.set(F_AGGPCON, _agg_pcon); + msk.set(F_AGGIVD, _agg_IVdir); + msk.set(F_FATTEM, _riatt_att); + msk.set(F_FATTRIC, _riatt_pas); + } + + msk.set(F_STD, _std); + + msk.disable(F_CODDITTARIC); + msk.disable(F_RAGSOC); + msk.disable(F_NULTRAS); + msk.disable(F_DATAULTRAS); + msk.disable(F_STD); + msk.disable(F_USELAB); + msk.disable(F_STATO); + msk.disable(F_AGGCAUSALI); + msk.disable(F_AGGCLIFO); + msk.disable(F_AGGPCON); + msk.disable(F_AGGIVD); + msk.disable(F_FATTEM); + msk.disable(F_FATTRIC); +} + +void TVis_ric::registra(TMask& m) +{ + if (_registra) + { + TString str; + + str = m.get(F_NULTRAS); + TString nultras = format("%03s", (const char*) str); + str = m.get(F_DATAULTRAS); + TString datault = riconverti(str); + char agg_cau = m.get(F_AGGCAUSALI)[0]; + char agg_clf = m.get(F_AGGCLIFO)[0]; + char agg_pco = m.get(F_AGGPCON)[0]; + char agg_IV = m.get(F_AGGIVD)[0]; + char riat_at = m.get(F_FATTEM)[0]; + char riat_pa = m.get(F_FATTRIC)[0]; + + TString flags (7); + flags[0] = agg_IV; + flags[1] = agg_cau; + flags[2] = agg_clf; + flags[3] = agg_pco; + flags[4] = riat_at; + flags[5] = riat_pa; + flags[6] = '\0'; + + TString uselab = m.get(F_USELAB); + str = m.get(F_STATO); + TString chiave = format("%-15s", (const char*) str); + + _control_rec.overwrite(nultras,29); + _control_rec.overwrite(datault,32); + _control_rec.overwrite(flags,234); + _control_rec.overwrite(uselab,240); + _control_rec.overwrite(chiave,241); + + const int size = 256; + + _tras_file.write_control_rec(_control_rec, size); + + TString std = m.get(F_STD); + + setta_std(std); + } +} + +void TVis_ric::setta_std(const TString& flag) +{ + TConfig conf (CONFIG_DITTA); + + conf.set("FlStTra", flag); +} + +void TVis_ric::ditta_ricevente() +{ + TLocalisamfile nditte (LF_NDITTE); + + nditte.setkey(1); + nditte.zero(); + nditte.put(NDT_CODDITTA, _dittaric); + if (nditte.read() == NOERR) + _ragsoc_dittar = nditte.get(NDT_RAGSOC); +} + +long TVis_ric::leggi_tabella_tras() +{ + TString dep; + long ditta = 0; + + _tab_tra->zero(); + dep = format("%10s%05d", (const char*) _nomeid, _dittainv); + _tab_tra->put("CODTAB", (const char*) dep); + if (_tab_tra->read() == NOERR) + ditta = _tab_tra->get_long("I0"); + + return ditta; +} + +bool TVis_ric::leggi_trasfer() +{ + TString data,tmp; + + _trasf = _tras_file.path(_dittaric); + _trasf << "\\trasfer"; + + _tras_file.open(_trasf); + + if (_tras_file.exist()) + { + if (_tras_file.read_control_rec()) + { + _control_rec = _tras_file.record(); + _nomeid = _control_rec.sub(15,25); + _dittainv = _control_rec.sub(25,29); + _nultras = _tras_file.nultras(); + _dataultras = _tras_file.dataultras(); + _uselab = _tras_file.ult_file(); + _key = _tras_file.key(); + _agg_cau = _control_rec.sub(235,236); + _agg_clifo = _control_rec.sub(236,237); + _agg_pcon = _control_rec.sub(237,238); + _agg_IVdir = _control_rec.sub(234,235); + _riatt_att = _control_rec.sub(238,239); + _riatt_pas = _control_rec.sub(239,240); + } + else + _ftrasfer = FALSE; + } + else + _ftrasfer = FALSE; + + return TRUE; +} + +bool TVis_ric::esegui_controlli() +{ + TConfig conf(CONFIG_DITTA); + + _std = conf.get("FlStTra"); + + _dittaric = get_firm(); + + if (!prefix().exist(_dittaric)) + return error_box("Rilevati GRAVI ERRORI negli archivi: procedura interrotta"); + + if (!leggi_trasfer()) + return FALSE; + + return TRUE; +} + +bool TVis_ric::menu(MENU_TAG m) +{ + if (m == BAR_ITEM(1)) + return video(); + return FALSE; +} diff --git a/cg/cg2803.h b/cg/cg2803.h new file mode 100755 index 000000000..4cacaf2bf --- /dev/null +++ b/cg/cg2803.h @@ -0,0 +1,58 @@ +// Visualizzazione stato ricezione + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cg2800.h" + +HIDDEN TString80 TP; + +class TVis_ric : public TApplication +{ + TTable* _tab_tra; + TTransfer_file _tras_file; + + TString _trasf,_std,_uselab,_key,_dittainv,_nomeid,_ragsoc_dittar; + TString _agg_cau,_agg_clifo,_agg_pcon,_agg_IVdir,_riatt_att,_riatt_pas; + long _dittaric; + TString _control_rec; + TDate _dataultras; + int _nultras; + bool _registra,_ftrasfer; + +public: + TString _titolo; + + virtual bool create(); + virtual bool destroy(); + virtual bool menu(MENU_TAG m); + + bool video(); + void setta_campi_video(TMask& m); + + void ditta_ricevente(); + long leggi_tabella_tras(); + bool esegui_controlli(); + bool leggi_trasfer(); + void registra(TMask& m); + + void setta_std(const TString& flag); + + static bool baipassa (TMask& m, KEY k); + static bool stato_hnd (TMask_field& f, KEY k); + static bool uselab_hnd (TMask_field& f, KEY k); + static bool chiave_hnd (TMask_field& f, KEY k); + + const char* riconverti (TString& data_PC); + + TVis_ric() {}; +}; diff --git a/cg/cg2803a.uml b/cg/cg2803a.uml index c54d05755..8d1e620ac 100755 --- a/cg/cg2803a.uml +++ b/cg/cg2803a.uml @@ -71,7 +71,6 @@ LIST F_AGGIVD 6 BEGIN PROMPT 1 13 "Aggiornamento classi Piano dei Conti " ITEM "N|No" - ITEM "D|Descr." ITEM "T|Tutto" END diff --git a/cg/cglib04.cpp b/cg/cglib04.cpp index 66f330b41..2e0afa5d6 100755 --- a/cg/cglib04.cpp +++ b/cg/cglib04.cpp @@ -9,7 +9,7 @@ HIDDEN TString80 TMP; const int size = 256; -const char* tracciato = "trc.txt"; +const char* tracciato = "cgtrc.ini"; #if XVT_OS == XVT_OS_WIN #include diff --git a/cg/cgtrc.ini b/cg/cgtrc.ini new file mode 100755 index 000000000..3cd9fba28 --- /dev/null +++ b/cg/cgtrc.ini @@ -0,0 +1,196 @@ +W1|1|256|256|26||| +W1|2|3|5|26|CODCAUS|| +W1|3|16|35|26|DESCR|1| +W1|4|36|37|26|TIPODOC|| +W1|5|38|38|26|REG|| +W1|6|39|39|26|ALLEG|| +W1|7|40|40|26|M770|| +W1|8|41|41|26|COLLCESP|| +W1|9|207|207|26|NUMDOC|| +W1|10|208|208|26|DATADOC|| +W1|11|210|212|26|CODCAUSIM|| +W1|12|247|247|26|INTRACOM|| +W1|13|248|248|26|VALINTRA|| +W1|14|249|249|26|RITFATT|| +W1|15|250|250|26|AUTOFATT|| +W1|16|3|5|27|CODCAUS|| +W1|17|42|43|27|GRUPPO|| +W1|18|44|45|27|CONTO|| +W1|19|46|51|27|SOTTOCONTO|| +W1|20|192|192|27|SEZIONE|| +W1|21|3|5|27|CODCAUS|| +W1|22|52|53|27|GRUPPO|| +W1|23|54|55|27|CONTO|| +W1|24|56|61|27|SOTTOCONTO|| +W1|25|193|193|27|SEZIONE|| +W1|26|3|5|27|CODCAUS|| +W1|27|62|63|27|GRUPPO|| +W1|28|64|65|27|CONTO|| +W1|29|66|71|27|SOTTOCONTO|| +W1|30|194|194|27|SEZIONE|| +W1|31|3|5|27|CODCAUS|| +W1|32|72|73|27|GRUPPO|| +W1|33|74|75|27|CONTO|| +W1|34|76|81|27|SOTTOCONTO|| +W1|35|195|195|27|SEZIONE|| +W1|36|3|5|27|CODCAUS|| +W1|37|82|83|27|GRUPPO|| +W1|38|84|85|27|CONTO|| +W1|39|86|91|27|SOTTOCONTO|| +W1|40|196|196|27|SEZIONE|| +W1|41|3|5|27|CODCAUS|| +W1|42|92|93|27|GRUPPO|| +W1|43|94|95|27|CONTO|| +W1|44|96|101|27|SOTTOCONTO|| +W1|45|197|197|27|SEZIONE|| +W1|46|3|5|27|CODCAUS|| +W1|47|102|103|27|GRUPPO|| +W1|48|104|105|27|CONTO|| +W1|49|106|111|27|SOTTOCONTO|| +W1|50|198|198|27|SEZIONE|| +W1|51|3|5|27|CODCAUS|| +W1|52|112|113|27|GRUPPO|| +W1|53|114|115|27|CONTO|| +W1|54|116|121|27|SOTTOCONTO|| +W1|55|199|199|27|SEZIONE|| +W1|56|3|5|27|CODCAUS|| +W1|57|122|123|27|GRUPPO|| +W1|58|124|125|27|CONTO|| +W1|59|126|131|27|SOTTOCONTO|| +W1|60|200|200|27|SEZIONE|| +W1|61|3|5|27|CODCAUS|| +W1|62|132|133|27|GRUPPO|| +W1|63|134|135|27|CONTO|| +W1|64|136|141|27|SOTTOCONTO|| +W1|65|201|201|27|SEZIONE|| +W1|66|3|5|27|CODCAUS|| +W1|67|142|143|27|GRUPPO|| +W1|68|144|145|27|CONTO|| +W1|69|146|151|27|SOTTOCONTO|| +W1|70|202|202|27|SEZIONE|| +W1|71|3|5|27|CODCAUS|| +W1|72|152|153|27|GRUPPO|| +W1|73|154|155|27|CONTO|| +W1|74|156|161|27|SOTTOCONTO|| +W1|75|203|203|27|SEZIONE|| +W1|76|3|5|27|CODCAUS|| +W1|77|162|163|27|GRUPPO|| +W1|78|164|165|27|CONTO|| +W1|79|166|171|27|SOTTOCONTO|| +W1|80|204|204|27|SEZIONE|| +W1|81|3|5|27|CODCAUS|| +W1|82|172|173|27|GRUPPO|| +W1|83|174|175|27|CONTO|| +W1|84|176|181|27|SOTTOCONTO|| +W1|85|205|205|27|SEZIONE|| +W1|86|3|5|27|CODCAUS|| +W1|87|182|183|27|GRUPPO|| +W1|88|184|185|27|CONTO|| +W1|89|186|191|27|SOTTOCONTO|| +W1|90|206|206|27|SEZIONE|| +A1|1|256|256|20||| +A1|2|3|3|20|TIPOCF|| +A1|3|4|9|20|CODCF|| +A1|4|16|16|20|TIPOPERS|| +A1|5|17|66|20|RAGSOC|1| +A1|6|67|77|20|PAIV|1| +A1|7|78|93|20|COFI|1| +A1|8|94|128|20|INDCF|1| +A1|9|129|133|20|CAPCF|| +A1|10|134|153|20|LOCALITACF|1| +A1|11|156|167|20|TEL|1| +A1|12|168|168|20|ALLEG|| +A1|13|169|170|20|GRUPPORIC|| +A1|14|171|172|20|CONTORIC|| +A1|15|173|178|20|SOTTOCRIC|| +A1|16|180|185|20|CODALLEG|| +A1|17|186|187|20|CODPAG|| +P1|1|256|256|19||| +P1|2|3|4|19|GRUPPO|| +P1|3|16|45|19|DESCR|1| +P2|1|256|256|19||| +P2|2|3|4|19|GRUPPO|| +P2|3|5|6|19|CONTO|| +P2|4|16|45|19|DESCR|1| +P2|5|46|46|19|INDBIL|| +P2|6|47|47|19|TMCF|| +P2|7|48|48|19|STSOTTBIL|| +P2|8|49|49|19|SEZIVD|| +P2|9|50|50|19|LETTIVD|| +P2|10|61|63|19|NUMRIVD|| +P2|11|59|60|19|NUMIVD|| +P2|12|64|64|19|SEZIVDOPP|| +P2|13|65|65|19|LETTIVDOPP|| +P2|14|76|78|19|NUMRIVDOPP|| +P2|15|74|75|19|NUMIVDOPP|| +P3|1|256|256|19||| +P3|2|3|4|19|GRUPPO|| +P3|3|5|6|19|CONTO|| +P3|4|7|12|19|SOTTOCONTO|| +P3|5|16|45|19|DESCR|1| +P3|6|46|46|19|TIPOSPRIC|| +P3|7|47|47|19|RICSER|| +P3|8|48|48|19|SEZIVD|| +P3|9|49|49|19|LETTIVD|| +P3|10|60|62|19|NUMRIVD|| +P3|11|58|59|19|NUMIVD|| +P3|12|63|63|19|SEZIVDOPP|| +P3|13|64|64|19|LETTIVDOPP|| +P3|14|75|77|19|NUMRIVDOPP|| +P3|15|73|74|19|NUMIVDOPP|| +Z1|50|22|22|23||| +Z1|51|249|249|23||| +Z1|0|16|21|23|DATAREG|| +Z1|1|250|250|23||| +Z1|2|251|256|23||| +Z1|3|3|8|23|NUMREG|| +Z1|4|23|28|23|DATADOC|1| +Z1|5|29|35|23|NUMDOC|| +Z1|6|36|36|23|REG|| +Z1|7|37|41|23|PROTIVA|| +Z1|8|42|44|23|CODCAUS|| +Z1|9|96|97|23|CODPAG|| +Z1|10|109|113|23|UPROTIVA|| +Z1|11|220|220|23|TIPO|| +Z1|12|221|222|23|TIPODOC|| +Z1|13|238|248|23|TOTDOC|| +Z1|14|3|8|24|NUMREG|| +Z1|15|9|10|24|NUMRIG|| +Z1|16|45|74|24|DESCR|| +Z1|17|75|76|24|GRUPPO|| +Z1|18|77|78|24|CONTO|| +Z1|19|79|84|24|SOTTOCONTO|| +Z1|20|85|85|24|SEZIONE|| +Z1|21|86|87|24|GRUPPOC|| +Z1|22|88|89|24|CONTOC|| +Z1|23|90|95|24|SOTTOCONTC|| +Z1|24|98|108|24|IMPORTO|| +Z1|25|220|220|24|TIPOC|| +Z1|26|223|223|24||| +U1|51|249|249|23||| +U1|1|250|250|23||| +U1|2|251|256|23||| +U1|3|3|8|23|NUMREG|| +U1|4|56|61|23|DATA74TER|1| +U1|5|147|149|23|CODVAL|| +U1|6|16|21|23|CODCF|| +U1|7|238|248|23|TOTDOC|| +U1|8|150|160|23|CAMBIOI|5| +U1|9|136|146|23|CORRLIRE|| +U1|10|161|174|23|CORRVALUTA|3| +U1|11|3|8|25|NUMREG|| +U1|12|9|10|25|NUMRIG|| +U1|13|33|34|25|CODIVA|| +U1|14|22|32|25|IMPONIBILE|| +U1|15|35|43|25|IMPOSTA|| +U1|16|45|45|25|TIPODET|| +U1|17|44|44|25|TIPOCR|| +U1|18|134|134|25|TIPOATT|| +U1|19|46|47|25|GRUPPO|| +U1|20|48|49|25|CONTO|| +U1|21|50|55|25|SOTTOCONTO|| +U1|50|62|86|||| +U1|51|87|108|||| +U1|52|109|126|||| +U1|53|127|131|||| +U1|54|132|133||||