diff --git a/src/business/business-gnome/dialog-invoice.c b/src/business/business-gnome/dialog-invoice.c
index 4ad64b2fc4..e6d4f23d93 100644
--- a/src/business/business-gnome/dialog-invoice.c
+++ b/src/business/business-gnome/dialog-invoice.c
@@ -111,6 +111,12 @@ FROM_STRING_DEC(InvoiceDialogType, ENUM_INVOICE_TYPE)
FROM_STRING_FUNC(InvoiceDialogType, ENUM_INVOICE_TYPE)
AS_STRING_FUNC(InvoiceDialogType, ENUM_INVOICE_TYPE)
+typedef enum
+{
+ DUE_FOR_VENDOR, // show bills due
+ DUE_FOR_CUSTOMER, // show invoices due
+} GncWhichDueType;
+
struct _invoice_select_window
{
QofBook * book;
@@ -201,6 +207,7 @@ struct _invoice_window
void gnc_invoice_window_closeCB (GtkWidget *widget, gpointer data);
void gnc_invoice_window_active_toggled_cb (GtkWidget *widget, gpointer data);
gboolean gnc_invoice_window_leave_notes_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data);
+DialogQueryView *gnc_invoice_show_bills_due (QofBook *book, double days_in_advance, GncWhichDueType duetype);
#define INV_WIDTH_PREFIX "invoice_reg"
#define BILL_WIDTH_PREFIX "bill_reg"
@@ -3251,24 +3258,31 @@ gnc_invoice_search (GncInvoice *start, GncOwner *owner, QofBook *book)
}
DialogQueryView *
-gnc_invoice_show_bills_due (QofBook *book, double days_in_advance)
+gnc_invoice_show_bills_due (QofBook *book, double days_in_advance, GncWhichDueType duetype)
{
QofIdType type = GNC_INVOICE_MODULE_NAME;
Query *q;
QofQueryPredData* pred_data;
time64 end_date;
GList *res;
- gchar *message;
+ gchar *message, *title;
DialogQueryView *dialog;
gint len;
Timespec ts;
+ QofQueryCompare comparetype;
static GList *param_list = NULL;
- static GNCDisplayViewButton buttons[] =
+ static GNCDisplayViewButton vendorbuttons[] =
{
{ N_("View/Edit Bill"), edit_invoice_direct },
{ N_("Process Payment"), pay_invoice_direct },
{ NULL },
};
+ static GNCDisplayViewButton customerbuttons[] =
+ {
+ { N_("View/Edit Invoice"), edit_invoice_direct },
+ { N_("Process Payment"), pay_invoice_direct },
+ { NULL },
+ };
/* Create the param list (in reverse order) */
if (param_list == NULL)
@@ -3290,7 +3304,7 @@ gnc_invoice_show_bills_due (QofBook *book, double days_in_advance)
qof_query_search_for(q, GNC_INVOICE_MODULE_NAME);
qof_query_set_book (q, book);
- /* We want to find all invoices where:
+ /* For vendor bills we want to find all invoices where:
* invoice -> is_posted == TRUE
* AND invoice -> lot -> is_closed? == FALSE
* AND invoice -> type != customer invoice
@@ -3298,17 +3312,47 @@ gnc_invoice_show_bills_due (QofBook *book, double days_in_advance)
* AND invoice -> due <= (today + days_in_advance)
*/
+ /* For customer invoices we want to find all invoices where:
+ * invoice -> is_posted == TRUE
+ * AND invoice -> lot -> is_closed? == FALSE
+ * AND invoice -> type != vendor bill
+ * AND invoice -> type != vendor credit note
+ * AND invoice -> type != employee voucher
+ * AND invoice -> type != employee credit note
+ * AND invoice -> due <= (today + days_in_advance)
+ * This could probably also be done by searching for customer invoices OR customer credit notes
+ * but that would make a more complicated query to compose.
+ */
+
qof_query_add_boolean_match (q, g_slist_prepend(NULL, INVOICE_IS_POSTED), TRUE,
QOF_QUERY_AND);
qof_query_add_boolean_match (q, g_slist_prepend(g_slist_prepend(NULL, LOT_IS_CLOSED),
INVOICE_POST_LOT), FALSE, QOF_QUERY_AND);
- pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_CUST_INVOICE);
- qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
- pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_CUST_CREDIT_NOTE);
- qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
+ if (duetype == DUE_FOR_VENDOR)
+ {
+ pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_CUST_INVOICE);
+ qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
+
+ pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_CUST_CREDIT_NOTE);
+ qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
+ }
+ else
+ {
+ pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_VEND_INVOICE);
+ qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
+
+ pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_VEND_CREDIT_NOTE);
+ qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
+
+ pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_EMPL_INVOICE);
+ qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
+
+ pred_data = qof_query_int32_predicate (QOF_COMPARE_NEQ, GNC_INVOICE_EMPL_CREDIT_NOTE);
+ qof_query_add_term (q, g_slist_prepend(NULL, INVOICE_TYPE), pred_data, QOF_QUERY_AND);
+ }
end_date = gnc_time (NULL);
if (days_in_advance < 0)
@@ -3328,19 +3372,36 @@ gnc_invoice_show_bills_due (QofBook *book, double days_in_advance)
return NULL;
}
- message = g_strdup_printf
- (/* Translators: %d is the number of bills due. This is a
- ngettext(3) message. */
- ngettext("The following bill is due:",
- "The following %d bills are due:",
- len),
- len);
+ if (duetype == DUE_FOR_VENDOR)
+ {
+ message = g_strdup_printf
+ (/* Translators: %d is the number of bills/credit notes due. This is a
+ ngettext(3) message. */
+ ngettext("The following vendor document is due:",
+ "The following %d vendor documents are due:",
+ len),
+ len);
+ title = _("Due Bills Reminder");
+ }
+ else
+ {
+ message = g_strdup_printf
+ (/* Translators: %d is the number of invoices/credit notes due. This is a
+ ngettext(3) message. */
+ ngettext("The following customer document is due:",
+ "The following %d customer documents are due:",
+ len),
+ len);
+ title = _("Due Invoices Reminder");
+ }
dialog = gnc_dialog_query_view_create(param_list, q,
- _("Due Bills Reminder"),
+ title,
message,
TRUE, FALSE,
1, GTK_SORT_ASCENDING,
- buttons, NULL);
+ duetype == DUE_FOR_VENDOR ?
+ vendorbuttons :
+ customerbuttons, NULL);
g_free(message);
qof_query_destroy(q);
@@ -3357,7 +3418,20 @@ gnc_invoice_remind_bills_due (void)
book = qof_session_get_book(gnc_get_current_session());
days = gnc_prefs_get_float(GNC_PREFS_GROUP_BILL, GNC_PREF_DAYS_IN_ADVANCE);
- gnc_invoice_show_bills_due(book, days);
+ gnc_invoice_show_bills_due(book, days, DUE_FOR_VENDOR);
+}
+
+void
+gnc_invoice_remind_invoices_due (void)
+{
+ QofBook *book;
+ gint days;
+
+ if (!gnc_current_session_exist()) return;
+ book = qof_session_get_book(gnc_get_current_session());
+ days = gnc_prefs_get_float(GNC_PREFS_GROUP_INVOICE, GNC_PREF_DAYS_IN_ADVANCE);
+
+ gnc_invoice_show_bills_due(book, days, DUE_FOR_CUSTOMER);
}
void
@@ -3368,3 +3442,12 @@ gnc_invoice_remind_bills_due_cb (void)
gnc_invoice_remind_bills_due();
}
+
+void
+gnc_invoice_remind_invoices_due_cb (void)
+{
+ if (!gnc_prefs_get_bool(GNC_PREFS_GROUP_INVOICE, GNC_PREF_NOTIFY_WHEN_DUE))
+ return;
+
+ gnc_invoice_remind_invoices_due();
+}
diff --git a/src/business/business-gnome/dialog-invoice.h b/src/business/business-gnome/dialog-invoice.h
index fef6bbd0b5..9823904a6f 100644
--- a/src/business/business-gnome/dialog-invoice.h
+++ b/src/business/business-gnome/dialog-invoice.h
@@ -85,8 +85,6 @@ void gnc_invoice_save_page (InvoiceWindow *iw, GKeyFile *key_file, const gchar *
GtkWidget * gnc_invoice_create_page (InvoiceWindow *iw, gpointer page);
-DialogQueryView *gnc_invoice_show_bills_due (QofBook *book, double days_in_advance);
-
GtkWidget *gnc_invoice_get_register(InvoiceWindow *iw);
/* definitions for CB functions */
diff --git a/src/business/business-gnome/gnc-plugin-business.c b/src/business/business-gnome/gnc-plugin-business.c
index b82a747214..422e3eaa54 100644
--- a/src/business/business-gnome/gnc-plugin-business.c
+++ b/src/business/business-gnome/gnc-plugin-business.c
@@ -119,6 +119,8 @@ static void gnc_plugin_business_cmd_billing_terms (GtkAction *action,
GncMainWindowActionData *data);
static void gnc_plugin_business_cmd_bills_due_reminder (GtkAction *action,
GncMainWindowActionData *data);
+static void gnc_plugin_business_cmd_invoices_due_reminder (GtkAction *action,
+ GncMainWindowActionData *data);
static void gnc_plugin_business_cmd_test_search (GtkAction *action,
GncMainWindowActionData *data);
@@ -284,6 +286,11 @@ static GtkActionEntry gnc_plugin_actions [] =
N_("Open the Bills Due Reminder dialog"),
G_CALLBACK (gnc_plugin_business_cmd_bills_due_reminder)
},
+ {
+ "InvoicesDueReminderOpenAction", NULL, N_("Invoices _Due Reminder"), NULL,
+ N_("Open the Invoices Due Reminder dialog"),
+ G_CALLBACK (gnc_plugin_business_cmd_invoices_due_reminder)
+ },
{ "ExportMenuAction", NULL, N_("E_xport"), NULL, NULL, NULL },
/* Extensions Menu */
@@ -791,6 +798,17 @@ gnc_plugin_business_cmd_bills_due_reminder (GtkAction *action,
gnc_invoice_remind_bills_due();
}
+
+static void
+gnc_plugin_business_cmd_invoices_due_reminder (GtkAction *action,
+ GncMainWindowActionData *mw)
+{
+ g_return_if_fail (mw != NULL);
+ g_return_if_fail (GNC_IS_PLUGIN_BUSINESS (mw->data));
+
+ gnc_invoice_remind_invoices_due();
+}
+
static void
gnc_plugin_business_cmd_test_search (GtkAction *action,
GncMainWindowActionData *data)
diff --git a/src/business/business-gnome/gnc-plugin-business.h b/src/business/business-gnome/gnc-plugin-business.h
index 3769a5f128..fe7f9d5e6c 100644
--- a/src/business/business-gnome/gnc-plugin-business.h
+++ b/src/business/business-gnome/gnc-plugin-business.h
@@ -61,7 +61,9 @@ G_END_DECLS
GncMainWindow *gnc_plugin_business_get_window (void);
void gnc_invoice_remind_bills_due (void);
+void gnc_invoice_remind_invoices_due (void);
void gnc_invoice_remind_bills_due_cb (void);
+void gnc_invoice_remind_invoices_due_cb (void);
const char *gnc_plugin_business_get_invoice_printreport(void);
#endif /* __GNC_PLUGIN_BUSINESS_H */
diff --git a/src/business/business-gnome/gncmod-business-gnome.c b/src/business/business-gnome/gncmod-business-gnome.c
index 92d90cc564..2ca3b9870d 100644
--- a/src/business/business-gnome/gncmod-business-gnome.c
+++ b/src/business/business-gnome/gncmod-business-gnome.c
@@ -110,6 +110,8 @@ libgncmod_business_gnome_gnc_module_init(int refcount)
gnc_hook_add_dangler(HOOK_BOOK_OPENED,
(GFunc)gnc_invoice_remind_bills_due_cb, NULL);
+ gnc_hook_add_dangler(HOOK_BOOK_OPENED,
+ (GFunc)gnc_invoice_remind_invoices_due_cb, NULL);
/* Add to preferences under Business */
/* The parameters are; glade file, items to add from glade file - last being the dialog, preference tab name */
diff --git a/src/business/business-gnome/gschemas/org.gnucash.dialogs.business.gschema.xml.in.in b/src/business/business-gnome/gschemas/org.gnucash.dialogs.business.gschema.xml.in.in
index a48d2ba883..78480bb4d9 100644
--- a/src/business/business-gnome/gschemas/org.gnucash.dialogs.business.gschema.xml.in.in
+++ b/src/business/business-gnome/gschemas/org.gnucash.dialogs.business.gschema.xml.in.in
@@ -112,6 +112,16 @@
Auto pay when posting.
At post time, automatically attempt to pay customer documents with outstanding pre-payments and counter documents. The pre-payments and documents obviously have to be against the same customer. Counter documents are documents with opposite sign. For example for an invoice, customer credit notes and negative invoices are considered counter documents.
+
+ true
+ Show invoices due reminder at startup
+ If active, at startup GnuCash will check to see whether any invoices will become due soon. If so, it will present the user with a reminder dialog. The definition of "soon" is controlled by the "Days in Advance" setting. Otherwise GnuCash does not check for due invoices.
+
+
+ 7.0
+ Show invoices due within this many days
+ This field defines the number of days in advance that GnuCash will check for due invoices. Its value is only used if the "Notify when due" setting is active.
+
false
Enable extra toolbar buttons for business
diff --git a/src/business/business-gnome/gtkbuilder/business-prefs.glade b/src/business/business-gnome/gtkbuilder/business-prefs.glade
index de8e96f367..c01ee55665 100644
--- a/src/business/business-gnome/gtkbuilder/business-prefs.glade
+++ b/src/business/business-gnome/gtkbuilder/business-prefs.glade
@@ -2,6 +2,13 @@
+
2
- 11
- 12
+ 12
+ 13
GTK_FILL
12
@@ -169,8 +215,8 @@
2
- 10
- 11
+ 11
+ 12
GTK_FILL
@@ -183,8 +229,8 @@
4
- 9
- 10
+ 10
+ 11
GTK_FILL
@@ -206,8 +252,8 @@
2
- 7
- 8
+ 8
+ 9
GTK_FILL
12
@@ -308,8 +354,8 @@
1
3
- 6
- 7
+ 7
+ 8
GTK_FILL
@@ -317,6 +363,9 @@
+
+
+
True
@@ -326,8 +375,8 @@
Report for printing:
- 6
- 7
+ 7
+ 8
GTK_FILL
@@ -343,8 +392,8 @@
True
- 8
- 9
+ 9
+ 10
GTK_FILL
12
@@ -361,13 +410,104 @@
True
- 13
- 14
+ 14
+ 15
GTK_FILL
12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Not_ify when due
+ True
+ True
+ False
+ True
+ Whether to display the list of Invoices Due at startup.
+ Whether to display the list of Invoices Due at startup.
+ True
+ True
+
+
+ 6
+ 7
+ GTK_FILL
+
+ 12
+
+
+
+
+ True
+ True
+ True
+ How many days in the future to warn about Bills coming due.
+ How many days in the future to warn about Bills coming due.
+ ●
+ True
+ False
+ False
+ True
+ True
+ cust_days_in_adj
+ 1
+ True
+
+
+ 3
+ 4
+ 6
+ 7
+
+
+
+
+
+
+ True
+ False
+ 0
+ Days in ad_vance:
+ True
+ pref/dialogs.business.invoice/days-in-advance
+
+
+ 2
+ 3
+ 6
+ 7
+ GTK_FILL
+
+
+
diff --git a/src/business/business-gnome/ui/gnc-plugin-business-ui.xml b/src/business/business-gnome/ui/gnc-plugin-business-ui.xml
index bf45ea11d5..313b23f223 100644
--- a/src/business/business-gnome/ui/gnc-plugin-business-ui.xml
+++ b/src/business/business-gnome/ui/gnc-plugin-business-ui.xml
@@ -17,6 +17,7 @@
+