Skip to content

Commit

Permalink
Improve visual appearance and sorting of Invoice payment dialog
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23362 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
gjanssens committed Oct 31, 2013
1 parent fed6a1e commit f3c5b93
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 41 deletions.
66 changes: 63 additions & 3 deletions src/business/business-gnome/dialog-payment.c
Expand Up @@ -33,11 +33,13 @@
#include "gnc-gui-query.h"
#include "gnc-ui-util.h"
#include "qof.h"
#include "gnc-date.h"
#include "gnc-date-edit.h"
#include "gnc-amount-edit.h"
#include "gnc-gtk-utils.h"
#include "gnc-prefs.h"
#include "gnc-tree-view-account.h"
#include "tree-view-utils.h"
#include "Transaction.h"
#include "Account.h"
#include "gncOwner.h"
Expand Down Expand Up @@ -287,7 +289,7 @@ gnc_payment_window_fill_docs_list (PaymentWindow *pw)
for (node = list; node; node = node->next)
{
GNCLot *lot = node->data;
const gchar *doc_date_str = NULL;
time64 doc_date_time = 0;
const gchar *doc_type_str = NULL;
const gchar *doc_id_str = NULL;
const gchar *doc_deb_str = NULL;
Expand Down Expand Up @@ -315,7 +317,7 @@ gnc_payment_window_fill_docs_list (PaymentWindow *pw)
else
continue; /* No valid split in this lot, skip it */
}
doc_date_str = gnc_print_date (doc_date);
doc_date_time = timespecToTime64 (doc_date);

/* Find the document type. No type means pre-payment in this case */
if (document)
Expand Down Expand Up @@ -351,7 +353,7 @@ gnc_payment_window_fill_docs_list (PaymentWindow *pw)

gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
0, doc_date_str,
0, doc_date_time,
1, doc_id_str,
2, doc_type_str,
3, doc_deb_str,
Expand Down Expand Up @@ -752,13 +754,36 @@ find_handler (gpointer find_data, gpointer user_data)
return (pw != NULL);
}

static void print_date (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gpointer data)
{
GValue value = { 0 };
time64 doc_date_time;
gchar *doc_date_str;

g_return_if_fail (cell && iter && tree_model);


gtk_tree_model_get_value (tree_model, iter, 0, &value);
doc_date_time = (time64) g_value_get_int64 (&value);
g_value_unset (&value);
doc_date_str = qof_print_date (doc_date_time);
g_object_set (G_OBJECT (cell), "text", doc_date_str, NULL);
g_free (doc_date_str);
}

static PaymentWindow *
new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice)
{
PaymentWindow *pw;
GtkBuilder *builder;
GtkWidget *box, *label, *credit_box, *debit_box;
GtkTreeSelection *selection;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
char * cm_class = (gncOwnerGetType (owner) == GNC_OWNER_CUSTOMER ?
DIALOG_PAYMENT_CUSTOMER_CM_CLASS :
DIALOG_PAYMENT_VENDOR_CM_CLASS);
Expand Down Expand Up @@ -862,6 +887,41 @@ new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice)
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(pw->docs_list_tree_view));
gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);

/* Configure date column */
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 0);
gtk_tree_view_column_pack_start (column, renderer, TRUE);
tree_view_column_set_default_width (GTK_TREE_VIEW (pw->docs_list_tree_view),
column, "31-12-2013");
gtk_tree_view_column_set_cell_data_func (column, renderer,
(GtkTreeCellDataFunc) print_date,
NULL, NULL);

/* Configure document number column */
column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 1);
tree_view_column_set_default_width (GTK_TREE_VIEW (pw->docs_list_tree_view),
column, "INV2013-016");

/* Configure document type column */
column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 2);
tree_view_column_set_default_width (GTK_TREE_VIEW (pw->docs_list_tree_view),
column, _("Credit Note"));

/* Configure debit column */
column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 3);
tree_view_column_set_default_width (GTK_TREE_VIEW (pw->docs_list_tree_view),
column, "11,999.00");

/* Configure credit column */
column = gtk_tree_view_get_column (GTK_TREE_VIEW (pw->docs_list_tree_view), 4);
tree_view_column_set_default_width (GTK_TREE_VIEW (pw->docs_list_tree_view),
column, "11,999.00");

gtk_tree_sortable_set_sort_column_id (
GTK_TREE_SORTABLE (gtk_tree_view_get_model (GTK_TREE_VIEW (pw->docs_list_tree_view))),
0, GTK_SORT_ASCENDING);


box = GTK_WIDGET (gtk_builder_get_object (builder, "acct_window"));
pw->acct_tree = GTK_WIDGET(gnc_tree_view_account_new (FALSE));
gtk_container_add (GTK_CONTAINER (box), pw->acct_tree);
Expand Down
53 changes: 18 additions & 35 deletions src/business/business-gnome/gtkbuilder/dialog-payment.glade
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.24"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkDialog" id="Payment Dialog">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Process Payment</property>
<property name="default_height">380</property>
<property name="default_height">560</property>
<property name="type_hint">dialog</property>
<signal name="destroy" handler="gnc_payment_window_destroy_cb" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<child>
<object class="GtkTable" id="table1">
Expand All @@ -38,7 +38,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">The company associated with this payment.</property>
<property name="tooltip_markup">The company associated with this payment.</property>
<property name="tooltip_text" translatable="yes">The company associated with this payment.</property>
<property name="border_width">3</property>
<child>
Expand All @@ -53,7 +53,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">The company associated with this payment.</property>
<property name="tooltip_markup">The company associated with this payment.</property>
<property name="tooltip_text" translatable="yes">The company associated with this payment.</property>
<property name="label" translatable="yes">(owner)</property>
<attributes>
Expand Down Expand Up @@ -154,12 +154,6 @@
<property name="clickable">True</property>
<property name="sort_indicator">True</property>
<property name="sort_column_id">0</property>
<child>
<object class="GtkCellRendererText" id="docs_list_date_renderer"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
Expand Down Expand Up @@ -303,7 +297,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
<property name="tooltip_markup">The amount to pay for this invoice.

If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.

Expand All @@ -330,7 +324,7 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
<property name="tooltip_markup">The amount to pay for this invoice.

If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.

Expand All @@ -356,7 +350,7 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
<property name="tooltip_markup">The amount to pay for this invoice.

If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.

Expand Down Expand Up @@ -412,7 +406,7 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
<property name="tooltip_markup">The amount to pay for this invoice.

If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.

Expand All @@ -438,7 +432,7 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
<property name="tooltip_markup">The amount to pay for this invoice.

If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.

Expand Down Expand Up @@ -492,7 +486,7 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
<property name="tooltip_markup">The amount to pay for this invoice.

If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.

Expand All @@ -509,8 +503,8 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
<property name="x_options"/>
<property name="y_options"/>
<property name="y_padding">3</property>
</packing>
</child>
Expand All @@ -519,7 +513,7 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">The amount to pay for this invoice.
<property name="tooltip_markup">The amount to pay for this invoice.

If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment.

Expand All @@ -536,20 +530,11 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
<packing>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="x_options"></property>
<property name="y_options"></property>
<property name="x_options"/>
<property name="y_options"/>
<property name="y_padding">3</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
Expand Down Expand Up @@ -629,7 +614,7 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
</packing>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
Expand All @@ -640,7 +625,6 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="gnc_payment_cancel_cb" swapped="no"/>
</object>
Expand All @@ -657,7 +641,6 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="gnc_payment_ok_cb" swapped="no"/>
</object>
Expand Down Expand Up @@ -690,7 +673,7 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic
<object class="GtkListStore" id="docs_list_model">
<columns>
<!-- column-name doc_date -->
<column type="gchararray"/>
<column type="gint64"/>
<!-- column-name doc_id -->
<column type="gchararray"/>
<!-- column-name doc_type -->
Expand Down
4 changes: 1 addition & 3 deletions src/engine/gncInvoice.c
Expand Up @@ -918,11 +918,9 @@ const char * gncInvoiceGetTypeString (const GncInvoice *invoice)
case GNC_INVOICE_EMPL_INVOICE:
return _("Expense");
case GNC_INVOICE_CUST_CREDIT_NOTE:
return _("Customer Credit Note");
case GNC_INVOICE_VEND_CREDIT_NOTE:
return _("Vendor Credit Note");
case GNC_INVOICE_EMPL_CREDIT_NOTE:
return _("Employee Credit Note");
return _("Credit Note");
default:
PWARN("Unknown invoice type");
return NULL;
Expand Down
2 changes: 2 additions & 0 deletions src/gnome-utils/Makefile.am
Expand Up @@ -102,6 +102,7 @@ libgncmod_gnome_utils_la_SOURCES = \
gnc-window.c \
gncmod-gnome-utils.c \
misc-gnome-utils.c \
tree-view-utils.c \
search-param.c \
print-session.c \
swig-gnome-utils.c \
Expand Down Expand Up @@ -180,6 +181,7 @@ gncinclude_HEADERS = \
gnc-ui.h \
gnc-window.h \
misc-gnome-utils.h \
tree-view-utils.h \
print-session.h \
window-main-summarybar.h

Expand Down

0 comments on commit f3c5b93

Please sign in to comment.