29#include <glib/gi18n.h>
31#include "swig-runtime.h"
35#include "dialog-utils.h"
36#include "gnc-component-manager.h"
38#include "gnc-gui-query.h"
42#include "gnc-date-edit.h"
43#include "gnc-amount-edit.h"
45#include "gnucash-register.h"
46#include "window-report.h"
47#include "dialog-search.h"
48#include "search-param.h"
49#include "gnc-session.h"
52#include "gncInvoiceP.h"
58#include "gnc-general-search.h"
59#include "dialog-date-close.h"
60#include "dialog-invoice.h"
61#include "dialog-job.h"
62#include "business-gnome-utils.h"
63#include "dialog-payment.h"
64#include "dialog-tax-table.h"
65#include "dialog-billterms.h"
67#include "guile-mappings.h"
68#include "dialog-dup-trans.h"
70#include "dialog-query-view.h"
72#include "gnc-plugin-business.h"
78#include "dialog-doclink.h"
79#include "dialog-doclink-utils.h"
80#include "dialog-transfer.h"
82#include "gnc-report-combo.h"
84#define DIALOG_NEW_INVOICE_CM_CLASS "dialog-new-invoice"
85#define DIALOG_VIEW_INVOICE_CM_CLASS "dialog-view-invoice"
87#define GNC_PREFS_GROUP_CUSTOMER "dialogs.customer-due"
88#define GNC_PREFS_GROUP_VENDOR "dialogs.vendor-due"
90#define GNC_PREFS_GROUP_SEARCH "dialogs.business.invoice-search"
91#define GNC_PREF_NOTIFY_WHEN_DUE "notify-when-due"
92#define GNC_PREF_ACCUM_SPLITS "accumulate-splits"
93#define GNC_PREF_DAYS_IN_ADVANCE "days-in-advance"
95void gnc_invoice_window_ok_cb (GtkWidget *widget, gpointer data);
96void gnc_invoice_window_cancel_cb (GtkWidget *widget, gpointer data);
97void gnc_invoice_window_help_cb (GtkWidget *widget, gpointer data);
98void gnc_invoice_type_toggled_cb (GtkWidget *widget, gpointer data);
99void gnc_invoice_id_changed_cb (GtkWidget *widget, gpointer data);
100void gnc_invoice_terms_changed_cb (GtkWidget *widget, gpointer data);
102#define ENUM_INVOICE_TYPE(_) \
109DEFINE_ENUM(InvoiceDialogType, ENUM_INVOICE_TYPE)
110AS_STRING_DEC(InvoiceDialogType, ENUM_INVOICE_TYPE)
111FROM_STRING_DEC(InvoiceDialogType, ENUM_INVOICE_TYPE)
113FROM_STRING_FUNC(InvoiceDialogType, ENUM_INVOICE_TYPE)
114AS_STRING_FUNC(InvoiceDialogType, ENUM_INVOICE_TYPE)
130#define UNUSED_VAR __attribute__ ((unused))
132static QofLogModule UNUSED_VAR log_module = G_LOG_DOMAIN;
141 GtkBuilder * builder;
145 const gchar * page_state_name;
148 GtkWidget * total_label;
149 GtkWidget * total_cash_label;
150 GtkWidget * total_charge_label;
151 GtkWidget * total_subtotal_label;
152 GtkWidget * total_tax_label;
155 GtkWidget * info_label;
156 GtkWidget * id_label;
157 GtkWidget * type_label;
158 GtkWidget * type_label_hbox;
159 GtkWidget * type_hbox;
160 GtkWidget * type_choice;
161 GtkWidget * id_entry;
162 GtkWidget * notes_text;
163 GtkWidget * opened_date;
164 GtkWidget * posted_date_hbox;
165 GtkWidget * posted_date;
166 GtkWidget * active_check;
167 GtkWidget * paid_label;
169 GtkWidget * doclink_button;
171 GtkWidget * owner_box;
172 GtkWidget * owner_label;
173 GtkWidget * owner_choice;
174 GtkWidget * job_label;
176 GtkWidget * job_choice;
177 GtkWidget * billing_id_entry;
178 GtkWidget * terms_menu;
181 GtkWidget * proj_frame;
182 GtkWidget * proj_cust_box;
183 GtkWidget * proj_cust_choice;
184 GtkWidget * proj_job_box;
185 GtkWidget * proj_job_choice;
188 GtkWidget * to_charge_frame;
189 GtkWidget * to_charge_edit;
194 GnucashRegister * reg;
195 GncEntryLedger * ledger;
197 invoice_sort_type_t last_sort;
199 InvoiceDialogType dialog_type;
201 gboolean is_credit_note;
204 GncInvoice * created_invoice;
217 gboolean reset_tax_tables;
221void gnc_invoice_window_active_toggled_cb (GtkWidget *widget, gpointer data);
222gboolean gnc_invoice_window_leave_notes_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data);
223DialogQueryView *gnc_invoice_show_docs_due (GtkWindow *parent,
QofBook *book,
double days_in_advance, GncWhichDueType duetype);
225#define INV_WIDTH_PREFIX "invoice_reg"
226#define BILL_WIDTH_PREFIX "bill_reg"
227#define VOUCHER_WIDTH_PREFIX "voucher_reg"
229static void gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget);
230static InvoiceWindow * gnc_ui_invoice_modify (GtkWindow *parent, GncInvoice *invoice);
236iw_get_window (InvoiceWindow *iw)
244gnc_invoice_get_register (InvoiceWindow *iw)
247 return (GtkWidget *)iw->reg;
252gnc_invoice_get_notes (InvoiceWindow *iw)
255 return (GtkWidget *)iw->notes_text;
263iw_ask_unpost (InvoiceWindow *iw)
266 GtkToggleButton *toggle;
269 const gchar *style_label = NULL;
273 builder = gtk_builder_new();
274 gnc_builder_add_from_file (builder,
"dialog-invoice.glade",
"unpost_message_dialog");
275 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"unpost_message_dialog"));
276 toggle = GTK_TOGGLE_BUTTON(gtk_builder_get_object (builder,
"yes_tt_reset"));
280 case GNC_OWNER_VENDOR:
281 style_label =
"gnc-class-vendors";
283 case GNC_OWNER_EMPLOYEE:
284 style_label =
"gnc-class-employees";
287 style_label =
"gnc-class-customers";
291 gnc_widget_style_context_add_class (GTK_WIDGET(dialog), style_label);
293 gtk_window_set_transient_for (GTK_WINDOW(dialog),
294 GTK_WINDOW(iw_get_window(iw)));
296 iw->reset_tax_tables = FALSE;
298 gtk_widget_show_all(dialog);
300 response = gtk_dialog_run(GTK_DIALOG(dialog));
301 if (response == GTK_RESPONSE_OK)
302 iw->reset_tax_tables =
303 gtk_toggle_button_get_active(toggle);
305 gtk_widget_destroy(dialog);
306 g_object_unref(G_OBJECT(builder));
308 return (response == GTK_RESPONSE_OK);
315iw_get_invoice (InvoiceWindow *iw)
320 return gncInvoiceLookup (iw->book, &iw->invoice_guid);
324gnc_invoice_window_get_invoice (InvoiceWindow *iw)
329 return iw_get_invoice (iw);
333gnc_invoice_window_get_doclink_button (InvoiceWindow *iw)
338 return iw->doclink_button;
342set_gncEntry_switch_type (gpointer data, gpointer user_data)
344 GncEntry *entry = data;
351set_gncEntry_date(gpointer data, gpointer user_data)
353 GncEntry *entry = data;
363static void gnc_ui_to_invoice (InvoiceWindow *iw, GncInvoice *invoice)
365 GtkTextBuffer* text_buffer;
366 GtkTextIter start, end;
369 gboolean is_credit_note = gncInvoiceGetIsCreditNote (invoice);
371 if (iw->dialog_type == VIEW_INVOICE)
374 gnc_suspend_gui_refresh ();
376 gncInvoiceBeginEdit (invoice);
378 if (iw->active_check)
379 gncInvoiceSetActive (invoice, gtk_toggle_button_get_active
380 (GTK_TOGGLE_BUTTON (iw->active_check)));
382 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(iw->notes_text));
383 gtk_text_buffer_get_bounds (text_buffer, &start, &end);
384 text = gtk_text_buffer_get_text (text_buffer, &start, &end, FALSE);
385 gncInvoiceSetNotes (invoice, text);
387 if (iw->to_charge_edit)
388 gncInvoiceSetToChargeAmount (invoice,
389 gnc_amount_edit_get_amount
390 (GNC_AMOUNT_EDIT (iw->to_charge_edit)));
392 time = gnc_date_edit_get_date (GNC_DATE_EDIT (iw->opened_date));
395 if (iw->dialog_type != EDIT_INVOICE)
397 gncInvoiceSetID (invoice, gtk_entry_get_text (GTK_ENTRY (iw->id_entry)));
398 gncInvoiceSetBillingID (invoice, gtk_entry_get_text (GTK_ENTRY (iw->billing_id_entry)));
399 gncInvoiceSetTerms (invoice, iw->terms);
401 gncInvoiceSetDateOpened (invoice, time);
403 gnc_owner_get_owner (iw->owner_choice, &(iw->owner));
405 gnc_owner_get_owner (iw->job_choice, &(iw->job));
409 gncInvoiceSetOwner (invoice, &(iw->job));
411 gncInvoiceSetOwner (invoice, &(iw->owner));
414 gncInvoiceSetCurrency (invoice, gncOwnerGetCurrency (&iw->owner));
418 gncInvoiceSetBillTo (invoice, &iw->proj_job);
420 gncInvoiceSetBillTo (invoice, &iw->proj_cust);
424 if (iw->dialog_type == NEW_INVOICE || iw->dialog_type == DUP_INVOICE)
429 g_list_foreach(gncInvoiceGetEntries(invoice),
430 &set_gncEntry_date, &time);
433 gncInvoiceSetIsCreditNote (invoice, iw->is_credit_note);
439 if (iw->dialog_type == DUP_INVOICE && iw->is_credit_note != is_credit_note)
441 g_list_foreach(gncInvoiceGetEntries(invoice),
442 &set_gncEntry_switch_type, NULL);
445 gncInvoiceCommitEdit (invoice);
446 gnc_resume_gui_refresh ();
451gnc_invoice_window_verify_ok (InvoiceWindow *iw)
461 gnc_owner_get_owner (iw->owner_choice, &(iw->owner));
462 res = gncOwnerGetName (&(iw->owner));
463 if (res == NULL || g_strcmp0 (res,
"") == 0)
465 gnc_error_dialog (GTK_WINDOW (iw_get_window(iw)),
"%s",
471 _(
"You need to supply Billing Information."));
476 res = gtk_entry_get_text (GTK_ENTRY (iw->id_entry));
477 if (g_strcmp0 (res,
"") == 0)
483 string = gncInvoiceNextID(iw->book, &(iw->owner));
484 gtk_entry_set_text (GTK_ENTRY (iw->id_entry),
string);
492gnc_invoice_window_ok_save (InvoiceWindow *iw)
494 if (!gnc_invoice_window_verify_ok (iw))
498 GncInvoice *invoice = iw_get_invoice (iw);
501 gnc_ui_to_invoice (iw, invoice);
504 iw->created_invoice = invoice;
510gnc_invoice_window_ok_cb (GtkWidget *widget, gpointer data)
512 InvoiceWindow *iw = data;
514 if (!gnc_invoice_window_ok_save (iw))
524 if ((iw->dialog_type == NEW_INVOICE || iw->dialog_type == DUP_INVOICE)
525 && iw->created_invoice)
528 gnc_close_gui_component (iw->component_id);
532gnc_invoice_window_cancel_cb (GtkWidget *widget, gpointer data)
534 InvoiceWindow *iw = data;
536 gnc_close_gui_component (iw->component_id);
540gnc_invoice_window_help_cb (GtkWidget *widget, gpointer data)
542 InvoiceWindow *iw = data;
547 case GNC_OWNER_CUSTOMER:
548 gnc_gnome_help (GTK_WINDOW(iw->dialog), DF_MANUAL, DL_USAGE_INVOICE);
550 case GNC_OWNER_VENDOR:
551 gnc_gnome_help (GTK_WINDOW(iw->dialog), DF_MANUAL, DL_USAGE_BILL);
554 gnc_gnome_help (GTK_WINDOW(iw->dialog), DF_MANUAL, DL_USAGE_VOUCHER);
560gnc_invoice_window_get_state_group (InvoiceWindow *iw)
564 case GNC_OWNER_VENDOR:
565 return "Vendor documents";
567 case GNC_OWNER_EMPLOYEE:
568 return "Employee documents";
571 return "Customer documents";
580gnc_invoice_window_save_document_layout_to_user_state (InvoiceWindow *iw)
583 const gchar *group = gnc_invoice_window_get_state_group (iw);
592gnc_invoice_window_reset_document_layout_and_clear_user_state (InvoiceWindow *iw)
594 GnucashRegister *reg = iw->reg;
595 const gchar *group = gnc_invoice_window_get_state_group (iw);
597 gnucash_register_reset_sheet_layout (reg);
606gnc_invoice_window_document_has_user_state (InvoiceWindow *iw)
609 const gchar *group = gnc_invoice_window_get_state_group (iw);
610 return g_key_file_has_group (state_file, group);
614gnc_invoice_window_destroy_cb (GtkWidget *widget, gpointer data)
616 InvoiceWindow *iw = data;
617 GncInvoice *invoice = iw_get_invoice (iw);
619 gnc_suspend_gui_refresh ();
621 if ((iw->dialog_type == NEW_INVOICE || iw->dialog_type == DUP_INVOICE)
625 gncInvoiceBeginEdit (invoice);
626 gncInvoiceDestroy (invoice);
630 gtk_widget_destroy(widget);
632 gnc_unregister_gui_component (iw->component_id);
633 g_object_unref (G_OBJECT (iw->builder));
634 gnc_resume_gui_refresh ();
640gnc_invoice_window_editCB (GtkWindow *parent, gpointer data)
642 InvoiceWindow *iw = data;
643 GncInvoice *invoice = iw_get_invoice (iw);
646 gnc_ui_invoice_modify (parent, invoice);
650gnc_invoice_window_duplicateInvoiceCB (GtkWindow *parent, gpointer data)
652 InvoiceWindow *iw = data;
653 GncInvoice *invoice = iw_get_invoice (iw);
656 gnc_ui_invoice_duplicate (parent, invoice, TRUE, NULL);
659void gnc_invoice_window_entryUpCB (GtkWidget *widget, gpointer data)
661 InvoiceWindow *iw = data;
662 if (!iw || !iw->ledger)
667void gnc_invoice_window_entryDownCB (GtkWidget *widget, gpointer data)
669 InvoiceWindow *iw = data;
670 if (!iw || !iw->ledger)
677gnc_invoice_window_recordCB (GtkWidget *widget, gpointer data)
679 InvoiceWindow *iw = data;
681 if (!iw || !iw->ledger)
687 gnucash_register_goto_next_virt_row (iw->reg);
691gnc_invoice_window_cancelCB (GtkWidget *widget, gpointer data)
693 InvoiceWindow *iw = data;
695 if (!iw || !iw->ledger)
698 gnc_entry_ledger_cancel_cursor_changes (iw->ledger);
702gnc_invoice_window_deleteCB (GtkWidget *widget, gpointer data)
704 InvoiceWindow *iw = data;
707 if (!iw || !iw->ledger)
714 gnc_entry_ledger_cancel_cursor_changes (iw->ledger);
721 gnc_entry_ledger_cancel_cursor_changes (iw->ledger);
727 const char *message =
_(
"Are you sure you want to delete the "
729 const char *order_warn =
_(
"This entry is attached to an order and "
730 "will be deleted from that as well!");
734 if (gncEntryGetOrder (entry))
735 msg = g_strconcat (message,
"\n\n", order_warn, (
char *)NULL);
737 msg = g_strdup (message);
739 result = gnc_verify_dialog (GTK_WINDOW (iw_get_window(iw)), FALSE,
"%s", msg);
747 gnc_entry_ledger_delete_current_entry (iw->ledger);
752gnc_invoice_window_duplicateCB (GtkWidget *widget, gpointer data)
754 InvoiceWindow *iw = data;
756 if (!iw || !iw->ledger)
759 gnc_entry_ledger_duplicate_current_entry (iw->ledger);
763gnc_invoice_window_blankCB (GtkWidget *widget, gpointer data)
765 InvoiceWindow *iw = data;
767 if (!iw || !iw->ledger)
774 VirtualCellLocation vcell_loc;
782 gnucash_register_goto_virt_cell (iw->reg, vcell_loc);
794update_progress_bar (gpointer user_data)
797 GtkProgressBar *pb = args->pb;
798 gdouble frac = gtk_progress_bar_get_fraction (pb);
799 gdouble step = 0.1 / (args->timeout);
805 gtk_dialog_response (GTK_DIALOG(args->dialog), GTK_RESPONSE_OK);
808 gtk_progress_bar_set_fraction (pb, frac);
813combo_popped_cb (GObject *gobject,
817 gboolean popup_shown;
819 g_object_get (G_OBJECT(gobject),
"popup-shown", &popup_shown, NULL);
822 g_source_remove_by_user_data (user_data);
826dialog_key_press_event_cb (GtkWidget *widget, GdkEventKey *event,
829 g_source_remove_by_user_data (user_data);
834combo_changed_cb (GtkComboBox *widget, gpointer user_data)
836 g_source_remove_by_user_data (user_data);
845use_default_report_template_or_change (GtkWindow *parent)
847 QofBook *book = gnc_get_current_book ();
851 GtkWidget *ok_button;
852 GtkWidget *report_combo_hbox;
853 GtkWidget *progress_bar;
855 gchar *ret_guid = NULL;
856 gchar *rep_guid = NULL;
857 gchar *rep_name = NULL;
858 gboolean warning_visible = FALSE;
865 combo = gnc_default_invoice_report_combo (
"gnc:custom-report-invoice-template-guids");
868 rep_guid = gnc_get_default_invoice_print_report ();
870 gnc_report_combo_set_active (GNC_REPORT_COMBO(combo),
876 warning_visible = gnc_report_combo_is_warning_visible_for_active (GNC_REPORT_COMBO(combo));
879 if (timeout == 0 && !warning_visible)
880 return gnc_get_default_invoice_print_report ();
882 builder = gtk_builder_new ();
883 gnc_builder_add_from_file (builder,
"dialog-invoice.glade",
"invoice_print_dialog");
885 dialog = GTK_WIDGET(gtk_builder_get_object (builder,
"invoice_print_dialog"));
887 gtk_window_set_transient_for (GTK_WINDOW(dialog), parent);
889 gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_OK);
891 ok_button = GTK_WIDGET(gtk_builder_get_object (builder,
"ok_button"));
892 report_combo_hbox = GTK_WIDGET(gtk_builder_get_object (builder,
"report_combo_hbox"));
893 progress_bar = GTK_WIDGET(gtk_builder_get_object (builder,
"progress_bar"));
894 label = GTK_WIDGET(gtk_builder_get_object (builder,
"label"));
896 gtk_box_pack_start (GTK_BOX(report_combo_hbox), GTK_WIDGET(combo), TRUE, TRUE, 0);
898 gtk_widget_grab_focus (ok_button);
900 gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress_bar), 1);
903 args->dialog = dialog;
904 args->pb = GTK_PROGRESS_BAR(progress_bar);
905 args->timeout = timeout;
907 gtk_widget_show_all (dialog);
909 g_object_unref (G_OBJECT(builder));
911 g_signal_connect (G_OBJECT(combo),
"changed",
912 G_CALLBACK(combo_changed_cb), args);
914 g_signal_connect (G_OBJECT(dialog),
"key_press_event",
915 G_CALLBACK(dialog_key_press_event_cb), args);
917 g_signal_connect (G_OBJECT(combo),
"notify::popup-shown",
918 G_CALLBACK (combo_popped_cb), args);
923 gtk_label_set_text (GTK_LABEL(label),
924 N_(
"Choose a different report template or Printable Invoice will be used"));
925 gtk_widget_hide (GTK_WIDGET(progress_bar));
928 g_timeout_add (100, update_progress_bar, args);
930 result = gtk_dialog_run (GTK_DIALOG(dialog));
932 g_source_remove_by_user_data (args);
934 if (result == GTK_RESPONSE_OK)
935 ret_guid = gnc_report_combo_get_active_guid (GNC_REPORT_COMBO(combo));
937 gtk_widget_destroy (dialog);
944gnc_invoice_window_print_invoice (GtkWindow *parent, GncInvoice *invoice,
945 const gchar *report_guid)
952 const gchar *use_report_guid = NULL;
955 g_return_val_if_fail (invoice, NULL);
957 is_invoice_guid = scm_c_eval_string (
"gnc:report-is-invoice-report?");
958 scm_guid = scm_from_utf8_string (report_guid);
960 if (scm_is_false (scm_call_1 (is_invoice_guid, scm_guid)))
961 use_report_guid = gnc_get_builtin_default_invoice_print_report ();
963 use_report_guid = report_guid;
965 func = scm_c_eval_string (
"gnc:invoice-report-create");
966 g_return_val_if_fail (scm_is_procedure (func), NULL);
968 arg = SWIG_NewPointerObj(invoice, SWIG_TypeQuery(
"_p__gncInvoice"), 0);
969 arg2 = scm_from_utf8_string (use_report_guid);
970 args = scm_cons2 (arg, arg2, args);
974 arg = scm_apply (func, args, SCM_EOL);
975 g_return_val_if_fail (scm_is_exact (arg), NULL);
976 report_id = scm_to_int (arg);
988equal_fn (gpointer
find_data, gpointer elt_data)
1000gnc_invoice_window_printCB (GtkWindow* parent, gpointer data)
1002 InvoiceWindow *iw = data;
1004 if (gnc_find_first_gui_component (WINDOW_REPORT_CM_CLASS, equal_fn,
1006 gnc_plugin_page_report_reload (GNC_PLUGIN_PAGE_REPORT (iw->reportPage));
1009 gchar *report_guid = use_default_report_template_or_change (parent);
1014 iw->reportPage = gnc_invoice_window_print_invoice (parent,
1015 iw_get_invoice (iw),
1017 g_free (report_guid);
1023gnc_dialog_post_invoice(InvoiceWindow *iw,
char *message,
1025 char **memo,
Account **acc, gboolean *accumulate)
1027 GncInvoice *invoice;
1028 char *ddue_label, *post_label, *acct_label, *question_label;
1029 GList * acct_types = NULL;
1030 GList * acct_commodities = NULL;
1032 EntryList *entries, *entries_iter;
1034 invoice = iw_get_invoice (iw);
1038 ddue_label =
_(
"Due Date");
1039 post_label =
_(
"Post Date");
1040 acct_label =
_(
"Post to Account");
1041 question_label =
_(
"Accumulate Splits?");
1050 entries = gncInvoiceGetEntries (invoice);
1059 if (entries && ((gncInvoiceGetOwnerType (invoice) == GNC_OWNER_VENDOR) ||
1060 (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_EMPLOYEE)))
1063 for (entries_iter = entries; entries_iter != NULL; entries_iter = g_list_next(entries_iter))
1066 if (entrydate > *postdate)
1067 *postdate = entrydate;
1078 "invoice-last-posted-account", &guid,
1085 if (!gnc_dialog_dates_acct_question_parented (iw_get_window(iw), message, ddue_label,
1086 post_label, acct_label, question_label, TRUE, TRUE,
1087 acct_types, acct_commodities, iw->book, iw->terms,
1088 ddue, postdate, memo, acc, accumulate))
1100 gboolean accumulate;
1107 GncInvoice *invoice;
1108 char *message, *memo;
1111 gboolean accumulate;
1114 GHashTable *foreign_currs;
1115 GHashTableIter foreign_currs_iter;
1117 gboolean is_cust_doc, auto_pay;
1118 gboolean show_dialog = TRUE;
1119 gboolean post_ok = TRUE;
1122 if (!gnc_invoice_window_verify_ok (iw))
1125 invoice = iw_get_invoice (iw);
1130 if (gncInvoiceGetEntries (invoice) == NULL)
1132 gnc_error_dialog (GTK_WINDOW (iw_get_window(iw)),
"%s",
1133 _(
"The Invoice must have at least one Entry."));
1137 is_cust_doc = (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_CUSTOMER);
1144 ddue = post_params->ddue;
1145 postdate = post_params->postdate;
1147 memo = g_strdup (post_params->memo);
1148 acc = post_params->acc;
1149 accumulate = post_params->accumulate;
1153 message =
_(
"Do you really want to post the invoice?");
1154 if (!gnc_dialog_post_invoice(iw, message,
1155 &ddue, &postdate, &memo, &acc, &accumulate))
1165 gnc_suspend_gui_refresh ();
1166 gncInvoiceBeginEdit (invoice);
1167 gnc_invoice_window_ok_save (iw);
1168 gncInvoiceSetCurrency (invoice, gncOwnerGetCurrency (gncInvoiceGetOwner (invoice)));
1171 text =
_(
"One or more of the entries are for accounts different from the invoice/bill currency. You will be asked to enter a conversion rate for each.");
1176 g_hash_table_iter_init (&foreign_currs_iter, foreign_currs);
1177 while (g_hash_table_iter_next (&foreign_currs_iter, &key, &value))
1179 GNCPrice *convprice;
1180 gnc_commodity *account_currency = (gnc_commodity*)key;
1181 gnc_numeric *amount = (gnc_numeric*)value;
1183 gnc_numeric exch_rate;
1191 gnc_info_dialog(GTK_WINDOW (iw_get_window(iw)),
"%s", text);
1192 show_dialog = FALSE;
1208 xfer = gnc_xfer_dialog (iw_get_window(iw), acc);
1209 gnc_xfer_dialog_is_exchange_dialog(xfer, &exch_rate);
1210 gnc_xfer_dialog_select_to_currency(xfer, account_currency);
1211 gnc_xfer_dialog_set_date (xfer, postdate);
1217 (gnc_numeric){1, 1} : *amount);
1220 convprice = gncInvoiceGetPrice (invoice, account_currency);
1223 exch_rate = gnc_price_get_value (convprice);
1229 gnc_xfer_dialog_set_price_edit (xfer, exch_rate);
1235 gnc_xfer_dialog_set_from_show_button_active(xfer, FALSE);
1236 gnc_xfer_dialog_set_to_show_button_active(xfer, FALSE);
1237 gnc_xfer_dialog_hide_from_account_tree(xfer);
1238 gnc_xfer_dialog_hide_to_account_tree(xfer);
1239 if (gnc_xfer_dialog_run_until_done(xfer))
1248 gnc_price_begin_edit (convprice);
1249 gnc_price_set_commodity (convprice, account_currency);
1250 gnc_price_set_currency (convprice, gncInvoiceGetCurrency (invoice));
1251 gnc_price_set_time64 (convprice, postdate);
1252 gnc_price_set_source (convprice, PRICE_SOURCE_TEMP);
1253 gnc_price_set_typestr (convprice, PRICE_TYPE_LAST);
1254 gnc_price_set_value (convprice, exch_rate);
1255 gncInvoiceAddPrice(invoice, convprice);
1256 gnc_price_commit_edit (convprice);
1275 "invoice-last-posted-account", guid,
1289 gncInvoiceCommitEdit (invoice);
1290 g_hash_table_unref (foreign_currs);
1291 gnc_resume_gui_refresh ();
1299 iw->dialog_type = VIEW_INVOICE;
1300 gnc_entry_ledger_set_readonly (iw->ledger, TRUE);
1304 text =
_(
"The post action was canceled because not all exchange rates were given.");
1305 gnc_info_dialog(GTK_WINDOW (iw_get_window(iw)),
"%s", text);
1309 gnc_invoice_update_window (iw, NULL);
1314gnc_invoice_window_postCB (GtkWidget *unused_widget, gpointer data)
1316 InvoiceWindow *iw =data;
1317 gnc_invoice_post(iw, NULL);
1321gnc_invoice_window_unpostCB (GtkWidget *widget, gpointer data)
1323 InvoiceWindow *iw = data;
1324 GncInvoice *invoice;
1327 invoice = iw_get_invoice (iw);
1332 result = iw_ask_unpost(iw);
1333 if (!result)
return;
1336 gnc_suspend_gui_refresh ();
1338 gnc_resume_gui_refresh ();
1339 if (!result)
return;
1342 iw->dialog_type = EDIT_INVOICE;
1343 gnc_entry_ledger_set_readonly (iw->ledger, FALSE);
1344 gnc_invoice_update_window (iw, NULL);
1348void gnc_invoice_window_cut_cb (GtkWidget *widget, gpointer data)
1350 InvoiceWindow *iw = data;
1351 gnucash_register_cut_clipboard (iw->reg);
1354void gnc_invoice_window_copy_cb (GtkWidget *widget, gpointer data)
1356 InvoiceWindow *iw = data;
1357 gnucash_register_copy_clipboard (iw->reg);
1360void gnc_invoice_window_paste_cb (GtkWidget *widget, gpointer data)
1362 InvoiceWindow *iw = data;
1363 gnucash_register_paste_clipboard (iw->reg);
1366void gnc_invoice_window_new_invoice_cb (GtkWindow *parent, gpointer data)
1368 InvoiceWindow *iw = data;
1371 gnc_ui_invoice_new (parent, &iw->job, iw->book);
1375 gnc_ui_invoice_new (parent, &iw->owner, iw->book);
1379void gnc_business_call_owner_report (GtkWindow *parent,
GncOwner *owner,
Account *acc)
1381 gnc_business_call_owner_report_with_enddate (parent, owner, acc, INT64_MAX);
1384void gnc_business_call_owner_report_with_enddate (GtkWindow *parent,
1394 g_return_if_fail (owner);
1398 func = scm_c_eval_string (
"gnc:owner-report-create-with-enddate");
1399 g_return_if_fail (scm_is_procedure (func));
1402 arg = (enddate != INT64_MAX) ? scm_from_int64 (enddate) : SCM_BOOL_F;
1403 args = scm_cons (arg, args);
1407 swig_type_info * qtype = SWIG_TypeQuery(
"_p_Account");
1408 g_return_if_fail (qtype);
1410 arg = SWIG_NewPointerObj(acc, qtype, 0);
1411 g_return_if_fail (arg != SCM_UNDEFINED);
1412 args = scm_cons (arg, args);
1416 args = scm_cons (SCM_BOOL_F, args);
1419 arg = SWIG_NewPointerObj(owner, SWIG_TypeQuery(
"_p__gncOwner"), 0);
1420 g_return_if_fail (arg != SCM_UNDEFINED);
1421 args = scm_cons (arg, args);
1424 arg = scm_apply (func, args, SCM_EOL);
1425 g_return_if_fail (scm_is_exact (arg));
1426 id = scm_to_int (arg);
1429 reportWindow (
id, parent);
1432void gnc_invoice_window_report_owner_cb (GtkWindow *parent, gpointer data)
1434 InvoiceWindow *iw = data;
1435 gnc_business_call_owner_report (parent, &iw->owner, NULL);
1438void gnc_invoice_window_payment_cb (GtkWindow *parent, gpointer data)
1440 InvoiceWindow *iw = data;
1441 GncInvoice *invoice = iw_get_invoice(iw);
1444 gnc_ui_payment_new_with_invoice (parent, &iw->job, iw->book, invoice);
1446 gnc_ui_payment_new_with_invoice (parent, &iw->owner, iw->book, invoice);
1452gnc_invoice_window_sort (InvoiceWindow *iw, invoice_sort_type_t sort_code)
1454 QofQuery *query = gnc_entry_ledger_get_query (iw->ledger);
1455 GSList *p1 = NULL, *p2 = NULL, *p3 = NULL, *standard;
1457 if (iw->last_sort == sort_code)
1464 case INVSORT_BY_STANDARD:
1467 case INVSORT_BY_DATE:
1468 p1 = g_slist_prepend (p1, ENTRY_DATE);
1471 case INVSORT_BY_DATE_ENTERED:
1472 p1 = g_slist_prepend (p1, ENTRY_DATE_ENTERED);
1475 case INVSORT_BY_DESC:
1476 p1 = g_slist_prepend (p1, ENTRY_DESC);
1479 case INVSORT_BY_QTY:
1480 p1 = g_slist_prepend (p1, ENTRY_QTY);
1483 case INVSORT_BY_PRICE:
1484 p1 = g_slist_prepend (p1, ((iw->owner.type == GNC_OWNER_CUSTOMER) ?
1485 ENTRY_IPRICE : ENTRY_BPRICE));
1489 g_slist_free (standard);
1490 g_return_if_fail (FALSE);
1495 iw->last_sort = sort_code;
1496 gnc_entry_ledger_display_refresh (iw->ledger);
1502gnc_invoice_window_active_toggled_cb (GtkWidget *widget, gpointer data)
1504 InvoiceWindow *iw = data;
1505 GncInvoice *invoice = iw_get_invoice(iw);
1507 if (!invoice)
return;
1509 gncInvoiceSetActive (invoice,
1510 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
1514gnc_invoice_window_leave_notes_cb (GtkWidget *widget, GdkEventFocus *event,
1517 InvoiceWindow *iw = data;
1518 GncInvoice *invoice = iw_get_invoice(iw);
1519 GtkTextBuffer* text_buffer;
1520 GtkTextIter start, end;
1523 if (!invoice)
return FALSE;
1525 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(iw->notes_text));
1526 gtk_text_buffer_get_bounds (text_buffer, &start, &end);
1527 text = gtk_text_buffer_get_text (text_buffer, &start, &end, FALSE);
1528 gncInvoiceSetNotes (invoice, text);
1534gnc_invoice_window_leave_to_charge_cb (GtkWidget *widget, GdkEventFocus *event,
1537 gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT(data), NULL);
1542gnc_invoice_window_changed_to_charge_cb (GtkWidget *widget, gpointer data)
1544 InvoiceWindow *iw = data;
1545 GncInvoice *invoice = iw_get_invoice(iw);
1547 if (!invoice)
return;
1549 gncInvoiceSetToChargeAmount (invoice, gnc_amount_edit_get_amount
1550 (GNC_AMOUNT_EDIT (widget)));
1554add_summary_label (GtkWidget *summarybar,
const char *label_str)
1559 hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
1560 gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
1561 gtk_box_pack_start (GTK_BOX(summarybar), hbox, FALSE, FALSE, 5);
1563 label = gtk_label_new (label_str);
1564 gnc_label_set_alignment (label, 1.0, 0.5);
1565 gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
1567 label = gtk_label_new (
"");
1568 gnc_label_set_alignment (label, 1.0, 0.5);
1569 gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
1575gnc_invoice_window_create_summary_bar (InvoiceWindow *iw)
1577 GtkWidget *summarybar;
1579 iw->total_label = NULL;
1580 iw->total_cash_label = NULL;
1581 iw->total_charge_label = NULL;
1582 iw->total_subtotal_label = NULL;
1583 iw->total_tax_label = NULL;
1585 summarybar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
1586 gtk_box_set_homogeneous (GTK_BOX (summarybar), FALSE);
1587 gtk_widget_set_name (summarybar,
"gnc-id-summarybar");
1589 iw->total_label = add_summary_label (summarybar,
_(
"Total:"));
1593 case GNC_OWNER_CUSTOMER:
1594 case GNC_OWNER_VENDOR:
1595 iw->total_subtotal_label = add_summary_label (summarybar,
_(
"Subtotal:"));
1596 iw->total_tax_label = add_summary_label (summarybar,
_(
"Tax:"));
1599 case GNC_OWNER_EMPLOYEE:
1600 iw->total_cash_label = add_summary_label (summarybar,
_(
"Total Cash:"));
1601 iw->total_charge_label = add_summary_label (summarybar,
_(
"Total Charge:"));
1608 gtk_widget_show_all(summarybar);
1613gnc_invoice_job_changed_cb (GtkWidget *widget, gpointer data)
1615 InvoiceWindow *iw = data;
1616 char const *msg =
"";
1621 if (iw->dialog_type == VIEW_INVOICE)
1624 gnc_owner_get_owner (iw->job_choice, &(iw->job));
1626 if (iw->dialog_type == EDIT_INVOICE)
1630 gtk_entry_set_text (GTK_ENTRY (iw->billing_id_entry), msg ? msg :
"");
1636static GNCSearchWindow *
1637gnc_invoice_select_job_cb (GtkWindow *parent, gpointer jobp, gpointer user_data)
1640 InvoiceWindow *iw = user_data;
1643 if (!iw)
return NULL;
1647 ownerp = gncJobGetOwner (j);
1648 gncOwnerCopy (ownerp, &owner);
1651 gncOwnerCopy (&(iw->owner), &owner);
1653 return gnc_job_search (parent, j, &owner, iw->book);
1657gnc_invoice_update_job_choice (InvoiceWindow *iw)
1660 gtk_container_remove (GTK_CONTAINER (iw->job_box), iw->job_choice);
1663 if (iw->owner.owner.undefined == NULL)
1665 iw->job_choice = NULL;
1668 switch (iw->dialog_type)
1673 gnc_owner_edit_create (NULL, iw->job_box, iw->book, &(iw->job));
1679 gnc_general_search_new (GNC_JOB_MODULE_NAME,
_(
"Select…"), TRUE,
1680 gnc_invoice_select_job_cb, iw, iw->book);
1682 gnc_general_search_set_selected (GNC_GENERAL_SEARCH (iw->job_choice),
1684 gnc_general_search_allow_clear (GNC_GENERAL_SEARCH (iw->job_choice),
1686 gtk_box_pack_start (GTK_BOX (iw->job_box), iw->job_choice,
1689 g_signal_connect (G_OBJECT (iw->job_choice),
"changed",
1690 G_CALLBACK (gnc_invoice_job_changed_cb), iw);
1695 gtk_widget_show_all (iw->job_choice);
1698static GNCSearchWindow *
1699gnc_invoice_select_proj_job_cb (GtkWindow *parent, gpointer jobp, gpointer user_data)
1702 InvoiceWindow *iw = user_data;
1705 if (!iw)
return NULL;
1709 ownerp = gncJobGetOwner (j);
1710 gncOwnerCopy (ownerp, &owner);
1713 gncOwnerCopy (&(iw->proj_cust), &owner);
1715 return gnc_job_search (parent, j, &owner, iw->book);
1719gnc_invoice_proj_job_changed_cb (GtkWidget *widget, gpointer data)
1721 InvoiceWindow *iw = data;
1726 if (iw->dialog_type == VIEW_INVOICE)
1729 gnc_owner_get_owner (iw->proj_job_choice, &(iw->proj_job));
1734gnc_invoice_update_proj_job (InvoiceWindow *iw)
1736 if (iw->proj_job_choice)
1737 gtk_container_remove (GTK_CONTAINER (iw->proj_job_box),
1738 iw->proj_job_choice);
1740 switch (iw->dialog_type)
1744 iw->proj_job_choice =
1745 gnc_owner_edit_create (NULL, iw->proj_job_box, iw->book, &(iw->proj_job));
1750 if (iw->proj_cust.owner.undefined == NULL)
1752 iw->proj_job_choice = NULL;
1756 iw->proj_job_choice =
1757 gnc_general_search_new (GNC_JOB_MODULE_NAME,
_(
"Select…"), TRUE,
1758 gnc_invoice_select_proj_job_cb, iw, iw->book);
1760 gnc_general_search_set_selected (GNC_GENERAL_SEARCH(iw->proj_job_choice),
1762 gnc_general_search_allow_clear (GNC_GENERAL_SEARCH (iw->proj_job_choice),
1764 gtk_box_pack_start (GTK_BOX (iw->proj_job_box), iw->proj_job_choice,
1767 g_signal_connect (G_OBJECT (iw->proj_job_choice),
"changed",
1768 G_CALLBACK (gnc_invoice_proj_job_changed_cb), iw);
1773 if (iw->proj_job_choice)
1774 gtk_widget_show_all (iw->proj_job_choice);
1778gnc_invoice_owner_changed_cb (GtkWidget *widget, gpointer data)
1780 InvoiceWindow *iw = data;
1781 GncBillTerm *term = NULL;
1787 if (iw->dialog_type == VIEW_INVOICE)
1790 gncOwnerCopy (&(iw->owner), &owner);
1791 gnc_owner_get_owner (iw->owner_choice, &owner);
1796 gncOwnerCopy (&owner, &(iw->owner));
1797 gncOwnerInitJob (&(iw->job), NULL);
1798 gnc_entry_ledger_reset_query (iw->ledger);
1801 if (iw->dialog_type == EDIT_INVOICE)
1806 case GNC_OWNER_CUSTOMER:
1809 case GNC_OWNER_VENDOR:
1812 case GNC_OWNER_EMPLOYEE:
1816 g_warning (
"Unknown owner type: %d\n",
gncOwnerGetType (&(iw->owner)));
1822 gnc_simple_combo_set_value (GTK_COMBO_BOX(iw->terms_menu), iw->terms);
1824 gnc_invoice_update_job_choice (iw);
1830gnc_invoice_proj_cust_changed_cb (GtkWidget *widget, gpointer data)
1832 InvoiceWindow *iw = data;
1838 if (iw->dialog_type == VIEW_INVOICE)
1841 gncOwnerCopy (&(iw->proj_cust), &owner);
1842 gnc_owner_get_owner (iw->proj_cust_choice, &owner);
1847 gncOwnerCopy (&owner, &(iw->proj_cust));
1848 gncOwnerInitJob (&(iw->proj_job), NULL);
1851 if (iw->dialog_type == EDIT_INVOICE)
1854 gnc_invoice_update_proj_job (iw);
1860gnc_invoice_dialog_close_handler (gpointer user_data)
1862 InvoiceWindow *iw = user_data;
1866 gtk_widget_destroy (iw->dialog);
1871gnc_invoice_window_close_handler (gpointer user_data)
1873 InvoiceWindow *iw = user_data;
1883gnc_invoice_reset_total_label (GtkLabel *label, gnc_numeric amt, gnc_commodity *com)
1892 gtk_label_set_text (label, bidi_string);
1893 g_free (bidi_string);
1897gnc_invoice_redraw_all_cb (GnucashRegister *g_reg, gpointer data)
1899 InvoiceWindow *iw = data;
1900 GncInvoice * invoice;
1901 gnc_commodity * currency;
1902 gnc_numeric amount, to_charge_amt = gnc_numeric_zero();
1910 invoice = iw_get_invoice (iw);
1914 currency = gncInvoiceGetCurrency (invoice);
1916 if (iw->total_label)
1919 gnc_invoice_reset_total_label (GTK_LABEL (iw->total_label), amount, currency);
1922 if (iw->total_subtotal_label)
1924 amount = gncInvoiceGetTotalSubtotal (invoice);
1925 gnc_invoice_reset_total_label (GTK_LABEL (iw->total_subtotal_label), amount, currency);
1928 if (iw->total_tax_label)
1930 amount = gncInvoiceGetTotalTax (invoice);
1931 gnc_invoice_reset_total_label (GTK_LABEL (iw->total_tax_label), amount, currency);
1936 if (iw->to_charge_edit)
1938 gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (iw->to_charge_edit), NULL);
1939 to_charge_amt = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(iw->to_charge_edit));
1942 if (iw->total_cash_label)
1944 amount = gncInvoiceGetTotalOf (invoice, GNC_PAYMENT_CASH);
1947 gnc_invoice_reset_total_label (GTK_LABEL (iw->total_cash_label), amount, currency);
1950 if (iw->total_charge_label)
1952 amount = gncInvoiceGetTotalOf (invoice, GNC_PAYMENT_CARD);
1955 gnc_invoice_reset_total_label (GTK_LABEL (iw->total_charge_label), amount, currency);
1960gnc_invoice_window_changed (InvoiceWindow *iw, GtkWidget *window)
1962 gnc_entry_ledger_set_parent(iw->ledger, window);
1966gnc_invoice_get_help (InvoiceWindow *iw)
1975gnc_invoice_window_refresh_handler (GHashTable *changes, gpointer user_data)
1977 InvoiceWindow *iw = user_data;
1979 GncInvoice *invoice = iw_get_invoice (iw);
1985 gnc_close_gui_component (iw->component_id);
1992 info = gnc_gui_get_entity_events (changes, &iw->invoice_guid);
1993 if (info && (info->event_mask & QOF_EVENT_DESTROY))
1995 gnc_close_gui_component (iw->component_id);
2001 owner = gncInvoiceGetOwner (invoice);
2008 owner = gncInvoiceGetBillTo (invoice);
2013 gnc_invoice_update_window (iw, NULL);
2027gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
2029 GtkWidget *acct_entry;
2030 GncInvoice *invoice;
2031 gboolean is_posted = FALSE;
2032 gboolean can_unpost = FALSE;
2034 invoice = iw_get_invoice (iw);
2036 if (iw->owner_choice)
2037 gtk_container_remove (GTK_CONTAINER (iw->owner_box), iw->owner_choice);
2039 if (iw->proj_cust_choice)
2040 gtk_container_remove (GTK_CONTAINER (iw->proj_cust_box),
2041 iw->proj_cust_choice);
2043 switch (iw->dialog_type)
2048 gnc_owner_edit_create (iw->owner_label, iw->owner_box, iw->book,
2050 iw->proj_cust_choice =
2051 gnc_owner_edit_create (NULL, iw->proj_cust_box, iw->book,
2058 gnc_owner_select_create (iw->owner_label, iw->owner_box, iw->book,
2060 iw->proj_cust_choice =
2061 gnc_owner_select_create (NULL, iw->proj_cust_box, iw->book,
2064 g_signal_connect (G_OBJECT (iw->owner_choice),
"changed",
2065 G_CALLBACK (gnc_invoice_owner_changed_cb), iw);
2067 g_signal_connect (G_OBJECT (iw->proj_cust_choice),
"changed",
2068 G_CALLBACK (gnc_invoice_proj_cust_changed_cb), iw);
2074 gtk_label_set_text (GTK_LABEL(iw->type_label), iw->is_credit_note ?
_(
"Credit Note")
2075 : gtk_label_get_text (GTK_LABEL(iw->type_label)));
2077 if (iw->owner_choice)
2078 gtk_widget_show_all (iw->owner_choice);
2079 if (iw->proj_cust_choice)
2080 gtk_widget_show_all (iw->proj_cust_choice);
2082 gnc_invoice_update_job_choice (iw);
2083 gnc_invoice_update_proj_job (iw);
2086 if (iw->owner.type == GNC_OWNER_CUSTOMER)
2087 gtk_widget_hide (iw->proj_frame);
2090 if (iw->owner.type == GNC_OWNER_EMPLOYEE)
2092 gtk_widget_hide (iw->job_label);
2093 gtk_widget_hide (iw->job_box);
2096 acct_entry = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"acct_entry"));
2100 GtkTextBuffer* text_buffer;
2105 gtk_entry_set_text (GTK_ENTRY (iw->id_entry), gncInvoiceGetID (invoice));
2107 gtk_entry_set_text (GTK_ENTRY (iw->billing_id_entry),
2108 gncInvoiceGetBillingID (invoice));
2110 string = gncInvoiceGetNotes (invoice);
2111 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(iw->notes_text));
2112 gtk_text_buffer_set_text (text_buffer,
string, -1);
2114 if (iw->active_check)
2115 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (iw->active_check),
2116 gncInvoiceGetActive (invoice));
2118 time = gncInvoiceGetDateOpened (invoice);
2119 if (time == INT64_MAX)
2121 gnc_date_edit_set_time (GNC_DATE_EDIT (iw->opened_date),
2126 gnc_date_edit_set_time (GNC_DATE_EDIT (iw->opened_date), time);
2130 iw->terms = gncInvoiceGetTerms (invoice);
2132 switch (iw->dialog_type)
2137 gnc_simple_combo_set_value (GTK_COMBO_BOX(iw->terms_menu), iw->terms);
2143 if(gncBillTermGetName (iw->terms) != NULL)
2144 gtk_entry_set_text (GTK_ENTRY (iw->terms_menu),gncBillTermGetName (iw->terms));
2146 gtk_entry_set_text (GTK_ENTRY (iw->terms_menu),
"None");
2158 is_posted = gncInvoiceIsPosted (invoice);
2161 Account *acct = gncInvoiceGetPostedAcc (invoice);
2169 time = gncInvoiceGetDatePosted (invoice);
2170 gnc_date_edit_set_time (GNC_DATE_EDIT (iw->posted_date), time);
2173 gtk_entry_set_text (GTK_ENTRY (acct_entry), tmp_string);
2178 gnc_invoice_id_changed_cb(NULL, iw);
2179 if (iw->dialog_type == NEW_INVOICE ||
2180 iw->dialog_type == DUP_INVOICE ||
2181 iw->dialog_type == MOD_INVOICE)
2184 gtk_widget_show (widget);
2186 gtk_widget_show (iw_get_window(iw));
2194 amount = gncInvoiceGetToChargeAmount (invoice);
2195 gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (iw->to_charge_edit), amount);
2201 GtkWidget *hide, *show;
2205 show = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"posted_label"));
2206 gtk_widget_show (show);
2207 gtk_widget_show (iw->posted_date_hbox);
2208 show = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"acct_label"));
2209 gtk_widget_show (show);
2210 gtk_widget_show (acct_entry);
2214 hide = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"posted_label"));
2215 gtk_widget_hide (hide);
2216 gtk_widget_hide (iw->posted_date_hbox);
2218 hide = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"acct_label"));
2219 gtk_widget_hide (hide);
2220 gtk_widget_hide (acct_entry);
2229 gtk_widget_set_sensitive (iw->to_charge_edit, !is_posted);
2234 if (iw->owner.type == GNC_OWNER_EMPLOYEE)
2237 gtk_widget_set_sensitive (iw->to_charge_edit, FALSE);
2241 gtk_widget_hide (iw->to_charge_frame);
2249 gtk_widget_set_sensitive (acct_entry, FALSE);
2250 gtk_widget_set_sensitive (iw->id_entry, FALSE);
2251 gtk_widget_set_sensitive (iw->id_entry, TRUE);
2252 gtk_widget_set_sensitive (iw->terms_menu, FALSE);
2253 gtk_widget_set_sensitive (iw->owner_box, TRUE);
2254 gtk_widget_set_sensitive (iw->job_box, TRUE);
2255 gtk_widget_set_sensitive (iw->billing_id_entry, FALSE);
2256 gtk_widget_set_sensitive (iw->notes_text, TRUE);
2260 gtk_widget_set_sensitive (acct_entry, TRUE);
2261 gtk_widget_set_sensitive (iw->terms_menu, TRUE);
2262 gtk_widget_set_sensitive (iw->owner_box, TRUE);
2263 gtk_widget_set_sensitive (iw->job_box, TRUE);
2264 gtk_widget_set_sensitive (iw->billing_id_entry, TRUE);
2265 gtk_widget_set_sensitive (iw->notes_text, TRUE);
2269 if(gncInvoiceIsPaid (invoice))
2270 gtk_label_set_text(GTK_LABEL(iw->paid_label),
_(
"PAID"));
2272 gtk_label_set_text(GTK_LABEL(iw->paid_label),
_(
"UNPAID"));
2275 gtk_widget_show (widget);
2277 gtk_widget_show (iw_get_window(iw));
2281gnc_invoice_get_type_from_window (InvoiceWindow *iw)
2288 case GNC_OWNER_CUSTOMER:
2289 return iw->is_credit_note ? GNC_INVOICE_CUST_CREDIT_NOTE
2290 : GNC_INVOICE_CUST_INVOICE;
2292 case GNC_OWNER_VENDOR:
2293 return iw->is_credit_note ? GNC_INVOICE_VEND_CREDIT_NOTE
2294 : GNC_INVOICE_VEND_INVOICE;
2296 case GNC_OWNER_EMPLOYEE:
2297 return iw->is_credit_note ? GNC_INVOICE_EMPL_CREDIT_NOTE
2298 : GNC_INVOICE_EMPL_INVOICE;
2301 return GNC_INVOICE_UNDEFINED;
2307gnc_invoice_get_title (InvoiceWindow *iw)
2309 char *wintitle = NULL;
2310 const char *
id = NULL;
2312 if (!iw)
return NULL;
2316 case GNC_OWNER_CUSTOMER:
2317 switch (iw->dialog_type)
2320 wintitle = iw->is_credit_note ?
_(
"New Credit Note")
2326 wintitle = iw->is_credit_note ?
_(
"Edit Credit Note")
2327 :
_(
"Edit Invoice");
2330 wintitle = iw->is_credit_note ?
_(
"View Credit Note")
2331 :
_(
"View Invoice");
2335 case GNC_OWNER_VENDOR:
2336 switch (iw->dialog_type)
2339 wintitle = iw->is_credit_note ?
_(
"New Credit Note")
2345 wintitle = iw->is_credit_note ?
_(
"Edit Credit Note")
2349 wintitle = iw->is_credit_note ?
_(
"View Credit Note")
2354 case GNC_OWNER_EMPLOYEE:
2355 switch (iw->dialog_type)
2358 wintitle = iw->is_credit_note ?
_(
"New Credit Note")
2359 :
_(
"New Expense Voucher");
2364 wintitle = iw->is_credit_note ?
_(
"Edit Credit Note")
2365 :
_(
"Edit Expense Voucher");
2368 wintitle = iw->is_credit_note ?
_(
"View Credit Note")
2369 :
_(
"View Expense Voucher");
2378 id = gtk_entry_get_text (GTK_ENTRY (iw->id_entry));
2380 return g_strconcat (wintitle,
" - ",
id, (
char *)NULL);
2381 return g_strdup (wintitle);
2385gnc_invoice_type_toggled_cb (GtkWidget *widget, gpointer data)
2387 InvoiceWindow *iw = data;
2390 iw->is_credit_note = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
2394gnc_invoice_id_changed_cb (GtkWidget *unused, gpointer data)
2396 InvoiceWindow *iw = data;
2406 title = gnc_invoice_get_title (iw);
2407 gtk_window_set_title (GTK_WINDOW (iw->dialog), title);
2413gnc_invoice_terms_changed_cb (GtkWidget *widget, gpointer data)
2415 GtkComboBox *cbox = GTK_COMBO_BOX (widget);
2416 InvoiceWindow *iw = data;
2421 iw->terms = gnc_simple_combo_get_value (cbox);
2426find_handler (gpointer
find_data, gpointer user_data)
2429 InvoiceWindow *iw = user_data;
2431 return(iw &&
guid_equal(&iw->invoice_guid, invoice_guid));
2434static InvoiceWindow *
2435gnc_invoice_new_page (
QofBook *bookp, InvoiceDialogType type,
2436 GncInvoice *invoice,
const GncOwner *owner,
2437 GncMainWindow *window,
const gchar *group_name)
2443 g_assert (type != NEW_INVOICE && type != MOD_INVOICE && type != DUP_INVOICE);
2444 g_assert (invoice != NULL);
2455 iw = gnc_find_first_gui_component (DIALOG_VIEW_INVOICE_CM_CLASS,
2456 find_handler, &invoice_guid);
2467 iw = g_new0 (InvoiceWindow, 1);
2469 iw->dialog_type = type;
2471 iw->is_credit_note = gncInvoiceGetIsCreditNote (invoice);
2473 iw->page_state_name = group_name;
2479 billto = gncInvoiceGetBillTo (invoice);
2487 window = gnc_plugin_business_get_window ();
2492 gnc_invoice_redraw_all_cb(iw->reg, iw);
2497#define KEY_INVOICE_TYPE "InvoiceType"
2498#define KEY_INVOICE_GUID "InvoiceGUID"
2499#define KEY_OWNER_TYPE "OwnerType"
2500#define KEY_OWNER_GUID "OwnerGUID"
2503gnc_invoice_recreate_page (GncMainWindow *window,
2505 const gchar *group_name)
2508 GError *error = NULL;
2509 char *tmp_string = NULL, *owner_type = NULL;
2510 InvoiceDialogType type;
2511 GncInvoice *invoice;
2517 tmp_string = g_key_file_get_string(key_file, group_name,
2518 KEY_INVOICE_TYPE, &error);
2521 g_warning(
"Error reading group %s key %s: %s.",
2522 group_name, KEY_INVOICE_TYPE, error->message);
2525 type = InvoiceDialogTypefromString(tmp_string);
2529 tmp_string = g_key_file_get_string(key_file, group_name,
2530 KEY_INVOICE_GUID, &error);
2533 g_warning(
"Error reading group %s key %s: %s.",
2534 group_name, KEY_INVOICE_GUID, error->message);
2537 if (!string_to_guid(tmp_string, &guid))
2539 g_warning(
"Invalid invoice guid: %s.", tmp_string);
2542 book = gnc_get_current_book();
2543 invoice = gncInvoiceLookup(gnc_get_current_book(), &guid);
2544 if (invoice == NULL)
2546 g_warning(
"Can't find invoice %s in current book.", tmp_string);
2553 owner_type = g_key_file_get_string(key_file, group_name,
2554 KEY_OWNER_TYPE, &error);
2557 g_warning(
"Error reading group %s key %s: %s.",
2558 group_name, KEY_OWNER_TYPE, error->message);
2563 tmp_string = g_key_file_get_string(key_file, group_name,
2564 KEY_OWNER_GUID, &error);
2567 g_warning(
"Error reading group %s key %s: %s.",
2568 group_name, KEY_OWNER_GUID, error->message);
2571 if (!string_to_guid(tmp_string, &guid))
2573 g_warning(
"Invalid owner guid: %s.", tmp_string);
2577 if (!gncOwnerGetOwnerFromTypeGuid(book, &owner, owner_type, &guid))
2579 g_warning(
"Can't find owner %s in current book.", tmp_string);
2585 iw = gnc_invoice_new_page (book, type, invoice, &owner, window, group_name);
2589 g_warning(
"Giving up on restoring '%s'.", group_name);
2591 g_error_free(error);
2600gnc_invoice_save_page (InvoiceWindow *iw,
2602 const gchar *group_name)
2607 g_key_file_set_string(key_file, group_name, KEY_INVOICE_TYPE,
2608 InvoiceDialogTypeasString(iw->dialog_type));
2609 g_key_file_set_string(key_file, group_name, KEY_INVOICE_GUID, guidstr);
2613 g_key_file_set_string(key_file, group_name, KEY_OWNER_TYPE,
2616 g_key_file_set_string(key_file, group_name, KEY_OWNER_GUID, guidstr);
2620 g_key_file_set_string(key_file, group_name, KEY_OWNER_TYPE,
2623 g_key_file_set_string(key_file, group_name, KEY_OWNER_GUID, guidstr);
2630doclink_button_cb (GtkLinkButton *button, InvoiceWindow *iw)
2632 GncInvoice *invoice = gncInvoiceLookup (iw->book, &iw->invoice_guid);
2633 gnc_doclink_open_uri (GTK_WINDOW(iw->dialog), gncInvoiceGetDocLink (invoice));
2639gnc_invoice_create_page (InvoiceWindow *iw, gpointer page)
2641 GncInvoice *invoice;
2642 GtkBuilder *builder;
2643 GtkWidget *dialog, *hbox;
2644 GncEntryLedger *entry_ledger = NULL;
2645 GncOwnerType owner_type;
2646 GncEntryLedgerType ledger_type;
2647 const gchar *prefs_group = NULL;
2648 gboolean is_credit_note = FALSE;
2649 const gchar *style_label = NULL;
2650 const gchar *doclink_uri;
2652 invoice = gncInvoiceLookup (iw->book, &iw->invoice_guid);
2653 is_credit_note = gncInvoiceGetIsCreditNote (invoice);
2658 iw->builder = builder = gtk_builder_new();
2659 gnc_builder_add_from_file (builder,
"dialog-invoice.glade",
"terms_store");
2660 gnc_builder_add_from_file (builder,
"dialog-invoice.glade",
"invoice_entry_vbox");
2661 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"invoice_entry_vbox"));
2664 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, iw);
2667 iw->id_label = GTK_WIDGET (gtk_builder_get_object (builder,
"label3"));
2668 iw->type_label = GTK_WIDGET (gtk_builder_get_object (builder,
"page_type_label"));
2669 iw->info_label = GTK_WIDGET (gtk_builder_get_object (builder,
"label25"));
2670 iw->id_entry = GTK_WIDGET (gtk_builder_get_object (builder,
"page_id_entry"));
2671 iw->billing_id_entry = GTK_WIDGET (gtk_builder_get_object (builder,
"page_billing_id_entry"));
2672 iw->terms_menu = GTK_WIDGET (gtk_builder_get_object (builder,
"page_terms_menu"));
2673 iw->notes_text = GTK_WIDGET (gtk_builder_get_object (builder,
"page_notes_text"));
2674 iw->active_check = GTK_WIDGET (gtk_builder_get_object (builder,
"active_check"));
2675 iw->owner_box = GTK_WIDGET (gtk_builder_get_object (builder,
"page_owner_hbox"));
2676 iw->owner_label = GTK_WIDGET (gtk_builder_get_object (builder,
"page_owner_label"));
2677 iw->job_label = GTK_WIDGET (gtk_builder_get_object (builder,
"page_job_label"));
2678 iw->job_box = GTK_WIDGET (gtk_builder_get_object (builder,
"page_job_hbox"));
2679 iw->paid_label = GTK_WIDGET (gtk_builder_get_object (builder,
"paid_label"));
2681 iw->doclink_button = GTK_WIDGET(gtk_builder_get_object (builder,
"doclink_button"));
2682 g_signal_connect (G_OBJECT (iw->doclink_button),
"activate-link",
2683 G_CALLBACK (doclink_button_cb), iw);
2686 doclink_uri = gncInvoiceGetDocLink (invoice);
2689 gchar *display_uri = gnc_doclink_get_unescaped_just_uri (doclink_uri);
2690 gtk_button_set_label (GTK_BUTTON (iw->doclink_button),
2691 _(
"Open Linked Document:"));
2692 gtk_link_button_set_uri (GTK_LINK_BUTTON (iw->doclink_button),
2694 gtk_widget_show (GTK_WIDGET (iw->doclink_button));
2695 g_free (display_uri);
2698 gtk_widget_hide (GTK_WIDGET (iw->doclink_button));
2701 gnc_widget_style_context_add_class (GTK_WIDGET(iw->paid_label),
"gnc-class-highlight");
2704 iw->proj_frame = GTK_WIDGET (gtk_builder_get_object (builder,
"page_proj_frame"));
2705 iw->proj_cust_box = GTK_WIDGET (gtk_builder_get_object (builder,
"page_proj_cust_hbox"));
2706 iw->proj_job_box = GTK_WIDGET (gtk_builder_get_object (builder,
"page_proj_job_hbox"));
2712 gnc_commodity *currency = gncInvoiceGetCurrency (invoice);
2715 iw->to_charge_frame = GTK_WIDGET (gtk_builder_get_object (builder,
"to_charge_frame"));
2716 edit = gnc_amount_edit_new();
2717 print_info = gnc_commodity_print_info (currency, FALSE);
2718 gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
2719 gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
2720 gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit),
2722 iw->to_charge_edit = edit;
2723 gtk_widget_show (edit);
2724 hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"to_charge_box"));
2725 gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);
2727 g_signal_connect(G_OBJECT(gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(edit))),
2729 G_CALLBACK(gnc_invoice_window_leave_to_charge_cb), edit);
2730 g_signal_connect(G_OBJECT(edit),
"amount_changed",
2731 G_CALLBACK(gnc_invoice_window_changed_to_charge_cb), iw);
2734 hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"page_date_opened_hbox"));
2735 iw->opened_date = gnc_date_edit_new (
gnc_time (NULL), FALSE, FALSE);
2736 gtk_widget_show(iw->opened_date);
2737 gtk_box_pack_start (GTK_BOX(hbox), iw->opened_date, TRUE, TRUE, 0);
2739 iw->posted_date_hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"date_posted_hbox"));
2740 iw->posted_date = gnc_date_edit_new (
gnc_time (NULL), FALSE, FALSE);
2741 gtk_widget_show(iw->posted_date);
2742 gtk_box_pack_start (GTK_BOX(iw->posted_date_hbox), iw->posted_date,
2746 gtk_widget_set_sensitive (iw->opened_date, FALSE);
2747 gtk_widget_set_sensitive (iw->posted_date, FALSE);
2749 gtk_widget_set_sensitive (iw->id_entry, FALSE);
2752 ledger_type = GNCENTRY_INVOICE_VIEWER;
2754 switch (iw->dialog_type)
2759 case GNC_OWNER_CUSTOMER:
2760 ledger_type = is_credit_note ? GNCENTRY_CUST_CREDIT_NOTE_ENTRY
2761 : GNCENTRY_INVOICE_ENTRY;
2763 case GNC_OWNER_VENDOR:
2764 ledger_type = is_credit_note ? GNCENTRY_VEND_CREDIT_NOTE_ENTRY
2765 : GNCENTRY_BILL_ENTRY;
2767 case GNC_OWNER_EMPLOYEE:
2768 ledger_type = is_credit_note ? GNCENTRY_EMPL_CREDIT_NOTE_ENTRY
2769 : GNCENTRY_EXPVOUCHER_ENTRY;
2772 g_warning (
"Invalid owner type");
2780 case GNC_OWNER_CUSTOMER:
2781 ledger_type = is_credit_note ? GNCENTRY_CUST_CREDIT_NOTE_VIEWER
2782 : GNCENTRY_INVOICE_VIEWER;
2783 prefs_group = GNC_PREFS_GROUP_INVOICE;
2785 case GNC_OWNER_VENDOR:
2786 ledger_type = is_credit_note ? GNCENTRY_VEND_CREDIT_NOTE_VIEWER
2787 : GNCENTRY_BILL_VIEWER;
2788 prefs_group = GNC_PREFS_GROUP_BILL;
2790 case GNC_OWNER_EMPLOYEE:
2791 ledger_type = is_credit_note ? GNCENTRY_EMPL_CREDIT_NOTE_VIEWER
2792 : GNCENTRY_EXPVOUCHER_VIEWER;
2793 prefs_group = GNC_PREFS_GROUP_BILL;
2796 g_warning (
"Invalid owner type");
2804 case GNC_OWNER_VENDOR:
2805 gtk_label_set_text (GTK_LABEL(iw->info_label),
_(
"Bill Information"));
2806 gtk_label_set_text (GTK_LABEL(iw->type_label),
_(
"Bill"));
2807 gtk_label_set_text (GTK_LABEL(iw->id_label),
_(
"Bill ID"));
2808 style_label =
"gnc-class-vendors";
2810 case GNC_OWNER_EMPLOYEE:
2811 gtk_label_set_text (GTK_LABEL(iw->info_label),
_(
"Voucher Information"));
2812 gtk_label_set_text (GTK_LABEL(iw->type_label),
_(
"Voucher"));
2813 gtk_label_set_text (GTK_LABEL(iw->id_label),
_(
"Voucher ID"));
2814 style_label =
"gnc-class-employees";
2817 style_label =
"gnc-class-customers";
2821 gnc_widget_style_context_add_class (GTK_WIDGET(dialog), style_label);
2826 iw->ledger = entry_ledger;
2833 gnc_entry_ledger_set_prefs_group (entry_ledger, prefs_group);
2837 gnc_register_gui_component (DIALOG_VIEW_INVOICE_CM_CLASS,
2838 gnc_invoice_window_refresh_handler,
2839 gnc_invoice_window_close_handler,
2842 gnc_gui_component_watch_entity_type (iw->component_id,
2843 GNC_INVOICE_MODULE_NAME,
2844 QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
2848 GtkWidget *regWidget, *frame, *window;
2849 const gchar *default_group = gnc_invoice_window_get_state_group (iw);
2853 if (iw->page_state_name)
2854 group = iw->page_state_name;
2856 group = default_group;
2860 (entry_ledger), group);
2861 gtk_widget_show(regWidget);
2863 frame = GTK_WIDGET (gtk_builder_get_object (builder,
"ledger_frame"));
2864 gtk_container_add (GTK_CONTAINER (frame), regWidget);
2866 iw->reg = GNUCASH_REGISTER (regWidget);
2868 gnucash_sheet_set_window (gnucash_register_get_sheet (iw->reg), window);
2870 g_signal_connect (G_OBJECT (regWidget),
"activate_cursor",
2871 G_CALLBACK (gnc_invoice_window_recordCB), iw);
2872 g_signal_connect (G_OBJECT (regWidget),
"redraw_all",
2873 G_CALLBACK (gnc_invoice_redraw_all_cb), iw);
2879 gnc_invoice_update_window (iw, dialog);
2890gnc_invoice_update_doclink_for_window (GncInvoice *invoice,
const gchar *uri)
2896 GtkWidget *doclink_button = gnc_invoice_window_get_doclink_button (iw);
2898 if (g_strcmp0 (uri,
"") == 0)
2900 GAction *uri_action;
2904 g_simple_action_set_enabled (G_SIMPLE_ACTION(uri_action), FALSE);
2906 gtk_widget_hide (doclink_button);
2910 gchar *display_uri = gnc_doclink_get_unescaped_just_uri (uri);
2911 gtk_link_button_set_uri (GTK_LINK_BUTTON (doclink_button),
2913 gtk_widget_show (GTK_WIDGET (doclink_button));
2914 g_free (display_uri);
2919static InvoiceWindow *
2920gnc_invoice_window_new_invoice (GtkWindow *parent, InvoiceDialogType dialog_type,
QofBook *bookp,
2921 const GncOwner *owner, GncInvoice *invoice)
2924 GtkBuilder *builder;
2926 GtkWidget *invoice_radio;
2929 GncBillTerm *owner_terms = NULL;
2930 GncOwnerType owner_type;
2931 const gchar *style_label = NULL;
2933 g_assert (dialog_type == NEW_INVOICE || dialog_type == MOD_INVOICE || dialog_type == DUP_INVOICE);
2944 iw = gnc_find_first_gui_component (DIALOG_NEW_INVOICE_CM_CLASS,
2945 find_handler, &invoice_guid);
2948 gtk_window_set_transient_for (GTK_WINDOW(iw->dialog), parent);
2949 gtk_window_present (GTK_WINDOW(iw->dialog));
2958 iw = g_new0 (InvoiceWindow, 1);
2959 iw->dialog_type = dialog_type;
2961 switch (dialog_type)
2966 invoice = gncInvoiceCreate (bookp);
2969 start_owner = owner;
2972 case GNC_OWNER_CUSTOMER:
2975 case GNC_OWNER_VENDOR:
2982 gncInvoiceSetTerms (invoice, owner_terms);
2987 start_owner = gncInvoiceGetOwner (invoice);
2988 iw->book = gncInvoiceGetBook (invoice);
2999 billto = gncInvoiceGetBillTo (invoice);
3004 iw->builder = builder = gtk_builder_new();
3005 gnc_builder_add_from_file (builder,
"dialog-invoice.glade",
"terms_store");
3006 gnc_builder_add_from_file (builder,
"dialog-invoice.glade",
"new_invoice_dialog");
3007 iw->dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"new_invoice_dialog"));
3008 gtk_window_set_transient_for (GTK_WINDOW(iw->dialog), parent);
3011 gtk_widget_set_name (GTK_WIDGET(iw->dialog),
"gnc-id-invoice");
3013 g_object_set_data (G_OBJECT (iw->dialog),
"dialog_info", iw);
3016 iw->type_label = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_type_label"));
3017 iw->type_label_hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_type_label_hbox"));
3018 iw->id_label = GTK_WIDGET (gtk_builder_get_object (builder,
"label14"));
3019 iw->info_label = GTK_WIDGET (gtk_builder_get_object (builder,
"label1"));
3020 invoice_radio = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_invoice_type"));
3022 iw->type_hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_type_choice_hbox"));
3023 iw->type_choice = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_type_invoice"));
3029 case GNC_OWNER_VENDOR:
3030 gtk_label_set_text (GTK_LABEL(iw->info_label),
_(
"Bill Information"));
3031 gtk_label_set_text (GTK_LABEL(iw->type_label),
_(
"Bill"));
3032 gtk_button_set_label (GTK_BUTTON(invoice_radio),
_(
"Bill"));
3033 gtk_label_set_text (GTK_LABEL(iw->id_label),
_(
"Bill ID"));
3034 style_label =
"gnc-class-vendors";
3036 case GNC_OWNER_EMPLOYEE:
3037 gtk_label_set_text (GTK_LABEL(iw->info_label),
_(
"Voucher Information"));
3038 gtk_label_set_text (GTK_LABEL(iw->type_label),
_(
"Voucher"));
3039 gtk_button_set_label (GTK_BUTTON(invoice_radio),
_(
"Voucher"));
3040 gtk_label_set_text (GTK_LABEL(iw->id_label),
_(
"Voucher ID"));
3041 style_label =
"gnc-class-employees";
3044 style_label =
"gnc-class-customers";
3048 gnc_widget_style_context_add_class (GTK_WIDGET(iw->dialog), style_label);
3051 switch (dialog_type)
3055 gtk_widget_show_all (iw->type_hbox);
3056 gtk_widget_hide (iw->type_label_hbox);
3057 gtk_widget_hide (iw->type_label);
3060 gtk_widget_hide (iw->type_hbox);
3061 gtk_widget_show (iw->type_label_hbox);
3062 gtk_widget_show (iw->type_label);
3068 if (dialog_type == DUP_INVOICE)
3070 GtkWidget *cn_radio = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_creditnote_type"));
3072 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(cn_radio), gncInvoiceGetIsCreditNote (invoice));
3075 iw->id_entry = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_id_entry"));
3076 iw->billing_id_entry = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_billing_id_entry"));
3077 iw->terms_menu = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_terms_menu"));
3078 iw->notes_text = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_notes_text"));
3079 iw->owner_box = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_owner_hbox"));
3080 iw->owner_label = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_owner_label"));
3081 iw->job_label = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_job_label"));
3082 iw->job_box = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_job_hbox"));
3085 iw->proj_frame = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_proj_frame"));
3086 iw->proj_cust_box = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_proj_cust_hbox"));
3087 iw->proj_job_box = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_proj_job_hbox"));
3089 hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_date_opened_hbox"));
3090 iw->opened_date = gnc_date_edit_new (
gnc_time (NULL), FALSE, FALSE);
3091 gtk_widget_show(iw->opened_date);
3092 gtk_box_pack_start (GTK_BOX(hbox), iw->opened_date, TRUE, TRUE, 0);
3095 gtk_widget_set_sensitive (iw->notes_text,
3096 (iw->dialog_type == NEW_INVOICE) ||
3097 (iw->dialog_type == DUP_INVOICE));
3100 gtk_builder_connect_signals_full( builder,
3101 gnc_builder_connect_full_func,
3105 iw->reportPage = NULL;
3107 iw->is_credit_note = gncInvoiceGetIsCreditNote (invoice);
3110 gnc_register_gui_component (DIALOG_NEW_INVOICE_CM_CLASS,
3111 gnc_invoice_window_refresh_handler,
3112 gnc_invoice_dialog_close_handler,
3115 gnc_gui_component_watch_entity_type (iw->component_id,
3116 GNC_INVOICE_MODULE_NAME,
3117 QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
3125 gnc_billterms_combo (GTK_COMBO_BOX(iw->terms_menu), iw->book, TRUE, iw->terms);
3130 if(gncBillTermGetName (iw->terms) != NULL)
3131 gtk_entry_set_text (GTK_ENTRY (iw->terms_menu),gncBillTermGetName (iw->terms));
3133 gtk_entry_set_text (GTK_ENTRY (iw->terms_menu),
"None");
3137 gnc_invoice_update_window (iw, iw->dialog);
3141 if (GNC_IS_GENERAL_SEARCH(iw->owner_choice))
3143 gnc_general_search_grab_focus(GNC_GENERAL_SEARCH(iw->owner_choice));
3150gnc_ui_invoice_edit (GtkWindow *parent, GncInvoice *invoice)
3153 InvoiceDialogType type;
3155 if (!invoice)
return NULL;
3158 if (gncInvoiceGetPostedAcc (invoice))
3159 type = VIEW_INVOICE;
3161 type = EDIT_INVOICE;
3163 iw = gnc_invoice_new_page (gncInvoiceGetBook(invoice), type,
3164 invoice, gncInvoiceGetOwner (invoice),
3170static InvoiceWindow *
3171gnc_ui_invoice_modify (GtkWindow *parent, GncInvoice *invoice)
3174 if (!invoice)
return NULL;
3176 iw = gnc_invoice_window_new_invoice (parent, MOD_INVOICE, NULL, NULL, invoice);
3181InvoiceWindow * gnc_ui_invoice_duplicate (GtkWindow *parent, GncInvoice *old_invoice, gboolean open_properties,
const GDate *new_date)
3183 InvoiceWindow *iw = NULL;
3184 GncInvoice *new_invoice = NULL;
3187 g_assert(old_invoice);
3193 gncInvoiceSetActive(new_invoice, TRUE);
3196 if (gncInvoiceIsPosted (new_invoice))
3201 g_warning(
"Oops, error when unposting the copied invoice; ignoring.");
3206 gncInvoiceSetID(new_invoice,
"");
3213 gncInvoiceSetDateOpened(new_invoice, entry_date);
3217 g_list_foreach(gncInvoiceGetEntries(new_invoice),
3218 &set_gncEntry_date, &entry_date);
3221 if (open_properties)
3224 iw = gnc_invoice_window_new_invoice (parent, DUP_INVOICE, NULL, NULL, new_invoice);
3229 iw = gnc_ui_invoice_edit (parent, new_invoice);
3231 if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (iw->id_entry)),
"") == 0)
3233 gncInvoiceSetID (new_invoice, gncInvoiceNextID(iw->book, &(iw->owner)));
3247 gncOwnerCopy (owner, &inv_owner);
3250 gncOwnerInitCustomer (&inv_owner, NULL);
3253 if (!book)
return NULL;
3255 iw = gnc_invoice_window_new_invoice (parent, NEW_INVOICE, book, &inv_owner, NULL);
3263edit_invoice_direct (GtkWindow *dialog, gpointer invoice, gpointer user_data)
3265 g_return_if_fail (invoice);
3270edit_invoice_cb (GtkWindow *dialog, gpointer inv, gpointer user_data)
3272 GncInvoice *invoice = inv;
3273 g_return_if_fail (invoice && user_data);
3274 edit_invoice_direct (dialog, invoice, user_data);
3286multi_edit_invoice_one (gpointer inv, gpointer user_data)
3289 edit_invoice_cb (meid->parent, inv, meid->user_data);
3293multi_edit_invoice_cb (GtkWindow *dialog, GList *invoice_list, gpointer user_data)
3297 meid.user_data = user_data;
3298 meid.parent = dialog;
3299 g_list_foreach (invoice_list, multi_edit_invoice_one, &meid);
3303pay_invoice_direct (GtkWindow *dialog, gpointer inv, gpointer user_data)
3305 GncInvoice *invoice = inv;
3307 g_return_if_fail (invoice);
3308 gnc_ui_payment_new_with_invoice (dialog, gncInvoiceGetOwner (invoice),
3309 gncInvoiceGetBook (invoice), invoice);
3313pay_invoice_cb (GtkWindow *dialog, gpointer *invoice_p, gpointer user_data)
3315 g_return_if_fail (invoice_p && user_data);
3318 pay_invoice_direct (dialog, *invoice_p, user_data);
3327static void multi_duplicate_invoice_one(gpointer data, gpointer user_data)
3329 GncInvoice *old_invoice = data;
3332 g_assert(dup_user_data);
3335 GncInvoice *new_invoice;
3339 InvoiceWindow *iw = gnc_ui_invoice_duplicate(dup_user_data->parent, old_invoice, FALSE, &dup_user_data->date);
3342 new_invoice = iw_get_invoice(iw);
3343 g_assert(new_invoice);
3348multi_duplicate_invoice_cb (GtkWindow *dialog, GList *invoice_list, gpointer user_data)
3350 g_return_if_fail (invoice_list);
3351 switch (g_list_length(invoice_list))
3358 GncInvoice *old_invoice = invoice_list->data;
3359 gnc_ui_invoice_duplicate(dialog, old_invoice, TRUE, NULL);
3370 dup_user_data.parent = dialog;
3371 dialog_ok = gnc_dup_date_dialog (GTK_WIDGET(dialog),
_(
"Date of duplicated entries"), &dup_user_data.date);
3381 g_list_foreach(invoice_list, multi_duplicate_invoice_one, &dup_user_data);
3387static void post_one_invoice_cb(gpointer data, gpointer user_data)
3389 GncInvoice *invoice = data;
3391 InvoiceWindow *iw = gnc_ui_invoice_edit(post_params->parent, invoice);
3392 gnc_invoice_post(iw, post_params);
3395static void gnc_invoice_is_posted(gpointer inv, gpointer test_value)
3397 GncInvoice *invoice = inv;
3398 gboolean *test = (gboolean*)test_value;
3400 if (gncInvoiceIsPosted (invoice))
3408multi_post_invoice_cb (GtkWindow *dialog, GList *invoice_list, gpointer user_data)
3417 iw = gnc_ui_invoice_edit(dialog, invoice_list->data);
3419 gnc_suspend_gui_refresh ();
3421 g_list_foreach(invoice_list, gnc_invoice_is_posted, &test);
3422 gnc_resume_gui_refresh ();
3425 gnc_error_dialog (GTK_WINDOW (iw_get_window(iw)),
"%s",
3426 _(
"One or more selected invoices have already been posted.\nRe-check your selection."));
3430 if (!gnc_dialog_post_invoice(iw,
_(
"Do you really want to post these invoices?"),
3431 &post_params.ddue, &post_params.postdate,
3432 &post_params.memo, &post_params.acc,
3433 &post_params.accumulate))
3435 post_params.parent = dialog;
3441 gnc_suspend_gui_refresh ();
3442 g_list_foreach(invoice_list, post_one_invoice_cb, &post_params);
3443 gnc_resume_gui_refresh ();
3446static void print_one_invoice_cb(GtkWindow *dialog, gpointer data, gpointer user_data)
3448 GncInvoice *invoice = data;
3450 gnc_invoice_window_print_invoice (dialog, invoice, meid->report_guid);
3454multi_print_invoice_one (gpointer data, gpointer user_data)
3461multi_print_invoice_cb (GtkWindow *dialog, GList *invoice_list, gpointer user_data)
3463 gchar *report_guid = NULL;
3469 report_guid = use_default_report_template_or_change (dialog);
3474 meid.user_data = user_data;
3475 meid.parent = dialog;
3476 meid.report_guid = report_guid;
3478 g_list_foreach (invoice_list, multi_print_invoice_one, &meid);
3479 g_free (report_guid);
3483new_invoice_cb (GtkWindow *dialog, gpointer user_data)
3488 g_return_val_if_fail (user_data, NULL);
3490 iw = gnc_ui_invoice_new (dialog, sw->owner, sw->book);
3491 return iw_get_invoice (iw);
3495free_invoice_cb (gpointer user_data)
3499 g_return_if_fail (sw);
3506gnc_invoice_search (GtkWindow *parent, GncInvoice *start,
GncOwner *owner,
QofBook *book)
3508 QofIdType type = GNC_INVOICE_MODULE_NAME;
3511 GncOwnerType owner_type = GNC_OWNER_CUSTOMER;
3512 static GList *inv_params = NULL, *bill_params = NULL, *emp_params = NULL, *params;
3513 static GList *columns = NULL;
3514 const gchar *title, *label, *style_class;
3518 { N_(
"View/Edit Invoice"), NULL, multi_edit_invoice_cb, TRUE},
3519 { N_(
"Process Payment"), pay_invoice_cb, NULL, FALSE},
3520 { N_(
"Duplicate"), NULL, multi_duplicate_invoice_cb, FALSE},
3521 { N_(
"Post"), NULL, multi_post_invoice_cb, FALSE},
3522 { N_(
"Printable Report"), NULL, multi_print_invoice_cb, TRUE},
3527 { N_(
"View/Edit Bill"), NULL, multi_edit_invoice_cb, TRUE},
3528 { N_(
"Process Payment"), pay_invoice_cb, NULL, FALSE},
3529 { N_(
"Duplicate"), NULL, multi_duplicate_invoice_cb, FALSE},
3530 { N_(
"Post"), NULL, multi_post_invoice_cb, FALSE},
3531 { N_(
"Printable Report"), NULL, multi_print_invoice_cb, TRUE},
3538 { N_(
"View/Edit Voucher"), NULL, multi_edit_invoice_cb, TRUE},
3539 { N_(
"Process Payment"), pay_invoice_cb, NULL, FALSE},
3540 { N_(
"Duplicate"), NULL, multi_duplicate_invoice_cb, FALSE},
3541 { N_(
"Post"), NULL, multi_post_invoice_cb, FALSE},
3542 { N_(
"Printable Report"), NULL, multi_print_invoice_cb, TRUE},
3546 g_return_val_if_fail (book, NULL);
3549 if (inv_params == NULL)
3551 inv_params = gnc_search_param_prepend (inv_params,
3552 _(
"Invoice Owner"), NULL, type,
3553 INVOICE_OWNER, NULL);
3554 inv_params = gnc_search_param_prepend (inv_params,
3555 _(
"Invoice Notes"), NULL, type,
3556 INVOICE_NOTES, NULL);
3557 inv_params = gnc_search_param_prepend (inv_params,
3558 _(
"Billing ID"), NULL, type,
3559 INVOICE_BILLINGID, NULL);
3560 inv_params = gnc_search_param_prepend (inv_params,
3561 _(
"Is Paid?"), NULL, type,
3562 INVOICE_IS_PAID, NULL);
3563 inv_params = gnc_search_param_prepend (inv_params,
3564 _(
"Date Posted"), NULL, type,
3565 INVOICE_POSTED, NULL);
3566 inv_params = gnc_search_param_prepend (inv_params,
3567 _(
"Is Posted?"), NULL, type,
3568 INVOICE_IS_POSTED, NULL);
3569 inv_params = gnc_search_param_prepend (inv_params,
3570 _(
"Date Opened"), NULL, type,
3571 INVOICE_OPENED, NULL);
3572 inv_params = gnc_search_param_prepend (inv_params,
3573 _(
"Due Date"), NULL, type,
3575 inv_params = gnc_search_param_prepend (inv_params,
3576 _(
"Company Name"), NULL, type,
3577 INVOICE_OWNER, OWNER_PARENT,
3579 inv_params = gnc_search_param_prepend (inv_params,
3580 _(
"Invoice ID"), NULL, type,
3583 if (bill_params == NULL)
3585 bill_params = gnc_search_param_prepend (bill_params,
3586 _(
"Bill Owner"), NULL, type,
3587 INVOICE_OWNER, NULL);
3588 bill_params = gnc_search_param_prepend (bill_params,
3589 _(
"Bill Notes"), NULL, type,
3590 INVOICE_NOTES, NULL);
3591 bill_params = gnc_search_param_prepend (bill_params,
3592 _(
"Billing ID"), NULL, type,
3593 INVOICE_BILLINGID, NULL);
3594 bill_params = gnc_search_param_prepend (bill_params,
3595 _(
"Is Paid?"), NULL, type,
3596 INVOICE_IS_PAID, NULL);
3597 bill_params = gnc_search_param_prepend (bill_params,
3598 _(
"Date Posted"), NULL, type,
3599 INVOICE_POSTED, NULL);
3600 bill_params = gnc_search_param_prepend (bill_params,
3601 _(
"Is Posted?"), NULL, type,
3602 INVOICE_IS_POSTED, NULL);
3603 bill_params = gnc_search_param_prepend (bill_params,
3604 _(
"Date Opened"), NULL, type,
3605 INVOICE_OPENED, NULL);
3606 bill_params = gnc_search_param_prepend (bill_params,
3607 _(
"Due Date"), NULL, type,
3609 bill_params = gnc_search_param_prepend (bill_params,
3610 _(
"Company Name"), NULL, type,
3611 INVOICE_OWNER, OWNER_PARENT,
3613 bill_params = gnc_search_param_prepend (bill_params,
3614 _(
"Bill ID"), NULL, type,
3617 if (emp_params == NULL)
3619 emp_params = gnc_search_param_prepend (emp_params,
3620 _(
"Voucher Owner"), NULL, type,
3621 INVOICE_OWNER, NULL);
3622 emp_params = gnc_search_param_prepend (emp_params,
3623 _(
"Voucher Notes"), NULL, type,
3624 INVOICE_NOTES, NULL);
3625 emp_params = gnc_search_param_prepend (emp_params,
3626 _(
"Billing ID"), NULL, type,
3627 INVOICE_BILLINGID, NULL);
3628 emp_params = gnc_search_param_prepend (emp_params,
3629 _(
"Is Paid?"), NULL, type,
3630 INVOICE_IS_PAID, NULL);
3631 emp_params = gnc_search_param_prepend (emp_params,
3632 _(
"Date Posted"), NULL, type,
3633 INVOICE_POSTED, NULL);
3634 emp_params = gnc_search_param_prepend (emp_params,
3635 _(
"Is Posted?"), NULL, type,
3636 INVOICE_IS_POSTED, NULL);
3637 emp_params = gnc_search_param_prepend (emp_params,
3638 _(
"Date Opened"), NULL, type,
3639 INVOICE_OPENED, NULL);
3640 emp_params = gnc_search_param_prepend (emp_params,
3641 _(
"Due Date"), NULL, type,
3643 emp_params = gnc_search_param_prepend (emp_params,
3644 _(
"Employee Name"), NULL, type,
3645 INVOICE_OWNER, OWNER_PARENT,
3647 emp_params = gnc_search_param_prepend (emp_params,
3648 _(
"Voucher ID"), NULL, type,
3653 if (columns == NULL)
3655 columns = gnc_search_param_prepend (columns,
_(
"Billing ID"), NULL, type,
3656 INVOICE_BILLINGID, NULL);
3657 columns = gnc_search_param_prepend (columns,
_(
"Type"), NULL, type,
3658 INVOICE_TYPE_STRING, NULL);
3659 columns = gnc_search_param_prepend_with_justify (columns,
_(
"Paid"),
3660 GTK_JUSTIFY_CENTER, NULL, type,
3661 INVOICE_IS_PAID, NULL);
3662 columns = gnc_search_param_prepend (columns,
_(
"Posted"), NULL, type,
3663 INVOICE_POSTED, NULL);
3664 columns = gnc_search_param_prepend (columns,
_(
"Company"), NULL, type,
3665 INVOICE_OWNER, OWNER_PARENT,
3667 columns = gnc_search_param_prepend (columns,
_(
"Due"), NULL, type,
3669 columns = gnc_search_param_prepend (columns,
_(
"Opened"), NULL, type,
3670 INVOICE_OPENED, NULL);
3671 columns = gnc_search_param_prepend (columns,
_(
"Num"), NULL, type,
3676 q = qof_query_create_for (type);
3700 (g_slist_prepend (NULL, QOF_PARAM_GUID),
3705 (g_slist_prepend (NULL, OWNER_PARENTG),
3720 QofQueryPredData *inv_type_pred = NULL;
3721 GList *type_list = NULL, *node = NULL;
3723 type_list = gncInvoiceGetTypeListForOwnerType(owner_type);
3724 for (node = type_list; node; node = node->next)
3726 inv_type_pred = qof_query_int32_predicate(QOF_COMPARE_EQUAL,
3727 GPOINTER_TO_INT(node->data));
3728 qof_query_add_term (q3, g_slist_prepend (NULL, INVOICE_TYPE), inv_type_pred, QOF_QUERY_OR);
3743 gncOwnerCopy (owner, &(sw->owner_def));
3744 sw->owner = &(sw->owner_def);
3751 case GNC_OWNER_VENDOR:
3752 title =
_(
"Find Bill");
3754 style_class =
"gnc-class-bills";
3755 params = bill_params;
3756 buttons = bill_buttons;
3758 case GNC_OWNER_EMPLOYEE:
3759 title =
_(
"Find Expense Voucher");
3760 label =
_(
"Expense Voucher");
3761 style_class =
"gnc-class-vouchers";
3762 params = emp_params;
3763 buttons = emp_buttons;
3766 title =
_(
"Find Invoice");
3767 label =
_(
"Invoice");
3768 style_class =
"gnc-class-invoices";
3769 params = inv_params;
3770 buttons = inv_buttons;
3773 return gnc_search_dialog_create (parent, type, title, params, columns, q, q2,
3774 buttons, NULL, new_invoice_cb,
3775 sw, free_invoice_cb, GNC_PREFS_GROUP_SEARCH,
3776 label, style_class);
3780gnc_invoice_show_docs_due (GtkWindow *parent,
QofBook *book,
double days_in_advance, GncWhichDueType duetype)
3782 QofIdType type = GNC_INVOICE_MODULE_NAME;
3784 QofQueryPredData* pred_data;
3787 gchar *message, *title;
3789 DialogQueryView *dialog;
3791 static GList *param_list = NULL;
3794 { N_(
"View/Edit Bill"), edit_invoice_direct },
3795 { N_(
"Process Payment"), pay_invoice_direct },
3800 { N_(
"View/Edit Invoice"), edit_invoice_direct },
3801 { N_(
"Process Payment"), pay_invoice_direct },
3807 PERR(
"No book, no due invoices.");
3812 if (param_list == NULL)
3814 param_list = gnc_search_param_prepend_with_justify (param_list,
_(
"Amount"),
3815 GTK_JUSTIFY_RIGHT, NULL, type,
3816 INVOICE_POST_LOT, LOT_BALANCE, NULL);
3817 param_list = gnc_search_param_prepend (param_list,
_(
"Type"), NULL, type,
3818 INVOICE_TYPE_STRING, NULL);
3819 param_list = gnc_search_param_prepend (param_list,
_(
"Company"), NULL, type,
3820 INVOICE_OWNER, OWNER_PARENT, OWNER_NAME, NULL);
3821 param_list = gnc_search_param_prepend (param_list,
_(
"Due"), NULL, type,
3854 INVOICE_POST_LOT), FALSE, QOF_QUERY_AND);
3857 if (duetype == DUE_FOR_VENDOR)
3859 pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_CUST_INVOICE);
3860 qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
3862 pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_CUST_CREDIT_NOTE);
3863 qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
3867 pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_VEND_INVOICE);
3868 qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
3870 pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_VEND_CREDIT_NOTE);
3871 qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
3873 pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_EMPL_INVOICE);
3874 qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
3876 pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_EMPL_CREDIT_NOTE);
3877 qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
3881 if (days_in_advance < 0)
3882 days_in_advance = 0;
3883 end_date += days_in_advance * 60 * 60 * 24;
3885 pred_data = qof_query_date_predicate (QOF_COMPARE_LTE, QOF_DATE_MATCH_NORMAL, end_date);
3886 qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_DUE), pred_data, QOF_QUERY_AND);
3889 len = g_list_length (res);
3890 if (!res || len <= 0)
3896 if (duetype == DUE_FOR_VENDOR)
3898 prefs_group = GNC_PREFS_GROUP_VENDOR;
3899 message = g_strdup_printf
3902 ngettext(
"The following vendor business item is due:",
3903 "The following %d vendor business items are due:",
3906 title =
_(
"Due Bills Reminder");
3910 prefs_group = GNC_PREFS_GROUP_CUSTOMER;
3911 message = g_strdup_printf
3914 ngettext(
"The following customer business item is due:",
3915 "The following %d customer business items are due:",
3918 title =
_(
"Due Invoices Reminder");
3921 dialog = gnc_dialog_query_view_create(parent, param_list, q,
3925 1, GTK_SORT_ASCENDING,
3927 duetype == DUE_FOR_VENDOR ?
3938gnc_invoice_remind_bills_due (GtkWindow *parent)
3943 if (!gnc_current_session_exist())
return;
3947 gnc_invoice_show_docs_due (parent, book, days, DUE_FOR_VENDOR);
3951gnc_invoice_remind_invoices_due (GtkWindow *parent)
3956 if (!gnc_current_session_exist())
return;
3960 gnc_invoice_show_docs_due (parent, book, days, DUE_FOR_CUSTOMER);
3964gnc_invoice_remind_bills_due_cb (
void)
3973gnc_invoice_remind_invoices_due_cb (
void)
This file contains the functions to present a gui to the user for creating a new account or editing a...
Date and Time handling routines.
Functions for adding content to a window.
utility functions for the GnuCash UI
Functions for adding plugins to a GnuCash window.
Generic api to store and retrieve preferences.
Functions to load, save and get gui state.
utility functions for the GnuCash UI
Utility functions for convert uri in separate components and back.
Business Invoice Interface.
Business Interface: Object OWNERs.
Public declarations of GnucashRegister class.
gchar * gnc_account_get_full_name(const Account *account)
The gnc_account_get_full_name routine returns the fully qualified name of the account using the given...
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id,...
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
gchar * qof_book_get_default_invoice_report_name(const QofBook *book)
Get the name of the Invoice Report to be used as the default for printing Invoices.
gdouble qof_book_get_default_invoice_report_timeout(const QofBook *book)
Get the length of time available to change the used Invoice Report when printing Invoices.
GncEntry * gnc_entry_ledger_get_current_entry(GncEntryLedger *ledger)
Returns the Entry where the cursor is currently located.
GncEntryLedger * gnc_entry_ledger_new(QofBook *book, GncEntryLedgerType type)
Create and return a new GncEntry Ledger.
void gnc_entry_ledger_destroy(GncEntryLedger *ledger)
Destroy the GncEntry Ledger.
gboolean gnc_entry_ledger_commit_entry(GncEntryLedger *ledger)
This will act just like hitting 'return' to record an entry.
Table * gnc_entry_ledger_get_table(GncEntryLedger *ledger)
Get the Table.
GncEntry * gnc_entry_ledger_get_blank_entry(GncEntryLedger *ledger)
Exported Functions.
gboolean gnc_entry_ledger_get_entry_virt_loc(GncEntryLedger *ledger, const GncEntry *entry, VirtualCellLocation *vcell_loc)
Looks up the cell location of the given "entry" and writes the location into the variable pointed to ...
void gnc_entry_ledger_set_default_invoice(GncEntryLedger *ledger, GncInvoice *invoice)
Set the default invoice for this ledger.
void gnc_entry_ledger_move_current_entry_updown(GncEntryLedger *ledger, gboolean move_up)
This implements the command of moving the current entry (where the cursor is currently located) one r...
gboolean gnc_entry_ledger_check_close(GtkWidget *parent, GncEntryLedger *ledger)
This will ask the user if they really want to make a change.
int gnc_commodity_get_fraction(const gnc_commodity *cm)
Retrieve the fraction for the specified commodity.
GtkWidget * gnc_plugin_page_get_window(GncPluginPage *page)
Retrieve a pointer to the GncMainWindow (GtkWindow) containing this page.
GAction * gnc_plugin_page_get_action(GncPluginPage *page, const gchar *name)
Retrieve a GAction object associated with this page.
void gnc_gdate_set_time64(GDate *gd, time64 time)
Set a GDate to a time64.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
time64 gnc_time64_get_day_neutral(time64 time_val)
The gnc_time64_get_day_neutral() routine will take the given time in seconds and adjust it to 10:59:0...
time64 gdate_to_time64(GDate d)
Turns a GDate into a time64, returning the first second of the day.
time64 gnc_time(time64 *tbuf)
get the current time
const gchar * QofIdType
QofIdType declaration.
time64 gncEntryGetDate(const GncEntry *entry)
DEPRECATED - use gncEntryGetDateGDate() instead! (Because the time-of-day is a misleading extra infor...
void gncEntrySetQuantity(GncEntry *entry, gnc_numeric quantity)
Set the internal quantity without any conversion.
gnc_numeric gncEntryGetQuantity(const GncEntry *entry)
Get the quantity as stored internally.
void gncEntrySetDate(GncEntry *entry, time64 date)
DEPRECATED - use gncEntrySetDateGDate() instead! (Because the time-of-day is a misleading extra infor...
const GncGUID * guid_null(void)
Returns a GncGUID which is guaranteed to never reference any entity.
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
Given two GUIDs, return TRUE if they are non-NULL and equal.
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
void gnc_main_window_display_page(GncPluginPage *page)
Bring the window containing the specified page to the top of the window stack, then switch the notebo...
GtkWindow * gnc_ui_get_main_window(GtkWidget *widget)
Get a pointer to the final GncMainWindow widget is rooted in.
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
void gnc_main_window_close_page(GncPluginPage *page)
Remove a data plugin page from a window and display the previous page.
gint gnc_state_drop_sections_for(const gchar *partial_name)
Drop all sections from the state file whose name contains partial_name.
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
GtkWidget * gnucash_register_new(Table *table, const gchar *state_section)
this already has scrollbars attached
void gnc_gnome_help(GtkWindow *parent, const char *file_name, const char *anchor)
Launch the systems default help browser, gnome's yelp for linux, and open to a given link within a gi...
GncPluginPage * gnc_plugin_page_report_new(int reportId)
int xaccSPrintAmount(char *bufp, gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
char * gnc_wrap_text_with_bidi_ltr_isolate(const char *text)
This function helps with GTK's use of 'Unicode Bidirectional Text Algorithm'.
gnc_commodity * gnc_default_currency(void)
Return the default currency set by the user.
gint gnc_list_length_cmp(const GList *list, size_t len)
Scans the GList elements the minimum number of iterations required to test it against a specified siz...
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
void qof_instance_set(QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.
GncPluginPage * gnc_plugin_page_invoice_new(InvoiceWindow *iw)
Create a new "invoice" plugin page, given a pointer to an InvoiceWindow data structure.
void gnc_plugin_page_invoice_update_menus(GncPluginPage *page, gboolean is_posted, gboolean can_unpost)
Update the menu items associated with this invoice page.
InvoiceWindow * gnc_plugin_page_invoice_get_window(GncInvoice *invoice)
Find the Invoice Window amongst the plugin pages for an Invoice, if not present return NULL.
void gnc_plugin_page_invoice_update_title(GncPluginPage *plugin_page)
Update the title associated with this invoice page.
gnc_numeric gncInvoiceGetTotal(GncInvoice *invoice)
Return the "total" amount of the invoice as seen on the document (and shown to the user in the report...
GHashTable * gncInvoiceGetForeignCurrencies(const GncInvoice *invoice)
Return an overview of amounts on this invoice that will be posted to accounts in currencies that are ...
GncInvoice * gncInvoiceCopy(const GncInvoice *from)
Create a new GncInvoice object as a deep copy of the given other invoice.
gboolean gncInvoiceUnpost(GncInvoice *invoice, gboolean reset_tax_tables)
Unpost this invoice.
Transaction * gncInvoicePostToAccount(GncInvoice *invoice, Account *acc, time64 post_date, time64 due_date, const char *memo, gboolean accumulatesplits, gboolean autopay)
Post this invoice to an account.
#define gncInvoiceGetGUID(x)
deprecated functions
void gncInvoiceRemoveEntries(GncInvoice *invoice)
Remove all entries from an invoice.
#define PERR(format, args...)
Log a serious error.
gnc_numeric gnc_numeric_sub(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a-b.
#define GNC_DENOM_AUTO
Values that can be passed as the 'denom' argument.
gnc_numeric gnc_numeric_div(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Division.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
gnc_numeric gnc_numeric_neg(gnc_numeric a)
Returns a newly created gnc_numeric that is the negative of the given gnc_numeric value.
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a+b.
@ GNC_HOW_RND_ROUND_HALF_UP
Round to the nearest integer, rounding away from zero when there are two equidistant nearest integers...
GncCustomer * gncOwnerGetCustomer(const GncOwner *owner)
If the given owner is of type GNC_OWNER_CUSTOMER, returns the pointer to the customer object.
GList * gncOwnerGetCommoditiesList(const GncOwner *owner)
Returns a GList of currencies associated with the owner.
GncEmployee * gncOwnerGetEmployee(const GncOwner *owner)
If the given owner is of type GNC_OWNER_EMPLOYEE, returns the pointer to the employee object.
QofIdTypeConst qofOwnerGetType(const GncOwner *owner)
return the type for the collection.
GList * gncOwnerGetAccountTypesList(const GncOwner *owner)
Returns a GList of account-types based on the owner type.
GncJob * gncOwnerGetJob(const GncOwner *owner)
If the given owner is of type GNC_OWNER_JOB, returns the pointer to the job object.
GncVendor * gncOwnerGetVendor(const GncOwner *owner)
If the given owner is of type GNC_OWNER_VENDOR, returns the pointer to the vendor object.
const GncOwner * gncOwnerGetEndOwner(const GncOwner *owner)
Get the "parent" Owner or GncGUID thereof.
gboolean gncOwnerEqual(const GncOwner *a, const GncOwner *b)
Assess equality by checking.
const GncGUID * gncOwnerGetGUID(const GncOwner *owner)
Get the GncGUID of the immediate owner.
GncOwnerType gncOwnerGetType(const GncOwner *owner)
Returns the GncOwnerType of this owner.
QofInstance * qofOwnerGetOwner(const GncOwner *owner)
return the owner itself as an entity.
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Get an float value from the preferences backend.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
GNCPrice * gnc_price_create(QofBook *book)
gnc_price_create - returns a newly allocated and initialized price with a reference count of 1.
void qof_query_add_term(QofQuery *q, QofQueryParamList *param_list, QofQueryPredData *pred_data, QofQueryOp op)
This is the general function that adds a new Query Term to a query.
void qof_query_add_guid_match(QofQuery *q, QofQueryParamList *param_list, const GncGUID *guid, QofQueryOp op)
DOCUMENT ME !!
#define QUERY_DEFAULT_SORT
Default sort object type.
QofQuery * qof_query_copy(QofQuery *q)
Make a copy of the indicated query.
void qof_query_set_book(QofQuery *query, QofBook *book)
Set the book to be searched.
void qof_query_set_sort_order(QofQuery *q, QofQueryParamList *params1, QofQueryParamList *params2, QofQueryParamList *params3)
When a query is run, the results are sorted before being returned.
void qof_query_add_boolean_match(QofQuery *q, QofQueryParamList *param_list, gboolean value, QofQueryOp op)
Handy-dandy convenience routines, avoids having to create a separate predicate for boolean matches.
void qof_query_destroy(QofQuery *query)
Frees the resources associate with a Query object.
QofQuery * qof_query_create(void)
Create a new query.
void qof_query_search_for(QofQuery *q, QofIdTypeConst obj_type)
Set the object type to be searched for.
void qof_query_merge_in_place(QofQuery *q1, QofQuery *q2, QofQueryOp op)
Like qof_query_merge, but this will merge a copy of q2 into q1.
GList * qof_query_run(QofQuery *query)
Perform the query, return the results.
void gnc_table_refresh_gui(Table *table, gboolean do_scroll)
Refresh the whole GUI from the table.
void gnc_table_save_state(Table *table, const gchar *state_section)
Implementation.
gboolean qof_commit_edit(QofInstance *inst)
commit_edit helpers
gboolean qof_begin_edit(QofInstance *inst)
begin_edit
The type used to store guids in C.
The instance data structure for a content plugin.
This data structure does double duty.