Patch level : 10.0
Files correlati : meglib02 vedoc Ricompilazione Demo : [ ] Commento : Modificata da Guy la convert_to_um in modo che sia in grado di gestire le conversioni dei pesi per le lavanderie git-svn-id: svn://10.65.10.50/trunk@20202 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
055f037035
commit
a0f460303d
@ -125,7 +125,7 @@ public:
|
||||
const char * first_um() const { return um().rows() > 0 ? um()[1].get(UMART_UM) : ""; }
|
||||
|
||||
static void round_um(real& v, const char* to_um);
|
||||
real convert_to_um(const real& v, const char* to_um, const char* from_um = NULL, bool arrotonda = true);
|
||||
real convert_to_um(const real& v, const TString& to_um, const TString& from_um = EMPTY_STRING, bool arrotonda = true);
|
||||
|
||||
TRecord_array & um() const { return body(LF_UMART); }
|
||||
TRecord_array & deslin() const { return body(LF_DESLIN); }
|
||||
|
@ -342,18 +342,17 @@ void TArticolo::round_um(real& r, const char* to_um)
|
||||
}
|
||||
}
|
||||
|
||||
real TArticolo::convert_to_um(const real& v, const char* to_um, const char* from_um, bool arrotonda)
|
||||
real TArticolo::convert_to_um(const real& v, const TString& to_um, const TString& from_um, bool arrotonda)
|
||||
{
|
||||
// Inutile convertire valori nulli ed
|
||||
// altrettanto inutile convertire un'unica unita' di misura
|
||||
if (v.is_zero() || um().rows() <= 1)
|
||||
// Inutile convertire valori nulli
|
||||
if (v.is_zero() || to_um == from_um) // (|| um().rows() <= 1) Non funzionerebbe coi pesi che non appartengano a LF_UMART
|
||||
return v;
|
||||
|
||||
// Se from_um non specificato significa che la qta che si desidera convertire e' in UM base
|
||||
// Gli indici delle unita; di misura valide partono da 1
|
||||
int i1 = (to_um && *to_um) ? find_um(to_um) : 1;
|
||||
int i2 = (from_um && *from_um) ? find_um(from_um) : 1;
|
||||
if (i1 == i2) // Inutile convertire in se stessi
|
||||
int i1 = to_um.full() ? find_um(to_um) : 1;
|
||||
int i2 = from_um.full() ? find_um(from_um) : 1;
|
||||
if (i1 == i2 && i1 > 0) // Inutile convertire in se stessi
|
||||
return v;
|
||||
|
||||
fraction f(v, UNO);
|
||||
@ -369,7 +368,7 @@ real TArticolo::convert_to_um(const real& v, const char* to_um, const char* from
|
||||
const TRectype& fromum = cache().get("%UMS", from_um);
|
||||
if (fromum.get("S7") == to_um)
|
||||
{
|
||||
fc2 = fromum.get_real(UMART_FC);
|
||||
fc2 = fromum.get_real("R10");
|
||||
i1 = 1; // La conversione termina qui: non moltiplicare per fc1!
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user