mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add code to make sure that split amount and value are valid numbers.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10174 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
8ac1f54b9f
commit
922d18d706
@ -198,13 +198,22 @@ xaccAccountScrubSplits (Account *account)
|
||||
void
|
||||
xaccTransScrubSplits (Transaction *trans)
|
||||
{
|
||||
gnc_commodity *currency;
|
||||
GList *node;
|
||||
|
||||
if (!trans)
|
||||
return;
|
||||
if (!trans) return;
|
||||
|
||||
/* The split scrub expects the transaction to have a currency! */
|
||||
currency = xaccTransGetCurrency (trans);
|
||||
if (!currency)
|
||||
{
|
||||
PERR ("Transaction doesn't have a currency!");
|
||||
}
|
||||
|
||||
for (node = trans->splits; node; node = node->next)
|
||||
{
|
||||
xaccSplitScrub (node->data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -212,7 +221,7 @@ xaccSplitScrub (Split *split)
|
||||
{
|
||||
Account *account;
|
||||
Transaction *trans;
|
||||
gnc_numeric value;
|
||||
gnc_numeric value, amount;
|
||||
gnc_commodity *currency;
|
||||
int scu;
|
||||
|
||||
@ -243,6 +252,21 @@ xaccSplitScrub (Split *split)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Split amounts and values should be valid numbers */
|
||||
value = xaccSplitGetValue (split);
|
||||
if (gnc_numeric_check (value))
|
||||
{
|
||||
value = gnc_numeric_zero();
|
||||
xaccSplitSetValue (split, value);
|
||||
}
|
||||
|
||||
amount = xaccSplitGetAmount (split);
|
||||
if (gnc_numeric_check (amount))
|
||||
{
|
||||
amount = gnc_numeric_zero();
|
||||
xaccSplitSetAmount (split, amount);
|
||||
}
|
||||
|
||||
currency = xaccTransGetCurrency (trans);
|
||||
|
||||
/* If the account doesn't have a commodity,
|
||||
@ -262,10 +286,7 @@ xaccSplitScrub (Split *split)
|
||||
scu = MIN (xaccAccountGetCommoditySCU (account),
|
||||
gnc_commodity_get_fraction (currency));
|
||||
|
||||
value = xaccSplitGetValue (split);
|
||||
|
||||
if (gnc_numeric_same (xaccSplitGetAmount (split),
|
||||
value, scu, GNC_HOW_RND_ROUND))
|
||||
if (gnc_numeric_same (amount, value, scu, GNC_HOW_RND_ROUND))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user