Merge branch 'R_10_00' of http://10.65.20.33/sirio/CAMPO/campo into R_10_00

This commit is contained in:
Sirio Builder 2020-01-22 11:33:43 +01:00
commit 5fb7cbbf26

View File

@ -615,9 +615,9 @@ int TExpr_documento::parse_user_func(const char * name, int nparms) const
if (strcmp(name, "NRATE") == 0) if (strcmp(name, "NRATE") == 0)
return nparms == 0 ? _nrate : -1; return nparms == 0 ? _nrate : -1;
if (strcmp(name, "QTACONAI") == 0) if (strcmp(name, "QTACONAI") == 0)
return nparms >= 1 && nparms < 3 ? _qtaconai : -1; return nparms >= 1 && nparms < 4 ? _qtaconai : -1;
if (strcmp(name, "VALCONAI") == 0) if (strcmp(name, "VALCONAI") == 0)
return nparms >= 1 && nparms < 3 ? _valconai : -1; return nparms >= 1 && nparms < 4 ? _valconai : -1;
return -1; return -1;
} }
@ -1068,12 +1068,11 @@ void TExpr_documento::evaluate_user_func(int index, int nparms, TEval_stack & st
break; break;
case _qtaconai: case _qtaconai:
{ {
int sp = stack.count(); const int ndec = (nparms > 2) ? (int)stack.pop_real().integer() : 5;
int tipo_calcolo = (nparms > 1) ? (int)stack.pop_real().integer() : 0; const int tipo_calcolo = (nparms > 1) ? (int)stack.pop_real().integer() : 0;
TString cat = stack.pop_string(); const TString cat = stack.pop_string();
if (stack.count() >= sp - 2) stack.push(ZERO);
stack.push(ZERO);
real & val = stack.peek_real(); real & val = stack.peek_real();
@ -1107,7 +1106,7 @@ void TExpr_documento::evaluate_user_func(int index, int nparms, TEval_stack & st
val *= (perc_esenz / CENTO); val *= (perc_esenz / CENTO);
} }
val.round(5); val.round(ndec);
} }
else else
val = ZERO; val = ZERO;
@ -1115,13 +1114,12 @@ void TExpr_documento::evaluate_user_func(int index, int nparms, TEval_stack & st
break; break;
case _valconai: case _valconai:
{ {
int sp = stack.count(); const int ndec = (nparms > 2) ? (int)stack.pop_real().integer() : 5;
int tipo_calcolo = (nparms > 1) ? (int)stack.pop_real().integer() : 0; const int tipo_calcolo = (nparms > 1) ? (int)stack.pop_real().integer() : 0;
TString cat = stack.pop_string(); const TString cat = stack.pop_string();
TString_array sottocat_found; TString_array sottocat_found;
if (stack.count() >= sp - 2) stack.push(ZERO);
stack.push(ZERO);
real & val = stack.peek_real(); real & val = stack.peek_real();
@ -1135,7 +1133,7 @@ void TExpr_documento::evaluate_user_func(int index, int nparms, TEval_stack & st
{ {
sottocat_found.add(sottocat); sottocat_found.add(sottocat);
stack.push(sottocat); stack.push(sottocat);
stack.push(tipo_calcolo); stack.push(tipo_calcolo);
evaluate_user_func(_qtaconai, 2, stack, type); evaluate_user_func(_qtaconai, 2, stack, type);
real valqta = stack.pop_real(); real valqta = stack.pop_real();
@ -1155,7 +1153,7 @@ void TExpr_documento::evaluate_user_func(int index, int nparms, TEval_stack & st
const real prezzo = rdoc.get_real(RDOC_PREZZO); const real prezzo = rdoc.get_real(RDOC_PREZZO);
val = valqta * prezzo; val = valqta * prezzo;
val.round(5); val.round(ndec);
break; break;
} }