Opening new bills / invoices made configurable from UI.

Patch by Rafał Krzewski

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21265 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens 2011-09-17 17:19:52 +00:00
parent 1b05840f0f
commit ef751285f7
4 changed files with 106 additions and 6 deletions

View File

@ -489,7 +489,8 @@ gnc_bi_import_fix_bis (GtkListStore * store, guint * fixed, guint * deleted,
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 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
//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);

View File

@ -68,7 +68,7 @@ void
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

View File

@ -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>

View File

@ -52,7 +52,8 @@ struct _bi_import_gui
gint component_id;
GString *regexp;
QofBook *book;
gchar *type;
gchar *type;
gchar *open_mode;
};
@ -72,6 +73,7 @@ void gnc_bi_import_gui_option2_cb (GtkWidget *widget, gpointer data);
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 @@ gnc_plugin_bi_import_showGUI(void)
// 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 @@ gnc_bi_import_gui_ok_cb (GtkWidget *widget, gpointer data)
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 @@ void gnc_bi_import_gui_option5_cb (GtkWidget *widget, gpointer data)
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
* ****************************************************************/