Customer and Vendors can set TaxIncluded to Yes, No, and Use Global,

which will allow you to override the global setting or just use it..
(Default is Use Global).

Grab the default TaxIncluded settings in the Entry Ledger.

Fix a couple compiler warnings.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7011 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins
2002-06-24 04:59:04 +00:00
parent f6e6c69101
commit 7bebb2eae9
15 changed files with 149 additions and 66 deletions

View File

@@ -245,8 +245,10 @@ customer_taxincluded_handler (xmlNodePtr node, gpointer cust_pdata)
gboolean ret;
ret = dom_tree_to_integer(node, &val);
if (ret)
gncCustomerSetTaxIncluded(pdata->customer, (gboolean)val);
if (ret) {
if (!val) val = GNC_TAXINCLUDED_USEGLOBAL;
gncCustomerSetTaxIncluded(pdata->customer, (GncTaxIncluded)val);
}
return ret;
}

View File

@@ -222,8 +222,10 @@ vendor_taxincluded_handler (xmlNodePtr node, gpointer vendor_pdata)
gboolean ret;
ret = dom_tree_to_integer(node, &val);
if (ret)
gncVendorSetTaxIncluded(pdata->vendor, (gboolean)val);
if (ret) {
if (!val) val = GNC_TAXINCLUDED_USEGLOBAL;
gncVendorSetTaxIncluded(pdata->vendor, (GncTaxIncluded)val);
}
return ret;
}

View File

@@ -35,7 +35,7 @@ struct _gncCustomer {
gnc_commodity * commodity;
gnc_numeric discount;
gnc_numeric credit;
gboolean taxincluded;
GncTaxIncluded taxincluded;
gboolean active;
GList * jobs;
gboolean dirty;
@@ -76,7 +76,7 @@ GncCustomer *gncCustomerCreate (GNCBook *book)
cust->shipaddr = gncAddressCreate (book, &cust->guid);
cust->discount = gnc_numeric_zero();
cust->credit = gnc_numeric_zero();
cust->taxincluded = FALSE;
cust->taxincluded = GNC_TAXINCLUDED_USEGLOBAL;
cust->active = TRUE;
cust->jobs = NULL;
@@ -163,7 +163,7 @@ void gncCustomerSetTerms (GncCustomer *cust, GncBillTerm *terms)
mark_customer (cust);
}
void gncCustomerSetTaxIncluded (GncCustomer *cust, gboolean taxincl)
void gncCustomerSetTaxIncluded (GncCustomer *cust, GncTaxIncluded taxincl)
{
if (!cust) return;
if (taxincl == cust->taxincluded) return;
@@ -295,9 +295,9 @@ GncBillTerm * gncCustomerGetTerms (GncCustomer *cust)
return cust->terms;
}
gboolean gncCustomerGetTaxIncluded (GncCustomer *cust)
GncTaxIncluded gncCustomerGetTaxIncluded (GncCustomer *cust)
{
if (!cust) return FALSE;
if (!cust) return GNC_TAXINCLUDED_USEGLOBAL;
return cust->taxincluded;
}

View File

@@ -12,6 +12,7 @@ typedef struct _gncCustomer GncCustomer;
#include "gnc-book.h"
#include "gncAddress.h"
#include "gncBillTerm.h"
#include "gncTaxTable.h"
#include "gncJob.h"
#include "gnc-numeric.h"
@@ -29,7 +30,7 @@ void gncCustomerSetID (GncCustomer *customer, const char *id);
void gncCustomerSetName (GncCustomer *customer, const char *name);
void gncCustomerSetNotes (GncCustomer *customer, const char *notes);
void gncCustomerSetTerms (GncCustomer *customer, GncBillTerm *term);
void gncCustomerSetTaxIncluded (GncCustomer *customer, gboolean taxincl);
void gncCustomerSetTaxIncluded (GncCustomer *customer, GncTaxIncluded taxincl);
void gncCustomerSetActive (GncCustomer *customer, gboolean active);
void gncCustomerSetDiscount (GncCustomer *customer, gnc_numeric discount);
void gncCustomerSetCredit (GncCustomer *customer, gnc_numeric credit);
@@ -50,7 +51,7 @@ GncAddress * gncCustomerGetAddr (GncCustomer *customer);
GncAddress * gncCustomerGetShipAddr (GncCustomer *customer);
const char * gncCustomerGetNotes (GncCustomer *customer);
GncBillTerm * gncCustomerGetTerms (GncCustomer *customer);
gboolean gncCustomerGetTaxIncluded (GncCustomer *customer);
GncTaxIncluded gncCustomerGetTaxIncluded (GncCustomer *customer);
gboolean gncCustomerGetActive (GncCustomer *customer);
gnc_numeric gncCustomerGetDiscount (GncCustomer *customer);
gnc_numeric gncCustomerGetCredit (GncCustomer *customer);

View File

@@ -19,7 +19,7 @@ typedef struct _gncAccountValue GncAccountValue;
#define GNC_TAXTABLE_MODULE_NAME "gncTaxTable"
/*
* How to interpret the amount.
* How to interpret the amount.
* You can interpret it as a VALUE or a PERCENT.
*/
typedef enum {
@@ -27,6 +27,13 @@ typedef enum {
GNC_AMT_TYPE_PERCENT
} GncAmountType;
/* How to interpret the TaxIncluded */
typedef enum {
GNC_TAXINCLUDED_YES = 1,
GNC_TAXINCLUDED_NO,
GNC_TAXINCLUDED_USEGLOBAL,
} GncTaxIncluded;
/* Create/Destroy Functions */
GncTaxTable * gncTaxTableCreate (GNCBook *book);
void gncTaxTableDestroy (GncTaxTable *table);

View File

@@ -31,7 +31,7 @@ struct _gncVendor {
GncBillTerm * terms;
GncAddress * addr;
gnc_commodity * commodity;
gboolean taxincluded;
GncTaxIncluded taxincluded;
gboolean active;
GList * jobs;
gboolean dirty;
@@ -69,7 +69,7 @@ GncVendor *gncVendorCreate (GNCBook *book)
vendor->name = CACHE_INSERT ("");
vendor->notes = CACHE_INSERT ("");
vendor->addr = gncAddressCreate (book, &vendor->guid);
vendor->taxincluded = FALSE;
vendor->taxincluded = GNC_TAXINCLUDED_USEGLOBAL;
vendor->active = TRUE;
xaccGUIDNew (&vendor->guid, book);
@@ -154,7 +154,7 @@ void gncVendorSetTerms (GncVendor *vendor, GncBillTerm *terms)
mark_vendor (vendor);
}
void gncVendorSetTaxIncluded (GncVendor *vendor, gboolean taxincl)
void gncVendorSetTaxIncluded (GncVendor *vendor, GncTaxIncluded taxincl)
{
if (!vendor) return;
if (taxincl == vendor->taxincluded) return;
@@ -224,9 +224,9 @@ GncBillTerm * gncVendorGetTerms (GncVendor *vendor)
return vendor->terms;
}
gboolean gncVendorGetTaxIncluded (GncVendor *vendor)
GncTaxIncluded gncVendorGetTaxIncluded (GncVendor *vendor)
{
if (!vendor) return FALSE;
if (!vendor) return GNC_TAXINCLUDED_USEGLOBAL;
return vendor->taxincluded;
}

View File

@@ -12,6 +12,7 @@ typedef struct _gncVendor GncVendor;
#include "gnc-book.h"
#include "gncAddress.h"
#include "gncBillTerm.h"
#include "gncTaxTable.h"
#include "gncJob.h"
#define GNC_VENDOR_MODULE_NAME "gncVendor"
@@ -27,7 +28,7 @@ void gncVendorSetID (GncVendor *vendor, const char *id);
void gncVendorSetName (GncVendor *vendor, const char *name);
void gncVendorSetNotes (GncVendor *vendor, const char *notes);
void gncVendorSetTerms (GncVendor *vendor, GncBillTerm *terms);
void gncVendorSetTaxIncluded (GncVendor *vendor, gboolean taxincl);
void gncVendorSetTaxIncluded (GncVendor *vendor, GncTaxIncluded taxincl);
void gncVendorSetCommodity (GncVendor *vendor, gnc_commodity *com);
void gncVendorSetActive (GncVendor *vendor, gboolean active);
@@ -45,7 +46,7 @@ const char * gncVendorGetName (GncVendor *vendor);
GncAddress * gncVendorGetAddr (GncVendor *vendor);
const char * gncVendorGetNotes (GncVendor *vendor);
GncBillTerm * gncVendorGetTerms (GncVendor *vendor);
gboolean gncVendorGetTaxIncluded (GncVendor *vendor);
GncTaxIncluded gncVendorGetTaxIncluded (GncVendor *vendor);
gnc_commodity * gncVendorGetCommodity (GncVendor *vendor);
gboolean gncVendorGetActive (GncVendor *vendor);

View File

@@ -368,3 +368,33 @@ gnc_ui_taxtables_optionmenu (GtkWidget *omenu, GNCBook *book,
(GenericLookup_t)gncTaxTableGetName,
(gpointer *)choice);
}
void
gnc_ui_taxincluded_optionmenu (GtkWidget *omenu, GncTaxIncluded *choice)
{
GtkWidget *menu;
int current = 0, index = 0;
if (!omenu || !choice) return;
menu = gtk_menu_new ();
add_menu_item (menu, _("Yes"), (gpointer *)choice,
GINT_TO_POINTER (GNC_TAXINCLUDED_YES));
if (*choice == GNC_TAXINCLUDED_YES) current = index;
index++;
add_menu_item (menu, _("No"), (gpointer *)choice,
GINT_TO_POINTER (GNC_TAXINCLUDED_NO));
if (*choice == GNC_TAXINCLUDED_NO) current = index;
index++;
add_menu_item (menu, _("Use Global"), (gpointer *)choice,
GINT_TO_POINTER (GNC_TAXINCLUDED_USEGLOBAL));
if (*choice == GNC_TAXINCLUDED_USEGLOBAL) current = index;
index++;
gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current);
gtk_widget_show (menu);
}

View File

@@ -46,4 +46,7 @@ void
gnc_ui_taxtables_optionmenu (GtkWidget *omenu, GNCBook *book,
gboolean none_ok, GncTaxTable **choice);
/* Build an option menu for choosing a GncTaxIncluded */
void gnc_ui_taxincluded_optionmenu (GtkWidget *omenu, GncTaxIncluded *choice);
#endif /* GNC_BUSINESS_UTILS_H_ */

View File

@@ -75,9 +75,10 @@ struct _customer_window {
GtkWidget * credit_amount;
GtkWidget * active_check;
GtkWidget * taxincluded_check;
GtkWidget * taxincluded_menu;
GtkWidget * notes_text;
GncTaxIncluded taxincluded;
GncBillTerm * terms;
CustomerDialogType dialog_type;
GUID customer_guid;
@@ -146,8 +147,7 @@ static void gnc_ui_to_customer (CustomerWindow *cw, GncCustomer *cust)
gncCustomerSetActive (cust, gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (cw->active_check)));
gncCustomerSetTaxIncluded (cust, gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (cw->taxincluded_check)));
gncCustomerSetTaxIncluded (cust, cw->taxincluded);
gncCustomerSetNotes (cust, gtk_editable_get_chars
(GTK_EDITABLE (cw->notes_text), 0, -1));
@@ -420,7 +420,7 @@ gnc_customer_new_window (GNCBook *bookp, GncCustomer *cust)
cw->shipemail_entry = glade_xml_get_widget (xml, "shipemail_entry");
cw->active_check = glade_xml_get_widget (xml, "active_check");
cw->taxincluded_check = glade_xml_get_widget (xml, "tax_included_check");
cw->taxincluded_menu = glade_xml_get_widget (xml, "tax_included_menu");
cw->notes_text = glade_xml_get_widget (xml, "notes_text");
cw->terms_menu = glade_xml_get_widget (xml, "terms_menu");
@@ -538,9 +538,6 @@ gnc_customer_new_window (GNCBook *bookp, GncCustomer *cust)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw->active_check),
gncCustomerGetActive (cust));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw->taxincluded_check),
gncCustomerGetTaxIncluded (cust));
string = gncCustomerGetNotes (cust);
gtk_editable_delete_text (GTK_EDITABLE (cw->notes_text), 0, -1);
gtk_editable_insert_text (GTK_EDITABLE (cw->notes_text), string,
@@ -571,6 +568,8 @@ gnc_customer_new_window (GNCBook *bookp, GncCustomer *cust)
/* I know that cust exists here -- either passed in or just created */
cw->taxincluded = gncCustomerGetTaxIncluded (cust);
gnc_ui_taxincluded_optionmenu (cw->taxincluded_menu, &cw->taxincluded);
gnc_ui_billterms_optionmenu (cw->terms_menu, bookp, TRUE, &cw->terms);

View File

@@ -314,7 +314,7 @@ gnc_dialog_dates_acct_parented (GtkWidget *parent, const char *message,
gtk_signal_connect (GTK_OBJECT (ddc->post_date), "date_changed",
post_date_changed_cb, ddc);
gtk_widget_set_sensitive (ddc->date, FALSE);
post_date_changed_cb (ddc->post_date, ddc);
post_date_changed_cb (GNC_DATE_EDIT (ddc->post_date), ddc);
} else
gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *ddue);

View File

@@ -62,9 +62,10 @@ struct _vendor_window {
GtkWidget * terms_menu;
GtkWidget * active_check;
GtkWidget * taxincluded_check;
GtkWidget * taxincluded_menu;
GtkWidget * notes_text;
GncTaxIncluded taxincluded;
GncBillTerm * terms;
VendorDialogType dialog_type;
GUID vendor_guid;
@@ -115,8 +116,7 @@ static void gnc_ui_to_vendor (VendorWindow *vw, GncVendor *vendor)
gncVendorSetActive (vendor, gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (vw->active_check)));
gncVendorSetTaxIncluded (vendor, gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (vw->taxincluded_check)));
gncVendorSetTaxIncluded (vendor, vw->taxincluded);
gncVendorSetNotes (vendor, gtk_editable_get_chars
(GTK_EDITABLE (vw->notes_text), 0, -1));
gncVendorSetTerms (vendor, vw->terms);
@@ -333,7 +333,7 @@ gnc_vendor_new_window (GNCBook *bookp, GncVendor *vendor)
vw->email_entry = glade_xml_get_widget (xml, "email_entry");
vw->active_check = glade_xml_get_widget (xml, "active_check");
vw->taxincluded_check = glade_xml_get_widget (xml, "tax_included_check");
vw->taxincluded_menu = glade_xml_get_widget (xml, "tax_included_menu");
vw->notes_text = glade_xml_get_widget (xml, "notes_text");
vw->terms_menu = glade_xml_get_widget (xml, "terms_menu");
@@ -403,9 +403,6 @@ gnc_vendor_new_window (GNCBook *bookp, GncVendor *vendor)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vw->active_check),
gncVendorGetActive (vendor));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vw->taxincluded_check),
gncVendorGetTaxIncluded (vendor));
string = gncVendorGetNotes (vendor);
gtk_editable_delete_text (GTK_EDITABLE (vw->notes_text), 0, -1);
gtk_editable_insert_text (GTK_EDITABLE (vw->notes_text), string,
@@ -437,6 +434,8 @@ gnc_vendor_new_window (GNCBook *bookp, GncVendor *vendor)
/* I know that vendor exists here -- either passed in or just created */
vw->taxincluded = gncVendorGetTaxIncluded (vendor);
gnc_ui_taxincluded_optionmenu (vw->taxincluded_menu, &vw->taxincluded);
gnc_ui_billterms_optionmenu (vw->terms_menu, bookp, TRUE, &vw->terms);

View File

@@ -688,13 +688,15 @@
</widget>
<widget>
<class>GtkCheckButton</class>
<name>tax_included_check</name>
<border_width>3</border_width>
<can_focus>True</can_focus>
<label>Tax Included</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<class>GtkLabel</class>
<name>label34</name>
<label>Tax Included: </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>
@@ -762,15 +764,12 @@
</widget>
<widget>
<class>GtkLabel</class>
<name>label32</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<class>GtkOptionMenu</class>
<name>tax_included_menu</name>
<can_focus>True</can_focus>
<items>(taxincluded)
</items>
<initial_choice>0</initial_choice>
<child>
<padding>0</padding>
<expand>False</expand>

View File

@@ -655,13 +655,15 @@
</widget>
<widget>
<class>GtkCheckButton</class>
<name>tax_included_check</name>
<border_width>3</border_width>
<can_focus>True</can_focus>
<label>Tax Included</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<class>GtkLabel</class>
<name>label34</name>
<label>Tax Included:</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>
@@ -697,15 +699,12 @@
</widget>
<widget>
<class>GtkLabel</class>
<name>label32</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<class>GtkOptionMenu</class>
<name>tax_included_menu</name>
<can_focus>True</can_focus>
<items>(taxincluded)
</items>
<initial_choice>0</initial_choice>
<child>
<padding>0</padding>
<expand>False</expand>

View File

@@ -15,6 +15,7 @@
#include "recncell.h"
#include "combocell.h"
#include "messages.h"
#include "global-options.h"
#include "gncEntry.h"
#include "gncEntryLedger.h"
@@ -191,6 +192,46 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
blank_entry = gncEntryCreate (ledger->book);
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;
GncTaxIncluded taxincluded_p = GNC_TAXINCLUDED_USEGLOBAL;
gboolean taxincluded;
gnc_numeric discount = gnc_numeric_zero ();
owner = gncOwnerGetEndOwner (owner);
switch (gncOwnerGetType (owner)) {
case GNC_OWNER_CUSTOMER:
taxincluded_p = gncCustomerGetTaxIncluded (owner->owner.customer);
discount = gncCustomerGetDiscount (owner->owner.customer);
break;
case GNC_OWNER_VENDOR:
taxincluded_p = gncVendorGetTaxIncluded (owner->owner.vendor);
break;
default:
}
/* XXX: Get the default tax-table */
/* Compute the default taxincluded */
switch (taxincluded_p) {
case GNC_TAXINCLUDED_YES:
taxincluded = TRUE;
break;
case GNC_TAXINCLUDED_NO:
taxincluded = FALSE;
break;
case GNC_TAXINCLUDED_USEGLOBAL:
taxincluded = gnc_lookup_boolean_option ("Business",
"Tax Included?", FALSE);
break;
}
gncEntrySetTaxTable (blank_entry, table);
gncEntrySetTaxIncluded (blank_entry, taxincluded);
gncEntrySetDiscount (blank_entry, discount);
}
break;
default:
ledger->blank_entry_guid = *xaccGUIDNULL ();