mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix bug #91413 -- Add TaxTable defaults to Customers and Vendors
* business-core/gncCustomer.[ch] -- add API for TaxTable and TaxTableOverride * business-core/gncVendor.[ch] -- add API for TaxTable and TaxTableOverride * business-core/file/gnc-customer-xml-v2.c -- store TaxTable and TTOverride * business-core/file/gnc-vendor-xml-v2.c -- store TaxTable and TTOverride * business-gnome/dialog-customer.c -- display/choose TaxTable and TTOverride * business-gnome/dialog-vendor.c -- display/choose TaxTable and TTOverride * business-gnome/glade/customer.glade -- add TaxTable Menu and Override button * business-gnome/glade/vendor.glade -- add TaxTable Menu and Override button * business-ledger/gncEntryLedger.c -- set traverse_to_new = TRUE when you create a new ledger. * business-ledger/gncEntryLedgerLoad.c -- don't load the ledger the first time through (e.g. when there is no invoice and no entries). Pull in the default TaxTable, TaxIncluded, and Discount flags. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7223 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
62145d4bd5
commit
78103fb7ae
17
ChangeLog
17
ChangeLog
@ -1,3 +1,20 @@
|
||||
2002-09-16 Derek Atkins <derek@ihtfp.com>
|
||||
Fix bug #91413 -- Add TaxTable defaults to Customers and Vendors
|
||||
|
||||
* business-core/gncCustomer.[ch] -- add API for TaxTable and TaxTableOverride
|
||||
* business-core/gncVendor.[ch] -- add API for TaxTable and TaxTableOverride
|
||||
* business-core/file/gnc-customer-xml-v2.c -- store TaxTable and TTOverride
|
||||
* business-core/file/gnc-vendor-xml-v2.c -- store TaxTable and TTOverride
|
||||
* business-gnome/dialog-customer.c -- display/choose TaxTable and TTOverride
|
||||
* business-gnome/dialog-vendor.c -- display/choose TaxTable and TTOverride
|
||||
* business-gnome/glade/customer.glade -- add TaxTable Menu and Override button
|
||||
* business-gnome/glade/vendor.glade -- add TaxTable Menu and Override button
|
||||
* business-ledger/gncEntryLedger.c -- set traverse_to_new = TRUE when
|
||||
you create a new ledger.
|
||||
* business-ledger/gncEntryLedgerLoad.c -- don't load the ledger the
|
||||
first time through (e.g. when there is no invoice and no entries).
|
||||
Pull in the default TaxTable, TaxIncluded, and Discount flags.
|
||||
|
||||
2002-09-16 David Hampton <hampton@employees.org>
|
||||
|
||||
* src/business/business-gnome/search-owner.c:
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "gncBillTermP.h"
|
||||
#include "gncCustomerP.h"
|
||||
#include "gncTaxTableP.h"
|
||||
#include "gnc-customer-xml-v2.h"
|
||||
#include "gnc-address-xml-v2.h"
|
||||
#include "gnc-engine-util.h"
|
||||
@ -69,6 +70,8 @@ const gchar *customer_version_string = "2.0.0";
|
||||
#define cust_discount_string "cust:discount"
|
||||
#define cust_credit_string "cust:credit"
|
||||
#define cust_commodity_string "cust:commodity"
|
||||
#define cust_taxtable_string "cust:taxtable"
|
||||
#define cust_taxtableoverride_string "cust:use-tt"
|
||||
|
||||
static void
|
||||
maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
|
||||
@ -83,6 +86,7 @@ customer_dom_tree_create (GncCustomer *cust)
|
||||
xmlNodePtr ret;
|
||||
gnc_numeric num;
|
||||
GncBillTerm *term;
|
||||
GncTaxTable *taxtable;
|
||||
|
||||
ret = xmlNewNode(NULL, gnc_customer_string);
|
||||
xmlSetProp(ret, "version", customer_version_string);
|
||||
@ -127,6 +131,13 @@ customer_dom_tree_create (GncCustomer *cust)
|
||||
commodity_ref_to_dom_tree(cust_commodity_string,
|
||||
gncCustomerGetCommodity (cust)));
|
||||
|
||||
xmlAddChild (ret, int_to_dom_tree (cust_taxtableoverride_string,
|
||||
gncCustomerGetTaxTableOverride (cust)));
|
||||
taxtable = gncCustomerGetTaxTable (cust);
|
||||
if (taxtable)
|
||||
xmlAddChild (ret, guid_to_dom_tree (cust_taxtable_string,
|
||||
gncTaxTableGetGUID (taxtable)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -152,6 +163,20 @@ set_string(xmlNodePtr node, GncCustomer* cust,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
set_boolean(xmlNodePtr node, GncCustomer* cust,
|
||||
void (*func)(GncCustomer* cust, gboolean b))
|
||||
{
|
||||
gint64 val;
|
||||
gboolean ret;
|
||||
|
||||
ret = dom_tree_to_integer(node, &val);
|
||||
if (ret)
|
||||
func(cust, (gboolean)val);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
customer_name_handler (xmlNodePtr node, gpointer cust_pdata)
|
||||
{
|
||||
@ -262,14 +287,7 @@ static gboolean
|
||||
customer_active_handler (xmlNodePtr node, gpointer cust_pdata)
|
||||
{
|
||||
struct customer_pdata *pdata = cust_pdata;
|
||||
gint64 val;
|
||||
gboolean ret;
|
||||
|
||||
ret = dom_tree_to_integer(node, &val);
|
||||
if (ret)
|
||||
gncCustomerSetActive(pdata->customer, (gboolean)val);
|
||||
|
||||
return ret;
|
||||
return set_boolean (node, pdata->customer, gncCustomerSetActive);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -316,6 +334,34 @@ customer_commodity_handler (xmlNodePtr node, gpointer customer_pdata)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
customer_taxtable_handler (xmlNodePtr node, gpointer cust_pdata)
|
||||
{
|
||||
struct customer_pdata *pdata = cust_pdata;
|
||||
GUID *guid;
|
||||
GncTaxTable *taxtable;
|
||||
|
||||
guid = dom_tree_to_guid (node);
|
||||
g_return_val_if_fail (guid, FALSE);
|
||||
taxtable = gncTaxTableLookup (pdata->book, guid);
|
||||
if (!taxtable) {
|
||||
taxtable = gncTaxTableCreate (pdata->book);
|
||||
gncTaxTableSetGUID (taxtable, guid);
|
||||
} else
|
||||
gncTaxTableDecRef (taxtable);
|
||||
|
||||
gncCustomerSetTaxTable (pdata->customer, taxtable);
|
||||
g_free(guid);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
customer_taxtableoverride_handler (xmlNodePtr node, gpointer cust_pdata)
|
||||
{
|
||||
struct customer_pdata *pdata = cust_pdata;
|
||||
return set_boolean (node, pdata->customer, gncCustomerSetTaxTableOverride);
|
||||
}
|
||||
|
||||
static struct dom_tree_handler customer_handlers_v2[] = {
|
||||
{ cust_name_string, customer_name_handler, 1, 0 },
|
||||
{ cust_guid_string, customer_guid_handler, 1, 0 },
|
||||
@ -329,6 +375,8 @@ static struct dom_tree_handler customer_handlers_v2[] = {
|
||||
{ cust_discount_string, customer_discount_handler, 1, 0 },
|
||||
{ cust_credit_string, customer_credit_handler, 1, 0 },
|
||||
{ cust_commodity_string, customer_commodity_handler, 1, 0 },
|
||||
{ cust_taxtable_string, customer_taxtable_handler, 0, 0 },
|
||||
{ cust_taxtableoverride_string, customer_taxtableoverride_handler, 0, 0 },
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "gncBillTermP.h"
|
||||
#include "gncVendorP.h"
|
||||
#include "gncTaxTableP.h"
|
||||
#include "gnc-vendor-xml-v2.h"
|
||||
#include "gnc-address-xml-v2.h"
|
||||
#include "gnc-engine-util.h"
|
||||
@ -66,6 +67,8 @@ const gchar *vendor_version_string = "2.0.0";
|
||||
#define vendor_taxincluded_string "vendor:taxincluded"
|
||||
#define vendor_active_string "vendor:active"
|
||||
#define vendor_commodity_string "vendor:commodity"
|
||||
#define vendor_taxtable_string "vendor:taxtable"
|
||||
#define vendor_taxtableoverride_string "vendor:use-tt"
|
||||
|
||||
static void
|
||||
maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
|
||||
@ -79,6 +82,7 @@ vendor_dom_tree_create (GncVendor *vendor)
|
||||
{
|
||||
xmlNodePtr ret;
|
||||
GncBillTerm *term;
|
||||
GncTaxTable *taxtable;
|
||||
|
||||
ret = xmlNewNode(NULL, gnc_vendor_string);
|
||||
xmlSetProp(ret, "version", vendor_version_string);
|
||||
@ -114,6 +118,13 @@ vendor_dom_tree_create (GncVendor *vendor)
|
||||
commodity_ref_to_dom_tree(vendor_commodity_string,
|
||||
gncVendorGetCommodity (vendor)));
|
||||
|
||||
xmlAddChild (ret, int_to_dom_tree (vendor_taxtableoverride_string,
|
||||
gncVendorGetTaxTableOverride (vendor)));
|
||||
taxtable = gncVendorGetTaxTable (vendor);
|
||||
if (taxtable)
|
||||
xmlAddChild (ret, guid_to_dom_tree (vendor_taxtable_string,
|
||||
gncTaxTableGetGUID (taxtable)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -139,6 +150,20 @@ set_string(xmlNodePtr node, GncVendor* vendor,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
set_boolean(xmlNodePtr node, GncVendor* vendor,
|
||||
void (*func)(GncVendor* vendor, gboolean b))
|
||||
{
|
||||
gint64 val;
|
||||
gboolean ret;
|
||||
|
||||
ret = dom_tree_to_integer(node, &val);
|
||||
if (ret)
|
||||
func(vendor, (gboolean)val);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
vendor_name_handler (xmlNodePtr node, gpointer vendor_pdata)
|
||||
{
|
||||
@ -239,14 +264,7 @@ static gboolean
|
||||
vendor_active_handler (xmlNodePtr node, gpointer vendor_pdata)
|
||||
{
|
||||
struct vendor_pdata *pdata = vendor_pdata;
|
||||
gint64 val;
|
||||
gboolean ret;
|
||||
|
||||
ret = dom_tree_to_integer(node, &val);
|
||||
if (ret)
|
||||
gncVendorSetActive(pdata->vendor, (gboolean)val);
|
||||
|
||||
return ret;
|
||||
set_boolean (node, pdata->vendor, gncVendorSetActive);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -263,6 +281,34 @@ vendor_commodity_handler (xmlNodePtr node, gpointer vendor_pdata)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
vendor_taxtable_handler (xmlNodePtr node, gpointer vendor_pdata)
|
||||
{
|
||||
struct vendor_pdata *pdata = vendor_pdata;
|
||||
GUID *guid;
|
||||
GncTaxTable *taxtable;
|
||||
|
||||
guid = dom_tree_to_guid (node);
|
||||
g_return_val_if_fail (guid, FALSE);
|
||||
taxtable = gncTaxTableLookup (pdata->book, guid);
|
||||
if (!taxtable) {
|
||||
taxtable = gncTaxTableCreate (pdata->book);
|
||||
gncTaxTableSetGUID (taxtable, guid);
|
||||
} else
|
||||
gncTaxTableDecRef (taxtable);
|
||||
|
||||
gncVendorSetTaxTable (pdata->vendor, taxtable);
|
||||
g_free(guid);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
vendor_taxtableoverride_handler (xmlNodePtr node, gpointer vendor_pdata)
|
||||
{
|
||||
struct vendor_pdata *pdata = vendor_pdata;
|
||||
return set_boolean (node, pdata->vendor, gncVendorSetTaxTableOverride);
|
||||
}
|
||||
|
||||
static struct dom_tree_handler vendor_handlers_v2[] = {
|
||||
{ vendor_name_string, vendor_name_handler, 1, 0 },
|
||||
{ vendor_guid_string, vendor_guid_handler, 1, 0 },
|
||||
@ -273,6 +319,8 @@ static struct dom_tree_handler vendor_handlers_v2[] = {
|
||||
{ vendor_taxincluded_string, vendor_taxincluded_handler, 1, 0 },
|
||||
{ vendor_active_string, vendor_active_handler, 1, 0 },
|
||||
{ vendor_commodity_string, vendor_commodity_handler, 1, 0 },
|
||||
{ vendor_taxtable_string, vendor_taxtable_handler, 0, 0 },
|
||||
{ vendor_taxtableoverride_string, vendor_taxtableoverride_handler, 0, 0 },
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -38,6 +38,9 @@ struct _gncCustomer {
|
||||
GncTaxIncluded taxincluded;
|
||||
gboolean active;
|
||||
GList * jobs;
|
||||
|
||||
GncTaxTable* taxtable;
|
||||
gboolean taxtable_override;
|
||||
gboolean dirty;
|
||||
};
|
||||
|
||||
@ -203,6 +206,26 @@ void gncCustomerSetCommodity (GncCustomer *cust, gnc_commodity *com)
|
||||
mark_customer (cust);
|
||||
}
|
||||
|
||||
void gncCustomerSetTaxTableOverride (GncCustomer *customer, gboolean override)
|
||||
{
|
||||
if (!customer) return;
|
||||
if (customer->taxtable_override == override) return;
|
||||
customer->taxtable_override = override;
|
||||
mark_customer (customer);
|
||||
}
|
||||
|
||||
void gncCustomerSetTaxTable (GncCustomer *customer, GncTaxTable *table)
|
||||
{
|
||||
if (!customer) return;
|
||||
if (customer->taxtable == table) return;
|
||||
if (customer->taxtable)
|
||||
gncTaxTableDecRef (customer->taxtable);
|
||||
if (table)
|
||||
gncTaxTableIncRef (table);
|
||||
customer->taxtable = table;
|
||||
mark_customer (customer);
|
||||
}
|
||||
|
||||
/* Note that JobList changes do not affect the "dirtiness" of the customer */
|
||||
void gncCustomerAddJob (GncCustomer *cust, GncJob *job)
|
||||
{
|
||||
@ -325,6 +348,18 @@ gnc_numeric gncCustomerGetCredit (GncCustomer *cust)
|
||||
return cust->credit;
|
||||
}
|
||||
|
||||
gboolean gncCustomerGetTaxTableOverride (GncCustomer *customer)
|
||||
{
|
||||
if (!customer) return FALSE;
|
||||
return customer->taxtable_override;
|
||||
}
|
||||
|
||||
GncTaxTable* gncCustomerGetTaxTable (GncCustomer *customer)
|
||||
{
|
||||
if (!customer) return NULL;
|
||||
return customer->taxtable;
|
||||
}
|
||||
|
||||
GList * gncCustomerGetJoblist (GncCustomer *cust, gboolean show_all)
|
||||
{
|
||||
if (!cust) return NULL;
|
||||
|
@ -36,6 +36,9 @@ void gncCustomerSetDiscount (GncCustomer *customer, gnc_numeric discount);
|
||||
void gncCustomerSetCredit (GncCustomer *customer, gnc_numeric credit);
|
||||
void gncCustomerSetCommodity (GncCustomer *customer, gnc_commodity *com);
|
||||
|
||||
void gncCustomerSetTaxTableOverride (GncCustomer *customer, gboolean override);
|
||||
void gncCustomerSetTaxTable (GncCustomer *customer, GncTaxTable *table);
|
||||
|
||||
void gncCustomerAddJob (GncCustomer *customer, GncJob *job);
|
||||
void gncCustomerRemoveJob (GncCustomer *customer, GncJob *job);
|
||||
|
||||
@ -57,6 +60,9 @@ gnc_numeric gncCustomerGetDiscount (GncCustomer *customer);
|
||||
gnc_numeric gncCustomerGetCredit (GncCustomer *customer);
|
||||
gnc_commodity * gncCustomerGetCommodity (GncCustomer *customer);
|
||||
|
||||
gboolean gncCustomerGetTaxTableOverride (GncCustomer *customer);
|
||||
GncTaxTable* gncCustomerGetTaxTable (GncCustomer *customer);
|
||||
|
||||
GList * gncCustomerGetJoblist (GncCustomer *customer, gboolean show_all);
|
||||
|
||||
GUID gncCustomerRetGUID (GncCustomer *customer);
|
||||
|
@ -34,6 +34,8 @@ struct _gncVendor {
|
||||
GncTaxIncluded taxincluded;
|
||||
gboolean active;
|
||||
GList * jobs;
|
||||
GncTaxTable* taxtable;
|
||||
gboolean taxtable_override;
|
||||
gboolean dirty;
|
||||
};
|
||||
|
||||
@ -180,6 +182,26 @@ void gncVendorSetActive (GncVendor *vendor, gboolean active)
|
||||
mark_vendor (vendor);
|
||||
}
|
||||
|
||||
void gncVendorSetTaxTableOverride (GncVendor *vendor, gboolean override)
|
||||
{
|
||||
if (!vendor) return;
|
||||
if (vendor->taxtable_override == override) return;
|
||||
vendor->taxtable_override = override;
|
||||
mark_vendor (vendor);
|
||||
}
|
||||
|
||||
void gncVendorSetTaxTable (GncVendor *vendor, GncTaxTable *table)
|
||||
{
|
||||
if (!vendor) return;
|
||||
if (vendor->taxtable == table) return;
|
||||
if (vendor->taxtable)
|
||||
gncTaxTableDecRef (vendor->taxtable);
|
||||
if (table)
|
||||
gncTaxTableIncRef (table);
|
||||
vendor->taxtable = table;
|
||||
mark_vendor (vendor);
|
||||
}
|
||||
|
||||
/* Get Functions */
|
||||
|
||||
GNCBook * gncVendorGetBook (GncVendor *vendor)
|
||||
@ -242,6 +264,18 @@ gboolean gncVendorGetActive (GncVendor *vendor)
|
||||
return vendor->active;
|
||||
}
|
||||
|
||||
gboolean gncVendorGetTaxTableOverride (GncVendor *vendor)
|
||||
{
|
||||
if (!vendor) return FALSE;
|
||||
return vendor->taxtable_override;
|
||||
}
|
||||
|
||||
GncTaxTable* gncVendorGetTaxTable (GncVendor *vendor)
|
||||
{
|
||||
if (!vendor) return NULL;
|
||||
return vendor->taxtable;
|
||||
}
|
||||
|
||||
/* Note that JobList changes do not affect the "dirtiness" of the vendor */
|
||||
void gncVendorAddJob (GncVendor *vendor, GncJob *job)
|
||||
{
|
||||
|
@ -32,6 +32,9 @@ void gncVendorSetTaxIncluded (GncVendor *vendor, GncTaxIncluded taxincl);
|
||||
void gncVendorSetCommodity (GncVendor *vendor, gnc_commodity *com);
|
||||
void gncVendorSetActive (GncVendor *vendor, gboolean active);
|
||||
|
||||
void gncVendorSetTaxTableOverride (GncVendor *vendor, gboolean override);
|
||||
void gncVendorSetTaxTable (GncVendor *vendor, GncTaxTable *table);
|
||||
|
||||
void gncVendorAddJob (GncVendor *vendor, GncJob *job);
|
||||
void gncVendorRemoveJob (GncVendor *vendor, GncJob *job);
|
||||
|
||||
@ -50,6 +53,9 @@ GncTaxIncluded gncVendorGetTaxIncluded (GncVendor *vendor);
|
||||
gnc_commodity * gncVendorGetCommodity (GncVendor *vendor);
|
||||
gboolean gncVendorGetActive (GncVendor *vendor);
|
||||
|
||||
gboolean gncVendorGetTaxTableOverride (GncVendor *vendor);
|
||||
GncTaxTable* gncVendorGetTaxTable (GncVendor *vendor);
|
||||
|
||||
GList * gncVendorGetJoblist (GncVendor *vendor, gboolean show_all);
|
||||
|
||||
GUID gncVendorRetGUID (GncVendor *vendor);
|
||||
|
@ -78,6 +78,9 @@ struct _customer_window {
|
||||
GtkWidget * taxincluded_menu;
|
||||
GtkWidget * notes_text;
|
||||
|
||||
GtkWidget * taxtable_check;
|
||||
GtkWidget * taxtable_menu;
|
||||
|
||||
GncTaxIncluded taxincluded;
|
||||
GncBillTerm * terms;
|
||||
CustomerDialogType dialog_type;
|
||||
@ -86,8 +89,21 @@ struct _customer_window {
|
||||
GNCBook * book;
|
||||
GncCustomer * created_customer;
|
||||
|
||||
GncTaxTable * taxtable;
|
||||
};
|
||||
|
||||
static void
|
||||
gnc_customer_taxtable_check_cb (GtkToggleButton *togglebutton,
|
||||
gpointer user_data)
|
||||
{
|
||||
CustomerWindow *cw = user_data;
|
||||
|
||||
if (gtk_toggle_button_get_active (togglebutton))
|
||||
gtk_widget_set_sensitive (cw->taxtable_menu, TRUE);
|
||||
else
|
||||
gtk_widget_set_sensitive (cw->taxtable_menu, FALSE);
|
||||
}
|
||||
|
||||
static GncCustomer *
|
||||
cw_get_customer (CustomerWindow *cw)
|
||||
{
|
||||
@ -158,6 +174,10 @@ static void gnc_ui_to_customer (CustomerWindow *cw, GncCustomer *cust)
|
||||
gncCustomerSetCredit (cust, gnc_amount_edit_get_amount
|
||||
(GNC_AMOUNT_EDIT (cw->credit_amount)));
|
||||
|
||||
gncCustomerSetTaxTableOverride
|
||||
(cust, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cw->taxtable_check)));
|
||||
gncCustomerSetTaxTable (cust, cw->taxtable);
|
||||
|
||||
gncCustomerCommitEdit (cust);
|
||||
gnc_resume_gui_refresh ();
|
||||
}
|
||||
@ -425,6 +445,9 @@ gnc_customer_new_window (GNCBook *bookp, GncCustomer *cust)
|
||||
|
||||
cw->terms_menu = glade_xml_get_widget (xml, "terms_menu");
|
||||
|
||||
cw->taxtable_check = glade_xml_get_widget (xml, "taxtable_button");
|
||||
cw->taxtable_menu = glade_xml_get_widget (xml, "taxtable_menu");
|
||||
|
||||
/* DISCOUNT: Percentage Value */
|
||||
edit = gnc_amount_edit_new();
|
||||
gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
|
||||
@ -497,6 +520,9 @@ gnc_customer_new_window (GNCBook *bookp, GncCustomer *cust)
|
||||
gtk_signal_connect(GTK_OBJECT (cw->company_entry), "changed",
|
||||
GTK_SIGNAL_FUNC(gnc_customer_name_changed_cb), cw);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT (cw->taxtable_check), "toggled",
|
||||
GTK_SIGNAL_FUNC(gnc_customer_taxtable_check_cb), cw);
|
||||
|
||||
/* Setup initial values */
|
||||
if (cust != NULL) {
|
||||
GncAddress *addr, *shipaddr;
|
||||
@ -572,6 +598,11 @@ gnc_customer_new_window (GNCBook *bookp, GncCustomer *cust)
|
||||
gnc_ui_taxincluded_optionmenu (cw->taxincluded_menu, &cw->taxincluded);
|
||||
gnc_ui_billterms_optionmenu (cw->terms_menu, bookp, TRUE, &cw->terms);
|
||||
|
||||
cw->taxtable = gncCustomerGetTaxTable (cust);
|
||||
gnc_ui_taxtables_optionmenu (cw->taxtable_menu, bookp, TRUE, &cw->taxtable);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw->taxtable_check),
|
||||
gncCustomerGetTaxTableOverride (cust));
|
||||
gnc_customer_taxtable_check_cb (cw->taxtable_check, cw);
|
||||
|
||||
/* Set the Discount, and Credit amounts */
|
||||
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->discount_amount),
|
||||
|
@ -65,6 +65,9 @@ struct _vendor_window {
|
||||
GtkWidget * taxincluded_menu;
|
||||
GtkWidget * notes_text;
|
||||
|
||||
GtkWidget * taxtable_check;
|
||||
GtkWidget * taxtable_menu;
|
||||
|
||||
GncTaxIncluded taxincluded;
|
||||
GncBillTerm * terms;
|
||||
VendorDialogType dialog_type;
|
||||
@ -73,8 +76,21 @@ struct _vendor_window {
|
||||
GNCBook * book;
|
||||
GncVendor * created_vendor;
|
||||
|
||||
GncTaxTable * taxtable;
|
||||
};
|
||||
|
||||
static void
|
||||
gnc_vendor_taxtable_check_cb (GtkToggleButton *togglebutton,
|
||||
gpointer user_data)
|
||||
{
|
||||
VendorWindow *vw = user_data;
|
||||
|
||||
if (gtk_toggle_button_get_active (togglebutton))
|
||||
gtk_widget_set_sensitive (vw->taxtable_menu, TRUE);
|
||||
else
|
||||
gtk_widget_set_sensitive (vw->taxtable_menu, FALSE);
|
||||
}
|
||||
|
||||
static GncVendor *
|
||||
vw_get_vendor (VendorWindow *vw)
|
||||
{
|
||||
@ -121,6 +137,10 @@ static void gnc_ui_to_vendor (VendorWindow *vw, GncVendor *vendor)
|
||||
(GTK_EDITABLE (vw->notes_text), 0, -1));
|
||||
gncVendorSetTerms (vendor, vw->terms);
|
||||
|
||||
gncVendorSetTaxTableOverride
|
||||
(vendor, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (vw->taxtable_check)));
|
||||
gncVendorSetTaxTable (vendor, vw->taxtable);
|
||||
|
||||
gncVendorCommitEdit (vendor);
|
||||
gnc_resume_gui_refresh ();
|
||||
}
|
||||
@ -337,6 +357,9 @@ gnc_vendor_new_window (GNCBook *bookp, GncVendor *vendor)
|
||||
vw->notes_text = glade_xml_get_widget (xml, "notes_text");
|
||||
vw->terms_menu = glade_xml_get_widget (xml, "terms_menu");
|
||||
|
||||
vw->taxtable_check = glade_xml_get_widget (xml, "taxtable_button");
|
||||
vw->taxtable_menu = glade_xml_get_widget (xml, "taxtable_menu");
|
||||
|
||||
/* Setup Dialog for Editing */
|
||||
gnome_dialog_set_default (vwd, 0);
|
||||
|
||||
@ -373,6 +396,9 @@ gnc_vendor_new_window (GNCBook *bookp, GncVendor *vendor)
|
||||
gtk_signal_connect(GTK_OBJECT (vw->company_entry), "changed",
|
||||
GTK_SIGNAL_FUNC(gnc_vendor_name_changed_cb), vw);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT (vw->taxtable_check), "toggled",
|
||||
GTK_SIGNAL_FUNC(gnc_vendor_taxtable_check_cb), vw);
|
||||
|
||||
/* Setup initial values */
|
||||
if (vendor != NULL) {
|
||||
GncAddress *addr;
|
||||
@ -438,6 +464,11 @@ gnc_vendor_new_window (GNCBook *bookp, GncVendor *vendor)
|
||||
gnc_ui_taxincluded_optionmenu (vw->taxincluded_menu, &vw->taxincluded);
|
||||
gnc_ui_billterms_optionmenu (vw->terms_menu, bookp, TRUE, &vw->terms);
|
||||
|
||||
vw->taxtable = gncVendorGetTaxTable (vendor);
|
||||
gnc_ui_taxtables_optionmenu (vw->taxtable_menu, bookp, TRUE, &vw->taxtable);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vw->taxtable_check),
|
||||
gncVendorGetTaxTableOverride (vendor));
|
||||
gnc_vendor_taxtable_check_cb (vw->taxtable_check, vw);
|
||||
|
||||
gnc_gui_component_watch_entity_type (vw->component_id,
|
||||
GNC_VENDOR_MODULE_NAME,
|
||||
|
@ -703,6 +703,23 @@
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label35</name>
|
||||
<label>Tax Table: </label>
|
||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@ -776,6 +793,48 @@
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>hbox7</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkCheckButton</class>
|
||||
<name>taxtable_button</name>
|
||||
<tooltip>Override the global Tax Table?</tooltip>
|
||||
<can_focus>True</can_focus>
|
||||
<label></label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkOptionMenu</class>
|
||||
<name>taxtable_menu</name>
|
||||
<tooltip>What Tax Table should be applied to this customer?</tooltip>
|
||||
<can_focus>True</can_focus>
|
||||
<items>(taxtables)
|
||||
</items>
|
||||
<initial_choice>0</initial_choice>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -670,6 +670,23 @@
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label35</name>
|
||||
<label>Tax Table:</label>
|
||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@ -711,6 +728,48 @@
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>hbox7</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkCheckButton</class>
|
||||
<name>taxtable_button</name>
|
||||
<tooltip>Override the global Tax Table?</tooltip>
|
||||
<can_focus>True</can_focus>
|
||||
<label></label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkOptionMenu</class>
|
||||
<name>taxtable_menu</name>
|
||||
<tooltip>What Tax Table should be applied to this vendor?</tooltip>
|
||||
<can_focus>True</can_focus>
|
||||
<items>(taxtables)
|
||||
</items>
|
||||
<initial_choice>0</initial_choice>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -208,6 +208,7 @@ GncEntryLedger * gnc_entry_ledger_new (GNCBook *book, GncEntryLedgerType type)
|
||||
ledger = g_new0 (GncEntryLedger, 1);
|
||||
ledger->type = type;
|
||||
ledger->book = book;
|
||||
ledger->traverse_to_new = TRUE;
|
||||
|
||||
/* Orders and Invoices are "invoices" for lookups */
|
||||
switch (type) {
|
||||
|
@ -191,7 +191,10 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
|
||||
|
||||
blank_entry = gnc_entry_ledger_get_blank_entry (ledger);
|
||||
|
||||
if (blank_entry == NULL) {
|
||||
if (blank_entry == NULL && ledger->invoice == NULL && entry_list == NULL)
|
||||
return;
|
||||
|
||||
if (blank_entry == NULL && ledger->invoice) {
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
case GNCENTRY_INVOICE_ENTRY:
|
||||
@ -200,13 +203,14 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
|
||||
gncEntrySetDate (blank_entry, ledger->last_date_entered);
|
||||
ledger->blank_entry_guid = *gncEntryGetGUID (blank_entry);
|
||||
|
||||
if (ledger->type == GNCENTRY_INVOICE_ENTRY) {
|
||||
{
|
||||
GncOwner *owner = gncInvoiceGetOwner (ledger->invoice);
|
||||
GncTaxTable *table = NULL;
|
||||
GncTaxTable *table;
|
||||
GncTaxIncluded taxincluded_p = GNC_TAXINCLUDED_USEGLOBAL;
|
||||
gboolean taxincluded = FALSE;
|
||||
gnc_numeric discount = gnc_numeric_zero ();
|
||||
|
||||
/* Determine the TaxIncluded and Discount values */
|
||||
owner = gncOwnerGetEndOwner (owner);
|
||||
switch (gncOwnerGetType (owner)) {
|
||||
case GNC_OWNER_CUSTOMER:
|
||||
@ -219,8 +223,6 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
|
||||
default:
|
||||
}
|
||||
|
||||
/* XXX: Get the default tax-table */
|
||||
|
||||
/* Compute the default taxincluded */
|
||||
switch (taxincluded_p) {
|
||||
case GNC_TAXINCLUDED_YES:
|
||||
@ -237,6 +239,22 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
|
||||
break;
|
||||
}
|
||||
|
||||
/* XXX: Get the default tax-table */
|
||||
table = NULL;
|
||||
|
||||
/* Maybe override the global taxtable */
|
||||
switch (gncOwnerGetType (owner)) {
|
||||
case GNC_OWNER_CUSTOMER:
|
||||
if (gncCustomerGetTaxTableOverride (owner->owner.customer))
|
||||
table = gncCustomerGetTaxTable (owner->owner.customer);
|
||||
break;
|
||||
case GNC_OWNER_VENDOR:
|
||||
if (gncVendorGetTaxTableOverride (owner->owner.vendor))
|
||||
table = gncVendorGetTaxTable (owner->owner.vendor);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
if (ledger->is_invoice) {
|
||||
gncEntrySetInvTaxTable (blank_entry, table);
|
||||
gncEntrySetInvTaxIncluded (blank_entry, taxincluded);
|
||||
|
Loading…
Reference in New Issue
Block a user