From 6d8034012da2469db1541676b6be98fc327e0ed4 Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Mon, 6 Jan 2003 04:29:15 +0000 Subject: [PATCH] * src/register/ledger-core/split-register-model-save.c: when editing an exchange rate, always change the _VALUE_ of the split, not the amount. This has the affect of keeping the visible number the same and changing the "other" account. This should fix #102161 git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7784 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 8 +++- .../ledger-core/split-register-model-save.c | 37 +++++++++++-------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index f1cb059236..0317becc00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,7 +29,13 @@ through the list and 'select' those that are marked as "start selected" * accounts/C/acctchrt_common.gnucash-xea: mark this account tree as "start selected" - + + * src/register/ledger-core/split-register-model-save.c: when + editing an exchange rate, always change the _VALUE_ of the + split, not the amount. This has the affect of keeping the + visible number the same and changing the "other" account. This + should fix #102161 + 2003-01-04 David Hampton * src/backend/file/gnc-account-xml-v2.c: diff --git a/src/register/ledger-core/split-register-model-save.c b/src/register/ledger-core/split-register-model-save.c index 680e49e3e4..398f0e1ca9 100644 --- a/src/register/ledger-core/split-register-model-save.c +++ b/src/register/ledger-core/split-register-model-save.c @@ -380,21 +380,11 @@ gnc_split_register_split_needs_amount (SplitRegister *reg, Split *split) } static void -gnc_split_register_save_debcred_cell (BasicCell * bcell, - gpointer save_data, - gpointer user_data) +gnc_split_register_save_amount_values (SRSaveData *sd, SplitRegister *reg) { - SRSaveData *sd = save_data; - SplitRegister *reg = user_data; Account *acc; gnc_numeric new_amount, convrate, amtconv, value; - g_return_if_fail (gnc_basic_cell_has_name (bcell, DEBT_CELL) || - gnc_basic_cell_has_name (bcell, CRED_CELL)); - - if (sd->handled_dc) - return; - new_amount = gnc_split_register_debcred_cell_value (reg); /* How to interpret new_amount depends on our view of this @@ -406,12 +396,9 @@ gnc_split_register_save_debcred_cell (BasicCell * bcell, */ /* First, compute the conversion rate to convert the value to the - * amount. Use the RATE_CELL (if it exists) -- if not, then assume - * it is 1. + * amount. */ convrate = gnc_split_register_get_rate_cell (reg, RATE_CELL); - if (gnc_numeric_zero_p (convrate)) - convrate = gnc_numeric_create (100,100); /* Now compute/set the split value. Amount is in the register * currency but we need to convert to the txn currency. @@ -456,6 +443,23 @@ gnc_split_register_save_debcred_cell (BasicCell * bcell, GNC_RND_ROUND); xaccSplitSetAmount (sd->split, new_amount); } +} + +static void +gnc_split_register_save_debcred_cell (BasicCell * bcell, + gpointer save_data, + gpointer user_data) +{ + SRSaveData *sd = save_data; + SplitRegister *reg = user_data; + + g_return_if_fail (gnc_basic_cell_has_name (bcell, DEBT_CELL) || + gnc_basic_cell_has_name (bcell, CRED_CELL)); + + if (sd->handled_dc) + return; + + gnc_split_register_save_amount_values (sd, reg); sd->handled_dc = TRUE; sd->do_scrub = TRUE; @@ -554,12 +558,15 @@ gnc_split_register_save_cells (gpointer save_data, */ if (!sd->handled_dc) { + gnc_split_register_save_amount_values (sd, reg); +#if 0 gnc_numeric value, amount; amount = xaccSplitGetAmount (sd->split); value = gnc_numeric_div (amount, rate, gnc_commodity_get_fraction (txn_cur), GNC_RND_ROUND); xaccSplitSetValue (sd->split, value); +#endif } } }