diff --git a/src/ba/bacnv.cpp b/src/ba/bacnv.cpp index 4ad80da67..a039de13d 100755 --- a/src/ba/bacnv.cpp +++ b/src/ba/bacnv.cpp @@ -205,6 +205,7 @@ public: //roba per il file della rilevazione ore void convert_rilore(); long convert_CONAI(); + void update_righe_doc(); TConversione_archivi() : _oldditta(0), _codditta(0), _error(0), _exitcode(1) {} }; @@ -382,6 +383,8 @@ bool TConversione_archivi::menu(MENU_TAG) case 26: _exitcode = convert_CONAI(); break; + case 27: + update_righe_doc(); default: break; } @@ -2214,49 +2217,14 @@ void TConversione_archivi::convert_profile(const char* profile_name) void TConversione_archivi::convert_CONAI_righe() { -/* - TArray old_conai_cod; - TArray old_conai_peso; - TArray new_conai_cod; - TArray new_conai_peso; -*/ TFast_isamfile f(LF_RIGHEDOC); TCursor c(new TRelation(LF_RIGHEDOC)); -/* c.relation()->add(LF_DOC, "PROVV==PROVV|ANNO==ANNO|CODNUM==CODNUM|NDOC==NDOC"); - c.relation()->add("%TIP", "CODTAB==TIPODOC", 1, LF_DOC, 200); - c.setfilter("200@->B6==\"X\""); */ c.relation()->lfile().set_curr(new TAuto_variable_rectype(LF_RIGHEDOC)); TRectype & r = c.curr(); TToken_string key; const long items = c.items(); TProgind pi(items, TR("Conversione righe documento..."), false); - - /*old_conai_cod.add(new TRecfield(r, "RG1:CONSCACC")); - old_conai_cod.add(new TRecfield(r, "RG1:CONSCALL")); - old_conai_cod.add(new TRecfield(r, "RG1:CONSCCAR")); - old_conai_cod.add(new TRecfield(r, "RG1:CONSCPLA")); - old_conai_cod.add(new TRecfield(r, "RG1:CONSCLEG")); - old_conai_cod.add(new TRecfield(r, "RG1:CONSCVET")); - old_conai_peso.add(new TRecfield(r, "RG1:CONPUACC")); - old_conai_peso.add(new TRecfield(r, "RG1:CONPUALL")); - old_conai_peso.add(new TRecfield(r, "RG1:CONPUCAR")); - old_conai_peso.add(new TRecfield(r, "RG1:CONPUPLA")); - old_conai_peso.add(new TRecfield(r, "RG1:CONPULEG")); - old_conai_peso.add(new TRecfield(r, "RG1:CONPUVET")); - new_conai_cod.add(new TRecfield(r, "RG1:CCON(1)")); - new_conai_cod.add(new TRecfield(r, "RG1:CCON(2)")); - new_conai_cod.add(new TRecfield(r, "RG1:CCON(3)")); - new_conai_cod.add(new TRecfield(r, "RG1:CCON(4)")); - new_conai_cod.add(new TRecfield(r, "RG1:CCON(6)")); - new_conai_cod.add(new TRecfield(r, "RG1:CCON(6)")); - new_conai_peso.add(new TRecfield(r, "RG1:PCON(1)")); - new_conai_peso.add(new TRecfield(r, "RG1:PCON(2)")); - new_conai_peso.add(new TRecfield(r, "RG1:PCON(3)")); - new_conai_peso.add(new TRecfield(r, "RG1:PCON(4)")); - new_conai_peso.add(new TRecfield(r, "RG1:PCON(5)")); - new_conai_peso.add(new TRecfield(r, "RG1:PCON(6)")); */ - const char * const old_conai_cod[CONAI_CLASSES] = { "CONSCACC", "CONSCALL", "CONSCCAR", "CONSCPLA", "CONSCLEG", "CONSCVET" }; const char * const old_conai_peso[CONAI_CLASSES] = { "CONPUACC", "CONPUALL", "CONPUCAR", "CONPUPLA", "CONPULEG", "CONPUVET" }; @@ -2287,7 +2255,6 @@ void TConversione_archivi::convert_CONAI_righe() for (int j = 0; j < CONAI_CLASSES; j++) { - // TString16 cat = (const char *)((TRecfield&)old_conai_cod[j]); TString16 cat = r.get(old_conai_cod[j]); if (cat.full()) @@ -2296,13 +2263,6 @@ void TConversione_archivi::convert_CONAI_righe() if (new_cat.full() && new_cat != cat) cat = new_cat; - - /* - (TRecfield&) new_conai_cod[pos] = cat; - (TRecfield&) new_conai_peso[pos++] = (const char *)((TRecfield&) old_conai_peso[j]); - (TRecfield&) old_conai_cod[j] = ""; - (TRecfield&) old_conai_peso[j] = ""; - */ r.put(conai_sottocat_name(pos), cat); r.put(conai_peso_name(pos++), r.get(old_conai_peso[j])); r.zero(old_conai_cod[j]); @@ -2319,7 +2279,6 @@ void TConversione_archivi::convert_CONAI_righe() if (new_cat.full() && new_cat != cat) { - /// (TRecfield&)new_conai_cod[j] = new_cat; r.put(conai_sottocat_name(j + 1), new_cat); changed = true; } @@ -2475,6 +2434,63 @@ long TConversione_archivi::convert_CONAI() return 0; } +////////////////////////////////////////////////////////////////////////////// +// Sistem le righe documento + +void TConversione_archivi::update_righe_doc() +{ + TFast_isamfile f(LF_RIGHEDOC); + TCursor c(new TRelation(LF_RIGHEDOC)); c.relation()->lfile().set_curr(new TAuto_variable_rectype(LF_RIGHEDOC)); + TRectype & r = c.curr(); + const long items = c.items(); + TProgind pi(items, TR("Aggiornamento righe documento..."), false); + const char * const old_conai_cod[CONAI_CLASSES] = { "CONSCACC", "CONSCALL", "CONSCCAR", "CONSCPLA", "CONSCLEG", "CONSCVET" }; + const char * const old_conai_peso[CONAI_CLASSES] = { "CONPUACC", "CONPUALL", "CONPUCAR", "CONPUPLA", "CONPULEG", "CONPUVET" }; + TCursor frr(new TRelation("%FRR")); + const int fritems = frr.items(); + TString_array formule; + + for (frr = 0L; frr.pos() < fritems; ++frr) + formule.add(frr.curr().get("CODTAB")); + for (c = 0L; c.pos() < items && pi.addstatus(1); ++c) + { + const TString4 tipo = r.get(RDOC_TIPORIGA); + const TTipo_riga_documento & tiporiga = TRiga_documento::tipo(tipo); + bool changed = false; + + if (tiporiga.is_merce() || tiporiga.is_omaggio()) + { + for (int j = 0; j < CONAI_CLASSES; j++) + { + if (r.get(old_conai_peso[j]).full()) + { + r.zero(old_conai_cod[j]); + r.zero(old_conai_peso[j]); + changed = true; + } + if (r.get(conai_sottocat_name(j + 1)).blank() && + r.get(conai_peso_name(j + 1)).full()) + { + r.zero(conai_peso_name(j + 1)); + changed = true; + } + } + } + else + if (tiporiga.is_descrizione()) + { + for (int i = 0; i < fritems; i++) + if (r.get(formule[i]).full()) + { + r.zero(formule[i]); + changed = true; + } + } + if (changed && r.rewrite(f) != NOERR) + cantwrite_box(f.description()); + } +} + /////////////////////////////////////////////////////////// // Programma di conversione archivi speciale /////////////////////////////////////////////////////////// diff --git a/src/ba/bamenu.men b/src/ba/bamenu.men index 06b47bd25..03c35ae73 100755 --- a/src/ba/bamenu.men +++ b/src/ba/bamenu.men @@ -134,6 +134,7 @@ Item_03 = "Aggiornamento profili documento personalizzati", "bacnv 23", "" Item_04 = "Conversione documenti CONAI", "bacnv 24", "" Item_05 = "Gestione attivazione licenze", "ba2 -7", "" Item_06 = "Aggiornamento Nazioni ISO 2017" "ba7 -4", "" +Item_04 = "Aggiornamento righe documento", "bacnv 27", "" [MENU_PREFERITI] Caption = "Preferiti"