mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug #537476: Fix currency trading account preference lookup
Patch by Mike Alexander: There are a few values related to the trading accounts preference that are needed in both Scheme and C code. Since one of them was already defined in Scheme before I started, I defined all of them there and tried to import them to C. This is obviously not a good idea, especially since the make check tests don't even fire up Guile so Scheme code isn't available. This patch changes things around to define the values in C and import them to Scheme. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18464 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
7359e68827
commit
a699183ae5
@ -257,7 +257,7 @@
|
|||||||
(export simple-obj-from-list)
|
(export simple-obj-from-list)
|
||||||
(export make-simple-obj)
|
(export make-simple-obj)
|
||||||
|
|
||||||
(define gnc:*kvp-option-path* '("options"))
|
(define gnc:*kvp-option-path* (list BOOK-OPTIONS-NAME))
|
||||||
(export gnc:*kvp-option-path*)
|
(export gnc:*kvp-option-path*)
|
||||||
|
|
||||||
(load-from-path "c-interface.scm")
|
(load-from-path "c-interface.scm")
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
gnc:*company-phone* gnc:*company-fax* gnc:*company-url*
|
gnc:*company-phone* gnc:*company-fax* gnc:*company-url*
|
||||||
gnc:*company-email* gnc:*company-contact*)
|
gnc:*company-email* gnc:*company-contact*)
|
||||||
|
|
||||||
(define gnc:*book-label* (N_ "Accounts"))
|
(define gnc:*book-label* ACCOUNT-OPTIONS-SECTION)
|
||||||
(define gnc:*trading-accounts* (N_ "Trading Accounts"))
|
(define gnc:*trading-accounts* TRADING-ACCOUNTS-OPTION)
|
||||||
|
|
||||||
(export gnc:*book-label* gnc:*trading-accounts*)
|
(export gnc:*book-label* gnc:*trading-accounts*)
|
||||||
|
|
||||||
|
@ -114,6 +114,7 @@ SplitList * qof_query_run (QofQuery *q);
|
|||||||
%ignore qof_query_run;
|
%ignore qof_query_run;
|
||||||
%include <qofquery.h>
|
%include <qofquery.h>
|
||||||
%include <qofquerycore.h>
|
%include <qofquerycore.h>
|
||||||
|
%include <qofbookslots.h>
|
||||||
|
|
||||||
gnc_numeric gnc_numeric_create(gint64 num, gint64 denom);
|
gnc_numeric gnc_numeric_create(gint64 num, gint64 denom);
|
||||||
gnc_numeric gnc_numeric_zero(void);
|
gnc_numeric gnc_numeric_zero(void);
|
||||||
@ -297,6 +298,10 @@ static KvpFrame * gnc_book_get_slots(QofBook *book) {
|
|||||||
SET_ENUM("TRANS-DATE-POSTED");
|
SET_ENUM("TRANS-DATE-POSTED");
|
||||||
SET_ENUM("TRANS-DESCRIPTION");
|
SET_ENUM("TRANS-DESCRIPTION");
|
||||||
SET_ENUM("TRANS-NUM");
|
SET_ENUM("TRANS-NUM");
|
||||||
|
|
||||||
|
SET_ENUM("BOOK-OPTIONS-NAME");
|
||||||
|
SET_ENUM("ACCOUNT-OPTIONS-SECTION");
|
||||||
|
SET_ENUM("TRADING-ACCOUNTS-OPTION");
|
||||||
|
|
||||||
SET_ENUM("ACCOUNT-CODE-"); /* sic */
|
SET_ENUM("ACCOUNT-CODE-"); /* sic */
|
||||||
|
|
||||||
|
@ -2,14 +2,12 @@ lib_LTLIBRARIES = libgnc-qof.la
|
|||||||
|
|
||||||
libgnc_qof_la_LDFLAGS= -version-info $(LIBQOF_LIBRARY_VERSION)
|
libgnc_qof_la_LDFLAGS= -version-info $(LIBQOF_LIBRARY_VERSION)
|
||||||
libgnc_qof_la_LIBADD= \
|
libgnc_qof_la_LIBADD= \
|
||||||
$(GUILE_LIBS) \
|
|
||||||
$(GLIB_LIBS) \
|
$(GLIB_LIBS) \
|
||||||
$(REGEX_LIBS) \
|
$(REGEX_LIBS) \
|
||||||
$(top_builddir)/lib/libc/libc-missing.la
|
$(top_builddir)/lib/libc/libc-missing.la
|
||||||
|
|
||||||
AM_CPPFLAGS = \
|
AM_CPPFLAGS = \
|
||||||
-I$(top_srcdir)/lib/libc \
|
-I$(top_srcdir)/lib/libc \
|
||||||
$(GUILE_INCS) \
|
|
||||||
$(GLIB_CFLAGS)
|
$(GLIB_CFLAGS)
|
||||||
|
|
||||||
libgnc_qof_la_SOURCES = \
|
libgnc_qof_la_SOURCES = \
|
||||||
@ -58,6 +56,7 @@ qofinclude_HEADERS = \
|
|||||||
qofinstance.h \
|
qofinstance.h \
|
||||||
qofquery.h \
|
qofquery.h \
|
||||||
qofbook.h \
|
qofbook.h \
|
||||||
|
qofbookslots.h \
|
||||||
qoflog.h \
|
qoflog.h \
|
||||||
qofobject.h \
|
qofobject.h \
|
||||||
qofquerycore.h \
|
qofquerycore.h \
|
||||||
|
@ -39,7 +39,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <libguile.h>
|
|
||||||
|
|
||||||
#include "qof.h"
|
#include "qof.h"
|
||||||
#include "qofevent-p.h"
|
#include "qofevent-p.h"
|
||||||
@ -47,6 +46,7 @@
|
|||||||
#include "qofbook-p.h"
|
#include "qofbook-p.h"
|
||||||
#include "qofid-p.h"
|
#include "qofid-p.h"
|
||||||
#include "qofobject-p.h"
|
#include "qofobject-p.h"
|
||||||
|
#include "qofbookslots.h"
|
||||||
|
|
||||||
static QofLogModule log_module = QOF_MOD_ENGINE;
|
static QofLogModule log_module = QOF_MOD_ENGINE;
|
||||||
|
|
||||||
@ -440,39 +440,17 @@ qof_book_get_counter (const QofBook *book, const char *counter_name)
|
|||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *get_scm_string(const char *str_name)
|
|
||||||
{
|
|
||||||
SCM scm_string = scm_c_eval_string (str_name);
|
|
||||||
if (! SCM_STRINGP(scm_string))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return g_strdup(SCM_STRING_CHARS(scm_string));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Determine whether this book uses trading accounts */
|
/* Determine whether this book uses trading accounts */
|
||||||
gboolean qof_book_use_trading_accounts (const QofBook *book)
|
gboolean qof_book_use_trading_accounts (const QofBook *book)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
static char *options_name = NULL;
|
|
||||||
static char *acct_section = NULL;
|
|
||||||
static char *trading_opt = NULL;
|
|
||||||
|
|
||||||
const char *opt;
|
const char *opt;
|
||||||
kvp_value *kvp_val;
|
kvp_value *kvp_val;
|
||||||
|
|
||||||
if (options_name == NULL)
|
|
||||||
{
|
|
||||||
options_name = get_scm_string ("(car gnc:*kvp-option-path*)");
|
|
||||||
//acct_section = get_scm_string ("gnc:*book-label*");
|
|
||||||
//trading_opt = get_scm_string ("gnc:*trading-accounts*");
|
|
||||||
if (options_name == NULL || acct_section == NULL || trading_opt == NULL)
|
|
||||||
{
|
|
||||||
PWARN ("Unable to find trading account preference");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
kvp_val = kvp_frame_get_slot_path (qof_book_get_slots (book), options_name, acct_section,
|
kvp_val = kvp_frame_get_slot_path (qof_book_get_slots (book),
|
||||||
trading_opt, NULL);
|
BOOK_OPTIONS_NAME,
|
||||||
|
ACCOUNT_OPTIONS_SECTION,
|
||||||
|
TRADING_ACCOUNTS_OPTION, NULL);
|
||||||
if (kvp_val == NULL)
|
if (kvp_val == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -480,7 +458,6 @@ gboolean qof_book_use_trading_accounts (const QofBook *book)
|
|||||||
|
|
||||||
if (opt && opt[0] == 't' && opt[1] == 0)
|
if (opt && opt[0] == 't' && opt[1] == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#endif
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
src/libqof/qof/qofbookslots.h
Normal file
33
src/libqof/qof/qofbookslots.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/********************************************************************\
|
||||||
|
* qofbookslots.h -- Defines the names of slots used in the book. *
|
||||||
|
* This program is free software; you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation; either version 2 of *
|
||||||
|
* the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License*
|
||||||
|
* along with this program; if not, contact: *
|
||||||
|
* *
|
||||||
|
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||||
|
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||||
|
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||||
|
* *
|
||||||
|
\********************************************************************/
|
||||||
|
|
||||||
|
/** @name Book parameter names
|
||||||
|
|
||||||
|
* These define the names used for the slots used to store book level parameters.
|
||||||
|
* They are defined here so swig will find them since they need to be available to
|
||||||
|
* Scheme code too.
|
||||||
|
@{
|
||||||
|
*/
|
||||||
|
#define BOOK_OPTIONS_NAME "options"
|
||||||
|
#define ACCOUNT_OPTIONS_SECTION "Accounts"
|
||||||
|
#define TRADING_ACCOUNTS_OPTION "Trading Accounts"
|
||||||
|
|
||||||
|
/** @} */
|
Loading…
Reference in New Issue
Block a user