r21248 - gnucash/trunk/src/plugins/bi_import - Pass document type to gnc_bi_import_fix_bis function and use it to perform correct document owner check: vendor for bill, customer for invoice.
Geert Janssens
gjanssens at code.gnucash.org
Sun Sep 11 10:24:05 EDT 2011
Author: gjanssens
Date: 2011-09-11 10:24:04 -0400 (Sun, 11 Sep 2011)
New Revision: 21248
Trac: http://svn.gnucash.org/trac/changeset/21248
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/gui.c
Log:
Pass document type to gnc_bi_import_fix_bis function and use it to perform correct document owner check: vendor for bill, customer for invoice.
Modified: gnucash/trunk/src/plugins/bi_import/bi_import.c
===================================================================
--- gnucash/trunk/src/plugins/bi_import/bi_import.c 2011-09-11 14:23:55 UTC (rev 21247)
+++ gnucash/trunk/src/plugins/bi_import/bi_import.c 2011-09-11 14:24:04 UTC (rev 21248)
@@ -230,7 +230,7 @@
//! * if price is unset, delete row
void
gnc_bi_import_fix_bis (GtkListStore * store, guint * fixed, guint * deleted,
- GString * info)
+ GString * info, gchar *type)
{
GtkTreeIter iter;
gboolean valid, row_deleted, row_fixed;
@@ -394,7 +394,7 @@
gtk_list_store_remove (store, &iter);
row_deleted = TRUE;
g_string_append_printf (info,
- _("ROW DELETED, VENDOR_NOT_SET: id=%s\n"),
+ _("ROW DELETED, OWNER_NOT_SET: id=%s\n"),
id);
}
else
@@ -409,17 +409,34 @@
// remember owner_id
g_string_assign (prev_owner_id, owner_id);
}
- // now check, if customer exists
- if (!gnc_search_vendor_on_id
- (gnc_get_current_book (), prev_owner_id->str))
+ if (g_ascii_strcasecmp (type, "BILL") == 0)
{
- // customer not found => delete row
- gtk_list_store_remove (store, &iter);
- row_deleted = TRUE;
- g_string_append_printf (info,
- _("ROW DELETED, VENDOR_DOES_NOT_EXIST: id=%s\n"),
- id);
+ // BILL: check, if vendor exists
+ if (!gnc_search_vendor_on_id
+ (gnc_get_current_book (), prev_owner_id->str))
+ {
+ // vendor not found => delete row
+ gtk_list_store_remove (store, &iter);
+ row_deleted = TRUE;
+ g_string_append_printf (info,
+ _("ROW DELETED, VENDOR_DOES_NOT_EXIST: id=%s\n"),
+ id);
+ }
}
+ else if (g_ascii_strcasecmp (type, "INVOICE") == 0)
+ {
+ // INVOICE: check, if customer exists
+ if (!gnc_search_customer_on_id
+ (gnc_get_current_book (), prev_owner_id->str))
+ {
+ // customer not found => delete row
+ gtk_list_store_remove (store, &iter);
+ row_deleted = TRUE;
+ g_string_append_printf (info,
+ _("ROW DELETED, CUSTOMER_DOES_NOT_EXIST: id=%s\n"),
+ id);
+ }
+ }
// owner_id is valid
}
Modified: gnucash/trunk/src/plugins/bi_import/bi_import.h
===================================================================
--- gnucash/trunk/src/plugins/bi_import/bi_import.h 2011-09-11 14:23:55 UTC (rev 21247)
+++ gnucash/trunk/src/plugins/bi_import/bi_import.h 2011-09-11 14:24:04 UTC (rev 21248)
@@ -65,7 +65,7 @@
gnc_bi_import_read_file (const gchar *filename, const gchar *parser_regexp, GtkListStore *store, guint max_rows, bi_import_stats *stats);
void
-gnc_bi_import_fix_bis (GtkListStore *store, guint *fixed, guint *deleted, GString *info);
+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);
Modified: gnucash/trunk/src/plugins/bi_import/gui.c
===================================================================
--- gnucash/trunk/src/plugins/bi_import/gui.c 2011-09-11 14:23:55 UTC (rev 21247)
+++ gnucash/trunk/src/plugins/bi_import/gui.c 2011-09-11 14:24:04 UTC (rev 21248)
@@ -200,7 +200,7 @@
res = gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 0, &stats);
if (res == RESULT_OK)
{
- gnc_bi_import_fix_bis (gui->store, &n_fixed, &n_deleted, info);
+ gnc_bi_import_fix_bis (gui->store, &n_fixed, &n_deleted, info, gui->type);
if (info->len > 0)
gnc_info_dialog (gui->dialog, "%s", info->str);
g_string_free( info, TRUE );
More information about the gnucash-changes
mailing list