mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 632166: Notify user when something goes wrong with a transaction save.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19673 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
657a435f38
commit
e536180587
@ -16,6 +16,7 @@ AM_CFLAGS = \
|
||||
${GLIB_CFLAGS} \
|
||||
${GUILE_INCS} \
|
||||
${GCONF_CFLAGS} \
|
||||
${GTK_CFLAGS} \
|
||||
${WARN_CFLAGS}
|
||||
|
||||
libgnc_backend_sql_la_SOURCES = \
|
||||
|
@ -28,7 +28,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "qof.h"
|
||||
#include "qofquery-p.h"
|
||||
@ -56,7 +57,7 @@
|
||||
#define SIMPLE_QUERY_COMPILATION 1
|
||||
#define LOAD_TRANSACTIONS_AS_NEEDED 0
|
||||
|
||||
/*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
|
||||
static QofLogModule log_module = G_LOG_DOMAIN;
|
||||
|
||||
#define TRANSACTION_TABLE "transactions"
|
||||
#define TX_TABLE_VERSION 3
|
||||
@ -694,6 +695,7 @@ save_transaction( GncSqlBackend* be, Transaction* pTx, gboolean do_save_splits )
|
||||
gboolean is_infant;
|
||||
QofInstance* inst;
|
||||
gboolean is_ok = TRUE;
|
||||
gchar* err = NULL;
|
||||
|
||||
g_return_val_if_fail( be != NULL, FALSE );
|
||||
g_return_val_if_fail( pTx != NULL, FALSE );
|
||||
@ -717,11 +719,19 @@ save_transaction( GncSqlBackend* be, Transaction* pTx, gboolean do_save_splits )
|
||||
{
|
||||
// Ensure the commodity is in the db
|
||||
is_ok = gnc_sql_save_commodity( be, xaccTransGetCurrency( pTx ) );
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = N_("Commodity save failed: Probably and invalid or missing currency");
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_ok )
|
||||
{
|
||||
is_ok = gnc_sql_do_db_operation( be, op, TRANSACTION_TABLE, GNC_ID_TRANS, pTx, tx_col_table );
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = N_("Transaction header save failed. Check trace log for SQL errors");
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_ok )
|
||||
@ -731,21 +741,61 @@ save_transaction( GncSqlBackend* be, Transaction* pTx, gboolean do_save_splits )
|
||||
if ( !qof_instance_get_destroying(inst) )
|
||||
{
|
||||
is_ok = gnc_sql_slots_save( be, guid, is_infant, qof_instance_get_slots( inst ) );
|
||||
if ( is_ok && do_save_splits )
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = N_("Slots save failed. Check trace log for SQL errors");
|
||||
}
|
||||
if ( is_ok && do_save_splits )
|
||||
{
|
||||
is_ok = save_splits( be, guid, xaccTransGetSplitList( pTx ) );
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = N_("Split save failed. Check trace log for SQL errors");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
is_ok = gnc_sql_slots_delete( be, guid );
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = N_("Slots delete failed. Check trace log for SQL errors");
|
||||
}
|
||||
if ( is_ok )
|
||||
{
|
||||
is_ok = delete_splits( be, pTx );
|
||||
}
|
||||
if ( ! is_ok )
|
||||
{
|
||||
err = N_("Split delete failed. Check trace log for SQL errors");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! is_ok )
|
||||
{
|
||||
gchar *message1 = N_("Transaction %s dated %s in account %s not saved due to %s.%s");
|
||||
gchar *message2 = N_("\nDatabase may be corrupted, check your data carefully.");
|
||||
GtkWidget* msg = gtk_message_dialog_new( NULL, GTK_DIALOG_MODAL,
|
||||
GTK_MESSAGE_WARNING,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
N_("Error saving transaction") );
|
||||
Split* split = xaccTransGetSplit( pTx, 0);
|
||||
Account *acc = xaccSplitGetAccount( split );
|
||||
gtk_message_dialog_format_secondary_text( GTK_MESSAGE_DIALOG( msg ),
|
||||
message1,
|
||||
xaccTransGetDescription( pTx ),
|
||||
qof_print_date( xaccTransGetDate( pTx ) ),
|
||||
xaccAccountGetName( acc ),
|
||||
err,
|
||||
message2 );
|
||||
PERR( "Transaction %s dated %s in account %s not saved due to %s.\n",
|
||||
xaccTransGetDescription( pTx ),
|
||||
qof_print_date( xaccTransGetDate( pTx ) ),
|
||||
xaccAccountGetName( acc ),
|
||||
err );
|
||||
gtk_dialog_run ( GTK_DIALOG( msg ) );
|
||||
gtk_widget_destroy ( msg );
|
||||
}
|
||||
return is_ok;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user