r21265 - gnucash/trunk/src/plugins/bi_import - Opening new bills / invoices made configurable from UI.
Geert Janssens
gjanssens at code.gnucash.org
Sat Sep 17 13:19:52 EDT 2011
Author: gjanssens
Date: 2011-09-17 13:19:52 -0400 (Sat, 17 Sep 2011)
New Revision: 21265
Trac: http://svn.gnucash.org/trac/changeset/21265
Modified:
gnucash/trunk/src/plugins/bi_import/bi_import.c
gnucash/trunk/src/plugins/bi_import/bi_import.h
gnucash/trunk/src/plugins/bi_import/glade/bi_import.glade
gnucash/trunk/src/plugins/bi_import/gui.c
Log:
Opening new bills / invoices made configurable from UI.
Patch by Rafał Krzewski
Modified: gnucash/trunk/src/plugins/bi_import/bi_import.c
===================================================================
--- gnucash/trunk/src/plugins/bi_import/bi_import.c 2011-09-17 17:19:42 UTC (rev 21264)
+++ gnucash/trunk/src/plugins/bi_import/bi_import.c 2011-09-17 17:19:52 UTC (rev 21265)
@@ -489,7 +489,8 @@
void
gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
guint * n_invoices_created,
- guint * n_invoices_updated, gchar * type)
+ guint * n_invoices_updated,
+ gchar * type, gchar * open_mode )
{
gboolean valid;
GtkTreeIter iter;
@@ -597,8 +598,11 @@
//if (g_ascii_strcasecmp(type,"INVOICE"))gncInvoiceSetBillTo( invoice, billto );
(*n_invoices_created)++;
update = YES;
- // If the invoice has not been posted yet, open it in a tab.
- if (strlen(date_posted) == 0)
+
+ // open new bill / invoice in a tab, if requested
+ if (g_ascii_strcasecmp(open_mode, "ALL") == 0
+ || (g_ascii_strcasecmp(open_mode, "NOT_POSTED") == 0
+ && strlen(date_posted) == 0))
{
iw = gnc_ui_invoice_edit (invoice);
new_page = gnc_plugin_page_invoice_new (iw);
Modified: gnucash/trunk/src/plugins/bi_import/bi_import.h
===================================================================
--- gnucash/trunk/src/plugins/bi_import/bi_import.h 2011-09-17 17:19:42 UTC (rev 21264)
+++ gnucash/trunk/src/plugins/bi_import/bi_import.h 2011-09-17 17:19:52 UTC (rev 21265)
@@ -68,7 +68,7 @@
gnc_bi_import_fix_bis (GtkListStore *store, guint *fixed, guint *deleted, GString *info, gchar *type);
void
-gnc_bi_import_create_bis (GtkListStore *store, QofBook *book, guint *n_invoices_created, guint *n_invoices_updated, gchar *type);
+gnc_bi_import_create_bis (GtkListStore *store, QofBook *book, guint *n_invoices_created, guint *n_invoices_updated, gchar *type, gchar *open_mode);
G_END_DECLS
Modified: gnucash/trunk/src/plugins/bi_import/glade/bi_import.glade
===================================================================
--- gnucash/trunk/src/plugins/bi_import/glade/bi_import.glade 2011-09-17 17:19:42 UTC (rev 21264)
+++ gnucash/trunk/src/plugins/bi_import/glade/bi_import.glade 2011-09-17 17:19:52 UTC (rev 21265)
@@ -302,6 +302,89 @@
<property name="position">3</property>
</packing>
</child>
+ <child>
+ <widget class="GtkFrame" id="frame5">
+ <property name="visible">True</property>
+ <property name="border_width">3</property>
+ <property name="label_xalign">0</property>
+ <child>
+ <widget class="GtkAlignment" id="alignment5">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <widget class="GtkVBox" id="vbox5">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <widget class="GtkRadioButton" id="radiobuttonOpenAll">
+ <property name="label" translatable="yes">Open imported documents in tabs</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="gnc_bi_import_gui_open_mode"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="radiobuttonOpenNotPosted">
+ <property name="label" translatable="yes">Open not yet posted documents in tabs </property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">radiobuttonOpenAll</property>
+ <signal name="toggled" handler="gnc_bi_import_gui_open_mode"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="radiobuttonOpenNone">
+ <property name="label" translatable="yes">Don't open imported documents in tabs</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">radiobuttonOpenAll</property>
+ <signal name="toggled" handler="gnc_bi_import_gui_open_mode"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">5. Afterwards</property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
Modified: gnucash/trunk/src/plugins/bi_import/gui.c
===================================================================
--- gnucash/trunk/src/plugins/bi_import/gui.c 2011-09-17 17:19:42 UTC (rev 21264)
+++ gnucash/trunk/src/plugins/bi_import/gui.c 2011-09-17 17:19:52 UTC (rev 21265)
@@ -52,7 +52,8 @@
gint component_id;
GString *regexp;
QofBook *book;
- gchar *type;
+ gchar *type;
+ gchar *open_mode;
};
@@ -72,6 +73,7 @@
void gnc_bi_import_gui_option3_cb (GtkWidget *widget, gpointer data);
void gnc_bi_import_gui_option4_cb (GtkWidget *widget, gpointer data);
void gnc_bi_import_gui_option5_cb (GtkWidget *widget, gpointer data);
+void gnc_bi_import_gui_open_mode (GtkWidget *widget, gpointer data);
void gnc_import_gui_type(GtkWidget *widget, gpointer data);
// utils
@@ -105,6 +107,7 @@
// create new window
gui = g_new0 (BillImportGui, 1);
gui->type = "BILL"; // Set default type to match gui. really shouldn't be here TODO change me
+ gui->open_mode = "ALL";
xml = gnc_glade_xml_new ("bi_import.glade", "bi_import Dialog");
gui->dialog = glade_xml_get_widget (xml, "bi_import Dialog");
gui->tree_view = glade_xml_get_widget (xml, "treeview1");
@@ -204,7 +207,7 @@
if (info->len > 0)
gnc_info_dialog (gui->dialog, "%s", info->str);
g_string_free( info, TRUE );
- gnc_bi_import_create_bis (gui->store, gui->book, &n_invoices_created, &n_invoices_updated, gui->type);
+ gnc_bi_import_create_bis (gui->store, gui->book, &n_invoices_created, &n_invoices_updated, gui->type, gui->open_mode);
gnc_info_dialog (gui->dialog, _("Import results:\n%i lines were ignored\n%i lines imported:\n %u fixes\n %u ignored (not fixable)\n\n %u created\n %u updated (based on id)"), stats.n_ignored, stats.n_imported, n_fixed, n_deleted, n_invoices_created, n_invoices_updated);
if (stats.n_ignored > 0)
@@ -334,6 +337,16 @@
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
}
}
+void gnc_bi_import_gui_open_mode (GtkWidget *widget, gpointer data)
+{
+ BillImportGui *gui = data;
+ if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
+ return;
+ if (g_ascii_strcasecmp(widget->name, "radiobuttonOpenAll") == 0)gui->open_mode = "ALL";
+ else if (g_ascii_strcasecmp(widget->name, "radiobuttonOpenNotPosted") == 0)gui->open_mode = "NOT_POSTED";
+ else if (g_ascii_strcasecmp(widget->name, "radiobuttonOpenNone") == 0)gui->open_mode = "NONE";
+}
+
/*****************************************************************
* Set whether we are importing a bi, invoice, Customer or Vendor
* ****************************************************************/
More information about the gnucash-changes
mailing list