28 #include <glib/gi18n.h> 30 #include "dialog-utils.h" 31 #include "gnc-component-manager.h" 33 #include "gnc-gui-query.h" 38 #include "gnc-date-edit.h" 39 #include "gnc-amount-edit.h" 43 #include "tree-view-utils.h" 47 #include "engine-helpers.h" 51 #include "dialog-payment.h" 52 #include "business-gnome-utils.h" 54 #include "dialog-transfer.h" 55 #include "dialog-print-check.h" 56 #include "gnc-general-search.h" 61 #define DIALOG_PAYMENT_CM_CLASS "payment-dialog" 62 #define GNC_PREFS_GROUP "dialogs.process-payment" 88 GtkWidget * payment_warning;
89 GtkWidget * conflict_message;
90 GtkWidget * ok_button;
91 GtkWidget * num_entry;
92 GtkWidget * memo_entry;
93 GtkWidget * post_combo;
94 GtkWidget * owner_box;
95 GtkWidget * owner_type_combo;
96 GtkWidget * owner_choice;
97 GtkWidget * amount_debit_edit;
98 GtkWidget * amount_credit_edit;
99 GtkWidget * amount_payment_box;
100 GtkWidget * amount_refund_box;
101 GtkWidget * date_edit;
102 GtkWidget * acct_tree;
103 GtkWidget * docs_list_tree_view;
104 GtkWidget * commodity_label;
105 GtkWidget * print_check;
110 GncOwnerType owner_type;
113 gnc_numeric amount_tot;
115 GList * acct_commodities;
118 gboolean print_check_state;
121 void gnc_ui_payment_window_set_num (PaymentWindow *pw,
const char* num)
124 gtk_entry_set_text(GTK_ENTRY (pw->num_entry), num);
126 void gnc_ui_payment_window_set_memo (PaymentWindow *pw,
const char* memo)
129 gtk_entry_set_text(GTK_ENTRY (pw->memo_entry), memo);
131 void gnc_ui_payment_window_set_date (PaymentWindow *pw,
const GDate *date)
135 gnc_date_edit_set_gdate (GNC_DATE_EDIT (pw->date_edit), date);
137 void gnc_ui_payment_window_set_amount (PaymentWindow *pw, gnc_numeric amount)
144 gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT(pw->amount_credit_edit),
146 gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT(pw->amount_debit_edit),
147 gnc_numeric_zero ());
151 gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT(pw->amount_debit_edit),
153 gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT(pw->amount_credit_edit),
154 gnc_numeric_zero ());
159 static void gnc_ui_payment_window_set_commodity (PaymentWindow *pw,
const Account* account)
169 gtk_label_set_text (GTK_LABEL(pw->commodity_label), comm_string);
170 g_free (comm_string);
173 void gnc_ui_payment_window_set_postaccount (PaymentWindow *pw,
const Account* account)
183 gnc_ui_payment_window_set_commodity (pw, account);
186 void gnc_ui_payment_window_set_xferaccount (PaymentWindow *pw,
const Account* account)
194 static gboolean gnc_payment_dialog_has_pre_existing_txn(
const PaymentWindow* pw)
196 return pw->tx_info->txn != NULL;
198 int gnc_payment_dialog_owner_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data);
199 int gnc_payment_dialog_post_to_changed_cb (GtkWidget *widget, gpointer data);
200 void gnc_payment_dialog_document_selection_changed_cb (GtkWidget *widget, gpointer data);
201 void gnc_payment_dialog_xfer_acct_changed_cb (GtkWidget *widget, gpointer data);
202 void gnc_payment_ok_cb (GtkWidget *widget, gpointer data);
203 void gnc_payment_cancel_cb (GtkWidget *widget, gpointer data);
204 void gnc_payment_window_destroy_cb (GtkWidget *widget, gpointer data);
205 void gnc_payment_acct_tree_row_activated_cb (GtkWidget *widget, GtkTreePath *path,
206 GtkTreeViewColumn *column, PaymentWindow *pw);
207 void gnc_payment_leave_amount_cb (GtkWidget *widget, GdkEventFocus *event,
209 void gnc_payment_activate_amount_cb (GtkWidget *widget, PaymentWindow *pw);
210 void gnc_payment_window_fill_docs_list (PaymentWindow *pw);
214 gnc_payment_window_refresh_handler (G_GNUC_UNUSED GHashTable *changes, gpointer data)
216 PaymentWindow *pw = data;
218 gnc_payment_window_fill_docs_list (pw);
219 pw->post_acct = gnc_account_select_combo_fill (pw->post_combo, pw->book, pw->acct_types, NULL);
223 gnc_payment_window_check_payment (PaymentWindow *pw)
225 const char *conflict_msg = NULL;
226 gnc_numeric amount_deb, amount_cred;
227 gboolean enable_xfer_acct = TRUE;
228 gboolean allow_payment = TRUE;
229 GtkTreeSelection *selection;
230 gint c_result, d_result;
238 conflict_msg = _(
"You must enter a valid account name for posting.");
239 allow_payment = FALSE;
244 gnc_owner_get_owner (pw->owner_choice, &(pw->owner));
247 conflict_msg = _(
"You must select a company for payment processing.");
248 allow_payment = FALSE;
253 d_result = gnc_amount_edit_expr_is_valid (GNC_AMOUNT_EDIT(pw->amount_debit_edit),
254 &amount_deb, FALSE, NULL);
256 c_result = gnc_amount_edit_expr_is_valid (GNC_AMOUNT_EDIT(pw->amount_credit_edit),
257 &amount_cred, FALSE, NULL);
259 if ((d_result == 1) || (c_result == 1))
261 conflict_msg = _(
"There is a problem with the Payment or Refund amount.");
262 allow_payment = FALSE;
274 enable_xfer_acct = FALSE;
282 conflict_msg = _(
"You must select a transfer account from the account tree.");
283 allow_payment = FALSE;
290 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(pw->docs_list_tree_view));
291 if (gtk_tree_selection_count_selected_rows (selection) == 0)
293 conflict_msg = _(
"No documents were selected to assign this payment to. This may create an unattached payment.");
294 allow_payment = TRUE;
299 gtk_widget_set_sensitive (pw->acct_tree, enable_xfer_acct);
303 if (gtk_widget_is_sensitive (pw->print_check))
304 pw->print_check_state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(pw->print_check));
305 if (!enable_xfer_acct)
306 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(pw->print_check), FALSE);
307 gtk_widget_set_sensitive (pw->print_check, enable_xfer_acct);
308 if (gtk_widget_is_sensitive (pw->print_check))
309 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(pw->print_check), pw->print_check_state);
312 gtk_label_set_text (GTK_LABEL(pw->conflict_message), conflict_msg);
313 gtk_widget_set_sensitive (pw->ok_button, allow_payment);
316 gtk_widget_show (pw->payment_warning);
320 gtk_widget_hide (pw->payment_warning);
323 return allow_payment;
327 gnc_payment_window_close_handler (gpointer data)
329 PaymentWindow *pw = data;
332 gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(pw->dialog));
333 gtk_widget_destroy (pw->dialog);
337 calculate_selected_total_helper (GtkTreeModel *model,
338 G_GNUC_UNUSED GtkTreePath *path,
342 gnc_numeric *subtotal = (gnc_numeric*) data;
346 gnc_commodity *currency;
348 gtk_tree_model_get (model, iter, 5, &lot, -1);
360 gnc_payment_dialog_calculate_selected_total (PaymentWindow *pw)
362 GtkTreeSelection *selection;
363 gnc_numeric val = gnc_numeric_zero();
365 if (!pw->docs_list_tree_view || !GTK_IS_TREE_VIEW(pw->docs_list_tree_view))
366 return gnc_numeric_zero();
369 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(pw->docs_list_tree_view));
371 gtk_tree_selection_selected_foreach (selection,
372 calculate_selected_total_helper,
379 gnc_payment_dialog_document_selection_changed (PaymentWindow *pw)
386 if (gnc_payment_dialog_has_pre_existing_txn (pw))
390 val = gnc_payment_dialog_calculate_selected_total (pw);
391 gnc_ui_payment_window_set_amount(pw, val);
395 _gnc_lotinfo_find_by_lot(
PreExistLotInfo *lotinfo_inst, GNCLot *lot_to_find)
397 if (lotinfo_inst->lot == lot_to_find)
403 gnc_payment_dialog_highlight_documents (PaymentWindow *pw)
405 gboolean selection_changed = FALSE;
407 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(pw->docs_list_tree_view));
408 GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(pw->docs_list_tree_view));
409 gtk_tree_selection_unselect_all (selection);
411 if (gtk_tree_model_get_iter_first (model, &iter))
418 gtk_tree_model_get (model, &iter, 5, &lot, -1);
423 li_node = g_list_find_custom (pw->tx_info->lots, lot,
424 (GCompareFunc)_gnc_lotinfo_find_by_lot);
427 gtk_tree_selection_select_iter (selection, &iter);
428 selection_changed = TRUE;
431 while (gtk_tree_model_iter_next (model, &iter));
434 if (selection_changed)
435 gnc_payment_dialog_document_selection_changed (pw);
440 gnc_payment_window_fill_docs_list (PaymentWindow *pw)
443 GtkTreeSelection *selection;
444 GList *list = NULL, *node;
446 g_return_if_fail (pw->docs_list_tree_view && GTK_IS_TREE_VIEW(pw->docs_list_tree_view));
449 if (pw->owner.owner.undefined && pw->post_acct)
474 if (pw->tx_info->post_acct == pw->post_acct)
475 for (node = pw->tx_info->lots; node; node = node->next)
482 gncOwnerInitUndefined(&lotowner, NULL);
490 gncOwnerCopy (owner, &lotowner);
494 list = g_list_prepend (list, lot_info->lot);
499 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(pw->docs_list_tree_view));
500 gtk_tree_selection_unselect_all (selection);
501 store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(pw->docs_list_tree_view)));
502 gtk_list_store_clear(store);
505 for (node = list; node; node = node->next)
507 GNCLot *lot = node->data;
510 const gchar *doc_type_str = NULL;
511 const gchar *doc_id_str = NULL;
512 const gchar *doc_deb_str = NULL;
513 const gchar *doc_cred_str = NULL;
515 GncInvoice *document;
517 gnc_numeric debit = gnc_numeric_zero();
518 gnc_numeric credit = gnc_numeric_zero();
526 doc_date_time = gncInvoiceGetDatePosted (document);
540 doc_type_str = gncInvoiceGetTypeString (document);
543 doc_type_str = _(
"Pre-Payment");
548 doc_id_str = gncInvoiceGetID (document);
562 li_node = g_list_find_custom (pw->tx_info->lots, lot,
563 (GCompareFunc)_gnc_lotinfo_find_by_lot);
585 doc_cred_str =
xaccPrintAmount (credit, gnc_default_print_info (FALSE));
587 gtk_list_store_append (store, &iter);
588 gtk_list_store_set (store, &iter,
602 gnc_payment_dialog_highlight_documents (pw);
606 gnc_payment_dialog_post_to_changed (PaymentWindow *pw)
608 gnc_payment_window_fill_docs_list (pw);
612 gnc_payment_dialog_owner_changed (PaymentWindow *pw)
619 g_list_free(pw->acct_types);
620 pw->acct_types = NULL;
623 if (pw->acct_commodities)
625 g_list_free(pw->acct_commodities);
626 pw->acct_commodities = NULL;
633 pw->post_acct = gnc_account_select_combo_fill (pw->post_combo, pw->book, pw->acct_types, NULL);
634 if (
gncOwnerEqual(&pw->owner, &pw->tx_info->owner) && pw->tx_info->post_acct)
636 pw->post_acct = pw->tx_info->post_acct;
637 gnc_ui_payment_window_set_postaccount (pw, pw->post_acct);
639 gnc_payment_dialog_post_to_changed (pw);
642 gnc_ui_payment_window_set_commodity (pw, pw->post_acct);
646 if (!gnc_payment_dialog_has_pre_existing_txn(pw))
653 "payment-last-account", &guid,
665 gnc_payment_dialog_owner_type_changed (PaymentWindow *pw)
667 GtkWidget *debit_box, *credit_box;
680 if (pw->owner_type == GNC_OWNER_CUSTOMER)
682 debit_box = pw->amount_refund_box;
683 credit_box = pw->amount_payment_box;
687 debit_box = pw->amount_payment_box;
688 credit_box = pw->amount_refund_box;
691 g_object_ref (G_OBJECT (pw->amount_debit_edit));
692 g_object_ref (G_OBJECT (pw->amount_credit_edit));
694 if (gtk_widget_is_ancestor(pw->amount_debit_edit, credit_box))
695 gtk_container_remove (GTK_CONTAINER (credit_box), pw->amount_debit_edit);
696 if (gtk_widget_is_ancestor(pw->amount_credit_edit, debit_box))
697 gtk_container_remove (GTK_CONTAINER (debit_box), pw->amount_credit_edit);
699 if (!gtk_widget_is_ancestor(pw->amount_debit_edit, debit_box))
700 gtk_box_pack_start (GTK_BOX (debit_box), pw->amount_debit_edit, TRUE, TRUE, 0);
701 if (!gtk_widget_is_ancestor(pw->amount_credit_edit, credit_box))
702 gtk_box_pack_start (GTK_BOX (credit_box), pw->amount_credit_edit, TRUE, TRUE, 0);
704 g_object_unref (G_OBJECT (pw->amount_debit_edit));
705 g_object_unref (G_OBJECT (pw->amount_credit_edit));
708 if (pw->owner_choice)
709 gtk_widget_destroy(pw->owner_choice);
710 pw->owner_choice = gnc_owner_select_create (NULL, pw->owner_box, pw->book, &pw->owner);
711 gtk_widget_show (pw->owner_choice);
712 gnc_payment_dialog_owner_changed (pw);
714 g_signal_connect (G_OBJECT (pw->owner_choice),
"changed",
715 G_CALLBACK (gnc_payment_dialog_owner_changed_cb), pw);
719 gnc_payment_dialog_remember_account (PaymentWindow *pw,
Account *acc)
729 "payment-last-account", guid,
736 gnc_payment_update_style_classes (PaymentWindow *pw)
738 GtkStyleContext *stylectxt = gtk_widget_get_style_context (GTK_WIDGET(pw->dialog));
739 const gchar *style_label = NULL;
741 if (gtk_style_context_has_class (stylectxt,
"gnc-class-customers"))
742 gtk_style_context_remove_class (stylectxt,
"gnc-class-customers");
744 if (gtk_style_context_has_class (stylectxt,
"gnc-class-vendors"))
745 gtk_style_context_remove_class (stylectxt,
"gnc-class-vendors");
747 if (gtk_style_context_has_class (stylectxt,
"gnc-class-employees"))
748 gtk_style_context_remove_class (stylectxt,
"gnc-class-employees");
750 switch (pw->owner_type)
752 case GNC_OWNER_CUSTOMER:
753 style_label =
"gnc-class-customers";
755 case GNC_OWNER_VENDOR:
756 style_label =
"gnc-class-vendors";
758 case GNC_OWNER_EMPLOYEE:
759 style_label =
"gnc-class-employees";
762 style_label =
"gnc-class-unknown";
766 gtk_style_context_add_class (stylectxt, style_label);
770 gnc_payment_set_owner_type (PaymentWindow *pw, GncOwnerType owner_type)
778 case GNC_OWNER_CUSTOMER:
779 case GNC_OWNER_EMPLOYEE:
780 case GNC_OWNER_VENDOR:
781 pw->owner_type = owner_type;
784 pw->owner_type = GNC_OWNER_CUSTOMER;
787 store = gtk_combo_box_get_model (GTK_COMBO_BOX(pw->owner_type_combo));
788 valid = gtk_tree_model_get_iter_first (store, &iter);
791 GncOwnerType owner_type;
792 gtk_tree_model_get (store, &iter, COL_OWNER_TYPE_NUM, &owner_type, -1);
793 if (owner_type == pw->owner_type)
795 gtk_combo_box_set_active_iter (GTK_COMBO_BOX(pw->owner_type_combo), &iter);
798 valid = gtk_tree_model_iter_next (store, &iter);
800 gnc_payment_update_style_classes (pw);
802 gnc_payment_dialog_owner_type_changed (pw);
806 gnc_payment_dialog_owner_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data)
808 PaymentWindow *pw = data;
811 if (!pw)
return FALSE;
813 gncOwnerCopy (&(pw->owner), &owner);
814 gnc_owner_get_owner (pw->owner_choice, &owner);
819 gncOwnerCopy (&owner, &(pw->owner));
820 gnc_payment_dialog_owner_changed(pw);
824 gnc_payment_window_check_payment (pw);
830 gnc_payment_dialog_owner_type_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data)
832 PaymentWindow *pw = data;
835 GncOwnerType owner_type;
837 if (!pw)
return FALSE;
839 gtk_combo_box_get_active_iter (GTK_COMBO_BOX(pw->owner_type_combo), &iter);
840 model = gtk_combo_box_get_model (GTK_COMBO_BOX(pw->owner_type_combo));
841 gtk_tree_model_get (model, &iter, COL_OWNER_TYPE_NUM, &owner_type, -1);
843 if (owner_type != pw->owner_type)
845 pw->owner_type = owner_type;
852 gncOwnerCopy (&pw->tx_info->owner, &pw->owner);
855 switch (pw->owner_type)
857 case GNC_OWNER_VENDOR:
858 gncOwnerInitVendor (&pw->owner, NULL);
860 case GNC_OWNER_EMPLOYEE:
861 gncOwnerInitEmployee (&pw->owner, NULL);
864 gncOwnerInitCustomer (&pw->owner, NULL);
869 gnc_payment_dialog_owner_type_changed (pw);
873 gnc_payment_window_check_payment (pw);
879 gnc_payment_dialog_document_selection_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data)
881 PaymentWindow *pw = data;
885 gnc_payment_dialog_document_selection_changed (pw);
888 gnc_payment_window_check_payment (pw);
892 gnc_payment_dialog_xfer_acct_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data)
894 PaymentWindow *pw = data;
899 gnc_payment_window_check_payment (pw);
903 gnc_payment_dialog_post_to_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data)
905 PaymentWindow *pw = data;
908 if (!pw)
return FALSE;
910 post_acct = gnc_account_select_combo_get_active (pw->post_combo);
913 if (post_acct != pw->post_acct)
915 pw->post_acct = post_acct;
916 gnc_payment_dialog_post_to_changed(pw);
919 gnc_payment_dialog_highlight_documents (pw);
922 gnc_payment_window_check_payment (pw);
933 get_selected_lots (GtkTreeModel *model,
934 G_GNUC_UNUSED GtkTreePath *path,
938 GList **return_list = data;
941 gtk_tree_model_get (model, iter, 5, &lot, -1);
948 gnc_payment_ok_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data)
950 PaymentWindow *pw = data;
951 const char *text = NULL;
970 gnc_gui_component_clear_watches (pw->component_id);
972 gnc_suspend_gui_refresh ();
974 const char *memo, *num;
977 gnc_numeric exch = gnc_numeric_create(1, 1);
978 GList *selected_lots = NULL;
979 GtkTreeSelection *selection;
983 memo = gtk_entry_get_text (GTK_ENTRY (pw->memo_entry));
984 num = gtk_entry_get_text (GTK_ENTRY (pw->num_entry));
985 g_date_clear (&date, 1);
986 gnc_date_edit_get_gdate (GNC_DATE_EDIT (pw->date_edit), &date);
990 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(pw->docs_list_tree_view));
991 gtk_tree_selection_selected_foreach (selection, get_selected_lots, &selected_lots);
1004 text = _(
"The transfer and post accounts are associated with different currencies. Please specify the conversion rate.");
1006 xfer = gnc_xfer_dialog(pw->dialog, pw->post_acct);
1007 gnc_info_dialog (GTK_WINDOW (pw->dialog),
"%s", text);
1009 gnc_xfer_dialog_select_to_account(xfer, pw->xfer_acct);
1010 gnc_xfer_dialog_set_amount(xfer, pw->amount_tot);
1011 gnc_xfer_dialog_set_date (xfer, t);
1015 gnc_xfer_dialog_set_from_show_button_active(xfer, FALSE);
1016 gnc_xfer_dialog_set_to_show_button_active(xfer, FALSE);
1017 gnc_xfer_dialog_hide_from_account_tree(xfer);
1018 gnc_xfer_dialog_hide_to_account_tree(xfer);
1019 gnc_xfer_dialog_is_exchange_dialog(xfer, &exch);
1021 if (!gnc_xfer_dialog_run_until_done(xfer))
1032 pw->post_acct, pw->xfer_acct, pw->amount_tot,
1033 exch, t, memo, num, auto_pay);
1035 gnc_resume_gui_refresh ();
1038 gnc_payment_dialog_remember_account(pw, pw->xfer_acct);
1040 if (gtk_widget_is_sensitive (pw->print_check) &&
1041 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(pw->print_check)))
1043 Split *split = xaccTransFindSplitByAccount (pw->tx_info->txn, pw->xfer_acct);
1044 GList *splits = NULL;
1045 splits = g_list_append(splits, split);
1046 gnc_ui_print_check_dialog_create(NULL, splits, NULL);
1047 g_list_free (splits);
1050 gnc_ui_payment_window_destroy (pw);
1054 gnc_payment_cancel_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data)
1056 PaymentWindow *pw = data;
1057 gnc_ui_payment_window_destroy (pw);
1061 gnc_payment_window_destroy_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data)
1063 PaymentWindow *pw = data;
1067 gnc_unregister_gui_component (pw->component_id);
1069 g_list_free (pw->acct_types);
1070 g_list_free (pw->acct_commodities);
1071 if (pw->tx_info->lots)
1072 g_list_free_full (pw->tx_info->lots, g_free);
1077 gnc_payment_acct_tree_row_activated_cb (GtkWidget *widget, GtkTreePath *path,
1078 G_GNUC_UNUSED GtkTreeViewColumn *column, PaymentWindow *pw)
1081 GtkTreeModel *model;
1084 g_return_if_fail(widget);
1085 view = GTK_TREE_VIEW(widget);
1087 model = gtk_tree_view_get_model(view);
1088 if (gtk_tree_model_get_iter(model, &iter, path))
1090 if (gtk_tree_model_iter_has_child(model, &iter))
1094 if (gtk_tree_view_row_expanded(view, path))
1095 gtk_tree_view_collapse_row(view, path);
1097 gtk_tree_view_expand_row(view, path, FALSE);
1099 else if (gnc_payment_window_check_payment (pw))
1102 gnc_payment_ok_cb(widget, pw);
1107 gnc_payment_leave_amount_cb (G_GNUC_UNUSED GtkWidget *widget,
1108 G_GNUC_UNUSED GdkEventFocus *event,
1111 gboolean d_payment_ok = FALSE;
1112 gboolean c_payment_ok = FALSE;
1114 if (! pw->amount_credit_edit || ! pw->amount_debit_edit)
1117 c_payment_ok = gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT(pw->amount_credit_edit), NULL);
1118 d_payment_ok = gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT(pw->amount_debit_edit), NULL);
1120 if (c_payment_ok && d_payment_ok)
1122 gnc_numeric amount_deb, amount_cred, amount_tot;
1125 amount_deb = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (pw->amount_debit_edit));
1126 amount_cred = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (pw->amount_credit_edit));
1132 gnc_ui_payment_window_set_amount (pw, amount_tot);
1135 gnc_payment_window_check_payment (pw);
1139 gnc_payment_activate_amount_cb (G_GNUC_UNUSED GtkWidget *widget,
1142 gnc_payment_leave_amount_cb (NULL, NULL, pw);
1147 gnc_payment_set_account_types (GncTreeViewAccount *tree)
1149 AccountViewInfo avi;
1161 find_handler (G_GNUC_UNUSED gpointer
find_data, gpointer user_data)
1163 PaymentWindow *pw = user_data;
1165 return (pw != NULL);
1168 static void print_date (G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
1169 GtkCellRenderer *cell,
1170 GtkTreeModel *tree_model,
1172 G_GNUC_UNUSED gpointer data)
1175 gchar *doc_date_str;
1177 g_return_if_fail (cell && iter && tree_model);
1180 gtk_tree_model_get (tree_model, iter, 0, &doc_date_time, -1);
1182 g_object_set (G_OBJECT (cell),
"text", doc_date_str, NULL);
1183 g_free (doc_date_str);
1187 doc_sort_func (GtkTreeModel *model,
1193 gchar *a_id = NULL, *b_id = NULL;
1196 gtk_tree_model_get (model, a, 0, &a_date, 1, &a_id, -1);
1197 gtk_tree_model_get (model, b, 0, &b_date, 1, &b_id, -1);
1199 if (a_date < b_date) ret = -1;
1200 else if (a_date > b_date) ret = 1;
1201 else ret = g_strcmp0 (a_id, b_id);
1209 payment_dialog_delete_event_cb (GtkWidget *widget,
1213 PaymentWindow *pw = user_data;
1216 gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(pw->dialog));
1221 static PaymentWindow *
1225 GtkBuilder *builder;
1227 GtkTreeSelection *selection;
1228 GtkTreeViewColumn *column;
1229 GtkCellRenderer *renderer;
1230 GtkTreeModel *store;
1237 gncOwnerInitCustomer (&tx_info->owner, NULL);
1246 pw = gnc_find_first_gui_component (DIALOG_PAYMENT_CM_CLASS, find_handler, NULL);
1251 if (pw->tx_info->lots)
1252 g_list_free_full (pw->tx_info->lots, g_free);
1253 g_free (pw->tx_info);
1254 pw->tx_info = tx_info;
1256 gncOwnerCopy (&pw->tx_info->owner, &(pw->owner));
1257 gnc_payment_set_owner_type (pw,
gncOwnerGetType(&pw->tx_info->owner));
1259 gtk_window_set_transient_for (GTK_WINDOW(pw->dialog), parent);
1260 gtk_window_present (GTK_WINDOW(pw->dialog));
1266 pw = g_new0 (PaymentWindow, 1);
1268 pw->tx_info = tx_info;
1271 builder = gtk_builder_new();
1272 gnc_builder_add_from_file (builder,
"dialog-payment.glade",
"docs_list_hor_adj");
1273 gnc_builder_add_from_file (builder,
"dialog-payment.glade",
"docs_list_vert_adj");
1274 gnc_builder_add_from_file (builder,
"dialog-payment.glade",
"docs_list_model");
1275 gnc_builder_add_from_file (builder,
"dialog-payment.glade",
"post_combo_model");
1276 gnc_builder_add_from_file (builder,
"dialog-payment.glade",
"owner_type_combo_model");
1277 gnc_builder_add_from_file (builder,
"dialog-payment.glade",
"payment_dialog");
1278 pw->dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"payment_dialog"));
1279 gtk_window_set_transient_for (GTK_WINDOW(pw->dialog), parent);
1282 gtk_widget_set_name (GTK_WIDGET(pw->dialog),
"gnc-id-payment");
1285 pw->payment_warning = GTK_WIDGET (gtk_builder_get_object (builder,
"payment_warning"));
1286 pw->conflict_message = GTK_WIDGET (gtk_builder_get_object (builder,
"conflict_message"));
1287 pw->ok_button = GTK_WIDGET (gtk_builder_get_object (builder,
"okbutton"));
1288 pw->num_entry = GTK_WIDGET (gtk_builder_get_object (builder,
"num_entry"));
1289 pw->memo_entry = GTK_WIDGET (gtk_builder_get_object (builder,
"memo_entry"));
1290 pw->commodity_label = GTK_WIDGET (gtk_builder_get_object (builder,
"commodity_label"));
1291 pw->post_combo = GTK_WIDGET (gtk_builder_get_object (builder,
"post_combo"));
1292 gtk_combo_box_set_entry_text_column( GTK_COMBO_BOX( pw->post_combo ), 0 );
1293 gnc_cbwe_require_list_item(GTK_COMBO_BOX(pw->post_combo));
1295 pw->owner_type_combo = GTK_WIDGET (gtk_builder_get_object (builder,
"owner_type_combo"));
1300 store = gtk_combo_box_get_model (GTK_COMBO_BOX(pw->owner_type_combo));
1301 gtk_tree_model_get_iter_first (store, &iter);
1302 gtk_list_store_set (GTK_LIST_STORE(store), &iter,
1303 COL_OWNER_TYPE_NAME, _(
"Customer"),
1304 COL_OWNER_TYPE_NUM, GNC_OWNER_CUSTOMER, -1);
1305 gtk_tree_model_iter_next (store, &iter);
1306 gtk_list_store_set (GTK_LIST_STORE(store), &iter,
1307 COL_OWNER_TYPE_NAME, _(
"Vendor"),
1308 COL_OWNER_TYPE_NUM, GNC_OWNER_VENDOR, -1);
1309 gtk_tree_model_iter_next (store, &iter);
1310 gtk_list_store_set (GTK_LIST_STORE(store), &iter,
1311 COL_OWNER_TYPE_NAME, _(
"Employee"),
1312 COL_OWNER_TYPE_NUM, GNC_OWNER_EMPLOYEE, -1);
1314 pw->owner_box = GTK_WIDGET (gtk_builder_get_object (builder,
"owner_box"));
1316 pw->amount_refund_box = GTK_WIDGET (gtk_builder_get_object (builder,
"amount_refund_box"));
1317 pw->amount_payment_box = GTK_WIDGET (gtk_builder_get_object (builder,
"amount_payment_box"));
1319 pw->amount_debit_edit = gnc_amount_edit_new ();
1320 gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (pw->amount_debit_edit),
1322 gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (pw->amount_debit_edit), gnc_numeric_zero());
1323 g_signal_connect(G_OBJECT(gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(pw->amount_debit_edit))),
1325 G_CALLBACK(gnc_payment_leave_amount_cb), pw);
1327 g_signal_connect(G_OBJECT(pw->amount_debit_edit),
1329 G_CALLBACK(gnc_payment_activate_amount_cb), pw);
1331 pw->amount_credit_edit = gnc_amount_edit_new ();
1332 gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (pw->amount_credit_edit),
1334 gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (pw->amount_credit_edit), gnc_numeric_zero());
1335 g_signal_connect(G_OBJECT(gnc_amount_edit_gtk_entry(GNC_AMOUNT_EDIT(pw->amount_credit_edit))),
1337 G_CALLBACK(gnc_payment_leave_amount_cb), pw);
1339 g_signal_connect(G_OBJECT(pw->amount_credit_edit),
1341 G_CALLBACK(gnc_payment_activate_amount_cb), pw);
1343 box = GTK_WIDGET (gtk_builder_get_object (builder,
"date_box"));
1344 pw->date_edit = gnc_date_edit_new (time(NULL), FALSE, FALSE);
1345 gtk_box_pack_start (GTK_BOX (box), pw->date_edit, TRUE, TRUE, 0);
1346 pw->print_check = GTK_WIDGET (gtk_builder_get_object (builder,
"print_check"));
1348 pw->docs_list_tree_view = GTK_WIDGET (gtk_builder_get_object (builder,
"docs_list_tree_view"));
1349 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(pw->docs_list_tree_view));
1350 gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
1353 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW(pw->docs_list_tree_view), gnc_tree_view_get_grid_lines_pref ());
1356 renderer = gtk_cell_renderer_text_new ();
1357 column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 0);
1358 gtk_tree_view_column_pack_start (column, renderer, TRUE);
1360 column,
"31-12-2013");
1361 gtk_tree_view_column_set_cell_data_func (column, renderer,
1362 (GtkTreeCellDataFunc) print_date,
1366 column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 1);
1368 column, _(
"Pre-Payment"));
1371 column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 2);
1373 column, _(
"Credit Note"));
1376 column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 3);
1378 column,
"9,999,999.00");
1381 column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 4);
1383 column,
"9,999,999.00");
1385 gtk_tree_sortable_set_default_sort_func
1386 (GTK_TREE_SORTABLE (gtk_tree_view_get_model
1387 (GTK_TREE_VIEW (pw->docs_list_tree_view))),
1388 doc_sort_func, NULL, NULL);
1390 gtk_tree_sortable_set_sort_column_id
1391 (GTK_TREE_SORTABLE (gtk_tree_view_get_model
1392 (GTK_TREE_VIEW (pw->docs_list_tree_view))),
1393 GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
1394 GTK_SORT_ASCENDING);
1396 box = GTK_WIDGET (gtk_builder_get_object (builder,
"acct_window"));
1398 gtk_container_add (GTK_CONTAINER (box), pw->acct_tree);
1399 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(pw->acct_tree), FALSE);
1400 gnc_payment_set_account_types (GNC_TREE_VIEW_ACCOUNT (pw->acct_tree));
1404 gncOwnerCopy (&pw->tx_info->owner, &(pw->owner));
1405 gnc_payment_set_owner_type (pw,
gncOwnerGetType (&pw->tx_info->owner));
1408 gtk_builder_connect_signals_full( builder,
1409 gnc_builder_connect_full_func,
1412 g_signal_connect (G_OBJECT (pw->acct_tree),
"row-activated",
1413 G_CALLBACK (gnc_payment_acct_tree_row_activated_cb), pw);
1415 g_signal_connect (G_OBJECT (pw->owner_type_combo),
"changed",
1416 G_CALLBACK (gnc_payment_dialog_owner_type_changed_cb), pw);
1418 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(pw->acct_tree));
1419 g_signal_connect (G_OBJECT (selection),
"changed",
1420 G_CALLBACK (gnc_payment_dialog_xfer_acct_changed_cb), pw);
1422 g_signal_connect (G_OBJECT(pw->dialog),
"delete-event",
1423 G_CALLBACK(payment_dialog_delete_event_cb), pw);
1427 gnc_register_gui_component (DIALOG_PAYMENT_CM_CLASS,
1428 gnc_payment_window_refresh_handler,
1429 gnc_payment_window_close_handler,
1433 gnc_gui_component_watch_entity_type (pw->component_id,
1435 QOF_EVENT_CREATE | QOF_EVENT_MODIFY |
1438 gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(pw->dialog), GTK_WINDOW(parent));
1441 gtk_widget_show_all (pw->dialog);
1442 g_object_unref(G_OBJECT(builder));
1445 if (GNC_IS_GENERAL_SEARCH(pw->owner_choice))
1447 gnc_general_search_grab_focus(GNC_GENERAL_SEARCH(pw->owner_choice));
1451 gnc_payment_window_check_payment (pw);
1456 const char *acct_type;
1458 text = gtk_entry_get_text(GTK_ENTRY (gtk_bin_get_child(GTK_BIN (GTK_COMBO_BOX(pw->post_combo)))));
1460 if (!text || g_strcmp0 (text,
"") == 0)
1465 g_assert (g_list_length (pw->acct_types) == 1);
1467 gnc_warning_dialog(GTK_WINDOW (pw->dialog),
1468 _(
"You have no valid \"Post To\" accounts. " 1469 "Please create an account of type \"%s\" " 1470 "before you continue to process this payment. " 1471 "Perhaps you want to create an Invoice or " 1482 gnc_ui_payment_window_destroy (PaymentWindow *pw)
1486 gnc_close_gui_component (pw->component_id);
1490 gnc_ui_payment_new_with_invoice (GtkWindow *parent,
const GncOwner *owner,
1491 QofBook *book, GncInvoice *invoice)
1496 if (!book)
return NULL;
1508 gncOwnerInitCustomer (&tx_info->owner, NULL);
1511 tx_info->post_acct = gncInvoiceGetPostedAcc (invoice);
1513 postlot = gncInvoiceGetPostedLot (invoice);
1517 lot_info->lot = postlot;
1518 lot_info->amount = gnc_numeric_zero ();
1519 tx_info->lots = g_list_prepend (tx_info->lots, lot_info);
1521 return new_payment_window (parent, book, tx_info);
1525 gnc_ui_payment_new (GtkWindow *parent,
GncOwner *owner, QofBook *book)
1527 return gnc_ui_payment_new_with_invoice (parent, owner, book, NULL);
1532 gboolean gnc_ui_payment_is_customer_payment(
const Transaction *txn)
1534 gboolean result = TRUE;
1535 Split *assetaccount_split, *aparaccount_split;
1548 if (!aparaccount_split)
1551 if (aparaccount_split)
1563 if (!assetaccount_split)
1567 PINFO(
"No asset splits in txn \"%s\"; cannot use this for assigning a payment.",
1580 static char *gen_split_desc (Transaction *txn, Split *split)
1585 const char *action = gnc_get_action_num (txn, split);
1588 const char *print_amt =
xaccPrintAmount(value, gnc_account_print_info (xfer_acct, TRUE));
1589 char *split_str = NULL;
1590 char *rec_str = NULL;
1592 if (rec_state ==
CREC)
1593 rec_str = g_strdup_printf(
"[%s] ", _(
"Cleared"));
1594 else if (rec_state ==
YREC)
1595 rec_str = g_strdup_printf(
"[%s] ", _(
"Reconciled"));
1597 rec_str = g_strdup(
"");
1599 if (action && *action && memo && *memo)
1600 split_str = g_strdup_printf (
"%s%s: %s (%s, %s)", rec_str, acct_name, print_amt,
1602 else if((action && *action) || (memo && *memo))
1603 split_str = g_strdup_printf (
"%s%s: %s (%s)", rec_str, acct_name, print_amt,
1604 action ? action : memo);
1606 split_str = g_strdup_printf (
"%s%s: %s", rec_str, acct_name, print_amt);
1614 static Split *select_payment_split (GtkWindow *parent, Transaction *txn)
1620 Split *selected_split = NULL;
1621 if (!payment_splits)
1628 dialog = gtk_message_dialog_new (parent,
1629 GTK_DIALOG_DESTROY_WITH_PARENT,
1633 _(
"The selected transaction doesn't have splits that can be assigned as a payment"));
1634 gtk_dialog_run (GTK_DIALOG(dialog));
1635 gtk_widget_destroy (dialog);
1636 PINFO(
"No asset splits in txn \"%s\"; cannot use this for assigning a payment.",
1641 if (g_list_length(payment_splits) > 1)
1643 GtkWidget *first_rb = NULL;
1644 int answer = GTK_BUTTONS_OK;
1645 const char *message = _(
"While this transaction has multiple splits that can be considered\n" 1646 "as 'the payment split', GnuCash only knows how to handle one.\n" 1647 "Please select one, the others will be discarded.\n\n");
1648 GtkDialog *dialog = GTK_DIALOG(
1649 gtk_dialog_new_with_buttons (_(
"Warning"),
1651 GTK_DIALOG_DESTROY_WITH_PARENT,
1652 _(
"Continue"), GTK_BUTTONS_OK,
1653 _(
"Cancel"), GTK_BUTTONS_CANCEL,
1655 GtkWidget *content = gtk_dialog_get_content_area(dialog);
1656 GtkWidget *label = gtk_label_new (message);
1657 gtk_box_pack_start (GTK_BOX(content), label, FALSE, TRUE, 0);
1660 for (GList *node = payment_splits; node; node = node->next)
1663 Split *split = node->data;
1664 char *split_str = gen_split_desc (txn, split);
1666 if (node == payment_splits)
1668 first_rb = gtk_radio_button_new_with_label (NULL, split_str);
1672 rbutton = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(first_rb), split_str);
1674 g_object_set_data(G_OBJECT(rbutton),
"split", split);
1675 gtk_box_pack_start (GTK_BOX(content), rbutton, FALSE, FALSE, 0);
1680 gtk_dialog_set_default_response (dialog, GTK_BUTTONS_CANCEL);
1681 gtk_widget_show_all (GTK_WIDGET(dialog));
1682 answer = gtk_dialog_run (dialog);
1684 if (answer == GTK_BUTTONS_OK)
1686 GSList *rbgroup = gtk_radio_button_get_group(GTK_RADIO_BUTTON(first_rb));
1688 for (rbnode = rbgroup; rbnode; rbnode = rbnode->next)
1690 GtkWidget *rbutton = rbnode->data;
1691 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(rbutton)))
1693 selected_split = g_object_get_data(G_OBJECT(rbutton),
"split");
1699 gtk_widget_destroy (GTK_WIDGET(dialog));
1702 selected_split = payment_splits->data;
1704 g_list_free (payment_splits);
1705 return selected_split;
1708 static GList *select_txn_lots (GtkWindow *parent, Transaction *txn,
Account **post_acct, gboolean *abort)
1713 GList *txn_lots = NULL;
1714 GList *unique_apar_accts = NULL;
1717 if (!post_acct || !abort)
1726 for (iter = apar_splits; iter; iter = iter->next)
1728 GNCLot *postlot = NULL;
1729 Split *post_split = iter->data;
1734 if (!g_list_find (unique_apar_accts, apar_acct))
1735 unique_apar_accts = g_list_prepend (unique_apar_accts, apar_acct);
1741 lot_info->lot = postlot;
1743 txn_lots = g_list_prepend (txn_lots, lot_info);
1744 *post_acct = apar_acct;
1747 apar_splits_no_lot = g_list_prepend (apar_splits_no_lot, post_split);
1752 if (!*post_acct && apar_splits_no_lot)
1758 if (g_list_length (unique_apar_accts) > 1)
1761 char *split_str = g_strdup (
"");
1763 for (iter = unique_apar_accts; iter; iter = iter->next)
1767 char *tmp_str = g_strconcat(split_str,
"• ", acct_name,
"\n", NULL);
1770 split_str = tmp_str;
1773 dialog = gtk_message_dialog_new (parent,
1774 GTK_DIALOG_DESTROY_WITH_PARENT,
1777 _(
"This transaction has splits in multiple business accounts:\n\n%s\n" 1778 "GnuCash can only handle transactions that post to a single account.\n\n" 1779 "Please correct this manually by editing the transaction directly and then try again."),
1781 gtk_dialog_run (GTK_DIALOG(dialog));
1782 gtk_widget_destroy (dialog);
1783 PINFO(
"Multiple asset accounts in splits of txn \"%s\"; cannot use this for assigning a payment.",
1788 g_list_free_full (txn_lots, g_free);
1792 g_list_free (apar_splits);
1793 g_list_free (apar_splits_no_lot);
1794 g_list_free (unique_apar_accts);
1798 PaymentWindow * gnc_ui_payment_new_with_txn (GtkWindow* parent,
GncOwner *owner, Transaction *txn)
1800 Split *payment_split = NULL;
1803 GList *txn_lots = NULL;
1804 gboolean abort = FALSE;
1816 payment_split = select_payment_split (parent, txn);
1821 txn_lots = select_txn_lots (parent, txn, &post_acct, &abort);
1828 tx_info->post_acct = post_acct;
1829 tx_info->lots = txn_lots;
1830 gncOwnerCopy (owner, &tx_info->owner);
1832 pw = new_payment_window (parent,
1836 gnc_ui_payment_window_set_num(pw, gnc_get_num_action (txn, payment_split));
1840 gnc_ui_payment_window_set_date(pw, &txn_date);
1849 amount = xaccSplitConvertAmount (payment_split, pw->post_acct);
1850 gnc_ui_payment_window_set_amount(pw, amount);
void gnc_cbwe_set_by_string(GtkComboBox *cbwe, const gchar *text)
Find an entry in the GtkComboBox by its text value, and set the widget to that value.
GList * gncOwnerGetCommoditiesList(const GncOwner *owner)
Returns a GList of currencies associated with the owner.
void gnc_tree_view_account_get_view_info(GncTreeViewAccount *view, AccountViewInfo *avi)
Given pointers to an account tree and old style filter block, this function will copy the current con...
void tree_view_column_set_default_width(GtkTreeView *view, GtkTreeViewColumn *column, const gchar *sizing_text)
Set default width for a treeview column.
int gnc_commodity_get_fraction(const gnc_commodity *cm)
Retrieve the fraction for the specified commodity.
Business Interface: Object OWNERs.
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.
Date and Time handling routines.
GList * gncOwnerGetAccountTypesList(const GncOwner *owner)
Returns a GList of account-types based on the owner type.
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
utility functions for the GnuCash UI
char xaccTransGetTxnType(Transaction *trans)
Returns the Transaction Type: note this type will be derived from the transaction splits...
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
#define PINFO(format, args...)
Print an informational note.
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
gnc_numeric gnc_numeric_neg(gnc_numeric a)
Returns a newly created gnc_numeric that is the negative of the given gnc_numeric value...
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.
char xaccSplitGetReconcile(const Split *split)
Returns the value of the reconcile flag.
gboolean gnc_commodity_equal(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equal.
const char * xaccPrintAmount(gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
gboolean gncOwnerEqual(const GncOwner *a, const GncOwner *b)
Assess equality by checking.
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a+b.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
stop here; the following types just aren't ready for prime time
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
void gnc_tree_view_account_set_view_info(GncTreeViewAccount *view, AccountViewInfo *avi)
Given pointers to an account tree and old style filter block, this function will applies the settings...
gboolean qof_commit_edit(QofInstance *inst)
commit_edit helpers
Split * xaccTransGetFirstPaymentAcctSplit(const Transaction *trans)
The xaccTransGetFirstPaymentAcctSplit() method returns a pointer to the first split in this transacti...
gboolean gncOwnerIsValid(const GncOwner *owner)
Returns TRUE if the given owner is one of the valid objects.
QofInstance * qofOwnerGetOwner(const GncOwner *owner)
return the owner itself as an entity.
Split * gnc_lot_get_latest_split(GNCLot *lot)
Convenience routineto identify the date this lot was closed.
gboolean qof_begin_edit(QofInstance *inst)
begin_edit
#define xaccAccountGetGUID(X)
char * qof_print_date(time64 secs)
Convenience; calls through to qof_print_date_dmy_buff().
void gncOwnerApplyPaymentSecs(const GncOwner *owner, Transaction **preset_txn, GList *lots, Account *posted_acc, Account *xfer_acc, gnc_numeric amount, gnc_numeric exch, time64 date, const char *memo, const char *num, gboolean auto_pay)
A convenience function to apply a payment to the owner.
GList SplitList
GList of Split.
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 handling public routines.
GtkTreeView implementation for gnucash account tree.
#define YREC
The Split has been reconciled.
gint gncOwnerLotsSortFunc(GNCLot *lotA, GNCLot *lotB)
Helper function used to sort lots by date.
GtkTreeView * gnc_tree_view_account_new(gboolean show_root)
Create a new account tree view.
time64 xaccTransRetDatePosted(const Transaction *trans)
Retrieve the posted date of the transaction.
const char * xaccTransGetDescription(const Transaction *trans)
Gets the transaction Description.
time64 gdate_to_time64(GDate d)
Turns a GDate into a time64, returning the first second of the day.
gboolean gncOwnerGetOwnerFromLot(GNCLot *lot, GncOwner *owner)
Get the owner from the lot.
const char * gnc_commodity_get_nice_symbol(const gnc_commodity *cm)
Retrieve a symbol for the specified commodity, suitable for display to the user.
gboolean xaccAccountIsAPARType(GNCAccountType t)
Convenience function to check if the account is a valid business account type (meaning an Accounts Pa...
#define TXN_TYPE_LINK
Transaction is a link between (invoice and payment) lots.
SplitList * xaccTransGetAPARAcctSplitList(const Transaction *trans, gboolean strict)
The xaccTransGetAPARSplitList() method returns a GList of the splits in a transaction that belong to ...
#define CREC
The Split has been cleared.
gboolean gnc_numeric_positive_p(gnc_numeric a)
Returns 1 if a > 0, otherwise returns 0.
Generic api to store and retrieve preferences.
gnc_numeric gnc_numeric_sub(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a-b.
GncOwnerType gncOwnerGetType(const GncOwner *owner)
Returns the GncOwnerType of this owner.
const GncOwner * gncOwnerGetEndOwner(const GncOwner *owner)
Get the "parent" Owner or GncGUID thereof.
GncInvoice * gncInvoiceGetInvoiceFromLot(GNCLot *lot)
Given a LOT, find and return the Invoice attached to the lot.
Business Invoice Interface.
void gnc_tree_view_account_set_selected_account(GncTreeViewAccount *view, Account *account)
This function selects an account in the account tree view.
Split * xaccTransGetFirstAPARAcctSplit(const Transaction *trans, gboolean strict)
The xaccTransGetFirstPaymentAcctSplit() method returns a pointer to the first split in this transacti...
gboolean gncOwnerLotMatchOwnerFunc(GNCLot *lot, gpointer user_data)
Helper function used to filter a list of lots by owner.
SplitList * xaccTransGetPaymentAcctSplitList(const Transaction *trans)
The xaccTransGetPaymentAcctSplitList() method returns a GList of the splits in a transaction that bel...
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
Account * gnc_tree_view_account_get_selected_account(GncTreeViewAccount *view)
This function returns the account associated with the selected item in the account tree view...
Round to the nearest integer, rounding away from zero when there are two equidistant nearest integers...
GNCNumericErrorCode gnc_numeric_check(gnc_numeric in)
Check for error signal in value.
const char * xaccSplitGetMemo(const Split *split)
Returns the memo string.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Account * gnc_lot_get_account(const GNCLot *lot)
Returns the account with which this lot is associated.
LotList * xaccAccountFindOpenLots(const Account *acc, gboolean(*match_func)(GNCLot *lot, gpointer user_data), gpointer user_data, GCompareFunc sort_func)
Find a list of open lots that match the match_func.
const char * xaccAccountGetTypeStr(GNCAccountType type)
The xaccAccountGetTypeStr() routine returns a string suitable for use in the GUI/Interface.
GDate xaccTransGetDatePostedGDate(const Transaction *trans)
Retrieve the posted date of the transaction.
API for Transactions and Splits (journal entries)
The type used to store guids in C.
SplitList * xaccTransGetSplitList(const Transaction *trans)
The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
gnc_numeric gnc_lot_get_balance(GNCLot *lot)
Returns the lot balance.
GNCLot * xaccSplitGetLot(const Split *split)
Returns the pointer to the debited/credited Lot where this split belongs to, or NULL if it doesn't be...
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id...