mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add account update notification
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4604 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
99efc0b6e8
commit
cf8e14f3a8
@ -368,6 +368,64 @@ pgendGetAllAccounts (PGBackend *be, AccountGroup *topgrp)
|
||||
}
|
||||
|
||||
|
||||
/* ============================================================= */
|
||||
|
||||
int
|
||||
pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid)
|
||||
{
|
||||
char *pbuff;
|
||||
Account *acc;
|
||||
PGresult *result;
|
||||
int engine_data_is_newer = 0;
|
||||
int i, j, nrows;
|
||||
|
||||
|
||||
ENTER ("be=%p", be);
|
||||
if (!be || !acct_guid) return 0;
|
||||
|
||||
/* disable callbacks into the backend, and events to GUI */
|
||||
gnc_engine_suspend_events();
|
||||
pgendDisable(be);
|
||||
|
||||
/* first, see if we already have such an account */
|
||||
acc = xaccAccountLookup (acct_guid);
|
||||
if (!acc)
|
||||
{
|
||||
engine_data_is_newer = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
engine_data_is_newer = - pgendAccountCompareVersion (be, acc);
|
||||
}
|
||||
|
||||
if (0 > engine_data_is_newer)
|
||||
{
|
||||
/* build the sql query to get the account */
|
||||
pbuff = be->buff;
|
||||
pbuff[0] = 0;
|
||||
pbuff = stpcpy (pbuff,
|
||||
"SELECT * FROM gncAccount WHERE accountGuid='");
|
||||
pbuff = guid_to_string_buff(acct_guid, pbuff);
|
||||
pbuff = stpcpy (pbuff, "';");
|
||||
|
||||
SEND_QUERY (be,be->buff, 0);
|
||||
pgendGetResults (be, get_account_cb, be->topgroup);
|
||||
|
||||
acc = xaccAccountLookup (acct_guid);
|
||||
/* restore any kvp data associated with the transaction and splits */
|
||||
acc->kvp_data = pgendKVPFetch (be, &(acc->guid), acc->kvp_data);
|
||||
|
||||
pgendGetAccountCurrencyHack (be, acc);
|
||||
}
|
||||
|
||||
/* re-enable events to the backend and GUI */
|
||||
pgendEnable(be);
|
||||
gnc_engine_resume_events();
|
||||
|
||||
LEAVE (" ");
|
||||
return engine_data_is_newer;
|
||||
}
|
||||
|
||||
/* ============================================================= */
|
||||
/* ============================================================= */
|
||||
/* HIGHER LEVEL ROUTINES AND BACKEND PROPER */
|
||||
|
@ -33,6 +33,8 @@ AccountGroup * pgendGetAllAccounts (PGBackend *be, AccountGroup *topgrp);
|
||||
void pgendStoreGroup (PGBackend *be, AccountGroup *grp);
|
||||
void pgendStoreGroupNoLock (PGBackend *be, AccountGroup *grp,
|
||||
gboolean do_mark, gboolean do_check_version);
|
||||
int pgendCopyAccountToEngine (PGBackend *be, const GUID *acct_guid);
|
||||
|
||||
int pgend_account_commit_edit (Backend * bend, Account * acct);
|
||||
|
||||
#endif /* __POSTGRES_ACCOUNT_H__ */
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "GNCIdP.h"
|
||||
|
||||
#include "PostgresBackend.h"
|
||||
#include "account.h"
|
||||
#include "putil.h"
|
||||
#include "txn.h"
|
||||
|
||||
@ -257,6 +258,23 @@ pgendProcessEvents (Backend *bend)
|
||||
{
|
||||
be->last_account = ev->stamp;
|
||||
}
|
||||
switch (ev->type)
|
||||
{
|
||||
default:
|
||||
PERR ("account: cant' happen !!!!!!!");
|
||||
break;
|
||||
case GNC_EVENT_CREATE:
|
||||
case GNC_EVENT_MODIFY:
|
||||
pgendCopyAccountToEngine (be, &(ev->guid));
|
||||
break;
|
||||
case GNC_EVENT_DESTROY: {
|
||||
Account * acc = xaccAccountLookup (&(ev->guid));
|
||||
xaccAccountBeginEdit (acc);
|
||||
xaccAccountDestroy (acc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case GNC_ID_TRANS:
|
||||
@ -268,7 +286,7 @@ pgendProcessEvents (Backend *bend)
|
||||
{
|
||||
default:
|
||||
case GNC_EVENT_CREATE:
|
||||
PERR ("cant' happen !!!!!!!");
|
||||
PERR ("transaction: cant' happen !!!!!!!");
|
||||
break;
|
||||
case GNC_EVENT_MODIFY:
|
||||
pgendCopyTransactionToEngine (be, &(ev->guid));
|
||||
|
Loading…
Reference in New Issue
Block a user