From abdfea53b7468dd7d553815f4827a24508f81c18 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 3 Apr 2003 16:15:58 +0000 Subject: [PATCH] Patch level : 2..0 442 Files correlati : cg4.exe Ricompilazione Demo : [ ] Commento : Aggiunto il supporto delle lingue a cg5 git-svn-id: svn://10.65.10.50/trunk@10970 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- cg/cg5000.cpp | 2 +- cg/cg5100.cpp | 100 +++++++++++---------- cg/cg5200.cpp | 84 ++++++----------- cg/cg5300.cpp | 243 ++++++++++++++++++++++++++------------------------ cg/cg5400.cpp | 102 +++++++-------------- cg/cg5500.cpp | 198 +++++++++++++++++++--------------------- cg/cg5600.cpp | 220 +++++++++++++++++---------------------------- 7 files changed, 419 insertions(+), 530 deletions(-) diff --git a/cg/cg5000.cpp b/cg/cg5000.cpp index aa536fbde..8038810a1 100755 --- a/cg/cg5000.cpp +++ b/cg/cg5000.cpp @@ -10,6 +10,6 @@ public: int cg5000 (int argc, char* argv[]) { CG5_App appc; - appc.run(argc, argv, "Parametri Studio"); + appc.run(argc, argv, TR("Parametri Studio")); return 0; } diff --git a/cg/cg5100.cpp b/cg/cg5100.cpp index 81c38343f..56b2dab2d 100755 --- a/cg/cg5100.cpp +++ b/cg/cg5100.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -33,18 +34,18 @@ public: bool TParametri_ditta::user_create() { - // _change_pcon = FALSE; + TRelation att(LF_ATTIV); + TRectype & r = att.curr(); - TLocalisamfile attiv(LF_ATTIV); - attiv.zero(); + r.put(ATT_CODDITTA, get_firm()); - attiv.put(ATT_CODDITTA, get_firm()); - TRectype r(attiv.curr()); + TCursor cur(&att, "", 1, &r, &r); + const TRecnotype items = cur.items(); - for(attiv.read(_isgteq); attiv.status() == NOERR && attiv.curr() == r; - attiv.next()) + cur.freeze(); + for (cur = 0L; cur.pos() < items; ++cur) // istanzia array _atts on le attivita' della ditta corrente - _atts.add(new TString(attiv.get(ATT_CODATT))); + _atts.add(r.get(ATT_CODATT)); return TRUE; } @@ -54,55 +55,57 @@ void TParametri_ditta::check_registers(int year) { // controlla che per ogni data attivita' esistano almeno un registro // acquisti, vendite e giornale; warning appropriato in caso negativo - TTable reg("REG"); - TRecfield reg_year(reg.curr(), "CODTAB", 0,3); - const byte R_ACQ = 0x01; const byte R_VEN = 0x02; const byte R_ALL = R_ACQ | R_VEN; - - bool is_giornale = FALSE; - - byte flags = 0x00; + TRelation relreg("REG"); + TRectype & reg = relreg.curr(); + bool is_giornale = FALSE; for (int i = 0; i < _atts.items(); i++) { - TString& att = (TString&)_atts[i]; - for (reg.first(); !reg.eof(); reg.next()) - { - if (atoi(reg_year) == year && reg.get_int("I0") == 5) - { + byte flags = 0x00; + const TString& att = (TString&)_atts[i]; + TString filter; + + reg.put("CODTAB", year); + filter.format("(S8==\"\")||(S8==\"%s\")", (const char *) att); + + TCursor cur(&relreg, filter, 1, ®, ®); + const TRecnotype items = cur.items(); + + cur.freeze(); + for (cur = 0L; (flags != R_ALL || !is_giornale) && (cur.pos() < items); ++cur) + { + if (reg.get_int("I0") == 5) is_giornale = TRUE; - continue; - } - if (atoi(reg_year) != year || att != reg.get("S8")) - continue; - - switch (reg.get_int("I0")) - { - case 1: // vendite - flags |= R_VEN; break; - case 2: // acquisti - flags |= R_ACQ; break; - default: - break; - } - if (flags == R_ALL && is_giornale) break; + else + { + switch (reg.get_int("I0")) + { + case 1: // vendite + flags |= R_VEN; break; + case 2: // acquisti + flags |= R_ACQ; break; + default: + break; + } + } } if (flags < R_ALL) { - TString wrn("I seguenti registri non esistono per l'attivita' "); + TString wrn(TR("I seguenti registri non esistono per l'attivita' ")); wrn << att << "(" << year << "):"; - if ((flags & R_VEN) == 0x00) wrn << "\n\tregistro vendite"; - if ((flags & R_ACQ) == 0x00) wrn << "\n\tregistro acquisti"; + if ((flags & R_VEN) == 0x00) wrn << TR("\n\tregistro vendite"); + if ((flags & R_ACQ) == 0x00) wrn << TR("\n\tregistro acquisti"); warning_box(wrn); } } // libro giornale non si controlla per attivita' if(!is_giornale) - warning_box("Non esiste probabilmente nessun " - "libro giornale per l'anno %d", year); + warning_box(FR("Non esiste probabilmente nessun " + "libro giornale per l'anno %d"), year); } @@ -189,11 +192,14 @@ bool TParametri_ditta::postprocess_config(TMask& mask, TConfig& config) bool TParametri_ditta::postprocess_config_changed(const char* par, const char* var, const char* oldv, const char* newv) { - TString v(var); + const bool changed = strcmp(oldv, newv) != 0; - if (v == "AnCfCm") + if (!changed) + return TRUE; + const TFixed_string v(var); + if (v == "AnCfCm") { - if (yesno_box("Confermi il cambiamento dell'anagrafica clienti/fornitori")) + if (yesno_box(TR("Confermare il cambiamento dell'anagrafica clienti/fornitori"))) { swap_file(LF_CLIFO, *newv == 'X'); swap_file(LF_INDSP, *newv == 'X'); @@ -203,10 +209,8 @@ bool TParametri_ditta::postprocess_config_changed(const char* par, const char* v } else if (v == "PcTcCm") { - if (yesno_box("Confermi il cambiamento del piano conti/causali")) + if (yesno_box(TR("Confermare il cambiamento del piano conti/causali"))) { - // _change_pcon = TRUE; - // _val = newv; swap_file(LF_PCON, *newv == 'X'); swap_file(LF_CAUSALI, *newv == 'X'); swap_file(LF_RCAUSALI, *newv == 'X'); @@ -215,7 +219,7 @@ bool TParametri_ditta::postprocess_config_changed(const char* par, const char* v { TDir d; d.get(LF_PCON, _nolock, _comdir); - if (d.eod() == 0 && yesno_box("Vuoi caricare gli archivi standard ?")) + if (d.eod() == 0 && yesno_box(TR("Si desidera caricare gli archivi standard ?"))) { load_file(LF_PCON); load_file(LF_CAUSALI); @@ -232,6 +236,6 @@ bool TParametri_ditta::postprocess_config_changed(const char* par, const char* v int cg5100 (int argc, char* argv[]) { TParametri_ditta appc; - appc.run(argc, argv, "Parametri Ditta"); + appc.run(argc, argv, TR("Parametri Ditta")); return 0; } diff --git a/cg/cg5200.cpp b/cg/cg5200.cpp index fd31f3d50..fa26079dd 100755 --- a/cg/cg5200.cpp +++ b/cg/cg5200.cpp @@ -109,7 +109,6 @@ class TSaldibrowse_application : public TBrowse_application TMask* _msk; TCursor * _cur; TRelation * _rel,* _rel1; -// TTable * _esc; TRiga_array _riga; int _anno, _annop, _g, _c; long _s; @@ -204,12 +203,8 @@ bool TSaldibrowse_application::fai_filtro() _saldo_conto = TRUE; else _saldo_sottoc = TRUE; - TLocalisamfile& saldi = _rel1->lfile(); - TRectype from (saldi.curr()); - TRectype to (saldi.curr()); - from.zero(); - to.zero(); - + TRectype from (LF_SALDI); + TRectype to (LF_SALDI); from.put(SLD_GRUPPO,_g); if (_c != 0) @@ -238,7 +233,7 @@ bool TSaldibrowse_application::anno_handler(TMask_field& f, KEY key) if (anno > 0) { if (!app()._ese.exist(anno)) - return f.error_box("Esercizio %d non presente.", anno); + return f.error_box(FR("Esercizio %d non presente."), anno); else app()._anno = anno; } @@ -265,8 +260,6 @@ bool TSaldibrowse_application::sottoc_handler(TMask_field& f, KEY key) int gruppo = m.get_int(F_GRUPPO); int conto = m.get_int(F_CONTO); const long sottoconto = atol(f.get()); - TLocalisamfile pconti(LF_PCON); - const short id = f.dlg(); if (sottoconto != 0) @@ -275,23 +268,26 @@ bool TSaldibrowse_application::sottoc_handler(TMask_field& f, KEY key) { if (gruppo != 0 && conto != 0) { - pconti.setkey(1); - pconti.put(PCN_GRUPPO, gruppo) ; - pconti.put(PCN_CONTO, conto); - pconti.put(PCN_SOTTOCONTO, sottoconto); - ok = stop = pconti.read() == NOERR; + TString key; + + key.format("%d|%d|%ld", gruppo, conto, sottoconto); + + const TRectype & pconti = cache().get(LF_PCON, key); + + ok = stop = !pconti.empty(); } - //else ok = FALSE; } else { const char tipo = id == F_SOTTOC_CLIENTE ? 'C' : 'F'; - TLocalisamfile clifo (LF_CLIFO); - clifo.setkey(1); - clifo.put(CLI_TIPOCF,tipo); - clifo.put(CLI_CODCF, sottoconto) ; + TString key; + + key.format("%c|%ld", tipo, sottoconto); app()._s = sottoconto; - ok = stop = clifo.read() == NOERR; + + const TRectype & clifo = cache().get(LF_CLIFO, key); + + ok = stop = !clifo.empty(); if (ok && (gruppo == 0 || conto == 0)) { m.set(F_GRUPPO, gruppo = clifo.get_int("GRUPPO")); @@ -303,18 +299,20 @@ bool TSaldibrowse_application::sottoc_handler(TMask_field& f, KEY key) else if (gruppo != 0 /* && conto != 0 */) { - pconti.setkey(1); - pconti.zero(); - pconti.put(PCN_GRUPPO, gruppo) ; - pconti.put(PCN_CONTO, conto); - ok = stop = pconti.read() == NOERR; + TString key; + + key.format("%d|%d", gruppo, conto); + + const TRectype & pconti = cache().get(LF_PCON, key); + + ok = stop = !pconti.empty(); if (ok) m.set(F_DESCR_CONTO, pconti.get(PCN_DESCR)); else m.reset(F_DESCR_CONTO); } if (!ok) - f.error_box("Conto errato o incompleto"); + f.error_box(TR("Conto errato o incompleto")); } return ok; @@ -322,12 +320,12 @@ bool TSaldibrowse_application::sottoc_handler(TMask_field& f, KEY key) bool TSaldibrowse_application::user_create() { + open_files(LF_TABCOM, LF_TAB, LF_PCON, LF_SALDI, 0); _rel = new TRelation(LF_PCON); _rel->add(LF_CLIFO,"TIPOCF=TMCF"); _rel1 = new TRelation(LF_SALDI); _cur = new TCursor(_rel1, "", 2); -// _esc = new TTable("ESC"); _msk = new TMask("cg5200a"); _msk->set_handler(F_ANNO, anno_handler); _msk->set_handler(F_SCARICATO, flsca_handler); @@ -360,17 +358,14 @@ int TSaldibrowse_application::read(TMask& m) m.set(F_ANNO,_anno); m.set(F_SCARICATO,_scarongly ? "X" : " "); TString tipo(m.get(F_TIPOCF)); - //if (tipo == "C") - // m.set(F_SOTTOC_CLIENTE,_s); - //else if (tipo == "F") - // m.set(F_SOTTOC_FORN,_s); + fai_filtro(); if (_cur->items() > 0) compilasheet(); else { err = _iskeynotfound; - error_box("Saldi non presenti per il conto specificato."); + error_box(TR("Saldi non presenti per il conto specificato.")); } return err; @@ -437,27 +432,6 @@ int TSaldibrowse_application::compare_rows(const TObject** o1, const TObject** o { TToken_string* r1 = (TToken_string*)*o1; TToken_string* r2 = (TToken_string*)*o2; - -/* Dick programming - TDate d1,d2; - TString c1,c2; - c1.format("%04d", r1->get_int(0)); - c2.format("%04d", r2->get_int(0)); - - app()._esc->zero(); - app()._esc->put("CODTAB",c1); - if (app()._esc->read() == NOERR) - d1 = app()._esc->get_date("D0"); - else - d1 = botime; - - app()._esc->put("CODTAB",c2); - if (app()._esc->read() == NOERR) - d2 = app()._esc->get_date("D0"); - else - d2 = botime; -*/ - TEsercizi_contabili& ese = app()._ese; int a1 = r1->get_int(0); TDate d1 = ese.exist(a1) ? ese[a1].inizio() : TDate(1, 1, a1); @@ -615,7 +589,7 @@ void TSaldibrowse_application::compilasheet() int cg5200(int argc, char* argv[]) { TSaldibrowse_application a; - a.run(argc, argv, "Visualizzazione saldi"); + a.run(argc, argv, TR("Visualizzazione saldi")); return 0; } diff --git a/cg/cg5300.cpp b/cg/cg5300.cpp index cfe4ed6fe..9155769c1 100755 --- a/cg/cg5300.cpp +++ b/cg/cg5300.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -24,10 +25,7 @@ class TParaliq_app : public TRelation_application { TRelation * _rel; TMask * _msk; - TLocalisamfile * _attiv; - TLocalisamfile * _ditte; int _yearliq; - TTable * _pla; protected: // Applicat virtual void on_config_change(); @@ -86,19 +84,18 @@ bool TParaliq_app::gelidi_handler(TMask_field& f, KEY k) { if (k==K_SPACE) { - TLocalisamfile* ditte = app()._ditte; TMask& m = f.mask(); if (m.get_bool(F_GELIDI)) { - const long ditta = m.get_long(F_CODDITTA); - ditte->put("CODDITTA", ditta); - if (ditte->read()==NOERR) - if (ditte->get("DINIZIOATT").empty()) - { - f.set(" "); - f.error_box("La gestione della liquidazione differita richiede " - "la data di inizio attivita' sull'anagrafica della ditta."); - } + const TString & cod = m.get(F_CODDITTA); + const TRectype & ditta = cache().get(LF_NDITTE, cod); + + if (ditta.get(NDT_DINIZIOATT).empty()) + { + f.set(" "); + f.error_box(TR("La gestione della liquidazione differita richiede " + "la data di inizio attivita' sull'anagrafica della ditta.")); + } } } return TRUE; @@ -108,18 +105,21 @@ bool TParaliq_app::agrmin_handler(TMask_field& f, KEY k) { if (k == K_SPACE) { - TLocalisamfile* attiv = app()._attiv; TMask& m = f.mask(); if (m.get_bool(F_AGRMIN)) { - const long ditta = m.get_long(F_CODDITTA); - attiv->put(ATT_CODDITTA, ditta); - if (attiv->read(_isgteq) == NOERR && attiv->get_long(ATT_CODDITTA) == ditta - && !attiv->get_bool(ATT_REGAGR)) + const TString & cod = m.get(F_CODDITTA); + const TRectype & ditta = cache().get(LF_NDITTE, cod); + TString16 key; + + key.format("%s|%s", (const char *) cod, (const char *) ditta.get(NDT_CODATTPREV)); + const TRectype & attiv = cache().get(LF_ATTIV, key); + + if (!attiv.get_bool(ATT_REGAGR)) { f.set(" "); - f.error_box("La gestione degli agricoltori minimi richiede " - "il settaggio del regime agricolo sull'attivita'."); + f.error_box(TR("La gestione degli agricoltori minimi richiede " + "il settaggio del regime agricolo sull'attivita'.")); } } } @@ -145,9 +145,9 @@ bool TParaliq_app::credres_handler(TMask_field& f, KEY k) const real r = m.get_real(F_CRED_RES); const int i = m.get_int(F_MESE_RES_AL); if (id == F_MESE_RES_AL && r != 0.0 && i == 0) - return f.error_box("Impostare anche il mese."); + return f.error_box(TR("Impostare anche il mese.")); if (id == F_CRED_RES && i != 0 && r == 0.0) - return f.error_box("Impostare anche il credito residuo."); + return f.error_box(TR("Impostare anche il credito residuo.")); } return TRUE; } @@ -179,19 +179,19 @@ bool TParaliq_app::utcred_handler(TMask_field& f, KEY k) if (anno_liq >= 2000 && f.get().not_empty()) { - m.field(F_CRED_PREC).set_prompt("Credito compensabile inizio anno "); - m.field(F_CRED_RES).set_prompt("Credito in compensaz.utilizzato "); + m.field(F_CRED_PREC).set_prompt(TR("Credito compensabile inizio anno ")); + m.field(F_CRED_RES).set_prompt(TR("Credito in compensaz.utilizzato ")); m.enable(F_UTCR_IVA); cod_mesi = "0|-1"; - des_mesi = " |Inizio Anno"; + des_mesi = FR(" |Inizio Anno"); mese = !m.field(F_CRED_RES).empty() ? "-1" : "0"; } else { - m.field(F_CRED_PREC).set_prompt("Credito precedente "); - m.field(F_CRED_RES).set_prompt("Credito residuo "); + m.field(F_CRED_PREC).set_prompt(TR("Credito precedente ")); + m.field(F_CRED_RES).set_prompt(TR("Credito residuo ")); cod_mesi = "0|1|2|3|4|5|6|7|8|9|10|11|12"; - des_mesi = " |Gennaio|Febbraio|Marzo|Aprile|Maggio|Giugno|Luglio|Agosto|Settembre|Ottobre|Novembre|Dicembre"; + des_mesi = FR(" |Gennaio|Febbraio|Marzo|Aprile|Maggio|Giugno|Luglio|Agosto|Settembre|Ottobre|Novembre|Dicembre"); mese = app().rel().lfile().get("I0"); if (!m.edit_mode() || atoi(mese) < 0) mese.cut(0); @@ -211,23 +211,26 @@ void TParaliq_app::check_registers(int year) // controlla che per ogni data attivita' esistano almeno un registro // acquisti, vendite e giornale; warning appropriato in caso negativo TSheet_field& sf = (TSheet_field&)_msk->field(F_SHEET_PLA); - TTable reg("REG"); - TRecfield reg_year(reg.curr(), "CODTAB", 0,3); - const byte R_ACQ = 0x01; const byte R_VEN = 0x02; const byte R_ALL = R_ACQ | R_VEN; - - byte flags = 0x00; + TRelation relreg("REG"); + TRectype & reg = relreg.curr(); for (int i = 0; i < sf.items(); i++) { + byte flags = 0x00; const TString16 att(sf.row(i).get(0)); - for (reg.first(); !reg.eof(); reg.next()) - { - if (atoi(reg_year) != year || att != reg.get("S8")) - continue; - + TString filter; + + reg.put("CODTAB", year); + filter.format("(S8==\"\")||(S8==\"%s\")", (const char *) att); + + TCursor cur(&relreg, filter, 1, ®, ®); + const TRecnotype items = cur.items(); + + for (cur = 0L; flags != R_ALL && (cur.pos() < items); ++cur) + { switch (reg.get_int("I0")) { case 1: // vendite @@ -239,14 +242,13 @@ void TParaliq_app::check_registers(int year) default: break; } - if (flags == R_ALL) break; } if (flags < R_ALL) { - TString wrn("I seguenti registri non esistono per l'attivita' "); + TString wrn(TR("I seguenti registri non esistono per l'attivita' ")); wrn << att << "(" << year << "):"; - if ((flags & R_VEN) == 0x00) wrn << "\n\tregistro vendite"; - if ((flags & R_ACQ) == 0x00) wrn << "\n\tregistro acquisti"; + if ((flags & R_VEN) == 0x00) wrn << TR("\n\tregistro vendite"); + if ((flags & R_ACQ) == 0x00) wrn << TR("\n\tregistro acquisti"); warning_box(wrn); } } @@ -255,24 +257,25 @@ void TParaliq_app::check_registers(int year) void TParaliq_app::init_array(TMask& m, bool update) { TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_PLA); - const long newditta = m.get_long(F_CODDITTA); - - _attiv->zero(); - _attiv->put(ATT_CODDITTA, newditta); - TRectype r(_attiv->curr()); + TRelation att(LF_ATTIV); + TRectype & r = att.curr(); + r.put(ATT_CODDITTA, newditta); + + TCursor cur(&att, "", 1, &r, &r); + const TRecnotype items = cur.items(); int i = 0; - for(_attiv->read(_isgteq); - _attiv->good() && _attiv->curr() == r; - _attiv->next(), i++) + + cur.freeze(); + for (cur = 0L; cur.pos() < items; ++cur, i++) { TToken_string& tt = sf.row(i); // istanzia array _atts on le attivita' della ditta corrente - tt = ""; - tt.add(_attiv->get(ATT_CODATT)); - tt.add(_attiv->get(ATT_TIPOATT)); + tt.cut(0); + tt.add(r.get(ATT_CODATT)); + tt.add(r.get(ATT_TIPOATT)); tt.add(""); tt.add(""); tt.add(""); @@ -295,10 +298,9 @@ void TParaliq_app::on_config_change() bool TParaliq_app::user_create() { + open_files(LF_TABCOM, LF_TAB, LF_NDITTE, LF_ATTIV, 0); + _rel = new TRelation(TAB_LIA); - _pla = new TTable(TAB_PLA); - _attiv = new TLocalisamfile(LF_ATTIV); - _ditte = new TLocalisamfile(LF_NDITTE); _msk = new TMask("cg5300a"); _msk->set_handler(F_GELIDI,gelidi_handler); @@ -315,10 +317,7 @@ bool TParaliq_app::user_create() bool TParaliq_app::user_destroy() { delete _rel; - delete _attiv; - delete _ditte; delete _msk; - delete _pla; return TRUE; } @@ -386,52 +385,58 @@ int TParaliq_app::rewrite(const TMask& m) TString16 codtab; codtab.format("%05ld%4d%s", firm, year, (const char*)att); + TTable pla(TAB_PLA); - _pla->zero(); - _pla->put("CODTAB", codtab); - _pla->remove(); // Rimuove dalla tabella PLA il record senza il tipo attivita' ad 1 (se non c'e' fa lo stesso) + pla.put("CODTAB", codtab); + pla.remove(); // Rimuove dalla tabella PLA il record senza il tipo attivita' ad 1 (se non c'e' fa lo stesso) codtab << "1"; // Questo invece e' il codice che deve esistere realmente - _pla->put("CODTAB", codtab); - was =_pla->read() == NOERR; - if (!was) _pla->zero(); + pla.put("CODTAB", codtab); + was = (pla.read() == NOERR); + if (!was) pla.zero(); - real prorata = _pla->get_real("R8"); - real es_a8 = _pla->get_real("R5"); - real es_a8b = _pla->get_real("R6"); - real es_a9 = _pla->get_real("R7"); + real prorata = pla.get_real("R8"); + real es_a8 = pla.get_real("R5"); + real es_a8b = pla.get_real("R6"); + real es_a9 = pla.get_real("R7"); - _pla->put("CODTAB", codtab); + pla.put("CODTAB", codtab); // scrive i campi (vedi a read() per i nomi) // in base alla riga sheet - _pla->put("S7", tips); // tipo attivita' - _pla->put("R8", tt.get()); // prorata - _pla->put("R5", tt.get()); // plafond art. 8 - _pla->put("R6", tt.get()); // plafond art. 8bis - _pla->put("R7", tt.get()); // plafond art. 9 + pla.put("S7", tips); // tipo attivita' + pla.put("R8", tt.get()); // prorata + pla.put("R5", tt.get()); // plafond art. 8 + pla.put("R6", tt.get()); // plafond art. 8bis + pla.put("R7", tt.get()); // plafond art. 9 - err = (was ? _pla->rewrite() : _pla->write()); + err = (was ? pla.rewrite() : pla.write()); // se si e' cambiato qualcosa.. - if (prorata != _pla->get_real("R8") || - es_a8 != _pla->get_real("R5") || - es_a8b != _pla->get_real("R6") || - es_a9 != _pla->get_real("R7") || + if ((prorata != pla.get_real("R8")) || + (es_a8 != pla.get_real("R5")) || + (es_a8b != pla.get_real("R6")) || + (es_a9 != pla.get_real("R7")) || m.field(F_CRED_PREC).dirty()) { // invalida la prima liquidazione calcolata se ce n'e' - TTable lim("LIM"); + TRelation rellim("LIM"); + TRectype & lim = rellim.curr(); - TRecfield lim_anno(lim.curr(),"CODTAB",0,3); - TRecfield lim_mese(lim.curr(),"CODTAB",4,5); + lim.put("CODTAB", year); + + TCursor cur(&rellim, "", 1, &lim, &lim); + const TRecnotype items = cur.items(); - for (lim.first(); !lim.eof(); lim.next()) + cur.freeze(); + for (cur = 0L; cur.pos() < items; ++cur) { - if (year == atoi(lim_anno) && (freq == 'M' || (freq == 'T' && atoi(lim_mese) == 3))) - { - lim.put("B0",""); - lim.rewrite(); - break; - } +// const int mese = atoi(lim.get("CODTAB").mid(4,2)); chiedere a cinzia +// if (freq == 'M' || (freq == 'T' && mese == 3)) +// { + rellim.lfile().reread(_lock); + lim.zero("B0"); + rellim.rewrite(); +// break; +// } } } } @@ -444,11 +449,13 @@ int TParaliq_app::rewrite(const TMask& m) if (err == NOERR) err = was ? lia.rewrite() : lia.write(); if (err == NOERR && year == _yearliq) { - _ditte->put(NDT_CODDITTA, firm); - if (_ditte->read() == NOERR) + TLocalisamfile ditte(LF_NDITTE); + + ditte.put(NDT_CODDITTA, firm); + if (ditte.read(_isequal, _lock) == NOERR) { - _ditte->put(NDT_FREQVIVA, m.get(F_FREQ_VERS)); - _ditte->rewrite(); + ditte.put(NDT_FREQVIVA, m.get(F_FREQ_VERS)); + ditte.rewrite(); } } @@ -470,35 +477,35 @@ int TParaliq_app::read(TMask& m) const long firm = m.get_long(F_CODDITTA); const int year = m.get_int(F_YEAR); - TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_PLA); - //sf.reset(); - - const TString16 ctab = format("%05ld%4d", firm, year); - _pla->put("CODTAB", ctab); + TString16 ctab; TToken_string tt(80); + TRelation relpla(TAB_PLA); + TRectype & pla = relpla.curr(); - init_array(m, FALSE); // Carica tutti i codici attivita' + ctab.format("%05ld%4d", firm, year); + pla.put("CODTAB", ctab); - for (_pla->read(_isgteq); _pla->good(); _pla->next()) - { - if (strncmp(ctab, _pla->get("CODTAB"), 9) == 0) - { - tt = _pla->get("CODTAB").mid(9,5); // codice attivita' + TCursor cur(&relpla, "", 1, &pla, &pla); + const TRecnotype items = cur.items(); + int i = 0; - for (int i = 0; i < sf.items(); i++) // Cerca riga corrispondente sullo sheet - if (tt == sf.row(i).get(0)) break; - - tt.add(_pla->get("S7")); // tipo attivita' - tt.add(_pla->get("R8")); // prorata - tt.add(_pla->get("R5")); // plafond art. 8 - tt.add(_pla->get("R6")); // plafond art. 8bis - tt.add(_pla->get("R7")); // plafond art. 9 - sf.row(i) = tt; - } - else break; + init_array(m, FALSE); // Carica tutti i codici attivita' + cur.freeze(); + for (cur = 0L; cur.pos() < items; ++cur, i++) + { + tt = pla.get("CODTAB").mid(9,5); // codice attivita' + + for (int i = 0; i < sf.items(); i++) // Cerca riga corrispondente sullo sheet + if (tt == sf.row(i).get(0)) break; + + tt.add(pla.get("S7")); // tipo attivita' + tt.add(pla.get("R8")); // prorata + tt.add(pla.get("R5")); // plafond art. 8 + tt.add(pla.get("R6")); // plafond art. 8bis + tt.add(pla.get("R7")); // plafond art. 9 + sf.row(i) = tt; } - //sf.force_update(); return NOERR; } @@ -507,7 +514,7 @@ int TParaliq_app::read(TMask& m) int cg5300(int argc, char* argv[]) { TParaliq_app a; - a.run(argc, argv, "Parametri liquidazione"); + a.run(argc, argv, TR("Parametri liquidazione")); return 0; } diff --git a/cg/cg5400.cpp b/cg/cg5400.cpp index ffe2883ee..620b59f22 100755 --- a/cg/cg5400.cpp +++ b/cg/cg5400.cpp @@ -20,8 +20,6 @@ protected: // TApplication virtual void main_loop(); public: - void azzera_lim(int year, int month) const; - bool reg_restore(const TString& reg, int year, int month, int day, bool giornale); bool inl_restore(const TString& lbu, int year, int month); @@ -29,23 +27,6 @@ public: }; // Azzera flag di stampato della liquidazione mensile dal mese dato in poi -void TRipristina_stampa::azzera_lim(int year, int month) const -{ - TTable lim("LIM"); // Azzera i flag di stampa liquidazione - TString16 cod; cod.format("%04d%02d", year, month); - lim.put("CODTAB", cod); - for (int err = lim.read(_isgteq); err == NOERR; err = lim.next()) - { - if (atoi(lim.get("CODTAB").left(4)) != year) break; - const bool stampato = lim.get_bool("B1"); - if (stampato) - { - lim.zero("B1"); - lim.rewrite(); - } - } -} - bool TRipristina_stampa::reg_restore(const TString& regist, int year, int month, int day, bool giornale) @@ -67,25 +48,6 @@ bool TRipristina_stampa::reg_restore(const TString& regist, { TDate dlast(reg.get_date("D3")); -/* - if (giornale) - { - TTable esc("ESC"); - esc.zero(); - esc.put("CODTAB", format("%04d", year)); - if (esc.read() != NOERR) - return error_box("Esercizio %d assente", year); - - TDate wd(esc.get_date("D0")); - inizio_anno = wd; - - // Determina il corretto anno solare dell'esercizio: se il giorno di inizio esercizio - // e successivo alla data di ripristino allora mi trovo nell'anno solare successivo - year = wd.year(); - if (wd.month() > month || (wd.month() == month && wd.day() > day)) - year++; - } -*/ const int ld = TDate::last_day(month, year); if (day > ld) day = ld; TDate d(day, month, year); // Data di ripristino @@ -105,7 +67,7 @@ bool TRipristina_stampa::reg_restore(const TString& regist, cursor = 0L; const long nitems = cursor.items(); - TString msg; msg.format("Ripristino stampa del registro %s", (const char*)regist); + TString msg; msg.format(FR("Ripristino stampa del registro %s"), (const char*)regist); TProgind p(nitems ? nitems : 1, msg , TRUE, TRUE); if (giornale) @@ -122,7 +84,7 @@ bool TRipristina_stampa::reg_restore(const TString& regist, ok = (mov.rewrite() == NOERR); if (!ok) - error_box("Errore nell'aggiornamento del movimento %ld.\n Errore n. %d", + error_box(FR("Errore nell'aggiornamento del movimento %ld.\n Errore n. %d"), mov.get_long(MOV_NUMREG), mov.status()); } @@ -137,7 +99,6 @@ bool TRipristina_stampa::reg_restore(const TString& regist, reg.put("I4", (long)mese); // Ultimo mese di stampa liquidazione if (reg.get_int("I8") >= mese) reg.zero("I8"); // Mese di ultima stampa credito precedente - // azzera_lim(year, mese+1); } } else @@ -147,18 +108,17 @@ bool TRipristina_stampa::reg_restore(const TString& regist, { reg.zero("I4"); reg.zero("I8"); - // azzera_lim(year, 1); } } ok = (reg.rewrite() == NOERR); if (!ok) - error_box("Errore nell'aggiornamento del registro %s.\n Errore n. %d", + error_box(FR("Errore nell'aggiornamento del registro %s.\n Errore n. %d"), (const char*)regist, mov.status()); } else - ok = error_box("Impossibile leggere il registro %s anno %s", - (const char*)regist, (const char*)year); + ok = error_box(FR("Impossibile leggere il registro %s anno %04d"), + (const char*)regist, year); return ok; } @@ -166,34 +126,40 @@ bool TRipristina_stampa::reg_restore(const TString& regist, bool TRipristina_stampa::inl_restore(const TString& lib, int year, int month) { - TLocalisamfile inl(LF_INDLIB); + TString filter; + TRelation relinl(LF_INDLIB); + TRectype & inl = relinl.curr(); - inl.zero(); inl.put("ANNO", year); inl.put("CODLIB", lib); - const TRectype filter(inl.curr()); + filter.format("STR(MESEREG>=%d)&&(STAMPATO==\"X\")", month); + TCursor cur(&relinl, filter, 1, &inl, &inl); + + const TRecnotype items = cur.items(); + + cur.freeze(); bool ok = FALSE; // Azzera il flag di stampato sugli indici con mese >= month - for (inl.read(_isgteq); inl.good() && inl.curr() == filter; inl.next()) - if (inl.get_int("MESEREG") >= month && inl.get_bool("STAMPATO")) + for (cur = 0L; cur.pos() < items; ++cur) + { + relinl.lfile().reread(_lock); + inl.zero("STAMPATO"); + ok = relinl.rewrite() == NOERR; + if (!ok) { - inl.zero("STAMPATO"); - ok = inl.rewrite() == NOERR; - if (!ok) - { - error_box("Errore di ripristino dell'indice %ld", inl.get_long("NUMREG")); - break; - } - } + error_box(FR("Errore di ripristino dell'indice %ld"), inl.get_long("NUMREG")); + break; + } + } if (ok) // Se e' stato ripristinato almeno un indice e non ci sono stati errori { TTable lbu("%LBU"); TString16 cod; cod.format("%4d%s", year, (const char*)lib); lbu.put("CODTAB", cod); - ok = lbu.read() == NOERR; + ok = lbu.read(_isequal, _lock) == NOERR; if (ok) { TDate d(1, month, year); // Riporta la data di ultima stampa @@ -201,7 +167,7 @@ bool TRipristina_stampa::inl_restore(const TString& lib, int year, int month) ok = lbu.rewrite() == NOERR; } if (!ok) - error_box("Impossibile aggiornare il libro unico %s per l'anno %d", (const char*)lib, year); + error_box(FR("Impossibile aggiornare il libro unico %s per l'anno %d"), (const char*)lib, year); } return ok; @@ -238,18 +204,18 @@ void TRipristina_stampa::main_loop() if (prefix().exist(firm)) { - TString256 mess("Attenzione ripristino della stampa de"); + TString256 mess(TR("Attenzione ripristino della stampa")); if (_op == restore_reg) - mess << (giornale ? "l giornale" : "l registro"); + mess << (giornale ? TR(" del giornale") : TR(" del registro")); else - mess << "gli indici del libro "; - mess << ' ' << reg << "\ndel " << year; - if (_op == restore_reg) mess << " della ditta " << firm; + mess << TR(" degli indici del libro "); + mess << ' ' << reg << TR("\ndel ") << year; + if (_op == restore_reg) mess << TR(" della ditta ") << firm; mess << " dal " << day << '-' << month << '-' << year; if (yesno_box(mess)) { - mess << "\nSi desidera veramente continuare?"; + mess << TR("\nSi desidera veramente continuare?"); if (yesno_box(mess)) { switch (_op) @@ -262,7 +228,7 @@ void TRipristina_stampa::main_loop() } } } - else error_box("Gli archivi della ditta %ld non sono stati ancora generati", firm); + else error_box(FR("Gli archivi della ditta %ld non sono stati ancora generati"), firm); msk.reset(); } } @@ -270,6 +236,6 @@ void TRipristina_stampa::main_loop() int cg5400(int argc, char* argv[]) { TRipristina_stampa a ; - a.run(argc, argv, "Ripristino stampe"); + a.run(argc, argv, TR("Ripristino stampe")); return 0; } diff --git a/cg/cg5500.cpp b/cg/cg5500.cpp index 3f4955f12..eb1b8fc69 100755 --- a/cg/cg5500.cpp +++ b/cg/cg5500.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -24,7 +25,7 @@ const char* Visliq_app::itoname(int m) { const char* mn; if (m == 13) - return "Annuale"; + return TR("Annuale"); if (_freqviva == "M") return itom(m); @@ -32,16 +33,16 @@ const char* Visliq_app::itoname(int m) switch(m) { case 3: - mn = "1 Trimestre"; + mn = TR("1 Trimestre"); break; case 6: - mn = "2 Trimestre"; + mn = TR("2 Trimestre"); break; case 9: - mn = "3 Trimestre"; + mn = TR("3 Trimestre"); break; case 12: - mn = "4 Trimestre"; + mn = TR("4 Trimestre"); break; } @@ -54,11 +55,13 @@ void Visliq_app::set_freqviva() _freqviva = _lia->get("S7"); else { - TLocalisamfile ditte(LF_NDITTE); - ditte.zero(); - ditte.put("CODDITTA", get_firm()); - ditte.read(); - _freqviva = ditte.get("FREQVIVA"); + TString key; + + key.format("%ld", get_firm()); + + const TRectype & ditta = cache().get(LF_NDITTE, key); + + _freqviva = ditta.get("FREQVIVA"); } } @@ -67,12 +70,12 @@ bool Visliq_app::create() _firm = get_firm(); TDate oggi(TODAY); _year = oggi.year(); + open_files(LF_TABCOM, LF_TAB, LF_NDITTE, 0); + _nditte = new TRelation(LF_NDITTE); - _ditte = new TArray_sheet(-1, -1, -4, -4, "Selezione Ditte", - "Cod.@5|Ragione Sociale@50|Vers."); - + _ditte = new TArray_sheet(-1, -1, -4, -4, TR("Selezione Ditte"), + HR("Cod.@5|Ragione Sociale@50|Vers.")); _from_one = FALSE; - _del = new TTable("%DEL"); _lia = new TTable("%LIA"); _lim = new TTable("LIM"); @@ -171,35 +174,36 @@ void Visliq_app::build_nomiditte() { _nomiditte.destroy(); // ricostruire _nomiditte e rifare build_ditte_sheet - TLocalisamfile& dt = _nditte->lfile(); - TString fr(2); - TTable lia("%LIA"); + TRectype & ditta = _nditte->lfile().curr(); + TCursor cur(_nditte); + const TRecnotype items = cur.items(); - for (dt.first(); !dt.eof(); dt.next()) + cur.freeze(); + for (cur = 0L; cur.pos() < items; ++cur) { // check no archivi - fr = "??"; - bool good = prefix().exist(dt.get_long("CODDITTA")); + bool good = prefix().exist(ditta.get_long("CODDITTA")); if (good) { // check no parametri liquidazione TString16 cod; - cod.format("%05ld%d", dt.get_long("CODDITTA"), _year); - lia.put("CODTAB", cod); - if (lia.read() != NOERR) good = FALSE; - else fr = lia.get("S7"); - } - else continue; + + cod.format("%05ld%d", ditta.get_long("CODDITTA"), _year); + + const TRectype & lia = cache().get("%LIA", cod); + TToken_string* d = new TToken_string(64); + + // add record + d->add(ditta.get("CODDITTA")); + d->add(ditta.get("RAGSOC")); + + const TString & fr = lia.get("S7"); + + d->add(fr.empty() ? "??" : fr); + _nomiditte.add(d); + } - TToken_string* d = new TToken_string(64); - - // add record - d->add(dt.get("CODDITTA")); - d->add(dt.get("RAGSOC")); - d->add(fr); - - _nomiditte.add(d); } } @@ -245,21 +249,21 @@ const char* Visliq_app::link_handler(TMask& m, if (group != 0) m.hide(group); - if (st.find("Iva chiesta a rimborso") >= 0 || st.find("Rimborsi") >= 0) + if (st.find(TR("Iva chiesta a rimborso")) >= 0 || st.find(TR("Rimborsi")) >= 0) { group = -1; firstfoc = F_RIMBORSO; } - else if (st.find("debito") >= 0 || st.find("credito") >= 0) + else if (st.find(TR("debito")) >= 0 || st.find(TR("credito")) >= 0) { group = -2; firstfoc = F_RETTIFICA; } - else if (st.find("cconto") >= 0) + else if (st.find(TR("acconto")) >= 0) { group = -3; firstfoc = F_ACCONTO; } - else if (st.find("Versamenti") >= 0) + else if (st.find(TR("Versamenti")) >= 0) { group = -4; firstfoc = F_DELDATE; } - else if (st.find("Descrizione") >= 0) + else if (st.find(TR("Descrizione")) >= 0) { group = -5; firstfoc = F_DESCR3; } - else if (st.find("Variazioni d'imposta") >= 0) + else if (st.find(TR("Variazioni d'imposta")) >= 0) { group = -6; firstfoc = F_VARIMP; } - else if (st.find("Imposta non versata") >= 0) + else if (st.find(TR("Imposta non versata")) >= 0) { group = -7; firstfoc = F_IMPNONVER; } - if (st.find("Crediti") >= 0) + if (st.find(TR("Crediti")) >= 0) { group = -8; firstfoc = F_CREDSPEC; } m.show(group); @@ -309,7 +313,7 @@ bool Visliq_app::set_ditta(TMask_field& f, KEY k) } else { - f.warning_box("Non sono definiti i parametri liquidazione per la ditta %ld", + f.warning_box(FR("Non sono definiti i parametri liquidazione per la ditta %ld"), atol(ditta)); f.reset(); } @@ -373,7 +377,7 @@ bool Visliq_app::sel_mese_sh1 (TMask_field& f, KEY k) //if (m.dirty() || sh.sheet_mask().dirty()) if (m.field(F_CREDPREC).dirty() || app()._sh_dirty || app()._sv_dirty) { - KEY k = yesnocancel_box("Registrazione modifiche effettuate?"); + KEY k = yesnocancel_box(TR("Registrazione modifiche effettuate?")); if (k == K_YES) app().write_general(m); else if (k == K_NO) @@ -441,7 +445,7 @@ bool Visliq_app::sel_mese_sh2 (TMask_field& f, KEY k) //if (m.dirty()) if (m.field(F_CREDPREC).dirty() || app()._sh_dirty || app()._sv_dirty) { - KEY k = yesnocancel_box("Registrazione modifiche effettuate?"); + KEY k = yesnocancel_box(TR("Registrazione modifiche effettuate?")); if (k == K_YES) app().write_general(m); else if (k == K_NO) @@ -471,13 +475,6 @@ bool Visliq_app::sel_mese_sh2 (TMask_field& f, KEY k) tv.add(app().del()->get("S9"),4); tv.add(app().del()->get("R0"),5); sh.force_update(sel); - /* - sv.field(102).set(app().del()->get("D0")); - sv.field(103).set(app().del()->get("S7")); - sv.field(104).set(app().del()->get("S8")); - sv.field(105).set(app().del()->get("S9")); - sv.field(106).set(app().del()->get("R0")); - */ } return TRUE; @@ -577,7 +574,7 @@ bool Visliq_app::vis_all() case K_QUIT: if (_mask->dirty()) { - KEY k = yesnocancel_box("Registrazione modifiche effettuate?"); + KEY k = yesnocancel_box(TR("Registrazione modifiche effettuate?")); if (k == K_YES) write_general(*_mask); @@ -614,7 +611,7 @@ bool Visliq_app::vis_one(int m) TMask msk("cg5500d"); bool recorded = TRUE; - TString nomem("Liquidazione IVA "); + TString nomem(TR("Liquidazione IVA ")); nomem << itoname(m); nomem << " " << _year; @@ -641,12 +638,12 @@ bool Visliq_app::vis_one(int m) TBrowsefile_field& brw = (TBrowsefile_field&)msk.field(F_VISFLQ); brw.set_link_handler(link_handler); - brw.enable_link("Modifica: ", 'r'); + brw.enable_link(TR("Modifica: "), 'r'); TExternal_app liq("cg4 -2"); end_wait(); - TProgind* pp = new TProgind(10,"Estrazione liquidazione: prego attendere",FALSE,FALSE); + TProgind* pp = new TProgind(10,TR("Estrazione liquidazione: prego attendere"),FALSE,FALSE); liq.run(); if (liq.exitcode()) { @@ -661,7 +658,7 @@ bool Visliq_app::vis_one(int m) real rettifica = _lim->get_real("R5"); if (_lim->get_bool("B2")) - nomem << " (diritto al rimborso infraannuale)"; + nomem << TR(" (diritto al rimborso infraannuale)"); real acconto(0.0); @@ -709,7 +706,7 @@ bool Visliq_app::vis_one(int m) msk.set(F_CREDSPEC, credspec); begin_wait(); - brw.set_text(f, "CALCOLO LIQUIDAZIONE D'IMPOSTA"); + brw.set_text(f, TR("CALCOLO LIQUIDAZIONE D'IMPOSTA")); brw.goto_pos(brw.lines()-16l, 9); delete pp; @@ -786,8 +783,8 @@ bool Visliq_app::vis_one(int m) const bool old_rim = !rimborso.is_zero(); // check diritto (se non ce n'era gia' uno prima) if (!_lim->get_bool("B2") && !old_rim) - ok = yesno_box("Non risulta diritto al rimborso per il mese %d. Si desidera " - "confermare ugualmente?", m); + ok = yesno_box(FR("Non risulta diritto al rimborso per il mese %d. Si desidera " + "confermare ugualmente?"), m); } if (ok) { @@ -823,13 +820,6 @@ bool Visliq_app::vis_one(int m) if (msk.field(F_DELIMP).dirty()) { real itt = _lim->get_real("R10"); - // if (!itt.is_zero()) - // { - // uso importi al netto degli interessi - // (vengono riapplicati dopo in write_del) - // n_vers = n_vers/((itt+real(100.0))/real(100.0)); - // n_vers.round(0); - // } vers = n_vers; d_mod = TRUE; } @@ -883,7 +873,7 @@ bool Visliq_app::vis_one(int m) { if (!recorded) { - KEY kk = yesnocancel_box("Modifiche non registrate: salvare?"); + KEY kk = yesnocancel_box(TR("Modifiche non registrate: salvare?")); if (kk == K_YES) { if (l_mod) { write_liq(); recalc_next_liq(m, _liq_sheet, _vers_sheet); } @@ -1101,27 +1091,27 @@ void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& ver // una sburlata di search ...... int x = 0; long lvers = -1l; - long line = vsw->search("CALCOLO LIQUIDAZIONE D'IMPOSTA", x); + long line = vsw->search(TR("CALCOLO LIQUIDAZIONE D'IMPOSTA"), x); int wasdebt = ris.sign(); - long lrisd = vsw->search("RISULTATO", x, line, TRUE); // RISULTATO a debito - long lrisc = vsw->search("RISULTATO", x, lrisd+1, TRUE); // credito - long lrettc = vsw->search("Rettifiche IVA a credito",x,line,TRUE); - long lrettd = vsw->search("Rettifiche IVA a debito", x,line,TRUE); - long lacct = vsw->search("Versamento acconto dicembre",x,line,TRUE); - long lintr = vsw->search("Interesse",x,line,TRUE); - long livdv = vsw->search("IVA DOVUTA",x,line,TRUE); - long lrivr = vsw->search("Versamenti effettuati",x,line,TRUE); - long lvari = vsw->search("Variazioni d'imposta",x,line,TRUE); - long limnv = vsw->search("Imposta non versata",x,line,TRUE); - long lcicd = vsw->search("Credito IVA compensabile detratto",x,line,TRUE); - long iadoc = vsw->search("IVA a debito o a credito per il periodo",x,line,TRUE); - long lrimb = vsw->search(iadoc > 0 ? "Rimborsi" : "Iva chiesta a rimborso",x,line,TRUE); + long lrisd = vsw->search(TR("RISULTATO"), x, line, TRUE); // RISULTATO a debito + long lrisc = vsw->search(TR("RISULTATO"), x, lrisd+1, TRUE); // credito + long lrettc = vsw->search(TR("Rettifiche IVA a credito"),x,line,TRUE); + long lrettd = vsw->search(TR("Rettifiche IVA a debito"), x,line,TRUE); + long lacct = vsw->search(TR("Versamento acconto dicembre"),x,line,TRUE); + long lintr = vsw->search(TR("Interesse"),x,line,TRUE); + long livdv = vsw->search(TR("IVA DOVUTA"),x,line,TRUE); + long lrivr = vsw->search(TR("Versamenti effettuati"),x,line,TRUE); + long lvari = vsw->search(TR("Variazioni d'imposta"),x,line,TRUE); + long limnv = vsw->search(TR("Imposta non versata"),x,line,TRUE); + long lcicd = vsw->search(TR("Credito IVA compensabile detratto"),x,line,TRUE); + long iadoc = vsw->search(TR("IVA a debito o a credito per il periodo"),x,line,TRUE); + long lrimb = vsw->search(iadoc > 0 ? TR("Rimborsi") : TR("Iva chiesta a rimborso"),x,line,TRUE); if (wasdebt != 0) - lvers = vsw->search(wasdebt < 0 ? "CREDITO ATTUALE" : "IVA DA VERSARE", + lvers = vsw->search(wasdebt < 0 ? TR("CREDITO ATTUALE") : TR("IVA DA VERSARE"), x, line, TRUE); if (lvers == -1l) - lvers = vsw->search("IVA A DEBITO DA NON VERSARE", x, line, TRUE); + lvers = vsw->search(TR("IVA A DEBITO DA NON VERSARE"), x, line, TRUE); if (lvers == -1l) lvers = lrisc+1l; @@ -1164,7 +1154,7 @@ void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& ver vsw->replace(iadoc, " ", tab2); - iadoc = vsw->search("IVA dovuta o a credito per il periodo",x,line,TRUE); + iadoc = vsw->search(TR("IVA dovuta o a credito per il periodo"),x,line,TRUE); v = risul + credspec; if (v < ZERO) { @@ -1178,7 +1168,7 @@ void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& ver vsw->replace(iadoc, " ", tab2); TString256 ln; - long lcrs = vsw->search("Crediti speciali",x,line,TRUE); + long lcrs = vsw->search(TR("Crediti speciali"),x,line,TRUE); if (credspec.is_zero()) vsw->replace(lcrs, " ", 58); @@ -1186,7 +1176,7 @@ void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& ver replace_number(vsw, lcrs, credspec, 58); const bool print_intr = _freqviva == "T" && intr != 0.0; - const char* desc_inter = "Interessi dovuti per liquidazioni trimestrali"; + const char* desc_inter = TR("Interessi dovuti per liquidazioni trimestrali"); lintr = vsw->search(desc_inter, x, line, TRUE); if (print_intr) @@ -1208,16 +1198,16 @@ void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& ver vsw->replace(lintr, ln, 11); } - long idv = vsw->search("IMPORTO DA", x, iadoc, TRUE); + long idv = vsw->search(TR("IMPORTO DA"), x, iadoc, TRUE); if (idv < 0) idv = iadoc+6; if (risul > ZERO) { - ln = "IMPORTO DA "; + ln = TR("IMPORTO DA "); if (risul < min_vers(_year, month) && month < 13) - ln << "NON "; - ln << "VERSARE "; + ln << TR("NON "); + ln << TR("VERSARE "); replace_number(vsw, idv, risul, 75); } else @@ -1234,7 +1224,7 @@ void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& ver TCurrency rabs(-risul); TString16 str = rabs.string(TRUE); str.right_just(15); - ln.overwrite("CREDITO ATTUALE", 23); + ln.overwrite(TR("CREDITO ATTUALE"), 23); ln.overwrite(str, 58); if (lintr > 0) // Quindi niente riga "Interessi " ... { @@ -1257,14 +1247,14 @@ void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& ver if (lintr == -1) { lintr = lrisc + 2; - vsw->replace(lintr, "Interesse", 23); + vsw->replace(lintr, TR("Interesse"), 23); vsw->replace(lintr, itt.stringa(6,2), 33); vsw->replace(lintr, "%", 43); } if (livdv == -1) { livdv = lrisc + 1; - vsw->replace(livdv, "IVA DOVUTA", 23); + vsw->replace(livdv, TR("IVA DOVUTA"), 23); } if (lintr > 0) replace_number(vsw, lintr, intr, 75); @@ -1274,7 +1264,7 @@ void Visliq_app::recalc_liq_data(TViswin* vsw, real& rimb, real& rett, real& ver risul += intr; } } - ln.overwrite("IVA DA VERSARE", 23); + ln.overwrite(TR("IVA DA VERSARE"), 23); TCurrency rabs(risul); TString16 str = rabs.string(TRUE); str.right_just(15); @@ -1498,9 +1488,9 @@ void Visliq_app::read_general(TMask& m) TMask_field & crprec = m.field(F_CREDPREC); if (new_age_2000) - crprec.set_prompt("Credito compensabile inizio anno "); + crprec.set_prompt(TR("Credito compensabile inizio anno ")); else - crprec.set_prompt("Credito inizio anno "); + crprec.set_prompt(TR("Credito inizio anno ")); real cr_res = _lia->get_real("R0"); crprec.set(cr_res.string()); if (new_age_2000) @@ -1612,8 +1602,8 @@ void Visliq_app::read_general(TMask& m) if (nomemese == "4 Trimestre") nomemese = "4 Tr."; - if (i == 12) nomemese << " acconto"; - if (i == 13) nomemese << " saldo"; + if (i == 12) nomemese << TR(" acconto"); + if (i == 13) nomemese << TR(" saldo"); tt.add(nomemese,0); // mese tt.add(date[i-1].string(),1); // data vers. @@ -1872,11 +1862,11 @@ void Visliq_app::write_general(TMask& m) if (!nrimb.is_zero()) { if (risc <= risd) - ok = yesno_box("Il risultato IVA non evidenzia crediti nel mese %d. Si conferma " - " il rimborso?", i); + ok = yesno_box(FR("Il risultato IVA non evidenzia crediti nel mese %d. Si conferma " + " il rimborso?"), i); if (!_lim->get_bool("B2") && ok) - ok = yesno_box("Non risulta diritto al rimborso per il mese %d. Si conferma" - " il rimborso?", i); + ok = yesno_box(FR("Non risulta diritto al rimborso per il mese %d. Si conferma" + " il rimborso?"), i); } if (ok) @@ -1981,6 +1971,6 @@ void Visliq_app::write_general(TMask& m) int cg5500(int argc, char* argv[]) { Visliq_app app; - app.run(argc, argv, "Visualizzazione Liquidazione"); + app.run(argc, argv, TR("Visualizzazione Liquidazione")); return 0; } diff --git a/cg/cg5600.cpp b/cg/cg5600.cpp index 20b3be338..52bacdcd4 100755 --- a/cg/cg5600.cpp +++ b/cg/cg5600.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -40,7 +41,8 @@ public: bool do_restore(); bool restore_firm(long firm); - + void zero_cursor(const char * tablename); + static TRipristino_liq& app() { return (TRipristino_liq&)main_app(); } TRipristino_liq() {} @@ -83,35 +85,35 @@ void TRipristino_liq::build_nomiditte() { _nomiditte.destroy(); // ricostruire _nomiditte e rifare build_ditte_sheet - TLocalisamfile& dt = _nditte->lfile(); - TString fr("??"); - TTable lia("%LIA"); - - for (dt.first(); !dt.eof(); dt.next()) + TRectype & ditta = _nditte->lfile().curr(); + TCursor cur(_nditte); + const TRecnotype items = cur.items(); + + cur.freeze(); + for (cur = 0L; cur.pos() < items; ++cur) { // check no archivi - fr = "??"; - bool good = prefix().exist(dt.get_long("CODDITTA")); + bool good = prefix().exist(ditta.get_long("CODDITTA")); if (good) { // check no parametri liquidazione - lia.zero(); - const TString16 cod(format("%05ld%4s", dt.get_long("CODDITTA"), (const char*)_year)); - lia.put("CODTAB", cod); - if (lia.read() != NOERR) good = FALSE; - else fr = lia.get("S7"); - } - else continue; + TString16 cod; + + cod.format("%05ld%s", ditta.get_long("CODDITTA"), (const char *)_year); + + const TRectype & lia = cache().get("%LIA", cod); - TToken_string* d = new TToken_string(64); + TToken_string* d = new TToken_string(64); - // add record - d->add(dt.get("CODDITTA")); - d->add(dt.get("RAGSOC")); - d->add(fr); - - _nomiditte.add(d); + // add record + d->add(ditta.get("CODDITTA")); + d->add(ditta.get("RAGSOC")); + const TString & fr = lia.get("S7"); + + d->add(fr.empty() ? "??" : fr); + _nomiditte.add(d); + } } TApplication::set_firm(_firm); } @@ -124,8 +126,8 @@ bool TRipristino_liq::create() TDate oggi(TODAY); _year.format("%d",oggi.year()); _nditte = new TRelation(LF_NDITTE); - _ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Ditte", - "@1|Cod.@5|Ragione Sociale@50|Vers."); + _ditte = new TArray_sheet(-1, -1, 65, 20, TR("Selezione Ditte"), + HR("@1|Cod.@5|Ragione Sociale@50|Vers.")); build_nomiditte(); build_ditte_sheet(); @@ -176,6 +178,21 @@ bool TRipristino_liq::do_restore() return k != K_QUIT; } +void TRipristino_liq::zero_cursor(const char * tablename) +{ + TRelation rel(tablename); + TRectype & rec = rel.curr(); + + rec.put("CODTAB", _year); + + TCursor cur(&rel, "", 1, &rec, &rec); + const TRecnotype items = cur.items(); + + cur.freeze(); + for (cur = 0L; cur.pos() < items; ++cur) + rel.remove(); +} + bool TRipristino_liq::restore_firm(long firm) { // azzera: campi progressivi in LIA e PLA @@ -183,122 +200,53 @@ bool TRipristino_liq::restore_firm(long firm) set_firm(firm); TTable lia("%LIA"); - TTable pla("%PLA"); - TTable pim("PIM"); - TTable plm("PLM"); - TTable ptm("PTM"); - TTable ppa("PPA"); - TTable rmb("RMB"); - TTable lim("LIM"); - - // LIA - for (lia.first(); !lia.eof(); lia.next()) + TString cod; + + cod.format("%05ld%s", firm, (const char *)_year); + lia.put("CODTAB", cod); + + if (lia.read(_isequal, _lock) == NOERR) { - TString codtab(lia.get("CODTAB")); - - if (atol(codtab.mid(0,5)) == firm && - codtab.mid(5,4) == _year) - { - lia.put("R1",""); - lia.put("R2",""); - lia.put("R3",""); - lia.put("R4",""); - lia.put("R5",""); - lia.put("R6",""); - break; - } + lia.zero("R1"); + lia.zero("R2"); + lia.zero("R3"); + lia.zero("R4"); + lia.zero("R5"); + lia.zero("R6"); + lia.rewrite(); } - lia.rewrite(); - // PLA - for (pla.first(); !pla.eof(); pla.next()) + TRelation relpla("%PLA"); + TRectype & pla = relpla.curr(); + + pla.put("CODTAB", cod); + + TCursor cur(&relpla, "", 1, &pla, &pla); + const TRecnotype items = cur.items(); + + cur.freeze(); + for (cur = 0L; cur.pos() < items; ++cur) { - TString codtab(pla.get("CODTAB")); - - if (atol(codtab.mid(0,5)) == firm && - codtab.mid(5,4) == _year) - { - pla.put("R0",""); - pla.put("R1",""); - pla.put("R2",""); - pla.put("R3",""); - pla.put("R4",""); - pla.put("R9",""); - pla.put("R10",""); - pla.put("S1",""); - pla.put("S2",""); - pla.put("S3",""); - pla.put("S4",""); - } + relpla.lfile().reread(_lock); + pla.zero("R0"); + pla.zero("R1"); + pla.zero("R2"); + pla.zero("R3"); + pla.zero("R4"); + pla.zero("R9"); + pla.zero("R10"); + pla.zero("S1"); + pla.zero("S2"); + pla.zero("S3"); + pla.zero("S4"); + relpla.rewrite(); } - pla.rewrite(); - - // PIM - for (pim.first(); !pim.eof(); pim.next()) - { - TString codtab(pim.get("CODTAB")); - - if (codtab.mid(0,4) == _year) - pim.remove(); - } - // pim.packfile(); - // pim.packindex(); - - // PLM - for (plm.first(); !plm.eof(); plm.next()) - { - TString codtab(plm.get("CODTAB")); - - if (codtab.mid(0,4) == _year) - plm.remove(); - } - // plm.packfile(); - // plm.packindex(); - - // PTM - for (ptm.first(); !ptm.eof(); ptm.next()) - { - TString codtab(ptm.get("CODTAB")); - - if (codtab.mid(0,4) == _year) - ptm.remove(); - } - // ptm.packfile(); - // ptm.packindex(); - - // PPA - for (ppa.first(); !ppa.eof(); ppa.next()) - { - TString codtab(ppa.get("CODTAB")); - - if (codtab.mid(0,4) == _year) - ppa.remove(); - } - // ppa.packfile(); - // ppa.packindex(); - - // RMB - for (rmb.first(); !rmb.eof(); rmb.next()) - { - TString codtab(rmb.get("CODTAB")); - - if (codtab.mid(0,4) == _year) - rmb.remove(); - } - // rmb.packfile(); - // rmb.packindex(); - - // LIM - for (lim.first(); !lim.eof(); lim.next()) - { - TString codtab(lim.get("CODTAB")); - - if (codtab.mid(0,4) == _year) - lim.remove(); - } - // lim.packfile(); - // lim.packindex(); - + zero_cursor("PIM"); + zero_cursor("PLM"); + zero_cursor("PTM"); + zero_cursor("PPA"); + zero_cursor("RMB"); + zero_cursor("LIM"); return TRUE; } @@ -306,6 +254,6 @@ bool TRipristino_liq::restore_firm(long firm) int cg5600(int argc, char* argv[]) { TRipristino_liq app; - app.run(argc, argv, "Ripristino liquidazione"); + app.run(argc, argv, TR("Ripristino liquidazione")); return 0; }