Apply the fixes for #92157 to the business entry ledger.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7474 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton
2002-11-12 18:58:45 +00:00
parent 348e88d83d
commit da778e274e
4 changed files with 62 additions and 31 deletions
+4
View File
@@ -13,6 +13,10 @@
accounts. (gnc_split_register_get_account): Call the new function
to get the addditional checks. This solves #92157.
* src/business/business-ledger/gncEntryLedger.c:
* src/business/business-ledger/gncEntryLedgerControl.c: Implement
the equivalent fixes for the business ledger.
2002-11-12 Benoit Grégoire <bock@step.polymtl.ca>
* src/import-export/Transaction-matcher.c: Fix previous patch.
gcc 3.2 is too forgiving...
+53 -5
View File
@@ -11,6 +11,7 @@
#include <glib.h>
#include "Account.h"
#include "AccWindow.h"
#include "gnc-ui-util.h"
#include "combocell.h"
#include "pricecell.h"
@@ -57,16 +58,63 @@ gnc_entry_ledger_get_blank_entry (GncEntryLedger *ledger)
return gncEntryLookup (ledger->book, &(ledger->blank_entry_guid));
}
Account *
gnc_entry_ledger_get_account_by_name (GncEntryLedger *ledger, BasicCell * bcell,
const char *name, gboolean *new)
{
const char *placeholder = _("The account %s does not allow transactions.\n");
const char *missing = _("The account %s does not exist.\n"
"Would you like to create it?");
char *fullname;
ComboCell *cell = (ComboCell *) bcell;
Account *account;
/* No changes, as yet. */
*new = FALSE;
/* Find the account */
account = xaccGetAccountFromFullName (gnc_get_current_group (),
name, gnc_get_account_separator ());
if (!account) {
/* Ask if they want to create a new one. */
if (!gnc_verify_dialog_parented (ledger->parent, TRUE, missing, name))
return NULL;
/* User said yes, they want to create a new account. */
account = gnc_ui_new_accounts_from_name_window (name);
if (!account)
return NULL;
*new = TRUE;
/* Now have a new account. Update the cell with the name as created. */
fullname = xaccAccountGetFullName (account, gnc_get_account_separator ());
gnc_combo_cell_set_value (cell, fullname);
gnc_basic_cell_set_changed (&cell->cell, TRUE);
g_free (fullname);
}
/* See if the account (either old or new) is a placeholder. */
if (xaccAccountGetPlaceholder (account)) {
gnc_error_dialog_parented (GTK_WINDOW(ledger->parent), placeholder, name);
}
/* Be seeing you. */
return account;
}
Account * gnc_entry_ledger_get_account (GncEntryLedger *ledger,
const char * cell_name)
{
const char * name =
gnc_table_layout_get_cell_value (ledger->table->layout, cell_name);
BasicCell *cell;
const char * name;
gboolean dummy;
return xaccGetAccountFromFullName (gnc_book_get_group (ledger->book),
name,
gnc_get_account_separator ());
cell = gnc_table_layout_get_cell (ledger->table->layout, cell_name);
if (!cell)
return NULL;
name = gnc_basic_cell_get_value (cell);
return gnc_entry_ledger_get_account_by_name (ledger, cell, name, &dummy);
}
GncTaxTable * gnc_entry_ledger_get_taxtable (GncEntryLedger *ledger,
@@ -279,7 +279,6 @@ static gboolean gnc_entry_ledger_traverse (VirtualLocation *p_new_virt_loc,
do
{
ComboCell *cell;
Account *account;
char *name;
char *cell_name = NULL;
@@ -316,31 +315,9 @@ static gboolean gnc_entry_ledger_traverse (VirtualLocation *p_new_virt_loc,
if (!name || *name == '\0')
break;
account = xaccGetAccountFromFullName (gnc_book_get_group (ledger->book),
cell->cell.value,
gnc_get_account_separator ());
if (account)
break;
{
const char *format = _("The account %s does not exist.\n"
"Would you like to create it?");
if (!gnc_verify_dialog_parented (ledger->parent, TRUE, format, name))
break;
}
ledger->full_refresh = FALSE;
account = gnc_ui_new_accounts_from_name_window (name);
if (!account)
break;
ledger->full_refresh = TRUE;
name = xaccAccountGetFullName (account, gnc_get_account_separator ());
gnc_combo_cell_set_value (cell, name);
gnc_basic_cell_set_changed (&cell->cell, TRUE);
g_free (name);
/* Create the account if necessary. Also checks for a placeholder */
(void) gnc_entry_ledger_get_account_by_name (ledger, (BasicCell *)cell, cell->cell.value,
&ledger->full_refresh);
} while (FALSE);
@@ -39,6 +39,8 @@ struct GncEntryLedger_s {
GncEntry * gnc_entry_ledger_get_entry (GncEntryLedger *ledger,
VirtualCellLocation vcell_loc);
Account * gnc_entry_ledger_get_account_by_name (GncEntryLedger *ledger, BasicCell * bcell,
const char *name, gboolean *new);
Account * gnc_entry_ledger_get_account (GncEntryLedger *ledger,
const char * cell_name);
GncTaxTable * gnc_entry_ledger_get_taxtable (GncEntryLedger *ledger,