diff --git a/gnucash/gnome/window-reconcile.c b/gnucash/gnome/window-reconcile.c index 0930849f25..689cb257a6 100644 --- a/gnucash/gnome/window-reconcile.c +++ b/gnucash/gnome/window-reconcile.c @@ -57,6 +57,7 @@ #include "gnc-window.h" #include "reconcile-view.h" #include "window-reconcile.h" +#include "gnc-session.h" #ifdef MAC_INTEGRATION #include #endif @@ -1765,6 +1766,8 @@ recnWindowWithBalance (GtkWidget *parent, Account *account, gnc_numeric new_endi gnc_register_gui_component (WINDOW_RECONCILE_CM_CLASS, refresh_handler, close_handler, recnData); + // This window should close if we close the session. + gnc_gui_component_set_session (recnData->component_id, gnc_get_current_session()); recn_set_watches (recnData); diff --git a/gnucash/import-export/ofx/gnc-ofx-import.c b/gnucash/import-export/ofx/gnc-ofx-import.c index 179e3c6866..05edb4d0f3 100644 --- a/gnucash/import-export/ofx/gnc-ofx-import.c +++ b/gnucash/import-export/ofx/gnc-ofx-import.c @@ -1133,28 +1133,16 @@ void gnc_file_ofx_import (GtkWindow *parent) { if (statement->ledger_balance_valid) { - // The balance needs to be corrected for credit-card and loan accounts. - float sign = 1; - switch(xaccAccountGetType (account)) - { - case ACCT_TYPE_CREDIT: - case ACCT_TYPE_LIABILITY: - sign = -1; - default: - sign = 1; - } - // Grab the balance value and date from the statement and open a reconcile window for this account. - gnc_numeric value = double_to_gnc_numeric (sign*statement->ledger_balance, xaccAccountGetCommoditySCU (account), GNC_HOW_RND_ROUND_HALF_UP); + gnc_numeric value = double_to_gnc_numeric (statement->ledger_balance, xaccAccountGetCommoditySCU (account), GNC_HOW_RND_ROUND_HALF_UP); recnWindowWithBalance (GTK_WIDGET (parent), account, value, statement->ledger_balance_date); } - g_free (statement); } } g_free (selected_filename); - g_slist_free (info.statement); + g_slist_free_full (info.statement,g_free); } if (ofx_created_commodites) diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp index b35e4555cb..33dd04a5e5 100644 --- a/libgnucash/engine/Account.cpp +++ b/libgnucash/engine/Account.cpp @@ -4391,6 +4391,35 @@ gboolean xaccAccountIsAssetLiabType(GNCAccountType t) } } +GNCAccountType +xaccAccountTypeGetFundamental (GNCAccountType t) +{ + switch (t) + { + case ACCT_TYPE_BANK: + case ACCT_TYPE_STOCK: + case ACCT_TYPE_MUTUAL: + case ACCT_TYPE_CURRENCY: + case ACCT_TYPE_CASH: + case ACCT_TYPE_ASSET: + case ACCT_TYPE_RECEIVABLE: + return ACCT_TYPE_ASSET; + case ACCT_TYPE_CREDIT: + case ACCT_TYPE_LIABILITY: + case ACCT_TYPE_PAYABLE: + return ACCT_TYPE_LIABILITY; + case ACCT_TYPE_INCOME: + return ACCT_TYPE_INCOME; + case ACCT_TYPE_EXPENSE: + return ACCT_TYPE_EXPENSE; + case ACCT_TYPE_EQUITY: + return ACCT_TYPE_EQUITY; + case ACCT_TYPE_TRADING: + default: + return ACCT_TYPE_NONE; + } +} + gboolean xaccAccountIsAPARType(GNCAccountType t) { switch (t) diff --git a/libgnucash/engine/Account.h b/libgnucash/engine/Account.h index 4ba18066e2..04b7b35c72 100644 --- a/libgnucash/engine/Account.h +++ b/libgnucash/engine/Account.h @@ -975,6 +975,11 @@ guint32 xaccAccountTypesValid(void); * Asset or Liability type, but not a business account type * (meaning not an Accounts Payable/Accounts Receivable). */ gboolean xaccAccountIsAssetLiabType(GNCAccountType t); + +/** Convenience function to return the fundamental type + * asset/liability/income/expense/equity given an account type. */ +GNCAccountType xaccAccountTypeGetFundamental (GNCAccountType t); + /** Convenience function to check if the account is a valid * business account type