mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug #502853 - Incorrent tax rounding in invoice (rounding of .5)
This patch changes the default rounding behaviour in GnuCash from "Round to nearest even" to "Round away to infinity". See the bugreport for more details on these different rounding methods. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19695 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
4a97361d38
commit
a0c19b4c71
@ -164,12 +164,11 @@ gnc_convert_to_euro(const gnc_commodity * currency, gnc_numeric value)
|
||||
{
|
||||
gnc_numeric rate;
|
||||
|
||||
rate = double_to_gnc_numeric (result->rate, 100000, GNC_HOW_RND_ROUND);
|
||||
rate = double_to_gnc_numeric (result->rate, 100000, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
/* Which rounding should be used here? H. Thoma said
|
||||
GNC_HOW_RND_FLOOR, but I (cstim) think he's wrong -- the official
|
||||
rules say you *have* to use GNC_HOW_RND_ROUND! */
|
||||
return gnc_numeric_div (value, rate, 100, GNC_HOW_RND_ROUND);
|
||||
/* EC Regulation 1103/97 states we should use "Round half away from zero"
|
||||
* See http://europa.eu/legislation_summaries/economic_and_monetary_affairs/institutional_and_economic_framework/l25025_en.htm */
|
||||
return gnc_numeric_div (value, rate, 100, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,10 +197,12 @@ gnc_convert_from_euro(const gnc_commodity * currency, gnc_numeric value)
|
||||
{
|
||||
gnc_numeric rate;
|
||||
|
||||
rate = double_to_gnc_numeric (result->rate, 100000, GNC_HOW_RND_ROUND);
|
||||
rate = double_to_gnc_numeric (result->rate, 100000, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
/* EC Regulation 1103/97 states we should use "Round half away from zero"
|
||||
* See http://europa.eu/legislation_summaries/economic_and_monetary_affairs/institutional_and_economic_framework/l25025_en.htm */
|
||||
return gnc_numeric_mul (value, rate, gnc_commodity_get_fraction (currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,7 +229,7 @@ gnc_euro_currency_get_rate (const gnc_commodity *currency)
|
||||
return gnc_numeric_zero ();
|
||||
|
||||
return double_to_gnc_numeric (result->rate, GNC_DENOM_AUTO,
|
||||
GNC_HOW_DENOM_SIGFIGS(6) | GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_DENOM_SIGFIGS(6) | GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
|
@ -393,7 +393,7 @@ func_op(const char *fname, int argc, void **argv)
|
||||
result = g_new0( gnc_numeric, 1 );
|
||||
*result = double_to_gnc_numeric( scm_num2dbl(scmTmp, G_STRFUNC),
|
||||
GNC_DENOM_AUTO,
|
||||
GNC_HOW_DENOM_SIGFIGS(6) | GNC_HOW_RND_ROUND );
|
||||
GNC_HOW_DENOM_SIGFIGS(6) | GNC_HOW_RND_ROUND_HALF_UP );
|
||||
/* FIXME: cleanup scmArgs = scm_list, cons'ed cells? */
|
||||
return (void*)result;
|
||||
}
|
||||
|
@ -1156,7 +1156,7 @@ create_each_transaction_helper(Transaction *template_txn, void *user_data)
|
||||
{
|
||||
exchange = gnc_numeric_div(gnc_numeric_create(1,1),
|
||||
gnc_price_get_value(price),
|
||||
1000, GNC_HOW_RND_ROUND);
|
||||
1000, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1177,7 +1177,7 @@ create_each_transaction_helper(Transaction *template_txn, void *user_data)
|
||||
}
|
||||
g_string_free(exchange_rate_var_name, TRUE);
|
||||
|
||||
amt = gnc_numeric_mul(final, exchange_rate, 1000, GNC_HOW_RND_ROUND);
|
||||
amt = gnc_numeric_mul(final, exchange_rate, 1000, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetAmount(copying_split, amt);
|
||||
}
|
||||
|
||||
@ -1612,7 +1612,7 @@ create_cashflow_helper(Transaction *template_txn, void *user_data)
|
||||
/* Multiply with the count factor. */
|
||||
final = gnc_numeric_mul(final_once, creation_data->count,
|
||||
gnc_numeric_denom(final_once),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
gncn_error = gnc_numeric_check(final);
|
||||
if (gncn_error != GNC_ERROR_OK)
|
||||
|
@ -55,7 +55,7 @@ test_num (gnc_numeric n)
|
||||
print_info.force_fit = 0;
|
||||
print_info.round = 0;
|
||||
|
||||
n1 = gnc_numeric_convert (n, fraction, GNC_HOW_RND_ROUND);
|
||||
n1 = gnc_numeric_convert (n, fraction, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
if (gnc_numeric_check(n1))
|
||||
{
|
||||
do_test_args((gnc_numeric_check(n1) == GNC_ERROR_OVERFLOW),
|
||||
@ -108,11 +108,11 @@ run_tests (void)
|
||||
IS_VALID_NUM(n, n);
|
||||
test_num (n);
|
||||
|
||||
n1 = gnc_numeric_mul (n, n, n.denom, GNC_HOW_RND_ROUND);
|
||||
n1 = gnc_numeric_mul (n, n, n.denom, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
IS_VALID_NUM(n1, n);
|
||||
test_num (n);
|
||||
|
||||
n1 = gnc_numeric_mul (n, n, n.denom, GNC_HOW_RND_ROUND);
|
||||
n1 = gnc_numeric_mul (n, n, n.denom, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
IS_VALID_NUM(n1, n);
|
||||
test_num (n);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ set_numeric (GtkWidget *widget, GncBillTerm *term,
|
||||
gdouble fl = 0.0;
|
||||
|
||||
fl = gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget));
|
||||
val = double_to_gnc_numeric (fl, 100000, GNC_HOW_RND_ROUND);
|
||||
val = double_to_gnc_numeric (fl, 100000, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
func (term, val);
|
||||
}
|
||||
|
||||
|
@ -1344,7 +1344,7 @@ gnc_invoice_reset_total_label (GtkLabel *label, gnc_numeric amt, gnc_commodity *
|
||||
{
|
||||
char string[256];
|
||||
|
||||
amt = gnc_numeric_convert (amt, gnc_commodity_get_fraction(com), GNC_HOW_RND_ROUND);
|
||||
amt = gnc_numeric_convert (amt, gnc_commodity_get_fraction(com), GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSPrintAmount (string, amt, gnc_default_print_info (TRUE));
|
||||
gtk_label_set_text (label, string);
|
||||
}
|
||||
@ -1399,7 +1399,7 @@ gnc_invoice_redraw_all_cb (GnucashRegister *g_reg, gpointer data)
|
||||
{
|
||||
amount = gncInvoiceGetTotalOf (invoice, GNC_PAYMENT_CASH);
|
||||
amount = gnc_numeric_sub (amount, to_charge_amt,
|
||||
gnc_commodity_get_fraction (currency), GNC_HOW_RND_ROUND);
|
||||
gnc_commodity_get_fraction (currency), GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_invoice_reset_total_label (GTK_LABEL (iw->total_cash_label), amount, currency);
|
||||
}
|
||||
|
||||
@ -1407,7 +1407,7 @@ gnc_invoice_redraw_all_cb (GnucashRegister *g_reg, gpointer data)
|
||||
{
|
||||
amount = gncInvoiceGetTotalOf (invoice, GNC_PAYMENT_CARD);
|
||||
amount = gnc_numeric_add (amount, to_charge_amt,
|
||||
gnc_commodity_get_fraction (currency), GNC_HOW_RND_ROUND);
|
||||
gnc_commodity_get_fraction (currency), GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_invoice_reset_total_label (GTK_LABEL (iw->total_charge_label), amount, currency);
|
||||
}
|
||||
}
|
||||
|
@ -3374,7 +3374,7 @@ xaccAccountBalanceHelper (Account *acc, gpointer data)
|
||||
balance = xaccAccountGetXxxBalanceInCurrency (acc, cb->fn, cb->currency);
|
||||
cb->balance = gnc_numeric_add (cb->balance, balance,
|
||||
gnc_commodity_get_fraction (cb->currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3389,7 +3389,7 @@ xaccAccountBalanceAsOfDateHelper (Account *acc, gpointer data)
|
||||
acc, cb->date, cb->asOfDateFn, cb->currency);
|
||||
cb->balance = gnc_numeric_add (cb->balance, balance,
|
||||
gnc_commodity_get_fraction (cb->currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
|
||||
|
@ -244,7 +244,7 @@ xaccSplitScrub (Split *split)
|
||||
scu = MIN (xaccAccountGetCommoditySCU (account),
|
||||
gnc_commodity_get_fraction (currency));
|
||||
|
||||
if (gnc_numeric_same (amount, value, scu, GNC_HOW_RND_ROUND))
|
||||
if (gnc_numeric_same (amount, value, scu, GNC_HOW_RND_ROUND_HALF_UP))
|
||||
{
|
||||
LEAVE("(split=%p) different values", split);
|
||||
return;
|
||||
@ -566,7 +566,7 @@ add_balance_split (Transaction *trans, gnc_numeric imbalance,
|
||||
* of the denominators might already be reduced. */
|
||||
new_value = gnc_numeric_sub (old_value, imbalance,
|
||||
gnc_commodity_get_fraction(currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
xaccSplitSetValue (balance_split, new_value);
|
||||
|
||||
@ -669,7 +669,7 @@ xaccTransScrubImbalance (Transaction *trans, Account *root,
|
||||
new_value = gnc_numeric_div (xaccSplitGetAmount(balance_split),
|
||||
convrate,
|
||||
gnc_commodity_get_fraction(currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
if (! gnc_numeric_equal (old_value, new_value))
|
||||
{
|
||||
xaccTransBeginEdit (trans);
|
||||
@ -740,7 +740,7 @@ xaccTransScrubImbalance (Transaction *trans, Account *root,
|
||||
old_amount = xaccSplitGetAmount (balance_split);
|
||||
new_amount = gnc_numeric_sub (old_amount, gnc_monetary_value(*imbal_mon),
|
||||
gnc_commodity_get_fraction(commodity),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
xaccSplitSetAmount (balance_split, new_amount);
|
||||
|
||||
@ -755,7 +755,7 @@ xaccTransScrubImbalance (Transaction *trans, Account *root,
|
||||
old_value = xaccSplitGetValue (balance_split);
|
||||
new_value = gnc_numeric_sub (old_value, val_imbalance,
|
||||
gnc_commodity_get_fraction(currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
xaccSplitSetValue (balance_split, new_value);
|
||||
}
|
||||
@ -806,7 +806,7 @@ xaccTransScrubImbalance (Transaction *trans, Account *root,
|
||||
old_value = xaccSplitGetValue (balance_split);
|
||||
new_value = gnc_numeric_sub (old_value, xaccSplitGetValue(split),
|
||||
gnc_commodity_get_fraction(currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetValue (balance_split, new_value);
|
||||
|
||||
/* Don't change the balance split's amount since the amount
|
||||
|
@ -273,7 +273,7 @@ xaccScrubSubSplitPrice (Split *split, int maxmult, int maxamtscu)
|
||||
frac = gnc_numeric_div (dst_amt, src_amt,
|
||||
GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE);
|
||||
target_val = gnc_numeric_mul (frac, src_val,
|
||||
scu, GNC_HOW_DENOM_EXACT | GNC_HOW_RND_ROUND);
|
||||
scu, GNC_HOW_DENOM_EXACT | GNC_HOW_RND_ROUND_HALF_UP);
|
||||
if (gnc_numeric_check (target_val))
|
||||
{
|
||||
PERR ("Numeric overflow of value\n"
|
||||
|
@ -937,9 +937,9 @@ DxaccSplitSetSharePriceAndAmount (Split *s, double price, double amt)
|
||||
xaccTransBeginEdit (s->parent);
|
||||
|
||||
s->amount = double_to_gnc_numeric(amt, get_commodity_denom(s),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
s->value = double_to_gnc_numeric(price * amt, get_currency_denom(s),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
SET_GAINS_A_VDIRTY(s);
|
||||
mark_split (s);
|
||||
@ -956,9 +956,9 @@ xaccSplitSetSharePriceAndAmount (Split *s, gnc_numeric price, gnc_numeric amt)
|
||||
xaccTransBeginEdit (s->parent);
|
||||
|
||||
s->amount = gnc_numeric_convert(amt, get_commodity_denom(s),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
s->value = gnc_numeric_mul(s->amount, price,
|
||||
get_currency_denom(s), GNC_HOW_RND_ROUND);
|
||||
get_currency_denom(s), GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
SET_GAINS_A_VDIRTY(s);
|
||||
mark_split (s);
|
||||
@ -973,7 +973,7 @@ qofSplitSetSharePrice (Split *split, gnc_numeric price)
|
||||
g_return_if_fail(split);
|
||||
split->value = gnc_numeric_mul(xaccSplitGetAmount(split),
|
||||
price, get_currency_denom(split),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
void
|
||||
@ -985,7 +985,7 @@ xaccSplitSetSharePrice (Split *s, gnc_numeric price)
|
||||
|
||||
s->value = gnc_numeric_mul(xaccSplitGetAmount(s),
|
||||
price, get_currency_denom(s),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
SET_GAINS_VDIRTY(s);
|
||||
mark_split (s);
|
||||
@ -1000,7 +1000,7 @@ DxaccSplitSetShareAmount (Split *s, double damt)
|
||||
gnc_numeric old_price, old_amt;
|
||||
int commodity_denom = get_commodity_denom(s);
|
||||
gnc_numeric amt = double_to_gnc_numeric(damt, commodity_denom,
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
if (!s) return;
|
||||
ENTER (" ");
|
||||
xaccTransBeginEdit (s->parent);
|
||||
@ -1020,7 +1020,7 @@ DxaccSplitSetShareAmount (Split *s, double damt)
|
||||
s->amount = gnc_numeric_convert(amt, commodity_denom,
|
||||
GNC_HOW_RND_NEVER);
|
||||
s->value = gnc_numeric_mul(s->amount, old_price,
|
||||
get_currency_denom(s), GNC_HOW_RND_ROUND);
|
||||
get_currency_denom(s), GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
SET_GAINS_A_VDIRTY(s);
|
||||
mark_split (s);
|
||||
@ -1036,7 +1036,7 @@ qofSplitSetAmount (Split *split, gnc_numeric amt)
|
||||
if (split->acc)
|
||||
{
|
||||
split->amount = gnc_numeric_convert(amt,
|
||||
get_commodity_denom(split), GNC_HOW_RND_ROUND);
|
||||
get_commodity_denom(split), GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1057,7 +1057,7 @@ xaccSplitSetAmount (Split *s, gnc_numeric amt)
|
||||
xaccTransBeginEdit (s->parent);
|
||||
if (s->acc)
|
||||
s->amount = gnc_numeric_convert(amt, get_commodity_denom(s),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
else
|
||||
s->amount = amt;
|
||||
|
||||
@ -1073,7 +1073,7 @@ qofSplitSetValue (Split *split, gnc_numeric amt)
|
||||
{
|
||||
g_return_if_fail(split);
|
||||
split->value = gnc_numeric_convert(amt,
|
||||
get_currency_denom(split), GNC_HOW_RND_ROUND);
|
||||
get_currency_denom(split), GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
/* The value of the split in the _transaction's_ currency. */
|
||||
@ -1090,7 +1090,7 @@ xaccSplitSetValue (Split *s, gnc_numeric amt)
|
||||
|
||||
xaccTransBeginEdit (s->parent);
|
||||
new_val = gnc_numeric_convert(amt, get_currency_denom(s),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
if (gnc_numeric_check(new_val) == GNC_ERROR_OK)
|
||||
s->value = new_val;
|
||||
else PERR("numeric error in converting the split value's denominator");
|
||||
@ -1151,16 +1151,16 @@ xaccSplitSetBaseValue (Split *s, gnc_numeric value,
|
||||
{
|
||||
s->amount = gnc_numeric_convert(value,
|
||||
get_commodity_denom(s),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
s->value = gnc_numeric_convert(value,
|
||||
get_currency_denom(s),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
else if (gnc_commodity_equiv(commodity, base_currency))
|
||||
{
|
||||
s->amount = gnc_numeric_convert(value, get_commodity_denom(s),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1257,7 +1257,7 @@ xaccSplitsComputeValue (GList *splits, const Split * skip_me,
|
||||
* doesn't mean the denominators are the same! */
|
||||
value = gnc_numeric_convert(value,
|
||||
gnc_commodity_get_fraction (base_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
LEAVE (" total=%" G_GINT64_FORMAT "/%" G_GINT64_FORMAT,
|
||||
value.num, value.denom);
|
||||
@ -1329,7 +1329,7 @@ xaccSplitConvertAmount (const Split *split, const Account * account)
|
||||
convrate = xaccTransGetAccountConvRate(txn, account);
|
||||
return gnc_numeric_mul (value, convrate,
|
||||
gnc_commodity_get_fraction (to_commodity),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -1847,7 +1847,7 @@ xaccSplitGetSharePrice (const Split * split)
|
||||
price = gnc_numeric_div(val, amt,
|
||||
GNC_DENOM_AUTO,
|
||||
GNC_HOW_DENOM_SIGFIGS(PRICE_SIGFIGS) |
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
/* During random checks we can get some very weird prices. Let's
|
||||
* handle some overflow and other error conditions by returning
|
||||
|
@ -975,7 +975,7 @@ xaccTransGetAccountAmount (const Transaction *trans, const Account *acc)
|
||||
if (!trans || !acc) return total;
|
||||
|
||||
total = gnc_numeric_convert (total, xaccAccountGetCommoditySCU (acc),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
FOR_EACH_SPLIT(trans, if (acc == xaccSplitGetAccount(s))
|
||||
total = gnc_numeric_add_fixed(
|
||||
total, xaccSplitGetAmount(s)));
|
||||
|
@ -494,7 +494,7 @@ xaccSplitAssignToLot (Split *split, GNCLot *lot)
|
||||
GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE);
|
||||
val_a = gnc_numeric_mul (frac, val_tot,
|
||||
gnc_numeric_denom(val_tot),
|
||||
GNC_HOW_RND_ROUND | GNC_HOW_DENOM_EXACT);
|
||||
GNC_HOW_RND_ROUND_HALF_UP | GNC_HOW_DENOM_EXACT);
|
||||
|
||||
val_b = gnc_numeric_sub_fixed (val_tot, val_a);
|
||||
if (gnc_numeric_check(val_a))
|
||||
@ -876,7 +876,7 @@ xaccSplitComputeCapGains(Split *split, Account *gain_acc)
|
||||
/* Basis for this split: */
|
||||
value = gnc_numeric_mul (frac, lot_value,
|
||||
gnc_numeric_denom(opening_value),
|
||||
GNC_HOW_DENOM_EXACT | GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_DENOM_EXACT | GNC_HOW_RND_ROUND_HALF_UP);
|
||||
/* Capital gain for this split: */
|
||||
value = gnc_numeric_sub (value, split->value,
|
||||
GNC_DENOM_AUTO, GNC_HOW_DENOM_FIXED);
|
||||
|
@ -1259,7 +1259,7 @@ gnc_scm2query_term_query_v1 (SCM query_term_scm)
|
||||
amount = scm_num2dbl (scm, G_STRFUNC);
|
||||
|
||||
val = double_to_gnc_numeric (amount, GNC_DENOM_AUTO,
|
||||
GNC_HOW_DENOM_SIGFIGS(6) | GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_DENOM_SIGFIGS(6) | GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
if (!safe_strcmp (pr_type, "pr-price"))
|
||||
{
|
||||
|
@ -2170,7 +2170,7 @@ gnc_pricedb_convert_balance_latest_price(GNCPriceDB *pdb,
|
||||
{
|
||||
balance = gnc_numeric_mul (balance, gnc_price_get_value (price),
|
||||
gnc_commodity_get_fraction (new_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_price_unref (price);
|
||||
return balance;
|
||||
}
|
||||
@ -2183,7 +2183,7 @@ gnc_pricedb_convert_balance_latest_price(GNCPriceDB *pdb,
|
||||
{
|
||||
balance = gnc_numeric_div (balance, gnc_price_get_value (price),
|
||||
gnc_commodity_get_fraction (new_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_price_unref (price);
|
||||
return balance;
|
||||
}
|
||||
@ -2239,7 +2239,7 @@ gnc_pricedb_convert_balance_latest_price(GNCPriceDB *pdb,
|
||||
GNC_HOW_DENOM_EXACT | GNC_HOW_RND_NEVER);
|
||||
balance = gnc_numeric_mul (balance, gnc_price_get_value (price),
|
||||
gnc_commodity_get_fraction (new_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
gnc_price_list_destroy(price_list);
|
||||
return balance;
|
||||
@ -2267,7 +2267,7 @@ gnc_pricedb_convert_balance_nearest_price(GNCPriceDB *pdb,
|
||||
{
|
||||
balance = gnc_numeric_mul (balance, gnc_price_get_value (price),
|
||||
gnc_commodity_get_fraction (new_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_price_unref (price);
|
||||
return balance;
|
||||
}
|
||||
@ -2280,7 +2280,7 @@ gnc_pricedb_convert_balance_nearest_price(GNCPriceDB *pdb,
|
||||
{
|
||||
balance = gnc_numeric_div (balance, gnc_price_get_value (price),
|
||||
gnc_commodity_get_fraction (new_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_price_unref (price);
|
||||
return balance;
|
||||
}
|
||||
@ -2321,7 +2321,7 @@ gnc_pricedb_convert_balance_nearest_price(GNCPriceDB *pdb,
|
||||
currency_price_value = gnc_numeric_div(gnc_numeric_create(1, 1),
|
||||
gnc_price_get_value(currency_price),
|
||||
gnc_commodity_get_fraction (new_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_price_unref(currency_price);
|
||||
}
|
||||
}
|
||||
@ -2333,11 +2333,11 @@ gnc_pricedb_convert_balance_nearest_price(GNCPriceDB *pdb,
|
||||
|
||||
balance = gnc_numeric_mul (balance, currency_price_value,
|
||||
gnc_commodity_get_fraction (new_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
balance = gnc_numeric_mul (balance, gnc_price_get_value (price),
|
||||
gnc_commodity_get_fraction (new_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
gnc_price_list_destroy(price_list);
|
||||
return balance;
|
||||
@ -2367,7 +2367,7 @@ gnc_pricedb_convert_balance_latest_before(GNCPriceDB *pdb,
|
||||
{
|
||||
balance = gnc_numeric_mul (balance, gnc_price_get_value (price),
|
||||
gnc_commodity_get_fraction (new_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_price_unref (price);
|
||||
return balance;
|
||||
}
|
||||
@ -2380,7 +2380,7 @@ gnc_pricedb_convert_balance_latest_before(GNCPriceDB *pdb,
|
||||
{
|
||||
balance = gnc_numeric_div (balance, gnc_price_get_value (price),
|
||||
gnc_commodity_get_fraction (new_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_price_unref (price);
|
||||
return balance;
|
||||
}
|
||||
@ -2421,7 +2421,7 @@ gnc_pricedb_convert_balance_latest_before(GNCPriceDB *pdb,
|
||||
currency_price_value = gnc_numeric_div(gnc_numeric_create(1, 1),
|
||||
gnc_price_get_value(currency_price),
|
||||
gnc_commodity_get_fraction (new_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_price_unref(currency_price);
|
||||
}
|
||||
}
|
||||
@ -2433,10 +2433,10 @@ gnc_pricedb_convert_balance_latest_before(GNCPriceDB *pdb,
|
||||
|
||||
balance = gnc_numeric_mul (balance, currency_price_value,
|
||||
gnc_commodity_get_fraction (new_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
balance = gnc_numeric_mul (balance, gnc_price_get_value (price),
|
||||
gnc_commodity_get_fraction (new_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
gnc_price_list_destroy(price_list);
|
||||
return balance;
|
||||
|
@ -85,7 +85,7 @@ SCM gnc_account_value_ptr_to_scm (GncAccountValue *av)
|
||||
|
||||
com = xaccAccountGetCommodity (av->account);
|
||||
val = gnc_numeric_convert (av->value, gnc_commodity_get_fraction (com),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
return scm_cons (SWIG_NewPointerObj(av->account, account_type, 0),
|
||||
gnc_numeric_to_scm (val));
|
||||
|
@ -1173,13 +1173,13 @@ void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
|
||||
|
||||
if (discount_value != NULL)
|
||||
{
|
||||
if (SCU) discount = gnc_numeric_convert(discount, SCU, GNC_HOW_RND_ROUND);
|
||||
if (SCU) discount = gnc_numeric_convert(discount, SCU, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
*discount_value = discount;
|
||||
}
|
||||
|
||||
if (value != NULL)
|
||||
{
|
||||
if (SCU) result = gnc_numeric_convert(result, SCU, GNC_HOW_RND_ROUND);
|
||||
if (SCU) result = gnc_numeric_convert(result, SCU, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
*value = result;
|
||||
}
|
||||
|
||||
@ -1200,14 +1200,14 @@ void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
|
||||
switch (gncTaxTableEntryGetType (entry))
|
||||
{
|
||||
case GNC_AMT_TYPE_VALUE:
|
||||
if (SCU) amount = gnc_numeric_convert(amount, SCU, GNC_HOW_RND_ROUND);
|
||||
if (SCU) amount = gnc_numeric_convert(amount, SCU, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
taxes = gncAccountValueAdd (taxes, acc, amount);
|
||||
break;
|
||||
case GNC_AMT_TYPE_PERCENT:
|
||||
amount = gnc_numeric_div (amount, percent, GNC_DENOM_AUTO,
|
||||
GNC_HOW_DENOM_LCD);
|
||||
tax = gnc_numeric_mul (pretax, amount, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
|
||||
if (SCU) tax = gnc_numeric_convert(tax, SCU, GNC_HOW_RND_ROUND);
|
||||
if (SCU) tax = gnc_numeric_convert(tax, SCU, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
taxes = gncAccountValueAdd (taxes, acc, tax);
|
||||
break;
|
||||
default:
|
||||
@ -1303,18 +1303,18 @@ gncEntryRecomputeValues (GncEntry *entry)
|
||||
&(entry->b_value), NULL, &(entry->b_tax_values));
|
||||
|
||||
entry->i_value_rounded = gnc_numeric_convert (entry->i_value, denom,
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
entry->i_disc_value_rounded = gnc_numeric_convert (entry->i_disc_value, denom,
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
entry->i_tax_value = gncAccountValueTotal (entry->i_tax_values);
|
||||
entry->i_tax_value_rounded = gnc_numeric_convert (entry->i_tax_value, denom,
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
entry->b_value_rounded = gnc_numeric_convert (entry->b_value, denom,
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
entry->b_tax_value = gncAccountValueTotal (entry->b_tax_values);
|
||||
entry->b_tax_value_rounded = gnc_numeric_convert (entry->b_tax_value, denom,
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
entry->values_dirty = FALSE;
|
||||
}
|
||||
|
||||
|
@ -1297,7 +1297,7 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
||||
{
|
||||
gnc_numeric converted_amount;
|
||||
xaccSplitSetValue(split, (reverse ? gnc_numeric_neg(value) : value));
|
||||
converted_amount = gnc_numeric_div(value, gnc_price_get_value(price), GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
|
||||
converted_amount = gnc_numeric_div(value, gnc_price_get_value(price), GNC_DENOM_AUTO, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
printf("converting from %f to %f\n", gnc_numeric_to_double(value), gnc_numeric_to_double(converted_amount));
|
||||
xaccSplitSetAmount(split, reverse ? gnc_numeric_neg(converted_amount) : converted_amount);
|
||||
}
|
||||
@ -1388,7 +1388,7 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
||||
{
|
||||
gnc_numeric converted_amount;
|
||||
xaccSplitSetValue(split, (reverse ? gnc_numeric_neg(acc_val->value) : acc_val->value));
|
||||
converted_amount = gnc_numeric_div(acc_val->value, gnc_price_get_value(price), GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
|
||||
converted_amount = gnc_numeric_div(acc_val->value, gnc_price_get_value(price), GNC_DENOM_AUTO, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
printf("converting from %f to %f\n", gnc_numeric_to_double(acc_val->value), gnc_numeric_to_double(converted_amount));
|
||||
|
||||
xaccSplitSetAmount(split, reverse ? gnc_numeric_neg(converted_amount) : converted_amount);
|
||||
@ -1687,7 +1687,7 @@ gncOwnerApplyPayment (GncOwner *owner, GncInvoice* invoice,
|
||||
{
|
||||
/* Need to value the payment in terms of the owner commodity */
|
||||
xaccSplitSetAmount(split, reverse ? amount : gnc_numeric_neg (amount));
|
||||
payment_value = gnc_numeric_mul(amount, exch, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND);
|
||||
payment_value = gnc_numeric_mul(amount, exch, GNC_DENOM_AUTO, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetValue(split, reverse ? payment_value : gnc_numeric_neg(payment_value));
|
||||
}
|
||||
|
||||
|
@ -1335,7 +1335,7 @@ get_random_split(QofBook *book, Account *acct, Transaction *trn)
|
||||
rate = gnc_numeric_abs(get_random_gnc_numeric());
|
||||
amt = gnc_numeric_mul(val, rate,
|
||||
GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE);
|
||||
amt = gnc_numeric_convert(amt, denom, GNC_HOW_RND_ROUND);
|
||||
amt = gnc_numeric_convert(amt, denom, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
while (gnc_numeric_check(amt) != GNC_ERROR_OK);
|
||||
}
|
||||
|
@ -901,7 +901,7 @@ gnc_xfer_update_to_amount (XferDialog *xferData)
|
||||
to_amount = gnc_numeric_zero();
|
||||
else
|
||||
to_amount = gnc_numeric_mul(gnc_amount_edit_get_amount(amount_edit),
|
||||
price, scu, GNC_HOW_RND_ROUND);
|
||||
price, scu, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
/* Update the dialog. */
|
||||
gnc_amount_edit_set_amount(to_amount_edit, to_amount);
|
||||
@ -950,7 +950,7 @@ gnc_xfer_to_amount_update_cb(GtkWidget *widget, GdkEventFocus *event,
|
||||
gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (xferData->to_amount_edit));
|
||||
|
||||
price = gnc_xfer_dialog_compute_price(xferData);
|
||||
price = gnc_numeric_convert (price, PRECISION, GNC_HOW_RND_ROUND);
|
||||
price = gnc_numeric_convert (price, PRECISION, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_amount_edit_set_amount(GNC_AMOUNT_EDIT(xferData->price_edit), price);
|
||||
gnc_xfer_dialog_update_conv_info(xferData);
|
||||
|
||||
|
@ -251,7 +251,7 @@ gnc_amount_edit_evaluate (GNCAmountEdit *gae)
|
||||
gnc_numeric old_amount = gae->amount;
|
||||
|
||||
if (gae->fraction > 0)
|
||||
amount = gnc_numeric_convert (amount, gae->fraction, GNC_HOW_RND_ROUND);
|
||||
amount = gnc_numeric_convert (amount, gae->fraction, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
gnc_amount_edit_set_amount (gae, amount);
|
||||
|
||||
@ -354,7 +354,7 @@ gnc_amount_edit_set_damount (GNCAmountEdit *gae, double damount)
|
||||
else
|
||||
fraction = 100000;
|
||||
|
||||
amount = double_to_gnc_numeric (damount, fraction, GNC_HOW_RND_ROUND);
|
||||
amount = double_to_gnc_numeric (damount, fraction, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
gnc_amount_edit_set_amount (gae, amount);
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ gnc_ui_accounts_recurse (Account *parent, GList **currency_list,
|
||||
currency_accum->assets =
|
||||
gnc_numeric_add (currency_accum->assets, end_amount,
|
||||
gnc_commodity_get_fraction (account_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
if (non_currency)
|
||||
@ -214,7 +214,7 @@ gnc_ui_accounts_recurse (Account *parent, GList **currency_list,
|
||||
non_curr_accum->assets =
|
||||
gnc_numeric_add (non_curr_accum->assets, end_amount_default_currency,
|
||||
gnc_commodity_get_fraction (options.default_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
if (options.grand_total)
|
||||
@ -222,7 +222,7 @@ gnc_ui_accounts_recurse (Account *parent, GList **currency_list,
|
||||
grand_total_accum->assets =
|
||||
gnc_numeric_add (grand_total_accum->assets, end_amount_default_currency,
|
||||
gnc_commodity_get_fraction (options.default_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
if (options.euro && (currency_accum != euro_accum))
|
||||
@ -231,7 +231,7 @@ gnc_ui_accounts_recurse (Account *parent, GList **currency_list,
|
||||
gnc_numeric_add (euro_accum->assets,
|
||||
gnc_convert_to_euro(account_currency, end_amount),
|
||||
gnc_commodity_get_fraction (euro_commodity),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
gnc_ui_accounts_recurse(account, currency_list, options);
|
||||
@ -256,11 +256,11 @@ gnc_ui_accounts_recurse (Account *parent, GList **currency_list,
|
||||
currency_accum->profits =
|
||||
gnc_numeric_add (currency_accum->profits, start_amount,
|
||||
gnc_commodity_get_fraction (account_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
currency_accum->profits =
|
||||
gnc_numeric_sub (currency_accum->profits, end_amount,
|
||||
gnc_commodity_get_fraction (account_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
if (non_currency)
|
||||
@ -268,11 +268,11 @@ gnc_ui_accounts_recurse (Account *parent, GList **currency_list,
|
||||
non_curr_accum->profits =
|
||||
gnc_numeric_add (non_curr_accum->profits, start_amount_default_currency,
|
||||
gnc_commodity_get_fraction (options.default_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
non_curr_accum->profits =
|
||||
gnc_numeric_sub (non_curr_accum->profits, end_amount_default_currency,
|
||||
gnc_commodity_get_fraction (options.default_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
if (options.grand_total)
|
||||
@ -281,12 +281,12 @@ gnc_ui_accounts_recurse (Account *parent, GList **currency_list,
|
||||
gnc_numeric_add (grand_total_accum->profits,
|
||||
start_amount_default_currency,
|
||||
gnc_commodity_get_fraction (options.default_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
grand_total_accum->profits =
|
||||
gnc_numeric_sub (grand_total_accum->profits,
|
||||
end_amount_default_currency,
|
||||
gnc_commodity_get_fraction (options.default_currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
if (options.euro && (currency_accum != euro_accum))
|
||||
@ -295,12 +295,12 @@ gnc_ui_accounts_recurse (Account *parent, GList **currency_list,
|
||||
gnc_numeric_add (euro_accum->profits,
|
||||
gnc_convert_to_euro(account_currency, start_amount),
|
||||
gnc_commodity_get_fraction (euro_commodity),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
euro_accum->profits =
|
||||
gnc_numeric_sub (euro_accum->profits,
|
||||
gnc_convert_to_euro(account_currency, end_amount),
|
||||
gnc_commodity_get_fraction (euro_commodity),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
gnc_ui_accounts_recurse(account, currency_list, options);
|
||||
|
@ -151,12 +151,12 @@ fi_to_gui(FinCalcDialog *fcd)
|
||||
gnc_amount_edit_set_damount (GNC_AMOUNT_EDIT(fcd->amounts[FUTURE_VALUE]),
|
||||
-fcd->financial_info.fv);
|
||||
|
||||
pmt = double_to_gnc_numeric (fcd->financial_info.pmt, 100000, GNC_HOW_RND_ROUND);
|
||||
pmt = double_to_gnc_numeric (fcd->financial_info.pmt, 100000, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
commodity = gnc_default_currency ();
|
||||
|
||||
total = gnc_numeric_mul (npp, pmt, gnc_commodity_get_fraction (commodity),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
xaccSPrintAmount (string, total, gnc_default_print_info (FALSE));
|
||||
gtk_label_set_text (GTK_LABEL(fcd->payment_total_label), string);
|
||||
|
@ -779,7 +779,7 @@ balance_cell_edited (GtkCellRendererText *cell,
|
||||
*/
|
||||
{
|
||||
int account_cmdty_fraction = xaccAccountGetCommoditySCU(account);
|
||||
amount = gnc_numeric_convert(amount, account_cmdty_fraction, GNC_HOW_RND_ROUND);
|
||||
amount = gnc_numeric_convert(amount, account_cmdty_fraction, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
set_final_balance (data->balance_hash, account, amount);
|
||||
qof_event_gen (QOF_INSTANCE(account), QOF_EVENT_MODIFY, NULL);
|
||||
|
@ -2152,7 +2152,7 @@ ld_setup_repayment_sx( LoanDruidData *ldd,
|
||||
GNCPrintAmountInfo pricePAI = gnc_default_price_print_info();
|
||||
#define AMTBUF_LEN 64
|
||||
gchar amtBuf[AMTBUF_LEN];
|
||||
gint GNCN_HOW = (GNC_HOW_DENOM_SIGFIGS(2) | GNC_HOW_RND_ROUND);
|
||||
gint GNCN_HOW = (GNC_HOW_DENOM_SIGFIGS(2) | GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
/* We're going to use this a lot, below, so just create it once. */
|
||||
xaccSPrintAmount( amtBuf,
|
||||
@ -2803,7 +2803,7 @@ ld_rev_recalc_schedule( LoanDruidData *ldd )
|
||||
PERR( "pmt Parsing error at %s", eloc );
|
||||
continue;
|
||||
}
|
||||
val = gnc_numeric_convert( val, 100, GNC_HOW_RND_ROUND );
|
||||
val = gnc_numeric_convert( val, 100, GNC_HOW_RND_ROUND_HALF_UP );
|
||||
rowNumData[0] = val;
|
||||
|
||||
if ( ! gnc_exp_parser_parse_separate_vars(
|
||||
@ -2812,7 +2812,7 @@ ld_rev_recalc_schedule( LoanDruidData *ldd )
|
||||
PERR( "ppmt Parsing error at %s", eloc );
|
||||
continue;
|
||||
}
|
||||
val = gnc_numeric_convert( val, 100, GNC_HOW_RND_ROUND );
|
||||
val = gnc_numeric_convert( val, 100, GNC_HOW_RND_ROUND_HALF_UP );
|
||||
rowNumData[1] = val;
|
||||
|
||||
if ( ! gnc_exp_parser_parse_separate_vars(
|
||||
@ -2821,7 +2821,7 @@ ld_rev_recalc_schedule( LoanDruidData *ldd )
|
||||
PERR( "ipmt Parsing error at %s", eloc );
|
||||
continue;
|
||||
}
|
||||
val = gnc_numeric_convert( val, 100, GNC_HOW_RND_ROUND );
|
||||
val = gnc_numeric_convert( val, 100, GNC_HOW_RND_ROUND_HALF_UP );
|
||||
rowNumData[2] = val;
|
||||
}
|
||||
|
||||
@ -2861,7 +2861,7 @@ ld_rev_recalc_schedule( LoanDruidData *ldd )
|
||||
{
|
||||
gint gncn_how =
|
||||
GNC_HOW_DENOM_SIGFIGS(2)
|
||||
| GNC_HOW_RND_ROUND;
|
||||
| GNC_HOW_RND_ROUND_HALF_UP;
|
||||
gnc_numeric val;
|
||||
rowNumData = (gnc_numeric*)g_hash_table_lookup( repayment_schedule,
|
||||
&curDate );
|
||||
|
@ -916,7 +916,7 @@ estimate_budget_helper(GtkTreeModel *model, GtkTreePath *path,
|
||||
|
||||
|
||||
num = gnc_numeric_convert(num, GNC_DENOM_AUTO,
|
||||
GNC_HOW_DENOM_SIGFIGS(priv->sigFigs) | GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_DENOM_SIGFIGS(priv->sigFigs) | GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_budget_set_account_period_value(
|
||||
priv->budget, acct, i, num);
|
||||
}
|
||||
|
@ -670,7 +670,7 @@ gsr_redraw_all_cb (GnucashRegister *g_reg, gpointer data)
|
||||
|
||||
amount = gnc_numeric_mul (amount, gnc_price_get_value (price),
|
||||
gnc_commodity_get_fraction (currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
xaccSPrintAmount (string, amount, print_info);
|
||||
|
||||
|
@ -223,7 +223,7 @@ gnc_ab_maketrans(GtkWidget *parent, Account *gnc_acc,
|
||||
amount = double_to_gnc_numeric(
|
||||
AB_Value_GetValueAsDouble(AB_Transaction_GetValue(ab_trans)),
|
||||
xaccAccountGetCommoditySCU(gnc_acc),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_xfer_dialog_set_amount(xfer_dialog, amount);
|
||||
|
||||
description = gnc_ab_description_to_gnc(ab_trans);
|
||||
|
@ -520,7 +520,7 @@ gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc)
|
||||
gnc_amount = double_to_gnc_numeric(
|
||||
d_value,
|
||||
xaccAccountGetCommoditySCU(gnc_acc),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
if (!ab_value)
|
||||
g_warning("transaction_cb: Oops, value was NULL. Using 0");
|
||||
xaccSplitSetBaseValue(split, gnc_amount, xaccAccountGetCommodity(gnc_acc));
|
||||
@ -815,7 +815,7 @@ bal_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data)
|
||||
|
||||
value = double_to_gnc_numeric(booked_value,
|
||||
xaccAccountGetCommoditySCU(gnc_acc),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
if (noted_value == 0.0 && booked_value == 0.0)
|
||||
{
|
||||
dialog = gtk_message_dialog_new(
|
||||
|
@ -690,7 +690,7 @@ static gboolean trans_property_set(TransProperty* prop, char* str)
|
||||
prop->value = g_new(gnc_numeric, 1);
|
||||
*((gnc_numeric*)(prop->value)) =
|
||||
double_to_gnc_numeric(value, xaccAccountGetCommoditySCU(prop->list->account),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -859,7 +859,7 @@ static GncCsvTransLine* trans_property_list_to_trans(TransPropertyList* list, gc
|
||||
QofBook* book = gnc_account_get_book(list->account);
|
||||
gnc_commodity* currency = xaccAccountGetCommodity(list->account);
|
||||
gnc_numeric amount = double_to_gnc_numeric(0.0, xaccAccountGetCommoditySCU(list->account),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
/* This flag is set to TRUE if we can use the "Deposit" or "Withdrawal" column. */
|
||||
gboolean amount_set = FALSE;
|
||||
@ -909,7 +909,7 @@ static GncCsvTransLine* trans_property_list_to_trans(TransPropertyList* list, gc
|
||||
amount = gnc_numeric_add(*((gnc_numeric*)(prop->value)),
|
||||
amount,
|
||||
xaccAccountGetCommoditySCU(list->account),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
amount_set = TRUE;
|
||||
/* We will use the "Deposit" and "Withdrawal" columns in preference to "Balance". */
|
||||
trans_line->balance_set = FALSE;
|
||||
@ -922,7 +922,7 @@ static GncCsvTransLine* trans_property_list_to_trans(TransPropertyList* list, gc
|
||||
amount = gnc_numeric_add(gnc_numeric_neg(*((gnc_numeric*)(prop->value))),
|
||||
amount,
|
||||
xaccAccountGetCommoditySCU(list->account),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
amount_set = TRUE;
|
||||
/* We will use the "Deposit" and "Withdrawal" columns in preference to "Balance". */
|
||||
trans_line->balance_set = FALSE;
|
||||
@ -1154,7 +1154,7 @@ int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
* any given transaction. */
|
||||
gnc_numeric balance_offset = double_to_gnc_numeric(0.0,
|
||||
xaccAccountGetCommoditySCU(account),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
while (transactions != NULL)
|
||||
{
|
||||
GncCsvTransLine* trans_line = (GncCsvTransLine*)transactions->data;
|
||||
@ -1165,13 +1165,13 @@ int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
gnc_numeric existing_balance = gnc_numeric_add(balance_offset,
|
||||
xaccAccountGetBalanceAsOfDate(account, date),
|
||||
xaccAccountGetCommoditySCU(account),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
/* The amount of the transaction is the difference between the new and existing balance. */
|
||||
gnc_numeric amount = gnc_numeric_sub(trans_line->balance,
|
||||
existing_balance,
|
||||
xaccAccountGetCommoditySCU(account),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
SplitList* splits = xaccTransGetSplitList(trans_line->trans);
|
||||
while (splits)
|
||||
@ -1187,7 +1187,7 @@ int gnc_csv_parse_to_trans(GncCsvParseData* parse_data, Account* account,
|
||||
balance_offset = gnc_numeric_add(balance_offset,
|
||||
amount,
|
||||
xaccAccountGetCommoditySCU(account),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
transactions = g_list_next(transactions);
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ gnc_hbci_getbalance_finish (GtkWidget *parent,
|
||||
|
||||
value = double_to_gnc_numeric (booked_value,
|
||||
xaccAccountGetCommoditySCU(gnc_acc),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
if ((noted_value == 0.0) && (booked_value == 0.0))
|
||||
{
|
||||
dialog = gtk_message_dialog_new(GTK_WINDOW(parent),
|
||||
|
@ -342,7 +342,7 @@ AB_TRANSACTION *gnc_hbci_trans_list_cb(AB_TRANSACTION *h_trans, void *user_data)
|
||||
gnc_amount = double_to_gnc_numeric
|
||||
(d_value,
|
||||
xaccAccountGetCommoditySCU(gnc_acc),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
if (!h_value)
|
||||
g_warning("trans_list_cb: Oops, value was NULL. Using 0.\n");
|
||||
xaccSplitSetBaseValue(split, gnc_amount, xaccAccountGetCommodity(gnc_acc));
|
||||
|
@ -271,7 +271,7 @@ gnc_hbci_maketrans_final(HBCITransDialog *td, Account *gnc_acc,
|
||||
amount = double_to_gnc_numeric
|
||||
(AB_Value_GetValue (AB_Transaction_GetValue (h_trans)),
|
||||
xaccAccountGetCommoditySCU(gnc_acc),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
/*switch (trans_type) {
|
||||
case SINGLE_DEBITNOTE:
|
||||
gnc_xfer_dialog_set_amount (transdialog, gnc_numeric_neg (amount));
|
||||
|
@ -385,7 +385,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void * transaction_u
|
||||
|
||||
gnc_amount = double_to_gnc_numeric (data.amount,
|
||||
gnc_commodity_get_fraction(xaccTransGetCurrency(transaction)),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetBaseValue(split, gnc_amount, xaccTransGetCurrency(transaction));
|
||||
|
||||
/* Also put the ofx transaction's memo in the split's memo field */
|
||||
@ -440,10 +440,10 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void * transaction_u
|
||||
|
||||
gnc_amount = double_to_gnc_numeric (ofx_get_investment_amount(data),
|
||||
gnc_commodity_get_fraction(investment_commodity),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
gnc_units = double_to_gnc_numeric (data.units,
|
||||
gnc_commodity_get_fraction(investment_commodity),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetAmount(split, gnc_units);
|
||||
xaccSplitSetValue(split, gnc_amount);
|
||||
|
||||
@ -523,7 +523,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void * transaction_u
|
||||
|
||||
gnc_amount = double_to_gnc_numeric (data.amount,
|
||||
gnc_commodity_get_fraction(xaccTransGetCurrency(transaction)),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetBaseValue(split, gnc_amount, xaccTransGetCurrency(transaction));
|
||||
|
||||
/* Also put the ofx transaction name in the splits memo field, or ofx memo if name is unavailable */
|
||||
@ -546,7 +546,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void * transaction_u
|
||||
|
||||
gnc_amount = double_to_gnc_numeric (-data.amount,/*OFX_INCOME amounts come in as positive numbers*/
|
||||
gnc_commodity_get_fraction(xaccTransGetCurrency(transaction)),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetBaseValue(split, gnc_amount, xaccTransGetCurrency(transaction));
|
||||
|
||||
/* Also put the ofx transaction name in the splits memo field, or ofx memo if name is unavailable */
|
||||
@ -570,7 +570,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void * transaction_u
|
||||
|
||||
gnc_amount = double_to_gnc_numeric (-ofx_get_investment_amount(data),
|
||||
gnc_commodity_get_fraction(xaccTransGetCurrency(transaction)),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetBaseValue(split, gnc_amount, xaccTransGetCurrency(transaction));
|
||||
|
||||
/* Also put the ofx transaction name in the splits memo field, or ofx memo if name is unavailable */
|
||||
|
@ -475,7 +475,7 @@ numeric_match_predicate (gpointer object, QofParam *getter,
|
||||
(gnc_numeric_compare (gnc_numeric_abs
|
||||
(gnc_numeric_sub (gnc_numeric_abs (obj_val),
|
||||
gnc_numeric_abs (pdata->amount),
|
||||
100000, GNC_HOW_RND_ROUND)),
|
||||
100000, GNC_HOW_RND_ROUND_HALF_UP)),
|
||||
cmp_val) < 0);
|
||||
}
|
||||
else
|
||||
|
@ -440,7 +440,7 @@ gnc_split_register_save_amount_values (SRSaveData *sd, SplitRegister *reg)
|
||||
{
|
||||
value = gnc_numeric_div(new_amount, amtconv,
|
||||
gnc_commodity_get_fraction(curr),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetValue(sd->split, value);
|
||||
}
|
||||
else
|
||||
@ -471,7 +471,7 @@ gnc_split_register_save_amount_values (SRSaveData *sd, SplitRegister *reg)
|
||||
/* convert the amount to the Value ... */
|
||||
value = gnc_numeric_div (new_amount, amtconv,
|
||||
gnc_commodity_get_fraction (curr),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetValue (sd->split, value);
|
||||
}
|
||||
else
|
||||
@ -488,7 +488,7 @@ gnc_split_register_save_amount_values (SRSaveData *sd, SplitRegister *reg)
|
||||
acc = xaccSplitGetAccount (sd->split);
|
||||
new_amount = gnc_numeric_mul (value, convrate,
|
||||
xaccAccountGetCommoditySCU (acc),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetAmount (sd->split, new_amount);
|
||||
}
|
||||
}
|
||||
@ -561,7 +561,7 @@ gnc_split_register_save_cells (gpointer save_data,
|
||||
{
|
||||
gnc_numeric amount = xaccSplitGetAmount (sd->split);
|
||||
value = gnc_numeric_div(
|
||||
amount, rate, gnc_commodity_get_fraction(txn_cur), GNC_HOW_RND_ROUND);
|
||||
amount, rate, gnc_commodity_get_fraction(txn_cur), GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetValue (sd->split, value);
|
||||
|
||||
/* XXX: do we need to set the amount on the other split? */
|
||||
@ -584,7 +584,7 @@ gnc_split_register_save_cells (gpointer save_data,
|
||||
acc);
|
||||
|
||||
amount = gnc_numeric_mul (value, rate, xaccAccountGetCommoditySCU (acc),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetAmount (other_split, amount);
|
||||
|
||||
}
|
||||
@ -612,7 +612,7 @@ gnc_split_register_save_cells (gpointer save_data,
|
||||
|
||||
amount = xaccSplitGetAmount (sd->split);
|
||||
value = gnc_numeric_div (amount, rate, gnc_commodity_get_fraction (txn_cur),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
xaccSplitSetValue (sd->split, value);
|
||||
#endif
|
||||
}
|
||||
|
@ -1625,13 +1625,13 @@ gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
|
||||
imbalance = gnc_numeric_mul (imbalance,
|
||||
xaccTransGetAccountConvRate(trans, acc),
|
||||
gnc_commodity_get_fraction (currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
else
|
||||
{
|
||||
imbalance = gnc_numeric_convert (imbalance,
|
||||
gnc_commodity_get_fraction (currency),
|
||||
GNC_HOW_RND_ROUND);
|
||||
GNC_HOW_RND_ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
return xaccPrintAmount (imbalance, gnc_account_print_info (acc, FALSE));
|
||||
|
@ -1918,7 +1918,7 @@ gnc_split_register_auto_calc (SplitRegister *reg, Split *split)
|
||||
if (!recalc_shares &&
|
||||
!recalc_price &&
|
||||
!recalc_value &&
|
||||
!gnc_numeric_same (value, calc_value, denom, GNC_HOW_RND_ROUND))
|
||||
!gnc_numeric_same (value, calc_value, denom, GNC_HOW_RND_ROUND_HALF_UP))
|
||||
{
|
||||
int choice;
|
||||
int default_value;
|
||||
@ -1989,7 +1989,7 @@ gnc_split_register_auto_calc (SplitRegister *reg, Split *split)
|
||||
|
||||
denom = gnc_split_get_amount_denom (split);
|
||||
|
||||
amount = gnc_numeric_div (value, price, denom, GNC_HOW_RND_ROUND);
|
||||
amount = gnc_numeric_div (value, price, denom, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
cell = gnc_table_layout_get_cell (reg->table->layout, SHRS_CELL);
|
||||
gnc_price_cell_set_value ((PriceCell *) cell, amount);
|
||||
@ -2047,7 +2047,7 @@ gnc_split_register_auto_calc (SplitRegister *reg, Split *split)
|
||||
|
||||
denom = gnc_split_get_value_denom (split);
|
||||
|
||||
value = gnc_numeric_mul (price, amount, denom, GNC_HOW_RND_ROUND);
|
||||
value = gnc_numeric_mul (price, amount, denom, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
gnc_price_cell_set_debt_credit_value ((PriceCell *) debit_cell,
|
||||
(PriceCell *) credit_cell, value);
|
||||
|
@ -144,7 +144,7 @@ gnc_price_cell_parse (PriceCell *cell, gboolean update_value)
|
||||
else if (gnc_exp_parser_parse (cell->cell.value, &amount, &err_location))
|
||||
{
|
||||
if (cell->fraction > 0)
|
||||
amount = gnc_numeric_convert (amount, cell->fraction, GNC_HOW_RND_ROUND);
|
||||
amount = gnc_numeric_convert (amount, cell->fraction, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
cell->amount = amount;
|
||||
}
|
||||
@ -243,7 +243,7 @@ gnc_price_cell_set_value (PriceCell * cell, gnc_numeric amount)
|
||||
return FALSE;
|
||||
|
||||
if (cell->fraction > 0)
|
||||
amount = gnc_numeric_convert (amount, cell->fraction, GNC_HOW_RND_ROUND);
|
||||
amount = gnc_numeric_convert (amount, cell->fraction, GNC_HOW_RND_ROUND_HALF_UP);
|
||||
|
||||
cell->amount = amount;
|
||||
buff = gnc_price_cell_print_value (cell);
|
||||
|
Loading…
Reference in New Issue
Block a user