mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Work on moving entity tables to sessions.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5463 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
891ac0e2b6
commit
2813e46549
@ -802,7 +802,8 @@ equity_base_name (GNCEquityType equity_type)
|
|||||||
Account *
|
Account *
|
||||||
gnc_find_or_create_equity_account (AccountGroup *group,
|
gnc_find_or_create_equity_account (AccountGroup *group,
|
||||||
GNCEquityType equity_type,
|
GNCEquityType equity_type,
|
||||||
gnc_commodity *currency)
|
gnc_commodity *currency,
|
||||||
|
GNCSession *session)
|
||||||
{
|
{
|
||||||
Account *parent;
|
Account *parent;
|
||||||
Account *account;
|
Account *account;
|
||||||
@ -868,7 +869,7 @@ gnc_find_or_create_equity_account (AccountGroup *group,
|
|||||||
if (parent && xaccAccountGetType (parent) != EQUITY)
|
if (parent && xaccAccountGetType (parent) != EQUITY)
|
||||||
parent == NULL;
|
parent == NULL;
|
||||||
|
|
||||||
account = xaccMallocAccount ();
|
account = xaccMallocAccount (session);
|
||||||
|
|
||||||
xaccAccountBeginEdit (account);
|
xaccAccountBeginEdit (account);
|
||||||
|
|
||||||
@ -895,7 +896,8 @@ gnc_find_or_create_equity_account (AccountGroup *group,
|
|||||||
gboolean
|
gboolean
|
||||||
gnc_account_create_opening_balance (Account *account,
|
gnc_account_create_opening_balance (Account *account,
|
||||||
gnc_numeric balance,
|
gnc_numeric balance,
|
||||||
time_t date)
|
time_t date,
|
||||||
|
GNCSession *session)
|
||||||
{
|
{
|
||||||
Account *equity_account;
|
Account *equity_account;
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
@ -909,7 +911,8 @@ gnc_account_create_opening_balance (Account *account,
|
|||||||
equity_account =
|
equity_account =
|
||||||
gnc_find_or_create_equity_account (xaccAccountGetRoot (account),
|
gnc_find_or_create_equity_account (xaccAccountGetRoot (account),
|
||||||
EQUITY_OPENING_BALANCE,
|
EQUITY_OPENING_BALANCE,
|
||||||
xaccAccountGetCommodity (account));
|
xaccAccountGetCommodity (account),
|
||||||
|
session);
|
||||||
if (!equity_account)
|
if (!equity_account)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -80,8 +80,11 @@ gnc_numeric gnc_ui_convert_balance_to_currency(gnc_numeric balance,
|
|||||||
gnc_numeric gnc_ui_account_get_balance (Account *account,
|
gnc_numeric gnc_ui_account_get_balance (Account *account,
|
||||||
gboolean include_children);
|
gboolean include_children);
|
||||||
|
|
||||||
gnc_numeric gnc_ui_account_get_reconciled_balance(Account *account, gboolean include_children);
|
gnc_numeric gnc_ui_account_get_reconciled_balance(Account *account,
|
||||||
gnc_numeric gnc_ui_account_get_balance_as_of_date (Account *account, time_t date, gboolean include_children);
|
gboolean include_children);
|
||||||
|
gnc_numeric gnc_ui_account_get_balance_as_of_date (Account *account,
|
||||||
|
time_t date,
|
||||||
|
gboolean include_children);
|
||||||
|
|
||||||
const char * gnc_get_reconcile_str (char reconciled_flag);
|
const char * gnc_get_reconcile_str (char reconciled_flag);
|
||||||
|
|
||||||
@ -94,10 +97,12 @@ typedef enum
|
|||||||
|
|
||||||
Account * gnc_find_or_create_equity_account (AccountGroup *group,
|
Account * gnc_find_or_create_equity_account (AccountGroup *group,
|
||||||
GNCEquityType equity_type,
|
GNCEquityType equity_type,
|
||||||
gnc_commodity *currency);
|
gnc_commodity *currency,
|
||||||
|
GNCSession *session);
|
||||||
gboolean gnc_account_create_opening_balance (Account *account,
|
gboolean gnc_account_create_opening_balance (Account *account,
|
||||||
gnc_numeric balance,
|
gnc_numeric balance,
|
||||||
time_t date);
|
time_t date,
|
||||||
|
GNCSession *session);
|
||||||
|
|
||||||
char * gnc_account_get_full_name (Account *account);
|
char * gnc_account_get_full_name (Account *account);
|
||||||
|
|
||||||
|
@ -102,6 +102,14 @@
|
|||||||
'()
|
'()
|
||||||
"Get the current top-level book.")
|
"Get the current top-level book.")
|
||||||
|
|
||||||
|
(gw:wrap-function
|
||||||
|
mod
|
||||||
|
'gnc:get-current-session
|
||||||
|
'<gnc:Session*>
|
||||||
|
"gnc_get_current_session"
|
||||||
|
'()
|
||||||
|
"Get the current session.")
|
||||||
|
|
||||||
(gw:wrap-function
|
(gw:wrap-function
|
||||||
mod
|
mod
|
||||||
'gnc:exp-parser-init
|
'gnc:exp-parser-init
|
||||||
|
@ -377,7 +377,7 @@ dom_tree_to_account (xmlNodePtr node, GNCSession * session)
|
|||||||
Account *accToRet;
|
Account *accToRet;
|
||||||
gboolean successful;
|
gboolean successful;
|
||||||
|
|
||||||
accToRet = xaccMallocAccount();
|
accToRet = xaccMallocAccount(session);
|
||||||
xaccAccountBeginEdit(accToRet);
|
xaccAccountBeginEdit(accToRet);
|
||||||
|
|
||||||
act_pdata.account = accToRet;
|
act_pdata.account = accToRet;
|
||||||
|
@ -424,7 +424,7 @@ gnc_schedXaction_end_handler(gpointer data_for_children,
|
|||||||
|
|
||||||
g_return_val_if_fail( tree, FALSE );
|
g_return_val_if_fail( tree, FALSE );
|
||||||
|
|
||||||
sx = xaccSchedXactionMalloc( NULL );
|
sx = xaccSchedXactionMalloc( gdata->sessiondata );
|
||||||
|
|
||||||
/* FIXME: this should be removed somewhere near 1.8 release time. */
|
/* FIXME: this should be removed somewhere near 1.8 release time. */
|
||||||
{
|
{
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
* *
|
* *
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
#ifndef _GNC_XML_HELPER_H_
|
#ifndef GNC_XML_HELPER_H
|
||||||
#define _GNC_XML_HELPER_H_
|
#define GNC_XML_HELPER_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
@ -250,14 +250,15 @@ cvt_potential_prices_to_pricedb_and_cleanup(GNCPriceDB **prices,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** PROTOTYPES ******************************************************/
|
/** PROTOTYPES ******************************************************/
|
||||||
static Account *locateAccount (int acc_id);
|
static Account *locateAccount (int acc_id, GNCSession *session);
|
||||||
|
|
||||||
static AccountGroup *readGroup( GNCSession *, int fd, Account *, int token );
|
static AccountGroup *readGroup( GNCSession *, int fd, Account *, int token );
|
||||||
static Account *readAccount( GNCSession *session, int fd,
|
static Account *readAccount( GNCSession *session, int fd,
|
||||||
AccountGroup *, int token );
|
AccountGroup *, int token );
|
||||||
static gboolean readAccInfo( int fd, Account *, int token );
|
static gboolean readAccInfo( int fd, Account *, int token );
|
||||||
static Transaction *readTransaction( int fd, Account *, int token );
|
static Transaction *readTransaction( GNCSession *session,
|
||||||
static Split *readSplit( int fd, int token );
|
int fd, Account *, int token );
|
||||||
|
static Split *readSplit( GNCSession *session, int fd, int token );
|
||||||
static char *readString( int fd, int token );
|
static char *readString( int fd, int token );
|
||||||
static time_t readDMYDate( int fd, int token );
|
static time_t readDMYDate( int fd, int token );
|
||||||
static int readTSDate( int fd, Timespec *, int token );
|
static int readTSDate( int fd, Timespec *, int token );
|
||||||
@ -487,7 +488,7 @@ gnc_load_financials_from_fd(GNCSession *session, int fd)
|
|||||||
error_code = ERR_FILEIO_FILE_BAD_READ;
|
error_code = ERR_FILEIO_FILE_BAD_READ;
|
||||||
|
|
||||||
/* create a lost account, put the missing accounts there */
|
/* create a lost account, put the missing accounts there */
|
||||||
acc = xaccMallocAccount();
|
acc = xaccMallocAccount(session);
|
||||||
xaccAccountBeginEdit (acc);
|
xaccAccountBeginEdit (acc);
|
||||||
xaccAccountSetName (acc, _("Lost Accounts"));
|
xaccAccountSetName (acc, _("Lost Accounts"));
|
||||||
acc -> children = holder;
|
acc -> children = holder;
|
||||||
@ -646,11 +647,11 @@ readAccount( GNCSession *session, int fd, AccountGroup *grp, int token )
|
|||||||
err = read( fd, &accID, sizeof(int) );
|
err = read( fd, &accID, sizeof(int) );
|
||||||
if( err != sizeof(int) ) { return NULL; }
|
if( err != sizeof(int) ) { return NULL; }
|
||||||
XACC_FLIP_INT (accID);
|
XACC_FLIP_INT (accID);
|
||||||
acc = locateAccount (accID);
|
acc = locateAccount (accID, session);
|
||||||
/* locateAccountAlways should always accounts that are open for
|
/* locateAccountAlways should always accounts that are open for
|
||||||
editing in this situation */
|
editing in this situation */
|
||||||
} else {
|
} else {
|
||||||
acc = xaccMallocAccount();
|
acc = xaccMallocAccount(session);
|
||||||
xaccGroupInsertAccount (holder, acc);
|
xaccGroupInsertAccount (holder, acc);
|
||||||
xaccAccountBeginEdit (acc);
|
xaccAccountBeginEdit (acc);
|
||||||
}
|
}
|
||||||
@ -771,7 +772,7 @@ readAccount( GNCSession *session, int fd, AccountGroup *grp, int token )
|
|||||||
/* read the transactions */
|
/* read the transactions */
|
||||||
for( i=0; i<numTrans; i++ ) {
|
for( i=0; i<numTrans; i++ ) {
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
trans = readTransaction( fd, acc, token );
|
trans = readTransaction(session, fd, acc, token );
|
||||||
if(trans == NULL ) {
|
if(trans == NULL ) {
|
||||||
PERR ("Short Transaction Read: \n"
|
PERR ("Short Transaction Read: \n"
|
||||||
"\texpected %d got %d transactions \n", numTrans, i);
|
"\texpected %d got %d transactions \n", numTrans, i);
|
||||||
@ -823,8 +824,8 @@ readAccount( GNCSession *session, int fd, AccountGroup *grp, int token )
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static Account *
|
static Account *
|
||||||
locateAccount (int acc_id) {
|
locateAccount (int acc_id, GNCSession *session)
|
||||||
|
{
|
||||||
Account * acc;
|
Account * acc;
|
||||||
/* negative account ids denote no account */
|
/* negative account ids denote no account */
|
||||||
if (0 > acc_id) return NULL;
|
if (0 > acc_id) return NULL;
|
||||||
@ -841,7 +842,7 @@ locateAccount (int acc_id) {
|
|||||||
|
|
||||||
/* if neither, then it does not yet exist. Create it.
|
/* if neither, then it does not yet exist. Create it.
|
||||||
* Put it in the drunk tank. */
|
* Put it in the drunk tank. */
|
||||||
acc = xaccMallocAccount ();
|
acc = xaccMallocAccount (session);
|
||||||
xaccAccountBeginEdit(acc);
|
xaccAccountBeginEdit(acc);
|
||||||
g_hash_table_insert(ids_to_unfinished_accounts,
|
g_hash_table_insert(ids_to_unfinished_accounts,
|
||||||
(gpointer) acc_id,
|
(gpointer) acc_id,
|
||||||
@ -925,7 +926,7 @@ xaccTransSetAction (Transaction *trans, const char *action)
|
|||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
static Transaction *
|
static Transaction *
|
||||||
readTransaction( int fd, Account *acc, int revision)
|
readTransaction(GNCSession *session, int fd, Account *acc, int revision)
|
||||||
{
|
{
|
||||||
int err=0;
|
int err=0;
|
||||||
int acc_id;
|
int acc_id;
|
||||||
@ -1180,7 +1181,7 @@ readTransaction( int fd, Account *acc, int revision)
|
|||||||
}
|
}
|
||||||
XACC_FLIP_INT (acc_id);
|
XACC_FLIP_INT (acc_id);
|
||||||
DEBUG ("credit %d\n", acc_id);
|
DEBUG ("credit %d\n", acc_id);
|
||||||
peer_acc = locateAccount (acc_id);
|
peer_acc = locateAccount (acc_id, session);
|
||||||
|
|
||||||
/* insert the split part of the transaction into
|
/* insert the split part of the transaction into
|
||||||
* the credited account */
|
* the credited account */
|
||||||
@ -1200,7 +1201,7 @@ readTransaction( int fd, Account *acc, int revision)
|
|||||||
}
|
}
|
||||||
XACC_FLIP_INT (acc_id);
|
XACC_FLIP_INT (acc_id);
|
||||||
DEBUG ("debit %d\n", acc_id);
|
DEBUG ("debit %d\n", acc_id);
|
||||||
peer_acc = locateAccount (acc_id);
|
peer_acc = locateAccount (acc_id, session);
|
||||||
if (peer_acc) {
|
if (peer_acc) {
|
||||||
Split *s0 = xaccTransGetSplit (trans, 0);
|
Split *s0 = xaccTransGetSplit (trans, 0);
|
||||||
Split *s1 = xaccTransGetSplit (trans, 1);
|
Split *s1 = xaccTransGetSplit (trans, 1);
|
||||||
@ -1222,7 +1223,7 @@ readTransaction( int fd, Account *acc, int revision)
|
|||||||
/* Version 5 files included a split that immediately
|
/* Version 5 files included a split that immediately
|
||||||
* followed the transaction, before the destination splits.
|
* followed the transaction, before the destination splits.
|
||||||
* Later versions don't have this. */
|
* Later versions don't have this. */
|
||||||
Split *split = readSplit (fd, revision);
|
Split *split = readSplit (session, fd, revision);
|
||||||
xaccTransAppendSplit(trans, split);
|
xaccTransAppendSplit(trans, split);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1236,7 +1237,7 @@ readTransaction( int fd, Account *acc, int revision)
|
|||||||
}
|
}
|
||||||
XACC_FLIP_INT (numSplits);
|
XACC_FLIP_INT (numSplits);
|
||||||
for (i = 0; i < numSplits; i++) {
|
for (i = 0; i < numSplits; i++) {
|
||||||
Split *split = readSplit(fd, revision);
|
Split *split = readSplit(session, fd, revision);
|
||||||
xaccTransAppendSplit(trans, split);
|
xaccTransAppendSplit(trans, split);
|
||||||
|
|
||||||
if(!notes) {
|
if(!notes) {
|
||||||
@ -1261,7 +1262,7 @@ readTransaction( int fd, Account *acc, int revision)
|
|||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
static Split *
|
static Split *
|
||||||
readSplit ( int fd, int token )
|
readSplit ( GNCSession *session, int fd, int token )
|
||||||
{
|
{
|
||||||
Account *peer_acc;
|
Account *peer_acc;
|
||||||
Split *split;
|
Split *split;
|
||||||
@ -1393,7 +1394,7 @@ readSplit ( int fd, int token )
|
|||||||
}
|
}
|
||||||
XACC_FLIP_INT (acc_id);
|
XACC_FLIP_INT (acc_id);
|
||||||
DEBUG ("account id %d", acc_id);
|
DEBUG ("account id %d", acc_id);
|
||||||
peer_acc = locateAccount (acc_id);
|
peer_acc = locateAccount (acc_id, session);
|
||||||
xaccAccountInsertSplit (peer_acc, split);
|
xaccAccountInsertSplit (peer_acc, split);
|
||||||
|
|
||||||
mark_potential_quote(split, share_price, num_shares);
|
mark_potential_quote(split, share_price, num_shares);
|
||||||
|
@ -1326,7 +1326,8 @@ account_restore_start_handler(GSList* sibling_data,
|
|||||||
const gchar *tag,
|
const gchar *tag,
|
||||||
gchar **attrs)
|
gchar **attrs)
|
||||||
{
|
{
|
||||||
Account *acc = xaccMallocAccount();
|
GNCParseStatus *pstatus = (GNCParseStatus *) global_data;
|
||||||
|
Account *acc = xaccMallocAccount(pstatus->session);
|
||||||
|
|
||||||
g_return_val_if_fail(acc, FALSE);
|
g_return_val_if_fail(acc, FALSE);
|
||||||
xaccAccountBeginEdit(acc);
|
xaccAccountBeginEdit(acc);
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
* *
|
* *
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
#ifndef _SIXTP_DOM_GENERATORS_H_
|
#ifndef SIXTP_DOM_GENERATORS_H
|
||||||
#define _SIXTP_DOM_GENERATORS_H_
|
#define SIXTP_DOM_GENERATORS_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
* *
|
* *
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
#ifndef _SIXTP_PARSERS_H_
|
#ifndef SIXTP_PARSERS_H
|
||||||
#define _SIXTP_PARSERS_H_
|
#define SIXTP_PARSERS_H
|
||||||
|
|
||||||
#include "sixtp.h"
|
#include "sixtp.h"
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
* *
|
* *
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
#ifndef _SIXTP_STACK_H_
|
#ifndef SIXTP_STACK_H
|
||||||
#define _SIXTP_STACK_H_
|
#define SIXTP_STACK_H
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
* *
|
* *
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
#ifndef _SIXTP_UTILS_H_
|
#ifndef SIXTP_UTILS_H
|
||||||
#define _SIXTP_UTILS_H_
|
#define SIXTP_UTILS_H
|
||||||
|
|
||||||
#include "date.h"
|
#include "date.h"
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
* *
|
* *
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
#ifndef _SIXTP_H_
|
#ifndef SIXTP_H
|
||||||
#define _SIXTP_H_
|
#define SIXTP_H
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -250,7 +250,7 @@ get_account_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
|||||||
acc = xaccAccountLookup (&guid);
|
acc = xaccAccountLookup (&guid);
|
||||||
if (!acc)
|
if (!acc)
|
||||||
{
|
{
|
||||||
acc = xaccMallocAccount();
|
acc = xaccMallocAccount(be->session);
|
||||||
xaccAccountBeginEdit(acc);
|
xaccAccountBeginEdit(acc);
|
||||||
xaccAccountSetGUID(acc, &guid);
|
xaccAccountSetGUID(acc, &guid);
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ get_account_cb (PGBackend *be, PGresult *result, int j, gpointer data)
|
|||||||
parent = xaccAccountLookup (&guid);
|
parent = xaccAccountLookup (&guid);
|
||||||
if (!parent)
|
if (!parent)
|
||||||
{
|
{
|
||||||
parent = xaccMallocAccount();
|
parent = xaccMallocAccount(be->session);
|
||||||
xaccAccountBeginEdit(parent);
|
xaccAccountBeginEdit(parent);
|
||||||
xaccAccountSetGUID(parent, &guid);
|
xaccAccountSetGUID(parent, &guid);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ mark_account (Account *account)
|
|||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xaccInitAccount (Account * acc)
|
xaccInitAccount (Account * acc, GNCSession *session)
|
||||||
{
|
{
|
||||||
acc->parent = NULL;
|
acc->parent = NULL;
|
||||||
acc->children = NULL;
|
acc->children = NULL;
|
||||||
@ -114,11 +114,15 @@ xaccInitAccount (Account * acc)
|
|||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
Account *
|
Account *
|
||||||
xaccMallocAccount (void)
|
xaccMallocAccount (GNCSession *session)
|
||||||
{
|
{
|
||||||
Account *acc = g_new (Account, 1);
|
Account *acc;
|
||||||
|
|
||||||
xaccInitAccount (acc);
|
g_return_val_if_fail (session, NULL);
|
||||||
|
|
||||||
|
acc = g_new (Account, 1);
|
||||||
|
|
||||||
|
xaccInitAccount (acc, session);
|
||||||
|
|
||||||
gnc_engine_generate_event (&acc->guid, GNC_EVENT_CREATE);
|
gnc_engine_generate_event (&acc->guid, GNC_EVENT_CREATE);
|
||||||
|
|
||||||
@ -126,11 +130,13 @@ xaccMallocAccount (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Account *
|
Account *
|
||||||
xaccCloneAccountSimple(const Account *from)
|
xaccCloneAccountSimple(const Account *from, GNCSession *session)
|
||||||
{
|
{
|
||||||
Account *ret;
|
Account *ret;
|
||||||
|
|
||||||
ret = xaccMallocAccount();
|
ret = xaccMallocAccount (session);
|
||||||
|
|
||||||
|
g_return_val_if_fail (ret, NULL);
|
||||||
|
|
||||||
ret->type = from->type;
|
ret->type = from->type;
|
||||||
|
|
||||||
|
@ -127,8 +127,8 @@ gboolean xaccAccountEqual(Account *a, Account* b, gboolean check_guids);
|
|||||||
* account. The account should have been opened for editing
|
* account. The account should have been opened for editing
|
||||||
* (by calling xaccAccountBeginEdit()) before calling this routine.
|
* (by calling xaccAccountBeginEdit()) before calling this routine.
|
||||||
*/
|
*/
|
||||||
Account * xaccMallocAccount (void);
|
Account * xaccMallocAccount (GNCSession *session);
|
||||||
Account * xaccCloneAccountSimple(const Account *from);
|
Account * xaccCloneAccountSimple(const Account *from, GNCSession *session);
|
||||||
void xaccAccountBeginEdit (Account *account);
|
void xaccAccountBeginEdit (Account *account);
|
||||||
void xaccAccountCommitEdit (Account *account);
|
void xaccAccountCommitEdit (Account *account);
|
||||||
void xaccAccountDestroy (Account *account);
|
void xaccAccountDestroy (Account *account);
|
||||||
|
@ -26,20 +26,17 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "SchedXaction.h"
|
|
||||||
#include "FreqSpec.h"
|
#include "FreqSpec.h"
|
||||||
#include "GNCIdP.h"
|
#include "GNCIdP.h"
|
||||||
#include "Transaction.h"
|
#include "SX-ttinfo.h"
|
||||||
|
#include "SchedXaction.h"
|
||||||
#include "TransactionP.h"
|
#include "TransactionP.h"
|
||||||
#include "date.h"
|
#include "date.h"
|
||||||
#include "gnc-engine-util.h"
|
#include "gnc-engine-util.h"
|
||||||
#include "gnc-event-p.h"
|
#include "gnc-event-p.h"
|
||||||
#include "messages.h"
|
#include "gnc-session.h"
|
||||||
#include "Account.h"
|
|
||||||
#include "Group.h"
|
|
||||||
#include "guid.h"
|
#include "guid.h"
|
||||||
#include "gnc-book.h"
|
#include "messages.h"
|
||||||
#include "SX-ttinfo.h"
|
|
||||||
|
|
||||||
static short module = MOD_SX;
|
static short module = MOD_SX;
|
||||||
|
|
||||||
@ -50,12 +47,16 @@ void sxprivtransactionListMapDelete( gpointer data, gpointer user_data );
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xaccSchedXactionInit( SchedXaction *sx, GNCBook *book)
|
xaccSchedXactionInit( SchedXaction *sx, GNCSession *session)
|
||||||
{
|
{
|
||||||
|
GNCBook *book;
|
||||||
AccountGroup *ag;
|
AccountGroup *ag;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
sx->freq = xaccFreqSpecMalloc();
|
sx->freq = xaccFreqSpecMalloc();
|
||||||
|
|
||||||
|
book = gnc_session_get_book (session);
|
||||||
|
|
||||||
xaccGUIDNew( &sx->guid );
|
xaccGUIDNew( &sx->guid );
|
||||||
xaccStoreEntity( sx, &sx->guid, GNC_ID_SCHEDXACTION );
|
xaccStoreEntity( sx, &sx->guid, GNC_ID_SCHEDXACTION );
|
||||||
g_date_clear( &sx->last_date, 1 );
|
g_date_clear( &sx->last_date, 1 );
|
||||||
@ -71,12 +72,13 @@ xaccSchedXactionInit( SchedXaction *sx, GNCBook *book)
|
|||||||
sx->dirty = TRUE;
|
sx->dirty = TRUE;
|
||||||
|
|
||||||
/* create a new template account for our splits */
|
/* create a new template account for our splits */
|
||||||
sx->template_acct = xaccMallocAccount();
|
sx->template_acct = xaccMallocAccount(session);
|
||||||
name = guid_to_string( &sx->guid );
|
name = guid_to_string( &sx->guid );
|
||||||
xaccAccountSetName( sx->template_acct, name );
|
xaccAccountSetName( sx->template_acct, name );
|
||||||
xaccAccountSetCommodity( sx->template_acct,
|
xaccAccountSetCommodity
|
||||||
gnc_commodity_new( "template", "template",
|
(sx->template_acct,
|
||||||
"template", "template", 1 ) );
|
gnc_commodity_new( "template", "template",
|
||||||
|
"template", "template", 1 ) );
|
||||||
g_free( name );
|
g_free( name );
|
||||||
xaccAccountSetType( sx->template_acct, BANK );
|
xaccAccountSetType( sx->template_acct, BANK );
|
||||||
ag = gnc_book_get_template_group( book );
|
ag = gnc_book_get_template_group( book );
|
||||||
@ -84,12 +86,16 @@ xaccSchedXactionInit( SchedXaction *sx, GNCBook *book)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SchedXaction*
|
SchedXaction*
|
||||||
xaccSchedXactionMalloc( GNCBook *book )
|
xaccSchedXactionMalloc(GNCSession *session)
|
||||||
{
|
{
|
||||||
SchedXaction *sx;
|
SchedXaction *sx;
|
||||||
|
|
||||||
|
g_return_val_if_fail (session, NULL);
|
||||||
|
|
||||||
sx = g_new0( SchedXaction, 1 );
|
sx = g_new0( SchedXaction, 1 );
|
||||||
xaccSchedXactionInit( sx, book );
|
xaccSchedXactionInit( sx, session );
|
||||||
gnc_engine_generate_event( &sx->guid, GNC_EVENT_CREATE );
|
gnc_engine_generate_event( &sx->guid, GNC_EVENT_CREATE );
|
||||||
|
|
||||||
return sx;
|
return sx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ typedef struct gncp_SchedXaction {
|
|||||||
/**
|
/**
|
||||||
* Creates and initializes a scheduled transaction.
|
* Creates and initializes a scheduled transaction.
|
||||||
**/
|
**/
|
||||||
SchedXaction *xaccSchedXactionMalloc( GNCBook *book);
|
SchedXaction *xaccSchedXactionMalloc(GNCSession *session);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* returns true if the scheduled transaction is dirty and needs to
|
* returns true if the scheduled transaction is dirty and needs to
|
||||||
|
@ -51,16 +51,18 @@
|
|||||||
|
|
||||||
static short module = MOD_SCRUB;
|
static short module = MOD_SCRUB;
|
||||||
static Account * GetOrMakeAccount (AccountGroup *root, Transaction *trans,
|
static Account * GetOrMakeAccount (AccountGroup *root, Transaction *trans,
|
||||||
const char *name_root);
|
const char *name_root, GNCSession *session);
|
||||||
|
|
||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccGroupScrubOrphans (AccountGroup *grp)
|
xaccGroupScrubOrphans (AccountGroup *grp, GNCSession *session)
|
||||||
{
|
{
|
||||||
GList *list;
|
GList *list;
|
||||||
GList *node;
|
GList *node;
|
||||||
|
|
||||||
|
g_return_if_fail (session);
|
||||||
|
|
||||||
if (!grp)
|
if (!grp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -70,26 +72,30 @@ xaccGroupScrubOrphans (AccountGroup *grp)
|
|||||||
{
|
{
|
||||||
Account *account = node->data;
|
Account *account = node->data;
|
||||||
|
|
||||||
xaccAccountTreeScrubOrphans (account);
|
xaccAccountTreeScrubOrphans (account, session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccAccountTreeScrubOrphans (Account *acc)
|
xaccAccountTreeScrubOrphans (Account *acc, GNCSession *session)
|
||||||
{
|
{
|
||||||
|
g_return_if_fail (session);
|
||||||
|
|
||||||
if (!acc)
|
if (!acc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xaccGroupScrubOrphans (xaccAccountGetChildren(acc));
|
xaccGroupScrubOrphans (xaccAccountGetChildren(acc), session);
|
||||||
xaccAccountScrubOrphans (acc);
|
xaccAccountScrubOrphans (acc, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccAccountScrubOrphans (Account *acc)
|
xaccAccountScrubOrphans (Account *acc, GNCSession *session)
|
||||||
{
|
{
|
||||||
GList *node;
|
GList *node;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
|
g_return_if_fail (session);
|
||||||
|
|
||||||
if (!acc)
|
if (!acc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -102,15 +108,19 @@ xaccAccountScrubOrphans (Account *acc)
|
|||||||
Split *split = node->data;
|
Split *split = node->data;
|
||||||
|
|
||||||
xaccTransScrubOrphans (xaccSplitGetParent (split),
|
xaccTransScrubOrphans (xaccSplitGetParent (split),
|
||||||
xaccAccountGetRoot (acc));
|
xaccAccountGetRoot (acc),
|
||||||
|
session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccTransScrubOrphans (Transaction *trans, AccountGroup *root)
|
xaccTransScrubOrphans (Transaction *trans, AccountGroup *root,
|
||||||
|
GNCSession *session)
|
||||||
{
|
{
|
||||||
GList *node;
|
GList *node;
|
||||||
|
|
||||||
|
g_return_if_fail (session);
|
||||||
|
|
||||||
if (!trans)
|
if (!trans)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -126,7 +136,7 @@ xaccTransScrubOrphans (Transaction *trans, AccountGroup *root)
|
|||||||
|
|
||||||
DEBUG ("Found an orphan \n");
|
DEBUG ("Found an orphan \n");
|
||||||
|
|
||||||
orph = GetOrMakeAccount (root, trans, _("Orphan"));
|
orph = GetOrMakeAccount (root, trans, _("Orphan"), session);
|
||||||
if (!orph)
|
if (!orph)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -248,11 +258,13 @@ xaccSplitScrub (Split *split)
|
|||||||
/* ================================================================ */
|
/* ================================================================ */
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccGroupScrubImbalance (AccountGroup *grp)
|
xaccGroupScrubImbalance (AccountGroup *grp, GNCSession *session)
|
||||||
{
|
{
|
||||||
GList *list;
|
GList *list;
|
||||||
GList *node;
|
GList *node;
|
||||||
|
|
||||||
|
g_return_if_fail (session);
|
||||||
|
|
||||||
if (!grp) return;
|
if (!grp) return;
|
||||||
|
|
||||||
list = xaccGroupGetAccountList (grp);
|
list = xaccGroupGetAccountList (grp);
|
||||||
@ -261,23 +273,30 @@ xaccGroupScrubImbalance (AccountGroup *grp)
|
|||||||
{
|
{
|
||||||
Account *account = node->data;
|
Account *account = node->data;
|
||||||
|
|
||||||
xaccAccountTreeScrubImbalance (account);
|
xaccAccountTreeScrubImbalance (account, session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccAccountTreeScrubImbalance (Account *acc)
|
xaccAccountTreeScrubImbalance (Account *acc, GNCSession *session)
|
||||||
{
|
{
|
||||||
xaccGroupScrubImbalance (xaccAccountGetChildren(acc));
|
g_return_if_fail (session);
|
||||||
xaccAccountScrubImbalance (acc);
|
|
||||||
|
xaccGroupScrubImbalance (xaccAccountGetChildren(acc), session);
|
||||||
|
xaccAccountScrubImbalance (acc, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccAccountScrubImbalance (Account *acc)
|
xaccAccountScrubImbalance (Account *acc, GNCSession *session)
|
||||||
{
|
{
|
||||||
GList *node;
|
GList *node;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
|
g_return_if_fail (session);
|
||||||
|
|
||||||
|
if (!acc)
|
||||||
|
return;
|
||||||
|
|
||||||
str = xaccAccountGetName(acc);
|
str = xaccAccountGetName(acc);
|
||||||
str = str ? str : "(null)";
|
str = str ? str : "(null)";
|
||||||
PINFO ("Looking for imbalance in account %s \n", str);
|
PINFO ("Looking for imbalance in account %s \n", str);
|
||||||
@ -287,17 +306,19 @@ xaccAccountScrubImbalance (Account *acc)
|
|||||||
Split *split = node->data;
|
Split *split = node->data;
|
||||||
Transaction *trans = xaccSplitGetParent(split);
|
Transaction *trans = xaccSplitGetParent(split);
|
||||||
|
|
||||||
xaccTransScrubImbalance (trans, xaccAccountGetRoot (acc), NULL);
|
xaccTransScrubImbalance (trans, xaccAccountGetRoot (acc), NULL, session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
|
xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
|
||||||
Account *parent)
|
Account *parent, GNCSession *session)
|
||||||
{
|
{
|
||||||
Split *balance_split = NULL;
|
Split *balance_split = NULL;
|
||||||
gnc_numeric imbalance;
|
gnc_numeric imbalance;
|
||||||
|
|
||||||
|
g_return_if_fail (session);
|
||||||
|
|
||||||
if (!trans)
|
if (!trans)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -312,7 +333,7 @@ xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!parent)
|
if (!parent)
|
||||||
account = GetOrMakeAccount (root, trans, _("Imbalance"));
|
account = GetOrMakeAccount (root, trans, _("Imbalance"), session);
|
||||||
else
|
else
|
||||||
account = parent;
|
account = parent;
|
||||||
|
|
||||||
@ -487,12 +508,14 @@ xaccGroupScrubCommodities (AccountGroup *group, GNCSession *session)
|
|||||||
|
|
||||||
static Account *
|
static Account *
|
||||||
GetOrMakeAccount (AccountGroup *root, Transaction *trans,
|
GetOrMakeAccount (AccountGroup *root, Transaction *trans,
|
||||||
const char *name_root)
|
const char *name_root, GNCSession *session)
|
||||||
{
|
{
|
||||||
gnc_commodity * currency;
|
gnc_commodity * currency;
|
||||||
char * accname;
|
char * accname;
|
||||||
Account * acc;
|
Account * acc;
|
||||||
|
|
||||||
|
g_return_val_if_fail (root, NULL);
|
||||||
|
|
||||||
/* build the account name */
|
/* build the account name */
|
||||||
currency = xaccTransGetCurrency (trans);
|
currency = xaccTransGetCurrency (trans);
|
||||||
if (!currency)
|
if (!currency)
|
||||||
@ -510,7 +533,7 @@ GetOrMakeAccount (AccountGroup *root, Transaction *trans,
|
|||||||
if (acc == NULL)
|
if (acc == NULL)
|
||||||
{
|
{
|
||||||
/* guess not. We'll have to build one */
|
/* guess not. We'll have to build one */
|
||||||
acc = xaccMallocAccount ();
|
acc = xaccMallocAccount (session);
|
||||||
xaccAccountBeginEdit (acc);
|
xaccAccountBeginEdit (acc);
|
||||||
xaccAccountSetName (acc, accname);
|
xaccAccountSetName (acc, accname);
|
||||||
xaccAccountSetCommodity (acc, currency);
|
xaccAccountSetCommodity (acc, currency);
|
||||||
|
@ -37,8 +37,8 @@
|
|||||||
#ifndef XACC_SCRUB_H
|
#ifndef XACC_SCRUB_H
|
||||||
#define XACC_SCRUB_H
|
#define XACC_SCRUB_H
|
||||||
|
|
||||||
#include "Account.h"
|
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
|
#include "gnc-engine.h"
|
||||||
|
|
||||||
/* The ScrubOrphans() methods search for transacations that contain
|
/* The ScrubOrphans() methods search for transacations that contain
|
||||||
* splits that do not have a parent account. These "orphaned splits"
|
* splits that do not have a parent account. These "orphaned splits"
|
||||||
@ -58,10 +58,11 @@
|
|||||||
* The xaccGroupScrubOrphans() method performs this scrub for the
|
* The xaccGroupScrubOrphans() method performs this scrub for the
|
||||||
* child accounts of this group.
|
* child accounts of this group.
|
||||||
*/
|
*/
|
||||||
void xaccTransScrubOrphans (Transaction *trans, AccountGroup *root);
|
void xaccTransScrubOrphans (Transaction *trans, AccountGroup *root,
|
||||||
void xaccAccountScrubOrphans (Account *acc);
|
GNCSession *session);
|
||||||
void xaccAccountTreeScrubOrphans (Account *acc);
|
void xaccAccountScrubOrphans (Account *acc, GNCSession *session);
|
||||||
void xaccGroupScrubOrphans (AccountGroup *grp);
|
void xaccAccountTreeScrubOrphans (Account *acc, GNCSession *session);
|
||||||
|
void xaccGroupScrubOrphans (AccountGroup *grp, GNCSession *session);
|
||||||
|
|
||||||
/* The ScrubSplit methods ensure that splits with the same commodity
|
/* The ScrubSplit methods ensure that splits with the same commodity
|
||||||
* and command currency have the same amount and value.
|
* and command currency have the same amount and value.
|
||||||
@ -78,10 +79,10 @@ void xaccGroupScrubSplits (AccountGroup *group);
|
|||||||
* account.
|
* account.
|
||||||
*/
|
*/
|
||||||
void xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
|
void xaccTransScrubImbalance (Transaction *trans, AccountGroup *root,
|
||||||
Account *parent);
|
Account *parent, GNCSession *session);
|
||||||
void xaccAccountScrubImbalance (Account *acc);
|
void xaccAccountScrubImbalance (Account *acc, GNCSession *session);
|
||||||
void xaccAccountTreeScrubImbalance (Account *acc);
|
void xaccAccountTreeScrubImbalance (Account *acc, GNCSession *session);
|
||||||
void xaccGroupScrubImbalance (AccountGroup *grp);
|
void xaccGroupScrubImbalance (AccountGroup *grp, GNCSession *session);
|
||||||
|
|
||||||
/* The xaccTransScrubCurrency method fixes transactions without a
|
/* The xaccTransScrubCurrency method fixes transactions without a
|
||||||
* common_currency by using the old account currency and security
|
* common_currency by using the old account currency and security
|
||||||
|
@ -856,7 +856,7 @@ number of nanoseconds.")
|
|||||||
'gnc:malloc-account
|
'gnc:malloc-account
|
||||||
'<gnc:Account*>
|
'<gnc:Account*>
|
||||||
"xaccMallocAccount"
|
"xaccMallocAccount"
|
||||||
'()
|
'((<gnc:Session*> session))
|
||||||
"Allocate a new account structure.")
|
"Allocate a new account structure.")
|
||||||
|
|
||||||
(gw:wrap-function
|
(gw:wrap-function
|
||||||
|
@ -462,7 +462,7 @@ get_random_account(GNCSession *session)
|
|||||||
Account *ret;
|
Account *ret;
|
||||||
int tmp_int;
|
int tmp_int;
|
||||||
|
|
||||||
ret = xaccMallocAccount();
|
ret = xaccMallocAccount(session);
|
||||||
|
|
||||||
xaccAccountBeginEdit(ret);
|
xaccAccountBeginEdit(ret);
|
||||||
|
|
||||||
|
@ -6,15 +6,12 @@
|
|||||||
(define (run-test)
|
(define (run-test)
|
||||||
(gnc:module-system-init)
|
(gnc:module-system-init)
|
||||||
(gnc:module-load "gnucash/engine" 0)
|
(gnc:module-load "gnucash/engine" 0)
|
||||||
|
|
||||||
(let ((group (gnc:malloc-account-group))
|
(let* ((session (gnc:session-new))
|
||||||
(acct (gnc:malloc-account)))
|
(group (gnc:malloc-account-group))
|
||||||
|
(acct (gnc:malloc-account session)))
|
||||||
(gnc:account-begin-edit acct)
|
(gnc:account-begin-edit acct)
|
||||||
(gnc:account-set-name acct "foo")
|
(gnc:account-set-name acct "foo")
|
||||||
(gnc:account-commit-edit acct)
|
(gnc:account-commit-edit acct)
|
||||||
(gnc:group-insert-account group acct))
|
(gnc:group-insert-account group acct))
|
||||||
#t)
|
#t)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -390,7 +390,8 @@ gnc_ui_to_account(AccountWindow *aw)
|
|||||||
|
|
||||||
if (use_equity)
|
if (use_equity)
|
||||||
{
|
{
|
||||||
if (!gnc_account_create_opening_balance (account, balance, date))
|
if (!gnc_account_create_opening_balance (account, balance, date,
|
||||||
|
gnc_get_current_session ()))
|
||||||
{
|
{
|
||||||
const char *message = _("Could not create opening balance.");
|
const char *message = _("Could not create opening balance.");
|
||||||
gnc_error_dialog_parented(GTK_WINDOW(aw->dialog), message);
|
gnc_error_dialog_parented(GTK_WINDOW(aw->dialog), message);
|
||||||
@ -433,7 +434,7 @@ gnc_finish_ok (AccountWindow *aw,
|
|||||||
gnc_suspend_gui_refresh ();
|
gnc_suspend_gui_refresh ();
|
||||||
|
|
||||||
parent = aw_get_account (aw);
|
parent = aw_get_account (aw);
|
||||||
account = xaccMallocAccount ();
|
account = xaccMallocAccount (gnc_get_current_session ());
|
||||||
aw->account = *xaccAccountGetGUID (account);
|
aw->account = *xaccAccountGetGUID (account);
|
||||||
aw->type = xaccAccountGetType (parent);
|
aw->type = xaccAccountGetType (parent);
|
||||||
|
|
||||||
@ -1415,7 +1416,7 @@ gnc_account_window_create(AccountWindow *aw)
|
|||||||
|
|
||||||
box = glade_xml_get_widget (xml, "parent_scroll");
|
box = glade_xml_get_widget (xml, "parent_scroll");
|
||||||
|
|
||||||
aw->top_level_account = xaccMallocAccount();
|
aw->top_level_account = xaccMallocAccount(gnc_get_current_session ());
|
||||||
xaccAccountSetName(aw->top_level_account, _("New top level account"));
|
xaccAccountSetName(aw->top_level_account, _("New top level account"));
|
||||||
|
|
||||||
aw->parent_tree = gnc_account_tree_new_with_root(aw->top_level_account);
|
aw->parent_tree = gnc_account_tree_new_with_root(aw->top_level_account);
|
||||||
@ -1614,7 +1615,7 @@ gnc_ui_new_account_window_internal (Account *base_account,
|
|||||||
|
|
||||||
aw->dialog_type = NEW_ACCOUNT;
|
aw->dialog_type = NEW_ACCOUNT;
|
||||||
|
|
||||||
account = xaccMallocAccount ();
|
account = xaccMallocAccount (gnc_get_current_session ());
|
||||||
aw->account = *xaccAccountGetGUID (account);
|
aw->account = *xaccAccountGetGUID (account);
|
||||||
|
|
||||||
if (base_account)
|
if (base_account)
|
||||||
|
@ -423,7 +423,7 @@ gnc_sx_create_from_trans(Transaction *trans)
|
|||||||
|
|
||||||
sxfti->trans = trans;
|
sxfti->trans = trans;
|
||||||
|
|
||||||
sxfti->sx = xaccSchedXactionMalloc(gnc_get_current_book ());
|
sxfti->sx = xaccSchedXactionMalloc(gnc_get_current_session ());
|
||||||
|
|
||||||
sxfti_attach_callbacks(sxfti);
|
sxfti_attach_callbacks(sxfti);
|
||||||
|
|
||||||
|
@ -562,7 +562,7 @@ clone_account (const Account* from, gnc_commodity *com)
|
|||||||
{
|
{
|
||||||
Account *ret;
|
Account *ret;
|
||||||
|
|
||||||
ret = xaccCloneAccountSimple (from);
|
ret = xaccCloneAccountSimple (from, gnc_get_current_session ());
|
||||||
|
|
||||||
xaccAccountSetCommodity (ret, com);
|
xaccAccountSetCommodity (ret, com);
|
||||||
|
|
||||||
@ -815,7 +815,8 @@ starting_balance_helper (Account *account, gpointer data)
|
|||||||
|
|
||||||
balance = get_final_balance (account);
|
balance = get_final_balance (account);
|
||||||
if (!gnc_numeric_zero_p (balance))
|
if (!gnc_numeric_zero_p (balance))
|
||||||
gnc_account_create_opening_balance (account, balance, time (NULL));
|
gnc_account_create_opening_balance (account, balance, time (NULL),
|
||||||
|
gnc_get_current_session ());
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -492,8 +492,8 @@ gnc_acct_tree_window_menu_scrub_cb(GtkWidget * widget,
|
|||||||
|
|
||||||
gnc_suspend_gui_refresh ();
|
gnc_suspend_gui_refresh ();
|
||||||
|
|
||||||
xaccAccountScrubOrphans (account);
|
xaccAccountScrubOrphans (account, gnc_get_current_session ());
|
||||||
xaccAccountScrubImbalance (account);
|
xaccAccountScrubImbalance (account, gnc_get_current_session ());
|
||||||
|
|
||||||
gnc_resume_gui_refresh ();
|
gnc_resume_gui_refresh ();
|
||||||
}
|
}
|
||||||
@ -514,8 +514,8 @@ gnc_acct_tree_window_menu_scrub_sub_cb(GtkWidget * widget,
|
|||||||
|
|
||||||
gnc_suspend_gui_refresh ();
|
gnc_suspend_gui_refresh ();
|
||||||
|
|
||||||
xaccAccountTreeScrubOrphans (account);
|
xaccAccountTreeScrubOrphans (account, gnc_get_current_session ());
|
||||||
xaccAccountTreeScrubImbalance (account);
|
xaccAccountTreeScrubImbalance (account, gnc_get_current_session ());
|
||||||
|
|
||||||
gnc_resume_gui_refresh ();
|
gnc_resume_gui_refresh ();
|
||||||
}
|
}
|
||||||
@ -527,8 +527,8 @@ gnc_acct_tree_window_menu_scrub_all_cb(GtkWidget * widget,
|
|||||||
|
|
||||||
gnc_suspend_gui_refresh ();
|
gnc_suspend_gui_refresh ();
|
||||||
|
|
||||||
xaccGroupScrubOrphans (group);
|
xaccGroupScrubOrphans (group, gnc_get_current_session ());
|
||||||
xaccGroupScrubImbalance (group);
|
xaccGroupScrubImbalance (group, gnc_get_current_session ());
|
||||||
|
|
||||||
gnc_resume_gui_refresh ();
|
gnc_resume_gui_refresh ();
|
||||||
}
|
}
|
||||||
|
@ -1131,8 +1131,8 @@ gnc_recn_scrub_cb(GtkWidget *widget, gpointer data)
|
|||||||
|
|
||||||
gnc_suspend_gui_refresh ();
|
gnc_suspend_gui_refresh ();
|
||||||
|
|
||||||
xaccAccountTreeScrubOrphans (account);
|
xaccAccountTreeScrubOrphans (account, gnc_get_current_session ());
|
||||||
xaccAccountTreeScrubImbalance (account);
|
xaccAccountTreeScrubImbalance (account, gnc_get_current_session ());
|
||||||
|
|
||||||
gnc_resume_gui_refresh ();
|
gnc_resume_gui_refresh ();
|
||||||
}
|
}
|
||||||
|
@ -1227,8 +1227,8 @@ gnc_register_scrub_all_cb (GtkWidget *widget, gpointer data)
|
|||||||
Split *split = node->data;
|
Split *split = node->data;
|
||||||
Transaction *trans = xaccSplitGetParent (split);
|
Transaction *trans = xaccSplitGetParent (split);
|
||||||
|
|
||||||
xaccTransScrubOrphans (trans, root);
|
xaccTransScrubOrphans (trans, root, gnc_get_current_session ());
|
||||||
xaccTransScrubImbalance (trans, root, NULL);
|
xaccTransScrubImbalance (trans, root, NULL, gnc_get_current_session ());
|
||||||
}
|
}
|
||||||
|
|
||||||
gnc_resume_gui_refresh ();
|
gnc_resume_gui_refresh ();
|
||||||
@ -1252,8 +1252,8 @@ gnc_register_scrub_current_cb (GtkWidget *widget, gpointer data)
|
|||||||
|
|
||||||
root = gnc_get_current_group ();
|
root = gnc_get_current_group ();
|
||||||
|
|
||||||
xaccTransScrubOrphans (trans, root);
|
xaccTransScrubOrphans (trans, root, gnc_get_current_session ());
|
||||||
xaccTransScrubImbalance (trans, root, NULL);
|
xaccTransScrubImbalance (trans, root, NULL, gnc_get_current_session ());
|
||||||
|
|
||||||
gnc_resume_gui_refresh ();
|
gnc_resume_gui_refresh ();
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
;; acct)
|
;; acct)
|
||||||
(if (and existing-account (compatible? existing-account))
|
(if (and existing-account (compatible? existing-account))
|
||||||
existing-account
|
existing-account
|
||||||
(let ((new-acct (gnc:malloc-account))
|
(let ((new-acct (gnc:malloc-account (gnc:get-current-session)))
|
||||||
(parent-acct #f)
|
(parent-acct #f)
|
||||||
(parent-name #f)
|
(parent-name #f)
|
||||||
(acct-name #f)
|
(acct-name #f)
|
||||||
|
@ -37,6 +37,11 @@ gnc_module_init(void) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* load the engine (we depend on it) */
|
||||||
|
if(!gnc_module_load("gnucash/app-utils", 0)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* load the QIF Scheme code */
|
/* load the QIF Scheme code */
|
||||||
if(gh_eval_str("(use-modules (gnucash qif-io core))") ==
|
if(gh_eval_str("(use-modules (gnucash qif-io core))") ==
|
||||||
SCM_BOOL_F) {
|
SCM_BOOL_F) {
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
;; make the account if necessary
|
;; make the account if necessary
|
||||||
(if (not acct)
|
(if (not acct)
|
||||||
(begin
|
(begin
|
||||||
(set! acct (gnc:malloc-account))
|
(set! acct (gnc:malloc-account (gnc:get-current-session)))
|
||||||
(gnc:account-begin-edit acct)
|
(gnc:account-begin-edit acct)
|
||||||
(gnc:account-set-name acct acct-name)
|
(gnc:account-set-name acct acct-name)
|
||||||
(gnc:account-commit-edit acct)
|
(gnc:account-commit-edit acct)
|
||||||
|
@ -159,7 +159,7 @@
|
|||||||
;; make the account if necessary
|
;; make the account if necessary
|
||||||
(if (not acct)
|
(if (not acct)
|
||||||
(begin
|
(begin
|
||||||
(set! acct (gnc:malloc-account))
|
(set! acct (gnc:malloc-account (gnc:get-current-session)))
|
||||||
(gnc:account-set-name acct acct-name)
|
(gnc:account-set-name acct acct-name)
|
||||||
(qif-io:acct-table-insert! gnc-acct-info
|
(qif-io:acct-table-insert! gnc-acct-info
|
||||||
acct-name acct-type acct)))
|
acct-name acct-type acct)))
|
||||||
|
@ -127,17 +127,18 @@ gnc_split_register_balance_trans (SplitRegister *reg, Transaction *trans)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
xaccTransScrubImbalance (trans, gnc_get_current_group (), NULL);
|
xaccTransScrubImbalance (trans, gnc_get_current_group (), NULL,
|
||||||
|
gnc_get_current_session ());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
xaccTransScrubImbalance (trans, gnc_get_current_group (),
|
xaccTransScrubImbalance (trans, gnc_get_current_group (),
|
||||||
default_account);
|
default_account, gnc_get_current_session ());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
xaccTransScrubImbalance (trans, gnc_get_current_group (),
|
xaccTransScrubImbalance (trans, gnc_get_current_group (),
|
||||||
other_account);
|
other_account, gnc_get_current_session ());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user