mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/register/ledger-core/*: gnc_table_layout_get_cell() doesn't
look at the current cursor, so the multi-currency code was acting all the time, instead of only in registers that needed to be corrected. Fix the code to only apply the multi-currency changes to the correct register types (e.g., NOT stock registers). Fixes 102549. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7778 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
fabeeeb3d7
commit
bd9e618670
@ -33,6 +33,12 @@
|
||||
add code to prevent searching on template-txn accounts so SXes don't
|
||||
show up in find results.
|
||||
|
||||
* src/register/ledger-core/*: gnc_table_layout_get_cell() doesn't
|
||||
look at the current cursor, so the multi-currency code was acting
|
||||
all the time, instead of only in registers that needed to be corrected.
|
||||
Fix the code to only apply the multi-currency changes to the correct
|
||||
register types (e.g., NOT stock registers). Fixes 102549.
|
||||
|
||||
2003-01-03 David Hampton <hampton@employees.org>
|
||||
|
||||
* src/gnome/druid-hierarchy.c:
|
||||
|
@ -1029,6 +1029,9 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog)
|
||||
const char *message;
|
||||
|
||||
/* Make sure we NEED this for this type of register */
|
||||
if (!gnc_split_reg_has_rate_cell (reg->type))
|
||||
return FALSE;
|
||||
|
||||
rate_cell = (PriceCell*) gnc_table_layout_get_cell (reg->table->layout, RATE_CELL);
|
||||
if (!rate_cell)
|
||||
return FALSE;
|
||||
@ -1099,8 +1102,8 @@ gnc_split_register_handle_exchange (SplitRegister *reg, gboolean force_dialog)
|
||||
* transaction in order to edit it.
|
||||
*/
|
||||
if (!expanded && osplit &&
|
||||
gnc_split_register_split_needs_amount (split) &&
|
||||
gnc_split_register_split_needs_amount (osplit)) {
|
||||
gnc_split_register_split_needs_amount (reg, split) &&
|
||||
gnc_split_register_split_needs_amount (reg, osplit)) {
|
||||
gnc_error_dialog (message);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -371,12 +371,12 @@ gnc_split_register_get_rate_cell (SplitRegister *reg, const char *cell_name)
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_split_register_split_needs_amount (Split *split)
|
||||
gnc_split_register_split_needs_amount (SplitRegister *reg, Split *split)
|
||||
{
|
||||
Transaction *txn = xaccSplitGetParent (split);
|
||||
Account *acc = xaccSplitGetAccount (split);
|
||||
|
||||
return gnc_split_register_needs_conv_rate (txn, acc);
|
||||
return gnc_split_register_needs_conv_rate (reg, txn, acc);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -417,7 +417,7 @@ gnc_split_register_save_debcred_cell (BasicCell * bcell,
|
||||
* currency but we need to convert to the txn currency.
|
||||
*/
|
||||
acc = gnc_split_register_get_default_account (reg);
|
||||
if (gnc_split_register_needs_conv_rate (sd->trans, acc)) {
|
||||
if (gnc_split_register_needs_conv_rate (reg, sd->trans, acc)) {
|
||||
gnc_commodity *curr, *reg_com, *xfer_com;
|
||||
Account *xfer_acc;
|
||||
|
||||
@ -449,7 +449,7 @@ gnc_split_register_save_debcred_cell (BasicCell * bcell,
|
||||
*/
|
||||
value = xaccSplitGetValue (sd->split);
|
||||
|
||||
if (gnc_split_register_split_needs_amount (sd->split)) {
|
||||
if (gnc_split_register_split_needs_amount (reg, sd->split)) {
|
||||
acc = xaccSplitGetAccount (sd->split);
|
||||
new_amount = gnc_numeric_mul (value, convrate,
|
||||
xaccAccountGetCommoditySCU (acc),
|
||||
@ -500,7 +500,7 @@ gnc_split_register_save_cells (gpointer save_data,
|
||||
Account *acc;
|
||||
gboolean split_needs_amount;
|
||||
|
||||
split_needs_amount = gnc_split_register_split_needs_amount (sd->split);
|
||||
split_needs_amount = gnc_split_register_split_needs_amount (reg, sd->split);
|
||||
|
||||
/* We are changing the rate on the current split, but it was not
|
||||
* handled in the debcred handler, so we need to do it here.
|
||||
@ -518,7 +518,7 @@ gnc_split_register_save_cells (gpointer save_data,
|
||||
/* Now reverse the value for the other split */
|
||||
value = gnc_numeric_neg (value);
|
||||
|
||||
if (gnc_split_register_split_needs_amount (other_split))
|
||||
if (gnc_split_register_split_needs_amount (reg, other_split))
|
||||
{
|
||||
acc = xaccSplitGetAccount (other_split);
|
||||
|
||||
@ -541,7 +541,7 @@ gnc_split_register_save_cells (gpointer save_data,
|
||||
|
||||
xaccSplitScrub (other_split);
|
||||
}
|
||||
else if (gnc_split_register_split_needs_amount (sd->split) &&
|
||||
else if (gnc_split_register_split_needs_amount (reg, sd->split) &&
|
||||
! gnc_numeric_zero_p (rate))
|
||||
{
|
||||
/* this is either a multi-split or expanded transaction, so only
|
||||
|
@ -919,7 +919,7 @@ gnc_split_register_get_rate_entry (VirtualLocation virt_loc,
|
||||
txn = gnc_split_register_get_trans (reg, virt_loc.vcell_loc);
|
||||
|
||||
if (!gnc_split_register_current_trans_expanded (reg) && osplit &&
|
||||
!gnc_split_register_needs_conv_rate (txn, xaccSplitGetAccount (split)))
|
||||
!gnc_split_register_needs_conv_rate (reg, txn, xaccSplitGetAccount (split)))
|
||||
{
|
||||
split = osplit;
|
||||
}
|
||||
@ -1298,15 +1298,46 @@ gnc_split_register_get_tdebcred_entry (VirtualLocation virt_loc,
|
||||
return xaccPrintAmount (total, gnc_split_amount_print_info (split, FALSE));
|
||||
}
|
||||
|
||||
/* return TRUE if we have a RATE_CELL; return FALSE if we do not.
|
||||
* (note: should match split-register-layout.c)
|
||||
*/
|
||||
gboolean
|
||||
gnc_split_reg_has_rate_cell (SplitRegisterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case BANK_REGISTER:
|
||||
case CASH_REGISTER:
|
||||
case ASSET_REGISTER:
|
||||
case CREDIT_REGISTER:
|
||||
case LIABILITY_REGISTER:
|
||||
case INCOME_REGISTER:
|
||||
case EXPENSE_REGISTER:
|
||||
case EQUITY_REGISTER:
|
||||
case GENERAL_LEDGER:
|
||||
case INCOME_LEDGER:
|
||||
case PORTFOLIO_LEDGER:
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* returns TRUE if you need to convert the split's value to the local
|
||||
* (account) display currency. Returns FALSE if you can just use the
|
||||
* split->value directly.
|
||||
*/
|
||||
gboolean
|
||||
gnc_split_register_needs_conv_rate (Transaction *txn, Account *acc)
|
||||
gnc_split_register_needs_conv_rate (SplitRegister *reg,
|
||||
Transaction *txn, Account *acc)
|
||||
{
|
||||
gnc_commodity *txn_cur, *acc_com;
|
||||
|
||||
/* If there is not a RATE_CELL, then don't do anything */
|
||||
if (!gnc_split_reg_has_rate_cell (reg->type))
|
||||
return FALSE;
|
||||
|
||||
/* if txn->currency == acc->commodity, then return FALSE */
|
||||
acc_com = xaccAccountGetCommodity (acc);
|
||||
txn_cur = xaccTransGetCurrency (txn);
|
||||
@ -1448,7 +1479,7 @@ gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
|
||||
imbalance = gnc_numeric_abs (imbalance);
|
||||
|
||||
acc = gnc_split_register_get_default_account (reg);
|
||||
if (gnc_split_register_needs_conv_rate (trans, acc)) {
|
||||
if (gnc_split_register_needs_conv_rate (reg, trans, acc)) {
|
||||
imbalance = gnc_numeric_mul (imbalance,
|
||||
gnc_split_register_get_conv_rate (trans, acc),
|
||||
gnc_commodity_get_fraction (currency),
|
||||
|
@ -165,8 +165,9 @@ gnc_numeric gnc_split_register_debcred_cell_value (SplitRegister *reg);
|
||||
/* Determine if we need to perform any conversion on the splits in this
|
||||
* transaction, and if so, what conversion we need
|
||||
*/
|
||||
gboolean gnc_split_register_split_needs_amount (Split *split);
|
||||
gboolean gnc_split_register_needs_conv_rate (Transaction *txn, Account *acc);
|
||||
gboolean gnc_split_reg_has_rate_cell (SplitRegisterType type);
|
||||
gboolean gnc_split_register_split_needs_amount (SplitRegister *reg, Split *split);
|
||||
gboolean gnc_split_register_needs_conv_rate (SplitRegister *reg, Transaction *txn, Account *acc);
|
||||
gnc_numeric gnc_split_register_get_conv_rate (Transaction *txn, Account *acc);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user