* src/engine/Transaction.c (xaccSplitsComputeValue): fix a bug

* src/engine/gnc-book.c (gnc_book_load): fix spelling

	* src/engine/Scrub.c (xaccTransScrubImbalance): don't use sub_fixed
	since the value may not have the right denominator
	(xaccSplitScrub): handle splits without accounts

	* src/gnome/query-user.c
	(gnc_choose_radio_option_dialog_parented): actually set the parent

	* src/SplitLedger.c (xaccSRCheckReconciled): check current
	transaction, not current split.

	* src/engine/GNCId.c: use GUID allocator for hash keys.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3724 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas
2001-03-01 07:03:38 +00:00
parent b91b75648f
commit f916a195cc
7 changed files with 69 additions and 27 deletions

View File

@@ -1,3 +1,21 @@
2001-02-28 Dave Peticolas <dave@krondo.com>
* src/engine/Transaction.c (xaccSplitsComputeValue): fix a bug
* src/engine/gnc-book.c (gnc_book_load): fix spelling
* src/engine/Scrub.c (xaccTransScrubImbalance): don't use sub_fixed
since the value may not have the right denominator
(xaccSplitScrub): handle splits without accounts
* src/gnome/query-user.c
(gnc_choose_radio_option_dialog_parented): actually set the parent
* src/SplitLedger.c (xaccSRCheckReconciled): check current
transaction, not current split.
* src/engine/GNCId.c: use GUID allocator for hash keys.
2001-02-28 James LewisMoss <jimdres@mindspring.com>
* src/engine/gnc-commodity-xml-v2.c (gnc_commodity_end_handler):

View File

@@ -811,7 +811,7 @@ sr_balance_trans (SplitRegister *reg, Transaction *trans)
Split *split;
Split *other_split;
gboolean two_accounts;
split = xaccTransGetSplit (trans, 0);
other_split = xaccGetOtherSplit (split);
@@ -4965,7 +4965,7 @@ trans_has_reconciled_splits (Transaction *trans)
gboolean
xaccSRCheckReconciled (SplitRegister *reg)
{
Split *split;
Transaction *trans;
guint32 changed;
gboolean confirm;
char *message = _("You are about to change a transaction with reconciled\n"
@@ -4978,11 +4978,11 @@ xaccSRCheckReconciled (SplitRegister *reg)
if (!changed)
return TRUE;
split = xaccSRGetCurrentSplit (reg);
if (split == NULL)
trans = xaccSRGetCurrentTrans (reg);
if (trans == NULL)
return TRUE;
if (!trans_has_reconciled_splits (xaccSplitGetParent (split)))
if (!trans_has_reconciled_splits (trans))
return TRUE;
confirm = gnc_lookup_boolean_option ("Register",

View File

@@ -91,7 +91,7 @@ entity_node_destroy(gpointer key, gpointer value, gpointer not_used)
e_node->entity_type = GNC_ID_NONE;
e_node->entity = NULL;
g_free(guid);
xaccGUIDFree(guid);
g_free(e_node);
return TRUE;
@@ -279,7 +279,7 @@ xaccStoreEntity(void * entity, const GUID * guid, GNCIdType entity_type)
e_node->entity_type = entity_type;
e_node->entity = entity;
new_guid = g_new(GUID, 1);
new_guid = xaccGUIDMalloc();
*new_guid = *guid;
g_hash_table_insert(entity_table, new_guid, e_node);

View File

@@ -182,6 +182,7 @@ xaccSplitScrub (Split *split)
{
Account *account;
Transaction *trans;
gnc_numeric value;
gboolean trans_was_open;
int scu;
@@ -194,7 +195,18 @@ xaccSplitScrub (Split *split)
account = xaccSplitGetAccount (split);
if (!account)
{
value = xaccSplitGetValue (split);
if (gnc_numeric_same (xaccSplitGetShareAmount (split),
xaccSplitGetValue (split),
value.denom, GNC_RND_ROUND))
return;
xaccSplitSetShareAmount (split, value);
return;
}
if (!gnc_commodity_equiv (xaccAccountGetCurrency (account),
xaccAccountGetEffectiveSecurity (account)))
@@ -203,9 +215,10 @@ xaccSplitScrub (Split *split)
scu = MIN (xaccAccountGetCurrencySCU (account),
xaccAccountGetSecuritySCU (account));
value = xaccSplitGetValue (split);
if (gnc_numeric_same (xaccSplitGetShareAmount (split),
xaccSplitGetValue (split),
scu, GNC_RND_ROUND))
value, scu, GNC_RND_ROUND))
return;
PINFO ("split with mismatched values");
@@ -215,7 +228,7 @@ xaccSplitScrub (Split *split)
if (!trans_was_open)
xaccTransBeginEdit (trans);
xaccSplitSetShareAmount (split, xaccSplitGetValue (split));
xaccSplitSetShareAmount (split, value);
if (!trans_was_open)
xaccTransCommitEdit (trans);
@@ -332,7 +345,8 @@ xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
{
gnc_numeric new_value = xaccSplitGetValue (balance_split);
new_value = gnc_numeric_sub_fixed (new_value, imbalance);
new_value = gnc_numeric_sub (new_value, imbalance,
new_value.denom, GNC_RND_ROUND);
xaccSplitSetValue (balance_split, new_value);
@@ -348,7 +362,9 @@ xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
{
gnc_numeric new_share_amount = xaccSplitGetShareAmount (balance_split);
new_share_amount = gnc_numeric_sub_fixed (new_share_amount, imbalance);
new_share_amount = gnc_numeric_sub (new_share_amount, imbalance,
new_share_amount.denom,
GNC_RND_ROUND);
xaccSplitSetShareAmount (balance_split, new_share_amount);

View File

@@ -968,14 +968,14 @@ xaccSplitsComputeValue (GList *splits, Split * skip_me,
assert (s->acc);
}
else {
value = gnc_numeric_add(value, s->value, GNC_DENOM_AUTO,
GNC_DENOM_REDUCE);
value = gnc_numeric_add(value, s->value,
GNC_DENOM_AUTO, GNC_DENOM_LCD);
}
}
}
else if ((NULL == base_currency) && (0 == force_double_entry)) {
value = gnc_numeric_add(value, s->value, GNC_DENOM_AUTO,
GNC_DENOM_REDUCE);
}
value = gnc_numeric_add(value, s->value,
GNC_DENOM_AUTO, GNC_DENOM_LCD);
}
else {
const gnc_commodity *currency;
const gnc_commodity *security;
@@ -985,13 +985,18 @@ xaccSplitsComputeValue (GList *splits, Split * skip_me,
/* OK, we've got a parent account, we've got currency, lets
* behave like professionals now, instead of the shenanigans
* above. */
if (gnc_commodity_equiv(currency, base_currency)) {
value = gnc_numeric_add_fixed(value, s->value);
}
else if (gnc_commodity_equiv(security, base_currency)) {
value = gnc_numeric_add_fixed(value, s->damount);
}
* above. Note that just because the currencies are equivalent
* doesn't mean the denominators are the same! */
if (base_currency &&
gnc_commodity_equiv(currency, base_currency)) {
value = gnc_numeric_add(value, s->value,
GNC_DENOM_AUTO, GNC_DENOM_LCD);
}
else if (base_currency &&
gnc_commodity_equiv(security, base_currency)) {
value = gnc_numeric_add(value, s->damount,
GNC_DENOM_AUTO, GNC_DENOM_LCD);
}
else {
PERR ("inconsistent currencies\n"
"\tbase = '%s', curr='%s', sec='%s'\n",
@@ -1003,7 +1008,7 @@ xaccSplitsComputeValue (GList *splits, Split * skip_me,
}
}
return value;
return gnc_numeric_convert (value, GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
}
gnc_numeric

View File

@@ -630,7 +630,7 @@ gnc_book_load (GNCBook *book)
(strncmp(book->book_id, "https://", 8) == 0) ||
(strncmp(book->book_id, "postgres://", 11) == 0))
{
/* This code should be sufficient to initiliaze *any* backend,
/* This code should be sufficient to initialize *any* backend,
* whether http, postgres, or anything else that might come along.
* Basically, the idea is that by now, a backend has already been
* created & set up. At this point, we only need to get the

View File

@@ -372,6 +372,9 @@ gnc_choose_radio_option_dialog_parented(gncUIWidget parent,
GNOME_STOCK_BUTTON_OK,
NULL);
if (parent)
gnome_dialog_set_parent (GNOME_DIALOG (dialog), parent);
/* default to ok */
gnome_dialog_set_default(GNOME_DIALOG(dialog), 0);