r23056 - gnucash/trunk/src - Improve transaction currency lookup by using the new account_or_default currency getter.
Christian Stimming
cstim at code.gnucash.org
Wed Jun 19 11:47:39 EDT 2013
Author: cstim
Date: 2013-06-19 11:47:39 -0400 (Wed, 19 Jun 2013)
New Revision: 23056
Trac: http://svn.gnucash.org/trac/changeset/23056
Modified:
gnucash/trunk/src/app-utils/gnc-ui-util.c
gnucash/trunk/src/gnc/dashboard.cpp
gnucash/trunk/src/gnome-utils/dialog-account.c
gnucash/trunk/src/gnome-utils/dialog-book-close.c
gnucash/trunk/src/gnome-utils/dialog-transfer.c
gnucash/trunk/src/gnome/gnc-split-reg.c
gnucash/trunk/src/gnome/gnc-split-reg2.c
Log:
Improve transaction currency lookup by using the new account_or_default currency getter.
Previously, this could result in transactions that have a non-currency as
txn commodity, which is what the multi-currency register tried to avoid hard.
Now by using account_or_default_currency, the currency choosing policy from
the register is available in the other places where new transactions are
created, hence we better use that here.
Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c 2013-06-19 15:47:27 UTC (rev 23055)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c 2013-06-19 15:47:39 UTC (rev 23056)
@@ -791,7 +791,7 @@
xaccTransBeginEdit (trans);
- xaccTransSetCurrency (trans, xaccAccountGetCommodity (account));
+ xaccTransSetCurrency (trans, gnc_account_or_default_currency (account, NULL));
xaccTransSetDatePostedSecsNormalized (trans, date);
xaccTransSetDescription (trans, _("Opening Balance"));
Modified: gnucash/trunk/src/gnc/dashboard.cpp
===================================================================
--- gnucash/trunk/src/gnc/dashboard.cpp 2013-06-19 15:47:27 UTC (rev 23055)
+++ gnucash/trunk/src/gnc/dashboard.cpp 2013-06-19 15:47:39 UTC (rev 23056)
@@ -275,7 +275,7 @@
::xaccTransSetNum(transaction, lineNum->text().toUtf8());
::xaccTransSetDescription(transaction, lineDescription->text().toUtf8());
- currency = xaccAccountGetCommodity(account);
+ currency = gnc_account_or_default_currency(account, NULL);
::xaccTransSetCurrency(transaction, currency);
denom = ::gnc_commodity_get_fraction(currency);
Modified: gnucash/trunk/src/gnome/gnc-split-reg.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-split-reg.c 2013-06-19 15:47:27 UTC (rev 23055)
+++ gnucash/trunk/src/gnome/gnc-split-reg.c 2013-06-19 15:47:39 UTC (rev 23056)
@@ -1450,7 +1450,7 @@
xaccTransBeginEdit(trans);
// fill Transaction
- xaccTransSetCurrency(trans, xaccAccountGetCommodity(account));
+ xaccTransSetCurrency(trans, gnc_account_or_default_currency(account, NULL));
xaccTransSetDatePostedSecsNormalized(trans, statement_date);
xaccTransSetDescription(trans, _("Balancing entry from reconcilation"));
/* We also must set a new DateEntered on the new entry
Modified: gnucash/trunk/src/gnome/gnc-split-reg2.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-split-reg2.c 2013-06-19 15:47:27 UTC (rev 23055)
+++ gnucash/trunk/src/gnome/gnc-split-reg2.c 2013-06-19 15:47:39 UTC (rev 23056)
@@ -725,7 +725,7 @@
xaccTransBeginEdit (trans);
// fill Transaction
- xaccTransSetCurrency (trans, xaccAccountGetCommodity (account));
+ xaccTransSetCurrency (trans, gnc_account_or_default_currency (account, NULL));
xaccTransSetDatePostedSecsNormalized (trans, statement_date);
xaccTransSetDescription (trans, _("Balancing entry from reconcilation"));
Modified: gnucash/trunk/src/gnome-utils/dialog-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-account.c 2013-06-19 15:47:27 UTC (rev 23055)
+++ gnucash/trunk/src/gnome-utils/dialog-account.c 2013-06-19 15:47:39 UTC (rev 23056)
@@ -299,7 +299,7 @@
xaccTransBeginEdit (trans);
- xaccTransSetCurrency (trans, xaccAccountGetCommodity (account));
+ xaccTransSetCurrency (trans, gnc_account_or_default_currency (account, NULL));
xaccTransSetDatePostedSecsNormalized (trans, date);
xaccTransSetDescription (trans, _("Opening Balance"));
Modified: gnucash/trunk/src/gnome-utils/dialog-book-close.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-book-close.c 2013-06-19 15:47:27 UTC (rev 23055)
+++ gnucash/trunk/src/gnome-utils/dialog-book-close.c 2013-06-19 15:47:39 UTC (rev 23056)
@@ -41,6 +41,7 @@
#include "gnc-component-manager.h"
#include "gnc-date-edit.h"
#include "gnc-session.h"
+#include "app-utils/gnc-ui-util.h"
#define DIALOG_BOOK_CLOSE_CM_CLASS "dialog-book-close"
@@ -145,7 +146,7 @@
if (gnc_numeric_zero_p(bal))
return;
- acct_commodity = xaccAccountGetCommodity(a);
+ acct_commodity = gnc_account_or_default_currency(a, NULL);
g_assert(acct_commodity);
txn = find_or_create_txn(cacb, acct_commodity);
Modified: gnucash/trunk/src/gnome-utils/dialog-transfer.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-transfer.c 2013-06-19 15:47:27 UTC (rev 23055)
+++ gnucash/trunk/src/gnome-utils/dialog-transfer.c 2013-06-19 15:47:39 UTC (rev 23056)
@@ -448,7 +448,7 @@
if (!account)
return;
- commodity = xaccAccountGetCommodity(account);
+ commodity = gnc_account_or_default_currency(account, NULL);
gtk_label_set_text(GTK_LABEL(xferData->from_currency_label),
gnc_commodity_get_printname(commodity));
More information about the gnucash-changes
mailing list