mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix register crash and merge from 1.4.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2503 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
47b53fba89
commit
2563901e06
@ -64,6 +64,9 @@ int force_double_entry = 0;
|
||||
#define DEFER_REBALANCE 0x2
|
||||
#define BEING_DESTROYED 0x4
|
||||
|
||||
/* a very small number */
|
||||
#define ZERO_THRESH_VALUE 0.0000000000001
|
||||
|
||||
/********************************************************************\
|
||||
* Because I can't use C++ for this project, doesn't mean that I *
|
||||
* can't pretend too! These functions perform actions on the *
|
||||
@ -590,8 +593,15 @@ xaccSplitSetBaseValue (Split *s, double value, const char * base_currency)
|
||||
PERR ("split must have a parent\n");
|
||||
assert (s->acc);
|
||||
} else {
|
||||
DEVIDE (s -> damount, value, s->share_price);
|
||||
return;
|
||||
/* if there's already a share-amount set, we need to respect
|
||||
* that and adjust the price to make this balance. */
|
||||
if (!DEQEPS(s->damount, 0.0, ZERO_THRESH_VALUE)) {
|
||||
DEVIDE(s->share_price, value, s->damount);
|
||||
}
|
||||
else {
|
||||
DEVIDE(s->damount, value, s->share_price);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -599,13 +609,23 @@ xaccSplitSetBaseValue (Split *s, double value, const char * base_currency)
|
||||
* value in. This may or may not require a divide.
|
||||
*/
|
||||
if (!safe_strcmp(s->acc->currency, base_currency)) {
|
||||
DEVIDE (s -> damount, value, s->share_price);
|
||||
if (!DEQEPS(s->damount, 0.0, ZERO_THRESH_VALUE)) {
|
||||
DEVIDE(s->share_price, value, s->damount);
|
||||
}
|
||||
else {
|
||||
DEVIDE(s->damount, value, s->share_price);
|
||||
}
|
||||
} else
|
||||
if (!safe_strcmp(s->acc->security, base_currency)) {
|
||||
s -> damount = value;
|
||||
s->damount = value;
|
||||
} else
|
||||
if ((0x0==base_currency) && (0 == force_double_entry)) {
|
||||
DEVIDE (s -> damount, value, s->share_price);
|
||||
if (!DEQEPS(s->damount, 0.0, ZERO_THRESH_VALUE)) {
|
||||
DEVIDE(s->share_price, value, s->damount);
|
||||
}
|
||||
else {
|
||||
DEVIDE(s->damount, value, s->share_price);
|
||||
}
|
||||
} else
|
||||
{
|
||||
PERR ("inappropriate base currency %s "
|
||||
|
@ -144,6 +144,13 @@
|
||||
(let ((currency (gnc:account-get-currency account))
|
||||
(security (gnc:account-get-security account))
|
||||
(trans (gnc:split-get-parent split)))
|
||||
|
||||
;; fixme: This is a temporary fix of a g-wrap problem.
|
||||
(if (not currency)
|
||||
(set! currency ""))
|
||||
(if (not security)
|
||||
(set! security ""))
|
||||
|
||||
(or (< (gnc:transaction-get-split-count trans) 2)
|
||||
(gnc:transaction-is-common-currency trans currency)
|
||||
(gnc:transaction-is-common-currency trans security))))
|
||||
|
Loading…
Reference in New Issue
Block a user