Spezzata la adjust_perc_imp (fornita per il test di Ferdinando)

git-svn-id: svn://10.65.10.50/trunk@2443 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1996-01-12 18:08:48 +00:00
parent 8ffb470266
commit d3e99e3642
2 changed files with 44 additions and 15 deletions

View File

@ -1248,30 +1248,57 @@ void TPagamento::adjust_parameters()
}
}
void TPagamento::adjust_perc_imp(bool is_perc, int rdiff)
void TPagamento::adjust_perc(int rdiff)
{
real toshare(100.0); real other(100.0);
if (is_perc)
toshare = (_tpr < 4 ? _firstr : _secndr);
else
other = (_tpr < 4 ? _firstr : _secndr);
real other(_tpr < 4 ? _firstr : _secndr);
TDistrib dt(toshare, is_perc ? _round : 2);
const int first = _tpr > 3 ? 1 : 0;
for (int j = first; j < _rate.items(); j++)
{
real rvl = tpay_rata(j);
// togli pezxo di troppo
if (j == first && _tpr > 0 && _tpr < 4)
rvl -= _secndr;
real zpx = (rvl * 100.0)/other; // percentuale
zpx.round(2);
set_percrata(j, zpx);
if (_cambio != 1.0)
{
real implit(tpay_rata(j));
implit *= _cambio;
implit.round();
TToken_string& tr = rata(j);
tr.add(implit.string(), 7);
}
}
}
void TPagamento::adjust_perc_imp(bool is_perc, int rdiff)
{
if (!is_perc)
{
adjust_perc(rdiff);
return;
}
real toshare(_tpr < 4 ? _firstr : _secndr);
const real other(100.0);
TDistrib dt(toshare, _round);
const int first = _tpr > 3 ? 1 : 0;
// for (int j = first; j < _rate.items(); j++)
for (int j = _rate.items() - 1 ; j >= first; j--)
for (int j = _rate.items() - 1; j >= first ; j--)
{
real rvl = is_perc ? perc_rata(j) : tpay_rata(j);
real rvl = perc_rata(j);
// togli pezxo di troppo
if (!is_perc && j == first && _tpr > 0 && _tpr < 4)
rvl -= _secndr;
real zpx = rvl/other; // percentuale
dt.add(zpx); // * cento???
}
// for (j = first; j < n_rate(); j++)
for (j = n_rate() - 1 ; j >= first; j--)
for (j = n_rate() - 1; j >= first ; j--)
{
real rfirst(0.0);
TToken_string& tr = rata(j);
@ -1286,16 +1313,16 @@ void TPagamento::adjust_perc_imp(bool is_perc, int rdiff)
real reminder = toshare - rfirst;
real rdiv = reminder.is_zero() ? real(0.0) :
(reminder / real(_rate.items() - (1+first)));
rdiv.round( is_perc ? _round : 2);
rdiv.round(_round);
rfirst += reminder - (rdiv * real(_rate.items() - (1+first)));
rvl = rdiv;
}
}
if (is_perc && j == first && _tpr > 0 && _tpr < 4)
if (j == first && _tpr > 0 && _tpr < 4)
rfirst += _secndr;
tr.add((j == first ? rfirst.string() : rvl.string()), is_perc ? 4 : 1);
tr.add((j == first ? rfirst.string() : rvl.string()), 4);
if (_cambio != 1.0)
{

View File

@ -74,6 +74,8 @@ protected:
void adjust_parameters();
// riaggiusta le percentuali o gli importi rispetto al dato modificato
void adjust_perc_imp(bool is_perc, int rdiff);
// riaggiusta le percentuali rispetto al dato modificato
void TPagamento::adjust_perc(int rdiff);
// controlla il segno di un valore in base a _tpr e row
bool sign_ok(const real& val, int row) const;