29 #include <glib/gi18n.h>
31 #include "swig-runtime.h"
36 #include "dialog-utils.h"
37 #include "gnc-component-manager.h"
39 #include "gnc-gui-query.h"
42 #include "gnc-date-edit.h"
43 #include "gnc-amount-edit.h"
44 #include "gnucash-sheet.h"
45 #include "window-report.h"
46 #include "dialog-search.h"
47 #include "search-param.h"
48 #include "gnc-session.h"
51 #include "gncInvoiceP.h"
53 #include "gncEntryLedger.h"
56 #include "gnc-general-search.h"
57 #include "dialog-date-close.h"
58 #include "dialog-invoice.h"
59 #include "dialog-job.h"
60 #include "business-gnome-utils.h"
61 #include "dialog-payment.h"
62 #include "dialog-tax-table.h"
63 #include "dialog-billterms.h"
65 #include "guile-mappings.h"
66 #include "dialog-dup-trans.h"
68 #include "dialog-query-view.h"
70 #include "gnc-plugin-business.h"
74 #include "dialog-transfer.h"
81 #if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 2)
82 # pragma GCC diagnostic warning "-Waddress"
85 #define DIALOG_NEW_INVOICE_CM_CLASS "dialog-new-invoice"
86 #define DIALOG_VIEW_INVOICE_CM_CLASS "dialog-view-invoice"
88 #define GNC_PREFS_GROUP_SEARCH "dialogs.business.invoice-search"
89 #define GNC_PREF_NOTIFY_WHEN_DUE "notify-when-due"
90 #define GNC_PREF_ACCUM_SPLITS "accumulate-splits"
91 #define GNC_PREF_DAYS_IN_ADVANCE "days-in-advance"
93 void gnc_invoice_window_ok_cb (GtkWidget *widget, gpointer data);
94 void gnc_invoice_window_cancel_cb (GtkWidget *widget, gpointer data);
95 void gnc_invoice_window_help_cb (GtkWidget *widget, gpointer data);
96 void gnc_invoice_type_toggled_cb (GtkWidget *widget, gpointer data);
97 void gnc_invoice_id_changed_cb (GtkWidget *widget, gpointer data);
98 void gnc_invoice_terms_changed_cb (GtkWidget *widget, gpointer data);
100 #define ENUM_INVOICE_TYPE(_) \
107 DEFINE_ENUM(InvoiceDialogType, ENUM_INVOICE_TYPE)
108 AS_STRING_DEC(InvoiceDialogType, ENUM_INVOICE_TYPE)
109 FROM_STRING_DEC(InvoiceDialogType, ENUM_INVOICE_TYPE)
111 FROM_STRING_FUNC(InvoiceDialogType, ENUM_INVOICE_TYPE)
112 AS_STRING_FUNC(InvoiceDialogType, ENUM_INVOICE_TYPE)
130 GtkBuilder * builder;
136 GtkWidget * total_label;
137 GtkWidget * total_cash_label;
138 GtkWidget * total_charge_label;
139 GtkWidget * total_subtotal_label;
140 GtkWidget * total_tax_label;
143 GtkWidget * info_label;
144 GtkWidget * id_label;
145 GtkWidget * type_label;
146 GtkWidget * type_hbox;
147 GtkWidget * type_choice;
148 GtkWidget * id_entry;
149 GtkWidget * notes_text;
150 GtkWidget * opened_date;
151 GtkWidget * posted_date_hbox;
152 GtkWidget * posted_date;
153 GtkWidget * active_check;
155 GtkWidget * owner_box;
156 GtkWidget * owner_label;
157 GtkWidget * owner_choice;
158 GtkWidget * job_label;
160 GtkWidget * job_choice;
161 GtkWidget * billing_id_entry;
162 GtkWidget * terms_menu;
165 GtkWidget * proj_frame;
166 GtkWidget * proj_cust_box;
167 GtkWidget * proj_cust_choice;
168 GtkWidget * proj_job_box;
169 GtkWidget * proj_job_choice;
172 GtkWidget * to_charge_frame;
173 GtkWidget * to_charge_edit;
181 invoice_sort_type_t last_sort;
183 InvoiceDialogType dialog_type;
185 gboolean is_credit_note;
196 gboolean reset_tax_tables;
200 void gnc_invoice_window_closeCB (GtkWidget *widget, gpointer data);
201 void gnc_invoice_window_active_toggled_cb (GtkWidget *widget, gpointer data);
202 gboolean gnc_invoice_window_leave_notes_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data);
204 #define INV_WIDTH_PREFIX "invoice_reg"
205 #define BILL_WIDTH_PREFIX "bill_reg"
206 #define VOUCHER_WIDTH_PREFIX "voucher_reg"
208 static void gnc_invoice_update_window (
InvoiceWindow *iw, GtkWidget *widget);
226 return (GtkWidget *)iw->reg;
237 GtkToggleButton *toggle;
241 builder = gtk_builder_new();
242 gnc_builder_add_from_file (builder,
"dialog-invoice.glade",
"Unpost Message Dialog");
243 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"Unpost Message Dialog"));
244 toggle = GTK_TOGGLE_BUTTON(gtk_builder_get_object (builder,
"yes_tt_reset"));
246 gtk_window_set_transient_for (GTK_WINDOW(dialog),
247 GTK_WINDOW(iw_get_window(iw)));
249 iw->reset_tax_tables = FALSE;
251 gtk_widget_show_all(dialog);
253 response = gtk_dialog_run(GTK_DIALOG(dialog));
254 if (response == GTK_RESPONSE_OK)
255 iw->reset_tax_tables =
256 gtk_toggle_button_get_active(toggle);
258 gtk_widget_destroy(dialog);
259 g_object_unref(G_OBJECT(builder));
261 return (response == GTK_RESPONSE_OK);
273 return gncInvoiceLookup (iw->book, &iw->invoice_guid);
277 set_gncEntry_switch_type (gpointer data, gpointer user_data)
287 GtkTextBuffer* text_buffer;
288 GtkTextIter start, end;
291 gboolean is_credit_note = gncInvoiceGetIsCreditNote (invoice);
293 if (iw->dialog_type == VIEW_INVOICE)
296 gnc_suspend_gui_refresh ();
298 gncInvoiceBeginEdit (invoice);
300 if (iw->active_check)
301 gncInvoiceSetActive (invoice, gtk_toggle_button_get_active
302 (GTK_TOGGLE_BUTTON (iw->active_check)));
304 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(iw->notes_text));
305 gtk_text_buffer_get_bounds (text_buffer, &start, &end);
306 text = gtk_text_buffer_get_text (text_buffer, &start, &end, FALSE);
307 gncInvoiceSetNotes (invoice, text);
309 if (iw->to_charge_edit)
310 gncInvoiceSetToChargeAmount (invoice,
311 gnc_amount_edit_get_amount
312 (GNC_AMOUNT_EDIT (iw->to_charge_edit)));
315 if (iw->dialog_type != EDIT_INVOICE)
317 gncInvoiceSetID (invoice, gtk_editable_get_chars
318 (GTK_EDITABLE (iw->id_entry), 0, -1));
319 gncInvoiceSetBillingID (invoice, gtk_editable_get_chars
320 (GTK_EDITABLE (iw->billing_id_entry), 0, -1));
321 gncInvoiceSetTerms (invoice, iw->terms);
323 ts = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (iw->opened_date));
324 gncInvoiceSetDateOpened (invoice, ts);
326 gnc_owner_get_owner (iw->owner_choice, &(iw->owner));
328 gnc_owner_get_owner (iw->job_choice, &(iw->job));
332 gncInvoiceSetOwner (invoice, &(iw->job));
334 gncInvoiceSetOwner (invoice, &(iw->owner));
337 gncInvoiceSetCurrency (invoice, gncOwnerGetCurrency (&iw->owner));
341 gncInvoiceSetBillTo (invoice, &iw->proj_job);
343 gncInvoiceSetBillTo (invoice, &iw->proj_cust);
347 if (iw->dialog_type == NEW_INVOICE || iw->dialog_type == DUP_INVOICE)
348 gncInvoiceSetIsCreditNote (invoice, iw->is_credit_note);
353 if (iw->dialog_type == DUP_INVOICE && iw->is_credit_note != is_credit_note)
355 g_list_foreach(gncInvoiceGetEntries(invoice),
356 &set_gncEntry_switch_type, NULL);
359 gncInvoiceCommitEdit (invoice);
360 gnc_resume_gui_refresh ();
370 if (!gnc_entry_ledger_check_close (iw_get_window(iw), iw->ledger))
374 gnc_owner_get_owner (iw->owner_choice, &(iw->owner));
375 res = gncOwnerGetName (&(iw->owner));
376 if (res == NULL || g_strcmp0 (res,
"") == 0)
378 gnc_error_dialog (iw_get_window(iw),
"%s",
384 _(
"You need to supply Billing Information."));
389 res = gtk_entry_get_text (GTK_ENTRY (iw->id_entry));
390 if (g_strcmp0 (res,
"") == 0)
396 string = gncInvoiceNextID(iw->book, &(iw->owner));
397 gtk_entry_set_text (GTK_ENTRY (iw->id_entry),
string);
407 if (!gnc_invoice_window_verify_ok (iw))
414 gnc_ui_to_invoice (iw, invoice);
417 iw->created_invoice = invoice;
423 gnc_invoice_window_ok_cb (GtkWidget *widget, gpointer data)
427 if (!gnc_invoice_window_ok_save (iw))
437 if ((iw->dialog_type == NEW_INVOICE || iw->dialog_type == DUP_INVOICE)
438 && iw->created_invoice)
439 gnc_ui_invoice_edit (iw->created_invoice);
441 gnc_close_gui_component (iw->component_id);
445 gnc_invoice_window_cancel_cb (GtkWidget *widget, gpointer data)
449 gnc_close_gui_component (iw->component_id);
453 gnc_invoice_window_help_cb (GtkWidget *widget, gpointer data)
459 gnc_invoice_window_destroy_cb (GtkWidget *widget, gpointer data)
464 gnc_suspend_gui_refresh ();
466 if ((iw->dialog_type == NEW_INVOICE || iw->dialog_type == DUP_INVOICE)
470 gncInvoiceBeginEdit (invoice);
471 gncInvoiceDestroy (invoice);
475 gnc_entry_ledger_destroy (iw->ledger);
476 gnc_unregister_gui_component (iw->component_id);
477 gtk_widget_destroy(widget);
478 gnc_resume_gui_refresh ();
484 gnc_invoice_window_closeCB (GtkWidget *widget, gpointer data)
486 gnc_invoice_window_ok_cb (widget, data);
490 gnc_invoice_window_editCB (GtkWidget *widget, gpointer data)
496 gnc_ui_invoice_modify (invoice);
500 gnc_invoice_window_duplicateInvoiceCB (GtkWidget *widget, gpointer data)
506 gnc_ui_invoice_duplicate (invoice, TRUE, NULL);
509 void gnc_invoice_window_entryUpCB (GtkWidget *widget, gpointer data)
512 if (!iw || !iw->ledger)
515 gnc_entry_ledger_move_current_entry_updown(iw->ledger, TRUE);
517 void gnc_invoice_window_entryDownCB (GtkWidget *widget, gpointer data)
520 if (!iw || !iw->ledger)
523 gnc_entry_ledger_move_current_entry_updown(iw->ledger, FALSE);
527 gnc_invoice_window_recordCB (GtkWidget *widget, gpointer data)
531 if (!iw || !iw->ledger)
534 if (!gnc_entry_ledger_commit_entry (iw->ledger))
537 gnucash_register_goto_next_virt_row (iw->reg);
541 gnc_invoice_window_cancelCB (GtkWidget *widget, gpointer data)
545 if (!iw || !iw->ledger)
548 gnc_entry_ledger_cancel_cursor_changes (iw->ledger);
552 gnc_invoice_window_deleteCB (GtkWidget *widget, gpointer data)
557 if (!iw || !iw->ledger)
561 entry = gnc_entry_ledger_get_current_entry (iw->ledger);
564 gnc_entry_ledger_cancel_cursor_changes (iw->ledger);
569 if (entry == gnc_entry_ledger_get_blank_entry (iw->ledger))
571 gnc_entry_ledger_cancel_cursor_changes (iw->ledger);
577 const char *message = _(
"Are you sure you want to delete the "
579 const char *order_warn = _(
"This entry is attached to an order and "
580 "will be deleted from that as well!");
584 if (gncEntryGetOrder (entry))
585 msg = g_strconcat (message,
"\n\n", order_warn, (
char *)NULL);
587 msg = g_strdup (message);
589 result = gnc_verify_dialog (iw_get_window(iw), FALSE,
"%s", msg);
597 gnc_entry_ledger_delete_current_entry (iw->ledger);
602 gnc_invoice_window_duplicateCB (GtkWidget *widget, gpointer data)
606 if (!iw || !iw->ledger)
609 gnc_entry_ledger_duplicate_current_entry (iw->ledger);
613 gnc_invoice_window_blankCB (GtkWidget *widget, gpointer data)
617 if (!iw || !iw->ledger)
620 if (!gnc_entry_ledger_commit_entry (iw->ledger))
627 blank = gnc_entry_ledger_get_blank_entry (iw->ledger);
631 if (gnc_entry_ledger_get_entry_virt_loc (iw->ledger, blank, &vcell_loc))
632 gnucash_register_goto_virt_cell (iw->reg, vcell_loc);
637 gnc_invoice_window_print_invoice(
GncInvoice *invoice)
642 const char *reportname = gnc_plugin_business_get_invoice_printreport();
644 g_return_if_fail (invoice);
646 reportname =
"5123a759ceb9483abf2182d01c140e8d";
648 func = scm_c_eval_string (
"gnc:invoice-report-create");
649 g_return_if_fail (scm_is_procedure (func));
651 arg = SWIG_NewPointerObj(invoice, SWIG_TypeQuery(
"_p__gncInvoice"), 0);
652 arg2 = scm_from_utf8_string(reportname);
653 args = scm_cons2 (arg, arg2, args);
657 arg = scm_apply (func, args, SCM_EOL);
658 g_return_if_fail (scm_is_exact (arg));
659 report_id = scm_to_int (arg);
663 reportWindow (report_id);
666 gnc_invoice_window_printCB (GtkWidget *unused_widget, gpointer data)
669 gnc_invoice_window_print_invoice(iw_get_invoice (iw));
675 char **memo,
Account **acc, gboolean *accumulate)
678 char *ddue_label, *post_label, *acct_label, *question_label;
679 GList * acct_types = NULL;
680 GList * acct_commodities = NULL;
682 EntryList *entries, *entries_iter;
684 invoice = iw_get_invoice (iw);
688 ddue_label = _(
"Due Date");
689 post_label = _(
"Post Date");
690 acct_label = _(
"Post to Account");
691 question_label = _(
"Accumulate Splits?");
700 entries = gncInvoiceGetEntries (invoice);
709 if (entries && ((gncInvoiceGetOwnerType (invoice) == GNC_OWNER_VENDOR) ||
710 (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_EMPLOYEE)))
713 for (entries_iter = entries; entries_iter != NULL; entries_iter = g_list_next(entries_iter))
719 *postdate = entrydate;
730 "invoice-last-posted-account", &guid,
737 if (!gnc_dialog_dates_acct_question_parented (iw_get_window(iw), message, ddue_label,
738 post_label, acct_label, question_label, TRUE, TRUE,
739 acct_types, acct_commodities, iw->book, iw->terms,
740 ddue, postdate, memo, acc, accumulate))
759 char *message, *memo;
765 GHashTable *foreign_currs;
766 GHashTableIter foreign_currs_iter;
768 gboolean is_cust_doc, auto_pay;
769 gboolean show_dialog = TRUE;
770 gboolean post_ok = TRUE;
773 if (!gnc_invoice_window_verify_ok (iw))
776 invoice = iw_get_invoice (iw);
781 if (gncInvoiceGetEntries (invoice) == NULL)
783 gnc_error_dialog (iw_get_window(iw),
"%s",
784 _(
"The Invoice must have at least one Entry."));
788 is_cust_doc = (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_CUSTOMER);
795 ddue = post_params->ddue;
796 postdate = post_params->postdate;
798 memo = g_strdup (post_params->memo);
799 acc = post_params->acc;
800 accumulate = post_params->accumulate;
804 message = _(
"Do you really want to post the invoice?");
805 if (!gnc_dialog_post_invoice(iw, message,
806 &ddue, &postdate, &memo, &acc, &accumulate))
814 gnc_suspend_gui_refresh ();
815 gncInvoiceBeginEdit (invoice);
816 gnc_invoice_window_ok_save (iw);
819 text = _(
"One or more of the entries are for accounts different from the invoice/bill currency. You will be asked a conversion rate for each.");
824 g_hash_table_iter_init (&foreign_currs_iter, foreign_currs);
825 while (g_hash_table_iter_next (&foreign_currs_iter, &key, &value))
832 convprice = gncInvoiceGetPrice (invoice, account_currency);
834 pricedate = gnc_price_get_time (convprice);
845 gnc_info_dialog(iw_get_window(iw),
"%s", text);
862 xfer = gnc_xfer_dialog (iw_get_window(iw), acc);
863 gnc_xfer_dialog_is_exchange_dialog(xfer, &exch_rate);
864 gnc_xfer_dialog_select_to_currency(xfer, account_currency);
875 gnc_xfer_dialog_set_from_show_button_active(xfer, FALSE);
876 gnc_xfer_dialog_set_to_show_button_active(xfer, FALSE);
877 gnc_xfer_dialog_hide_from_account_tree(xfer);
878 gnc_xfer_dialog_hide_to_account_tree(xfer);
879 if (gnc_xfer_dialog_run_until_done(xfer))
888 gnc_price_begin_edit (convprice);
889 gnc_price_set_commodity (convprice, account_currency);
890 gnc_price_set_currency (convprice, gncInvoiceGetCurrency (invoice));
891 gnc_price_set_time (convprice, postdate);
892 gnc_price_set_source (convprice,
"user:invoice-post");
896 gnc_price_set_typestr (convprice,
"last");
897 gnc_price_set_value (convprice, exch_rate);
898 gncInvoiceAddPrice(invoice, convprice);
899 gnc_price_commit_edit (convprice);
919 "invoice-last-posted-account", guid,
933 gncInvoiceCommitEdit (invoice);
934 g_hash_table_unref (foreign_currs);
935 gnc_resume_gui_refresh ();
943 iw->dialog_type = VIEW_INVOICE;
944 gnc_entry_ledger_set_readonly (iw->ledger, TRUE);
948 text = _(
"The post action was canceled because not all exchange rates were given.");
949 gnc_info_dialog(iw_get_window(iw),
"%s", text);
953 gnc_invoice_update_window (iw, NULL);
954 gnc_table_refresh_gui (gnc_entry_ledger_get_table (iw->ledger), FALSE);
958 gnc_invoice_window_postCB (GtkWidget *unused_widget, gpointer data)
961 gnc_invoice_post(iw, NULL);
965 gnc_invoice_window_unpostCB (GtkWidget *widget, gpointer data)
971 invoice = iw_get_invoice (iw);
976 result = iw_ask_unpost(iw);
980 gnc_suspend_gui_refresh ();
982 gnc_resume_gui_refresh ();
986 iw->dialog_type = EDIT_INVOICE;
987 gnc_entry_ledger_set_readonly (iw->ledger, FALSE);
988 gnc_invoice_update_window (iw, NULL);
989 gnc_table_refresh_gui (gnc_entry_ledger_get_table (iw->ledger), FALSE);
992 void gnc_invoice_window_cut_cb (GtkWidget *widget, gpointer data)
995 gnucash_register_cut_clipboard (iw->reg);
998 void gnc_invoice_window_copy_cb (GtkWidget *widget, gpointer data)
1001 gnucash_register_copy_clipboard (iw->reg);
1004 void gnc_invoice_window_paste_cb (GtkWidget *widget, gpointer data)
1007 gnucash_register_paste_clipboard (iw->reg);
1010 void gnc_invoice_window_new_invoice_cb (GtkWidget *widget, gpointer data)
1015 gnc_ui_invoice_new (&iw->job, iw->book);
1019 gnc_ui_invoice_new (&iw->owner, iw->book);
1030 g_return_if_fail (owner);
1034 func = scm_c_eval_string (
"gnc:owner-report-create");
1035 g_return_if_fail (scm_is_procedure (func));
1039 swig_type_info * qtype = SWIG_TypeQuery(
"_p_Account");
1040 g_return_if_fail (qtype);
1042 arg = SWIG_NewPointerObj(acc, qtype, 0);
1043 g_return_if_fail (arg != SCM_UNDEFINED);
1044 args = scm_cons (arg, args);
1048 args = scm_cons (SCM_BOOL_F, args);
1051 arg = SWIG_NewPointerObj(owner, SWIG_TypeQuery(
"_p__gncOwner"), 0);
1052 g_return_if_fail (arg != SCM_UNDEFINED);
1053 args = scm_cons (arg, args);
1056 arg = scm_apply (func, args, SCM_EOL);
1057 g_return_if_fail (scm_is_exact (arg));
1058 id = scm_to_int (arg);
1064 void gnc_invoice_window_report_owner_cb (GtkWidget *widget, gpointer data)
1067 gnc_business_call_owner_report (&iw->owner, NULL);
1070 void gnc_invoice_window_payment_cb (GtkWidget *widget, gpointer data)
1076 gnc_ui_payment_new_with_invoice (&iw->job, iw->book, invoice);
1078 gnc_ui_payment_new_with_invoice (&iw->owner, iw->book, invoice);
1084 gnc_invoice_window_sort (
InvoiceWindow *iw, invoice_sort_type_t sort_code)
1086 QofQuery *query = gnc_entry_ledger_get_query (iw->ledger);
1087 GSList *p1 = NULL, *p2 = NULL, *p3 = NULL, *standard;
1089 if (iw->last_sort == sort_code)
1096 case INVSORT_BY_STANDARD:
1099 case INVSORT_BY_DATE:
1100 p1 = g_slist_prepend (p1, ENTRY_DATE);
1103 case INVSORT_BY_DATE_ENTERED:
1104 p1 = g_slist_prepend (p1, ENTRY_DATE_ENTERED);
1107 case INVSORT_BY_DESC:
1108 p1 = g_slist_prepend (p1, ENTRY_DESC);
1111 case INVSORT_BY_QTY:
1112 p1 = g_slist_prepend (p1, ENTRY_QTY);
1115 case INVSORT_BY_PRICE:
1116 p1 = g_slist_prepend (p1, ((iw->owner.type == GNC_OWNER_CUSTOMER) ?
1117 ENTRY_IPRICE : ENTRY_BPRICE));
1121 g_slist_free (standard);
1122 g_return_if_fail (FALSE);
1127 iw->last_sort = sort_code;
1128 gnc_entry_ledger_display_refresh (iw->ledger);
1134 gnc_invoice_window_active_toggled_cb (GtkWidget *widget, gpointer data)
1139 if (!invoice)
return;
1141 gncInvoiceSetActive (invoice,
1142 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
1146 gnc_invoice_window_leave_notes_cb (GtkWidget *widget, GdkEventFocus *event,
1151 GtkTextBuffer* text_buffer;
1152 GtkTextIter start, end;
1155 if (!invoice)
return FALSE;
1157 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(iw->notes_text));
1158 gtk_text_buffer_get_bounds (text_buffer, &start, &end);
1159 text = gtk_text_buffer_get_text (text_buffer, &start, &end, FALSE);
1160 gncInvoiceSetNotes (invoice, text);
1165 gnc_invoice_window_leave_to_charge_cb (GtkWidget *widget, GdkEventFocus *event,
1168 gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (widget));
1173 gnc_invoice_window_changed_to_charge_cb (GtkWidget *widget, gpointer data)
1178 if (!invoice)
return;
1180 gncInvoiceSetToChargeAmount (invoice, gnc_amount_edit_get_amount
1181 (GNC_AMOUNT_EDIT (widget)));
1185 add_summary_label (GtkWidget *summarybar,
const char *label_str)
1190 hbox = gtk_hbox_new(FALSE, 2);
1191 gtk_box_pack_start (GTK_BOX(summarybar), hbox, FALSE, FALSE, 5);
1193 label = gtk_label_new (label_str);
1194 gtk_misc_set_alignment (GTK_MISC(label), 1.0, 0.5);
1195 gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
1197 label = gtk_label_new (
"");
1198 gtk_misc_set_alignment (GTK_MISC(label), 1.0, 0.5);
1199 gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
1207 GtkWidget *summarybar;
1209 iw->total_label = NULL;
1210 iw->total_cash_label = NULL;
1211 iw->total_charge_label = NULL;
1212 iw->total_subtotal_label = NULL;
1213 iw->total_tax_label = NULL;
1215 summarybar = gtk_hbox_new (FALSE, 4);
1217 iw->total_label = add_summary_label (summarybar, _(
"Total:"));
1221 case GNC_OWNER_CUSTOMER:
1222 case GNC_OWNER_VENDOR:
1223 iw->total_subtotal_label = add_summary_label (summarybar, _(
"Subtotal:"));
1224 iw->total_tax_label = add_summary_label (summarybar, _(
"Tax:"));
1227 case GNC_OWNER_EMPLOYEE:
1228 iw->total_cash_label = add_summary_label (summarybar, _(
"Total Cash:"));
1229 iw->total_charge_label = add_summary_label (summarybar, _(
"Total Charge:"));
1236 gtk_widget_show_all(summarybar);
1241 gnc_invoice_job_changed_cb (GtkWidget *widget, gpointer data)
1244 char const *msg =
"";
1249 if (iw->dialog_type == VIEW_INVOICE)
1252 gnc_owner_get_owner (iw->job_choice, &(iw->job));
1254 if (iw->dialog_type == EDIT_INVOICE)
1258 gtk_entry_set_text (GTK_ENTRY (iw->billing_id_entry), msg ? msg :
"");
1265 gnc_invoice_select_job_cb (gpointer jobp, gpointer user_data)
1271 if (!iw)
return NULL;
1275 ownerp = gncJobGetOwner (j);
1276 gncOwnerCopy (ownerp, &owner);
1279 gncOwnerCopy (&(iw->owner), &owner);
1281 return gnc_job_search (j, &owner, iw->book);
1288 gtk_container_remove (GTK_CONTAINER (iw->job_box), iw->job_choice);
1291 if (iw->owner.owner.undefined == NULL)
1293 iw->job_choice = NULL;
1296 switch (iw->dialog_type)
1301 gnc_owner_edit_create (NULL, iw->job_box, iw->book, &(iw->job));
1307 gnc_general_search_new (GNC_JOB_MODULE_NAME, _(
"Select..."), TRUE,
1308 gnc_invoice_select_job_cb, iw, iw->book);
1310 gnc_general_search_set_selected (GNC_GENERAL_SEARCH (iw->job_choice),
1312 gnc_general_search_allow_clear (GNC_GENERAL_SEARCH (iw->job_choice),
1314 gtk_box_pack_start (GTK_BOX (iw->job_box), iw->job_choice,
1317 g_signal_connect (G_OBJECT (iw->job_choice),
"changed",
1318 G_CALLBACK (gnc_invoice_job_changed_cb), iw);
1323 gtk_widget_show_all (iw->job_choice);
1327 gnc_invoice_select_proj_job_cb (gpointer jobp, gpointer user_data)
1333 if (!iw)
return NULL;
1337 ownerp = gncJobGetOwner (j);
1338 gncOwnerCopy (ownerp, &owner);
1341 gncOwnerCopy (&(iw->proj_cust), &owner);
1343 return gnc_job_search (j, &owner, iw->book);
1347 gnc_invoice_proj_job_changed_cb (GtkWidget *widget, gpointer data)
1354 if (iw->dialog_type == VIEW_INVOICE)
1357 gnc_owner_get_owner (iw->proj_job_choice, &(iw->proj_job));
1364 if (iw->proj_job_choice)
1365 gtk_container_remove (GTK_CONTAINER (iw->proj_job_box),
1366 iw->proj_job_choice);
1368 switch (iw->dialog_type)
1372 iw->proj_job_choice =
1373 gnc_owner_edit_create (NULL, iw->proj_job_box, iw->book, &(iw->proj_job));
1378 if (iw->proj_cust.owner.undefined == NULL)
1380 iw->proj_job_choice = NULL;
1384 iw->proj_job_choice =
1385 gnc_general_search_new (GNC_JOB_MODULE_NAME, _(
"Select..."), TRUE,
1386 gnc_invoice_select_proj_job_cb, iw, iw->book);
1388 gnc_general_search_set_selected (GNC_GENERAL_SEARCH(iw->proj_job_choice),
1390 gnc_general_search_allow_clear (GNC_GENERAL_SEARCH (iw->proj_job_choice),
1392 gtk_box_pack_start (GTK_BOX (iw->proj_job_box), iw->proj_job_choice,
1395 g_signal_connect (G_OBJECT (iw->proj_job_choice),
"changed",
1396 G_CALLBACK (gnc_invoice_proj_job_changed_cb), iw);
1401 if (iw->proj_job_choice)
1402 gtk_widget_show_all (iw->proj_job_choice);
1406 gnc_invoice_owner_changed_cb (GtkWidget *widget, gpointer data)
1415 if (iw->dialog_type == VIEW_INVOICE)
1418 gncOwnerCopy (&(iw->owner), &owner);
1419 gnc_owner_get_owner (iw->owner_choice, &owner);
1424 gncOwnerCopy (&owner, &(iw->owner));
1425 gncOwnerInitJob (&(iw->job), NULL);
1426 gnc_entry_ledger_reset_query (iw->ledger);
1429 if (iw->dialog_type == EDIT_INVOICE)
1434 case GNC_OWNER_CUSTOMER:
1437 case GNC_OWNER_VENDOR:
1440 case GNC_OWNER_EMPLOYEE:
1444 g_warning (
"Unknown owner type: %d\n",
gncOwnerGetType (&(iw->owner)));
1450 gnc_simple_combo_set_value (GTK_COMBO_BOX(iw->terms_menu), iw->terms);
1452 gnc_invoice_update_job_choice (iw);
1458 gnc_invoice_proj_cust_changed_cb (GtkWidget *widget, gpointer data)
1466 if (iw->dialog_type == VIEW_INVOICE)
1469 gncOwnerCopy (&(iw->proj_cust), &owner);
1470 gnc_owner_get_owner (iw->proj_cust_choice, &owner);
1475 gncOwnerCopy (&owner, &(iw->proj_cust));
1476 gncOwnerInitJob (&(iw->proj_job), NULL);
1479 if (iw->dialog_type == EDIT_INVOICE)
1482 gnc_invoice_update_proj_job (iw);
1488 gnc_invoice_dialog_close_handler (gpointer user_data)
1494 gtk_widget_destroy (iw->dialog);
1499 gnc_invoice_window_close_handler (gpointer user_data)
1517 gtk_label_set_text (label,
string);
1526 gnc_numeric amount, to_charge_amt = gnc_numeric_zero();
1534 invoice = iw_get_invoice (iw);
1538 currency = gncInvoiceGetCurrency (invoice);
1540 if (iw->total_label)
1543 gnc_invoice_reset_total_label (GTK_LABEL (iw->total_label), amount, currency);
1546 if (iw->total_subtotal_label)
1548 amount = gncInvoiceGetTotalSubtotal (invoice);
1549 gnc_invoice_reset_total_label (GTK_LABEL (iw->total_subtotal_label), amount, currency);
1552 if (iw->total_tax_label)
1554 amount = gncInvoiceGetTotalTax (invoice);
1555 gnc_invoice_reset_total_label (GTK_LABEL (iw->total_tax_label), amount, currency);
1560 if (iw->to_charge_edit)
1562 gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (iw->to_charge_edit));
1563 to_charge_amt = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(iw->to_charge_edit));
1566 if (iw->total_cash_label)
1568 amount = gncInvoiceGetTotalOf (invoice, GNC_PAYMENT_CASH);
1571 gnc_invoice_reset_total_label (GTK_LABEL (iw->total_cash_label), amount, currency);
1574 if (iw->total_charge_label)
1576 amount = gncInvoiceGetTotalOf (invoice, GNC_PAYMENT_CARD);
1579 gnc_invoice_reset_total_label (GTK_LABEL (iw->total_charge_label), amount, currency);
1584 gnc_invoice_window_changed (
InvoiceWindow *iw, GtkWidget *window)
1586 gnc_entry_ledger_set_parent(iw->ledger, window);
1595 return gnc_table_get_help (gnc_entry_ledger_get_table (iw->ledger));
1599 gnc_invoice_window_refresh_handler (GHashTable *changes, gpointer user_data)
1609 gnc_close_gui_component (iw->component_id);
1616 info = gnc_gui_get_entity_events (changes, &iw->invoice_guid);
1617 if (info && (info->event_mask & QOF_EVENT_DESTROY))
1619 gnc_close_gui_component (iw->component_id);
1625 owner = gncInvoiceGetOwner (invoice);
1632 owner = gncInvoiceGetBillTo (invoice);
1637 gnc_invoice_update_window (iw, NULL);
1651 gnc_invoice_update_window (
InvoiceWindow *iw, GtkWidget *widget)
1653 GtkWidget *acct_entry;
1655 gboolean is_posted = FALSE;
1656 gboolean can_unpost = FALSE;
1658 invoice = iw_get_invoice (iw);
1660 if (iw->owner_choice)
1661 gtk_container_remove (GTK_CONTAINER (iw->owner_box), iw->owner_choice);
1663 if (iw->proj_cust_choice)
1664 gtk_container_remove (GTK_CONTAINER (iw->proj_cust_box),
1665 iw->proj_cust_choice);
1667 switch (iw->dialog_type)
1672 gnc_owner_edit_create (iw->owner_label, iw->owner_box, iw->book,
1674 iw->proj_cust_choice =
1675 gnc_owner_edit_create (NULL, iw->proj_cust_box, iw->book,
1682 gnc_owner_select_create (iw->owner_label, iw->owner_box, iw->book,
1684 iw->proj_cust_choice =
1685 gnc_owner_select_create (NULL, iw->proj_cust_box, iw->book,
1688 g_signal_connect (G_OBJECT (iw->owner_choice),
"changed",
1689 G_CALLBACK (gnc_invoice_owner_changed_cb), iw);
1691 g_signal_connect (G_OBJECT (iw->proj_cust_choice),
"changed",
1692 G_CALLBACK (gnc_invoice_proj_cust_changed_cb), iw);
1698 gtk_label_set_text (GTK_LABEL(iw->type_label), iw->is_credit_note ? _(
"Credit Note")
1699 : gtk_label_get_text (GTK_LABEL(iw->type_label)));
1701 if (iw->owner_choice)
1702 gtk_widget_show_all (iw->owner_choice);
1703 if (iw->proj_cust_choice)
1704 gtk_widget_show_all (iw->proj_cust_choice);
1706 gnc_invoice_update_job_choice (iw);
1707 gnc_invoice_update_proj_job (iw);
1710 if (iw->owner.type == GNC_OWNER_CUSTOMER)
1711 gtk_widget_hide (iw->proj_frame);
1714 if (iw->owner.type == GNC_OWNER_EMPLOYEE)
1716 gtk_widget_hide (iw->job_label);
1717 gtk_widget_hide (iw->job_box);
1720 acct_entry = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"acct_entry"));
1724 GtkTextBuffer* text_buffer;
1730 gtk_entry_set_text (GTK_ENTRY (iw->id_entry), gncInvoiceGetID (invoice));
1732 gtk_entry_set_text (GTK_ENTRY (iw->billing_id_entry),
1733 gncInvoiceGetBillingID (invoice));
1735 string = gncInvoiceGetNotes (invoice);
1736 text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(iw->notes_text));
1737 gtk_text_buffer_set_text (text_buffer,
string, -1);
1739 if (iw->active_check)
1740 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (iw->active_check),
1741 gncInvoiceGetActive (invoice));
1743 ts = gncInvoiceGetDateOpened (invoice);
1746 gnc_date_edit_set_time (GNC_DATE_EDIT (iw->opened_date),
1751 gnc_date_edit_set_time_ts (GNC_DATE_EDIT (iw->opened_date), ts);
1755 iw->terms = gncInvoiceGetTerms (invoice);
1756 gnc_simple_combo_set_value (GTK_COMBO_BOX(iw->terms_menu), iw->terms);
1764 acct = gncInvoiceGetPostedAcc (invoice);
1776 ts = gncInvoiceGetDatePosted (invoice);
1777 gnc_date_edit_set_time_ts (GNC_DATE_EDIT (iw->posted_date), ts);
1780 gtk_entry_set_text (GTK_ENTRY (acct_entry), tmp_string);
1785 gnc_invoice_id_changed_cb(NULL, iw);
1786 if (iw->dialog_type == NEW_INVOICE ||
1787 iw->dialog_type == DUP_INVOICE ||
1788 iw->dialog_type == MOD_INVOICE)
1791 gtk_widget_show (widget);
1793 gtk_widget_show (iw_get_window(iw));
1801 amount = gncInvoiceGetToChargeAmount (invoice);
1802 gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (iw->to_charge_edit), amount);
1808 GtkWidget *hide, *show;
1810 if (is_posted == TRUE)
1812 hide = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"hide3"));
1813 gtk_widget_hide (hide);
1814 hide = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"hide4"));
1815 gtk_widget_hide (hide);
1817 show = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"posted_label"));
1818 gtk_widget_show (show);
1819 gtk_widget_show (iw->posted_date_hbox);
1820 show = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"acct_label"));
1821 gtk_widget_show (show);
1822 gtk_widget_show (acct_entry);
1824 show = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"hide1"));
1825 gtk_widget_show (show);
1826 show = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"hide2"));
1827 gtk_widget_show (show);
1831 hide = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"posted_label"));
1832 gtk_widget_hide (hide);
1833 gtk_widget_hide (iw->posted_date_hbox);
1835 hide = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"acct_label"));
1836 gtk_widget_hide (hide);
1837 gtk_widget_hide (acct_entry);
1839 hide = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"hide1"));
1840 gtk_widget_hide (hide);
1841 hide = GTK_WIDGET (gtk_builder_get_object (iw->builder,
"hide2"));
1842 gtk_widget_hide (hide);
1851 gtk_widget_set_sensitive (iw->to_charge_edit, !is_posted);
1856 if (iw->owner.type == GNC_OWNER_EMPLOYEE)
1859 gtk_widget_set_sensitive (iw->to_charge_edit, FALSE);
1863 gtk_widget_hide (iw->to_charge_frame);
1878 gtk_widget_show (widget);
1880 gtk_widget_show (iw_get_window(iw));
1886 char *wintitle = NULL;
1887 const char *
id = NULL;
1889 if (!iw)
return NULL;
1893 case GNC_OWNER_CUSTOMER:
1894 switch (iw->dialog_type)
1897 wintitle = iw->is_credit_note ? _(
"New Credit Note")
1903 wintitle = iw->is_credit_note ? _(
"Edit Credit Note")
1904 : _(
"Edit Invoice");
1907 wintitle = iw->is_credit_note ? _(
"View Credit Note")
1908 : _(
"View Invoice");
1912 case GNC_OWNER_VENDOR:
1913 switch (iw->dialog_type)
1916 wintitle = iw->is_credit_note ? _(
"New Credit Note")
1922 wintitle = iw->is_credit_note ? _(
"Edit Credit Note")
1926 wintitle = iw->is_credit_note ? _(
"View Credit Note")
1931 case GNC_OWNER_EMPLOYEE:
1932 switch (iw->dialog_type)
1935 wintitle = iw->is_credit_note ? _(
"New Credit Note")
1936 : _(
"New Expense Voucher");
1941 wintitle = iw->is_credit_note ? _(
"Edit Credit Note")
1942 : _(
"Edit Expense Voucher");
1945 wintitle = iw->is_credit_note ? _(
"View Credit Note")
1946 : _(
"View Expense Voucher");
1955 id = gtk_entry_get_text (GTK_ENTRY (iw->id_entry));
1957 return g_strconcat (wintitle,
" - ",
id, (
char *)NULL);
1958 return g_strdup (wintitle);
1962 gnc_invoice_type_toggled_cb (GtkWidget *widget, gpointer data)
1967 iw->is_credit_note = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
1971 gnc_invoice_id_changed_cb (GtkWidget *unused, gpointer data)
1983 title = gnc_invoice_get_title (iw);
1984 gtk_window_set_title (GTK_WINDOW (iw->dialog), title);
1990 gnc_invoice_terms_changed_cb (GtkWidget *widget, gpointer data)
1992 GtkComboBox *cbox = GTK_COMBO_BOX (widget);
1998 iw->terms = gnc_simple_combo_get_value (cbox);
2003 find_handler (gpointer
find_data, gpointer user_data)
2005 const GncGUID *invoice_guid = find_data;
2008 return(iw &&
guid_equal(&iw->invoice_guid, invoice_guid));
2012 gnc_invoice_new_page (
QofBook *bookp, InvoiceDialogType type,
2020 g_assert (type != NEW_INVOICE && type != MOD_INVOICE && type != DUP_INVOICE);
2021 g_assert (invoice != NULL);
2032 iw = gnc_find_first_gui_component (DIALOG_VIEW_INVOICE_CM_CLASS,
2033 find_handler, &invoice_guid);
2046 iw->dialog_type = type;
2048 iw->is_credit_note = gncInvoiceGetIsCreditNote (invoice);
2055 billto = gncInvoiceGetBillTo (invoice);
2064 window = gnc_plugin_business_get_window ();
2069 gnc_invoice_redraw_all_cb(iw->reg, iw);
2074 #define KEY_INVOICE_TYPE "InvoiceType"
2075 #define KEY_INVOICE_GUID "InvoiceGUID"
2076 #define KEY_OWNER_TYPE "OwnerType"
2077 #define KEY_OWNER_GUID "OwnerGUID"
2082 const gchar *group_name)
2085 GError *error = NULL;
2086 char *tmp_string = NULL, *owner_type = NULL;
2087 InvoiceDialogType type;
2094 tmp_string = g_key_file_get_string(key_file, group_name,
2095 KEY_INVOICE_TYPE, &error);
2098 g_warning(
"Error reading group %s key %s: %s.",
2099 group_name, KEY_INVOICE_TYPE, error->message);
2102 type = InvoiceDialogTypefromString(tmp_string);
2106 tmp_string = g_key_file_get_string(key_file, group_name,
2107 KEY_INVOICE_GUID, &error);
2110 g_warning(
"Error reading group %s key %s: %s.",
2111 group_name, KEY_INVOICE_GUID, error->message);
2116 g_warning(
"Invalid invoice guid: %s.", tmp_string);
2119 book = gnc_get_current_book();
2120 invoice = gncInvoiceLookup(gnc_get_current_book(), &guid);
2121 if (invoice == NULL)
2123 g_warning(
"Can't find invoice %s in current book.", tmp_string);
2129 owner_type = g_key_file_get_string(key_file, group_name,
2130 KEY_OWNER_TYPE, &error);
2133 g_warning(
"Error reading group %s key %s: %s.",
2134 group_name, KEY_OWNER_TYPE, error->message);
2139 tmp_string = g_key_file_get_string(key_file, group_name,
2140 KEY_OWNER_GUID, &error);
2143 g_warning(
"Error reading group %s key %s: %s.",
2144 group_name, KEY_OWNER_GUID, error->message);
2149 g_warning(
"Invalid owner guid: %s.", tmp_string);
2153 if (!gncOwnerGetOwnerFromTypeGuid(book, &owner, owner_type, &guid))
2155 g_warning(
"Can't find owner %s in current book.", tmp_string);
2161 iw = gnc_invoice_new_page (book, type, invoice, &owner, window);
2165 g_warning(
"Giving up on restoring '%s'.", group_name);
2167 g_error_free(error);
2178 const gchar *group_name)
2182 g_key_file_set_string(key_file, group_name, KEY_INVOICE_TYPE,
2183 InvoiceDialogTypeasString(iw->dialog_type));
2184 g_key_file_set_string(key_file, group_name, KEY_INVOICE_GUID, guidstr);
2188 g_key_file_set_string(key_file, group_name, KEY_OWNER_TYPE,
2191 g_key_file_set_string(key_file, group_name, KEY_OWNER_GUID, guidstr);
2195 g_key_file_set_string(key_file, group_name, KEY_OWNER_TYPE,
2198 g_key_file_set_string(key_file, group_name, KEY_OWNER_GUID, guidstr);
2206 GtkBuilder *builder;
2207 GtkWidget *id_label;
2208 GtkWidget *dialog, *hbox;
2210 GncOwnerType owner_type;
2211 GncEntryLedgerType ledger_type;
2212 const gchar *prefs_group = NULL;
2213 gboolean is_credit_note = FALSE;
2215 invoice = gncInvoiceLookup (iw->book, &iw->invoice_guid);
2216 is_credit_note = gncInvoiceGetIsCreditNote (invoice);
2221 iw->builder = builder = gtk_builder_new();
2222 gnc_builder_add_from_file (builder,
"dialog-invoice.glade",
"terms_store");
2223 gnc_builder_add_from_file (builder,
"dialog-invoice.glade",
"invoice_entry_vbox");
2224 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"invoice_entry_vbox"));
2227 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, iw);
2230 iw->id_label = GTK_WIDGET (gtk_builder_get_object (builder,
"label3"));
2231 iw->type_label = GTK_WIDGET (gtk_builder_get_object (builder,
"page_type_label"));
2232 iw->info_label = GTK_WIDGET (gtk_builder_get_object (builder,
"label25"));
2233 iw->id_entry = GTK_WIDGET (gtk_builder_get_object (builder,
"page_id_entry"));
2234 iw->billing_id_entry = GTK_WIDGET (gtk_builder_get_object (builder,
"page_billing_id_entry"));
2235 iw->terms_menu = GTK_WIDGET (gtk_builder_get_object (builder,
"page_terms_menu"));
2236 iw->notes_text = GTK_WIDGET (gtk_builder_get_object (builder,
"page_notes_text"));
2237 iw->active_check = GTK_WIDGET (gtk_builder_get_object (builder,
"active_check"));
2238 iw->owner_box = GTK_WIDGET (gtk_builder_get_object (builder,
"page_owner_hbox"));
2239 iw->owner_label = GTK_WIDGET (gtk_builder_get_object (builder,
"page_owner_label"));
2240 iw->job_label = GTK_WIDGET (gtk_builder_get_object (builder,
"page_job_label"));
2241 iw->job_box = GTK_WIDGET (gtk_builder_get_object (builder,
"page_job_hbox"));
2244 iw->proj_frame = GTK_WIDGET (gtk_builder_get_object (builder,
"page_proj_frame"));
2245 iw->proj_cust_box = GTK_WIDGET (gtk_builder_get_object (builder,
"page_proj_cust_hbox"));
2246 iw->proj_job_box = GTK_WIDGET (gtk_builder_get_object (builder,
"page_proj_job_hbox"));
2255 iw->to_charge_frame = GTK_WIDGET (gtk_builder_get_object (builder,
"to_charge_frame"));
2256 edit = gnc_amount_edit_new();
2257 print_info = gnc_commodity_print_info (currency, FALSE);
2258 gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
2259 gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
2260 gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit),
2262 iw->to_charge_edit = edit;
2263 gtk_widget_show (edit);
2264 hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"to_charge_box"));
2265 gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);
2267 g_signal_connect(G_OBJECT(gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(edit))),
2269 G_CALLBACK(gnc_invoice_window_leave_to_charge_cb), iw);
2270 g_signal_connect(G_OBJECT(edit),
"amount_changed",
2271 G_CALLBACK(gnc_invoice_window_changed_to_charge_cb), iw);
2274 hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"page_date_opened_hbox"));
2275 iw->opened_date = gnc_date_edit_new (
gnc_time (NULL), FALSE, FALSE);
2276 gtk_widget_show(iw->opened_date);
2277 gtk_box_pack_start (GTK_BOX(hbox), iw->opened_date, TRUE, TRUE, 0);
2279 iw->posted_date_hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"date_posted_hbox"));
2280 iw->posted_date = gnc_date_edit_new (
gnc_time (NULL), FALSE, FALSE);
2281 gtk_widget_show(iw->posted_date);
2282 gtk_box_pack_start (GTK_BOX(iw->posted_date_hbox), iw->posted_date,
2286 gtk_widget_set_sensitive (iw->opened_date, FALSE);
2287 gtk_widget_set_sensitive (iw->posted_date, FALSE);
2290 ledger_type = GNCENTRY_INVOICE_VIEWER;
2292 switch (iw->dialog_type)
2297 case GNC_OWNER_CUSTOMER:
2298 ledger_type = is_credit_note ? GNCENTRY_CUST_CREDIT_NOTE_ENTRY
2299 : GNCENTRY_INVOICE_ENTRY;
2301 case GNC_OWNER_VENDOR:
2302 ledger_type = is_credit_note ? GNCENTRY_VEND_CREDIT_NOTE_ENTRY
2303 : GNCENTRY_BILL_ENTRY;
2305 case GNC_OWNER_EMPLOYEE:
2306 ledger_type = is_credit_note ? GNCENTRY_EMPL_CREDIT_NOTE_ENTRY
2307 : GNCENTRY_EXPVOUCHER_ENTRY;
2310 g_warning (
"Invalid owner type");
2318 case GNC_OWNER_CUSTOMER:
2319 ledger_type = is_credit_note ? GNCENTRY_CUST_CREDIT_NOTE_VIEWER
2320 : GNCENTRY_INVOICE_VIEWER;
2321 prefs_group = GNC_PREFS_GROUP_INVOICE;
2323 case GNC_OWNER_VENDOR:
2324 ledger_type = is_credit_note ? GNCENTRY_VEND_CREDIT_NOTE_VIEWER
2325 : GNCENTRY_BILL_VIEWER;
2326 prefs_group = GNC_PREFS_GROUP_BILL;
2328 case GNC_OWNER_EMPLOYEE:
2329 ledger_type = is_credit_note ? GNCENTRY_EMPL_CREDIT_NOTE_VIEWER
2330 : GNCENTRY_EXPVOUCHER_VIEWER;
2331 prefs_group = GNC_PREFS_GROUP_BILL;
2334 g_warning (
"Invalid owner type");
2342 case GNC_OWNER_VENDOR:
2343 gtk_label_set_text (GTK_LABEL(iw->info_label), _(
"Bill Information"));
2344 gtk_label_set_text (GTK_LABEL(iw->type_label), _(
"Bill"));
2345 gtk_label_set_text (GTK_LABEL(iw->id_label), _(
"Bill ID"));
2347 case GNC_OWNER_EMPLOYEE:
2348 gtk_label_set_text (GTK_LABEL(iw->info_label), _(
"Voucher Information"));
2349 gtk_label_set_text (GTK_LABEL(iw->type_label), _(
"Voucher"));
2350 gtk_label_set_text (GTK_LABEL(iw->id_label), _(
"Voucher ID"));
2355 entry_ledger = gnc_entry_ledger_new (iw->book, ledger_type);
2358 iw->ledger = entry_ledger;
2362 gnc_entry_ledger_set_default_invoice (entry_ledger, invoice);
2365 gnc_entry_ledger_set_prefs_group (entry_ledger, prefs_group);
2369 gnc_register_gui_component (DIALOG_VIEW_INVOICE_CM_CLASS,
2370 gnc_invoice_window_refresh_handler,
2371 gnc_invoice_window_close_handler,
2374 gnc_gui_component_watch_entity_type (iw->component_id,
2375 GNC_INVOICE_MODULE_NAME,
2376 QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
2380 GtkWidget *regWidget, *frame, *window;
2383 regWidget = gnucash_register_new (gnc_entry_ledger_get_table
2385 gtk_widget_show(regWidget);
2388 frame = GTK_WIDGET (gtk_builder_get_object (builder,
"ledger_frame"));
2389 gtk_container_add (GTK_CONTAINER (frame), regWidget);
2391 iw->reg = GNUCASH_REGISTER (regWidget);
2393 gnucash_sheet_set_window (gnucash_register_get_sheet (iw->reg), window);
2395 g_signal_connect (G_OBJECT (regWidget),
"activate_cursor",
2396 G_CALLBACK (gnc_invoice_window_recordCB), iw);
2397 g_signal_connect (G_OBJECT (regWidget),
"redraw_all",
2398 G_CALLBACK (gnc_invoice_redraw_all_cb), iw);
2401 gnc_table_realize_gui (gnc_entry_ledger_get_table (entry_ledger));
2404 gnc_billterms_combo (GTK_COMBO_BOX(iw->terms_menu), iw->book, TRUE, iw->terms);
2405 gnc_invoice_update_window (iw, dialog);
2407 gnc_table_refresh_gui (gnc_entry_ledger_get_table (iw->ledger), TRUE);
2416 gnc_invoice_window_new_invoice (InvoiceDialogType dialog_type,
QofBook *bookp,
2420 GtkBuilder *builder;
2422 GtkWidget *invoice_radio;
2426 GncOwnerType owner_type;
2428 g_assert (dialog_type == NEW_INVOICE || dialog_type == MOD_INVOICE || dialog_type == DUP_INVOICE);
2439 iw = gnc_find_first_gui_component (DIALOG_NEW_INVOICE_CM_CLASS,
2440 find_handler, &invoice_guid);
2443 gtk_window_present (GTK_WINDOW(iw->dialog));
2453 iw->dialog_type = dialog_type;
2455 switch (dialog_type)
2460 invoice = gncInvoiceCreate (bookp);
2463 start_owner = owner;
2466 case GNC_OWNER_CUSTOMER:
2469 case GNC_OWNER_VENDOR:
2476 gncInvoiceSetTerms (invoice, owner_terms);
2481 start_owner = gncInvoiceGetOwner (invoice);
2482 iw->book = gncInvoiceGetBook (invoice);
2493 billto = gncInvoiceGetBillTo (invoice);
2498 iw->builder = builder = gtk_builder_new();
2499 gnc_builder_add_from_file (builder,
"dialog-invoice.glade",
"terms_store");
2500 gnc_builder_add_from_file (builder,
"dialog-invoice.glade",
"New Invoice Dialog");
2501 iw->dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"New Invoice Dialog"));
2503 g_object_set_data (G_OBJECT (iw->dialog),
"dialog_info", iw);
2506 iw->type_label = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_type_label"));
2507 iw->id_label = GTK_WIDGET (gtk_builder_get_object (builder,
"label14"));
2508 iw->info_label = GTK_WIDGET (gtk_builder_get_object (builder,
"label1"));
2509 invoice_radio = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_invoice_type"));
2511 iw->type_hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_type_choice_hbox"));
2512 iw->type_choice = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_type_invoice"));
2518 case GNC_OWNER_VENDOR:
2519 gtk_label_set_text (GTK_LABEL(iw->info_label), _(
"Bill Information"));
2520 gtk_label_set_text (GTK_LABEL(iw->type_label), _(
"Bill"));
2521 gtk_button_set_label (GTK_BUTTON(invoice_radio), _(
"Bill"));
2522 gtk_label_set_text (GTK_LABEL(iw->id_label), _(
"Bill ID"));
2525 case GNC_OWNER_EMPLOYEE:
2526 gtk_label_set_text (GTK_LABEL(iw->info_label), _(
"Voucher Information"));
2527 gtk_label_set_text (GTK_LABEL(iw->type_label), _(
"Voucher"));
2528 gtk_button_set_label (GTK_BUTTON(invoice_radio), _(
"Voucher"));
2529 gtk_label_set_text (GTK_LABEL(iw->id_label), _(
"Voucher ID"));
2535 switch (dialog_type)
2539 gtk_widget_show_all (iw->type_hbox);
2540 gtk_widget_hide (iw->type_label);
2543 gtk_widget_hide (iw->type_hbox);
2544 gtk_widget_show (iw->type_label);
2550 if (dialog_type == DUP_INVOICE)
2552 GtkWidget *invoice_radio = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_invoice_type"));
2553 GtkWidget *cn_radio = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_creditnote_type"));
2555 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(cn_radio), gncInvoiceGetIsCreditNote (invoice));
2558 iw->id_entry = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_id_entry"));
2559 iw->billing_id_entry = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_billing_id_entry"));
2560 iw->terms_menu = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_terms_menu"));
2561 iw->notes_text = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_notes_text"));
2562 iw->owner_box = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_owner_hbox"));
2563 iw->owner_label = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_owner_label"));
2564 iw->job_label = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_job_label"));
2565 iw->job_box = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_job_hbox"));
2568 iw->proj_frame = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_proj_frame"));
2569 iw->proj_cust_box = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_proj_cust_hbox"));
2570 iw->proj_job_box = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_proj_job_hbox"));
2572 hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"dialog_date_opened_hbox"));
2573 iw->opened_date = gnc_date_edit_new (
gnc_time (NULL), FALSE, FALSE);
2574 gtk_widget_show(iw->opened_date);
2575 gtk_box_pack_start (GTK_BOX(hbox), iw->opened_date, TRUE, TRUE, 0);
2578 gtk_widget_set_sensitive (iw->notes_text, (iw->dialog_type == NEW_INVOICE));
2581 gtk_builder_connect_signals_full( builder,
2582 gnc_builder_connect_full_func,
2587 iw->is_credit_note = gncInvoiceGetIsCreditNote (invoice);
2590 gnc_register_gui_component (DIALOG_NEW_INVOICE_CM_CLASS,
2591 gnc_invoice_window_refresh_handler,
2592 gnc_invoice_dialog_close_handler,
2595 gnc_gui_component_watch_entity_type (iw->component_id,
2596 GNC_INVOICE_MODULE_NAME,
2597 QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
2600 gnc_billterms_combo (GTK_COMBO_BOX(iw->terms_menu), iw->book, TRUE, iw->terms);
2601 gnc_invoice_update_window (iw, iw->dialog);
2602 gnc_table_refresh_gui (gnc_entry_ledger_get_table (iw->ledger), TRUE);
2605 if (GNC_IS_GENERAL_SEARCH(iw->owner_choice))
2607 gnc_general_search_grab_focus(GNC_GENERAL_SEARCH(iw->owner_choice));
2617 InvoiceDialogType type;
2619 if (!invoice)
return NULL;
2622 if (gncInvoiceGetPostedAcc (invoice))
2623 type = VIEW_INVOICE;
2625 type = EDIT_INVOICE;
2627 iw = gnc_invoice_new_page (gncInvoiceGetBook(invoice), type,
2628 invoice, gncInvoiceGetOwner (invoice), NULL);
2637 if (!invoice)
return NULL;
2639 iw = gnc_invoice_window_new_invoice (MOD_INVOICE, NULL, NULL, invoice);
2644 set_gncEntry_date(gpointer data, gpointer user_data)
2647 const GDate* new_date = user_data;
2657 InvoiceWindow * gnc_ui_invoice_duplicate (
GncInvoice *old_invoice, gboolean open_properties,
const GDate *new_date)
2662 GDate new_date_gdate;
2664 g_assert(old_invoice);
2670 gncInvoiceSetActive(new_invoice, TRUE);
2673 if (gncInvoiceIsPosted (new_invoice))
2678 g_warning(
"Oops, error when unposting the copied invoice; ignoring.");
2683 new_id = gncInvoiceNextID(gnc_get_current_book(),
2684 gncInvoiceGetOwner(new_invoice));
2685 gncInvoiceSetID(new_invoice, new_id);
2691 new_date_gdate = *new_date;
2696 new_date_gdate = *tmp;
2703 g_list_foreach(gncInvoiceGetEntries(new_invoice),
2704 &set_gncEntry_date, &new_date_gdate);
2707 if (open_properties)
2710 iw = gnc_invoice_window_new_invoice (DUP_INVOICE, NULL, NULL, new_invoice);
2715 iw = gnc_ui_invoice_edit (new_invoice);
2729 gncOwnerCopy (ownerp, &owner);
2732 gncOwnerInitCustomer (&owner, NULL);
2735 if (!bookp)
return NULL;
2737 iw = gnc_invoice_window_new_invoice (NEW_INVOICE, bookp, &owner, NULL);
2745 edit_invoice_direct (gpointer invoice, gpointer user_data)
2747 g_return_if_fail (invoice);
2748 gnc_ui_invoice_edit (invoice);
2752 edit_invoice_cb (gpointer *invoice_p, gpointer user_data)
2754 g_return_if_fail (invoice_p && user_data);
2757 edit_invoice_direct (*invoice_p, user_data);
2761 pay_invoice_direct (gpointer inv, gpointer user_data)
2765 g_return_if_fail (invoice);
2766 gnc_ui_payment_new_with_invoice (gncInvoiceGetOwner (invoice),
2767 gncInvoiceGetBook (invoice), invoice);
2771 pay_invoice_cb (gpointer *invoice_p, gpointer user_data)
2773 g_return_if_fail (invoice_p && user_data);
2776 pay_invoice_direct (*invoice_p, user_data);
2783 static void multi_duplicate_invoice_one(gpointer data, gpointer user_data)
2788 g_assert(dup_user_data);
2795 InvoiceWindow *iw = gnc_ui_invoice_duplicate(old_invoice, FALSE, &dup_user_data->date);
2798 new_invoice = iw_get_invoice(iw);
2799 g_assert(new_invoice);
2804 multi_duplicate_invoice_cb (GList *invoice_list, gpointer user_data)
2806 g_return_if_fail (invoice_list);
2807 switch (g_list_length(invoice_list))
2814 GncInvoice *old_invoice = invoice_list->data;
2815 gnc_ui_invoice_duplicate(old_invoice, TRUE, NULL);
2826 dialog_ok = gnc_dup_date_dialog (NULL, _(
"Date of duplicated entries"), &dup_user_data.date);
2836 g_list_foreach(invoice_list, multi_duplicate_invoice_one, &dup_user_data);
2842 static void post_one_invoice_cb(gpointer data, gpointer user_data)
2847 gnc_invoice_post(iw, post_params);
2851 multi_post_invoice_cb (GList *invoice_list, gpointer user_data)
2856 if (g_list_length(invoice_list) == 0)
2860 iw = gnc_ui_invoice_edit(invoice_list->data);
2861 if (!gnc_dialog_post_invoice(iw, _(
"Do you really want to post these invoices?"),
2862 &post_params.ddue, &post_params.postdate,
2863 &post_params.memo, &post_params.acc,
2864 &post_params.accumulate))
2871 gnc_suspend_gui_refresh ();
2872 g_list_foreach(invoice_list, post_one_invoice_cb, &post_params);
2873 gnc_resume_gui_refresh ();
2876 static void print_one_invoice_cb(gpointer data, gpointer user_data)
2879 gnc_invoice_window_print_invoice(invoice);
2883 multi_print_invoice_cb (GList *invoice_list, gpointer user_data)
2885 if (g_list_length(invoice_list) == 0)
2888 g_list_foreach(invoice_list, print_one_invoice_cb, user_data);
2892 new_invoice_cb (gpointer user_data)
2897 g_return_val_if_fail (user_data, NULL);
2899 iw = gnc_ui_invoice_new (sw->owner, sw->book);
2900 return iw_get_invoice (iw);
2904 free_invoice_cb (gpointer user_data)
2908 g_return_if_fail (sw);
2917 QofIdType type = GNC_INVOICE_MODULE_NAME;
2920 GncOwnerType owner_type = GNC_OWNER_CUSTOMER;
2921 static GList *inv_params = NULL, *bill_params = NULL, *emp_params = NULL, *params;
2922 static GList *columns = NULL;
2923 const gchar *title, *label;
2927 { N_(
"View/Edit Invoice"), edit_invoice_cb, NULL, TRUE},
2928 { N_(
"Process Payment"), pay_invoice_cb, NULL, FALSE},
2929 { N_(
"Duplicate"), NULL, multi_duplicate_invoice_cb, FALSE},
2930 { N_(
"Post"), NULL, multi_post_invoice_cb, FALSE},
2931 { N_(
"Printable Report"), NULL, multi_print_invoice_cb, TRUE},
2936 { N_(
"View/Edit Bill"), edit_invoice_cb, NULL, TRUE},
2937 { N_(
"Process Payment"), pay_invoice_cb, NULL, FALSE},
2938 { N_(
"Duplicate"), NULL, multi_duplicate_invoice_cb, FALSE},
2939 { N_(
"Post"), NULL, multi_post_invoice_cb, FALSE},
2940 { N_(
"Printable Report"), NULL, multi_print_invoice_cb, TRUE},
2947 { N_(
"View/Edit Voucher"), edit_invoice_cb, NULL, TRUE},
2948 { N_(
"Process Payment"), pay_invoice_cb, NULL, FALSE},
2949 { N_(
"Duplicate"), NULL, multi_duplicate_invoice_cb, FALSE},
2950 { N_(
"Post"), NULL, multi_post_invoice_cb, FALSE},
2951 { N_(
"Printable Report"), NULL, multi_print_invoice_cb, TRUE},
2955 g_return_val_if_fail (book, NULL);
2958 if (inv_params == NULL)
2960 inv_params = gnc_search_param_prepend (inv_params,
2961 _(
"Invoice Owner"), NULL, type,
2962 INVOICE_OWNER, NULL);
2963 inv_params = gnc_search_param_prepend (inv_params,
2964 _(
"Invoice Notes"), NULL, type,
2965 INVOICE_NOTES, NULL);
2966 inv_params = gnc_search_param_prepend (inv_params,
2967 _(
"Billing ID"), NULL, type,
2968 INVOICE_BILLINGID, NULL);
2969 inv_params = gnc_search_param_prepend (inv_params,
2970 _(
"Is Paid?"), NULL, type,
2971 INVOICE_IS_PAID, NULL);
2972 inv_params = gnc_search_param_prepend (inv_params,
2973 _(
"Date Posted"), NULL, type,
2974 INVOICE_POSTED, NULL);
2975 inv_params = gnc_search_param_prepend (inv_params,
2976 _(
"Is Posted?"), NULL, type,
2977 INVOICE_IS_POSTED, NULL);
2978 inv_params = gnc_search_param_prepend (inv_params,
2979 _(
"Date Opened"), NULL, type,
2980 INVOICE_OPENED, NULL);
2981 inv_params = gnc_search_param_prepend (inv_params,
2982 _(
"Due Date"), NULL, type,
2984 inv_params = gnc_search_param_prepend (inv_params,
2985 _(
"Company Name "), NULL, type,
2986 INVOICE_OWNER, OWNER_PARENT,
2988 inv_params = gnc_search_param_prepend (inv_params,
2989 _(
"Invoice ID"), NULL, type,
2992 if (bill_params == NULL)
2994 bill_params = gnc_search_param_prepend (bill_params,
2995 _(
"Bill Owner"), NULL, type,
2996 INVOICE_OWNER, NULL);
2997 bill_params = gnc_search_param_prepend (bill_params,
2998 _(
"Bill Notes"), NULL, type,
2999 INVOICE_NOTES, NULL);
3000 bill_params = gnc_search_param_prepend (bill_params,
3001 _(
"Billing ID"), NULL, type,
3002 INVOICE_BILLINGID, NULL);
3003 bill_params = gnc_search_param_prepend (bill_params,
3004 _(
"Is Paid?"), NULL, type,
3005 INVOICE_IS_PAID, NULL);
3006 bill_params = gnc_search_param_prepend (bill_params,
3007 _(
"Date Posted"), NULL, type,
3008 INVOICE_POSTED, NULL);
3009 bill_params = gnc_search_param_prepend (bill_params,
3010 _(
"Is Posted?"), NULL, type,
3011 INVOICE_IS_POSTED, NULL);
3012 bill_params = gnc_search_param_prepend (bill_params,
3013 _(
"Date Opened"), NULL, type,
3014 INVOICE_OPENED, NULL);
3015 bill_params = gnc_search_param_prepend (bill_params,
3016 _(
"Due Date"), NULL, type,
3018 bill_params = gnc_search_param_prepend (bill_params,
3019 _(
"Company Name "), NULL, type,
3020 INVOICE_OWNER, OWNER_PARENT,
3022 bill_params = gnc_search_param_prepend (bill_params,
3023 _(
"Bill ID"), NULL, type,
3026 if (emp_params == NULL)
3028 emp_params = gnc_search_param_prepend (emp_params,
3029 _(
"Voucher Owner"), NULL, type,
3030 INVOICE_OWNER, NULL);
3031 emp_params = gnc_search_param_prepend (emp_params,
3032 _(
"Voucher Notes"), NULL, type,
3033 INVOICE_NOTES, NULL);
3034 emp_params = gnc_search_param_prepend (emp_params,
3035 _(
"Billing ID"), NULL, type,
3036 INVOICE_BILLINGID, NULL);
3037 emp_params = gnc_search_param_prepend (emp_params,
3038 _(
"Is Paid?"), NULL, type,
3039 INVOICE_IS_PAID, NULL);
3040 emp_params = gnc_search_param_prepend (emp_params,
3041 _(
"Date Posted"), NULL, type,
3042 INVOICE_POSTED, NULL);
3043 emp_params = gnc_search_param_prepend (emp_params,
3044 _(
"Is Posted?"), NULL, type,
3045 INVOICE_IS_POSTED, NULL);
3046 emp_params = gnc_search_param_prepend (emp_params,
3047 _(
"Date Opened"), NULL, type,
3048 INVOICE_OPENED, NULL);
3049 emp_params = gnc_search_param_prepend (emp_params,
3050 _(
"Due Date"), NULL, type,
3052 emp_params = gnc_search_param_prepend (emp_params,
3053 _(
"Employee Name"), NULL, type,
3054 INVOICE_OWNER, OWNER_PARENT,
3056 emp_params = gnc_search_param_prepend (emp_params,
3057 _(
"Voucher ID"), NULL, type,
3062 if (columns == NULL)
3064 columns = gnc_search_param_prepend (columns, _(
"Billing ID"), NULL, type,
3065 INVOICE_BILLINGID, NULL);
3066 columns = gnc_search_param_prepend (columns, _(
"Type"), NULL, type,
3067 INVOICE_TYPE_STRING, NULL);
3068 columns = gnc_search_param_prepend_with_justify (columns, _(
"Paid"),
3069 GTK_JUSTIFY_CENTER, NULL, type,
3070 INVOICE_IS_PAID, NULL);
3071 columns = gnc_search_param_prepend (columns, _(
"Posted"), NULL, type,
3072 INVOICE_POSTED, NULL);
3073 columns = gnc_search_param_prepend (columns, _(
"Company"), NULL, type,
3074 INVOICE_OWNER, OWNER_PARENT,
3076 columns = gnc_search_param_prepend (columns, _(
"Due"), NULL, type,
3078 columns = gnc_search_param_prepend (columns, _(
"Opened"), NULL, type,
3079 INVOICE_OPENED, NULL);
3080 columns = gnc_search_param_prepend (columns, _(
"Num"), NULL, type,
3085 q = qof_query_create_for (type);
3109 (g_slist_prepend (NULL, QOF_PARAM_GUID),
3114 (g_slist_prepend (NULL, OWNER_PARENTG),
3130 GList *type_list = NULL, *node = NULL;
3132 type_list = gncInvoiceGetTypeListForOwnerType(owner_type);
3133 for (node = type_list; node; node = node->next)
3135 inv_type_pred = qof_query_int32_predicate(QOF_COMPARE_EQUAL,
3136 GPOINTER_TO_INT(node->data));
3137 qof_query_add_term (q3, g_slist_prepend (NULL, INVOICE_TYPE), inv_type_pred, QOF_QUERY_OR);
3152 gncOwnerCopy (owner, &(sw->owner_def));
3153 sw->owner = &(sw->owner_def);
3160 case GNC_OWNER_VENDOR:
3161 title = _(
"Find Bill");
3163 params = bill_params;
3164 buttons = bill_buttons;
3166 case GNC_OWNER_EMPLOYEE:
3167 title = _(
"Find Expense Voucher");
3168 label = _(
"Expense Voucher");
3169 params = emp_params;
3170 buttons = emp_buttons;
3173 title = _(
"Find Invoice");
3174 label = _(
"Invoice");
3175 params = inv_params;
3176 buttons = inv_buttons;
3179 return gnc_search_dialog_create (type, title, params, columns, q, q2,
3180 buttons, NULL, new_invoice_cb,
3181 sw, free_invoice_cb, GNC_PREFS_GROUP_SEARCH,
3186 gnc_invoice_show_bills_due (
QofBook *book,
double days_in_advance)
3188 QofIdType type = GNC_INVOICE_MODULE_NAME;
3197 static GList *param_list = NULL;
3200 { N_(
"View/Edit Bill"), edit_invoice_direct },
3201 { N_(
"Process Payment"), pay_invoice_direct },
3206 if (param_list == NULL)
3210 param_list = gnc_search_param_prepend (param_list, _(
"CN?"), NULL, type,
3211 INVOICE_IS_CN, NULL);
3212 param_list = gnc_search_param_prepend (param_list, _(
"Amount"), NULL, type,
3213 INVOICE_POST_LOT, LOT_BALANCE, NULL);
3214 param_list = gnc_search_param_prepend (param_list, _(
"Company"), NULL, type,
3215 INVOICE_OWNER, OWNER_NAME, NULL);
3216 param_list = gnc_search_param_prepend (param_list, _(
"Due"), NULL, type,
3237 INVOICE_POST_LOT), FALSE, QOF_QUERY_AND);
3239 pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_CUST_INVOICE);
3240 qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
3242 pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_CUST_CREDIT_NOTE);
3243 qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
3246 if (days_in_advance < 0)
3247 days_in_advance = 0;
3248 end_date += days_in_advance * 60 * 60 * 24;
3250 ts.tv_sec = (gint64) end_date;
3252 pred_data = qof_query_date_predicate (QOF_COMPARE_LTE, QOF_DATE_MATCH_NORMAL, ts);
3253 qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_DUE), pred_data, QOF_QUERY_AND);
3256 len = g_list_length (res);
3257 if (!res || len <= 0)
3263 message = g_strdup_printf
3266 ngettext(
"The following bill is due:",
3267 "The following %d bills are due:",
3270 dialog = gnc_dialog_query_view_create(param_list, q,
3271 _(
"Due Bills Reminder"),
3274 1, GTK_SORT_ASCENDING,
3283 gnc_invoice_remind_bills_due (
void)
3288 if (!gnc_current_session_exist())
return;
3292 gnc_invoice_show_bills_due(book, days);
3296 gnc_invoice_remind_bills_due_cb (
void)
3301 gnc_invoice_remind_bills_due();
GList * gncOwnerGetCommoditiesList(const GncOwner *owner)
GNCPrice * gnc_price_create(QofBook *book)
utility functions for the GnuCash UI
GtkWidget * gnc_plugin_page_get_window(GncPluginPage *page)
const GncGUID * gncOwnerGetGUID(const GncOwner *owner)
void qof_query_add_term(QofQuery *query, QofQueryParamList *param_list, QofQueryPredData *pred_data, QofQueryOp op)
int gnc_commodity_get_fraction(const gnc_commodity *cm)
time64 timespecToTime64(Timespec ts)
Business Interface: Object OWNERs.
const GncGUID * qof_instance_get_guid(gconstpointer)
void qof_instance_get(const QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_get.
void gncEntrySetQuantity(GncEntry *entry, gnc_numeric quantity)
Dialog for create/edit an account.
GList * gncOwnerGetAccountTypesList(const GncOwner *owner)
utility functions for the GnuCash UI
void qof_query_set_sort_order(QofQuery *q, QofQueryParamList *primary_sort_params, QofQueryParamList *secondary_sort_params, QofQueryParamList *tertiary_sort_params)
gnc_numeric gnc_numeric_neg(gnc_numeric a)
gboolean string_to_guid(const gchar *string, GncGUID *guid)
void qof_instance_set(QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
gboolean timespec_equal(const Timespec *ta, const Timespec *tb)
gboolean gncOwnerEqual(const GncOwner *a, const GncOwner *b)
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
QofQuery * qof_query_copy(QofQuery *q)
Use a 64-bit unsigned int timespec.
void gncInvoiceRemoveEntries(GncInvoice *invoice)
gboolean gnc_numeric_zero_p(gnc_numeric a)
Timespec gncEntryGetDate(const GncEntry *entry)
gchar * guid_to_string_buff(const GncGUID *guid, gchar *buff)
GHashTable * gncInvoiceGetForeignCurrencies(const GncInvoice *invoice)
gboolean qof_commit_edit(QofInstance *inst)
gnc_numeric gncInvoiceGetTotal(GncInvoice *invoice)
struct _QofQuery QofQuery
void gnc_plugin_page_invoice_update_menus(GncPluginPage *page, gboolean is_posted, gboolean can_unpost)
void gnc_main_window_display_page(GncPluginPage *page)
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Functions for adding content to a window.
QofInstance * qofOwnerGetOwner(const GncOwner *owner)
gnc_commodity * gnc_default_currency(void)
gint timespec_cmp(const Timespec *ta, const Timespec *tb)
gboolean qof_begin_edit(QofInstance *inst)
QofBook * qof_session_get_book(const QofSession *session)
gchar * gnc_account_get_full_name(const Account *account)
gnc_numeric gnc_numeric_convert(gnc_numeric n, gint64 denom, gint how)
void qof_query_destroy(QofQuery *q)
void gnc_plugin_page_set_use_new_window(GncPluginPage *page, gboolean use_new)
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
#define GUID_ENCODING_LENGTH
GncPluginPage * gnc_plugin_page_invoice_new(InvoiceWindow *iw)
void qof_query_set_book(QofQuery *q, QofBook *book)
QofIdTypeConst qofOwnerGetType(const GncOwner *owner)
Functions for adding plugins to a GnuCash window.
#define gncInvoiceGetGUID(x)
void gncEntrySetDateGDate(GncEntry *entry, const GDate *date)
gnc_numeric gnc_numeric_div(gnc_numeric x, gnc_numeric y, gint64 denom, gint how)
void gnc_table_init_gui(GtkWidget *widget, gchar *state_section)
void gnc_gnome_help(const char *file_name, const char *anchor)
int xaccSPrintAmount(char *bufp, gnc_numeric val, GNCPrintAmountInfo info)
void qof_query_add_guid_match(QofQuery *q, QofQueryParamList *param_list, const GncGUID *guid, QofQueryOp op)
Transaction * gncInvoicePostToAccount(GncInvoice *invoice, Account *acc, Timespec *post_date, Timespec *due_date, const char *memo, gboolean accumulatesplits, gboolean autopay)
Generic api to store and retrieve preferences.
void gncInvoiceSetDateOpenedGDate(GncInvoice *invoice, const GDate *date)
gnc_numeric gnc_numeric_sub(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
GncOwnerType gncOwnerGetType(const GncOwner *owner)
const GncOwner * gncOwnerGetEndOwner(const GncOwner *owner)
Business Invoice Interface.
GncJob * gncOwnerGetJob(const GncOwner *owner)
gboolean gncInvoiceUnpost(GncInvoice *invoice, gboolean reset_tax_tables)
GList * qof_query_run(QofQuery *query)
const GncGUID * guid_null(void)
Timespec timespec_now(void)
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
void gnc_main_window_close_page(GncPluginPage *page)
gnc_numeric gncEntryGetQuantity(const GncEntry *entry)
#define QUERY_DEFAULT_SORT
GncVendor * gncOwnerGetVendor(const GncOwner *owner)
GncCustomer * gncOwnerGetCustomer(const GncOwner *owner)
time64 gnc_time(time64 *tbuf)
get the current local time
void qof_query_add_boolean_match(QofQuery *q, QofQueryParamList *param_list, gboolean value, QofQueryOp op)
GncEmployee * gncOwnerGetEmployee(const GncOwner *owner)
GncInvoice * gncInvoiceCopy(const GncInvoice *from)
QofQuery * qof_query_create(void)
void qof_query_search_for(QofQuery *query, QofIdTypeConst obj_type)
void gnc_plugin_page_invoice_update_title(GncPluginPage *plugin_page)
void gnc_gdate_set_time64(GDate *gd, time64 time)
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
void qof_query_merge_in_place(QofQuery *q1, QofQuery *q2, QofQueryOp op)
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
GDate * gnc_g_date_new_today(void)