mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Move gnc_ui_account_get_tax_info_string to gnc-locale-tax.c
To prevent a circular dependency between libgnc-app-utils and libgnucash-guile.
This commit is contained in:
parent
3e2f7bc66a
commit
f4c27d4494
@ -3,6 +3,7 @@ add_subdirectory(python)
|
||||
|
||||
set_local_dist(bindings_DIST_local
|
||||
CMakeLists.txt
|
||||
app-utils.i
|
||||
business-core.i
|
||||
core-utils.i
|
||||
engine.i
|
||||
|
@ -30,11 +30,13 @@ extern "C"
|
||||
#include <gnc-euro.h>
|
||||
#include <gnc-ui-util.h>
|
||||
#include <gnc-prefs-utils.h>
|
||||
#if defined(SWIGGUILE)
|
||||
#include <gnc-helpers.h>
|
||||
#include "gnc-engine-guile.h"
|
||||
#endif
|
||||
#include <gnc-accounting-period.h>
|
||||
#include <gnc-session.h>
|
||||
|
||||
#include "gnc-engine-guile.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
72
bindings/expressions.i
Normal file
72
bindings/expressions.i
Normal file
@ -0,0 +1,72 @@
|
||||
/********************************************************************\
|
||||
* 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 *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
%module sw_expressions
|
||||
%{
|
||||
#include <gnc-sx-instance-model.h>
|
||||
|
||||
SCM scm_init_sw_expressions_module (void);
|
||||
|
||||
static GDate
|
||||
gnc_time64_to_GDate(SCM x)
|
||||
{
|
||||
time64 time = scm_to_int64 (x);
|
||||
return time64_to_gdate(time);
|
||||
}
|
||||
|
||||
|
||||
static SCM
|
||||
gnc_guid2scm(GncGUID guid)
|
||||
{
|
||||
char string[GUID_ENCODING_LENGTH + 1];
|
||||
|
||||
if (!guid_to_string_buff(&guid, string))
|
||||
return SCM_BOOL_F;
|
||||
|
||||
return scm_from_utf8_string(string);
|
||||
}
|
||||
|
||||
static SCM
|
||||
gnc_numeric_to_scm(gnc_numeric arg)
|
||||
{
|
||||
return gnc_numeric_check (arg) ? SCM_BOOL_F :
|
||||
scm_divide (scm_from_int64 (arg.num), scm_from_int64 (arg.denom));
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(out) GHashTable * {
|
||||
SCM table = scm_c_make_hash_table (g_hash_table_size($1) + 17);
|
||||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
|
||||
g_hash_table_iter_init (&iter, $1);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value)) {
|
||||
const GncGUID* c_guid = (const GncGUID*) key;
|
||||
const gnc_numeric* c_numeric = (const gnc_numeric*) value;
|
||||
SCM scm_guid = gnc_guid2scm(*c_guid);
|
||||
SCM scm_numeric = gnc_numeric_to_scm(*c_numeric);
|
||||
|
||||
scm_hash_set_x(table, scm_guid, scm_numeric);
|
||||
}
|
||||
g_hash_table_destroy($1);
|
||||
$result = table;
|
||||
}
|
||||
GHashTable* gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_end);
|
||||
%clear GHashTable *;
|
@ -1,6 +1,6 @@
|
||||
add_subdirectory(test)
|
||||
|
||||
# Command to generate the swig-core-utils-guile.c wrapper file
|
||||
# Generate the swig-core-utils-guile.c wrapper file
|
||||
gnc_swig_extract_header_files (gnc-core-utils CORE_UTILS_HEADERS)
|
||||
gnc_add_swig_guile_command (swig-core-utils-guile-c
|
||||
SWIG_CORE_UTILS_GUILE_C swig-core-utils-guile.c
|
||||
@ -9,7 +9,7 @@ gnc_add_swig_guile_command (swig-core-utils-guile-c
|
||||
${CORE_UTILS_HEADERS}
|
||||
)
|
||||
|
||||
# Command to generate the swig-engine.c wrapper file
|
||||
# Generate the swig-engine.c wrapper file
|
||||
gnc_swig_extract_header_files (gnc-engine ENGINE_HEADERS)
|
||||
gnc_add_swig_guile_command (swig-engine-c
|
||||
SWIG_ENGINE_C swig-engine.c
|
||||
@ -20,10 +20,28 @@ gnc_add_swig_guile_command (swig-engine-c
|
||||
${CMAKE_SOURCE_DIR}/bindings/engine-common.i
|
||||
)
|
||||
|
||||
# Generate the swig-app-utils-guile.cpp wrapper file
|
||||
set(SWIG_ARGS "-c++" "-procdoc" "sw-gnc-option-doc" "-procdocformat" "plain")
|
||||
gnc_add_swig_guile_command (swig-apputils-guile-cpp #target
|
||||
SWIG_APP_UTILS_GUILE_CPP swig-app-utils-guile.cpp #outvar, output
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../app-utils.i #input
|
||||
"${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_SOURCE_DIR}/libgnucash/app-utils" #includes
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gnc-optiondb.i #additional dependencies
|
||||
)
|
||||
unset(SWIG_ARGS)
|
||||
|
||||
#Generate the swig-expressions-guile.c wrapper file
|
||||
gnc_add_swig_guile_command(swig-expressions-guile-c #target
|
||||
SWIG_EXPRESSIONS_GUILE_C swig-expressions-guile.c #outvar, output
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/expressions.i #input
|
||||
"${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_SOURCE_DIR}/libgnucash/app-utils;${CMAKE_SOURCE_DIR}/libgnucash/expressions" #includes
|
||||
)
|
||||
|
||||
set(guile_HEADERS
|
||||
glib-guile.h
|
||||
gnc-engine-guile.h
|
||||
gnc-guile-utils.h
|
||||
gnc-helpers.h
|
||||
gnc-kvp-guile.h)
|
||||
|
||||
set(guile_SOURCES
|
||||
@ -31,13 +49,15 @@ set(guile_SOURCES
|
||||
gnc-engine-guile.c
|
||||
gnc-guile-bindings.c
|
||||
gnc-guile-utils.c
|
||||
gnc-helpers.c
|
||||
gnc-kvp-guile.cpp)
|
||||
|
||||
add_library(gnucash-guile SHARED
|
||||
${guile_SOURCES}
|
||||
${guile_HEADERS}
|
||||
${SWIG_CORE_UTILS_GUILE_C}
|
||||
${SWIG_ENGINE_C})
|
||||
${SWIG_ENGINE_C}
|
||||
${SWIG_APP_UTILS_GUILE_CPP})
|
||||
|
||||
add_dependencies(gnucash-guile
|
||||
swig-runtime-h)
|
||||
@ -57,6 +77,7 @@ target_link_libraries(gnucash-guile
|
||||
PRIVATE
|
||||
gnc-core-utils
|
||||
gnc-engine
|
||||
gnc-app-utils
|
||||
${GLIB2_LDFLAGS})
|
||||
|
||||
install(TARGETS gnucash-guile
|
||||
@ -65,6 +86,28 @@ install(TARGETS gnucash-guile
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
add_library(gnc-expressions-guile SHARED
|
||||
${SWIG_EXPRESSIONS_GUILE_C})
|
||||
|
||||
target_include_directories(gnc-expressions-guile
|
||||
PUBLIC
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/expressions
|
||||
${GUILE_INCLUDE_DIRS}
|
||||
${GLIB2_INCLUDE_DIRS})
|
||||
|
||||
target_link_libraries(gnc-expressions-guile
|
||||
gnc-expressions
|
||||
gnc-engine
|
||||
gnc-app-utils
|
||||
${GUILE_LDFLAGS}
|
||||
${GLIB2_LDFLAGS})
|
||||
|
||||
install(TARGETS gnc-expressions-guile
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
# Scheme
|
||||
|
||||
set (core_utils_SCHEME core-utils.scm)
|
||||
@ -126,6 +169,57 @@ gnc_add_scheme_targets(scm-engine-2
|
||||
|
||||
add_custom_target(scm-engine ALL DEPENDS scm-engine-2 scm-engine-1 scm-engine-0)
|
||||
|
||||
set (app_utils_SCHEME_1
|
||||
c-interface.scm
|
||||
date-utilities.scm
|
||||
)
|
||||
|
||||
set (app_utils_SCHEME_1a
|
||||
options.scm
|
||||
)
|
||||
|
||||
set (app_utils_SCHEME_2
|
||||
app-utils.scm
|
||||
)
|
||||
|
||||
|
||||
set(GUILE_DEPENDS
|
||||
gnc-app-utils
|
||||
scm-core-utils
|
||||
scm-engine)
|
||||
|
||||
gnc_add_scheme_targets(scm-app-utils-1
|
||||
SOURCES "${app_utils_SCHEME_1}"
|
||||
OUTPUT_DIR "gnucash/app-utils"
|
||||
DEPENDS "${GUILE_DEPENDS}"
|
||||
MAKE_LINKS)
|
||||
|
||||
gnc_add_scheme_targets(scm-app-utils-1a
|
||||
SOURCES "${app_utils_SCHEME_1a}"
|
||||
OUTPUT_DIR "gnucash/app-utils"
|
||||
DEPENDS "scm-app-utils-1"
|
||||
MAKE_LINKS)
|
||||
|
||||
gnc_add_scheme_targets(scm-app-utils-2
|
||||
SOURCES "${app_utils_SCHEME_2}"
|
||||
OUTPUT_DIR "gnucash"
|
||||
DEPENDS "scm-app-utils-1a"
|
||||
MAKE_LINKS)
|
||||
|
||||
add_custom_target(scm-app-utils ALL DEPENDS scm-app-utils-2 scm-app-utils-1)
|
||||
|
||||
set(expressions_SCHEME
|
||||
fin.scm)
|
||||
|
||||
set(GUILE_INTERNAL_DEPENDS
|
||||
scm-app-utils-1)
|
||||
|
||||
gnc_add_scheme_targets(scm-expressions
|
||||
SOURCES "${expressions_SCHEME}"
|
||||
OUTPUT_DIR "gnucash/app-utils"
|
||||
DEPENDS "${GUILE_INTERNAL_DEPENDS}"
|
||||
MAKE_LINKS)
|
||||
|
||||
set_local_dist(guile_DIST_local
|
||||
CMakeLists.txt
|
||||
core-utils.scm
|
||||
@ -133,7 +227,14 @@ set_local_dist(guile_DIST_local
|
||||
${guile_HEADERS}
|
||||
${engine_SCHEME_0}
|
||||
${engine_SCHEME_1}
|
||||
${engine_SCHEME_2})
|
||||
${engine_SCHEME_2}
|
||||
${app_utils_SCHEME_1}
|
||||
${app_utils_SCHEME_1a}
|
||||
${app_utils_SCHEME_1b}
|
||||
${app_utils_SCHEME_1c}
|
||||
${app_utils_SCHEME_2}
|
||||
${app_utils_SCHEME_3}
|
||||
expressions.i)
|
||||
set(guile_DIST ${guile_DIST_local} ${test_guile_DIST} PARENT_SCOPE)
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
(define-module (gnucash app-utils))
|
||||
|
||||
(eval-when (compile load eval expand)
|
||||
(load-extension "libgnc-app-utils" "scm_init_sw_app_utils_module"))
|
||||
(load-extension "libgnucash-guile" "scm_init_sw_app_utils_module"))
|
||||
|
||||
(use-modules (srfi srfi-1))
|
||||
(use-modules (gnucash utilities))
|
@ -24,7 +24,7 @@
|
||||
(define-module (gnucash app-utils date-utilities))
|
||||
|
||||
(eval-when (compile load eval expand)
|
||||
(load-extension "libgnc-app-utils" "scm_init_sw_app_utils_module"))
|
||||
(load-extension "libgnucash-guile" "scm_init_sw_app_utils_module"))
|
||||
|
||||
(use-modules (gnucash engine))
|
||||
(use-modules (gnucash core-utils))
|
@ -20,7 +20,7 @@
|
||||
(define-module (gnucash app-utils options))
|
||||
|
||||
(eval-when (compile load eval expand)
|
||||
(load-extension "libgnc-app-utils" "scm_init_sw_app_utils_module"))
|
||||
(load-extension "libgnucash-guile" "scm_init_sw_app_utils_module"))
|
||||
|
||||
(use-modules (gnucash core-utils))
|
||||
(use-modules (gnucash engine))
|
@ -6,15 +6,20 @@ set(ENGINE_TEST_INCLUDE_DIRS
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/engine/test-core
|
||||
${CMAKE_BINARY_DIR}/common # for config.h
|
||||
${CMAKE_SOURCE_DIR}/common/test-core # for unittest-support.h
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/app-utils
|
||||
${CMAKE_SOURCE_DIR}/bindings/guile # for gnc-engine-guile.h
|
||||
${GLIB2_INCLUDE_DIRS}
|
||||
${GUILE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
set(ENGINE_TEST_LIBS
|
||||
gnc-engine
|
||||
gnc-app-utils
|
||||
gnc-test-engine
|
||||
test-core
|
||||
gnucash-guile
|
||||
${GIO_LDFLAGS}
|
||||
${GUILE_LDFLAGS}
|
||||
${LIBXML2_LDFLAGS}
|
||||
-lm)
|
||||
|
||||
@ -105,11 +110,57 @@ set(test_engine_SCHEME_DIST
|
||||
test-business-core.scm
|
||||
)
|
||||
|
||||
set(test_app_utils_scheme_SOURCES
|
||||
test-c-interface.scm
|
||||
test-load-app-utils-module.scm
|
||||
)
|
||||
|
||||
set (test_app_utils_scheme_SRFI64_SOURCES
|
||||
test-date-utilities.scm
|
||||
test-options.scm
|
||||
)
|
||||
|
||||
gnc_add_scheme_test_targets(scm-test-load-app-utils-module
|
||||
SOURCES "test-load-app-utils-module.scm"
|
||||
OUTPUT_DIR "tests"
|
||||
DEPENDS "${GUILE_DEPENDS}")
|
||||
|
||||
gnc_add_scheme_test_targets(scm-test-c-interface
|
||||
SOURCES "test-c-interface.scm"
|
||||
OUTPUT_DIR "tests"
|
||||
DEPENDS "${GUILE_DEPENDS}")
|
||||
|
||||
gnc_add_scheme_tests("${test_app_utils_scheme_SOURCES}")
|
||||
|
||||
if (HAVE_SRFI64)
|
||||
gnc_add_scheme_test_targets(scm-test-app-utils-srfi64
|
||||
SOURCES "${test_app_utils_scheme_SRFI64_SOURCES}"
|
||||
OUTPUT_DIR "tests"
|
||||
DEPENDS "${GUILE_DEPENDS};scm-srfi64-extras")
|
||||
|
||||
gnc_add_scheme_test_targets(scm-test-gnc-optiondb
|
||||
SOURCES "test-gnc-optiondb.scm" "test-gnc-option-scheme-output.scm"
|
||||
OUTPUT_DIR "tests"
|
||||
DEPENDS "swig-apputils-guile-cpp;scm-srfi64-extras")
|
||||
gnc_add_scheme_tests("test-gnc-optiondb.scm")
|
||||
gnc_add_scheme_tests("test-gnc-option-scheme-output.scm")
|
||||
gnc_add_scheme_tests("${test_app_utils_scheme_SRFI64_SOURCES}")
|
||||
endif()
|
||||
|
||||
gnc_add_test_with_guile(test-print-queries test-print-queries.cpp ENGINE_TEST_INCLUDE_DIRS ENGINE_TEST_LIBS)
|
||||
gnc_add_test_with_guile(test-scm-query-string test-scm-query-string.cpp
|
||||
ENGINE_TEST_INCLUDE_DIRS ENGINE_TEST_LIBS
|
||||
)
|
||||
|
||||
set_local_dist(test_guile_DIST_local
|
||||
CMakeLists.txt
|
||||
test-print-queries.cpp
|
||||
test-scm-query.cpp
|
||||
test-scm-query-string.cpp
|
||||
${test_engine_SCHEME_DIST}
|
||||
${test_scm_SCHEME}
|
||||
${test_app_utils_scheme_SOURCES}
|
||||
${test_app_utils_scheme_SRFI64_SOURCES}
|
||||
)
|
||||
set(test_guile_DIST
|
||||
${test_guile_DIST_local}
|
||||
|
@ -39,7 +39,7 @@
|
||||
;; Load the C++ option implementation, avoiding the options.scm ones.
|
||||
(eval-when
|
||||
(compile load eval expand)
|
||||
(load-extension "libgnc-app-utils" "scm_init_sw_app_utils_module"))
|
||||
(load-extension "libgnucash-guile" "scm_init_sw_app_utils_module"))
|
||||
|
||||
(use-modules (gnucash engine))
|
||||
(use-modules (sw_app_utils))
|
||||
@ -246,4 +246,4 @@
|
||||
(gnc-register-report-placement-option option-db "foo" "bar")
|
||||
(gnc-set-option option-db "foo" "bar" rp)
|
||||
(test-equal report2 (car (cadr (gnc-option-value option-db "foo" "bar")))))
|
||||
(test-end "test-gnc-report-placement-option"))
|
||||
(test-end "test-gnc-report-placement-option"))
|
@ -2,7 +2,7 @@
|
||||
;; Load the C++ option implementation, avoiding the options.scm ones.
|
||||
(eval-when
|
||||
(compile load eval expand)
|
||||
(load-extension "libgnc-app-utils" "scm_init_sw_app_utils_module"))
|
||||
(load-extension "libgnucash-guile" "scm_init_sw_app_utils_module"))
|
||||
(use-modules (sw_app_utils))
|
||||
(use-modules (srfi srfi-64))
|
||||
(use-modules (tests srfi64-extras))
|
@ -55,6 +55,13 @@ gnc_add_swig_python_command (swig-core-utils-python
|
||||
${CORE_UTILS_HEADERS}
|
||||
)
|
||||
|
||||
# Command to generate the swig-app-utils-python.c wrapper file
|
||||
gnc_add_swig_python_command (swig-app-utils-python
|
||||
SWIG_APP_UTILS_PYTHON_C SWIG_APP_UTILS_PYTHON_PY
|
||||
swig-app-utils-python.c sw_app_utils.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../app-utils.i ""
|
||||
)
|
||||
|
||||
if(WITH_PYTHON)
|
||||
|
||||
### gnucash_core_c
|
||||
@ -146,6 +153,39 @@ if(WITH_PYTHON)
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR_BUILD}/gnucash/_sw_core_utils${CMAKE_SHARED_MODULE_SUFFIX} ${PYTHON_SYSCONFIG_BUILD}/gnucash
|
||||
DEPENDS sw_core_utils)
|
||||
|
||||
### App-utils
|
||||
set(PYEXEC_FILES sw_app_utils.py)
|
||||
add_library (sw_app_utils MODULE ${SWIG_APP_UTILS_PYTHON_C})
|
||||
|
||||
target_link_libraries(sw_app_utils gnc-app-utils ${app_utils_ALL_LIBRARIES} ${PYTHON_LIBRARIES})
|
||||
set_target_properties(sw_app_utils PROPERTIES PREFIX "_")
|
||||
if (HAVE_STRINGOP_TRUNCATION)
|
||||
target_compile_options(sw_app_utils PRIVATE -Wno-error=stringop-truncation)
|
||||
endif()
|
||||
|
||||
add_custom_target(sw-app-utils-py ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${SWIG_APP_UTILS_PYTHON_PY} ${PYTHON_SYSCONFIG_BUILD}/gnucash
|
||||
DEPENDS ${SWIG_APP_UTILS_PYTHON_C})
|
||||
|
||||
target_include_directories (sw_app_utils
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PRIVATE ${app_utils_ALL_INCLUDES} ${PYTHON_INCLUDE_DIRS}
|
||||
)
|
||||
target_compile_definitions (sw_app_utils PRIVATE -DG_LOG_DOMAIN=\"gnc.app-utils\")
|
||||
|
||||
if (APPLE)
|
||||
set_target_properties (sw_app_utils PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||
endif()
|
||||
|
||||
install(TARGETS sw_app_utils
|
||||
LIBRARY DESTINATION ${PYTHON_SYSCONFIG_OUTPUT}/gnucash
|
||||
ARCHIVE DESTINATION ${PYTHON_SYSCONFIG_OUTPUT}/gnucash
|
||||
)
|
||||
|
||||
add_custom_target(sw-app-utils-build ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR_BUILD}/gnucash/_sw_app_utils${CMAKE_SHARED_MODULE_SUFFIX} ${PYTHON_SYSCONFIG_BUILD}/gnucash
|
||||
DEPENDS sw_app_utils)
|
||||
|
||||
endif()
|
||||
|
||||
set(python_bindings_DATA ${PYEXEC_FILES}
|
||||
|
@ -207,6 +207,7 @@ target_link_libraries(gnc-gnome-utils
|
||||
gnc-app-utils
|
||||
gnc-engine
|
||||
gnc-expressions
|
||||
gnc-locale-tax
|
||||
gnc-backend-xml-utils
|
||||
gnucash-guile
|
||||
PkgConfig::GTK3
|
||||
|
@ -49,7 +49,7 @@
|
||||
#include "gnc-tree-view-account.h"
|
||||
#include "gnc-ui.h"
|
||||
#include "gnc-ui-util.h"
|
||||
|
||||
#include <gnc-locale-tax.h>
|
||||
|
||||
#define DIALOG_NEW_ACCOUNT_CM_CLASS "dialog-new-account"
|
||||
#define DIALOG_EDIT_ACCOUNT_CM_CLASS "dialog-edit-account"
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "gnc-gobject-utils.h"
|
||||
#include "gnc-ui-balances.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include <gnc-locale-tax.h>
|
||||
|
||||
#define TREE_MODEL_ACCOUNT_CM_CLASS "tree-model-account"
|
||||
|
||||
|
@ -17,7 +17,6 @@ set (app_utils_noinst_HEADERS
|
||||
set (app_utils_HEADERS
|
||||
QuickFill.h
|
||||
file-utils.h
|
||||
gfec.h
|
||||
gnc-basic-gobject.h
|
||||
gnc-account-merge.h
|
||||
gnc-accounting-period.h
|
||||
@ -26,7 +25,6 @@ set (app_utils_HEADERS
|
||||
gnc-euro.h
|
||||
gnc-gsettings.h
|
||||
gnc-help-utils.h
|
||||
gnc-helpers.h
|
||||
gnc-option.hpp
|
||||
gnc-optiondb.h
|
||||
gnc-optiondb.hpp
|
||||
@ -36,34 +34,15 @@ set (app_utils_HEADERS
|
||||
gnc-ui-balances.h
|
||||
)
|
||||
|
||||
# Command to generate the swig-app-utils-guile.c wrapper file
|
||||
set(SWIG_ARGS "-c++" "-procdoc" "sw-gnc-option-doc" "-procdocformat" "plain")
|
||||
gnc_add_swig_guile_command (swig-apputils-guile-cpp #target
|
||||
SWIG_APP_UTILS_GUILE_CPP swig-app-utils-guile.cpp #outvar, output
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/app-utils.i #input
|
||||
"${CMAKE_SOURCE_DIR}/bindings;${CMAKE_SOURCE_DIR}/bindings/guile" #includes
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gnc-optiondb.i #additional dependencies
|
||||
)
|
||||
unset(SWIG_ARGS)
|
||||
|
||||
# Command to generate the swig-app-utils-python.c wrapper file
|
||||
gnc_add_swig_python_command (swig-app-utils-python
|
||||
SWIG_APP_UTILS_PYTHON_C SWIG_APP_UTILS_PYTHON_PY
|
||||
swig-app-utils-python.c sw_app_utils.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/app-utils.i ""
|
||||
)
|
||||
|
||||
set (app_utils_SOURCES
|
||||
QuickFill.c
|
||||
file-utils.c
|
||||
gfec.c
|
||||
gnc-account-merge.c
|
||||
gnc-accounting-period.c
|
||||
gnc-addr-quickfill.c
|
||||
gnc-entry-quickfill.c
|
||||
gnc-euro.c
|
||||
gnc-gsettings.cpp
|
||||
gnc-helpers.c
|
||||
gnc-option-date.cpp
|
||||
gnc-option.cpp
|
||||
gnc-option-impl.cpp
|
||||
@ -84,8 +63,6 @@ endif()
|
||||
set(app_utils_ALL_SOURCES ${app_utils_SOURCES} ${app_utils_HEADERS} ${app_utils_noinst_HEADERS})
|
||||
set(app_utils_ALL_LIBRARIES
|
||||
gnc-engine
|
||||
gnc-locale-tax
|
||||
gnucash-guile
|
||||
${GLIB_LDFLAGS}
|
||||
${GIO_LDFLAGS}
|
||||
${LIBXML2_LDFLAGS}
|
||||
@ -130,44 +107,10 @@ install(TARGETS gnc-app-utils
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
if (WITH_PYTHON)
|
||||
set(PYEXEC_FILES sw_app_utils.py)
|
||||
add_library (sw_app_utils MODULE ${SWIG_APP_UTILS_PYTHON_C})
|
||||
|
||||
target_link_libraries(sw_app_utils gnc-app-utils ${app_utils_ALL_LIBRARIES} ${PYTHON_LIBRARIES})
|
||||
set_target_properties(sw_app_utils PROPERTIES PREFIX "_")
|
||||
if (HAVE_STRINGOP_TRUNCATION)
|
||||
target_compile_options(sw_app_utils PRIVATE -Wno-error=stringop-truncation)
|
||||
endif()
|
||||
|
||||
target_include_directories (sw_app_utils
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PRIVATE ${app_utils_ALL_INCLUDES} ${PYTHON_INCLUDE_DIRS}
|
||||
)
|
||||
target_compile_definitions (sw_app_utils PRIVATE -DG_LOG_DOMAIN=\"gnc.app-utils\")
|
||||
|
||||
if (APPLE)
|
||||
set_target_properties (sw_app_utils PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||
endif()
|
||||
|
||||
install(TARGETS sw_app_utils
|
||||
LIBRARY DESTINATION ${PYTHON_SYSCONFIG_OUTPUT}/gnucash
|
||||
ARCHIVE DESTINATION ${PYTHON_SYSCONFIG_OUTPUT}/gnucash
|
||||
)
|
||||
|
||||
add_custom_target(sw-app-utils-py ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${SWIG_APP_UTILS_PYTHON_PY} ${PYTHON_SYSCONFIG_BUILD}/gnucash
|
||||
DEPENDS ${SWIG_APP_UTILS_PYTHON_C})
|
||||
|
||||
add_custom_target(sw-app-utils-build ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR_BUILD}/gnucash/_sw_app_utils${CMAKE_SHARED_MODULE_SUFFIX} ${PYTHON_SYSCONFIG_BUILD}/gnucash
|
||||
DEPENDS sw_app_utils)
|
||||
|
||||
endif()
|
||||
|
||||
set(expressions_SOURCES
|
||||
calculation/expression_parser.c
|
||||
calculation/fin.c
|
||||
gfec.c
|
||||
gnc-exp-parser.c
|
||||
gnc-sx-instance-model.c
|
||||
)
|
||||
@ -179,6 +122,7 @@ set(expressions_noinstall_HEADERS
|
||||
calculation/fin_static_proto.h
|
||||
)
|
||||
set(expressions_HEADERS
|
||||
gfec.h
|
||||
gnc-exp-parser.h
|
||||
gnc-sx-instance-model.h
|
||||
)
|
||||
@ -206,8 +150,8 @@ target_include_directories(gnc-expressions
|
||||
target_link_libraries(gnc-expressions
|
||||
PUBLIC
|
||||
gnc-engine
|
||||
gnucash-guile
|
||||
gnc-app-utils
|
||||
gnucash-guile
|
||||
${GUILE_LDFLAGS}
|
||||
${GLIB2_LDFLAGS})
|
||||
|
||||
@ -217,90 +161,9 @@ install(TARGETS gnc-expressions
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
#Generate the swig-expressions-guile.c wrapper file
|
||||
gnc_add_swig_guile_command(swig-expressions-guile-c #target
|
||||
SWIG_EXPRESSIONS_GUILE_C swig-expressions-guile.c #outvar, output
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/expressions.i #input
|
||||
"${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_SOURCE_DIR}/libgnucash/app-utils;${CMAKE_SOURCE_DIR}/libgnucash/expressions" #includes
|
||||
)
|
||||
|
||||
add_library(gnc-expressions-guile SHARED
|
||||
${SWIG_EXPRESSIONS_GUILE_C})
|
||||
|
||||
target_include_directories(gnc-expressions-guile
|
||||
PUBLIC
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/expressions
|
||||
${GUILE_INCLUDE_DIRS}
|
||||
${GLIB2_INCLUDE_DIRS})
|
||||
|
||||
target_link_libraries(gnc-expressions-guile
|
||||
gnc-expressions
|
||||
gnc-engine
|
||||
gnc-app-utils
|
||||
${GUILE_LDFLAGS}
|
||||
${GLIB2_LDFLAGS})
|
||||
|
||||
install(TARGETS gnc-expressions-guile
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
install(FILES ${app_utils_HEADERS} ${expressions_HEADERS}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gnucash)
|
||||
|
||||
# And now handle scheme files
|
||||
|
||||
set (app_utils_SCHEME_1
|
||||
c-interface.scm
|
||||
date-utilities.scm
|
||||
)
|
||||
|
||||
set (app_utils_SCHEME_1a
|
||||
options.scm
|
||||
)
|
||||
|
||||
set (app_utils_SCHEME_2
|
||||
app-utils.scm
|
||||
)
|
||||
|
||||
set(GUILE_DEPENDS
|
||||
gnc-app-utils
|
||||
scm-core-utils
|
||||
scm-engine)
|
||||
|
||||
gnc_add_scheme_targets(scm-app-utils-1
|
||||
SOURCES "${app_utils_SCHEME_1}"
|
||||
OUTPUT_DIR "gnucash/app-utils"
|
||||
DEPENDS "${GUILE_DEPENDS}"
|
||||
MAKE_LINKS)
|
||||
|
||||
gnc_add_scheme_targets(scm-app-utils-1a
|
||||
SOURCES "${app_utils_SCHEME_1a}"
|
||||
OUTPUT_DIR "gnucash/app-utils"
|
||||
DEPENDS "scm-app-utils-1"
|
||||
MAKE_LINKS)
|
||||
|
||||
gnc_add_scheme_targets(scm-app-utils-2
|
||||
SOURCES "${app_utils_SCHEME_2}"
|
||||
OUTPUT_DIR "gnucash"
|
||||
DEPENDS "scm-app-utils-1a"
|
||||
MAKE_LINKS)
|
||||
|
||||
add_custom_target(scm-app-utils ALL DEPENDS scm-app-utils-2 scm-app-utils-1)
|
||||
|
||||
set(expressions_SCHEME
|
||||
fin.scm)
|
||||
|
||||
set(GUILE_INTERNAL_DEPENDS
|
||||
scm-app-utils-1)
|
||||
|
||||
gnc_add_scheme_targets(scm-expressions
|
||||
SOURCES "${expressions_SCHEME}"
|
||||
OUTPUT_DIR "gnucash/app-utils"
|
||||
DEPENDS "${GUILE_INTERNAL_DEPENDS}"
|
||||
MAKE_LINKS)
|
||||
|
||||
set_local_dist(app_utils_DIST_local
|
||||
${app_utils_ALL_SOURCES}
|
||||
${app_utils_SCHEME_1}
|
||||
@ -313,6 +176,7 @@ set_local_dist(app_utils_DIST_local
|
||||
${expressions_SCHEME}
|
||||
app-utils.i gnc-optiondb.i expressions.i CMakeLists.txt gnc-help-utils.c)
|
||||
|
||||
|
||||
set(app_utils_DIST
|
||||
${app_utils_DIST_local}
|
||||
${test_app_utils_DIST}
|
||||
|
@ -43,7 +43,6 @@ extern "C"
|
||||
#include <gnc-commodity.h>
|
||||
}
|
||||
#include <gnc-datetime.hpp>
|
||||
#include <libguile.h>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
@ -34,7 +34,6 @@
|
||||
#define GNC_OPTION_HPP_
|
||||
|
||||
#include <glib.h>
|
||||
#include <libguile.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
@ -21,7 +21,6 @@
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#include <libguile.h>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <limits>
|
||||
|
@ -63,8 +63,6 @@ typedef struct GncOption GncOption;
|
||||
typedef struct GncOptionDB GncOptionDB;
|
||||
#endif
|
||||
|
||||
#include <libguile.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include <exception>
|
||||
#include <optional>
|
||||
#include <iostream>
|
||||
#include <libguile.h>
|
||||
extern "C"
|
||||
{
|
||||
#include <config.h>
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <gio/gio.h>
|
||||
#include <libguile.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
@ -45,18 +44,15 @@
|
||||
|
||||
|
||||
#include "qof.h"
|
||||
#include "guile-mappings.h"
|
||||
#include "gnc-prefs.h"
|
||||
#include "Account.h"
|
||||
#include "Transaction.h"
|
||||
#include "gnc-engine.h"
|
||||
#include "gnc-features.h"
|
||||
#include "gnc-hooks.h"
|
||||
#include "gnc-locale-tax.h"
|
||||
#include "gnc-session.h"
|
||||
#include "engine-helpers.h"
|
||||
#include "gnc-locale-utils.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
|
||||
#define GNC_PREF_CURRENCY_CHOICE_LOCALE "currency-choice-locale"
|
||||
#define GNC_PREF_CURRENCY_CHOICE_OTHER "currency-choice-other"
|
||||
@ -467,263 +463,6 @@ gnc_account_lookup_for_register(const Account *base_account, const char *name)
|
||||
return gnc_account_lookup_by_full_name (base_account, name);
|
||||
}
|
||||
|
||||
|
||||
/* Caller is responsible for g_free'ing returned memory */
|
||||
char *
|
||||
gnc_ui_account_get_tax_info_string (const Account *account)
|
||||
{
|
||||
static SCM get_form = SCM_UNDEFINED;
|
||||
static SCM get_desc = SCM_UNDEFINED;
|
||||
|
||||
gboolean tax_related = FALSE;
|
||||
const char *code;
|
||||
|
||||
if (!account)
|
||||
return NULL;
|
||||
|
||||
tax_related = xaccAccountGetTaxRelated (account);
|
||||
code = xaccAccountGetTaxUSCode (account);
|
||||
|
||||
if (!code)
|
||||
{
|
||||
if (!tax_related)
|
||||
return NULL;
|
||||
/* tax_related && !code */
|
||||
else
|
||||
/* Translators: This and the following strings appear on
|
||||
the account tab if the Tax Info column is displayed,
|
||||
i.e. if the user wants to record the tax form number
|
||||
and location on that tax form which corresponds to this
|
||||
gnucash account. For the US Income Tax support in
|
||||
gnucash, each tax code that can be assigned to an
|
||||
account generally corresponds to a specific line number
|
||||
on a paper form and each form has a unique
|
||||
identification (e.g., Form 1040, Schedule A). */
|
||||
return g_strdup (_("Tax-related but has no tax code"));
|
||||
}
|
||||
else /* with tax code */
|
||||
{
|
||||
const gchar *tax_type;
|
||||
GNCAccountType atype;
|
||||
SCM tax_entity_type;
|
||||
SCM category;
|
||||
gchar *num_code = NULL;
|
||||
const gchar *prefix = "N";
|
||||
gchar *return_string = NULL;
|
||||
|
||||
tax_type = gnc_get_current_book_tax_type ();
|
||||
if (tax_type == NULL || (g_strcmp0 (tax_type, "") == 0))
|
||||
return g_strdup (_("Tax entity type not specified"));
|
||||
|
||||
atype = xaccAccountGetType (account);
|
||||
tax_entity_type = scm_from_utf8_string (tax_type);
|
||||
|
||||
if (get_form == SCM_UNDEFINED)
|
||||
{
|
||||
const gchar *tax_module;
|
||||
/* load the tax info */
|
||||
gnc_locale_tax_init ();
|
||||
|
||||
get_form = scm_c_eval_string
|
||||
("(false-if-exception gnc:txf-get-form)");
|
||||
get_desc = scm_c_eval_string
|
||||
("(false-if-exception gnc:txf-get-description)");
|
||||
}
|
||||
|
||||
g_return_val_if_fail (scm_is_procedure (get_form), NULL);
|
||||
g_return_val_if_fail (scm_is_procedure (get_desc), NULL);
|
||||
|
||||
category = scm_c_eval_string (atype == ACCT_TYPE_INCOME ?
|
||||
"txf-income-categories" :
|
||||
(atype == ACCT_TYPE_EXPENSE ?
|
||||
"txf-expense-categories" :
|
||||
(((atype == ACCT_TYPE_BANK) ||
|
||||
(atype == ACCT_TYPE_CASH) ||
|
||||
(atype == ACCT_TYPE_ASSET) ||
|
||||
(atype == ACCT_TYPE_STOCK) ||
|
||||
(atype == ACCT_TYPE_MUTUAL) ||
|
||||
(atype == ACCT_TYPE_RECEIVABLE)) ?
|
||||
"txf-asset-categories" :
|
||||
(((atype == ACCT_TYPE_CREDIT) ||
|
||||
(atype == ACCT_TYPE_LIABILITY) ||
|
||||
(atype == ACCT_TYPE_EQUITY) ||
|
||||
(atype == ACCT_TYPE_PAYABLE)) ?
|
||||
"txf-liab-eq-categories" : ""))));
|
||||
|
||||
if (g_str_has_prefix (code, prefix))
|
||||
{
|
||||
const gchar *num_code_tmp;
|
||||
num_code_tmp = g_strdup (code);
|
||||
num_code_tmp++; /* to lose the leading N */
|
||||
num_code = g_strdup (num_code_tmp);
|
||||
num_code_tmp--;
|
||||
g_free ((gpointer *) num_code_tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
num_code = g_strdup (code);
|
||||
}
|
||||
|
||||
if (category == SCM_UNDEFINED)
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("Tax type %s: invalid code %s for account type"),
|
||||
tax_type, num_code);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; tax type %s: invalid code %s for account type"),
|
||||
tax_type, num_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
SCM code_scm;
|
||||
SCM form_scm;
|
||||
code_scm = scm_from_locale_symbol (code);
|
||||
form_scm = scm_call_3 (get_form, category, code_scm, tax_entity_type);
|
||||
if (!scm_is_string (form_scm))
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("Invalid code %s for tax type %s"),
|
||||
num_code, tax_type);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; invalid code %s for tax type %s"),
|
||||
num_code, tax_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *form = NULL;
|
||||
|
||||
/* Note: using scm_to_utf8_stringn directly here instead
|
||||
of our wrapper gnc_scm_to_utf8_string. 'form' should
|
||||
be freed with 'free' instead of 'g_free'. This will
|
||||
be taken care of automatically during scm_dynwind_end,
|
||||
because we inform guile of this memory allocation via
|
||||
scm_dynwind_free a little further. */
|
||||
form = scm_to_utf8_stringn (form_scm, NULL);
|
||||
if (!form)
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("No form: code %s, tax type %s"), num_code,
|
||||
tax_type);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; no form: code %s, tax type %s"),
|
||||
num_code, tax_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
SCM desc_scm;
|
||||
|
||||
/* Create a dynwind context because we will be calling (scm) functions
|
||||
that potentially exit non-locally */
|
||||
scm_dynwind_begin (0);
|
||||
scm_dynwind_free (form);
|
||||
desc_scm = scm_call_3 (get_desc, category, code_scm,
|
||||
tax_entity_type);
|
||||
if (!scm_is_string (desc_scm))
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("No description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *desc = NULL;
|
||||
desc = gnc_scm_to_utf8_string (desc_scm);
|
||||
if (!desc)
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("No description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
gint64 copy_number;
|
||||
gchar *copy_txt = NULL;
|
||||
copy_number = xaccAccountGetTaxUSCopyNumber (account);
|
||||
copy_txt = (copy_number == 1) ?
|
||||
g_strdup ("") :
|
||||
g_strdup_printf ("(%d)",
|
||||
(gint) copy_number);
|
||||
if (tax_related)
|
||||
{
|
||||
if (g_strcmp0 (form, "") == 0)
|
||||
return_string = g_strdup_printf ("%s", desc);
|
||||
else
|
||||
return_string = g_strdup_printf ("%s%s: %s",
|
||||
form, copy_txt, desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; %s%s: %s (code %s, tax type %s)"),
|
||||
form, copy_txt, desc, num_code, tax_type);
|
||||
}
|
||||
g_free (copy_txt);
|
||||
}
|
||||
g_free (desc);
|
||||
}
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
}
|
||||
}
|
||||
g_free (num_code);
|
||||
return return_string;
|
||||
}
|
||||
}
|
||||
|
||||
/* Caller is responsible for g_free'ing returned memory */
|
||||
char *
|
||||
gnc_ui_account_get_tax_info_sub_acct_string (const Account *account)
|
||||
{
|
||||
GList *descendant, *account_descendants;
|
||||
|
||||
if (!account)
|
||||
return NULL;
|
||||
|
||||
account_descendants = gnc_account_get_descendants (account);
|
||||
if (account_descendants)
|
||||
{
|
||||
gint sub_acct_tax_number = 0;
|
||||
for (descendant = account_descendants; descendant;
|
||||
descendant = g_list_next(descendant))
|
||||
{
|
||||
if (xaccAccountGetTaxRelated (descendant->data))
|
||||
sub_acct_tax_number++;
|
||||
}
|
||||
g_list_free (account_descendants);
|
||||
g_list_free (descendant);
|
||||
/* Translators: This and the following strings appear on
|
||||
the account tab if the Tax Info column is displayed,
|
||||
i.e. if the user wants to record the tax form number
|
||||
and location on that tax form which corresponds to this
|
||||
gnucash account. For the US Income Tax support in
|
||||
gnucash, each tax code that can be assigned to an
|
||||
account generally corresponds to a specific line number
|
||||
on a paper form and each form has a unique
|
||||
identification (e.g., Form 1040, Schedule A). */
|
||||
return (sub_acct_tax_number == 0) ? NULL :
|
||||
g_strdup_printf (_("(Tax-related subaccounts: %d)"),
|
||||
sub_acct_tax_number);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_get_reconcile_str *
|
||||
* return the i18n'd string for the given reconciled flag *
|
||||
|
@ -142,9 +142,6 @@ gchar *gnc_get_account_name_for_split_register(const Account *account,
|
||||
* of things like stock account values from share
|
||||
* values to an amount the requested currency.
|
||||
*/
|
||||
char *gnc_ui_account_get_tax_info_string (const Account *account);
|
||||
|
||||
char *gnc_ui_account_get_tax_info_sub_acct_string (const Account *account);
|
||||
|
||||
const char * gnc_get_reconcile_str (char reconciled_flag);
|
||||
const char * gnc_get_reconcile_valid_flags (void);
|
||||
|
@ -26,11 +26,6 @@ gnc_add_test_with_guile(test-exp-parser test-exp-parser.c
|
||||
APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS
|
||||
)
|
||||
add_app_utils_test(test-print-parse-amount test-print-parse-amount.cpp)
|
||||
# FIXME Why is this test not run ?
|
||||
#gnc_add_test_with_guile(test-print-queries test-print-queries.cpp APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS)
|
||||
gnc_add_test_with_guile(test-scm-query-string test-scm-query-string.cpp
|
||||
APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS
|
||||
)
|
||||
add_app_utils_test(test-sx test-sx.cpp)
|
||||
|
||||
set(gtest_gnc_option_SOURCES
|
||||
@ -62,49 +57,10 @@ set(GUILE_DEPENDS
|
||||
gncmod-backend-xml
|
||||
)
|
||||
|
||||
set(test_app_utils_scheme_SOURCES
|
||||
test-c-interface.scm
|
||||
test-load-app-utils-module.scm
|
||||
)
|
||||
|
||||
set (test_app_utils_scheme_SRFI64_SOURCES
|
||||
test-date-utilities.scm
|
||||
test-options.scm
|
||||
)
|
||||
|
||||
gnc_add_scheme_test_targets(scm-test-load-app-utils-module
|
||||
SOURCES "test-load-app-utils-module.scm"
|
||||
OUTPUT_DIR "tests"
|
||||
DEPENDS "${GUILE_DEPENDS}")
|
||||
|
||||
gnc_add_scheme_test_targets(scm-test-c-interface
|
||||
SOURCES "test-c-interface.scm"
|
||||
OUTPUT_DIR "tests"
|
||||
DEPENDS "${GUILE_DEPENDS}")
|
||||
|
||||
gnc_add_scheme_tests("${test_app_utils_scheme_SOURCES}")
|
||||
|
||||
if (HAVE_SRFI64)
|
||||
gnc_add_scheme_test_targets(scm-test-app-utils-srfi64
|
||||
SOURCES "${test_app_utils_scheme_SRFI64_SOURCES}"
|
||||
OUTPUT_DIR "tests"
|
||||
DEPENDS "${GUILE_DEPENDS};scm-srfi64-extras")
|
||||
|
||||
gnc_add_scheme_test_targets(scm-test-gnc-optiondb
|
||||
SOURCES "test-gnc-optiondb.scm" "test-gnc-option-scheme-output.scm"
|
||||
OUTPUT_DIR "tests"
|
||||
DEPENDS "swig-apputils-guile-cpp;scm-srfi64-extras")
|
||||
gnc_add_scheme_tests("test-gnc-optiondb.scm")
|
||||
gnc_add_scheme_tests("test-gnc-option-scheme-output.scm")
|
||||
gnc_add_scheme_tests("${test_app_utils_scheme_SRFI64_SOURCES}")
|
||||
endif()
|
||||
|
||||
set_dist_list(test_app_utils_DIST
|
||||
CMakeLists.txt
|
||||
test-exp-parser.c
|
||||
test-print-parse-amount.cpp
|
||||
test-print-queries.cpp
|
||||
test-scm-query-string.cpp
|
||||
test-sx.cpp
|
||||
gtest-gnc-option.cpp
|
||||
gtest-gnc-optiondb.cpp
|
||||
|
@ -7,6 +7,9 @@ set_source_files_properties (${locale_tax_SOURCES} PROPERTIES OBJECT_DEPENDS ${C
|
||||
|
||||
add_library(gnc-locale-tax ${locale_tax_SOURCES})
|
||||
target_link_libraries(gnc-locale-tax
|
||||
gnc-engine
|
||||
gnc-app-utils
|
||||
gnucash-guile
|
||||
${GLIB2_LDFLAGS}
|
||||
${GUILE_LDFLAGS})
|
||||
|
||||
|
@ -30,7 +30,11 @@
|
||||
#include <locale.h>
|
||||
#include <libguile.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <Account.h>
|
||||
#include <gnc-ui-util.h>
|
||||
#include <guile-mappings.h>
|
||||
#include <gnc-guile-utils.h>
|
||||
#include "gnc-locale-tax.h"
|
||||
|
||||
|
||||
@ -54,3 +58,259 @@ gnc_locale_tax_init(void)
|
||||
else
|
||||
scm_c_use_module("gnucash locale us tax");
|
||||
}
|
||||
|
||||
/* Caller is responsible for g_free'ing returned memory */
|
||||
char *
|
||||
gnc_ui_account_get_tax_info_string (const Account *account)
|
||||
{
|
||||
static SCM get_form = SCM_UNDEFINED;
|
||||
static SCM get_desc = SCM_UNDEFINED;
|
||||
|
||||
gboolean tax_related = FALSE;
|
||||
const char *code;
|
||||
|
||||
if (!account)
|
||||
return NULL;
|
||||
|
||||
tax_related = xaccAccountGetTaxRelated (account);
|
||||
code = xaccAccountGetTaxUSCode (account);
|
||||
|
||||
if (!code)
|
||||
{
|
||||
if (!tax_related)
|
||||
return NULL;
|
||||
/* tax_related && !code */
|
||||
else
|
||||
/* Translators: This and the following strings appear on
|
||||
the account tab if the Tax Info column is displayed,
|
||||
i.e. if the user wants to record the tax form number
|
||||
and location on that tax form which corresponds to this
|
||||
gnucash account. For the US Income Tax support in
|
||||
gnucash, each tax code that can be assigned to an
|
||||
account generally corresponds to a specific line number
|
||||
on a paper form and each form has a unique
|
||||
identification (e.g., Form 1040, Schedule A). */
|
||||
return g_strdup (_("Tax-related but has no tax code"));
|
||||
}
|
||||
else /* with tax code */
|
||||
{
|
||||
const gchar *tax_type;
|
||||
GNCAccountType atype;
|
||||
SCM tax_entity_type;
|
||||
SCM category;
|
||||
gchar *num_code = NULL;
|
||||
const gchar *prefix = "N";
|
||||
gchar *return_string = NULL;
|
||||
|
||||
tax_type = gnc_get_current_book_tax_type ();
|
||||
if (tax_type == NULL || (g_strcmp0 (tax_type, "") == 0))
|
||||
return g_strdup (_("Tax entity type not specified"));
|
||||
|
||||
atype = xaccAccountGetType (account);
|
||||
tax_entity_type = scm_from_utf8_string (tax_type);
|
||||
|
||||
if (get_form == SCM_UNDEFINED)
|
||||
{
|
||||
const gchar *tax_module;
|
||||
/* load the tax info */
|
||||
gnc_locale_tax_init ();
|
||||
|
||||
get_form = scm_c_eval_string
|
||||
("(false-if-exception gnc:txf-get-form)");
|
||||
get_desc = scm_c_eval_string
|
||||
("(false-if-exception gnc:txf-get-description)");
|
||||
}
|
||||
|
||||
g_return_val_if_fail (scm_is_procedure (get_form), NULL);
|
||||
g_return_val_if_fail (scm_is_procedure (get_desc), NULL);
|
||||
|
||||
category = scm_c_eval_string (atype == ACCT_TYPE_INCOME ?
|
||||
"txf-income-categories" :
|
||||
(atype == ACCT_TYPE_EXPENSE ?
|
||||
"txf-expense-categories" :
|
||||
(((atype == ACCT_TYPE_BANK) ||
|
||||
(atype == ACCT_TYPE_CASH) ||
|
||||
(atype == ACCT_TYPE_ASSET) ||
|
||||
(atype == ACCT_TYPE_STOCK) ||
|
||||
(atype == ACCT_TYPE_MUTUAL) ||
|
||||
(atype == ACCT_TYPE_RECEIVABLE)) ?
|
||||
"txf-asset-categories" :
|
||||
(((atype == ACCT_TYPE_CREDIT) ||
|
||||
(atype == ACCT_TYPE_LIABILITY) ||
|
||||
(atype == ACCT_TYPE_EQUITY) ||
|
||||
(atype == ACCT_TYPE_PAYABLE)) ?
|
||||
"txf-liab-eq-categories" : ""))));
|
||||
|
||||
if (g_str_has_prefix (code, prefix))
|
||||
{
|
||||
const gchar *num_code_tmp;
|
||||
num_code_tmp = g_strdup (code);
|
||||
num_code_tmp++; /* to lose the leading N */
|
||||
num_code = g_strdup (num_code_tmp);
|
||||
num_code_tmp--;
|
||||
g_free ((gpointer *) num_code_tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
num_code = g_strdup (code);
|
||||
}
|
||||
|
||||
if (category == SCM_UNDEFINED)
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("Tax type %s: invalid code %s for account type"),
|
||||
tax_type, num_code);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; tax type %s: invalid code %s for account type"),
|
||||
tax_type, num_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
SCM code_scm;
|
||||
SCM form_scm;
|
||||
code_scm = scm_from_locale_symbol (code);
|
||||
form_scm = scm_call_3 (get_form, category, code_scm, tax_entity_type);
|
||||
if (!scm_is_string (form_scm))
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("Invalid code %s for tax type %s"),
|
||||
num_code, tax_type);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; invalid code %s for tax type %s"),
|
||||
num_code, tax_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *form = NULL;
|
||||
|
||||
/* Note: using scm_to_utf8_stringn directly here instead
|
||||
of our wrapper gnc_scm_to_utf8_string. 'form' should
|
||||
be freed with 'free' instead of 'g_free'. This will
|
||||
be taken care of automatically during scm_dynwind_end,
|
||||
because we inform guile of this memory allocation via
|
||||
scm_dynwind_free a little further. */
|
||||
form = scm_to_utf8_stringn (form_scm, NULL);
|
||||
if (!form)
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("No form: code %s, tax type %s"), num_code,
|
||||
tax_type);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; no form: code %s, tax type %s"),
|
||||
num_code, tax_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
SCM desc_scm;
|
||||
|
||||
/* Create a dynwind context because we will be calling (scm) functions
|
||||
that potentially exit non-locally */
|
||||
scm_dynwind_begin (0);
|
||||
scm_dynwind_free (form);
|
||||
desc_scm = scm_call_3 (get_desc, category, code_scm,
|
||||
tax_entity_type);
|
||||
if (!scm_is_string (desc_scm))
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("No description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *desc = NULL;
|
||||
desc = gnc_scm_to_utf8_string (desc_scm);
|
||||
if (!desc)
|
||||
{
|
||||
if (tax_related)
|
||||
return_string = g_strdup_printf
|
||||
(_("No description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
else
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
|
||||
form, num_code, tax_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
gint64 copy_number;
|
||||
gchar *copy_txt = NULL;
|
||||
copy_number = xaccAccountGetTaxUSCopyNumber (account);
|
||||
copy_txt = (copy_number == 1) ?
|
||||
g_strdup ("") :
|
||||
g_strdup_printf ("(%d)",
|
||||
(gint) copy_number);
|
||||
if (tax_related)
|
||||
{
|
||||
if (g_strcmp0 (form, "") == 0)
|
||||
return_string = g_strdup_printf ("%s", desc);
|
||||
else
|
||||
return_string = g_strdup_printf ("%s%s: %s",
|
||||
form, copy_txt, desc);
|
||||
}
|
||||
else
|
||||
{
|
||||
return_string = g_strdup_printf
|
||||
(_("Not tax-related; %s%s: %s (code %s, tax type %s)"),
|
||||
form, copy_txt, desc, num_code, tax_type);
|
||||
}
|
||||
g_free (copy_txt);
|
||||
}
|
||||
g_free (desc);
|
||||
}
|
||||
scm_dynwind_end ();
|
||||
}
|
||||
}
|
||||
}
|
||||
g_free (num_code);
|
||||
return return_string;
|
||||
}
|
||||
}
|
||||
|
||||
/* Caller is responsible for g_free'ing returned memory */
|
||||
char *
|
||||
gnc_ui_account_get_tax_info_sub_acct_string (const Account *account)
|
||||
{
|
||||
GList *descendant, *account_descendants;
|
||||
|
||||
if (!account)
|
||||
return NULL;
|
||||
|
||||
account_descendants = gnc_account_get_descendants (account);
|
||||
if (account_descendants)
|
||||
{
|
||||
gint sub_acct_tax_number = 0;
|
||||
for (descendant = account_descendants; descendant;
|
||||
descendant = g_list_next(descendant))
|
||||
{
|
||||
if (xaccAccountGetTaxRelated (descendant->data))
|
||||
sub_acct_tax_number++;
|
||||
}
|
||||
g_list_free (account_descendants);
|
||||
g_list_free (descendant);
|
||||
/* Translators: This and the following strings appear on
|
||||
the account tab if the Tax Info column is displayed,
|
||||
i.e. if the user wants to record the tax form number
|
||||
and location on that tax form which corresponds to this
|
||||
gnucash account. For the US Income Tax support in
|
||||
gnucash, each tax code that can be assigned to an
|
||||
account generally corresponds to a specific line number
|
||||
on a paper form and each form has a unique
|
||||
identification (e.g., Form 1040, Schedule A). */
|
||||
return (sub_acct_tax_number == 0) ? NULL :
|
||||
g_strdup_printf (_("(Tax-related subaccounts: %d)"),
|
||||
sub_acct_tax_number);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
@ -24,7 +24,11 @@
|
||||
|
||||
#ifndef GNC_LOCALE_TAX_H_
|
||||
#define GNC_LOCALE_TAX_H_
|
||||
#include <config.h>
|
||||
#include <Account.h>
|
||||
|
||||
void gnc_locale_tax_init (void);
|
||||
char *gnc_ui_account_get_tax_info_string (const Account *account);
|
||||
char *gnc_ui_account_get_tax_info_sub_acct_string (const Account *account);
|
||||
|
||||
#endif
|
||||
|
@ -1,14 +1,20 @@
|
||||
# This is a list of files which contain translatable strings.
|
||||
# This file was autogenerated by cmake.
|
||||
bindings/guile/app-utils.scm
|
||||
bindings/guile/business-core.scm
|
||||
bindings/guile/c-interface.scm
|
||||
bindings/guile/core-utils.scm
|
||||
bindings/guile/date-utilities.scm
|
||||
bindings/guile/engine.scm
|
||||
bindings/guile/fin.scm
|
||||
bindings/guile/glib-guile.c
|
||||
bindings/guile/gnc-engine-guile.c
|
||||
bindings/guile/gnc-guile-bindings.c
|
||||
bindings/guile/gnc-guile-utils.c
|
||||
bindings/guile/gnc-helpers.c
|
||||
bindings/guile/gnc-kvp-guile.cpp
|
||||
bindings/guile/gnc-numeric.scm
|
||||
bindings/guile/options.scm
|
||||
bindings/guile/utilities.scm
|
||||
bindings/python/app_utils.py
|
||||
bindings/python/deprecation.py
|
||||
@ -497,13 +503,9 @@ gnucash/report/stylesheets/footer.scm
|
||||
gnucash/report/stylesheets/head-or-tail.scm
|
||||
gnucash/report/stylesheets/plain.scm
|
||||
gnucash/report/trep-engine.scm
|
||||
libgnucash/app-utils/app-utils.scm
|
||||
libgnucash/app-utils/calculation/expression_parser.c
|
||||
libgnucash/app-utils/calculation/fin.c
|
||||
libgnucash/app-utils/c-interface.scm
|
||||
libgnucash/app-utils/date-utilities.scm
|
||||
libgnucash/app-utils/file-utils.c
|
||||
libgnucash/app-utils/fin.scm
|
||||
libgnucash/app-utils/gfec.c
|
||||
libgnucash/app-utils/gnc-accounting-period.c
|
||||
libgnucash/app-utils/gnc-account-merge.c
|
||||
@ -512,7 +514,6 @@ libgnucash/app-utils/gnc-entry-quickfill.c
|
||||
libgnucash/app-utils/gnc-euro.c
|
||||
libgnucash/app-utils/gnc-exp-parser.c
|
||||
libgnucash/app-utils/gnc-gsettings.cpp
|
||||
libgnucash/app-utils/gnc-helpers.c
|
||||
libgnucash/app-utils/gnc-help-utils.c
|
||||
libgnucash/app-utils/gnc-option.cpp
|
||||
libgnucash/app-utils/gnc-option-date.cpp
|
||||
@ -523,7 +524,6 @@ libgnucash/app-utils/gnc-state.c
|
||||
libgnucash/app-utils/gnc-sx-instance-model.c
|
||||
libgnucash/app-utils/gnc-ui-balances.c
|
||||
libgnucash/app-utils/gnc-ui-util.c
|
||||
libgnucash/app-utils/options.scm
|
||||
libgnucash/app-utils/QuickFill.c
|
||||
libgnucash/backend/dbi/gnc-backend-dbi.cpp
|
||||
libgnucash/backend/dbi/gnc-dbisqlconnection.cpp
|
||||
|
Loading…
Reference in New Issue
Block a user