mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
continue whacking at multi-book support
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6505 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
8ff4969d89
commit
c66e3a0dd4
@ -137,11 +137,86 @@ pgendGetUserGecos (PGBackend *be)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountGroup *
|
/* ============================================================= */
|
||||||
pgendGetTopGroup (PGBackend *be)
|
|
||||||
|
Account *
|
||||||
|
pgendAccountLookup (PGBackend *be, const GUID *acct_guid)
|
||||||
{
|
{
|
||||||
if (!be) return NULL;
|
GList *node;
|
||||||
return gnc_book_get_group (be->book);
|
Account * acc = NULL;
|
||||||
|
|
||||||
|
for (node=be->blist; node; node=node->next)
|
||||||
|
{
|
||||||
|
GNCBook *book = node->data;
|
||||||
|
acc = xaccAccountLookup (acct_guid, book);
|
||||||
|
if (acc) return acc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Transaction *
|
||||||
|
pgendTransLookup (PGBackend *be, const GUID *txn_guid)
|
||||||
|
{
|
||||||
|
GList *node;
|
||||||
|
Transaction * txn = NULL;
|
||||||
|
|
||||||
|
for (node=be->blist; node; node=node->next)
|
||||||
|
{
|
||||||
|
GNCBook *book = node->data;
|
||||||
|
txn = xaccTransLookup (txn_guid, book);
|
||||||
|
if (txn) return txn;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Split *
|
||||||
|
pgendSplitLookup (PGBackend *be, const GUID *split_guid)
|
||||||
|
{
|
||||||
|
GList *node;
|
||||||
|
Split * split = NULL;
|
||||||
|
|
||||||
|
for (node=be->blist; node; node=node->next)
|
||||||
|
{
|
||||||
|
GNCBook *book = node->data;
|
||||||
|
split = xaccSplitLookup (split_guid, book);
|
||||||
|
if (split) return split;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GNCPrice *
|
||||||
|
pgendPriceLookup (PGBackend *be, const GUID *price_guid)
|
||||||
|
{
|
||||||
|
GList *node;
|
||||||
|
GNCPrice * price = NULL;
|
||||||
|
|
||||||
|
for (node=be->blist; node; node=node->next)
|
||||||
|
{
|
||||||
|
GNCBook *book = node->data;
|
||||||
|
price = gnc_price_lookup (price_guid, book);
|
||||||
|
if (price) return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
GNCIdType
|
||||||
|
pgendGUIDType (PGBackend *be, const GUID *guid)
|
||||||
|
{
|
||||||
|
GList *node;
|
||||||
|
GNCIdType tip = GNC_ID_NONE;
|
||||||
|
|
||||||
|
for (node=be->blist; node; node=node->next)
|
||||||
|
{
|
||||||
|
GNCBook *book = node->data;
|
||||||
|
tip = xaccGUIDType (guid, book);
|
||||||
|
if (GNC_ID_NONE != tip) return tip;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GNC_ID_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ============================================================= */
|
/* ============================================================= */
|
||||||
@ -723,7 +798,7 @@ pgendSync (Backend *bend, GNCBook *book)
|
|||||||
pgendDisable(be);
|
pgendDisable(be);
|
||||||
|
|
||||||
pgendKVPInit(be);
|
pgendKVPInit(be);
|
||||||
pgendGetAllAccounts (be, grp);
|
pgendGetAllAccountsInBook (be, book);
|
||||||
if ((MODE_SINGLE_FILE != be->session_mode) &&
|
if ((MODE_SINGLE_FILE != be->session_mode) &&
|
||||||
(MODE_SINGLE_UPDATE != be->session_mode))
|
(MODE_SINGLE_UPDATE != be->session_mode))
|
||||||
{
|
{
|
||||||
@ -1310,20 +1385,28 @@ pgend_book_load_poll (Backend *bend, GNCBook *book)
|
|||||||
|
|
||||||
if (!be) return;
|
if (!be) return;
|
||||||
|
|
||||||
be->book = book;
|
|
||||||
|
|
||||||
pgendGetBook (be, book);
|
|
||||||
|
|
||||||
grp = gnc_book_get_group (book);
|
|
||||||
|
|
||||||
/* don't send events to GUI, don't accept callbacks to backend */
|
/* don't send events to GUI, don't accept callbacks to backend */
|
||||||
gnc_engine_suspend_events();
|
gnc_engine_suspend_events();
|
||||||
pgendDisable(be);
|
pgendDisable(be);
|
||||||
be->version_check = (guint32) time(0);
|
be->version_check = (guint32) time(0);
|
||||||
|
|
||||||
pgendKVPInit(be);
|
pgendKVPInit(be);
|
||||||
pgendGetAllAccounts (be, grp);
|
|
||||||
|
|
||||||
|
be->book = book;
|
||||||
|
|
||||||
|
if (be->blist)
|
||||||
|
{
|
||||||
|
/* XXX not clear what this means ... should we free old books ?? */
|
||||||
|
PWARN ("old book list not empty ");
|
||||||
|
g_list_free (be->blist);
|
||||||
|
}
|
||||||
|
pgendGetBook (be, book);
|
||||||
|
|
||||||
|
be->blist = g_list_append (NULL, book);
|
||||||
|
|
||||||
|
pgendGetAllAccountsInBook (be, book);
|
||||||
|
|
||||||
|
grp = gnc_book_get_group (book);
|
||||||
xaccAccountGroupBeginEdit (grp);
|
xaccAccountGroupBeginEdit (grp);
|
||||||
pgendGroupGetAllBalances (be, grp, ts);
|
pgendGroupGetAllBalances (be, grp, ts);
|
||||||
xaccAccountGroupCommitEdit (grp);
|
xaccAccountGroupCommitEdit (grp);
|
||||||
@ -1349,19 +1432,29 @@ pgend_book_load_single (Backend *bend, GNCBook *book)
|
|||||||
|
|
||||||
if (!be) return;
|
if (!be) return;
|
||||||
|
|
||||||
be->book = book;
|
|
||||||
|
|
||||||
pgendGetBook (be, book);
|
|
||||||
|
|
||||||
grp = gnc_book_get_group (book);
|
|
||||||
|
|
||||||
/* don't send events to GUI, don't accept callbacks to backend */
|
/* don't send events to GUI, don't accept callbacks to backend */
|
||||||
gnc_engine_suspend_events();
|
gnc_engine_suspend_events();
|
||||||
pgendDisable(be);
|
pgendDisable(be);
|
||||||
be->version_check = (guint32) time(0);
|
be->version_check = (guint32) time(0);
|
||||||
|
|
||||||
|
be->book = book;
|
||||||
|
|
||||||
pgendKVPInit(be);
|
pgendKVPInit(be);
|
||||||
pgendGetAllAccounts (be, grp);
|
|
||||||
|
if (be->blist)
|
||||||
|
{
|
||||||
|
/* XXX not clear what this means ... should we free old books ?? */
|
||||||
|
PWARN ("old book list not empty ");
|
||||||
|
g_list_free (be->blist);
|
||||||
|
}
|
||||||
|
pgendGetBook (be, book);
|
||||||
|
|
||||||
|
be->blist = g_list_append (NULL, book);
|
||||||
|
|
||||||
|
pgendGetAllAccountsInBook (be, book);
|
||||||
|
|
||||||
|
grp = gnc_book_get_group (book);
|
||||||
pgendGetMassTransactions (be, grp);
|
pgendGetMassTransactions (be, grp);
|
||||||
|
|
||||||
/* re-enable events */
|
/* re-enable events */
|
||||||
@ -1981,7 +2074,7 @@ pgend_session_begin (Backend *backend,
|
|||||||
be->be.price_begin_edit = pgend_price_begin_edit;
|
be->be.price_begin_edit = pgend_price_begin_edit;
|
||||||
be->be.price_commit_edit = pgend_price_commit_edit;
|
be->be.price_commit_edit = pgend_price_commit_edit;
|
||||||
be->be.run_query = pgendRunQuery;
|
be->be.run_query = pgendRunQuery;
|
||||||
be->be.price_lookup = pgendPriceLookup;
|
be->be.price_lookup = pgendPriceFind;
|
||||||
be->be.sync_all = pgendSync;
|
be->be.sync_all = pgendSync;
|
||||||
be->be.sync_group = NULL;
|
be->be.sync_group = NULL;
|
||||||
be->be.sync_price = pgendSyncPriceDB;
|
be->be.sync_price = pgendSyncPriceDB;
|
||||||
@ -2011,7 +2104,7 @@ pgend_session_begin (Backend *backend,
|
|||||||
be->be.price_begin_edit = pgend_price_begin_edit;
|
be->be.price_begin_edit = pgend_price_begin_edit;
|
||||||
be->be.price_commit_edit = pgend_price_commit_edit;
|
be->be.price_commit_edit = pgend_price_commit_edit;
|
||||||
be->be.run_query = pgendRunQuery;
|
be->be.run_query = pgendRunQuery;
|
||||||
be->be.price_lookup = pgendPriceLookup;
|
be->be.price_lookup = pgendPriceFind;
|
||||||
be->be.sync_all = pgendSync;
|
be->be.sync_all = pgendSync;
|
||||||
be->be.sync_group = NULL;
|
be->be.sync_group = NULL;
|
||||||
be->be.sync_price = pgendSyncPriceDB;
|
be->be.sync_price = pgendSyncPriceDB;
|
||||||
@ -2197,7 +2290,9 @@ pgendInit (PGBackend *be)
|
|||||||
}
|
}
|
||||||
be->ipath_max = 0;
|
be->ipath_max = 0;
|
||||||
|
|
||||||
|
be->session = NULL;
|
||||||
be->book = NULL;
|
be->book = NULL;
|
||||||
|
be->blist = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ============================================================= */
|
/* ============================================================= */
|
||||||
|
@ -110,7 +110,8 @@ struct _pgend {
|
|||||||
|
|
||||||
/* engine data caches */
|
/* engine data caches */
|
||||||
GNCSession *session;
|
GNCSession *session;
|
||||||
GNCBook *book;
|
GNCBook *book; /* the currently open book -- XXX -- depricate ???*/
|
||||||
|
BookList *blist; /* list of books in this db */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -118,7 +119,11 @@ struct _pgend {
|
|||||||
*/
|
*/
|
||||||
Backend * pgendNew (void);
|
Backend * pgendNew (void);
|
||||||
|
|
||||||
AccountGroup * pgendGetTopGroup (PGBackend *be);
|
Account * pgendAccountLookup (PGBackend *be, const GUID *acct_guid);
|
||||||
|
Transaction * pgendTransLookup (PGBackend *be, const GUID *txn_guid);
|
||||||
|
Split * pgendSplitLookup (PGBackend *be, const GUID *split_guid);
|
||||||
|
GNCPrice * pgendPriceLookup (PGBackend *be, const GUID *price_guid);
|
||||||
|
GNCIdType pgendGUIDType (PGBackend *be, const GUID *guid);
|
||||||
|
|
||||||
void pgendDisable (PGBackend *be);
|
void pgendDisable (PGBackend *be);
|
||||||
void pgendEnable (PGBackend *be);
|
void pgendEnable (PGBackend *be);
|
||||||
|
@ -35,12 +35,15 @@
|
|||||||
#include "BackendP.h"
|
#include "BackendP.h"
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
#include "GroupP.h"
|
#include "GroupP.h"
|
||||||
|
#include "gnc-book.h"
|
||||||
|
#include "gnc-book-p.h"
|
||||||
#include "gnc-commodity.h"
|
#include "gnc-commodity.h"
|
||||||
#include "gnc-engine-util.h"
|
#include "gnc-engine-util.h"
|
||||||
#include "gnc-event.h"
|
#include "gnc-event.h"
|
||||||
#include "guid.h"
|
#include "guid.h"
|
||||||
|
|
||||||
#include "account.h"
|
#include "account.h"
|
||||||
|
#include "book.h"
|
||||||
#include "base-autogen.h"
|
#include "base-autogen.h"
|
||||||
#include "kvp-sql.h"
|
#include "kvp-sql.h"
|
||||||
#include "PostgresBackend.h"
|
#include "PostgresBackend.h"
|
||||||
@ -236,30 +239,47 @@ pgendGetAllAccountKVP (PGBackend *be, AccountGroup *grp)
|
|||||||
|
|
||||||
/* ============================================================= */
|
/* ============================================================= */
|
||||||
/* The pgendGetAllAccounts() routine restores the account hierarchy
|
/* The pgendGetAllAccounts() routine restores the account hierarchy
|
||||||
* of *all* accounts in the DB.
|
* of *all* accounts in the DB. Each account is stuffed into
|
||||||
* It implicitly assumes that the database has only one account
|
* its corresponding book.
|
||||||
* hierarchy in it, i.e. any accounts without a parent will be stuffed
|
*
|
||||||
* into the same top group.
|
* The pgendGetAllAccountsInBook() routine only fetches the accounts
|
||||||
|
* for the indicated book.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
get_account_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
get_account_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||||
{
|
{
|
||||||
AccountGroup *topgrp = (AccountGroup *) data;
|
GList *node;
|
||||||
|
GNCBook *book;
|
||||||
Account *parent;
|
Account *parent;
|
||||||
Account *acc;
|
Account *acc;
|
||||||
GUID guid;
|
GUID acct_guid, book_guid;
|
||||||
|
|
||||||
/* first, lets see if we've already got this one */
|
|
||||||
PINFO ("account GUID=%s", DB_GET_VAL("accountGUID",j));
|
PINFO ("account GUID=%s", DB_GET_VAL("accountGUID",j));
|
||||||
guid = nullguid; /* just in case the read fails ... */
|
|
||||||
string_to_guid (DB_GET_VAL("accountGUID",j), &guid);
|
/* First, find the book that pertains to this account */
|
||||||
acc = xaccAccountLookup (&guid, be->book);
|
book_guid = nullguid; /* just in case the read fails ... */
|
||||||
|
string_to_guid (DB_GET_VAL("bookGUID",j), &book_guid);
|
||||||
|
|
||||||
|
book = NULL;
|
||||||
|
for (node=be->blist; node; node=node->next)
|
||||||
|
{
|
||||||
|
book = node->data;
|
||||||
|
if (guid_equal (&book->guid, &book_guid)) break;
|
||||||
|
book = NULL;
|
||||||
|
}
|
||||||
|
if (!book) return NULL;
|
||||||
|
|
||||||
|
/* Next, lets see if we've already got this account */
|
||||||
|
acct_guid = nullguid; /* just in case the read fails ... */
|
||||||
|
string_to_guid (DB_GET_VAL("accountGUID",j), &acct_guid);
|
||||||
|
|
||||||
|
acc = xaccAccountLookup (&acct_guid, book);
|
||||||
if (!acc)
|
if (!acc)
|
||||||
{
|
{
|
||||||
acc = xaccMallocAccount(be->book);
|
acc = xaccMallocAccount(book);
|
||||||
xaccAccountBeginEdit(acc);
|
xaccAccountBeginEdit(acc);
|
||||||
xaccAccountSetGUID(acc, &guid);
|
xaccAccountSetGUID(acc, &acct_guid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -272,30 +292,30 @@ get_account_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
|||||||
xaccAccountSetType(acc, xaccAccountStringToEnum(DB_GET_VAL("type",j)));
|
xaccAccountSetType(acc, xaccAccountStringToEnum(DB_GET_VAL("type",j)));
|
||||||
xaccAccountSetCommodity(acc,
|
xaccAccountSetCommodity(acc,
|
||||||
gnc_string_to_commodity (DB_GET_VAL("commodity",j),
|
gnc_string_to_commodity (DB_GET_VAL("commodity",j),
|
||||||
be->book));
|
book));
|
||||||
xaccAccountSetVersion(acc, atoi(DB_GET_VAL("version",j)));
|
xaccAccountSetVersion(acc, atoi(DB_GET_VAL("version",j)));
|
||||||
acc->idata = atoi(DB_GET_VAL("iguid",j));
|
acc->idata = atoi(DB_GET_VAL("iguid",j));
|
||||||
|
|
||||||
/* try to find the parent account */
|
/* try to find the parent account */
|
||||||
PINFO ("parent GUID=%s", DB_GET_VAL("parentGUID",j));
|
PINFO ("parent GUID=%s", DB_GET_VAL("parentGUID",j));
|
||||||
guid = nullguid; /* just in case the read fails ... */
|
acct_guid = nullguid; /* just in case the read fails ... */
|
||||||
string_to_guid (DB_GET_VAL("parentGUID",j), &guid);
|
string_to_guid (DB_GET_VAL("parentGUID",j), &acct_guid);
|
||||||
if (guid_equal(xaccGUIDNULL(), &guid))
|
if (guid_equal(xaccGUIDNULL(), &acct_guid))
|
||||||
{
|
{
|
||||||
/* if the parent guid is null, then this
|
/* if the parent guid is null, then this
|
||||||
* account belongs in the top group */
|
* account belongs in the top group */
|
||||||
xaccGroupInsertAccount (topgrp, acc);
|
xaccGroupInsertAccount (gnc_book_get_group(book), acc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* if we haven't restored the parent account, create
|
/* if we haven't restored the parent account, create
|
||||||
* an empty holder for it */
|
* an empty holder for it */
|
||||||
parent = xaccAccountLookup (&guid, be->book);
|
parent = xaccAccountLookup (&acct_guid, book);
|
||||||
if (!parent)
|
if (!parent)
|
||||||
{
|
{
|
||||||
parent = xaccMallocAccount(be->book);
|
parent = xaccMallocAccount(book);
|
||||||
xaccAccountBeginEdit(parent);
|
xaccAccountBeginEdit(parent);
|
||||||
xaccAccountSetGUID(parent, &guid);
|
xaccAccountSetGUID(parent, &acct_guid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -306,30 +326,66 @@ get_account_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
|||||||
}
|
}
|
||||||
xaccAccountCommitEdit(acc);
|
xaccAccountCommitEdit(acc);
|
||||||
|
|
||||||
return topgrp;
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountGroup *
|
void
|
||||||
pgendGetAllAccounts (PGBackend *be, AccountGroup *topgrp)
|
pgendGetAllAccounts (PGBackend *be)
|
||||||
{
|
{
|
||||||
|
BookList *node;
|
||||||
char * bufp;
|
char * bufp;
|
||||||
|
|
||||||
ENTER ("be=%p", be);
|
ENTER ("be=%p", be);
|
||||||
if (!be) return NULL;
|
if (!be) return;
|
||||||
|
|
||||||
|
/* get all the books in the database */
|
||||||
|
pgendGetAllBooks (be, be->blist);
|
||||||
|
|
||||||
|
/* Make sure commodities table is up to date */
|
||||||
|
pgendGetAllCommodities (be);
|
||||||
|
|
||||||
|
/* Get them ALL */
|
||||||
|
bufp = "SELECT * FROM gncAccount;";
|
||||||
|
SEND_QUERY (be, bufp, );
|
||||||
|
pgendGetResults (be, get_account_cb, NULL);
|
||||||
|
|
||||||
|
for (node=be->blist; node; node=node->next)
|
||||||
|
{
|
||||||
|
GNCBook *book = node->data;
|
||||||
|
AccountGroup *topgrp = gnc_book_get_group (book);
|
||||||
|
pgendGetAllAccountKVP (be, topgrp);
|
||||||
|
|
||||||
|
/* Mark the newly read group as saved, since the act of putting
|
||||||
|
* it together will have caused it to be marked up as not-saved.
|
||||||
|
*/
|
||||||
|
xaccGroupMarkSaved (topgrp);
|
||||||
|
}
|
||||||
|
|
||||||
|
LEAVE (" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pgendGetAllAccountsInBook (PGBackend *be, GNCBook *book)
|
||||||
|
{
|
||||||
|
char *p, buff[400];
|
||||||
|
AccountGroup *topgrp;
|
||||||
|
|
||||||
|
ENTER ("be=%p", be);
|
||||||
|
if (!be || !book) return;
|
||||||
|
|
||||||
/* first, make sure commodities table is up to date */
|
/* first, make sure commodities table is up to date */
|
||||||
pgendGetAllCommodities (be);
|
pgendGetAllCommodities (be);
|
||||||
|
|
||||||
if (!topgrp)
|
/* Get everything for this book */
|
||||||
{
|
|
||||||
topgrp = xaccMallocAccountGroup(be->book);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get them ALL */
|
p = buff;
|
||||||
bufp = "SELECT * FROM gncAccount;";
|
p = stpcpy (p, "SELECT * FROM gncAccount WHERE bookGuid='");
|
||||||
SEND_QUERY (be, bufp, NULL);
|
p = guid_to_string_buff (gnc_book_get_guid(book), p);
|
||||||
pgendGetResults (be, get_account_cb, topgrp);
|
p = stpcpy (p, "';");
|
||||||
|
SEND_QUERY (be, buff, );
|
||||||
|
pgendGetResults (be, get_account_cb, NULL);
|
||||||
|
|
||||||
|
topgrp = gnc_book_get_group (book);
|
||||||
pgendGetAllAccountKVP (be, topgrp);
|
pgendGetAllAccountKVP (be, topgrp);
|
||||||
|
|
||||||
/* Mark the newly read group as saved, since the act of putting
|
/* Mark the newly read group as saved, since the act of putting
|
||||||
@ -338,17 +394,16 @@ pgendGetAllAccounts (PGBackend *be, AccountGroup *topgrp)
|
|||||||
xaccGroupMarkSaved (topgrp);
|
xaccGroupMarkSaved (topgrp);
|
||||||
|
|
||||||
LEAVE (" ");
|
LEAVE (" ");
|
||||||
return topgrp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ============================================================= */
|
/* ============================================================= */
|
||||||
|
|
||||||
int
|
Account *
|
||||||
pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
|
pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
|
||||||
{
|
{
|
||||||
char *pbuff;
|
char *pbuff;
|
||||||
Account *acc;
|
Account *acc = NULL;
|
||||||
int engine_data_is_newer = 0;
|
int engine_data_is_newer = 0;
|
||||||
|
|
||||||
ENTER ("be=%p", be);
|
ENTER ("be=%p", be);
|
||||||
@ -358,8 +413,9 @@ pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
|
|||||||
gnc_engine_suspend_events();
|
gnc_engine_suspend_events();
|
||||||
pgendDisable(be);
|
pgendDisable(be);
|
||||||
|
|
||||||
/* first, see if we already have such an account */
|
/* First, see if we already have such an account */
|
||||||
acc = xaccAccountLookup (acct_guid, be->book);
|
acc = pgendAccountLookup (be, acct_guid);
|
||||||
|
|
||||||
if (!acc)
|
if (!acc)
|
||||||
{
|
{
|
||||||
engine_data_is_newer = -1;
|
engine_data_is_newer = -1;
|
||||||
@ -390,10 +446,11 @@ pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
|
|||||||
pbuff = stpcpy (pbuff, "';");
|
pbuff = stpcpy (pbuff, "';");
|
||||||
|
|
||||||
SEND_QUERY (be,be->buff, 0);
|
SEND_QUERY (be,be->buff, 0);
|
||||||
pgendGetResults (be, get_account_cb, pgendGetTopGroup (be));
|
acc = pgendGetResults (be, get_account_cb, NULL);
|
||||||
|
|
||||||
acc = xaccAccountLookup (acct_guid, be->book);
|
|
||||||
/* restore any kvp data associated with the transaction and splits */
|
/* restore any kvp data associated with the transaction and splits */
|
||||||
|
if (acc)
|
||||||
|
{
|
||||||
if (acc->idata)
|
if (acc->idata)
|
||||||
{
|
{
|
||||||
acc->kvp_data = pgendKVPFetch (be, acc->idata, acc->kvp_data);
|
acc->kvp_data = pgendKVPFetch (be, acc->idata, acc->kvp_data);
|
||||||
@ -401,13 +458,14 @@ pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
|
|||||||
|
|
||||||
acc->version_check = be->version_check;
|
acc->version_check = be->version_check;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* re-enable events to the backend and GUI */
|
/* re-enable events to the backend and GUI */
|
||||||
pgendEnable(be);
|
pgendEnable(be);
|
||||||
gnc_engine_resume_events();
|
gnc_engine_resume_events();
|
||||||
|
|
||||||
LEAVE (" ");
|
LEAVE (" ");
|
||||||
return engine_data_is_newer;
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ============================================================= */
|
/* ============================================================= */
|
||||||
|
@ -25,15 +25,19 @@
|
|||||||
#define POSTGRES_ACCOUNT_H
|
#define POSTGRES_ACCOUNT_H
|
||||||
|
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
|
#include "gnc-book.h"
|
||||||
#include "guid.h"
|
#include "guid.h"
|
||||||
|
|
||||||
#include "PostgresBackend.h"
|
#include "PostgresBackend.h"
|
||||||
|
|
||||||
AccountGroup * pgendGetAllAccounts (PGBackend *be, AccountGroup *topgrp);
|
void pgendGetAllAccountsInBook (PGBackend *be, GNCBook *);
|
||||||
|
|
||||||
|
void pgendGetAllAccounts (PGBackend *be);
|
||||||
|
|
||||||
void pgendStoreGroup (PGBackend *be, AccountGroup *grp);
|
void pgendStoreGroup (PGBackend *be, AccountGroup *grp);
|
||||||
void pgendStoreGroupNoLock (PGBackend *be, AccountGroup *grp,
|
void pgendStoreGroupNoLock (PGBackend *be, AccountGroup *grp,
|
||||||
gboolean do_mark, gboolean do_check_version);
|
gboolean do_mark, gboolean do_check_version);
|
||||||
int pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid);
|
Account * pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid);
|
||||||
|
|
||||||
void pgend_account_commit_edit (Backend * bend, Account * acct);
|
void pgend_account_commit_edit (Backend * bend, Account * acct);
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ pgendStoreBook (PGBackend *be, GNCBook *book)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
get_book_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
get_one_book_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||||
{
|
{
|
||||||
GNCBook *book = (GNCBook *) data;
|
GNCBook *book = (GNCBook *) data;
|
||||||
GUID guid;
|
GUID guid;
|
||||||
@ -166,7 +166,7 @@ pgendGetBook (PGBackend *be, GNCBook *book)
|
|||||||
*/
|
*/
|
||||||
bufp = "SELECT * FROM gncBook WHERE book_open='y';";
|
bufp = "SELECT * FROM gncBook WHERE book_open='y';";
|
||||||
SEND_QUERY (be, bufp, );
|
SEND_QUERY (be, bufp, );
|
||||||
pgendGetResults (be, get_book_cb, book);
|
pgendGetResults (be, get_one_book_cb, book);
|
||||||
|
|
||||||
if (0 != book->idata)
|
if (0 != book->idata)
|
||||||
{
|
{
|
||||||
@ -176,6 +176,73 @@ pgendGetBook (PGBackend *be, GNCBook *book)
|
|||||||
LEAVE (" ");
|
LEAVE (" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ============================================================= */
|
||||||
|
/* The pgendGetAllBooks() routine creates an empty book
|
||||||
|
* for each book in the database.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static gpointer
|
||||||
|
get_book_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||||
|
{
|
||||||
|
BookList *blist = (BookList *) data;
|
||||||
|
BookList *node;
|
||||||
|
GNCBook *book;
|
||||||
|
GUID guid;
|
||||||
|
|
||||||
|
PINFO ("book GUID=%s", DB_GET_VAL("bookGUID",j));
|
||||||
|
guid = nullguid; /* just in case the read fails ... */
|
||||||
|
string_to_guid (DB_GET_VAL("bookGUID",j), &guid);
|
||||||
|
|
||||||
|
/* first, lets see if we've already got this one */
|
||||||
|
book = NULL;
|
||||||
|
for (node=blist; node; node=node->next)
|
||||||
|
{
|
||||||
|
book = node->data;
|
||||||
|
if (guid_equal (&book->guid, &guid)) break;
|
||||||
|
book = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!book)
|
||||||
|
{
|
||||||
|
book = gnc_book_new();
|
||||||
|
gnc_book_set_guid (book, guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
book->book_open = (DB_GET_VAL("book_open",j))[0];
|
||||||
|
book->version = atoi(DB_GET_VAL("version",j));
|
||||||
|
book->idata = atoi(DB_GET_VAL("iguid",j));
|
||||||
|
|
||||||
|
return blist;
|
||||||
|
}
|
||||||
|
|
||||||
|
BookList *
|
||||||
|
pgendGetAllBooks (PGBackend *be, BookList *blist)
|
||||||
|
{
|
||||||
|
BookList *node;
|
||||||
|
char * bufp;
|
||||||
|
|
||||||
|
ENTER ("be=%p", be);
|
||||||
|
if (!be) return NULL;
|
||||||
|
|
||||||
|
/* Get them ALL */
|
||||||
|
bufp = "SELECT * FROM gncBook;";
|
||||||
|
SEND_QUERY (be, bufp, NULL);
|
||||||
|
blist = pgendGetResults (be, get_book_cb, blist);
|
||||||
|
|
||||||
|
/* get the KVP data for each book too */
|
||||||
|
for (node=blist; node; node=node->next)
|
||||||
|
{
|
||||||
|
GNCBook *book = node->data;
|
||||||
|
if (0 != book->idata)
|
||||||
|
{
|
||||||
|
book->kvp_data = pgendKVPFetch (be, book->idata, book->kvp_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LEAVE (" ");
|
||||||
|
return blist;
|
||||||
|
}
|
||||||
|
|
||||||
/* ============================================================= */
|
/* ============================================================= */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -25,10 +25,13 @@
|
|||||||
#define POSTGRES_BOOK_H
|
#define POSTGRES_BOOK_H
|
||||||
|
|
||||||
#include "gnc-book.h"
|
#include "gnc-book.h"
|
||||||
|
#include "gnc-engine.h"
|
||||||
#include "guid.h"
|
#include "guid.h"
|
||||||
|
|
||||||
#include "PostgresBackend.h"
|
#include "PostgresBackend.h"
|
||||||
|
|
||||||
|
BookList * pgendGetAllBooks (PGBackend *be, BookList *);
|
||||||
|
|
||||||
void pgendGetBook (PGBackend *be, GNCBook *book);
|
void pgendGetBook (PGBackend *be, GNCBook *book);
|
||||||
void pgendStoreBookNoLock (PGBackend *be, GNCBook *book, int do_check_version);
|
void pgendStoreBookNoLock (PGBackend *be, GNCBook *book, int do_check_version);
|
||||||
void pgendStoreBook (PGBackend *be, GNCBook *book);
|
void pgendStoreBook (PGBackend *be, GNCBook *book);
|
||||||
|
@ -87,7 +87,7 @@ pgendAccountRecomputeAllCheckpoints (PGBackend *be, const GUID *acct_guid)
|
|||||||
ENTER("be=%p", be);
|
ENTER("be=%p", be);
|
||||||
|
|
||||||
guid_string = guid_to_string (acct_guid);
|
guid_string = guid_to_string (acct_guid);
|
||||||
acc = xaccAccountLookup (acct_guid, be->book);
|
acc = pgendAccountLookup (be, acct_guid);
|
||||||
commodity_name =
|
commodity_name =
|
||||||
gnc_commodity_get_unique_name (xaccAccountGetCommodity(acc));
|
gnc_commodity_get_unique_name (xaccAccountGetCommodity(acc));
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ pgendProcessEvents (Backend *bend)
|
|||||||
GNCIdType local_obj_type;
|
GNCIdType local_obj_type;
|
||||||
|
|
||||||
/* lets see if the local cache has this item in it */
|
/* lets see if the local cache has this item in it */
|
||||||
local_obj_type = xaccGUIDType (&(ev->guid), be->book);
|
local_obj_type = pgendGUIDType (be, &(ev->guid));
|
||||||
if ((local_obj_type != GNC_ID_NONE) &&
|
if ((local_obj_type != GNC_ID_NONE) &&
|
||||||
(safe_strcmp (local_obj_type, ev->obj_type)))
|
(safe_strcmp (local_obj_type, ev->obj_type)))
|
||||||
{
|
{
|
||||||
@ -292,16 +292,20 @@ pgendProcessEvents (Backend *bend)
|
|||||||
PERR ("account: cant' happen !!!!!!!");
|
PERR ("account: cant' happen !!!!!!!");
|
||||||
break;
|
break;
|
||||||
case GNC_EVENT_CREATE:
|
case GNC_EVENT_CREATE:
|
||||||
case GNC_EVENT_MODIFY:
|
case GNC_EVENT_MODIFY: {
|
||||||
|
Account *acc;
|
||||||
|
|
||||||
/* if the remote user created an account, mirror it here */
|
/* if the remote user created an account, mirror it here */
|
||||||
pgendCopyAccountToEngine (be, &(ev->guid));
|
acc = pgendCopyAccountToEngine (be, &(ev->guid));
|
||||||
xaccGroupMarkSaved (pgendGetTopGroup (be));
|
xaccGroupMarkSaved (xaccAccountGetRoot(acc));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case GNC_EVENT_DESTROY: {
|
case GNC_EVENT_DESTROY: {
|
||||||
Account * acc = xaccAccountLookup (&(ev->guid), be->book);
|
Account * acc = pgendAccountLookup (be, &(ev->guid));
|
||||||
|
AccountGroup *topgrp = xaccAccountGetRoot(acc);
|
||||||
xaccAccountBeginEdit (acc);
|
xaccAccountBeginEdit (acc);
|
||||||
xaccAccountDestroy (acc);
|
xaccAccountDestroy (acc);
|
||||||
xaccGroupMarkSaved (pgendGetTopGroup (be));
|
xaccGroupMarkSaved (topgrp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,7 +331,7 @@ pgendProcessEvents (Backend *bend)
|
|||||||
pgendCopyTransactionToEngine (be, &(ev->guid));
|
pgendCopyTransactionToEngine (be, &(ev->guid));
|
||||||
break;
|
break;
|
||||||
case GNC_EVENT_DESTROY: {
|
case GNC_EVENT_DESTROY: {
|
||||||
Transaction *trans = xaccTransLookup (&(ev->guid), be->book);
|
Transaction *trans = pgendTransLookup (be, &(ev->guid));
|
||||||
xaccTransBeginEdit (trans);
|
xaccTransBeginEdit (trans);
|
||||||
xaccTransDestroy (trans);
|
xaccTransDestroy (trans);
|
||||||
xaccTransCommitEdit (trans);
|
xaccTransCommitEdit (trans);
|
||||||
@ -360,7 +364,7 @@ pgendProcessEvents (Backend *bend)
|
|||||||
* the guid above */
|
* the guid above */
|
||||||
if (GNC_ID_NONE == local_obj_type)
|
if (GNC_ID_NONE == local_obj_type)
|
||||||
{
|
{
|
||||||
local_obj_type = xaccGUIDType (&(ev->guid), be->book);
|
local_obj_type = pgendGUIDType (be, &(ev->guid));
|
||||||
if (GNC_ID_NONE != local_obj_type)
|
if (GNC_ID_NONE != local_obj_type)
|
||||||
{
|
{
|
||||||
gnc_engine_generate_event (&(ev->guid), GNC_EVENT_CREATE);
|
gnc_engine_generate_event (&(ev->guid), GNC_EVENT_CREATE);
|
||||||
@ -368,7 +372,7 @@ pgendProcessEvents (Backend *bend)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
local_obj_type = xaccGUIDType (&(ev->guid), be->book);
|
local_obj_type = pgendGUIDType (be, &(ev->guid));
|
||||||
if (GNC_ID_NONE != local_obj_type)
|
if (GNC_ID_NONE != local_obj_type)
|
||||||
{
|
{
|
||||||
gnc_engine_generate_event (&(ev->guid), GNC_EVENT_MODIFY);
|
gnc_engine_generate_event (&(ev->guid), GNC_EVENT_MODIFY);
|
||||||
|
@ -271,7 +271,7 @@ get_price_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
|||||||
|
|
||||||
/* First, lets see if we've already got this one */
|
/* First, lets see if we've already got this one */
|
||||||
string_to_guid (DB_GET_VAL ("priceGuid", j), &guid);
|
string_to_guid (DB_GET_VAL ("priceGuid", j), &guid);
|
||||||
pr = gnc_price_lookup (&guid, be->book);
|
pr = pgendPriceLookup (be, &guid);
|
||||||
|
|
||||||
if (!pr)
|
if (!pr)
|
||||||
{
|
{
|
||||||
@ -351,7 +351,7 @@ pgendGetAllPrices (PGBackend *be, GNCPriceDB *prdb)
|
|||||||
/* ============================================================= */
|
/* ============================================================= */
|
||||||
|
|
||||||
void
|
void
|
||||||
pgendPriceLookup (Backend *bend, GNCPriceLookup *look)
|
pgendPriceFind (Backend *bend, GNCPriceLookup *look)
|
||||||
{
|
{
|
||||||
PGBackend *be = (PGBackend *)bend;
|
PGBackend *be = (PGBackend *)bend;
|
||||||
const char * commodity_str;
|
const char * commodity_str;
|
||||||
@ -366,9 +366,9 @@ pgendPriceLookup (Backend *bend, GNCPriceLookup *look)
|
|||||||
if (LOOKUP_NEAREST_IN_TIME == look->type)
|
if (LOOKUP_NEAREST_IN_TIME == look->type)
|
||||||
{
|
{
|
||||||
look->type = LOOKUP_LATEST_BEFORE;
|
look->type = LOOKUP_LATEST_BEFORE;
|
||||||
pgendPriceLookup (bend, look);
|
pgendPriceFind (bend, look);
|
||||||
look->type = LOOKUP_EARLIEST_AFTER;
|
look->type = LOOKUP_EARLIEST_AFTER;
|
||||||
pgendPriceLookup (bend, look);
|
pgendPriceFind (bend, look);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ void pgendGetCommodity (PGBackend *be, const char * unique_name);
|
|||||||
void pgendStorePriceDB (PGBackend *be, GNCPriceDB *prdb);
|
void pgendStorePriceDB (PGBackend *be, GNCPriceDB *prdb);
|
||||||
void pgendStorePriceDBNoLock (PGBackend *be, GNCPriceDB *prdb);
|
void pgendStorePriceDBNoLock (PGBackend *be, GNCPriceDB *prdb);
|
||||||
GNCPriceDB * pgendGetAllPrices (PGBackend *be, GNCPriceDB *prdb);
|
GNCPriceDB * pgendGetAllPrices (PGBackend *be, GNCPriceDB *prdb);
|
||||||
void pgendPriceLookup (Backend *bend, GNCPriceLookup *look);
|
void pgendPriceFind (Backend *bend, GNCPriceLookup *look);
|
||||||
|
|
||||||
|
|
||||||
void pgend_price_begin_edit (Backend * bend, GNCPrice *pr);
|
void pgend_price_begin_edit (Backend * bend, GNCPrice *pr);
|
||||||
|
@ -118,7 +118,7 @@ delete_list_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
|||||||
|
|
||||||
/* If the database has splits that the engine doesn't,
|
/* If the database has splits that the engine doesn't,
|
||||||
* collect 'em up & we'll have to delete em */
|
* collect 'em up & we'll have to delete em */
|
||||||
if (NULL == xaccSplitLookup (&guid, be->book))
|
if (NULL == pgendSplitLookup (be, &guid))
|
||||||
{
|
{
|
||||||
DeleteTransInfo *dti;
|
DeleteTransInfo *dti;
|
||||||
|
|
||||||
@ -469,10 +469,10 @@ pgendCopySplitsToEngine (PGBackend *be, Transaction *trans)
|
|||||||
PINFO ("split GUID=%s", DB_GET_VAL("entryGUID",j));
|
PINFO ("split GUID=%s", DB_GET_VAL("entryGUID",j));
|
||||||
guid = nullguid; /* just in case the read fails ... */
|
guid = nullguid; /* just in case the read fails ... */
|
||||||
string_to_guid (DB_GET_VAL("entryGUID",j), &guid);
|
string_to_guid (DB_GET_VAL("entryGUID",j), &guid);
|
||||||
s = xaccSplitLookup (&guid, be->book);
|
s = pgendSplitLookup (be, &guid);
|
||||||
if (!s)
|
if (!s)
|
||||||
{
|
{
|
||||||
s = xaccMallocSplit(be->book);
|
s = xaccMallocSplit(trans->book);
|
||||||
xaccSplitSetGUID(s, &guid);
|
xaccSplitSetGUID(s, &guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,7 +490,7 @@ pgendCopySplitsToEngine (PGBackend *be, Transaction *trans)
|
|||||||
/* next, find the account that this split goes into */
|
/* next, find the account that this split goes into */
|
||||||
guid = nullguid; /* just in case the read fails ... */
|
guid = nullguid; /* just in case the read fails ... */
|
||||||
string_to_guid (DB_GET_VAL("accountGUID",j), &guid);
|
string_to_guid (DB_GET_VAL("accountGUID",j), &guid);
|
||||||
acc = xaccAccountLookup (&guid, be->book);
|
acc = pgendAccountLookup (be, &guid);
|
||||||
|
|
||||||
if (!acc)
|
if (!acc)
|
||||||
{
|
{
|
||||||
@ -564,12 +564,11 @@ pgendCopySplitsToEngine (PGBackend *be, Transaction *trans)
|
|||||||
|
|
||||||
/* account could have been pulled in by a previous
|
/* account could have been pulled in by a previous
|
||||||
* iteration of this loop. */
|
* iteration of this loop. */
|
||||||
account = xaccAccountLookup (&sri->account_guid, be->book);
|
account = pgendAccountLookup (be, &sri->account_guid);
|
||||||
|
|
||||||
if (!account)
|
if (!account)
|
||||||
{
|
{
|
||||||
pgendCopyAccountToEngine (be, &sri->account_guid);
|
account = pgendCopyAccountToEngine (be, &sri->account_guid);
|
||||||
account = xaccAccountLookup (&sri->account_guid, be->book);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account)
|
if (account)
|
||||||
@ -661,7 +660,7 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
|
|||||||
pgendDisable(be);
|
pgendDisable(be);
|
||||||
|
|
||||||
/* first, see if we already have such a transaction */
|
/* first, see if we already have such a transaction */
|
||||||
trans = xaccTransLookup (trans_guid, be->book);
|
trans = pgendTransLookup (be, trans_guid);
|
||||||
if (!trans)
|
if (!trans)
|
||||||
{
|
{
|
||||||
trans = xaccMallocTransaction(be->book);
|
trans = xaccMallocTransaction(be->book);
|
||||||
@ -886,7 +885,7 @@ pgendSyncTransaction (PGBackend *be, GUID *trans_guid)
|
|||||||
"\tto the database. This mode of operation is\n"
|
"\tto the database. This mode of operation is\n"
|
||||||
"\tguarenteed to clobber other user's updates.\n");
|
"\tguarenteed to clobber other user's updates.\n");
|
||||||
|
|
||||||
trans = xaccTransLookup (trans_guid);
|
trans = pgendTransLookup (be, trans_guid);
|
||||||
|
|
||||||
/* hack alert -- basically, we should use the pgend_commit_transaction
|
/* hack alert -- basically, we should use the pgend_commit_transaction
|
||||||
* routine instead, and in fact, 'StoreTransaction'
|
* routine instead, and in fact, 'StoreTransaction'
|
||||||
|
@ -65,7 +65,7 @@ get_mass_trans_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
|||||||
|
|
||||||
/* first, see if we already have such a transaction */
|
/* first, see if we already have such a transaction */
|
||||||
string_to_guid (DB_GET_VAL("transGUID",j), &trans_guid);
|
string_to_guid (DB_GET_VAL("transGUID",j), &trans_guid);
|
||||||
trans = xaccTransLookup (&trans_guid, be->book);
|
trans = pgendTransLookup (be, &trans_guid);
|
||||||
if (trans)
|
if (trans)
|
||||||
{
|
{
|
||||||
/* If transaction already exists, determine whose data is
|
/* If transaction already exists, determine whose data is
|
||||||
@ -116,7 +116,7 @@ get_mass_trans_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
|||||||
static gpointer
|
static gpointer
|
||||||
get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
||||||
{
|
{
|
||||||
Transaction *trans;
|
Transaction *trans=NULL;
|
||||||
Account *acc;
|
Account *acc;
|
||||||
Split *s;
|
Split *s;
|
||||||
GUID guid;
|
GUID guid;
|
||||||
@ -132,7 +132,7 @@ get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
|||||||
PINFO ("split GUID=%s", DB_GET_VAL("entryGUID",j));
|
PINFO ("split GUID=%s", DB_GET_VAL("entryGUID",j));
|
||||||
guid = nullguid; /* just in case the read fails ... */
|
guid = nullguid; /* just in case the read fails ... */
|
||||||
string_to_guid (DB_GET_VAL("entryGUID",j), &guid);
|
string_to_guid (DB_GET_VAL("entryGUID",j), &guid);
|
||||||
s = xaccSplitLookup (&guid, be->book);
|
s = pgendSplitLookup (be, &guid);
|
||||||
if (!s)
|
if (!s)
|
||||||
{
|
{
|
||||||
s = xaccMallocSplit(be->book);
|
s = xaccMallocSplit(be->book);
|
||||||
@ -151,7 +151,7 @@ get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
|||||||
|
|
||||||
guid = nullguid; /* just in case the read fails ... */
|
guid = nullguid; /* just in case the read fails ... */
|
||||||
string_to_guid (DB_GET_VAL("transGUID",j), &guid);
|
string_to_guid (DB_GET_VAL("transGUID",j), &guid);
|
||||||
trans = xaccTransLookup (&guid, be->book);
|
trans = pgendTransLookup (be, &guid);
|
||||||
if (!trans)
|
if (!trans)
|
||||||
{
|
{
|
||||||
PERR ("trans not found, will delete this split\n"
|
PERR ("trans not found, will delete this split\n"
|
||||||
@ -170,7 +170,7 @@ get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
|||||||
/* next, find the account that this split goes into */
|
/* next, find the account that this split goes into */
|
||||||
guid = nullguid; /* just in case the read fails ... */
|
guid = nullguid; /* just in case the read fails ... */
|
||||||
string_to_guid (DB_GET_VAL("accountGUID",j), &guid);
|
string_to_guid (DB_GET_VAL("accountGUID",j), &guid);
|
||||||
acc = xaccAccountLookup (&guid, be->book);
|
acc = pgendAccountLookup (be, &guid);
|
||||||
if (!acc)
|
if (!acc)
|
||||||
{
|
{
|
||||||
PERR ("account not found, will delete this split\n"
|
PERR ("account not found, will delete this split\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user