From cb9ede4b5ce97580aa8e46124d477ad6fd6d30ba Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 15 Apr 2013 20:02:43 +0000 Subject: [PATCH] Fix indirect libguile dependency in business ledger git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22908 57a11ea4-9604-0410-9ed3-97b8803252fd --- po/POTFILES.in | 7 ++- src/app-utils/Makefile.am | 2 + src/app-utils/business-helpers.c | 60 +++++++++++++++++++ src/app-utils/business-helpers.h | 35 +++++++++++ .../business-ledger/gncEntryLedgerLoad.c | 20 ++----- 5 files changed, 106 insertions(+), 18 deletions(-) create mode 100644 src/app-utils/business-helpers.c create mode 100644 src/app-utils/business-helpers.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 8f92e1026e..36ff375b15 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,5 +1,6 @@ # This is a list of files which contain translatable strings. # This file was generated by ../make-gnucash-potfiles. +src/app-utils/business-helpers.c src/app-utils/business-options.c src/app-utils/calculation/expression_parser.c src/app-utils/calculation/fin.c @@ -179,14 +180,14 @@ src/gnome/assistant-loan.c src/gnome/assistant-stock-split.c src/gnome/dialog-commodities.c src/gnome/dialog-fincalc.c -src/gnome/dialog-find-transactions.c src/gnome/dialog-find-transactions2.c +src/gnome/dialog-find-transactions.c src/gnome/dialog-lot-viewer.c src/gnome/dialog-new-user.c src/gnome/dialog-price-edit-db.c src/gnome/dialog-price-editor.c -src/gnome/dialog-print-check.c src/gnome/dialog-print-check2.c +src/gnome/dialog-print-check.c src/gnome/dialog-progress.c src/gnome/dialog-sx-editor.c src/gnome/dialog-sx-from-trans.c @@ -351,8 +352,8 @@ src/gnome-utils/schemas/apps_gnucash_history.schemas.in src/gnome-utils/search-param.c src/gnome-utils/window-main-summarybar.c src/gnome/window-autoclear.c -src/gnome/window-reconcile.c src/gnome/window-reconcile2.c +src/gnome/window-reconcile.c src/html/gnc-html.c src/html/gnc-html-factory.c src/html/gnc-html-history.c diff --git a/src/app-utils/Makefile.am b/src/app-utils/Makefile.am index 015e26a666..9e1153a407 100644 --- a/src/app-utils/Makefile.am +++ b/src/app-utils/Makefile.am @@ -39,6 +39,7 @@ libgncmod_app_utils_la_SOURCES = \ calculation/expression_parser.c \ calculation/fin.c \ swig-app-utils-guile.c \ + business-helpers.c \ business-options.c \ QuickFill.c \ file-utils.c \ @@ -62,6 +63,7 @@ libgncmod_app_utils_la_SOURCES = \ gncincludedir = ${GNC_INCLUDE_DIR} gncinclude_HEADERS = \ QuickFill.h \ + business-helpers.h \ business-options.h \ file-utils.h \ gfec.h \ diff --git a/src/app-utils/business-helpers.c b/src/app-utils/business-helpers.c new file mode 100644 index 0000000000..e6e9bb1831 --- /dev/null +++ b/src/app-utils/business-helpers.c @@ -0,0 +1,60 @@ +/* + * business-options.c -- non-GUI helper functions for business features + * + * Written By: Derek Atkins + * 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; + GNCOptionDB *odb; + + odb = gnc_option_db_new_for_type (GNC_ID_BOOK); + gnc_option_db_load_from_kvp (odb, qof_book_get_slots (book)); + + 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; +} diff --git a/src/app-utils/business-helpers.h b/src/app-utils/business-helpers.h new file mode 100644 index 0000000000..25032d7173 --- /dev/null +++ b/src/app-utils/business-helpers.h @@ -0,0 +1,35 @@ +/* + * business-helpers.h -- non-GUI helper functions for business features + * + * Written By: Derek Atkins + * 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 + */ + +#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_ */ diff --git a/src/business/business-ledger/gncEntryLedgerLoad.c b/src/business/business-ledger/gncEntryLedgerLoad.c index b6f9ba11f4..e7f8eb778a 100644 --- a/src/business/business-ledger/gncEntryLedgerLoad.c +++ b/src/business/business-ledger/gncEntryLedgerLoad.c @@ -34,7 +34,7 @@ #include "gnc-ui-util.h" #include "recncell.h" -#include "business-options.h" +#include "business-helpers.h" #include "gncEntry.h" #include "gncEntryLedger.h" @@ -373,7 +373,6 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list) GncTaxIncluded taxincluded_p = GNC_TAXINCLUDED_USEGLOBAL; gboolean taxincluded = FALSE; gnc_numeric discount = gnc_numeric_zero (); - GNCOptionDB *odb; /* Determine the TaxIncluded and Discount values */ switch (gncOwnerGetType (owner)) @@ -411,26 +410,19 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list) } /* Compute the proper taxtable */ - odb = gnc_option_db_new_for_type (GNC_ID_BOOK); - gnc_option_db_load_from_kvp (odb, qof_book_get_slots (ledger->book)); - switch (gncOwnerGetType (owner)) { case GNC_OWNER_CUSTOMER: - table = gnc_option_db_lookup_taxtable_option (odb, - "Business", - "Default Customer TaxTable", - NULL); + table = gnc_business_get_default_tax_table (ledger->book, + GNC_OWNER_CUSTOMER); if (gncCustomerGetTaxTableOverride (owner->owner.customer)) table = gncCustomerGetTaxTable (owner->owner.customer); break; case GNC_OWNER_VENDOR: - table = gnc_option_db_lookup_taxtable_option (odb, - "Business", - "Default Vendor TaxTable", - NULL); + table = gnc_business_get_default_tax_table (ledger->book, + GNC_OWNER_VENDOR); if (gncVendorGetTaxTableOverride (owner->owner.vendor)) table = gncVendorGetTaxTable (owner->owner.vendor); @@ -440,8 +432,6 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list) break; } - gnc_option_db_destroy (odb); - if (ledger->is_cust_doc) { gncEntrySetInvTaxTable (blank_entry, table);