mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Replace overly indirect gnc_business_get_default_tax_table.
With gncTaxTableGetDefault. qof_book_get_default_tax_table would have been even better but it would have created a circular dependency between QofBook and GncTaxTable.
This commit is contained in:
parent
33b1a19eb2
commit
fcc1653822
@ -34,8 +34,6 @@
|
||||
#include "gnc-ui-util.h"
|
||||
#include "recncell.h"
|
||||
|
||||
#include "business-helpers.h"
|
||||
|
||||
#include "gncEntry.h"
|
||||
#include "gncEntryLedger.h"
|
||||
#include "gncEntryLedgerP.h"
|
||||
@ -430,16 +428,16 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
|
||||
switch (gncOwnerGetType (owner))
|
||||
{
|
||||
case GNC_OWNER_CUSTOMER:
|
||||
table = gnc_business_get_default_tax_table (ledger->book,
|
||||
GNC_OWNER_CUSTOMER);
|
||||
table = gncTaxTableGetDefault (ledger->book,
|
||||
GNC_OWNER_CUSTOMER);
|
||||
|
||||
if (gncCustomerGetTaxTableOverride (owner->owner.customer))
|
||||
table = gncCustomerGetTaxTable (owner->owner.customer);
|
||||
break;
|
||||
|
||||
case GNC_OWNER_VENDOR:
|
||||
table = gnc_business_get_default_tax_table (ledger->book,
|
||||
GNC_OWNER_VENDOR);
|
||||
table = gncTaxTableGetDefault (ledger->book,
|
||||
GNC_OWNER_VENDOR);
|
||||
|
||||
if (gncVendorGetTaxTableOverride (owner->owner.vendor))
|
||||
table = gncVendorGetTaxTable (owner->owner.vendor);
|
||||
|
@ -11,7 +11,6 @@ set (app_utils_noinst_HEADERS
|
||||
|
||||
set (app_utils_HEADERS
|
||||
QuickFill.h
|
||||
business-helpers.h
|
||||
business-options.h
|
||||
file-utils.h
|
||||
gfec.h
|
||||
@ -52,7 +51,6 @@ gnc_add_swig_python_command (swig-app-utils-python
|
||||
set (app_utils_SOURCES
|
||||
calculation/expression_parser.c
|
||||
calculation/fin.c
|
||||
business-helpers.c
|
||||
business-options.c
|
||||
QuickFill.c
|
||||
file-utils.c
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* business-options.c -- non-GUI helper functions for business features
|
||||
*
|
||||
* Written By: Derek Atkins <warlord@MIT.EDU>
|
||||
* Copyright (C) 2003 Derek Atkins
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "business-options.h"
|
||||
#include "business-helpers.h"
|
||||
|
||||
GncTaxTable* gnc_business_get_default_tax_table (QofBook *book, GncOwnerType ownertype)
|
||||
{
|
||||
GncTaxTable *table = NULL;
|
||||
GNCOptionDB *odb;
|
||||
|
||||
odb = gnc_option_db_new_for_type (GNC_ID_BOOK);
|
||||
qof_book_load_options (book, gnc_option_db_load, odb);
|
||||
|
||||
switch (ownertype)
|
||||
{
|
||||
case GNC_OWNER_CUSTOMER:
|
||||
table = gnc_option_db_lookup_taxtable_option (odb,
|
||||
"Business",
|
||||
"Default Customer TaxTable",
|
||||
NULL);
|
||||
break;
|
||||
|
||||
case GNC_OWNER_VENDOR:
|
||||
table = gnc_option_db_lookup_taxtable_option (odb,
|
||||
"Business",
|
||||
"Default Vendor TaxTable",
|
||||
NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gnc_option_db_destroy (odb);
|
||||
return table;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* business-helpers.h -- non-GUI helper functions for business features
|
||||
*
|
||||
* Written By: Derek Atkins <warlord@MIT.EDU>
|
||||
* Copyright (C) 2003 Derek Atkins <warlord@MIT.EDU>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef GNC_BUSINESS_HELPERS_H_
|
||||
#define GNC_BUSINESS_HELPERS_H_
|
||||
|
||||
#include "gncTaxTable.h"
|
||||
#include "gncOwner.h"
|
||||
|
||||
|
||||
GncTaxTable* gnc_business_get_default_tax_table (QofBook *book, GncOwnerType ownertype);
|
||||
|
||||
|
||||
#endif /* GNC_BUSINESS_HELPERS_H_ */
|
@ -681,6 +681,26 @@ GncTaxTable *gncTaxTableLookupByName (QofBook *book, const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GncTaxTable*
|
||||
gncTaxTableGetDefault (QofBook *book, GncOwnerType type)
|
||||
{
|
||||
GSList *path = NULL;
|
||||
const GncGUID *guid = NULL;
|
||||
const char *vendor = "Default Vendor TaxTable";
|
||||
const char *customer = "Default Customer TaxTable";
|
||||
const char *section = "Business";
|
||||
|
||||
g_return_val_if_fail (book != NULL, NULL);
|
||||
g_return_val_if_fail (type == GNC_OWNER_CUSTOMER || \
|
||||
type == GNC_OWNER_VENDOR, NULL);
|
||||
path = g_slist_prepend (path, type == GNC_OWNER_CUSTOMER ? (void*)customer : (void*)vendor);
|
||||
path = g_slist_prepend (path, (void*)section);
|
||||
|
||||
guid = qof_book_get_guid_option (book, path);
|
||||
g_return_val_if_fail (guid, NULL);
|
||||
return gncTaxTableLookup (book, guid);
|
||||
}
|
||||
|
||||
GncTaxTableList * gncTaxTableGetTables (QofBook *book)
|
||||
{
|
||||
struct _book_info *bi;
|
||||
|
@ -60,32 +60,6 @@ typedef struct _gncTaxTableClass GncTaxTableClass;
|
||||
};
|
||||
|
||||
*/
|
||||
typedef struct _gncTaxTableEntry GncTaxTableEntry;
|
||||
|
||||
typedef struct _gncAccountValue GncAccountValue;
|
||||
|
||||
#include "Account.h"
|
||||
#include "qof.h"
|
||||
#ifdef GNUCASH_MAJOR_VERSION
|
||||
#include "gncBusiness.h"
|
||||
#endif
|
||||
|
||||
#define GNC_ID_TAXTABLE "gncTaxTable"
|
||||
|
||||
/* --- type macros --- */
|
||||
#define GNC_TYPE_TAXTABLE (gnc_taxtable_get_type ())
|
||||
#define GNC_TAXTABLE(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TAXTABLE, GncTaxTable))
|
||||
#define GNC_TAXTABLE_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TAXTABLE, GncTaxTableClass))
|
||||
#define GNC_IS_TAXTABLE(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TAXTABLE))
|
||||
#define GNC_IS_TAXTABLE_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TAXTABLE))
|
||||
#define GNC_TAXTABLE_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TAXTABLE, GncTaxTableClass))
|
||||
GType gnc_taxtable_get_type(void);
|
||||
|
||||
/**
|
||||
* How to interpret the amount.
|
||||
* You can interpret it as a VALUE or a PERCENT.
|
||||
@ -104,6 +78,32 @@ typedef enum
|
||||
GNC_TAXINCLUDED_USEGLOBAL, /**< use the global setting */
|
||||
} GncTaxIncluded;
|
||||
|
||||
typedef struct _gncTaxTableEntry GncTaxTableEntry;
|
||||
|
||||
typedef struct _gncAccountValue GncAccountValue;
|
||||
|
||||
#include "Account.h"
|
||||
#include "qof.h"
|
||||
#include "gncBusiness.h"
|
||||
#include "gncOwner.h"
|
||||
|
||||
#define GNC_ID_TAXTABLE "gncTaxTable"
|
||||
|
||||
/* --- type macros --- */
|
||||
#define GNC_TYPE_TAXTABLE (gnc_taxtable_get_type ())
|
||||
#define GNC_TAXTABLE(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TAXTABLE, GncTaxTable))
|
||||
#define GNC_TAXTABLE_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TAXTABLE, GncTaxTableClass))
|
||||
#define GNC_IS_TAXTABLE(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TAXTABLE))
|
||||
#define GNC_IS_TAXTABLE_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TAXTABLE))
|
||||
#define GNC_TAXTABLE_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TAXTABLE, GncTaxTableClass))
|
||||
GType gnc_taxtable_get_type(void);
|
||||
|
||||
|
||||
const char * gncAmountTypeToString (GncAmountType type);
|
||||
gboolean gncAmountStringToType (const char *str, GncAmountType *type);
|
||||
|
||||
@ -151,6 +151,7 @@ static inline GncTaxTable *gncTaxTableLookup (const QofBook* book, const GncGUID
|
||||
}
|
||||
|
||||
GncTaxTable *gncTaxTableLookupByName (QofBook *book, const char *name);
|
||||
GncTaxTable *gncTaxTableGetDefault (QofBook *book, GncOwnerType type);
|
||||
|
||||
typedef GList GncTaxTableList;
|
||||
GncTaxTableList * gncTaxTableGetTables (QofBook *book);
|
||||
|
@ -1173,6 +1173,18 @@ qof_book_set_string_option(QofBook* book, const char* opt_name, const char* opt_
|
||||
qof_book_commit_edit(book);
|
||||
}
|
||||
|
||||
const GncGUID*
|
||||
qof_book_get_guid_option(QofBook* book, GSList* path)
|
||||
{
|
||||
g_return_val_if_fail(book != nullptr, nullptr);
|
||||
g_return_val_if_fail(path != nullptr, nullptr);
|
||||
|
||||
auto table_value = qof_book_get_option(book, path);
|
||||
if (!table_value)
|
||||
return nullptr;
|
||||
return table_value->get<GncGUID*>();
|
||||
}
|
||||
|
||||
void
|
||||
qof_book_option_frame_delete (QofBook *book, const char* opt_name)
|
||||
{
|
||||
|
@ -375,6 +375,7 @@ char *qof_book_get_counter_format (const QofBook *book,
|
||||
|
||||
const char* qof_book_get_string_option(const QofBook* book, const char* opt_name);
|
||||
void qof_book_set_string_option(QofBook* book, const char* opt_name, const char* opt_val);
|
||||
const GncGUID* qof_book_get_guid_option(QofBook* book, GSList* path);
|
||||
void qof_book_option_frame_delete (QofBook *book, const char* opt_name);
|
||||
|
||||
/** Access functions for reading and setting the used-features on this book.
|
||||
|
@ -506,7 +506,6 @@ gnucash/report/utility-reports/utility-reports.scm
|
||||
gnucash/report/utility-reports/view-column.scm
|
||||
gnucash/report/utility-reports/welcome-to-gnucash.scm
|
||||
libgnucash/app-utils/app-utils.scm
|
||||
libgnucash/app-utils/business-helpers.c
|
||||
libgnucash/app-utils/business-options.c
|
||||
libgnucash/app-utils/business-options.scm
|
||||
libgnucash/app-utils/business-prefs.scm
|
||||
|
Loading…
Reference in New Issue
Block a user