diff --git a/ve/ve6600.cpp b/ve/ve6600.cpp index bdd17430c..94e808b0d 100755 --- a/ve/ve6600.cpp +++ b/ve/ve6600.cpp @@ -18,7 +18,7 @@ class TIndustriosa_app : public TSkeleton_application int _len_fase; protected: - const TString& conto_industriale(const TRiga_documento& row) const; + const TString& conto_industriale(const TRiga_documento& row, TString& conto) const; void trim_and_cut(TString& val, int len) const; void get_field(const TDocumento& doc, const TRectype& mov, const TRectype& rec, const char* field, TString& val) const; bool filerr(const char* name) const; @@ -29,29 +29,40 @@ public: virtual void main_loop(); }; -const TString& TIndustriosa_app::conto_industriale(const TRiga_documento& row) const +const TString& TIndustriosa_app::conto_industriale(const TRiga_documento& row, TString& conto) const { const TDocumento& doc = row.doc(); - const char tipocf = doc.get_char(DOC_TIPOCF); - + const bool acquisti = doc.get_char(DOC_TIPOCF) == 'F'; + conto.cut(0); if (row.is_merce()) { const TRectype& rec = cache().get(LF_ANAMAG, row.get(RDOC_CODARTMAG)); - return rec.get(tipocf == 'F' ? ANAMAG_CONTOINDA : ANAMAG_CONTOINDV); + conto = rec.get(acquisti ? ANAMAG_CONTOINDA : ANAMAG_CONTOINDV); } else if (row.is_prestazione()) { const TRectype& rec = cache().get("PRS", row.get(RDOC_CODART)); - return rec.get(tipocf == 'F' ? "S1" : "S2"); + conto = rec.get(acquisti ? "S1" : "S2"); + } + if (!conto.empty()) + { + TString16 cnt; + cnt << conto.mid(1,2); + cnt << conto.mid(4,2); + cnt << conto.mid(6); + conto = cnt; } - return EMPTY_STRING; + return conto; } void TIndustriosa_app::trim_and_cut(TString& val, int len) const { if (len > 0) { - val.ltrim('0'); + int zeroes = 0; + for (zeroes = 0; val[zeroes] == '0'; zeroes++); + if (zeroes > 0) + val.ltrim(zeroes); val.cut(len); } else @@ -86,34 +97,36 @@ void TIndustriosa_app::get_field(const TDocumento& doc, const TRectype& mov, con } else if (stricmp(field, "_CONINDU") == 0) { - val = conto_industriale((TRiga_documento&)rec); + conto_industriale((TRiga_documento&)rec, val); } else if (stricmp(field, "_IMPORTO") == 0) { TCurrency_documento imp(((TRiga_documento&)rec).importo(TRUE, FALSE), doc); imp.change_to_firm_val(); - val = imp.get_num().string(); + val = imp.get_num().stringa(); } else if (stricmp(field, "_IMPORTOVAL") == 0) { if (doc.in_valuta()) { const TCurrency_documento imp(((TRiga_documento&)rec).importo(TRUE, FALSE), doc); - val = imp.get_num().string(); + val = imp.get_num().stringa(); } } else if (stricmp(field, "_IMPOSTADOC") == 0) - { + { + TString16 conto; real impval; for (int i = 1; i <= doc.physical_rows(); i++) { const TRiga_documento& rdoc = doc[i]; - if (conto_industriale(rdoc).not_empty()) + conto_industriale(rdoc, conto); + if (conto.not_empty()) impval += rdoc.imposta(); } TCurrency_documento imposta(impval, doc); imposta.change_to_firm_val(); - val = imposta.get_num().string(); + val = imposta.get_num().stringa(); } else if (stricmp(field, "_SEZIONE") == 0) { @@ -122,17 +135,19 @@ void TIndustriosa_app::get_field(const TDocumento& doc, const TRectype& mov, con val = str; } else if (stricmp(field, "_TOTDOC") == 0) - { + { + TString16 conto; real totval; for (int i = 1; i <= doc.physical_rows(); i++) { const TRiga_documento& rdoc = doc[i]; - if (conto_industriale(rdoc).not_empty()) + conto_industriale(rdoc, conto); + if (conto.not_empty()) totval += rdoc.importo(TRUE, FALSE); } TCurrency_documento tot(totval, doc); tot.change_to_firm_val(); - val = tot.get_num().string(); + val = tot.get_num().stringa(); } } else @@ -152,8 +167,24 @@ void TIndustriosa_app::get_field(const TDocumento& doc, const TRectype& mov, con const TFieldtypes ft = r->type(field); switch (ft) { + case _alfafld: + val = r->get(field); + if (r->num() == LF_DOC && val.not_empty() && real::is_real(val)) // Campo virtuale numerico + { + const real n(val); + val = n.stringa(); + } + break; case _nullfld: val.cut(0); break; - case _realfld: val = r->get_real(field).string(); break; + case _realfld: + { + const real n(r->get(field)); + if (!n.is_zero()) + val = n.stringa(); + else + val.cut(0); + } + break; default: val = r->get(field); break; } } @@ -187,7 +218,7 @@ bool TIndustriosa_app::get_mci_path(TFilename& shell) const lcl << ":"; shell.insert(lcl); } - + shell.add("appl.ini"); if (shell.exist()) { TConfig appl(shell, "Paths"); @@ -214,8 +245,8 @@ bool TIndustriosa_app::call_mci(TDocumento& doc, const TRectype& movimento) TString_array para; mci.list_paragraphs(para); - _len_commessa = mci.get_int("LCommessa", "General", -1, 10); - _len_fase = mci.get_int("LFase", "General", -1, 10); + _len_commessa = mci.get_int("LCommessa", "General", -1, 20); + _len_fase = mci.get_int("LFase", "General", -1, 0); int pos =para.find("General"); if (pos >= 0) @@ -244,8 +275,9 @@ bool TIndustriosa_app::call_mci(TDocumento& doc, const TRectype& movimento) for (int r = 1; r <= doc.physical_rows(); r++) { const TRiga_documento& rdoc = doc[r]; - - if (conto_industriale(rdoc).not_empty()) + TString16 conto; + conto_industriale(rdoc, conto); + if (conto.not_empty()) { TString16 pr; pr.format("%s_%d", (const char*)para.row(1), i++); // Paragrafo riga contabile @@ -266,7 +298,7 @@ bool TIndustriosa_app::call_mci(TDocumento& doc, const TRectype& movimento) TFilename shell; if (get_mci_path(shell)) { - shell << ' ' << ininame; + shell << " -c " << ininame << ','; TExternal_app app(shell); ok = app.run() == 0; if (ok) @@ -320,7 +352,7 @@ void TIndustriosa_app::main_loop() filerr(ininame); } else - error_box("Specificare il file con la transazione da eseguire"); + error_box("Specificare il file con la transazione"); } ////// Esecuzione del programma ///////////