Cazzata 2

git-svn-id: svn://10.65.10.50/trunk@1097 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1995-03-10 10:48:50 +00:00
parent 33d1503c69
commit 1accaaeea9

View File

@ -238,3 +238,79 @@ const char* TBill::string(int mode)
return s;
}
///////////////////////////////////////////////////////////
// Importo
///////////////////////////////////////////////////////////
const TImporto& TImporto::add_to(TToken_string& s) const
{
const bool dare = sezione() == 'D';
const char* v = valore().string();
s.add(dare ? v : "", 0);
s.add(dare ? "" : v, 1);
return *this;
}
// Cerified 99%
// Ambigous section for ZERO
const TImporto& TImporto::operator =(TToken_string& sv)
{
_valore = real(sv.get(0));
if (_valore == ZERO)
{
_valore = real(sv.get());
_sezione = 'A';
}
else
_sezione = 'D';
return *this;
}
const TImporto& TImporto::set(char s, const real& v)
{
CHECKD(s == 'D' || s == 'A', "Sezione errata per importo: codice ", (int)s);
_sezione = s; _valore = v;
return *this;
}
const TImporto& TImporto::operator += (const TImporto& i)
{
if (_sezione == i._sezione)
_valore += i._valore;
else
_valore -= i._valore;
return *this;
}
const TImporto& TImporto::operator -= (const TImporto& i)
{
if (_sezione == i._sezione)
_valore -= i._valore;
else
_valore += i._valore;
return *this;
}
const TImporto& TImporto::swap_section()
{
_sezione = (_sezione == 'D') ? 'A' : 'D';
return *this;
}
const TImporto& TImporto::normalize()
{
if (_valore.sign() < 0)
{
_valore = -_valore;
swap_section();
}
return *this;
}