29 #include <glib/gi18n.h>
32 #include "dialog-billterms.h"
33 #include "dialog-customer.h"
34 #include "dialog-employee.h"
35 #include "dialog-invoice.h"
36 #include "dialog-job.h"
37 #include "dialog-payment.h"
38 #include "dialog-tax-table.h"
39 #include "dialog-vendor.h"
40 #include "business-gnome-utils.h"
41 #include "gnc-plugin-business.h"
48 #include "guile-mappings.h"
49 #include "gnc-session.h"
50 #include "gnome-utils/gnc-icons.h"
63 static void gnc_plugin_business_finalize (GObject *
object);
64 static void gnc_plugin_business_add_to_window (
GncPlugin *plugin,
69 static void gnc_plugin_business_cmd_customer_page (GtkAction *action,
71 static void gnc_plugin_business_cmd_customer_new_customer (GtkAction *action,
73 static void gnc_plugin_business_cmd_customer_find_customer (GtkAction *action,
75 static void gnc_plugin_business_cmd_customer_new_invoice (GtkAction *action,
77 static void gnc_plugin_business_cmd_customer_find_invoice (GtkAction *action,
79 static void gnc_plugin_business_cmd_customer_new_job (GtkAction *action,
81 static void gnc_plugin_business_cmd_customer_find_job (GtkAction *action,
83 static void gnc_plugin_business_cmd_customer_process_payment (GtkAction *action,
86 static void gnc_plugin_business_cmd_vendor_page (GtkAction *action,
88 static void gnc_plugin_business_cmd_vendor_new_vendor (GtkAction *action,
90 static void gnc_plugin_business_cmd_vendor_find_vendor (GtkAction *action,
92 static void gnc_plugin_business_cmd_vendor_new_bill (GtkAction *action,
94 static void gnc_plugin_business_cmd_vendor_find_bill (GtkAction *action,
96 static void gnc_plugin_business_cmd_vendor_new_job (GtkAction *action,
98 static void gnc_plugin_business_cmd_vendor_find_job (GtkAction *action,
100 static void gnc_plugin_business_cmd_vendor_process_payment (GtkAction *action,
103 static void gnc_plugin_business_cmd_employee_page (GtkAction *action,
105 static void gnc_plugin_business_cmd_employee_new_employee (GtkAction *action,
107 static void gnc_plugin_business_cmd_employee_find_employee (GtkAction *action,
109 static void gnc_plugin_business_cmd_employee_new_expense_voucher (GtkAction *action,
111 static void gnc_plugin_business_cmd_employee_find_expense_voucher (GtkAction *action,
113 static void gnc_plugin_business_cmd_employee_process_payment (GtkAction *action,
116 static void gnc_plugin_business_cmd_tax_tables (GtkAction *action,
118 static void gnc_plugin_business_cmd_billing_terms (GtkAction *action,
120 static void gnc_plugin_business_cmd_bills_due_reminder (GtkAction *action,
123 static void gnc_plugin_business_cmd_test_search (GtkAction *action,
126 static void gnc_plugin_business_cmd_test_init_data (GtkAction *action,
129 static void gnc_plugin_business_cmd_assign_payment (GtkAction *action,
133 #define PLUGIN_ACTIONS_NAME "gnc-plugin-business-actions"
134 #define PLUGIN_UI_FILENAME "gnc-plugin-business-ui.xml"
136 #define GNC_PREF_EXTRA_TOOLBUTTONS "enable-toolbuttons"
137 #define GNC_PREF_INV_PRINT_RPT "invoice-printreport"
147 static GtkActionEntry gnc_plugin_actions [] =
150 {
"BusinessAction", NULL, N_(
"_Business"), NULL, NULL, NULL },
153 {
"CustomerMenuAction", NULL, N_(
"_Customer"), NULL, NULL, NULL },
155 "CustomerOverviewPageAction", NULL, N_(
"Customers Overview"), NULL,
156 N_(
"Open a Customer overview page"),
157 G_CALLBACK (gnc_plugin_business_cmd_customer_page)
160 "CustomerNewCustomerOpenAction", NULL, N_(
"_New Customer..."), NULL,
161 N_(
"Open the New Customer dialog"),
162 G_CALLBACK (gnc_plugin_business_cmd_customer_new_customer)
165 "CustomerFindCustomerOpenAction", NULL, N_(
"_Find Customer..."), NULL,
166 N_(
"Open the Find Customer dialog"),
167 G_CALLBACK (gnc_plugin_business_cmd_customer_find_customer)
170 "CustomerNewInvoiceOpenAction", NULL, N_(
"New _Invoice..."), NULL,
171 N_(
"Open the New Invoice dialog"),
172 G_CALLBACK (gnc_plugin_business_cmd_customer_new_invoice)
175 "CustomerFindInvoiceOpenAction", NULL, N_(
"Find In_voice..."), NULL,
176 N_(
"Open the Find Invoice dialog"),
177 G_CALLBACK (gnc_plugin_business_cmd_customer_find_invoice)
180 "CustomerNewJobOpenAction", NULL, N_(
"New _Job..."), NULL,
181 N_(
"Open the New Job dialog"),
182 G_CALLBACK (gnc_plugin_business_cmd_customer_new_job)
185 "CustomerFindJobOpenAction", NULL, N_(
"Find Jo_b..."), NULL,
186 N_(
"Open the Find Job dialog"),
187 G_CALLBACK (gnc_plugin_business_cmd_customer_find_job)
190 "CustomerProcessPaymentAction", NULL, N_(
"_Process Payment..."), NULL,
191 N_(
"Open the Process Payment dialog"),
192 G_CALLBACK (gnc_plugin_business_cmd_customer_process_payment)
197 "VendorOverviewPageAction", NULL, N_(
"Vendors Overview"), NULL,
198 N_(
"Open a Vendor overview page"),
199 G_CALLBACK (gnc_plugin_business_cmd_vendor_page)
201 {
"VendorMenuAction", NULL, N_(
"_Vendor"), NULL, NULL, NULL },
203 "VendorNewVendorOpenAction", NULL, N_(
"_New Vendor..."), NULL,
204 N_(
"Open the New Vendor dialog"),
205 G_CALLBACK (gnc_plugin_business_cmd_vendor_new_vendor)
208 "VendorFindVendorOpenAction", NULL, N_(
"_Find Vendor..."), NULL,
209 N_(
"Open the Find Vendor dialog"),
210 G_CALLBACK (gnc_plugin_business_cmd_vendor_find_vendor)
213 "VendorNewBillOpenAction", NULL, N_(
"New _Bill..."), NULL,
214 N_(
"Open the New Bill dialog"),
215 G_CALLBACK (gnc_plugin_business_cmd_vendor_new_bill)
218 "VendorFindBillOpenAction", NULL, N_(
"Find Bi_ll..."), NULL,
219 N_(
"Open the Find Bill dialog"),
220 G_CALLBACK (gnc_plugin_business_cmd_vendor_find_bill)
223 "VendorNewJobOpenAction", NULL, N_(
"New _Job..."), NULL,
224 N_(
"Open the New Job dialog"),
225 G_CALLBACK (gnc_plugin_business_cmd_vendor_new_job)
228 "VendorFindJobOpenAction", NULL, N_(
"Find Jo_b..."), NULL,
229 N_(
"Open the Find Job dialog"),
230 G_CALLBACK (gnc_plugin_business_cmd_vendor_find_job)
233 "VendorProcessPaymentAction", NULL, N_(
"_Process Payment..."), NULL,
234 N_(
"Open the Process Payment dialog"),
235 G_CALLBACK (gnc_plugin_business_cmd_vendor_process_payment)
240 "EmployeeOverviewPageAction", NULL, N_(
"Employees Overview"), NULL,
241 N_(
"Open a Employee overview page"),
242 G_CALLBACK (gnc_plugin_business_cmd_employee_page)
244 {
"EmployeeMenuAction", NULL, N_(
"_Employee"), NULL, NULL, NULL },
246 "EmployeeNewEmployeeOpenAction", NULL, N_(
"_New Employee..."), NULL,
247 N_(
"Open the New Employee dialog"),
248 G_CALLBACK (gnc_plugin_business_cmd_employee_new_employee)
251 "EmployeeFindEmployeeOpenAction", NULL, N_(
"_Find Employee..."), NULL,
252 N_(
"Open the Find Employee dialog"),
253 G_CALLBACK (gnc_plugin_business_cmd_employee_find_employee)
256 "EmployeeNewExpenseVoucherOpenAction", NULL, N_(
"New _Expense Voucher..."), NULL,
257 N_(
"Open the New Expense Voucher dialog"),
258 G_CALLBACK (gnc_plugin_business_cmd_employee_new_expense_voucher)
261 "EmployeeFindExpenseVoucherOpenAction", NULL, N_(
"Find Expense _Voucher..."), NULL,
262 N_(
"Open the Find Expense Voucher dialog"),
263 G_CALLBACK (gnc_plugin_business_cmd_employee_find_expense_voucher)
266 "EmployeeProcessPaymentAction", NULL, N_(
"_Process Payment..."), NULL,
267 N_(
"Open the Process Payment dialog"),
268 G_CALLBACK (gnc_plugin_business_cmd_employee_process_payment)
273 "TaxTablesOpenAction", NULL, N_(
"Sales _Tax Table"), NULL,
274 N_(
"View and edit the list of Sales Tax Tables (GST/VAT)"),
275 G_CALLBACK (gnc_plugin_business_cmd_tax_tables)
278 "BillingTermsOpenAction", NULL, N_(
"_Billing Terms Editor"), NULL,
279 N_(
"View and edit the list of Billing Terms"),
280 G_CALLBACK (gnc_plugin_business_cmd_billing_terms)
283 "BillsDueReminderOpenAction", NULL, N_(
"Bills _Due Reminder"), NULL,
284 N_(
"Open the Bills Due Reminder dialog"),
285 G_CALLBACK (gnc_plugin_business_cmd_bills_due_reminder)
287 {
"ExportMenuAction", NULL, N_(
"E_xport"), NULL, NULL, NULL },
290 {
"BusinessTestAction", NULL, N_(
"_Business"), NULL, NULL, NULL },
292 "BusinessTestSearchAction", NULL, N_(
"Test Search Dialog"), NULL,
293 N_(
"Test Search Dialog"),
294 G_CALLBACK (gnc_plugin_business_cmd_test_search)
297 "BusinessTestInitDataAction", NULL, N_(
"Initialize Test Data"), NULL,
298 N_(
"Initialize Test Data"),
299 G_CALLBACK (gnc_plugin_business_cmd_test_init_data)
304 "ToolbarNewInvoiceAction", GNC_STOCK_INVOICE_NEW, N_(
"New _Invoice..."), NULL,
305 N_(
"Open the New Invoice dialog"),
306 G_CALLBACK (gnc_plugin_business_cmd_customer_new_invoice)
311 "RegisterAssignPayment", NULL, N_(
"Assign as payment..."), NULL,
312 N_(
"Assign the selected transaction as payment"),
313 G_CALLBACK (gnc_plugin_business_cmd_assign_payment)
316 static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
330 #define GNC_PLUGIN_BUSINESS_GET_PRIVATE(o) \
331 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_BUSINESS, GncPluginBusinessPrivate))
333 static GObjectClass *parent_class = NULL;
336 gnc_plugin_business_get_type (
void)
338 static GType gnc_plugin_business_type = 0;
340 if (gnc_plugin_business_type == 0)
342 static const GTypeInfo our_info =
347 (GClassInitFunc) gnc_plugin_business_class_init,
352 (GInstanceInitFunc) gnc_plugin_business_init
355 gnc_plugin_business_type = g_type_register_static (GNC_TYPE_PLUGIN,
360 return gnc_plugin_business_type;
364 gnc_plugin_business_new (
void)
370 GNC_TYPE_PLUGIN_PAGE_INVOICE;
371 GNC_TYPE_PLUGIN_PAGE_OWNER_TREE;
373 plugin = g_object_new (GNC_TYPE_PLUGIN_BUSINESS,
376 return GNC_PLUGIN (plugin);
382 GObjectClass *object_class = G_OBJECT_CLASS (klass);
385 parent_class = g_type_class_peek_parent (klass);
387 object_class->finalize = gnc_plugin_business_finalize;
390 plugin_class->
plugin_name = GNC_PLUGIN_BUSINESS_NAME;
393 plugin_class->
add_to_window = gnc_plugin_business_add_to_window;
397 plugin_class->
actions = gnc_plugin_actions;
398 plugin_class->
n_actions = gnc_plugin_n_actions;
409 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
411 gncOwnerInitCustomer (priv->last_customer, NULL);
414 gncOwnerInitVendor (priv->last_vendor, NULL);
417 gncOwnerInitEmployee (priv->last_employee, NULL);
421 gnc_plugin_business_finalize (GObject *
object)
423 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (
object));
425 G_OBJECT_CLASS (parent_class)->finalize (
object);
433 gnc_plugin_business_get_window()
443 gnc_plugin_business_cmd_customer_page (GtkAction *action,
448 g_return_if_fail (mw != NULL);
449 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
456 gnc_plugin_business_cmd_customer_new_customer (GtkAction *action,
459 g_return_if_fail (mw != NULL);
460 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
462 gnc_ui_customer_new (gnc_get_current_book());
466 gnc_plugin_business_cmd_customer_find_customer (GtkAction *action,
473 g_return_if_fail (mw != NULL);
474 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
476 plugin = GNC_PLUGIN_BUSINESS (mw->data);
477 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
479 gnc_customer_search (customer, gnc_get_current_book());
483 gnc_plugin_business_cmd_customer_new_invoice (GtkAction *action,
489 g_return_if_fail (mw != NULL);
490 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
492 plugin = GNC_PLUGIN_BUSINESS (mw->data);
493 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
494 last_window = mw->window;
495 gnc_ui_invoice_new (priv->last_customer, gnc_get_current_book());
499 gnc_plugin_business_cmd_customer_find_invoice (GtkAction *action,
505 g_return_if_fail (mw != NULL);
506 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
508 plugin = GNC_PLUGIN_BUSINESS (mw->data);
509 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
510 last_window = mw->window;
511 gnc_invoice_search (NULL, priv->last_customer, gnc_get_current_book());
515 gnc_plugin_business_cmd_customer_new_job (GtkAction *action,
521 g_return_if_fail (mw != NULL);
522 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
524 plugin = GNC_PLUGIN_BUSINESS (mw->data);
525 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
526 gnc_ui_job_new (priv->last_customer, gnc_get_current_book());
530 gnc_plugin_business_cmd_customer_find_job (GtkAction *action,
536 g_return_if_fail (mw != NULL);
537 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
539 plugin = GNC_PLUGIN_BUSINESS (mw->data);
540 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
541 gnc_job_search (NULL, priv->last_customer, gnc_get_current_book());
545 gnc_plugin_business_cmd_customer_process_payment (GtkAction *action,
551 g_return_if_fail (mw != NULL);
552 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
554 plugin = GNC_PLUGIN_BUSINESS (mw->data);
555 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
556 gnc_ui_payment_new (priv->last_customer, gnc_get_current_book());
560 gnc_plugin_business_cmd_vendor_page (GtkAction *action,
565 g_return_if_fail (mw != NULL);
566 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
573 gnc_plugin_business_cmd_vendor_new_vendor (GtkAction *action,
576 g_return_if_fail (mw != NULL);
577 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
579 gnc_ui_vendor_new (gnc_get_current_book());
583 gnc_plugin_business_cmd_vendor_find_vendor (GtkAction *action,
590 g_return_if_fail (mw != NULL);
591 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
593 plugin = GNC_PLUGIN_BUSINESS (mw->data);
594 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
596 gnc_vendor_search (vendor, gnc_get_current_book());
600 gnc_plugin_business_cmd_vendor_new_bill (GtkAction *action,
606 g_return_if_fail (mw != NULL);
607 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
609 plugin = GNC_PLUGIN_BUSINESS (mw->data);
610 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
611 last_window = mw->window;
612 gnc_ui_invoice_new (priv->last_vendor, gnc_get_current_book());
616 gnc_plugin_business_cmd_vendor_find_bill (GtkAction *action,
622 g_return_if_fail (mw != NULL);
623 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
625 plugin = GNC_PLUGIN_BUSINESS (mw->data);
626 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
627 last_window = mw->window;
628 gnc_invoice_search (NULL, priv->last_vendor, gnc_get_current_book());
632 gnc_plugin_business_cmd_vendor_new_job (GtkAction *action,
638 g_return_if_fail (mw != NULL);
639 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
641 plugin = GNC_PLUGIN_BUSINESS (mw->data);
642 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
643 gnc_ui_job_new (priv->last_vendor, gnc_get_current_book());
647 gnc_plugin_business_cmd_vendor_find_job (GtkAction *action,
653 g_return_if_fail (mw != NULL);
654 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
656 plugin = GNC_PLUGIN_BUSINESS (mw->data);
657 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
658 gnc_job_search (NULL, priv->last_vendor, gnc_get_current_book());
662 gnc_plugin_business_cmd_vendor_process_payment (GtkAction *action,
668 g_return_if_fail (mw != NULL);
669 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
671 plugin = GNC_PLUGIN_BUSINESS (mw->data);
672 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
673 gnc_ui_payment_new (priv->last_vendor, gnc_get_current_book());
677 gnc_plugin_business_cmd_employee_page (GtkAction *action,
682 g_return_if_fail (mw != NULL);
683 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
690 gnc_plugin_business_cmd_employee_new_employee (GtkAction *action,
693 g_return_if_fail (mw != NULL);
694 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
696 gnc_ui_employee_new (gnc_get_current_book());
700 gnc_plugin_business_cmd_employee_find_employee (GtkAction *action,
707 g_return_if_fail (mw != NULL);
708 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
710 plugin = GNC_PLUGIN_BUSINESS (mw->data);
711 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
713 gnc_employee_search (employee, gnc_get_current_book());
717 gnc_plugin_business_cmd_employee_new_expense_voucher (GtkAction *action,
723 g_return_if_fail (mw != NULL);
724 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
726 plugin = GNC_PLUGIN_BUSINESS (mw->data);
727 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
728 last_window = mw->window;
729 gnc_ui_invoice_new (priv->last_employee, gnc_get_current_book());
733 gnc_plugin_business_cmd_employee_find_expense_voucher (GtkAction *action,
739 g_return_if_fail (mw != NULL);
740 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
742 plugin = GNC_PLUGIN_BUSINESS (mw->data);
743 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
744 last_window = mw->window;
745 gnc_invoice_search (NULL, priv->last_employee, gnc_get_current_book());
749 gnc_plugin_business_cmd_employee_process_payment (GtkAction *action,
755 g_return_if_fail (mw != NULL);
756 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
758 plugin = GNC_PLUGIN_BUSINESS (mw->data);
759 priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin);
760 gnc_ui_payment_new (priv->last_employee, gnc_get_current_book());
764 gnc_plugin_business_cmd_tax_tables (GtkAction *action,
767 g_return_if_fail (mw != NULL);
768 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
770 gnc_ui_tax_table_window_new (gnc_get_current_book());
774 gnc_plugin_business_cmd_billing_terms (GtkAction *action,
777 g_return_if_fail (mw != NULL);
778 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
780 gnc_ui_billterms_window_new (gnc_get_current_book());
785 gnc_plugin_business_cmd_bills_due_reminder (GtkAction *action,
788 g_return_if_fail (mw != NULL);
789 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
791 gnc_invoice_remind_bills_due();
795 gnc_plugin_business_cmd_test_search (GtkAction *action,
798 gnc_search_dialog_test();
801 static void gnc_business_assign_payment (GtkWidget *parent,
805 g_return_if_fail(trans);
812 gnc_ui_payment_new_with_txn(owner, trans);
815 static void gnc_plugin_business_cmd_assign_payment (GtkAction *action,
825 gboolean is_customer;
827 g_return_if_fail (mw != NULL);
828 g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
834 if (!GNC_IS_PLUGIN_PAGE(plugin_page)
835 || !GNC_IS_PLUGIN_PAGE_REGISTER(plugin_page))
839 g_return_if_fail(gsr);
841 reg = gnc_ledger_display_get_split_register( gsr->
ledger );
842 g_return_if_fail(reg);
845 g_return_if_fail(split);
848 g_return_if_fail(trans);
849 is_customer = gnc_ui_payment_is_customer_payment(trans);
851 plugin_business = GNC_PLUGIN_BUSINESS (mw->data);
852 plugin_business_priv = GNC_PLUGIN_BUSINESS_GET_PRIVATE (plugin_business);
857 ? plugin_business_priv->last_customer
858 : plugin_business_priv->last_vendor);
861 static const gchar *register_txn_actions[] =
863 "RegisterAssignPayment",
868 gnc_plugin_business_update_menus (
GncPluginPage *plugin_page)
871 GtkActionGroup *action_group;
872 gboolean is_txn_register;
875 if (!plugin_page || !GNC_IS_PLUGIN_PAGE(plugin_page))
878 is_txn_register = GNC_IS_PLUGIN_PAGE_REGISTER(plugin_page);
879 window = GNC_MAIN_WINDOW(plugin_page->
window);
880 g_return_if_fail(GNC_IS_MAIN_WINDOW(window));
882 g_return_if_fail(GTK_IS_ACTION_GROUP(action_group));
886 "sensitive", is_txn_register);
888 "visible", is_txn_register);
892 static void gnc_plugin_business_main_window_page_changed(
GncMainWindow *window,
896 gnc_plugin_business_update_menus(page);
897 update_inactive_actions(page);
901 gnc_plugin_business_cmd_test_init_data (GtkAction *action,
904 QofBook *book = gnc_get_current_book();
906 GncAddress *address = gncCustomerGetAddr(customer);
909 GncJob *job = gncJobCreate(book);
910 Account *root = gnc_book_get_root_account(book);
918 gncCustomerSetID(customer,
"000001");
919 gncCustomerSetName(customer,
"Test Customer");
921 gncAddressSetName(address,
"Contact Person");
922 gncAddressSetAddr1(address,
"20 Customer Lane");
923 gncAddressSetAddr2(address,
"Customer M/S");
924 gncAddressSetAddr3(address,
"Addr3, XXX 12345");
927 gncOwnerInitCustomer(owner, customer);
931 gncInvoiceSetID(invoice,
"000012");
932 gncInvoiceSetOwner(invoice, owner);
933 gncInvoiceSetDateOpened(invoice, now);
937 gncJobSetID(job,
"000025");
938 gncJobSetName(job,
"Test Job");
939 gncJobSetReference(job,
"Customer's ref#");
940 gncJobSetOwner(job, owner);
943 gncOwnerInitJob(owner, job);
970 gnc_ui_invoice_edit(invoice);
974 static const gchar* readonly_inactive_actions[] =
976 "CustomerNewCustomerOpenAction",
977 "CustomerNewInvoiceOpenAction",
978 "CustomerNewInvoiceOpenAction",
979 "CustomerNewJobOpenAction",
980 "CustomerProcessPaymentAction",
981 "VendorNewVendorOpenAction",
982 "VendorNewBillOpenAction",
983 "VendorNewJobOpenAction",
984 "VendorProcessPaymentAction",
985 "EmployeeNewEmployeeOpenAction",
986 "EmployeeNewExpenseVoucherOpenAction",
987 "EmployeeProcessPaymentAction",
988 "ToolbarNewInvoiceAction",
989 "RegisterAssignPayment",
993 static void update_inactive_actions(
GncPluginPage *plugin_page)
996 GtkActionGroup *action_group;
1002 if (!plugin_page || !GNC_IS_PLUGIN_PAGE(plugin_page))
1005 window = GNC_MAIN_WINDOW(plugin_page->
window);
1006 g_return_if_fail(GNC_IS_MAIN_WINDOW(window));
1008 g_return_if_fail(GTK_IS_ACTION_GROUP(action_group));
1012 "sensitive", is_readwrite);
1017 static const char* extra_toolbar_actions[] =
1019 "ToolbarNewInvoiceAction",
1025 static void bind_toolbuttons_visibility (
GncMainWindow *mainwindow)
1027 GtkActionGroup *action_group;
1030 g_return_if_fail(mainwindow);
1031 g_return_if_fail(GNC_IS_MAIN_WINDOW(mainwindow));
1036 g_assert(action_group);
1038 for (iter = extra_toolbar_actions; *iter; ++iter)
1041 GtkAction *action = gtk_action_group_get_action (action_group, *iter);
1042 gnc_prefs_bind (GNC_PREFS_GROUP_INVOICE, GNC_PREF_EXTRA_TOOLBUTTONS, G_OBJECT (action),
"visible");
1052 static void gnc_plugin_business_add_to_window (
GncPlugin *plugin,
1056 bind_toolbuttons_visibility (mainwindow);
1058 g_signal_connect(mainwindow,
"page_changed",
1059 G_CALLBACK(gnc_plugin_business_main_window_page_changed),
1063 static const char* invoice_printreport_values[] =
1070 "5123a759ceb9483abf2182d01c140e8d",
1071 "0769e242be474010b4acf264a5512e6e",
1072 "67112f318bef4fc496bdc27d106bbda4",
1073 "3ce293441e894423a2425d7a22dd1ac6",
1077 const char *gnc_plugin_business_get_invoice_printreport(
void)
1079 int value =
gnc_prefs_get_int (GNC_PREFS_GROUP_INVOICE, GNC_PREF_INV_PRINT_RPT);
1080 if (value >= 0 && value < 4)
1081 return invoice_printreport_values[value];
void xaccAccountSetType(Account *acc, GNCAccountType tip)
utility functions for the GnuCash UI
GtkWidget * gnc_plugin_page_get_window(GncPluginPage *page)
void gnc_account_append_child(Account *new_parent, Account *child)
Business Interface: Object OWNERs.
Date and Time handling routines.
utility functions for the GnuCash UI
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
The type, style and table for the register.
Split * gnc_split_register_get_current_split(SplitRegister *reg)
Use a 64-bit unsigned int timespec.
Transaction * xaccSplitGetParent(const Split *split)
const gchar * ui_filename
GncPluginPage * gnc_main_window_get_current_page(GncMainWindow *window)
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
gint gnc_prefs_get_int(const gchar *group, const gchar *pref_name)
Functions for adding content to a window.
gnc_commodity * gnc_default_currency(void)
int xaccTransCountSplits(const Transaction *trans)
Functions providing a register page for the GnuCash UI.
Functions providing a page which lists owners of one type. This type can be vendors, customers or employees.
void gnc_prefs_bind(const gchar *group, const gchar *pref_name, gpointer object, const gchar *property)
const gchar * actions_name
Generic api to store and retrieve preferences.
GtkActionGroup * gnc_main_window_get_action_group(GncMainWindow *window, const gchar *group_name)
gboolean qof_book_is_readonly(const QofBook *book)
const gchar * plugin_name
GNCLedgerDisplay * ledger
#define PLUGIN_ACTIONS_NAME
void(* add_to_window)(GncPlugin *plugin, GncMainWindow *window, GQuark type)
Account * xaccMallocAccount(QofBook *book)
GncVendor * gncOwnerGetVendor(const GncOwner *owner)
GncCustomer * gncOwnerGetCustomer(const GncOwner *owner)
GncEmployee * gncOwnerGetEmployee(const GncOwner *owner)
GNCSplitReg * gnc_plugin_page_register_get_gsr(GncPluginPage *plugin_page)
GncOwner * gncOwnerNew(void)
void xaccAccountSetName(Account *acc, const char *str)
GncPluginPage * gnc_plugin_page_owner_tree_new(GncOwnerType owner_type)
#define PLUGIN_UI_FILENAME
const gchar * QofLogModule
void xaccAccountSetCommodity(Account *acc, gnc_commodity *com)
void timespecFromTime64(Timespec *ts, time64 t)