Patch level : 2.0 nopatch

Files correlati     : ve6.exe
Ricompilazione Demo : [ ]
Commento            :

Corretto invio a contabilita' industriale


git-svn-id: svn://10.65.10.50/trunk@11628 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2003-12-01 08:52:07 +00:00
parent d8388facbb
commit 85ea466cfe

View File

@ -18,7 +18,7 @@ class TIndustriosa_app : public TSkeleton_application
int _len_fase; int _len_fase;
protected: 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 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; void get_field(const TDocumento& doc, const TRectype& mov, const TRectype& rec, const char* field, TString& val) const;
bool filerr(const char* name) const; bool filerr(const char* name) const;
@ -29,29 +29,40 @@ public:
virtual void main_loop(); 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 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()) if (row.is_merce())
{ {
const TRectype& rec = cache().get(LF_ANAMAG, row.get(RDOC_CODARTMAG)); 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 } else
if (row.is_prestazione()) if (row.is_prestazione())
{ {
const TRectype& rec = cache().get("PRS", row.get(RDOC_CODART)); 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 void TIndustriosa_app::trim_and_cut(TString& val, int len) const
{ {
if (len > 0) 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); val.cut(len);
} }
else else
@ -86,34 +97,36 @@ void TIndustriosa_app::get_field(const TDocumento& doc, const TRectype& mov, con
} else } else
if (stricmp(field, "_CONINDU") == 0) if (stricmp(field, "_CONINDU") == 0)
{ {
val = conto_industriale((TRiga_documento&)rec); conto_industriale((TRiga_documento&)rec, val);
} else } else
if (stricmp(field, "_IMPORTO") == 0) if (stricmp(field, "_IMPORTO") == 0)
{ {
TCurrency_documento imp(((TRiga_documento&)rec).importo(TRUE, FALSE), doc); TCurrency_documento imp(((TRiga_documento&)rec).importo(TRUE, FALSE), doc);
imp.change_to_firm_val(); imp.change_to_firm_val();
val = imp.get_num().string(); val = imp.get_num().stringa();
} else } else
if (stricmp(field, "_IMPORTOVAL") == 0) if (stricmp(field, "_IMPORTOVAL") == 0)
{ {
if (doc.in_valuta()) if (doc.in_valuta())
{ {
const TCurrency_documento imp(((TRiga_documento&)rec).importo(TRUE, FALSE), doc); const TCurrency_documento imp(((TRiga_documento&)rec).importo(TRUE, FALSE), doc);
val = imp.get_num().string(); val = imp.get_num().stringa();
} }
} else } else
if (stricmp(field, "_IMPOSTADOC") == 0) if (stricmp(field, "_IMPOSTADOC") == 0)
{ {
TString16 conto;
real impval; real impval;
for (int i = 1; i <= doc.physical_rows(); i++) for (int i = 1; i <= doc.physical_rows(); i++)
{ {
const TRiga_documento& rdoc = doc[i]; const TRiga_documento& rdoc = doc[i];
if (conto_industriale(rdoc).not_empty()) conto_industriale(rdoc, conto);
if (conto.not_empty())
impval += rdoc.imposta(); impval += rdoc.imposta();
} }
TCurrency_documento imposta(impval, doc); TCurrency_documento imposta(impval, doc);
imposta.change_to_firm_val(); imposta.change_to_firm_val();
val = imposta.get_num().string(); val = imposta.get_num().stringa();
} else } else
if (stricmp(field, "_SEZIONE") == 0) if (stricmp(field, "_SEZIONE") == 0)
{ {
@ -122,17 +135,19 @@ void TIndustriosa_app::get_field(const TDocumento& doc, const TRectype& mov, con
val = str; val = str;
} else } else
if (stricmp(field, "_TOTDOC") == 0) if (stricmp(field, "_TOTDOC") == 0)
{ {
TString16 conto;
real totval; real totval;
for (int i = 1; i <= doc.physical_rows(); i++) for (int i = 1; i <= doc.physical_rows(); i++)
{ {
const TRiga_documento& rdoc = doc[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); totval += rdoc.importo(TRUE, FALSE);
} }
TCurrency_documento tot(totval, doc); TCurrency_documento tot(totval, doc);
tot.change_to_firm_val(); tot.change_to_firm_val();
val = tot.get_num().string(); val = tot.get_num().stringa();
} }
} }
else else
@ -152,8 +167,24 @@ void TIndustriosa_app::get_field(const TDocumento& doc, const TRectype& mov, con
const TFieldtypes ft = r->type(field); const TFieldtypes ft = r->type(field);
switch (ft) 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 _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; default: val = r->get(field); break;
} }
} }
@ -187,7 +218,7 @@ bool TIndustriosa_app::get_mci_path(TFilename& shell) const
lcl << ":"; lcl << ":";
shell.insert(lcl); shell.insert(lcl);
} }
shell.add("appl.ini");
if (shell.exist()) if (shell.exist())
{ {
TConfig appl(shell, "Paths"); TConfig appl(shell, "Paths");
@ -214,8 +245,8 @@ bool TIndustriosa_app::call_mci(TDocumento& doc, const TRectype& movimento)
TString_array para; TString_array para;
mci.list_paragraphs(para); mci.list_paragraphs(para);
_len_commessa = mci.get_int("LCommessa", "General", -1, 10); _len_commessa = mci.get_int("LCommessa", "General", -1, 20);
_len_fase = mci.get_int("LFase", "General", -1, 10); _len_fase = mci.get_int("LFase", "General", -1, 0);
int pos =para.find("General"); int pos =para.find("General");
if (pos >= 0) 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++) for (int r = 1; r <= doc.physical_rows(); r++)
{ {
const TRiga_documento& rdoc = doc[r]; const TRiga_documento& rdoc = doc[r];
TString16 conto;
if (conto_industriale(rdoc).not_empty()) conto_industriale(rdoc, conto);
if (conto.not_empty())
{ {
TString16 pr; pr.format("%s_%d", (const char*)para.row(1), i++); // Paragrafo riga contabile 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; TFilename shell;
if (get_mci_path(shell)) if (get_mci_path(shell))
{ {
shell << ' ' << ininame; shell << " -c " << ininame << ',';
TExternal_app app(shell); TExternal_app app(shell);
ok = app.run() == 0; ok = app.run() == 0;
if (ok) if (ok)
@ -320,7 +352,7 @@ void TIndustriosa_app::main_loop()
filerr(ininame); filerr(ininame);
} }
else else
error_box("Specificare il file con la transazione da eseguire"); error_box("Specificare il file con la transazione");
} }
////// Esecuzione del programma /////////// ////// Esecuzione del programma ///////////