Mark splits as changed *after* the change is made. Prelude to

using event api.
Kill macros in Account.c.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3268 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-12-08 08:30:20 +00:00
parent 338ec344a8
commit cd5a0cf748
3 changed files with 41 additions and 40 deletions

View File

@ -404,14 +404,20 @@ xaccClearMarkDownGr (AccountGroup *grp, short val)
/********************************************************************\
\********************************************************************/
#define CHECK(acc) { \
if (acc->editlevel <= 0) { \
/* not today, some day in the future ... */ \
/* PERR ("Account not open for editing\n"); */ \
/* assert (0); */ \
/* return; */ \
} \
if (NULL != acc->parent) acc->parent->saved = FALSE; \
G_INLINE_FUNC void check_and_mark (Account *account);
G_INLINE_FUNC void
check_and_mark (Account *account)
{
if (account->editlevel <= 0)
{
/* not today, some day in the future ... */
/* PERR ("Account not open for editing\n"); */
/* assert (0); */
/* return; */
}
if (account->parent)
account->parent->saved = FALSE;
}
/********************************************************************\
@ -439,7 +445,7 @@ xaccAccountInsertSplit ( Account *acc, Split *split ) {
xaccAccountBeginEdit(acc);
{
Account *oldacc;
CHECK (acc);
check_and_mark (acc);
acc->balance_dirty = TRUE;
acc->sort_dirty = TRUE;
@ -483,7 +489,7 @@ xaccAccountRemoveSplit ( Account *acc, Split *split ) {
xaccAccountBeginEdit(acc);
{
CHECK (acc);
check_and_mark (acc);
acc->balance_dirty = TRUE;
acc->splits = g_list_remove(acc->splits, split);
split->acc = NULL;
@ -823,7 +829,7 @@ xaccAccountSetType (Account *acc, int tip) {
xaccAccountBeginEdit(acc);
{
CHECK (acc);
check_and_mark (acc);
/* refuse invalid account types, and don't bother if not new type. */
if((NUM_ACCOUNT_TYPES > tip) && (acc->type != tip)) {
@ -842,7 +848,7 @@ xaccAccountSetName (Account *acc, const char *str) {
xaccAccountBeginEdit(acc);
{
CHECK (acc);
check_and_mark (acc);
/* make strdup before freeing */
tmp = g_strdup (str);
@ -859,7 +865,7 @@ xaccAccountSetCode (Account *acc, const char *str) {
xaccAccountBeginEdit(acc);
{
CHECK (acc);
check_and_mark (acc);
/* make strdup before freeing */
tmp = g_strdup (str);
@ -876,7 +882,7 @@ xaccAccountSetDescription (Account *acc, const char *str) {
xaccAccountBeginEdit(acc);
{
CHECK (acc);
check_and_mark (acc);
/* make strdup before freeing */
tmp = g_strdup (str);
@ -894,7 +900,7 @@ xaccAccountSetNotes (Account *acc, const char *str) {
xaccAccountBeginEdit(acc);
{
CHECK (acc);
check_and_mark (acc);
new_value = kvp_value_new_string(str);
if(new_value) {
@ -934,7 +940,7 @@ xaccAccountSetCurrency (Account * acc, const gnc_commodity * currency) {
xaccAccountBeginEdit(acc);
{
CHECK (acc);
check_and_mark (acc);
acc->currency = currency;
acc->currency_scu = gnc_commodity_get_fraction(currency);
@ -953,7 +959,7 @@ xaccAccountSetSecurity (Account *acc, const gnc_commodity * security) {
xaccAccountBeginEdit(acc);
{
CHECK (acc);
check_and_mark (acc);
acc->security = security;
acc->security_scu = gnc_commodity_get_fraction(security);
@ -972,7 +978,7 @@ xaccAccountSetCurrencySCU (Account * acc, int scu) {
xaccAccountBeginEdit(acc);
{
CHECK (acc);
check_and_mark (acc);
acc->currency_scu = scu;
}
xaccAccountCommitEdit(acc);
@ -1273,7 +1279,7 @@ xaccAccountSetTaxRelated (Account *account, gboolean tax_related)
xaccAccountBeginEdit (account);
{
CHECK (account);
check_and_mark (account);
kvp_frame_set_slot(xaccAccountGetSlots (account),
"tax-related", new_value);

View File

@ -381,14 +381,13 @@ xaccSplitSetSharePriceAndAmount (Split *s, gnc_numeric price,
{
if (!s) return;
mark_split (s);
s->damount = gnc_numeric_convert(amt, get_security_denom(s), GNC_RND_ROUND);;
s->value = gnc_numeric_mul(s->damount, price,
get_currency_denom(s), GNC_RND_ROUND);
/* force double entry to always balance */
xaccSplitRebalance (s);
mark_split (s);
}
void
@ -401,13 +400,12 @@ void
xaccSplitSetSharePrice (Split *s, gnc_numeric price) {
if (!s) return;
mark_split (s);
s->value = gnc_numeric_mul(s->damount, price, get_currency_denom(s),
GNC_RND_ROUND);
/* force double entry to always balance */
xaccSplitRebalance (s);
mark_split (s);
}
void
@ -417,8 +415,6 @@ DxaccSplitSetShareAmount (Split *s, double damt) {
GNC_RND_ROUND);
if (!s) return;
mark_split (s);
if(!gnc_numeric_zero_p(s->damount)) {
old_price = gnc_numeric_div(s->value, s->damount, GNC_DENOM_AUTO,
GNC_DENOM_REDUCE);
@ -434,17 +430,17 @@ DxaccSplitSetShareAmount (Split *s, double damt) {
/* force double entry to always balance */
xaccSplitRebalance (s);
mark_split (s);
}
void
xaccSplitSetShareAmount (Split *s, gnc_numeric amt) {
if(!s) return;
mark_split (s);
s->damount = gnc_numeric_convert(amt, get_security_denom(s), GNC_RND_ROUND);
xaccSplitRebalance (s);
mark_split (s);
}
void
@ -455,8 +451,6 @@ DxaccSplitSetValue (Split *s, double damt) {
gnc_numeric old_price;
if (!s) return;
mark_split (s);
if(!gnc_numeric_zero_p(s->damount)) {
old_price = gnc_numeric_div(s->value, s->damount, GNC_DENOM_AUTO,
GNC_DENOM_REDUCE);
@ -475,17 +469,17 @@ DxaccSplitSetValue (Split *s, double damt) {
/* force double entry to always balance */
xaccSplitRebalance (s);
mark_split (s);
}
void
xaccSplitSetValue (Split *s, gnc_numeric amt) {
if(!s) return;
mark_split (s);
s->value = gnc_numeric_convert(amt, get_currency_denom(s), GNC_RND_ROUND);;
xaccSplitRebalance (s);
mark_split (s);
}
/********************************************************************\
@ -812,8 +806,6 @@ xaccSplitSetBaseValue (Split *s, gnc_numeric value,
if (!s) return;
mark_split (s);
/* Novice/casual users may not want or use the double entry
* features of this engine. So, in particular, there may be the
* occasional split without a parent account. Well, that's ok,
@ -831,6 +823,7 @@ xaccSplitSetBaseValue (Split *s, gnc_numeric value,
s->value = value;
s->damount = value;
}
mark_split (s);
return;
}
@ -866,6 +859,8 @@ xaccSplitSetBaseValue (Split *s, gnc_numeric value,
gnc_commodity_get_printname(security));
return;
}
mark_split (s);
}
@ -1494,8 +1489,8 @@ xaccTransRollbackEdit (Transaction *trans)
/* do NOT check date order until all of the other fields
* have been properly restored */
xaccAccountFixSplitDateOrder (s->acc, s);
mark_split (s);
xaccAccountRecomputeBalance (s->acc);
mark_split (s);
}
if (so != s)
@ -1547,10 +1542,10 @@ xaccTransRollbackEdit (Transaction *trans)
{
Split *s = node->data;
mark_split (s);
xaccStoreEntity(s, &s->guid, GNC_ID_SPLIT);
xaccAccountInsertSplit (s->acc, s);
xaccAccountRecomputeBalance (s->acc);
mark_split (s);
}
}
@ -2100,9 +2095,9 @@ xaccSplitSetReconcile (Split *split, char recn)
}
split->reconciled = recn;
mark_split (split);
xaccAccountRecomputeBalance (split->acc);
mark_split (split);
}
void
@ -2110,10 +2105,9 @@ xaccSplitSetDateReconciledSecs (Split *split, time_t secs)
{
if (!split) return;
mark_split (split);
split->date_reconciled.tv_sec = secs;
split->date_reconciled.tv_nsec = 0;
mark_split (split);
}
void
@ -2121,9 +2115,8 @@ xaccSplitSetDateReconciledTS (Split *split, Timespec *ts)
{
if (!split || !ts) return;
mark_split (split);
split->date_reconciled = *ts;
mark_split (split);
}
void

View File

@ -122,6 +122,8 @@ gnc_engine_unregister_event_handler (gint handler_id)
return;
}
PERR ("no such handler: %d", handler_id);
}
void