mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Re-indentation of source code.
This re-indentation was done using astyle-1.24 using the following options: astyle --indent=spaces=4 --brackets=break --pad-oper --pad-header --suffix=none git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20163 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
bd17b5fa41
commit
c8f1244fff
@ -479,28 +479,28 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
|||||||
account_descendants = gnc_account_get_descendants (account);
|
account_descendants = gnc_account_get_descendants (account);
|
||||||
if (account_descendants)
|
if (account_descendants)
|
||||||
{
|
{
|
||||||
gint sub_acct_tax_number = 0;
|
gint sub_acct_tax_number = 0;
|
||||||
for (descendant = account_descendants; descendant;
|
for (descendant = account_descendants; descendant;
|
||||||
descendant = g_list_next(descendant))
|
descendant = g_list_next(descendant))
|
||||||
{
|
{
|
||||||
if (xaccAccountGetTaxRelated (descendant->data))
|
if (xaccAccountGetTaxRelated (descendant->data))
|
||||||
sub_acct_tax_number++;
|
sub_acct_tax_number++;
|
||||||
}
|
}
|
||||||
/* Translators: This and the following strings appear on
|
/* Translators: This and the following strings appear on
|
||||||
* the account tab if the Tax Info column is displayed,
|
* the account tab if the Tax Info column is displayed,
|
||||||
* i.e. if the user wants to record the tax form number
|
* i.e. if the user wants to record the tax form number
|
||||||
* and location on that tax form which corresponds to this
|
* and location on that tax form which corresponds to this
|
||||||
* gnucash account. For the US Income Tax support in
|
* gnucash account. For the US Income Tax support in
|
||||||
* gnucash, each tax code that can be assigned to an
|
* gnucash, each tax code that can be assigned to an
|
||||||
* account generally corresponds to a specific line number
|
* account generally corresponds to a specific line number
|
||||||
* on a paper form and each form has a unique
|
* on a paper form and each form has a unique
|
||||||
* identification (e.g., Form 1040, Schedule A). */
|
* identification (e.g., Form 1040, Schedule A). */
|
||||||
descendant_txt = (sub_acct_tax_number == 0) ? "" :
|
descendant_txt = (sub_acct_tax_number == 0) ? "" :
|
||||||
g_strdup_printf (_("(Tax-related subaccounts: %d)"),
|
g_strdup_printf (_("(Tax-related subaccounts: %d)"),
|
||||||
sub_acct_tax_number);
|
sub_acct_tax_number);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
descendant_txt = "";
|
descendant_txt = "";
|
||||||
|
|
||||||
tax_related = xaccAccountGetTaxRelated (account);
|
tax_related = xaccAccountGetTaxRelated (account);
|
||||||
code = xaccAccountGetTaxUSCode (account);
|
code = xaccAccountGetTaxUSCode (account);
|
||||||
@ -509,19 +509,19 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
|||||||
{
|
{
|
||||||
if (!tax_related)
|
if (!tax_related)
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
else
|
else
|
||||||
return g_strdup_printf ("%s", descendant_txt);
|
return g_strdup_printf ("%s", descendant_txt);
|
||||||
}
|
}
|
||||||
/* tax_related && !code */
|
/* tax_related && !code */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup (_("Tax-related but has no tax code"));
|
return g_strdup (_("Tax-related but has no tax code"));
|
||||||
else
|
else
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Tax-related but has no tax code; %s"), descendant_txt);
|
(_("Tax-related but has no tax code; %s"), descendant_txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* with tax code */
|
else /* with tax code */
|
||||||
@ -532,11 +532,11 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
|||||||
tax_type = gnc_get_current_book_tax_type ();
|
tax_type = gnc_get_current_book_tax_type ();
|
||||||
if (tax_type == NULL || (safe_strcmp (tax_type, "") == 0))
|
if (tax_type == NULL || (safe_strcmp (tax_type, "") == 0))
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup (_("Tax entity type not specified"));
|
return g_strdup (_("Tax entity type not specified"));
|
||||||
else
|
else
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Tax entity type not specified; %s"), descendant_txt);
|
(_("Tax entity type not specified; %s"), descendant_txt);
|
||||||
}
|
}
|
||||||
atype = xaccAccountGetType (account);
|
atype = xaccAccountGetType (account);
|
||||||
/* tax_entity_type = scm_from_locale_string (tax_type); <- requires guile 1.8*/
|
/* tax_entity_type = scm_from_locale_string (tax_type); <- requires guile 1.8*/
|
||||||
@ -603,25 +603,25 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
|||||||
{
|
{
|
||||||
if (tax_related)
|
if (tax_related)
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Tax type %s: invalid code %s for account type"),
|
(_("Tax type %s: invalid code %s for account type"),
|
||||||
tax_type, num_code);
|
tax_type, num_code);
|
||||||
else
|
else
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Tax type %s: invalid code %s for account type; %s"),
|
(_("Tax type %s: invalid code %s for account type; %s"),
|
||||||
tax_type, num_code, descendant_txt);
|
tax_type, num_code, descendant_txt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Not tax-related; tax type %s: invalid code %s for account type"),
|
(_("Not tax-related; tax type %s: invalid code %s for account type"),
|
||||||
tax_type, num_code);
|
tax_type, num_code);
|
||||||
else
|
else
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Not tax-related; tax type %s: invalid code %s for account type; %s"),
|
(_("Not tax-related; tax type %s: invalid code %s for account type; %s"),
|
||||||
tax_type, num_code, descendant_txt);
|
tax_type, num_code, descendant_txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,25 +631,25 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
|||||||
{
|
{
|
||||||
if (tax_related)
|
if (tax_related)
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Invalid code %s for tax type %s"),
|
(_("Invalid code %s for tax type %s"),
|
||||||
num_code, tax_type);
|
num_code, tax_type);
|
||||||
else
|
else
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Invalid code %s for tax type %s; %s"),
|
(_("Invalid code %s for tax type %s; %s"),
|
||||||
num_code, tax_type, descendant_txt);
|
num_code, tax_type, descendant_txt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Not tax-related; invalid code %s for tax type %s"),
|
(_("Not tax-related; invalid code %s for tax type %s"),
|
||||||
num_code, tax_type);
|
num_code, tax_type);
|
||||||
else
|
else
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Not tax-related; invalid code %s for tax type %s; %s"),
|
(_("Not tax-related; invalid code %s for tax type %s; %s"),
|
||||||
num_code, tax_type, descendant_txt);
|
num_code, tax_type, descendant_txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,24 +658,24 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
|||||||
{
|
{
|
||||||
if (tax_related)
|
if (tax_related)
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("No form: code %s, tax type %s"), num_code, tax_type);
|
(_("No form: code %s, tax type %s"), num_code, tax_type);
|
||||||
else
|
else
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("No form: code %s, tax type %s; %s"),
|
(_("No form: code %s, tax type %s; %s"),
|
||||||
num_code, tax_type, descendant_txt);
|
num_code, tax_type, descendant_txt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Not tax-related; no form: code %s, tax type %s"),
|
(_("Not tax-related; no form: code %s, tax type %s"),
|
||||||
num_code, tax_type);
|
num_code, tax_type);
|
||||||
else
|
else
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Not tax-related; no form: code %s, tax type %s; %s"),
|
(_("Not tax-related; no form: code %s, tax type %s; %s"),
|
||||||
num_code, tax_type, descendant_txt);
|
num_code, tax_type, descendant_txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -684,25 +684,25 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
|||||||
{
|
{
|
||||||
if (tax_related)
|
if (tax_related)
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("No description: form %s, code %s, tax type %s"),
|
(_("No description: form %s, code %s, tax type %s"),
|
||||||
form, num_code, tax_type);
|
form, num_code, tax_type);
|
||||||
else
|
else
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("No description: form %s, code %s, tax type %s; %s"),
|
(_("No description: form %s, code %s, tax type %s; %s"),
|
||||||
form, num_code, tax_type, descendant_txt);
|
form, num_code, tax_type, descendant_txt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
|
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
|
||||||
form, num_code, tax_type);
|
form, num_code, tax_type);
|
||||||
else
|
else
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
|
(_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
|
||||||
form, num_code, tax_type, descendant_txt);
|
form, num_code, tax_type, descendant_txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -711,25 +711,25 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
|||||||
{
|
{
|
||||||
if (tax_related)
|
if (tax_related)
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("No description: form %s, code %s, tax type %s"),
|
(_("No description: form %s, code %s, tax type %s"),
|
||||||
form, num_code, tax_type);
|
form, num_code, tax_type);
|
||||||
else
|
else
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("No description: form %s, code %s, tax type %s; %s"),
|
(_("No description: form %s, code %s, tax type %s; %s"),
|
||||||
form, num_code, tax_type, descendant_txt);
|
form, num_code, tax_type, descendant_txt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
|
(_("Not tax-related; no description: form %s, code %s, tax type %s"),
|
||||||
form, num_code, tax_type);
|
form, num_code, tax_type);
|
||||||
else
|
else
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
|
(_("Not tax-related; no description: form %s, code %s, tax type %s; %s"),
|
||||||
form, num_code, tax_type, descendant_txt);
|
form, num_code, tax_type, descendant_txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -741,31 +741,31 @@ gnc_ui_account_get_tax_info_string (const Account *account)
|
|||||||
{
|
{
|
||||||
if (safe_strcmp (form, "") == 0)
|
if (safe_strcmp (form, "") == 0)
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup_printf ("%s", desc);
|
return g_strdup_printf ("%s", desc);
|
||||||
else
|
else
|
||||||
return g_strdup_printf ("%s; %s", desc, descendant_txt);
|
return g_strdup_printf ("%s; %s", desc, descendant_txt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup_printf ("%s%s: %s", form, copy_txt, desc);
|
return g_strdup_printf ("%s%s: %s", form, copy_txt, desc);
|
||||||
else
|
else
|
||||||
return g_strdup_printf ("%s%s: %s; %s",
|
return g_strdup_printf ("%s%s: %s; %s",
|
||||||
form, copy_txt, desc, descendant_txt);
|
form, copy_txt, desc, descendant_txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (safe_strcmp (descendant_txt, "") == 0)
|
if (safe_strcmp (descendant_txt, "") == 0)
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Not tax-related; %s%s: %s (code %s, tax type %s)"),
|
(_("Not tax-related; %s%s: %s (code %s, tax type %s)"),
|
||||||
form, copy_txt, desc, num_code, tax_type);
|
form, copy_txt, desc, num_code, tax_type);
|
||||||
else
|
else
|
||||||
return g_strdup_printf
|
return g_strdup_printf
|
||||||
(_("Not tax-related; %s%s: %s (code %s, tax type %s); %s"),
|
(_("Not tax-related; %s%s: %s (code %s, tax type %s); %s"),
|
||||||
form, copy_txt, desc, num_code, tax_type, descendant_txt);
|
form, copy_txt, desc, num_code, tax_type, descendant_txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,9 +153,9 @@ static void
|
|||||||
gnc_table_slist_free( GSList *table_list )
|
gnc_table_slist_free( GSList *table_list )
|
||||||
{
|
{
|
||||||
GSList *list;
|
GSList *list;
|
||||||
for ( list = table_list; list !=NULL; list = g_slist_next( list ))
|
for ( list = table_list; list != NULL; list = g_slist_next( list ))
|
||||||
{
|
{
|
||||||
g_free( list->data );
|
g_free( list->data );
|
||||||
}
|
}
|
||||||
g_slist_free( table_list );
|
g_slist_free( table_list );
|
||||||
}
|
}
|
||||||
@ -252,19 +252,19 @@ gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
|
|||||||
/* Remove uri type if present */
|
/* Remove uri type if present */
|
||||||
filepath = gnc_uri_get_path ( book_id );
|
filepath = gnc_uri_get_path ( book_id );
|
||||||
file_exists = g_file_test( filepath,
|
file_exists = g_file_test( filepath,
|
||||||
G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS );
|
G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS );
|
||||||
if ( !create && !file_exists )
|
if ( !create && !file_exists )
|
||||||
{
|
{
|
||||||
qof_backend_set_error( qbe, ERR_FILEIO_FILE_NOT_FOUND );
|
qof_backend_set_error( qbe, ERR_FILEIO_FILE_NOT_FOUND );
|
||||||
qof_backend_set_message(qbe, "Sqlite3 file %s not found", filepath);
|
qof_backend_set_message(qbe, "Sqlite3 file %s not found", filepath);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( create && !force && file_exists )
|
if ( create && !force && file_exists )
|
||||||
{
|
{
|
||||||
qof_backend_set_error (qbe, ERR_BACKEND_STORE_EXISTS);
|
qof_backend_set_error (qbe, ERR_BACKEND_STORE_EXISTS);
|
||||||
msg = "Might clobber, no force";
|
msg = "Might clobber, no force";
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
|
|||||||
{
|
{
|
||||||
PERR( "Unable to create sqlite3 dbi connection\n" );
|
PERR( "Unable to create sqlite3 dbi connection\n" );
|
||||||
qof_backend_set_error( qbe, ERR_BACKEND_BAD_URL );
|
qof_backend_set_error( qbe, ERR_BACKEND_BAD_URL );
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
dirname = g_path_get_dirname( filepath );
|
dirname = g_path_get_dirname( filepath );
|
||||||
@ -289,21 +289,21 @@ gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
|
|||||||
{
|
{
|
||||||
PERR( "Error setting 'host' option\n" );
|
PERR( "Error setting 'host' option\n" );
|
||||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
result = dbi_conn_set_option( be->conn, "dbname", basename );
|
result = dbi_conn_set_option( be->conn, "dbname", basename );
|
||||||
if ( result < 0 )
|
if ( result < 0 )
|
||||||
{
|
{
|
||||||
PERR( "Error setting 'dbname' option\n" );
|
PERR( "Error setting 'dbname' option\n" );
|
||||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
result = dbi_conn_set_option( be->conn, "sqlite3_dbdir", dirname );
|
result = dbi_conn_set_option( be->conn, "sqlite3_dbdir", dirname );
|
||||||
if ( result < 0 )
|
if ( result < 0 )
|
||||||
{
|
{
|
||||||
PERR( "Error setting 'sqlite3_dbdir' option\n" );
|
PERR( "Error setting 'sqlite3_dbdir' option\n" );
|
||||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
result = dbi_conn_connect( be->conn );
|
result = dbi_conn_connect( be->conn );
|
||||||
|
|
||||||
@ -311,26 +311,28 @@ gnc_dbi_sqlite3_session_begin( QofBackend *qbe, QofSession *session,
|
|||||||
{
|
{
|
||||||
PERR( "Unable to connect to %s: %d\n", book_id, result );
|
PERR( "Unable to connect to %s: %d\n", book_id, result );
|
||||||
qof_backend_set_error( qbe, ERR_BACKEND_BAD_URL );
|
qof_backend_set_error( qbe, ERR_BACKEND_BAD_URL );
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !conn_test_dbi_library( be->conn ) ) {
|
if ( !conn_test_dbi_library( be->conn ) )
|
||||||
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
|
{
|
||||||
qof_backend_set_message( qbe, "DBI library fails large number test" );
|
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
|
||||||
if ( create && !file_exists ) /* File didn't exist before, but it */
|
qof_backend_set_message( qbe, "DBI library fails large number test" );
|
||||||
{ /* does now, and we don't want to */
|
if ( create && !file_exists ) /* File didn't exist before, but it */
|
||||||
dbi_conn_close( be->conn );/* leave it lying around. */
|
{
|
||||||
be->conn = NULL;
|
/* does now, and we don't want to */
|
||||||
g_unlink( filepath );
|
dbi_conn_close( be->conn );/* leave it lying around. */
|
||||||
}
|
be->conn = NULL;
|
||||||
msg = "Bad DBI Library";
|
g_unlink( filepath );
|
||||||
goto exit;
|
}
|
||||||
|
msg = "Bad DBI Library";
|
||||||
|
goto exit;
|
||||||
}
|
}
|
||||||
if ( !gnc_dbi_lock_database( qbe, ignore_lock ) )
|
if ( !gnc_dbi_lock_database( qbe, ignore_lock ) )
|
||||||
{
|
{
|
||||||
qof_backend_set_error( qbe, ERR_BACKEND_LOCKED );
|
qof_backend_set_error( qbe, ERR_BACKEND_LOCKED );
|
||||||
msg = "Locked";
|
msg = "Locked";
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( be->sql_be.conn != NULL )
|
if ( be->sql_be.conn != NULL )
|
||||||
@ -354,8 +356,8 @@ conn_get_index_list_sqlite3( dbi_conn conn )
|
|||||||
dbi_result result = dbi_conn_query( conn, "SELECT name FROM sqlite_master WHERE type = 'index' AND name NOT LIKE 'sqlite_autoindex%'" );
|
dbi_result result = dbi_conn_query( conn, "SELECT name FROM sqlite_master WHERE type = 'index' AND name NOT LIKE 'sqlite_autoindex%'" );
|
||||||
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
|
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
|
||||||
{
|
{
|
||||||
g_print( "Index Table Retrieval Error: %s\n", errmsg );
|
g_print( "Index Table Retrieval Error: %s\n", errmsg );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
while ( dbi_result_next_row( result ) != 0 )
|
while ( dbi_result_next_row( result ) != 0 )
|
||||||
{
|
{
|
||||||
@ -761,12 +763,13 @@ gnc_dbi_mysql_session_begin( QofBackend* qbe, QofSession *session,
|
|||||||
result = dbi_conn_connect( be->conn );
|
result = dbi_conn_connect( be->conn );
|
||||||
if ( result == 0 )
|
if ( result == 0 )
|
||||||
{
|
{
|
||||||
if ( !conn_test_dbi_library( be->conn ) ) {
|
if ( !conn_test_dbi_library( be->conn ) )
|
||||||
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
|
{
|
||||||
qof_backend_set_message( qbe,
|
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
|
||||||
"DBI library fails large number test" );
|
qof_backend_set_message( qbe,
|
||||||
goto exit;
|
"DBI library fails large number test" );
|
||||||
}
|
goto exit;
|
||||||
|
}
|
||||||
if (create && !force && save_may_clobber_data( qbe ) )
|
if (create && !force && save_may_clobber_data( qbe ) )
|
||||||
{
|
{
|
||||||
qof_backend_set_error ( qbe, ERR_BACKEND_STORE_EXISTS );
|
qof_backend_set_error ( qbe, ERR_BACKEND_STORE_EXISTS );
|
||||||
@ -833,13 +836,14 @@ gnc_dbi_mysql_session_begin( QofBackend* qbe, QofSession *session,
|
|||||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if ( !conn_test_dbi_library( be->conn ) ) {
|
if ( !conn_test_dbi_library( be->conn ) )
|
||||||
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
|
{
|
||||||
qof_backend_set_message( qbe,
|
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
|
||||||
"DBI library fails large number test" );
|
qof_backend_set_message( qbe,
|
||||||
dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbname );
|
"DBI library fails large number test" );
|
||||||
goto exit;
|
dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbname );
|
||||||
}
|
goto exit;
|
||||||
|
}
|
||||||
success = gnc_dbi_lock_database ( qbe, ignore_lock );
|
success = gnc_dbi_lock_database ( qbe, ignore_lock );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -891,28 +895,28 @@ conn_get_index_list_mysql( dbi_conn conn )
|
|||||||
table_list = dbi_conn_get_table_list( conn, dbname, NULL );
|
table_list = dbi_conn_get_table_list( conn, dbname, NULL );
|
||||||
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
|
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
|
||||||
{
|
{
|
||||||
g_print( "Table Retrieval Error: %s\n", errmsg );
|
g_print( "Table Retrieval Error: %s\n", errmsg );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
while ( dbi_result_next_row( table_list ) != 0 )
|
while ( dbi_result_next_row( table_list ) != 0 )
|
||||||
{
|
{
|
||||||
dbi_result result;
|
dbi_result result;
|
||||||
const gchar *table_name = dbi_result_get_string_idx( table_list, 1 );
|
const gchar *table_name = dbi_result_get_string_idx( table_list, 1 );
|
||||||
result = dbi_conn_queryf( conn,
|
result = dbi_conn_queryf( conn,
|
||||||
"SHOW INDEXES IN %s WHERE Key_name != 'PRIMARY'",
|
"SHOW INDEXES IN %s WHERE Key_name != 'PRIMARY'",
|
||||||
table_name );
|
table_name );
|
||||||
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
|
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
|
||||||
{
|
{
|
||||||
g_print( "Index Table Retrieval Error: %s\n", errmsg );
|
g_print( "Index Table Retrieval Error: %s\n", errmsg );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ( dbi_result_next_row( result ) != 0 )
|
while ( dbi_result_next_row( result ) != 0 )
|
||||||
{
|
{
|
||||||
const gchar* index_name = dbi_result_get_string_idx( result, 3 );
|
const gchar* index_name = dbi_result_get_string_idx( result, 3 );
|
||||||
index_list = g_slist_prepend( index_list, strdup( index_name ) );
|
index_list = g_slist_prepend( index_list, strdup( index_name ) );
|
||||||
}
|
}
|
||||||
dbi_result_free( result );
|
dbi_result_free( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
return index_list;
|
return index_list;
|
||||||
@ -1027,12 +1031,13 @@ gnc_dbi_postgres_session_begin( QofBackend *qbe, QofSession *session,
|
|||||||
result = dbi_conn_connect( be->conn );
|
result = dbi_conn_connect( be->conn );
|
||||||
if ( result == 0 )
|
if ( result == 0 )
|
||||||
{
|
{
|
||||||
if ( !conn_test_dbi_library( be->conn ) ) {
|
if ( !conn_test_dbi_library( be->conn ) )
|
||||||
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
|
{
|
||||||
qof_backend_set_message( qbe,
|
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
|
||||||
"DBI library fails large number test" );
|
qof_backend_set_message( qbe,
|
||||||
goto exit;
|
"DBI library fails large number test" );
|
||||||
}
|
goto exit;
|
||||||
|
}
|
||||||
if (create && !force && save_may_clobber_data( qbe ) )
|
if (create && !force && save_may_clobber_data( qbe ) )
|
||||||
{
|
{
|
||||||
qof_backend_set_error ( qbe, ERR_BACKEND_STORE_EXISTS );
|
qof_backend_set_error ( qbe, ERR_BACKEND_STORE_EXISTS );
|
||||||
@ -1100,14 +1105,15 @@ gnc_dbi_postgres_session_begin( QofBackend *qbe, QofSession *session,
|
|||||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if ( !conn_test_dbi_library( be->conn ) ) {
|
if ( !conn_test_dbi_library( be->conn ) )
|
||||||
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
|
{
|
||||||
qof_backend_set_message( qbe,
|
qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
|
||||||
"DBI library fails large number test" );
|
qof_backend_set_message( qbe,
|
||||||
dbi_conn_select_db( be->conn, "template1" );
|
"DBI library fails large number test" );
|
||||||
dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbnamelc );
|
dbi_conn_select_db( be->conn, "template1" );
|
||||||
goto exit;
|
dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbnamelc );
|
||||||
}
|
goto exit;
|
||||||
|
}
|
||||||
success = gnc_dbi_lock_database ( qbe, ignore_lock );
|
success = gnc_dbi_lock_database ( qbe, ignore_lock );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1146,8 +1152,8 @@ conn_get_index_list_pgsql( dbi_conn conn )
|
|||||||
result = dbi_conn_query( conn, "SELECT relname FROM pg_class AS a INNER JOIN pg_index AS b ON (b.indexrelid = a.oid) INNER JOIN pg_namespace AS c ON (a.relnamespace = c.oid) WHERE reltype = '0' AND indisprimary = 'f' AND nspname = 'public'" );
|
result = dbi_conn_query( conn, "SELECT relname FROM pg_class AS a INNER JOIN pg_index AS b ON (b.indexrelid = a.oid) INNER JOIN pg_namespace AS c ON (a.relnamespace = c.oid) WHERE reltype = '0' AND indisprimary = 'f' AND nspname = 'public'" );
|
||||||
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
|
if ( dbi_conn_error( conn, &errmsg ) != DBI_ERROR_NONE )
|
||||||
{
|
{
|
||||||
g_print( "Index Table Retrieval Error: %s\n", errmsg );
|
g_print( "Index Table Retrieval Error: %s\n", errmsg );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
while ( dbi_result_next_row( result ) != 0 )
|
while ( dbi_result_next_row( result ) != 0 )
|
||||||
{
|
{
|
||||||
@ -1226,19 +1232,19 @@ gnc_dbi_load( QofBackend* qbe, /*@ dependent @*/ QofBook *book, QofBackendLoadTy
|
|||||||
|
|
||||||
if ( GNC_RESAVE_VERSION > gnc_sql_get_table_version( &be->sql_be, "Gnucash" ) )
|
if ( GNC_RESAVE_VERSION > gnc_sql_get_table_version( &be->sql_be, "Gnucash" ) )
|
||||||
{
|
{
|
||||||
/* The database was loaded with an older database schema or
|
/* The database was loaded with an older database schema or
|
||||||
* data semantics. In order to ensure consistency, the whole
|
* data semantics. In order to ensure consistency, the whole
|
||||||
* thing needs to be saved anew. */
|
* thing needs to be saved anew. */
|
||||||
qof_backend_set_error( qbe, ERR_SQL_DB_TOO_OLD );
|
qof_backend_set_error( qbe, ERR_SQL_DB_TOO_OLD );
|
||||||
}
|
}
|
||||||
else if ( GNC_RESAVE_VERSION < gnc_sql_get_table_version( &be->sql_be,
|
else if ( GNC_RESAVE_VERSION < gnc_sql_get_table_version( &be->sql_be,
|
||||||
"Gnucash-Resave"))
|
"Gnucash-Resave"))
|
||||||
{
|
{
|
||||||
/* Worse, the database was created with a newer version. We
|
/* Worse, the database was created with a newer version. We
|
||||||
* can't safely write to this database, so the user will have
|
* can't safely write to this database, so the user will have
|
||||||
* to do a "save as" to make one that we can write to.
|
* to do a "save as" to make one that we can write to.
|
||||||
*/
|
*/
|
||||||
qof_backend_set_error( qbe, ERR_SQL_DB_TOO_NEW );
|
qof_backend_set_error( qbe, ERR_SQL_DB_TOO_NEW );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1268,26 +1274,26 @@ save_may_clobber_data( QofBackend* qbe )
|
|||||||
|
|
||||||
static dbi_result
|
static dbi_result
|
||||||
conn_table_manage_backup (GncDbiSqlConnection *conn,
|
conn_table_manage_backup (GncDbiSqlConnection *conn,
|
||||||
gchar *table_name, TableOpType op )
|
gchar *table_name, TableOpType op )
|
||||||
{
|
{
|
||||||
gchar *new_name = g_strdup_printf( "%s_%s", table_name, "back" );
|
gchar *new_name = g_strdup_printf( "%s_%s", table_name, "back" );
|
||||||
dbi_result result;
|
dbi_result result;
|
||||||
switch ( op )
|
switch ( op )
|
||||||
{
|
{
|
||||||
case backup:
|
case backup:
|
||||||
result = dbi_conn_queryf( conn->conn, "ALTER TABLE %s RENAME TO %s",
|
result = dbi_conn_queryf( conn->conn, "ALTER TABLE %s RENAME TO %s",
|
||||||
table_name, new_name );
|
table_name, new_name );
|
||||||
break;
|
break;
|
||||||
case rollback:
|
case rollback:
|
||||||
result = dbi_conn_queryf( conn->conn,
|
result = dbi_conn_queryf( conn->conn,
|
||||||
"ALTER TABLE %s RENAME TO %s",
|
"ALTER TABLE %s RENAME TO %s",
|
||||||
new_name, table_name );
|
new_name, table_name );
|
||||||
break;
|
break;
|
||||||
case drop_backup:
|
case drop_backup:
|
||||||
result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
|
result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
|
||||||
new_name );
|
new_name );
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
g_free( new_name );
|
g_free( new_name );
|
||||||
return result;
|
return result;
|
||||||
@ -1320,7 +1326,7 @@ conn_table_manage_backup (GncDbiSqlConnection *conn,
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
conn_table_operation( GncSqlConnection *sql_conn, GSList *table_name_list,
|
conn_table_operation( GncSqlConnection *sql_conn, GSList *table_name_list,
|
||||||
TableOpType op )
|
TableOpType op )
|
||||||
{
|
{
|
||||||
GSList* node;
|
GSList* node;
|
||||||
gboolean result = TRUE;
|
gboolean result = TRUE;
|
||||||
@ -1330,55 +1336,56 @@ conn_table_operation( GncSqlConnection *sql_conn, GSList *table_name_list,
|
|||||||
|
|
||||||
g_return_val_if_fail( table_name_list != NULL, FALSE );
|
g_return_val_if_fail( table_name_list != NULL, FALSE );
|
||||||
if ( op == rollback )
|
if ( op == rollback )
|
||||||
full_table_name_list =
|
full_table_name_list =
|
||||||
conn->provider->get_table_list( conn->conn, dbname );
|
conn->provider->get_table_list( conn->conn, dbname );
|
||||||
|
|
||||||
for ( node = table_name_list; node != NULL && result; node = node->next )
|
for ( node = table_name_list; node != NULL && result; node = node->next )
|
||||||
{
|
{
|
||||||
gchar* table_name = (gchar*)node->data;
|
gchar* table_name = (gchar*)node->data;
|
||||||
dbi_result result;
|
dbi_result result;
|
||||||
/* Ignore the lock table */
|
/* Ignore the lock table */
|
||||||
if ( g_strcmp0(table_name, lock_table) == 0)
|
if ( g_strcmp0(table_name, lock_table) == 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
gnc_dbi_init_error( conn );
|
gnc_dbi_init_error( conn );
|
||||||
switch( op ) {
|
switch ( op )
|
||||||
case rollback:
|
{
|
||||||
if (g_slist_find(full_table_name_list, table_name))
|
case rollback:
|
||||||
{
|
if (g_slist_find(full_table_name_list, table_name))
|
||||||
result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
|
{
|
||||||
table_name );
|
result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
|
||||||
if ( result )
|
table_name );
|
||||||
break;
|
if ( result )
|
||||||
}
|
break;
|
||||||
/* Note fall-through */
|
}
|
||||||
case backup:
|
/* Note fall-through */
|
||||||
case drop_backup:
|
case backup:
|
||||||
result = conn_table_manage_backup( conn, table_name, op );
|
case drop_backup:
|
||||||
break;
|
result = conn_table_manage_backup( conn, table_name, op );
|
||||||
case empty:
|
break;
|
||||||
result = dbi_conn_queryf( conn->conn, "DELETE FROM TABLE %s",
|
case empty:
|
||||||
table_name );
|
result = dbi_conn_queryf( conn->conn, "DELETE FROM TABLE %s",
|
||||||
break;
|
table_name );
|
||||||
case drop:
|
break;
|
||||||
default:
|
case drop:
|
||||||
result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
|
default:
|
||||||
table_name );
|
result = dbi_conn_queryf( conn->conn, "DROP TABLE %s",
|
||||||
break;
|
table_name );
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
while ( conn->retry );
|
}
|
||||||
if ( result != NULL )
|
while ( conn->retry );
|
||||||
{
|
if ( result != NULL )
|
||||||
if ( dbi_result_free( result ) < 0 )
|
{
|
||||||
{
|
if ( dbi_result_free( result ) < 0 )
|
||||||
PERR( "Error in dbi_result_free() result\n" );
|
{
|
||||||
result = FALSE;
|
PERR( "Error in dbi_result_free() result\n" );
|
||||||
}
|
result = FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gnc_table_slist_free( full_table_name_list );
|
gnc_table_slist_free( full_table_name_list );
|
||||||
return result;
|
return result;
|
||||||
@ -1409,7 +1416,7 @@ gnc_dbi_sync_all( QofBackend* qbe, /*@ dependent @*/ QofBook *book )
|
|||||||
dbname = dbi_conn_get_option( be->conn, "dbname" );
|
dbname = dbi_conn_get_option( be->conn, "dbname" );
|
||||||
table_name_list = conn->provider->get_table_list( conn->conn, dbname );
|
table_name_list = conn->provider->get_table_list( conn->conn, dbname );
|
||||||
if ( !conn_table_operation( (GncSqlConnection*)conn, table_name_list,
|
if ( !conn_table_operation( (GncSqlConnection*)conn, table_name_list,
|
||||||
drop ) )
|
drop ) )
|
||||||
{
|
{
|
||||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||||
return;
|
return;
|
||||||
@ -1448,33 +1455,33 @@ gnc_dbi_safe_sync_all( QofBackend *qbe, QofBook *book )
|
|||||||
dbname = dbi_conn_get_option( be->conn, "dbname" );
|
dbname = dbi_conn_get_option( be->conn, "dbname" );
|
||||||
table_list = conn->provider->get_table_list( conn->conn, dbname );
|
table_list = conn->provider->get_table_list( conn->conn, dbname );
|
||||||
if ( !conn_table_operation( (GncSqlConnection*)conn, table_list,
|
if ( !conn_table_operation( (GncSqlConnection*)conn, table_list,
|
||||||
backup ) )
|
backup ) )
|
||||||
{
|
{
|
||||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||||
conn_table_operation( (GncSqlConnection*)conn, table_list,
|
conn_table_operation( (GncSqlConnection*)conn, table_list,
|
||||||
rollback );
|
rollback );
|
||||||
LEAVE( "Failed to rename tables" );
|
LEAVE( "Failed to rename tables" );
|
||||||
gnc_table_slist_free( table_list );
|
gnc_table_slist_free( table_list );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
index_list = conn->provider->get_index_list( conn->conn );
|
index_list = conn->provider->get_index_list( conn->conn );
|
||||||
for ( iter = index_list; iter != NULL; iter = g_slist_next( iter) )
|
for ( iter = index_list; iter != NULL; iter = g_slist_next( iter) )
|
||||||
{
|
{
|
||||||
const char *errmsg;
|
const char *errmsg;
|
||||||
dbi_result result =
|
dbi_result result =
|
||||||
dbi_conn_queryf( conn->conn, "DROP INDEX %s", iter->data );
|
dbi_conn_queryf( conn->conn, "DROP INDEX %s", iter->data );
|
||||||
if ( result )
|
if ( result )
|
||||||
dbi_result_free( result );
|
dbi_result_free( result );
|
||||||
if ( DBI_ERROR_NONE != dbi_conn_error( conn->conn, &errmsg ) )
|
if ( DBI_ERROR_NONE != dbi_conn_error( conn->conn, &errmsg ) )
|
||||||
{
|
{
|
||||||
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
|
||||||
gnc_table_slist_free( index_list );
|
gnc_table_slist_free( index_list );
|
||||||
conn_table_operation( (GncSqlConnection*)conn, table_list,
|
conn_table_operation( (GncSqlConnection*)conn, table_list,
|
||||||
rollback );
|
rollback );
|
||||||
gnc_table_slist_free( table_list );
|
gnc_table_slist_free( table_list );
|
||||||
LEAVE( "Failed to drop indexes %s", errmsg );
|
LEAVE( "Failed to drop indexes %s", errmsg );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gnc_table_slist_free( index_list );
|
gnc_table_slist_free( index_list );
|
||||||
|
|
||||||
@ -1484,13 +1491,13 @@ gnc_dbi_safe_sync_all( QofBackend *qbe, QofBook *book )
|
|||||||
gnc_sql_sync_all( &be->sql_be, book );
|
gnc_sql_sync_all( &be->sql_be, book );
|
||||||
if ( ERR_BACKEND_NO_ERR != qof_backend_get_error( qbe ) )
|
if ( ERR_BACKEND_NO_ERR != qof_backend_get_error( qbe ) )
|
||||||
{
|
{
|
||||||
conn_table_operation( (GncSqlConnection*)conn, table_list,
|
conn_table_operation( (GncSqlConnection*)conn, table_list,
|
||||||
rollback );
|
rollback );
|
||||||
LEAVE( "Failed to create new database tables" );
|
LEAVE( "Failed to create new database tables" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
conn_table_operation( (GncSqlConnection*)conn, table_list,
|
conn_table_operation( (GncSqlConnection*)conn, table_list,
|
||||||
drop_backup );
|
drop_backup );
|
||||||
gnc_table_slist_free( table_list );
|
gnc_table_slist_free( table_list );
|
||||||
LEAVE("book=%p", book);
|
LEAVE("book=%p", book);
|
||||||
}
|
}
|
||||||
@ -2860,58 +2867,58 @@ conn_test_dbi_library( dbi_conn conn )
|
|||||||
gboolean retval = TRUE;
|
gboolean retval = TRUE;
|
||||||
|
|
||||||
result = dbi_conn_query( conn, "CREATE TEMPORARY TABLE numtest "
|
result = dbi_conn_query( conn, "CREATE TEMPORARY TABLE numtest "
|
||||||
"( test_int BIGINT, test_unsigned BIGINT,"
|
"( test_int BIGINT, test_unsigned BIGINT,"
|
||||||
" test_double FLOAT8 )" );
|
" test_double FLOAT8 )" );
|
||||||
if ( result == NULL )
|
if ( result == NULL )
|
||||||
{
|
{
|
||||||
PWARN("Test_DBI_Library: Create table failed");
|
PWARN("Test_DBI_Library: Create table failed");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
dbi_result_free( result );
|
dbi_result_free( result );
|
||||||
result = dbi_conn_queryf( conn,
|
result = dbi_conn_queryf( conn,
|
||||||
"INSERT INTO numtest VALUES (%lld, %llu, %17e)",
|
"INSERT INTO numtest VALUES (%lld, %llu, %17e)",
|
||||||
testlonglong, testulonglong, testdouble );
|
testlonglong, testulonglong, testdouble );
|
||||||
if ( result == NULL )
|
if ( result == NULL )
|
||||||
{
|
{
|
||||||
PWARN("Test_DBI_Library: Failed to insert test row into table" );
|
PWARN("Test_DBI_Library: Failed to insert test row into table" );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
dbi_result_free( result );
|
dbi_result_free( result );
|
||||||
result = dbi_conn_query( conn, "SELECT * FROM numtest" );
|
result = dbi_conn_query( conn, "SELECT * FROM numtest" );
|
||||||
if ( result == NULL )
|
if ( result == NULL )
|
||||||
{
|
{
|
||||||
const char *errmsg;
|
const char *errmsg;
|
||||||
dbi_conn_error( conn, &errmsg );
|
dbi_conn_error( conn, &errmsg );
|
||||||
PWARN("Test_DBI_Library: Failed to retrieve test row into table: %s",
|
PWARN("Test_DBI_Library: Failed to retrieve test row into table: %s",
|
||||||
errmsg );
|
errmsg );
|
||||||
result = dbi_conn_query( conn, "DROP TABLE numtest" );
|
result = dbi_conn_query( conn, "DROP TABLE numtest" );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
while ( dbi_result_next_row( result ))
|
while ( dbi_result_next_row( result ))
|
||||||
{
|
{
|
||||||
resultlonglong = dbi_result_get_longlong( result, "test_int" );
|
resultlonglong = dbi_result_get_longlong( result, "test_int" );
|
||||||
resultulonglong = dbi_result_get_ulonglong( result, "test_unsigned" );
|
resultulonglong = dbi_result_get_ulonglong( result, "test_unsigned" );
|
||||||
resultdouble = dbi_result_get_double( result, "test_double" );
|
resultdouble = dbi_result_get_double( result, "test_double" );
|
||||||
}
|
}
|
||||||
if ( testlonglong != resultlonglong )
|
if ( testlonglong != resultlonglong )
|
||||||
{
|
{
|
||||||
PWARN( "Test_DBI_Library: LongLong Failed %" G_GINT64_FORMAT " != % " G_GINT64_FORMAT,
|
PWARN( "Test_DBI_Library: LongLong Failed %" G_GINT64_FORMAT " != % " G_GINT64_FORMAT,
|
||||||
testlonglong, resultlonglong );
|
testlonglong, resultlonglong );
|
||||||
retval = FALSE;
|
retval = FALSE;
|
||||||
}
|
}
|
||||||
if ( testulonglong != resultulonglong )
|
if ( testulonglong != resultulonglong )
|
||||||
{
|
{
|
||||||
PWARN( "Test_DBI_Library: Unsigned longlong Failed %" G_GUINT64_FORMAT " != %" G_GUINT64_FORMAT,
|
PWARN( "Test_DBI_Library: Unsigned longlong Failed %" G_GUINT64_FORMAT " != %" G_GUINT64_FORMAT,
|
||||||
testulonglong, resultulonglong );
|
testulonglong, resultulonglong );
|
||||||
retval = FALSE;
|
retval = FALSE;
|
||||||
}
|
}
|
||||||
/* A bug in libdbi stores only 7 digits of precision */
|
/* A bug in libdbi stores only 7 digits of precision */
|
||||||
if ( testdouble >= resultdouble + 0.000001e307 ||
|
if ( testdouble >= resultdouble + 0.000001e307 ||
|
||||||
testdouble <= resultdouble - 0.000001e307 )
|
testdouble <= resultdouble - 0.000001e307 )
|
||||||
{
|
{
|
||||||
PWARN( "Test_DBI_Library: Double Failed %17e != %17e",
|
PWARN( "Test_DBI_Library: Double Failed %17e != %17e",
|
||||||
testdouble, resultdouble );
|
testdouble, resultdouble );
|
||||||
retval = FALSE;
|
retval = FALSE;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -121,9 +121,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
session_1 = create_session();
|
session_1 = create_session();
|
||||||
test_dbi_store_and_reload( "mysql", session_1, TEST_MYSQL_URL );
|
test_dbi_store_and_reload( "mysql", session_1, TEST_MYSQL_URL );
|
||||||
session_1 = create_session();
|
session_1 = create_session();
|
||||||
test_dbi_safe_save( "mysql", filename );
|
test_dbi_safe_save( "mysql", filename );
|
||||||
test_dbi_version_control( "mysql", filename );
|
test_dbi_version_control( "mysql", filename );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef TEST_PGSQL_URL
|
#ifdef TEST_PGSQL_URL
|
||||||
@ -132,9 +132,9 @@ int main (int argc, char ** argv)
|
|||||||
{
|
{
|
||||||
session_1 = create_session();
|
session_1 = create_session();
|
||||||
test_dbi_store_and_reload( "pgsql", session_1, TEST_PGSQL_URL );
|
test_dbi_store_and_reload( "pgsql", session_1, TEST_PGSQL_URL );
|
||||||
session_1 = create_session();
|
session_1 = create_session();
|
||||||
test_dbi_safe_save( "pgsql", filename );
|
test_dbi_safe_save( "pgsql", filename );
|
||||||
test_dbi_version_control( "pgsql", filename );
|
test_dbi_version_control( "pgsql", filename );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
print_test_results();
|
print_test_results();
|
||||||
|
@ -141,8 +141,8 @@ test_conn_get_index_list( QofBackend *qbe )
|
|||||||
g_print ( "Returned from index list\n");
|
g_print ( "Returned from index list\n");
|
||||||
if ( index_list == NULL )
|
if ( index_list == NULL )
|
||||||
{
|
{
|
||||||
do_test( FALSE, "Index List Test -- No List" );
|
do_test( FALSE, "Index List Test -- No List" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
do_test( g_slist_length( index_list ) == 4, "Index List Test" );
|
do_test( g_slist_length( index_list ) == 4, "Index List Test" );
|
||||||
g_slist_free( index_list );
|
g_slist_free( index_list );
|
||||||
@ -177,16 +177,16 @@ test_dbi_store_and_reload( const gchar* driver, QofSession* session_1, const gch
|
|||||||
if (session_2 && qof_session_get_error(session_2) != ERR_BACKEND_NO_ERR)
|
if (session_2 && qof_session_get_error(session_2) != ERR_BACKEND_NO_ERR)
|
||||||
{
|
{
|
||||||
g_warning("Session Error: %d, %s", qof_session_get_error(session_2), qof_session_get_error_message(session_2));
|
g_warning("Session Error: %d, %s", qof_session_get_error(session_2), qof_session_get_error_message(session_2));
|
||||||
do_test( FALSE, "First DB Session Creation Failed");
|
do_test( FALSE, "First DB Session Creation Failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qof_session_swap_data( session_1, session_2 );
|
qof_session_swap_data( session_1, session_2 );
|
||||||
qof_session_save( session_2, NULL );
|
qof_session_save( session_2, NULL );
|
||||||
if (session_2 && qof_session_get_error(session_2) != ERR_BACKEND_NO_ERR)
|
if (session_2 && qof_session_get_error(session_2) != ERR_BACKEND_NO_ERR)
|
||||||
{
|
{
|
||||||
g_warning("Session Error: %s", qof_session_get_error_message(session_2));
|
g_warning("Session Error: %s", qof_session_get_error_message(session_2));
|
||||||
do_test( FALSE, "First DB Session Save Failed");
|
do_test( FALSE, "First DB Session Save Failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reload the session data
|
// Reload the session data
|
||||||
@ -195,15 +195,15 @@ test_dbi_store_and_reload( const gchar* driver, QofSession* session_1, const gch
|
|||||||
if (session_3 && qof_session_get_error(session_3) != ERR_BACKEND_NO_ERR)
|
if (session_3 && qof_session_get_error(session_3) != ERR_BACKEND_NO_ERR)
|
||||||
{
|
{
|
||||||
g_warning("Session Error: %s", qof_session_get_error_message(session_3));
|
g_warning("Session Error: %s", qof_session_get_error_message(session_3));
|
||||||
do_test( FALSE, "Second DB Session Creation Failed");
|
do_test( FALSE, "Second DB Session Creation Failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qof_session_load( session_3, NULL );
|
qof_session_load( session_3, NULL );
|
||||||
if (session_3 && qof_session_get_error(session_3) != ERR_BACKEND_NO_ERR)
|
if (session_3 && qof_session_get_error(session_3) != ERR_BACKEND_NO_ERR)
|
||||||
{
|
{
|
||||||
g_warning("Session Error: %s", qof_session_get_error_message(session_3));
|
g_warning("Session Error: %s", qof_session_get_error_message(session_3));
|
||||||
do_test( FALSE, "Second DBI Session Load Failed");
|
do_test( FALSE, "Second DBI Session Load Failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Compare with the original data
|
// Compare with the original data
|
||||||
compare_books( qof_session_get_book( session_2 ), qof_session_get_book( session_3 ) );
|
compare_books( qof_session_get_book( session_2 ), qof_session_get_book( session_3 ) );
|
||||||
@ -236,18 +236,18 @@ test_dbi_safe_save( const gchar* driver, const gchar* url )
|
|||||||
if (session_1 && qof_session_get_error(session_1) != ERR_BACKEND_NO_ERR)
|
if (session_1 && qof_session_get_error(session_1) != ERR_BACKEND_NO_ERR)
|
||||||
{
|
{
|
||||||
g_warning("Session Error: %d, %s", qof_session_get_error(session_1),
|
g_warning("Session Error: %d, %s", qof_session_get_error(session_1),
|
||||||
qof_session_get_error_message(session_1));
|
qof_session_get_error_message(session_1));
|
||||||
do_test( FALSE, "DB Session Creation Failed");
|
do_test( FALSE, "DB Session Creation Failed");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
qof_session_load( session_1, NULL );
|
qof_session_load( session_1, NULL );
|
||||||
/* Do a safe save */
|
/* Do a safe save */
|
||||||
qof_session_safe_save( session_1, NULL );
|
qof_session_safe_save( session_1, NULL );
|
||||||
if (session_1 && qof_session_get_error(session_1) != ERR_BACKEND_NO_ERR)
|
if (session_1 && qof_session_get_error(session_1) != ERR_BACKEND_NO_ERR)
|
||||||
{
|
{
|
||||||
g_warning("Session Error: %s", qof_session_get_error_message(session_1));
|
g_warning("Session Error: %s", qof_session_get_error_message(session_1));
|
||||||
do_test( FALSE, "DB Session Safe Save Failed");
|
do_test( FALSE, "DB Session Safe Save Failed");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
/* Destroy the session and reload it */
|
/* Destroy the session and reload it */
|
||||||
|
|
||||||
@ -256,13 +256,13 @@ test_dbi_safe_save( const gchar* driver, const gchar* url )
|
|||||||
if (session_2 && qof_session_get_error(session_2) != ERR_BACKEND_NO_ERR)
|
if (session_2 && qof_session_get_error(session_2) != ERR_BACKEND_NO_ERR)
|
||||||
{
|
{
|
||||||
g_warning("Session Error: %d, %s", qof_session_get_error(session_2),
|
g_warning("Session Error: %d, %s", qof_session_get_error(session_2),
|
||||||
qof_session_get_error_message(session_2));
|
qof_session_get_error_message(session_2));
|
||||||
do_test( FALSE, "DB Session re-creation Failed");
|
do_test( FALSE, "DB Session re-creation Failed");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
qof_session_load( session_2, NULL );
|
qof_session_load( session_2, NULL );
|
||||||
compare_books( qof_session_get_book( session_1 ),
|
compare_books( qof_session_get_book( session_1 ),
|
||||||
qof_session_get_book( session_2 ) );
|
qof_session_get_book( session_2 ) );
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
qof_session_end( session_2 );
|
qof_session_end( session_2 );
|
||||||
@ -294,16 +294,16 @@ test_dbi_version_control( const gchar* driver, const gchar* url )
|
|||||||
if (sess && qof_session_get_error(sess) != ERR_BACKEND_NO_ERR)
|
if (sess && qof_session_get_error(sess) != ERR_BACKEND_NO_ERR)
|
||||||
{
|
{
|
||||||
g_warning("Session Error: %d, %s", qof_session_get_error(sess),
|
g_warning("Session Error: %d, %s", qof_session_get_error(sess),
|
||||||
qof_session_get_error_message(sess));
|
qof_session_get_error_message(sess));
|
||||||
do_test( FALSE, "DB Session Creation Failed");
|
do_test( FALSE, "DB Session Creation Failed");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
qof_session_load( sess, NULL );
|
qof_session_load( sess, NULL );
|
||||||
qbe = qof_session_get_backend( sess );
|
qbe = qof_session_get_backend( sess );
|
||||||
book = qof_session_get_book( sess );
|
book = qof_session_get_book( sess );
|
||||||
qof_book_begin_edit( book );
|
qof_book_begin_edit( book );
|
||||||
gnc_sql_set_table_version( (GncSqlBackend*)qbe,
|
gnc_sql_set_table_version( (GncSqlBackend*)qbe,
|
||||||
"Gnucash", GNC_RESAVE_VERSION - 1 );
|
"Gnucash", GNC_RESAVE_VERSION - 1 );
|
||||||
qof_book_commit_edit( book );
|
qof_book_commit_edit( book );
|
||||||
qof_session_end( sess );
|
qof_session_end( sess );
|
||||||
qof_session_destroy( sess );
|
qof_session_destroy( sess );
|
||||||
@ -316,9 +316,9 @@ test_dbi_version_control( const gchar* driver, const gchar* url )
|
|||||||
book = qof_session_get_book( sess );
|
book = qof_session_get_book( sess );
|
||||||
qof_book_begin_edit( book );
|
qof_book_begin_edit( book );
|
||||||
gnc_sql_set_table_version( (GncSqlBackend*)qbe,
|
gnc_sql_set_table_version( (GncSqlBackend*)qbe,
|
||||||
"Gnucash", ourversion );
|
"Gnucash", ourversion );
|
||||||
gnc_sql_set_table_version( (GncSqlBackend*)qbe,
|
gnc_sql_set_table_version( (GncSqlBackend*)qbe,
|
||||||
"Gnucash-Resave", ourversion + 1 );
|
"Gnucash-Resave", ourversion + 1 );
|
||||||
qof_book_commit_edit( book );
|
qof_book_commit_edit( book );
|
||||||
qof_session_end( sess );
|
qof_session_end( sess );
|
||||||
qof_session_destroy( sess );
|
qof_session_destroy( sess );
|
||||||
|
@ -161,7 +161,7 @@ create_tables_cb( const gchar* type, gpointer data_p, gpointer be_p )
|
|||||||
|
|
||||||
if ( pData->create_tables != NULL )
|
if ( pData->create_tables != NULL )
|
||||||
{
|
{
|
||||||
update_progress( be );
|
update_progress( be );
|
||||||
(pData->create_tables)( be );
|
(pData->create_tables)( be );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,14 +194,14 @@ initial_load_cb( const gchar* type, gpointer data_p, gpointer be_p )
|
|||||||
// Don't need to load anything if it has already been loaded with the fixed order
|
// Don't need to load anything if it has already been loaded with the fixed order
|
||||||
for ( i = 0; fixed_load_order[i] != NULL; i++ )
|
for ( i = 0; fixed_load_order[i] != NULL; i++ )
|
||||||
{
|
{
|
||||||
update_progress( be );
|
update_progress( be );
|
||||||
if ( g_ascii_strcasecmp( type, fixed_load_order[i] ) == 0 ) return;
|
if ( g_ascii_strcasecmp( type, fixed_load_order[i] ) == 0 ) return;
|
||||||
}
|
}
|
||||||
if ( other_load_order != NULL )
|
if ( other_load_order != NULL )
|
||||||
{
|
{
|
||||||
for ( i = 0; other_load_order[i] != NULL; i++ )
|
for ( i = 0; other_load_order[i] != NULL; i++ )
|
||||||
{
|
{
|
||||||
update_progress( be );
|
update_progress( be );
|
||||||
if ( g_ascii_strcasecmp( type, other_load_order[i] ) == 0 ) return;
|
if ( g_ascii_strcasecmp( type, other_load_order[i] ) == 0 ) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoad
|
|||||||
pData = qof_object_lookup_backend( fixed_load_order[i], GNC_SQL_BACKEND );
|
pData = qof_object_lookup_backend( fixed_load_order[i], GNC_SQL_BACKEND );
|
||||||
if ( pData->initial_load != NULL )
|
if ( pData->initial_load != NULL )
|
||||||
{
|
{
|
||||||
update_progress( be );
|
update_progress( be );
|
||||||
(pData->initial_load)( be );
|
(pData->initial_load)( be );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,7 +248,7 @@ gnc_sql_load( GncSqlBackend* be, /*@ dependent @*/ QofBook *book, QofBackendLoad
|
|||||||
pData = qof_object_lookup_backend( other_load_order[i], GNC_SQL_BACKEND );
|
pData = qof_object_lookup_backend( other_load_order[i], GNC_SQL_BACKEND );
|
||||||
if ( pData->initial_load != NULL )
|
if ( pData->initial_load != NULL )
|
||||||
{
|
{
|
||||||
update_progress( be );
|
update_progress( be );
|
||||||
(pData->initial_load)( be );
|
(pData->initial_load)( be );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,7 +350,7 @@ write_account_tree( GncSqlBackend* be, Account* root )
|
|||||||
{
|
{
|
||||||
is_ok = gnc_sql_save_account( be, QOF_INSTANCE(GNC_ACCOUNT(node->data)) );
|
is_ok = gnc_sql_save_account( be, QOF_INSTANCE(GNC_ACCOUNT(node->data)) );
|
||||||
if ( !is_ok ) break;
|
if ( !is_ok ) break;
|
||||||
}
|
}
|
||||||
g_list_free( descendants );
|
g_list_free( descendants );
|
||||||
}
|
}
|
||||||
update_progress( be );
|
update_progress( be );
|
||||||
@ -369,7 +369,7 @@ write_accounts( GncSqlBackend* be )
|
|||||||
is_ok = write_account_tree( be, gnc_book_get_root_account( be->primary_book ) );
|
is_ok = write_account_tree( be, gnc_book_get_root_account( be->primary_book ) );
|
||||||
if ( is_ok )
|
if ( is_ok )
|
||||||
{
|
{
|
||||||
update_progress( be );
|
update_progress( be );
|
||||||
is_ok = write_account_tree( be, gnc_book_get_template_root( be->primary_book ) );
|
is_ok = write_account_tree( be, gnc_book_get_template_root( be->primary_book ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ write_transactions( GncSqlBackend* be )
|
|||||||
data.be = be;
|
data.be = be;
|
||||||
data.is_ok = TRUE;
|
data.is_ok = TRUE;
|
||||||
(void)xaccAccountTreeForEachTransaction(
|
(void)xaccAccountTreeForEachTransaction(
|
||||||
gnc_book_get_root_account( be->primary_book ), write_tx, &data );
|
gnc_book_get_root_account( be->primary_book ), write_tx, &data );
|
||||||
update_progress( be );
|
update_progress( be );
|
||||||
return data.is_ok;
|
return data.is_ok;
|
||||||
}
|
}
|
||||||
@ -426,7 +426,7 @@ write_template_transactions( GncSqlBackend* be )
|
|||||||
if ( gnc_account_n_descendants( ra ) > 0 )
|
if ( gnc_account_n_descendants( ra ) > 0 )
|
||||||
{
|
{
|
||||||
(void)xaccAccountTreeForEachTransaction( ra, write_tx, &data );
|
(void)xaccAccountTreeForEachTransaction( ra, write_tx, &data );
|
||||||
update_progress( be );
|
update_progress( be );
|
||||||
}
|
}
|
||||||
|
|
||||||
return data.is_ok;
|
return data.is_ok;
|
||||||
@ -465,7 +465,7 @@ write_cb( const gchar* type, gpointer data_p, gpointer be_p )
|
|||||||
if ( pData->write != NULL )
|
if ( pData->write != NULL )
|
||||||
{
|
{
|
||||||
(void)(pData->write)( be );
|
(void)(pData->write)( be );
|
||||||
update_progress( be );
|
update_progress( be );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,7 +549,7 @@ gnc_sql_sync_all( GncSqlBackend* be, /*@ dependent @*/ QofBook *book )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_SERVER_ERR );
|
qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_SERVER_ERR );
|
||||||
is_ok = gnc_sql_connection_rollback_transaction( be->conn );
|
is_ok = gnc_sql_connection_rollback_transaction( be->conn );
|
||||||
}
|
}
|
||||||
finish_progress( be );
|
finish_progress( be );
|
||||||
@ -616,9 +616,9 @@ gnc_sql_commit_edit( GncSqlBackend *be, QofInstance *inst )
|
|||||||
|
|
||||||
if ( qof_book_is_readonly( be->primary_book ) )
|
if ( qof_book_is_readonly( be->primary_book ) )
|
||||||
{
|
{
|
||||||
qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_READONLY );
|
qof_backend_set_error( (QofBackend*)be, ERR_BACKEND_READONLY );
|
||||||
(void)gnc_sql_connection_rollback_transaction( be->conn );
|
(void)gnc_sql_connection_rollback_transaction( be->conn );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* During initial load where objects are being created, don't commit
|
/* During initial load where objects are being created, don't commit
|
||||||
anything, but do mark the object as clean. */
|
anything, but do mark the object as clean. */
|
||||||
@ -665,7 +665,7 @@ gnc_sql_commit_edit( GncSqlBackend *be, QofInstance *inst )
|
|||||||
be_data.is_ok = TRUE;
|
be_data.is_ok = TRUE;
|
||||||
/* Set/update the application version in the database */
|
/* Set/update the application version in the database */
|
||||||
if ( gnc_sql_get_table_version( be, "Gnucash") != gnc_version )
|
if ( gnc_sql_get_table_version( be, "Gnucash") != gnc_version )
|
||||||
gnc_sql_set_table_version( be, "Gnucash", gnc_version );
|
gnc_sql_set_table_version( be, "Gnucash", gnc_version );
|
||||||
|
|
||||||
qof_object_foreach_backend( GNC_SQL_BACKEND, commit_cb, &be_data );
|
qof_object_foreach_backend( GNC_SQL_BACKEND, commit_cb, &be_data );
|
||||||
|
|
||||||
|
@ -705,7 +705,7 @@ gnc_plugin_page_invoice_cmd_edit (GtkAction *action,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gnc_plugin_page_invoice_cmd_duplicateInvoice (GtkAction *action,
|
gnc_plugin_page_invoice_cmd_duplicateInvoice (GtkAction *action,
|
||||||
GncPluginPageInvoice *plugin_page)
|
GncPluginPageInvoice *plugin_page)
|
||||||
{
|
{
|
||||||
GncPluginPageInvoicePrivate *priv;
|
GncPluginPageInvoicePrivate *priv;
|
||||||
|
|
||||||
@ -828,7 +828,7 @@ gnc_plugin_page_invoice_cmd_blank (GtkAction *action,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gnc_plugin_page_invoice_cmd_duplicateEntry (GtkAction *action,
|
gnc_plugin_page_invoice_cmd_duplicateEntry (GtkAction *action,
|
||||||
GncPluginPageInvoice *plugin_page)
|
GncPluginPageInvoice *plugin_page)
|
||||||
{
|
{
|
||||||
GncPluginPageInvoicePrivate *priv;
|
GncPluginPageInvoicePrivate *priv;
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ static QofQuery *new_query_for_entry_desc(GncEntryLedger *reg, const char* desc,
|
|||||||
/* For invoice entries, Entry->Bill must be NULL, and vice versa */
|
/* For invoice entries, Entry->Bill must be NULL, and vice versa */
|
||||||
qof_query_add_guid_match (query,
|
qof_query_add_guid_match (query,
|
||||||
qof_query_build_param_list (should_be_null,
|
qof_query_build_param_list (should_be_null,
|
||||||
QOF_PARAM_GUID, NULL),
|
QOF_PARAM_GUID, NULL),
|
||||||
NULL, QOF_QUERY_AND);
|
NULL, QOF_QUERY_AND);
|
||||||
|
|
||||||
/* Set the sort order: By DATE_ENTERED, increasing, and returning
|
/* Set the sort order: By DATE_ENTERED, increasing, and returning
|
||||||
@ -494,9 +494,9 @@ gnc_entry_ledger_auto_completion (GncEntryLedger *ledger,
|
|||||||
auto_entry =
|
auto_entry =
|
||||||
/* Use this for book-wide auto-completion of the invoice entries */
|
/* Use this for book-wide auto-completion of the invoice entries */
|
||||||
find_entry_in_book_by_desc(ledger, desc);
|
find_entry_in_book_by_desc(ledger, desc);
|
||||||
/* #else */
|
/* #else */
|
||||||
/* gnc_find_entry_in_reg_by_desc(ledger, desc); */
|
/* gnc_find_entry_in_reg_by_desc(ledger, desc); */
|
||||||
/* #endif */
|
/* #endif */
|
||||||
|
|
||||||
if (auto_entry == NULL)
|
if (auto_entry == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1805,9 +1805,9 @@ xaccTransSetIsClosingTxn (Transaction *trans, gboolean is_closing)
|
|||||||
xaccTransBeginEdit(trans);
|
xaccTransBeginEdit(trans);
|
||||||
|
|
||||||
if (is_closing)
|
if (is_closing)
|
||||||
kvp_frame_set_gint64 (trans->inst.kvp_data, trans_is_closing_str, 1);
|
kvp_frame_set_gint64 (trans->inst.kvp_data, trans_is_closing_str, 1);
|
||||||
else
|
else
|
||||||
kvp_frame_replace_value_nc (trans->inst.kvp_data, trans_is_closing_str, NULL);
|
kvp_frame_replace_value_nc (trans->inst.kvp_data, trans_is_closing_str, NULL);
|
||||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||||
xaccTransCommitEdit(trans);
|
xaccTransCommitEdit(trans);
|
||||||
}
|
}
|
||||||
@ -1873,8 +1873,8 @@ gboolean
|
|||||||
xaccTransGetIsClosingTxn (const Transaction *trans)
|
xaccTransGetIsClosingTxn (const Transaction *trans)
|
||||||
{
|
{
|
||||||
return trans ?
|
return trans ?
|
||||||
kvp_frame_get_gint64 (trans->inst.kvp_data, trans_is_closing_str)
|
kvp_frame_get_gint64 (trans->inst.kvp_data, trans_is_closing_str)
|
||||||
: FALSE;
|
: FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
|
@ -326,7 +326,7 @@ clone_budget_values_cb(Account* a, gpointer user_data)
|
|||||||
if ( gnc_budget_is_account_period_value_set(data->old_b, a, i) )
|
if ( gnc_budget_is_account_period_value_set(data->old_b, a, i) )
|
||||||
{
|
{
|
||||||
gnc_budget_set_account_period_value(data->new_b, a, i,
|
gnc_budget_set_account_period_value(data->new_b, a, i,
|
||||||
gnc_budget_get_account_period_value(data->old_b, a, i));
|
gnc_budget_get_account_period_value(data->old_b, a, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1356,8 +1356,8 @@ gnc_commodity_set_quote_tz(gnc_commodity *cm, const char *tz)
|
|||||||
|
|
||||||
if (tz == priv->quote_tz)
|
if (tz == priv->quote_tz)
|
||||||
{
|
{
|
||||||
LEAVE("Already correct TZ");
|
LEAVE("Already correct TZ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gnc_commodity_begin_edit(cm);
|
gnc_commodity_begin_edit(cm);
|
||||||
|
@ -104,7 +104,7 @@ find_or_create_txn(struct CloseAccountsCB* cacb, gnc_commodity* cmdty)
|
|||||||
xaccTransSetDatePostedSecs(txn->txn, cacb->cbw->close_date);
|
xaccTransSetDatePostedSecs(txn->txn, cacb->cbw->close_date);
|
||||||
xaccTransSetDescription(txn->txn, cacb->cbw->desc);
|
xaccTransSetDescription(txn->txn, cacb->cbw->desc);
|
||||||
xaccTransSetCurrency(txn->txn, cmdty);
|
xaccTransSetCurrency(txn->txn, cmdty);
|
||||||
xaccTransSetIsClosingTxn(txn->txn, TRUE);
|
xaccTransSetIsClosingTxn(txn->txn, TRUE);
|
||||||
g_hash_table_insert(cacb->txns, cmdty, txn);
|
g_hash_table_insert(cacb->txns, cmdty, txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@ listen_for_gncentry_events(QofInstance *entity, QofEventId event_type,
|
|||||||
if (0 == (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_DESTROY)))
|
if (0 == (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_DESTROY)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* g_warning("entity %p, entity type %s, event type %s, user data %p, ecent data %p", */
|
/* g_warning("entity %p, entity type %s, event type %s, user data %p, ecent data %p", */
|
||||||
/* entity, entity->e_type, qofeventid_to_string(event_type), user_data, event_data); */
|
/* entity, entity->e_type, qofeventid_to_string(event_type), user_data, event_data); */
|
||||||
|
|
||||||
desc = gncEntryGetDescription(GNC_ENTRY(entity));
|
desc = gncEntryGetDescription(GNC_ENTRY(entity));
|
||||||
if (event_type & QOF_EVENT_MODIFY)
|
if (event_type & QOF_EVENT_MODIFY)
|
||||||
@ -124,7 +124,7 @@ static EntryQF* build_shared_quickfill (QofBook *book, const char * key, gboolea
|
|||||||
QofQuery *query = new_query_for_entrys(book);
|
QofQuery *query = new_query_for_entrys(book);
|
||||||
GList *entries = qof_query_run(query);
|
GList *entries = qof_query_run(query);
|
||||||
|
|
||||||
/* g_warning("Found %d GncEntry items", g_list_length (entries)); */
|
/* g_warning("Found %d GncEntry items", g_list_length (entries)); */
|
||||||
|
|
||||||
result = g_new0(EntryQF, 1);
|
result = g_new0(EntryQF, 1);
|
||||||
|
|
||||||
|
@ -412,18 +412,18 @@ show_session_error (QofBackendError io_error,
|
|||||||
case ERR_SQL_DB_TOO_OLD:
|
case ERR_SQL_DB_TOO_OLD:
|
||||||
fmt = _("This database is from an older version of GnuCash. "
|
fmt = _("This database is from an older version of GnuCash. "
|
||||||
"Select OK to upgrade it to the current version, Cancel "
|
"Select OK to upgrade it to the current version, Cancel "
|
||||||
"to mark it read-only.");
|
"to mark it read-only.");
|
||||||
|
|
||||||
response = gnc_ok_cancel_dialog(parent, GTK_RESPONSE_CANCEL, "%s", fmt);
|
response = gnc_ok_cancel_dialog(parent, GTK_RESPONSE_CANCEL, "%s", fmt);
|
||||||
uh_oh = (response == GTK_RESPONSE_CANCEL);
|
uh_oh = (response == GTK_RESPONSE_CANCEL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ERR_SQL_DB_TOO_NEW:
|
case ERR_SQL_DB_TOO_NEW:
|
||||||
fmt = _("This database is from a newer version of GnuCash. "
|
fmt = _("This database is from a newer version of GnuCash. "
|
||||||
"This version can read it, but cannot safely save to it. "
|
"This version can read it, but cannot safely save to it. "
|
||||||
"It will be marked read-only until you do File>Save As.");
|
"It will be marked read-only until you do File>Save As.");
|
||||||
gnc_warning_dialog (parent, "%s", fmt);
|
gnc_warning_dialog (parent, "%s", fmt);
|
||||||
uh_oh = TRUE;
|
uh_oh = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ERR_SQL_DB_BUSY:
|
case ERR_SQL_DB_BUSY:
|
||||||
@ -437,15 +437,15 @@ show_session_error (QofBackendError io_error,
|
|||||||
|
|
||||||
case ERR_SQL_BAD_DBI:
|
case ERR_SQL_BAD_DBI:
|
||||||
|
|
||||||
fmt = _("The library \"libdbi\" installed on your system doesn't correctly "
|
fmt = _("The library \"libdbi\" installed on your system doesn't correctly "
|
||||||
"store large numbers. This means GnuCash cannot use SQL databases "
|
"store large numbers. This means GnuCash cannot use SQL databases "
|
||||||
"correctly. Gnucash will not open or save to SQL databases until this is "
|
"correctly. Gnucash will not open or save to SQL databases until this is "
|
||||||
"fixed by installing a different version of \"libdbi\". Please see "
|
"fixed by installing a different version of \"libdbi\". Please see "
|
||||||
"https://bugzilla.gnome.org/show_bug.cgi?id=611936 for more "
|
"https://bugzilla.gnome.org/show_bug.cgi?id=611936 for more "
|
||||||
"information.");
|
"information.");
|
||||||
|
|
||||||
gnc_error_dialog (parent, "%s", fmt);
|
gnc_error_dialog (parent, "%s", fmt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
PERR("FIXME: Unhandled error %d", io_error);
|
PERR("FIXME: Unhandled error %d", io_error);
|
||||||
@ -766,8 +766,8 @@ gnc_post_file_open (const char * filename)
|
|||||||
* don't bother with the message, just die. */
|
* don't bother with the message, just die. */
|
||||||
io_err = qof_session_get_error (new_session);
|
io_err = qof_session_get_error (new_session);
|
||||||
if ((ERR_BACKEND_LOCKED == io_err) ||
|
if ((ERR_BACKEND_LOCKED == io_err) ||
|
||||||
(ERR_BACKEND_READONLY == io_err) ||
|
(ERR_BACKEND_READONLY == io_err) ||
|
||||||
(ERR_BACKEND_NO_SUCH_DB == io_err))
|
(ERR_BACKEND_NO_SUCH_DB == io_err))
|
||||||
{
|
{
|
||||||
uh_oh = TRUE;
|
uh_oh = TRUE;
|
||||||
}
|
}
|
||||||
@ -815,24 +815,24 @@ gnc_post_file_open (const char * filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uh_oh = show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN);
|
uh_oh = show_session_error (io_err, newfile, GNC_FILE_DIALOG_OPEN);
|
||||||
/* Attempt to update the database if it's too old */
|
/* Attempt to update the database if it's too old */
|
||||||
if ( !uh_oh && io_err == ERR_SQL_DB_TOO_OLD )
|
if ( !uh_oh && io_err == ERR_SQL_DB_TOO_OLD )
|
||||||
{
|
{
|
||||||
gnc_window_show_progress(_("Re-saving user data..."), 0.0);
|
gnc_window_show_progress(_("Re-saving user data..."), 0.0);
|
||||||
qof_session_safe_save(new_session, gnc_window_show_progress);
|
qof_session_safe_save(new_session, gnc_window_show_progress);
|
||||||
io_err = qof_session_get_error(new_session);
|
io_err = qof_session_get_error(new_session);
|
||||||
uh_oh = show_session_error(io_err, newfile, GNC_FILE_DIALOG_SAVE);
|
uh_oh = show_session_error(io_err, newfile, GNC_FILE_DIALOG_SAVE);
|
||||||
}
|
}
|
||||||
/* Database is either too old and couldn't (or user didn't
|
/* Database is either too old and couldn't (or user didn't
|
||||||
* want it to) be updated or it's too new. Mark it as
|
* want it to) be updated or it's too new. Mark it as
|
||||||
* read-only
|
* read-only
|
||||||
*/
|
*/
|
||||||
if (uh_oh && (io_err == ERR_SQL_DB_TOO_OLD ||
|
if (uh_oh && (io_err == ERR_SQL_DB_TOO_OLD ||
|
||||||
io_err == ERR_SQL_DB_TOO_NEW))
|
io_err == ERR_SQL_DB_TOO_NEW))
|
||||||
{
|
{
|
||||||
qof_book_mark_readonly(qof_session_get_book(new_session));
|
qof_book_mark_readonly(qof_session_get_book(new_session));
|
||||||
uh_oh = FALSE;
|
uh_oh = FALSE;
|
||||||
}
|
}
|
||||||
new_root = gnc_book_get_root_account (qof_session_get_book (new_session));
|
new_root = gnc_book_get_root_account (qof_session_get_book (new_session));
|
||||||
if (uh_oh) new_root = NULL;
|
if (uh_oh) new_root = NULL;
|
||||||
|
|
||||||
|
@ -2353,13 +2353,13 @@ gnc_main_window_engine_commit_error_callback( gpointer data,
|
|||||||
GtkWidget* dialog;
|
GtkWidget* dialog;
|
||||||
gchar *reason = ".";
|
gchar *reason = ".";
|
||||||
if ( errcode == ERR_BACKEND_READONLY )
|
if ( errcode == ERR_BACKEND_READONLY )
|
||||||
reason = _(": Book is marked read-only.");
|
reason = _(": Book is marked read-only.");
|
||||||
dialog = gtk_message_dialog_new( GTK_WINDOW(window),
|
dialog = gtk_message_dialog_new( GTK_WINDOW(window),
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
GTK_MESSAGE_ERROR,
|
GTK_MESSAGE_ERROR,
|
||||||
GTK_BUTTONS_CLOSE,
|
GTK_BUTTONS_CLOSE,
|
||||||
_("Unable to save to database%s"),
|
_("Unable to save to database%s"),
|
||||||
reason );
|
reason );
|
||||||
gtk_dialog_run(GTK_DIALOG (dialog));
|
gtk_dialog_run(GTK_DIALOG (dialog));
|
||||||
gtk_widget_destroy(dialog);
|
gtk_widget_destroy(dialog);
|
||||||
|
|
||||||
|
@ -128,8 +128,8 @@ gnc_ab_getbalance(GtkWidget *parent, Account *gnc_acc)
|
|||||||
{
|
{
|
||||||
g_warning("gnc_ab_getbalance: Error on executing job");
|
g_warning("gnc_ab_getbalance: Error on executing job");
|
||||||
gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
|
gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
|
||||||
, AB_Job_Status2Char(job_status)
|
, AB_Job_Status2Char(job_status)
|
||||||
, AB_Job_GetResultText(job));
|
, AB_Job_GetResultText(job));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,8 +193,8 @@ gnc_ab_gettrans(GtkWidget *parent, Account *gnc_acc)
|
|||||||
{
|
{
|
||||||
g_warning("gnc_ab_gettrans: Error on executing job");
|
g_warning("gnc_ab_gettrans: Error on executing job");
|
||||||
gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
|
gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
|
||||||
, AB_Job_Status2Char(job_status)
|
, AB_Job_Status2Char(job_status)
|
||||||
, AB_Job_GetResultText(job));
|
, AB_Job_GetResultText(job));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,11 +435,11 @@ gnc_ab_memo_to_gnc(const AB_TRANSACTION *ab_trans)
|
|||||||
{
|
{
|
||||||
retval = g_strdup_printf("%s %s %s %s",
|
retval = g_strdup_printf("%s %s %s %s",
|
||||||
have_accountid ? _("Account") : "",
|
have_accountid ? _("Account") : "",
|
||||||
have_accountid ? ab_other_accountid : "",
|
have_accountid ? ab_other_accountid : "",
|
||||||
have_bankcode ? _("Bank") : "",
|
have_bankcode ? _("Bank") : "",
|
||||||
have_bankcode ? ab_other_bankcode : ""
|
have_bankcode ? ab_other_bankcode : ""
|
||||||
);
|
);
|
||||||
g_strstrip(retval);
|
g_strstrip(retval);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -325,15 +325,15 @@ gnc_plugin_ab_account_selected(GncPluginPage *plugin_page, Account *account,
|
|||||||
|
|
||||||
gnc_plugin_update_actions(action_group, need_account_actions,
|
gnc_plugin_update_actions(action_group, need_account_actions,
|
||||||
"sensitive",
|
"sensitive",
|
||||||
(account && bankcode && *bankcode
|
(account && bankcode && *bankcode
|
||||||
&& accountid && *accountid));
|
&& accountid && *accountid));
|
||||||
gnc_plugin_update_actions(action_group, need_account_actions,
|
gnc_plugin_update_actions(action_group, need_account_actions,
|
||||||
"visible",TRUE);
|
"visible", TRUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gnc_plugin_update_actions(action_group, need_account_actions,
|
gnc_plugin_update_actions(action_group, need_account_actions,
|
||||||
"sensitive",FALSE);
|
"sensitive", FALSE);
|
||||||
gnc_plugin_update_actions(action_group, need_account_actions,
|
gnc_plugin_update_actions(action_group, need_account_actions,
|
||||||
"visible", FALSE);
|
"visible", FALSE);
|
||||||
}
|
}
|
||||||
|
@ -946,8 +946,8 @@ gnc_import_process_trans_item (GncImportMatchMap *matchmap,
|
|||||||
xaccTransBeginEdit(selected_match->trans);
|
xaccTransBeginEdit(selected_match->trans);
|
||||||
|
|
||||||
xaccTransSetDatePostedSecs(selected_match->trans,
|
xaccTransSetDatePostedSecs(selected_match->trans,
|
||||||
xaccTransGetDate(xaccSplitGetParent(
|
xaccTransGetDate(xaccSplitGetParent(
|
||||||
gnc_import_TransInfo_get_fsplit(trans_info))));
|
gnc_import_TransInfo_get_fsplit(trans_info))));
|
||||||
|
|
||||||
xaccSplitSetAmount(selected_match->split,
|
xaccSplitSetAmount(selected_match->split,
|
||||||
xaccSplitGetAmount(
|
xaccSplitGetAmount(
|
||||||
@ -988,7 +988,7 @@ gnc_import_process_trans_item (GncImportMatchMap *matchmap,
|
|||||||
if (gnc_import_split_has_online_id(trans_info->first_split))
|
if (gnc_import_split_has_online_id(trans_info->first_split))
|
||||||
{
|
{
|
||||||
gnc_import_set_split_online_id(selected_match->split,
|
gnc_import_set_split_online_id(selected_match->split,
|
||||||
gnc_import_get_split_online_id(trans_info->first_split));
|
gnc_import_get_split_online_id(trans_info->first_split));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Done editing. */
|
/* Done editing. */
|
||||||
@ -1231,8 +1231,8 @@ gnc_import_TransInfo_init_matches (GNCImportTransInfo *trans_info,
|
|||||||
trans_info->action = GNCImport_ADD;
|
trans_info->action = GNCImport_ADD;
|
||||||
}
|
}
|
||||||
if (best_match &&
|
if (best_match &&
|
||||||
trans_info->action == GNCImport_CLEAR &&
|
trans_info->action == GNCImport_CLEAR &&
|
||||||
gnc_import_Settings_get_action_update_enabled(settings))
|
gnc_import_Settings_get_action_update_enabled(settings))
|
||||||
{
|
{
|
||||||
if (best_match->update_proposed)
|
if (best_match->update_proposed)
|
||||||
{
|
{
|
||||||
|
@ -331,8 +331,8 @@ gnc_gen_trans_clear_toggled_cb (GtkCellRendererToggle *cell_renderer,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gnc_gen_trans_update_toggled_cb (GtkCellRendererToggle *cell_renderer,
|
gnc_gen_trans_update_toggled_cb (GtkCellRendererToggle *cell_renderer,
|
||||||
gchar *path,
|
gchar *path,
|
||||||
GNCImportMainMatcher *gui)
|
GNCImportMainMatcher *gui)
|
||||||
{
|
{
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
@ -3239,18 +3239,21 @@ get_preferences(QIFImportWindow *wind)
|
|||||||
|
|
||||||
/* Clear / Reconcile transaction if not specified in QIF file. */
|
/* Clear / Reconcile transaction if not specified in QIF file. */
|
||||||
status_pref = gnc_gconf_get_string(
|
status_pref = gnc_gconf_get_string(
|
||||||
GCONF_SECTION, GCONF_NAME_DEFAULT_TRANSACTION_STATUS, &err);
|
GCONF_SECTION, GCONF_NAME_DEFAULT_TRANSACTION_STATUS, &err);
|
||||||
if (err != NULL)
|
if (err != NULL)
|
||||||
{
|
{
|
||||||
g_warning("QIF import: gnc_gconf_get_string error: %s", err->message);
|
g_warning("QIF import: gnc_gconf_get_string error: %s", err->message);
|
||||||
g_error_free(err);
|
g_error_free(err);
|
||||||
g_warning("QIF import: Couldn't get %s setting from gconf.",
|
g_warning("QIF import: Couldn't get %s setting from gconf.",
|
||||||
GCONF_NAME_DEFAULT_TRANSACTION_STATUS);
|
GCONF_NAME_DEFAULT_TRANSACTION_STATUS);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (g_strcmp0(status_pref, "cleared") == 0)
|
if (g_strcmp0(status_pref, "cleared") == 0)
|
||||||
{
|
{
|
||||||
tmp_transaction_status = 'c';
|
tmp_transaction_status = 'c';
|
||||||
} else if (g_strcmp0(status_pref, "reconciled") == 0)
|
}
|
||||||
|
else if (g_strcmp0(status_pref, "reconciled") == 0)
|
||||||
{
|
{
|
||||||
tmp_transaction_status = 'y';
|
tmp_transaction_status = 'y';
|
||||||
}
|
}
|
||||||
|
@ -373,7 +373,7 @@ Globals: dateCompletion dateCompletionBackMonths
|
|||||||
void qof_date_completion_set(QofDateCompletion dc, int backmonths)
|
void qof_date_completion_set(QofDateCompletion dc, int backmonths)
|
||||||
{
|
{
|
||||||
if (dc == QOF_DATE_COMPLETION_THISYEAR ||
|
if (dc == QOF_DATE_COMPLETION_THISYEAR ||
|
||||||
dc == QOF_DATE_COMPLETION_SLIDING)
|
dc == QOF_DATE_COMPLETION_SLIDING)
|
||||||
{
|
{
|
||||||
dateCompletion = dc;
|
dateCompletion = dc;
|
||||||
}
|
}
|
||||||
@ -655,7 +655,7 @@ floordiv(int a, int b)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return - ((-a-1) / b) - 1;
|
return - ((-a - 1) / b) - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,7 +470,7 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name)
|
|||||||
|
|
||||||
/* Check if an error occured */
|
/* Check if an error occured */
|
||||||
if (counter < 0)
|
if (counter < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Increment the counter */
|
/* Increment the counter */
|
||||||
counter++;
|
counter++;
|
||||||
@ -480,8 +480,8 @@ qof_book_increment_and_format_counter (QofBook *book, const char *counter_name)
|
|||||||
|
|
||||||
if (!kvp)
|
if (!kvp)
|
||||||
{
|
{
|
||||||
PWARN ("Book has no KVP_Frame");
|
PWARN ("Book has no KVP_Frame");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save off the new counter */
|
/* Save off the new counter */
|
||||||
@ -576,10 +576,10 @@ qof_book_validate_counter_format(const gchar *p)
|
|||||||
/* Skip two adjacent percent marks, which are literal percent
|
/* Skip two adjacent percent marks, which are literal percent
|
||||||
* marks */
|
* marks */
|
||||||
if (p[0] == '%' && p[1] == '%')
|
if (p[0] == '%' && p[1] == '%')
|
||||||
{
|
{
|
||||||
p += 2;
|
p += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Break on a single percent mark, which is the start of the
|
/* Break on a single percent mark, which is the start of the
|
||||||
* conversion specification */
|
* conversion specification */
|
||||||
if (*p == '%')
|
if (*p == '%')
|
||||||
@ -621,7 +621,9 @@ qof_book_validate_counter_format(const gchar *p)
|
|||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
{
|
{
|
||||||
return g_strdup_printf("Invalid length modifier and/or conversion specifier ('%.2s'), it should be: " G_GINT64_FORMAT, p);
|
return g_strdup_printf("Invalid length modifier and/or conversion specifier ('%.2s'), it should be: " G_GINT64_FORMAT, p);
|
||||||
} else if (tmp != p) {
|
}
|
||||||
|
else if (tmp != p)
|
||||||
|
{
|
||||||
return g_strdup_printf("Garbage before length modifier and/or conversion specifier: '%*s'", (int)(tmp - p), p);
|
return g_strdup_printf("Garbage before length modifier and/or conversion specifier: '%*s'", (int)(tmp - p), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,10 +636,10 @@ qof_book_validate_counter_format(const gchar *p)
|
|||||||
/* Skip two adjacent percent marks, which are literal percent
|
/* Skip two adjacent percent marks, which are literal percent
|
||||||
* marks */
|
* marks */
|
||||||
if (p[0] == '%' && p[1] == '%')
|
if (p[0] == '%' && p[1] == '%')
|
||||||
{
|
{
|
||||||
p += 2;
|
p += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Break on a single percent mark, which is the start of the
|
/* Break on a single percent mark, which is the start of the
|
||||||
* conversion specification */
|
* conversion specification */
|
||||||
if (*p == '%')
|
if (*p == '%')
|
||||||
|
@ -1250,10 +1250,10 @@ qof_session_load (QofSession *session,
|
|||||||
*/
|
*/
|
||||||
err = qof_session_get_error(session);
|
err = qof_session_get_error(session);
|
||||||
if ((err != ERR_BACKEND_NO_ERR) &&
|
if ((err != ERR_BACKEND_NO_ERR) &&
|
||||||
(err != ERR_FILEIO_FILE_TOO_OLD) &&
|
(err != ERR_FILEIO_FILE_TOO_OLD) &&
|
||||||
(err != ERR_FILEIO_NO_ENCODING) &&
|
(err != ERR_FILEIO_NO_ENCODING) &&
|
||||||
(err != ERR_SQL_DB_TOO_OLD) &&
|
(err != ERR_SQL_DB_TOO_OLD) &&
|
||||||
(err != ERR_SQL_DB_TOO_NEW))
|
(err != ERR_SQL_DB_TOO_NEW))
|
||||||
{
|
{
|
||||||
/* Something broke, put back the old stuff */
|
/* Something broke, put back the old stuff */
|
||||||
qof_book_set_backend (newbook, NULL);
|
qof_book_set_backend (newbook, NULL);
|
||||||
@ -1464,9 +1464,9 @@ qof_session_safe_save(QofSession *session, QofPercentageFunc percentage_func)
|
|||||||
msg = qof_backend_get_message(session->backend);
|
msg = qof_backend_get_message(session->backend);
|
||||||
if (err != ERR_BACKEND_NO_ERR)
|
if (err != ERR_BACKEND_NO_ERR)
|
||||||
{
|
{
|
||||||
g_free(session->book_id);
|
g_free(session->book_id);
|
||||||
session->book_id = NULL;
|
session->book_id = NULL;
|
||||||
qof_session_push_error (session, err, msg);
|
qof_session_push_error (session, err, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ void qof_session_save (QofSession *session,
|
|||||||
* the new tables back.
|
* the new tables back.
|
||||||
*/
|
*/
|
||||||
void qof_session_safe_save (QofSession *session,
|
void qof_session_safe_save (QofSession *session,
|
||||||
QofPercentageFunc percentage_func);
|
QofPercentageFunc percentage_func);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The qof_session_end() method will release the session lock. For the
|
* The qof_session_end() method will release the session lock. For the
|
||||||
|
@ -65,8 +65,8 @@ static void
|
|||||||
test_session_safe_save( Fixture *fixture, gconstpointer pData )
|
test_session_safe_save( Fixture *fixture, gconstpointer pData )
|
||||||
{
|
{
|
||||||
qof_session_safe_save( fixture->session, percentage_fn );
|
qof_session_safe_save( fixture->session, percentage_fn );
|
||||||
g_assert_cmpint( ERR_BACKEND_DATA_CORRUPT, ==,
|
g_assert_cmpint( ERR_BACKEND_DATA_CORRUPT, == ,
|
||||||
qof_session_get_error( fixture->session ));
|
qof_session_get_error( fixture->session ));
|
||||||
g_assert( NULL == qof_session_get_url( fixture->session ));
|
g_assert( NULL == qof_session_get_url( fixture->session ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,16 +3,16 @@
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
qof_log_init();
|
qof_log_init();
|
||||||
qof_init();
|
qof_init();
|
||||||
gnc_module_system_init();
|
gnc_module_system_init();
|
||||||
char * no_args[1] = { NULL };
|
char * no_args[1] = { NULL };
|
||||||
gnc_engine_init(0, no_args);
|
gnc_engine_init(0, no_args);
|
||||||
|
|
||||||
QofSession * s = qof_session_new();
|
QofSession * s = qof_session_new();
|
||||||
qof_session_begin(s, "sqlite3:///tmp/blah.gnucash", 0, 1, 0);
|
qof_session_begin(s, "sqlite3:///tmp/blah.gnucash", 0, 1, 0);
|
||||||
qof_session_load(s, NULL);
|
qof_session_load(s, NULL);
|
||||||
qof_session_save(s, NULL);
|
qof_session_save(s, NULL);
|
||||||
qof_session_end(s);
|
qof_session_end(s);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -37,23 +37,26 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
// model
|
// model
|
||||||
enum bi_import_model_columns {
|
enum bi_import_model_columns
|
||||||
ID, DATE_OPENED, OWNER_ID, BILLING_ID, NOTES, // invoice settings
|
{
|
||||||
DATE, DESC, ACTION, ACCOUNT, QUANTITY, PRICE, DISC_TYPE, DISC_HOW, DISCOUNT, TAXABLE, TAXINCLUDED, TAX_TABLE, // entry settings
|
ID, DATE_OPENED, OWNER_ID, BILLING_ID, NOTES, // invoice settings
|
||||||
DATE_POSTED, DUE_DATE, ACCOUNT_POSTED, MEMO_POSTED, ACCU_SPLITS, // autopost settings
|
DATE, DESC, ACTION, ACCOUNT, QUANTITY, PRICE, DISC_TYPE, DISC_HOW, DISCOUNT, TAXABLE, TAXINCLUDED, TAX_TABLE, // entry settings
|
||||||
N_COLUMNS
|
DATE_POSTED, DUE_DATE, ACCOUNT_POSTED, MEMO_POSTED, ACCU_SPLITS, // autopost settings
|
||||||
|
N_COLUMNS
|
||||||
};
|
};
|
||||||
|
|
||||||
enum _bi_import_result {
|
enum _bi_import_result
|
||||||
RESULT_OK,
|
{
|
||||||
RESULT_OPEN_FAILED,
|
RESULT_OK,
|
||||||
RESULT_ERROR_IN_REGEXP,
|
RESULT_OPEN_FAILED,
|
||||||
|
RESULT_ERROR_IN_REGEXP,
|
||||||
};
|
};
|
||||||
typedef enum _bi_import_result bi_import_result;
|
typedef enum _bi_import_result bi_import_result;
|
||||||
|
|
||||||
struct _bi_import_stats {
|
struct _bi_import_stats
|
||||||
int n_imported, n_ignored;
|
{
|
||||||
GString *ignored_lines;
|
int n_imported, n_ignored;
|
||||||
|
GString *ignored_lines;
|
||||||
};
|
};
|
||||||
typedef struct _bi_import_stats bi_import_stats;
|
typedef struct _bi_import_stats bi_import_stats;
|
||||||
|
|
||||||
|
@ -51,9 +51,10 @@ static void gnc_plugin_bi_import_cmd_test (GtkAction *action, GncMainWindowActio
|
|||||||
#define PLUGIN_ACTIONS_NAME "gnc-plugin-bi_import-actions"
|
#define PLUGIN_ACTIONS_NAME "gnc-plugin-bi_import-actions"
|
||||||
#define PLUGIN_UI_FILENAME "gnc-plugin-bi_import-ui.xml"
|
#define PLUGIN_UI_FILENAME "gnc-plugin-bi_import-ui.xml"
|
||||||
|
|
||||||
static GtkActionEntry gnc_plugin_actions [] = {
|
static GtkActionEntry gnc_plugin_actions [] =
|
||||||
|
{
|
||||||
/* Menu Items */
|
/* Menu Items */
|
||||||
{ "ImportMenuAction", NULL, N_("_Import"), NULL, NULL, NULL },
|
{ "ImportMenuAction", NULL, N_("_Import"), NULL, NULL, NULL },
|
||||||
{ "bi_importAction", NULL, N_("Import Bills & Invoices..."), NULL, N_("bi_import tooltip"), G_CALLBACK(gnc_plugin_bi_import_cmd_test) },
|
{ "bi_importAction", NULL, N_("Import Bills & Invoices..."), NULL, N_("bi_import tooltip"), G_CALLBACK(gnc_plugin_bi_import_cmd_test) },
|
||||||
};
|
};
|
||||||
static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions);
|
static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions);
|
||||||
|
@ -47,11 +47,13 @@ G_BEGIN_DECLS
|
|||||||
#define GNC_PLUGIN_bi_import_NAME "gnc-plugin-bi_import"
|
#define GNC_PLUGIN_bi_import_NAME "gnc-plugin-bi_import"
|
||||||
|
|
||||||
/* typedefs & structures */
|
/* typedefs & structures */
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
GncPlugin gnc_plugin;
|
GncPlugin gnc_plugin;
|
||||||
} GncPluginbi_import;
|
} GncPluginbi_import;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
GncPluginClass gnc_plugin;
|
GncPluginClass gnc_plugin;
|
||||||
} GncPluginbi_importClass;
|
} GncPluginbi_importClass;
|
||||||
|
|
||||||
|
@ -66,24 +66,29 @@ libgncmod_bi_import_gnc_module_description (void)
|
|||||||
int
|
int
|
||||||
libgncmod_bi_import_gnc_module_init (int refcount)
|
libgncmod_bi_import_gnc_module_init (int refcount)
|
||||||
{
|
{
|
||||||
if (!gnc_module_load ("gnucash/app-utils", 0)) {
|
if (!gnc_module_load ("gnucash/app-utils", 0))
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!gnc_module_load ("gnucash/gnome-utils", 0)) {
|
if (!gnc_module_load ("gnucash/gnome-utils", 0))
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!gnc_module_load ("gnucash/business-core", 0)) {
|
if (!gnc_module_load ("gnucash/business-core", 0))
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!gnc_module_load ("gnucash/engine", 0)) {
|
if (!gnc_module_load ("gnucash/engine", 0))
|
||||||
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refcount == 0) {
|
if (refcount == 0)
|
||||||
|
{
|
||||||
/* this is the first time the module is loaded */
|
/* this is the first time the module is loaded */
|
||||||
|
|
||||||
gnc_plugin_manager_add_plugin ( gnc_plugin_manager_get (),
|
gnc_plugin_manager_add_plugin ( gnc_plugin_manager_get (),
|
||||||
gnc_plugin_bi_import_new ());
|
gnc_plugin_bi_import_new ());
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -92,7 +97,8 @@ libgncmod_bi_import_gnc_module_init (int refcount)
|
|||||||
int
|
int
|
||||||
libgncmod_bi_import_gnc_module_end (int refcount)
|
libgncmod_bi_import_gnc_module_end (int refcount)
|
||||||
{
|
{
|
||||||
if (refcount == 0) {
|
if (refcount == 0)
|
||||||
|
{
|
||||||
/* this is the last time the module is unloaded */
|
/* this is the last time the module is unloaded */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,15 +43,16 @@
|
|||||||
#include "bi_import.h"
|
#include "bi_import.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
|
||||||
struct _bi_import_gui {
|
struct _bi_import_gui
|
||||||
GtkWidget *dialog;
|
{
|
||||||
GtkWidget *tree_view;
|
GtkWidget *dialog;
|
||||||
GtkWidget *entryFilename;
|
GtkWidget *tree_view;
|
||||||
GtkListStore *store;
|
GtkWidget *entryFilename;
|
||||||
gint component_id;
|
GtkListStore *store;
|
||||||
GString *regexp;
|
gint component_id;
|
||||||
QofBook *book;
|
GString *regexp;
|
||||||
gchar *type;
|
QofBook *book;
|
||||||
|
gchar *type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -81,251 +82,257 @@ static void gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar
|
|||||||
BillImportGui *
|
BillImportGui *
|
||||||
gnc_plugin_bi_import_showGUI(void)
|
gnc_plugin_bi_import_showGUI(void)
|
||||||
{
|
{
|
||||||
BillImportGui *gui;
|
BillImportGui *gui;
|
||||||
GladeXML *xml;
|
GladeXML *xml;
|
||||||
GList *glist;
|
GList *glist;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GtkCellRenderer *renderer;
|
GtkCellRenderer *renderer;
|
||||||
GtkTreeViewColumn *column;
|
GtkTreeViewColumn *column;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if window exists already, activate it
|
// if window exists already, activate it
|
||||||
glist = gnc_find_gui_components ("dialog-bi_import_gui", NULL, NULL);
|
glist = gnc_find_gui_components ("dialog-bi_import_gui", NULL, NULL);
|
||||||
if (glist) {
|
if (glist)
|
||||||
// window found
|
{
|
||||||
gui = g_list_nth_data (glist,0);
|
// window found
|
||||||
g_list_free (glist);
|
gui = g_list_nth_data (glist, 0);
|
||||||
gtk_window_present (GTK_WINDOW(gui->dialog));
|
g_list_free (glist);
|
||||||
return gui;
|
gtk_window_present (GTK_WINDOW(gui->dialog));
|
||||||
}
|
return gui;
|
||||||
|
}
|
||||||
|
|
||||||
// create new window
|
// create new window
|
||||||
gui = g_new0 (BillImportGui, 1);
|
gui = g_new0 (BillImportGui, 1);
|
||||||
gui->type = "BILL"; // Set default type to match gui. really shouldn't be here TODO change me
|
gui->type = "BILL"; // Set default type to match gui. really shouldn't be here TODO change me
|
||||||
xml = gnc_glade_xml_new ("bi_import.glade", "bi_import Dialog");
|
xml = gnc_glade_xml_new ("bi_import.glade", "bi_import Dialog");
|
||||||
gui->dialog = glade_xml_get_widget (xml, "bi_import Dialog");
|
gui->dialog = glade_xml_get_widget (xml, "bi_import Dialog");
|
||||||
gui->tree_view = glade_xml_get_widget (xml, "treeview1");
|
gui->tree_view = glade_xml_get_widget (xml, "treeview1");
|
||||||
gui->entryFilename = glade_xml_get_widget (xml, "entryFilename");
|
gui->entryFilename = glade_xml_get_widget (xml, "entryFilename");
|
||||||
|
|
||||||
gui->book = gnc_get_current_book();
|
gui->book = gnc_get_current_book();
|
||||||
|
|
||||||
gui->regexp = g_string_new ( "^(?<id>[^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*)(;?(?<disc_type>[^;]*)(;?(?<disc_how>[^;]*)(;?(?<discount>[^;]*)(;?(?<taxable>[^;]*)(;?(?<taxincluded>[^;]*)(;?(?<tax_table>[^;]*)(;(?<date_posted>[^;]*)(;(?<due_date>[^;]*)(;(?<account_posted>[^;]*)(;(?<memo_posted>[^;]*)(;(?<accu_splits>[^;]*))?)?)?)?)?)?)?)?)?)?)?");
|
gui->regexp = g_string_new ( "^(?<id>[^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*)(;?(?<disc_type>[^;]*)(;?(?<disc_how>[^;]*)(;?(?<discount>[^;]*)(;?(?<taxable>[^;]*)(;?(?<taxincluded>[^;]*)(;?(?<tax_table>[^;]*)(;(?<date_posted>[^;]*)(;(?<due_date>[^;]*)(;(?<account_posted>[^;]*)(;(?<memo_posted>[^;]*)(;(?<accu_splits>[^;]*))?)?)?)?)?)?)?)?)?)?)?");
|
||||||
|
|
||||||
// create model and bind to view
|
// create model and bind to view
|
||||||
gui->store = gtk_list_store_new (N_COLUMNS,
|
gui->store = gtk_list_store_new (N_COLUMNS,
|
||||||
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // invoice settings
|
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // invoice settings
|
||||||
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // entry settings
|
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, // entry settings
|
||||||
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); // autopost settings
|
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); // autopost settings
|
||||||
gtk_tree_view_set_model( GTK_TREE_VIEW(gui->tree_view), GTK_TREE_MODEL(gui->store) );
|
gtk_tree_view_set_model( GTK_TREE_VIEW(gui->tree_view), GTK_TREE_MODEL(gui->store) );
|
||||||
#define CREATE_COLUMN(description,column_id) \
|
#define CREATE_COLUMN(description,column_id) \
|
||||||
renderer = gtk_cell_renderer_text_new (); \
|
renderer = gtk_cell_renderer_text_new (); \
|
||||||
column = gtk_tree_view_column_new_with_attributes (description, renderer, "text", column_id, NULL); \
|
column = gtk_tree_view_column_new_with_attributes (description, renderer, "text", column_id, NULL); \
|
||||||
gtk_tree_view_column_set_resizable (column, TRUE); \
|
gtk_tree_view_column_set_resizable (column, TRUE); \
|
||||||
gtk_tree_view_append_column (GTK_TREE_VIEW (gui->tree_view), column);
|
gtk_tree_view_append_column (GTK_TREE_VIEW (gui->tree_view), column);
|
||||||
CREATE_COLUMN ("id", ID);
|
CREATE_COLUMN ("id", ID);
|
||||||
CREATE_COLUMN ("date__opened", DATE_OPENED);
|
CREATE_COLUMN ("date__opened", DATE_OPENED);
|
||||||
CREATE_COLUMN ("owner__id", OWNER_ID);
|
CREATE_COLUMN ("owner__id", OWNER_ID);
|
||||||
CREATE_COLUMN ("billing_id", BILLING_ID);
|
CREATE_COLUMN ("billing_id", BILLING_ID);
|
||||||
CREATE_COLUMN ("notes", NOTES);
|
CREATE_COLUMN ("notes", NOTES);
|
||||||
|
|
||||||
CREATE_COLUMN ("date", DATE);
|
CREATE_COLUMN ("date", DATE);
|
||||||
CREATE_COLUMN ("desc", DESC);
|
CREATE_COLUMN ("desc", DESC);
|
||||||
CREATE_COLUMN ("action", ACTION);
|
CREATE_COLUMN ("action", ACTION);
|
||||||
CREATE_COLUMN ("account", ACCOUNT);
|
CREATE_COLUMN ("account", ACCOUNT);
|
||||||
CREATE_COLUMN ("quantity", QUANTITY);
|
CREATE_COLUMN ("quantity", QUANTITY);
|
||||||
CREATE_COLUMN ("price", PRICE);
|
CREATE_COLUMN ("price", PRICE);
|
||||||
CREATE_COLUMN ("disc__type", DISC_TYPE);
|
CREATE_COLUMN ("disc__type", DISC_TYPE);
|
||||||
CREATE_COLUMN ("disc__how", DISC_HOW);
|
CREATE_COLUMN ("disc__how", DISC_HOW);
|
||||||
CREATE_COLUMN ("discount", DISCOUNT);
|
CREATE_COLUMN ("discount", DISCOUNT);
|
||||||
CREATE_COLUMN ("taxable", TAXABLE);
|
CREATE_COLUMN ("taxable", TAXABLE);
|
||||||
CREATE_COLUMN ("taxincluded", TAXINCLUDED);
|
CREATE_COLUMN ("taxincluded", TAXINCLUDED);
|
||||||
CREATE_COLUMN ("tax__table", TAX_TABLE);
|
CREATE_COLUMN ("tax__table", TAX_TABLE);
|
||||||
|
|
||||||
CREATE_COLUMN ("date__posted", DATE_POSTED);
|
CREATE_COLUMN ("date__posted", DATE_POSTED);
|
||||||
CREATE_COLUMN ("due__date", DUE_DATE);
|
CREATE_COLUMN ("due__date", DUE_DATE);
|
||||||
CREATE_COLUMN ("account__posted", ACCOUNT_POSTED);
|
CREATE_COLUMN ("account__posted", ACCOUNT_POSTED);
|
||||||
CREATE_COLUMN ("memo__posted", MEMO_POSTED);
|
CREATE_COLUMN ("memo__posted", MEMO_POSTED);
|
||||||
CREATE_COLUMN ("accu__splits", ACCU_SPLITS);
|
CREATE_COLUMN ("accu__splits", ACCU_SPLITS);
|
||||||
|
|
||||||
gui->component_id = gnc_register_gui_component ("dialog-bi_import_gui",
|
gui->component_id = gnc_register_gui_component ("dialog-bi_import_gui",
|
||||||
NULL,
|
NULL,
|
||||||
gnc_bi_import_gui_close_handler,
|
gnc_bi_import_gui_close_handler,
|
||||||
gui);
|
gui);
|
||||||
|
|
||||||
/* Setup signals */
|
/* Setup signals */
|
||||||
glade_xml_signal_autoconnect_full( xml, gnc_glade_autoconnect_full_func, gui );
|
glade_xml_signal_autoconnect_full( xml, gnc_glade_autoconnect_full_func, gui );
|
||||||
|
|
||||||
gtk_widget_show_all ( gui->dialog );
|
gtk_widget_show_all ( gui->dialog );
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
gnc_plugin_bi_import_getFilename(void)
|
gnc_plugin_bi_import_getFilename(void)
|
||||||
{
|
{
|
||||||
// prepare file import dialog
|
// prepare file import dialog
|
||||||
gchar *filename;
|
gchar *filename;
|
||||||
GList *filters;
|
GList *filters;
|
||||||
GtkFileFilter *filter;
|
GtkFileFilter *filter;
|
||||||
filters = NULL;
|
filters = NULL;
|
||||||
filter = gtk_file_filter_new ();
|
filter = gtk_file_filter_new ();
|
||||||
gtk_file_filter_set_name (filter, "comma separated values (*.csv)");
|
gtk_file_filter_set_name (filter, "comma separated values (*.csv)");
|
||||||
gtk_file_filter_add_pattern (filter, "*.csv");
|
gtk_file_filter_add_pattern (filter, "*.csv");
|
||||||
filters = g_list_append( filters, filter );
|
filters = g_list_append( filters, filter );
|
||||||
filter = gtk_file_filter_new ();
|
filter = gtk_file_filter_new ();
|
||||||
gtk_file_filter_set_name (filter, "text files (*.txt)");
|
gtk_file_filter_set_name (filter, "text files (*.txt)");
|
||||||
gtk_file_filter_add_pattern (filter, "*.txt");
|
gtk_file_filter_add_pattern (filter, "*.txt");
|
||||||
filters = g_list_append( filters, filter );
|
filters = g_list_append( filters, filter );
|
||||||
filename = gnc_file_dialog(_("Import Bills or Invoices from csv"), filters, NULL, GNC_FILE_DIALOG_IMPORT);
|
filename = gnc_file_dialog(_("Import Bills or Invoices from csv"), filters, NULL, GNC_FILE_DIALOG_IMPORT);
|
||||||
|
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_bi_import_gui_ok_cb (GtkWidget *widget, gpointer data)
|
gnc_bi_import_gui_ok_cb (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
BillImportGui *gui = data;
|
BillImportGui *gui = data;
|
||||||
gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) );
|
gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) );
|
||||||
bi_import_stats stats;
|
bi_import_stats stats;
|
||||||
bi_import_result res;
|
bi_import_result res;
|
||||||
guint n_fixed, n_deleted, n_invoices_created, n_invoices_updated;
|
guint n_fixed, n_deleted, n_invoices_created, n_invoices_updated;
|
||||||
GString *info;
|
GString *info;
|
||||||
|
|
||||||
// import
|
// import
|
||||||
info = g_string_new("");
|
info = g_string_new("");
|
||||||
|
|
||||||
gtk_list_store_clear (gui->store);
|
gtk_list_store_clear (gui->store);
|
||||||
res = gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 0, &stats);
|
res = gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 0, &stats);
|
||||||
if (res == RESULT_OK) {
|
if (res == RESULT_OK)
|
||||||
gnc_bi_import_fix_bis (gui->store, &n_fixed, &n_deleted, info);
|
{
|
||||||
if (info->len > 0)
|
gnc_bi_import_fix_bis (gui->store, &n_fixed, &n_deleted, info);
|
||||||
gnc_info_dialog (gui->dialog, "%s", info->str);
|
if (info->len > 0)
|
||||||
g_string_free( info, TRUE );
|
gnc_info_dialog (gui->dialog, "%s", info->str);
|
||||||
gnc_bi_import_create_bis (gui->store, gui->book, &n_invoices_created, &n_invoices_updated, gui->type);
|
g_string_free( info, TRUE );
|
||||||
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);
|
gnc_bi_import_create_bis (gui->store, gui->book, &n_invoices_created, &n_invoices_updated, gui->type);
|
||||||
|
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)
|
if (stats.n_ignored > 0)
|
||||||
gnc_info2_dialog (gui->dialog, _("These lines were ignored during import"), stats.ignored_lines->str);
|
gnc_info2_dialog (gui->dialog, _("These lines were ignored during import"), stats.ignored_lines->str);
|
||||||
|
|
||||||
g_string_free (stats.ignored_lines,TRUE);
|
g_string_free (stats.ignored_lines, TRUE);
|
||||||
gnc_close_gui_component (gui->component_id);
|
gnc_close_gui_component (gui->component_id);
|
||||||
} else
|
}
|
||||||
if (res == RESULT_OPEN_FAILED) {
|
else if (res == RESULT_OPEN_FAILED)
|
||||||
gnc_error_dialog (gui->dialog, _("The input file can not be opened."));
|
{
|
||||||
} else
|
gnc_error_dialog (gui->dialog, _("The input file can not be opened."));
|
||||||
if (res == RESULT_ERROR_IN_REGEXP) {
|
}
|
||||||
//gnc_error_dialog (gui->dialog, "The regular expression is faulty:\n\n%s", stats.err->str);
|
else if (res == RESULT_ERROR_IN_REGEXP)
|
||||||
}
|
{
|
||||||
|
//gnc_error_dialog (gui->dialog, "The regular expression is faulty:\n\n%s", stats.err->str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_bi_import_gui_cancel_cb (GtkWidget *widget, gpointer data)
|
gnc_bi_import_gui_cancel_cb (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
BillImportGui *gui = data;
|
BillImportGui *gui = data;
|
||||||
|
|
||||||
gnc_close_gui_component (gui->component_id);
|
gnc_close_gui_component (gui->component_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_bi_import_gui_help_cb (GtkWidget *widget, gpointer data)
|
gnc_bi_import_gui_help_cb (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
gnc_gnome_help(HF_HELP, HL_USAGE);
|
gnc_gnome_help(HF_HELP, HL_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gnc_bi_import_gui_close_handler (gpointer user_data)
|
gnc_bi_import_gui_close_handler (gpointer user_data)
|
||||||
{
|
{
|
||||||
BillImportGui *gui = user_data;
|
BillImportGui *gui = user_data;
|
||||||
|
|
||||||
gtk_widget_destroy (gui->dialog);
|
gtk_widget_destroy (gui->dialog);
|
||||||
// gui has already been freed by this point.
|
// gui has already been freed by this point.
|
||||||
// gui->dialog = NULL;
|
// gui->dialog = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_bi_import_gui_destroy_cb (GtkWidget *widget, gpointer data)
|
gnc_bi_import_gui_destroy_cb (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
BillImportGui *gui = data;
|
BillImportGui *gui = data;
|
||||||
|
|
||||||
gnc_suspend_gui_refresh ();
|
gnc_suspend_gui_refresh ();
|
||||||
gnc_unregister_gui_component (gui->component_id);
|
gnc_unregister_gui_component (gui->component_id);
|
||||||
gnc_resume_gui_refresh ();
|
gnc_resume_gui_refresh ();
|
||||||
|
|
||||||
g_object_unref (gui->store);
|
g_object_unref (gui->store);
|
||||||
g_string_free (gui->regexp, TRUE);
|
g_string_free (gui->regexp, TRUE);
|
||||||
g_free (gui);
|
g_free (gui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnc_bi_import_gui_buttonOpen_cb (GtkWidget *widget, gpointer data)
|
void gnc_bi_import_gui_buttonOpen_cb (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
gchar *filename;
|
gchar *filename;
|
||||||
BillImportGui *gui = data;
|
BillImportGui *gui = data;
|
||||||
|
|
||||||
filename = gnc_plugin_bi_import_getFilename();
|
filename = gnc_plugin_bi_import_getFilename();
|
||||||
if (filename) {
|
if (filename)
|
||||||
//printf("Setting filename"); // debug
|
{
|
||||||
gtk_entry_set_text( GTK_ENTRY(gui->entryFilename), filename );
|
//printf("Setting filename"); // debug
|
||||||
//printf("Set filename"); // debug
|
gtk_entry_set_text( GTK_ENTRY(gui->entryFilename), filename );
|
||||||
g_free( filename );
|
//printf("Set filename"); // debug
|
||||||
}
|
g_free( filename );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnc_bi_import_gui_filenameChanged_cb (GtkWidget *widget, gpointer data)
|
void gnc_bi_import_gui_filenameChanged_cb (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
BillImportGui *gui = data;
|
BillImportGui *gui = data;
|
||||||
gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) );
|
gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) );
|
||||||
|
|
||||||
// generate preview
|
// generate preview
|
||||||
gtk_list_store_clear (gui->store);
|
gtk_list_store_clear (gui->store);
|
||||||
gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 10, NULL);
|
gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 10, NULL);
|
||||||
|
|
||||||
g_free( filename );
|
g_free( filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
void gnc_bi_import_gui_option1_cb (GtkWidget *widget, gpointer data)
|
void gnc_bi_import_gui_option1_cb (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
BillImportGui *gui = data;
|
BillImportGui *gui = data;
|
||||||
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
|
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
|
||||||
return;
|
return;
|
||||||
g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
|
g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
|
||||||
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
|
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
|
||||||
}
|
}
|
||||||
void gnc_bi_import_gui_option2_cb (GtkWidget *widget, gpointer data)
|
void gnc_bi_import_gui_option2_cb (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
BillImportGui *gui = data;
|
BillImportGui *gui = data;
|
||||||
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
|
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
|
||||||
return;
|
return;
|
||||||
g_string_assign (gui->regexp, "^(?<id>[^!#+^,]*),(?<date_opened>[^,]*),(?<owner_id>[^,]*),(?<billingid>[^,]*),?(?<notes>[^,]*),?(?<date>[^,]*),?(?<desc>[^,]*),?(?<action>[^,]*),?(?<account>[^,]*),?(?<quantity>[^,]*),?(?<price>[^,]*),?(?<disc_type>[^,]*),?(?<disc_how>[^,]*),?(?<discount>[^,]*),?(?<taxable>[^,]*),?(?<taxincluded>[^,]*),?(?<tax_table>[^,]*),(?<date_posted>[^,]*),(?<due_date>[^,]*),(?<account_posted>[^,]*),(?<memo_posted>[^,]*),(?<accu_splits>[^,]*)");
|
g_string_assign (gui->regexp, "^(?<id>[^!#+^,]*),(?<date_opened>[^,]*),(?<owner_id>[^,]*),(?<billingid>[^,]*),?(?<notes>[^,]*),?(?<date>[^,]*),?(?<desc>[^,]*),?(?<action>[^,]*),?(?<account>[^,]*),?(?<quantity>[^,]*),?(?<price>[^,]*),?(?<disc_type>[^,]*),?(?<disc_how>[^,]*),?(?<discount>[^,]*),?(?<taxable>[^,]*),?(?<taxincluded>[^,]*),?(?<tax_table>[^,]*),(?<date_posted>[^,]*),(?<due_date>[^,]*),(?<account_posted>[^,]*),(?<memo_posted>[^,]*),(?<accu_splits>[^,]*)");
|
||||||
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
|
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
|
||||||
}
|
}
|
||||||
void gnc_bi_import_gui_option3_cb (GtkWidget *widget, gpointer data)
|
void gnc_bi_import_gui_option3_cb (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
BillImportGui *gui = data;
|
BillImportGui *gui = data;
|
||||||
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
|
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
|
||||||
return;
|
return;
|
||||||
g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
|
g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
|
||||||
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
|
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
|
||||||
}
|
}
|
||||||
void gnc_bi_import_gui_option4_cb (GtkWidget *widget, gpointer data)
|
void gnc_bi_import_gui_option4_cb (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
BillImportGui *gui = data;
|
BillImportGui *gui = data;
|
||||||
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
|
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
|
||||||
return;
|
return;
|
||||||
g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
|
g_string_assign (gui->regexp, "^(?<id>[^!#+^;]*);(?<date_opened>[^;]*);(?<owner_id>[^;]*);(?<billingid>[^;]*);?(?<notes>[^;]*);?(?<date>[^;]*);?(?<desc>[^;]*);?(?<action>[^;]*);?(?<account>[^;]*);?(?<quantity>[^;]*);?(?<price>[^;]*);?(?<disc_type>[^;]*);?(?<disc_how>[^;]*);?(?<discount>[^;]*);?(?<taxable>[^;]*);?(?<taxincluded>[^;]*);?(?<tax_table>[^;]*);(?<date_posted>[^;]*);(?<due_date>[^;]*);(?<account_posted>[^;]*);(?<memo_posted>[^;]*);(?<accu_splits>[^;]*)");
|
||||||
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
|
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
|
||||||
}
|
}
|
||||||
void gnc_bi_import_gui_option5_cb (GtkWidget *widget, gpointer data)
|
void gnc_bi_import_gui_option5_cb (GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
BillImportGui *gui = data;
|
BillImportGui *gui = data;
|
||||||
gchar *temp;
|
gchar *temp;
|
||||||
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
|
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
|
||||||
return;
|
return;
|
||||||
temp = gnc_input_dialog (0, _("Adjust regular expression used for import"), _("This regular expression is used to parse the import file. Modify according to your needs.\n"), gui->regexp->str);
|
temp = gnc_input_dialog (0, _("Adjust regular expression used for import"), _("This regular expression is used to parse the import file. Modify according to your needs.\n"), gui->regexp->str);
|
||||||
if (temp) {
|
if (temp)
|
||||||
g_string_assign (gui->regexp,temp);
|
{
|
||||||
g_free (temp);
|
g_string_assign (gui->regexp, temp);
|
||||||
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
|
g_free (temp);
|
||||||
}
|
gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
* Set whether we are importing a bi, invoice, Customer or Vendor
|
* Set whether we are importing a bi, invoice, Customer or Vendor
|
||||||
@ -333,12 +340,12 @@ void gnc_bi_import_gui_option5_cb (GtkWidget *widget, gpointer data)
|
|||||||
|
|
||||||
void gnc_import_gui_type(GtkWidget *widget, gpointer data)
|
void gnc_import_gui_type(GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
BillImportGui *gui = data;
|
BillImportGui *gui = data;
|
||||||
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
|
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
|
||||||
return;
|
return;
|
||||||
if (g_ascii_strcasecmp(widget->name,"radiobuttonInvoice") == 0)gui->type="INVOICE";
|
if (g_ascii_strcasecmp(widget->name, "radiobuttonInvoice") == 0)gui->type = "INVOICE";
|
||||||
else if (g_ascii_strcasecmp(widget->name,"radiobuttonBill") == 0)gui->type="BILL";
|
else if (g_ascii_strcasecmp(widget->name, "radiobuttonBill") == 0)gui->type = "BILL";
|
||||||
//printf ("TYPE set to, %s\n",gui->type);
|
//printf ("TYPE set to, %s\n",gui->type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,10 +383,10 @@ gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const
|
|||||||
|
|
||||||
/* Create the widgets */
|
/* Create the widgets */
|
||||||
dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
|
dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
|
||||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
|
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
|
||||||
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
|
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
|
||||||
NULL);
|
NULL);
|
||||||
#ifdef HAVE_GTK_2_14
|
#ifdef HAVE_GTK_2_14
|
||||||
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
||||||
#else
|
#else
|
||||||
@ -403,11 +410,12 @@ gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const
|
|||||||
|
|
||||||
if (result == GTK_RESPONSE_REJECT)
|
if (result == GTK_RESPONSE_REJECT)
|
||||||
user_input = 0;
|
user_input = 0;
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
gtk_text_buffer_get_start_iter (buffer, &start);
|
gtk_text_buffer_get_start_iter (buffer, &start);
|
||||||
gtk_text_buffer_get_end_iter (buffer, &end);
|
gtk_text_buffer_get_end_iter (buffer, &end);
|
||||||
user_input = gtk_text_buffer_get_text (buffer,
|
user_input = gtk_text_buffer_get_text (buffer,
|
||||||
&start, &end, FALSE);
|
&start, &end, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
@ -435,13 +443,13 @@ gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg)
|
|||||||
GtkTextBuffer *buffer;
|
GtkTextBuffer *buffer;
|
||||||
gchar *user_input;
|
gchar *user_input;
|
||||||
GtkTextIter start, end;
|
GtkTextIter start, end;
|
||||||
gint width,height;
|
gint width, height;
|
||||||
|
|
||||||
/* Create the widgets */
|
/* Create the widgets */
|
||||||
dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
|
dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (parent),
|
||||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
|
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
|
||||||
NULL);
|
NULL);
|
||||||
#ifdef HAVE_GTK_2_14
|
#ifdef HAVE_GTK_2_14
|
||||||
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
|
||||||
#else
|
#else
|
||||||
@ -449,22 +457,23 @@ gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// add a scroll area
|
// add a scroll area
|
||||||
scrolledwindow = gtk_scrolled_window_new (NULL,NULL);
|
scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
|
||||||
gtk_container_add (GTK_CONTAINER (content_area), scrolledwindow);
|
gtk_container_add (GTK_CONTAINER (content_area), scrolledwindow);
|
||||||
|
|
||||||
// add a textview
|
// add a textview
|
||||||
view = gtk_text_view_new ();
|
view = gtk_text_view_new ();
|
||||||
// gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
|
// gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD_CHAR);
|
||||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
|
||||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||||
gtk_text_buffer_set_text (buffer, msg, -1);
|
gtk_text_buffer_set_text (buffer, msg, -1);
|
||||||
gtk_container_add (GTK_CONTAINER (scrolledwindow), view);
|
gtk_container_add (GTK_CONTAINER (scrolledwindow), view);
|
||||||
|
|
||||||
// run the dialog
|
// run the dialog
|
||||||
if (parent) {
|
if (parent)
|
||||||
gtk_window_get_size (GTK_WINDOW(parent), &width, &height);
|
{
|
||||||
gtk_window_set_default_size (GTK_WINDOW(dialog), width, height);
|
gtk_window_get_size (GTK_WINDOW(parent), &width, &height);
|
||||||
}
|
gtk_window_set_default_size (GTK_WINDOW(dialog), width, height);
|
||||||
|
}
|
||||||
gtk_widget_show_all (dialog);
|
gtk_widget_show_all (dialog);
|
||||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
|
@ -28,53 +28,53 @@
|
|||||||
//! \brief helper function
|
//! \brief helper function
|
||||||
gboolean text2bool( const gchar *text )
|
gboolean text2bool( const gchar *text )
|
||||||
{
|
{
|
||||||
gboolean erg = FALSE;
|
gboolean erg = FALSE;
|
||||||
gchar *temp;
|
gchar *temp;
|
||||||
|
|
||||||
if (!text)
|
if (!text)
|
||||||
return erg;
|
return erg;
|
||||||
|
|
||||||
temp = g_strdup( text );
|
temp = g_strdup( text );
|
||||||
g_strstrip( temp );
|
g_strstrip( temp );
|
||||||
if ((g_ascii_strcasecmp( temp, "yes" ) == 0) || (g_ascii_strcasecmp( temp, "true" ) == 0) ||
|
if ((g_ascii_strcasecmp( temp, "yes" ) == 0) || (g_ascii_strcasecmp( temp, "true" ) == 0) ||
|
||||||
(g_ascii_strcasecmp( temp, "1" ) == 0) || (g_ascii_strcasecmp( temp, "x" ) == 0))
|
(g_ascii_strcasecmp( temp, "1" ) == 0) || (g_ascii_strcasecmp( temp, "x" ) == 0))
|
||||||
erg = TRUE;
|
erg = TRUE;
|
||||||
g_free( temp );
|
g_free( temp );
|
||||||
return erg;
|
return erg;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief helper function
|
//! \brief helper function
|
||||||
GncAmountType text2disc_type( const gchar *text )
|
GncAmountType text2disc_type( const gchar *text )
|
||||||
{
|
{
|
||||||
GncAmountType type = GNC_AMT_TYPE_PERCENT;
|
GncAmountType type = GNC_AMT_TYPE_PERCENT;
|
||||||
gchar *temp;
|
gchar *temp;
|
||||||
|
|
||||||
if (!text)
|
if (!text)
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
temp = g_strdup( text );
|
temp = g_strdup( text );
|
||||||
g_strstrip( temp );
|
g_strstrip( temp );
|
||||||
if ((strlen(temp) > 0) && (g_ascii_strcasecmp( temp, "%" ) != 0))
|
if ((strlen(temp) > 0) && (g_ascii_strcasecmp( temp, "%" ) != 0))
|
||||||
type = GNC_AMT_TYPE_VALUE;
|
type = GNC_AMT_TYPE_VALUE;
|
||||||
g_free( temp );
|
g_free( temp );
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief helper function
|
//! \brief helper function
|
||||||
GncDiscountHow text2disc_how( const gchar *text )
|
GncDiscountHow text2disc_how( const gchar *text )
|
||||||
{
|
{
|
||||||
GncDiscountHow how = GNC_DISC_PRETAX;
|
GncDiscountHow how = GNC_DISC_PRETAX;
|
||||||
gchar *temp;
|
gchar *temp;
|
||||||
|
|
||||||
if (!text)
|
if (!text)
|
||||||
return how;
|
return how;
|
||||||
|
|
||||||
temp = g_strdup( text );
|
temp = g_strdup( text );
|
||||||
g_strstrip( temp );
|
g_strstrip( temp );
|
||||||
if (g_ascii_strcasecmp( temp, "=" ) == 0)
|
if (g_ascii_strcasecmp( temp, "=" ) == 0)
|
||||||
how = GNC_DISC_SAMETIME;
|
how = GNC_DISC_SAMETIME;
|
||||||
else if (g_ascii_strcasecmp( temp, ">" ) == 0)
|
else if (g_ascii_strcasecmp( temp, ">" ) == 0)
|
||||||
how = GNC_DISC_POSTTAX;
|
how = GNC_DISC_POSTTAX;
|
||||||
g_free( temp );
|
g_free( temp );
|
||||||
return how;
|
return how;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user