Merge branch 'maint'

This commit is contained in:
Christopher Lam 2019-10-23 20:11:52 +08:00
commit 5f6aa6ed45
10 changed files with 173 additions and 33 deletions

View File

@ -903,9 +903,10 @@ estimate_budget_helper(GtkTreeModel *model, GtkTreePath *path,
if (priv->useAvg && num_periods) if (priv->useAvg && num_periods)
{ {
num = xaccAccountGetBalanceChangeForPeriod(acct, num = xaccAccountGetNoclosingBalanceChangeForPeriod
recurrenceGetPeriodTime(&priv->r, 0, FALSE), (acct, recurrenceGetPeriodTime(&priv->r, 0, FALSE),
recurrenceGetPeriodTime(&priv->r, num_periods - 1, TRUE), TRUE); recurrenceGetPeriodTime(&priv->r, num_periods - 1, TRUE), TRUE);
num = gnc_numeric_div(num, num = gnc_numeric_div(num,
gnc_numeric_create(num_periods, 1), gnc_numeric_create(num_periods, 1),
GNC_DENOM_AUTO, GNC_DENOM_AUTO,
@ -924,7 +925,10 @@ estimate_budget_helper(GtkTreeModel *model, GtkTreePath *path,
{ {
for (i = 0; i < num_periods; i++) for (i = 0; i < num_periods; i++)
{ {
num = recurrenceGetAccountPeriodValue(&priv->r, acct, i); num = xaccAccountGetNoclosingBalanceChangeForPeriod
(acct, recurrenceGetPeriodTime(&priv->r, i, FALSE),
recurrenceGetPeriodTime(&priv->r, i, TRUE), TRUE);
if (!gnc_numeric_check(num)) if (!gnc_numeric_check(num))
{ {
if (gnc_reverse_balance(acct)) if (gnc_reverse_balance(acct))

View File

@ -23,6 +23,8 @@
;; Boston, MA 02110-1301, USA gnu@gnu.org ;; Boston, MA 02110-1301, USA gnu@gnu.org
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-modules (srfi srfi-9))
(define gnc:*register-report-hash* (make-hash-table 23)) (define gnc:*register-report-hash* (make-hash-table 23))
;; Keep a hash-table of records, keyed off the account type. Each ;; Keep a hash-table of records, keyed off the account type. Each
@ -30,26 +32,15 @@
;; or without split. If no function is found, then run the 'default' ;; or without split. If no function is found, then run the 'default'
;; function ;; function
(define acct-type-info (make-record-type "AcctTypeInfo" '(split non-split))) (define-record-type :acct-type-info
(make-acct-type-private split non-split)
(define make-acct-type-private acct-type?
(record-constructor acct-type-info '(split non-split))) (split get-split set-split)
(non-split get-non-split set-non-split))
(define (make-acct-type) (define (make-acct-type)
(make-acct-type-private #f #f)) (make-acct-type-private #f #f))
(define get-split
(record-accessor acct-type-info 'split))
(define set-split
(record-modifier acct-type-info 'split))
(define get-non-split
(record-accessor acct-type-info 'non-split))
(define set-non-split
(record-modifier acct-type-info 'non-split))
(define (gnc:register-report-hook acct-type split? create-fcn) (define (gnc:register-report-hook acct-type split? create-fcn)
(let ((type-info (hash-ref gnc:*register-report-hash* acct-type (make-acct-type)))) (let ((type-info (hash-ref gnc:*register-report-hash* acct-type (make-acct-type))))
(if split? (if split?

View File

@ -123,15 +123,6 @@
sublist) sublist)
accrec-printer)) accrec-printer))
(define newaccrec-full (record-constructor accrectype)) ; requires all the fields (define newaccrec-full (record-constructor accrectype)) ; requires all the fields
(define newaccrec-empty (record-constructor accrectype '())) ; all fields default to #f
(define newaccrec (record-constructor accrectype '(account ; most-likely-to-be-needed fields
code
placeholder?
namelink
commodity
balance-num
depth
treedepth)))
(define (newaccrec-clean) (define (newaccrec-clean)
;; Create a new accrec with 'clean' empty values, e.g. strings are "", not #f ;; Create a new accrec with 'clean' empty values, e.g. strings are "", not #f
(newaccrec-full #f ; account (newaccrec-full #f ; account

View File

@ -63,6 +63,8 @@ static const std::string AB_ACCOUNT_UID("account-uid");
static const std::string AB_BANK_CODE("bank-code"); static const std::string AB_BANK_CODE("bank-code");
static const std::string AB_TRANS_RETRIEVAL("trans-retrieval"); static const std::string AB_TRANS_RETRIEVAL("trans-retrieval");
static gnc_numeric GetBalanceAsOfDate (Account *acc, time64 date, gboolean ignclosing);
using FinalProbabilityVec=std::vector<std::pair<std::string, int32_t>>; using FinalProbabilityVec=std::vector<std::pair<std::string, int32_t>>;
using ProbabilityVec=std::vector<std::pair<std::string, struct AccountProbability>>; using ProbabilityVec=std::vector<std::pair<std::string, struct AccountProbability>>;
using FlatKvpEntry=std::pair<std::string, KvpValue*>; using FlatKvpEntry=std::pair<std::string, KvpValue*>;
@ -88,6 +90,7 @@ enum
PROP_COMMODITY_SCU, /* Table */ PROP_COMMODITY_SCU, /* Table */
PROP_NON_STD_SCU, /* Table */ PROP_NON_STD_SCU, /* Table */
PROP_END_BALANCE, /* Constructed */ PROP_END_BALANCE, /* Constructed */
PROP_END_NOCLOSING_BALANCE, /* Constructed */
PROP_END_CLEARED_BALANCE, /* Constructed */ PROP_END_CLEARED_BALANCE, /* Constructed */
PROP_END_RECONCILED_BALANCE, /* Constructed */ PROP_END_RECONCILED_BALANCE, /* Constructed */
@ -116,6 +119,7 @@ enum
PROP_SORT_DIRTY, /* Runtime Value */ PROP_SORT_DIRTY, /* Runtime Value */
PROP_BALANCE_DIRTY, /* Runtime Value */ PROP_BALANCE_DIRTY, /* Runtime Value */
PROP_START_BALANCE, /* Runtime Value */ PROP_START_BALANCE, /* Runtime Value */
PROP_START_NOCLOSING_BALANCE, /* Runtime Value */
PROP_START_CLEARED_BALANCE, /* Runtime Value */ PROP_START_CLEARED_BALANCE, /* Runtime Value */
PROP_START_RECONCILED_BALANCE, /* Runtime Value */ PROP_START_RECONCILED_BALANCE, /* Runtime Value */
}; };
@ -279,9 +283,11 @@ gnc_account_init(Account* acc)
priv->non_standard_scu = FALSE; priv->non_standard_scu = FALSE;
priv->balance = gnc_numeric_zero(); priv->balance = gnc_numeric_zero();
priv->noclosing_balance = gnc_numeric_zero();
priv->cleared_balance = gnc_numeric_zero(); priv->cleared_balance = gnc_numeric_zero();
priv->reconciled_balance = gnc_numeric_zero(); priv->reconciled_balance = gnc_numeric_zero();
priv->starting_balance = gnc_numeric_zero(); priv->starting_balance = gnc_numeric_zero();
priv->starting_noclosing_balance = gnc_numeric_zero();
priv->starting_cleared_balance = gnc_numeric_zero(); priv->starting_cleared_balance = gnc_numeric_zero();
priv->starting_reconciled_balance = gnc_numeric_zero(); priv->starting_reconciled_balance = gnc_numeric_zero();
priv->balance_dirty = FALSE; priv->balance_dirty = FALSE;
@ -364,6 +370,9 @@ gnc_account_get_property (GObject *object,
case PROP_START_BALANCE: case PROP_START_BALANCE:
g_value_set_boxed(value, &priv->starting_balance); g_value_set_boxed(value, &priv->starting_balance);
break; break;
case PROP_START_NOCLOSING_BALANCE:
g_value_set_boxed(value, &priv->starting_noclosing_balance);
break;
case PROP_START_CLEARED_BALANCE: case PROP_START_CLEARED_BALANCE:
g_value_set_boxed(value, &priv->starting_cleared_balance); g_value_set_boxed(value, &priv->starting_cleared_balance);
break; break;
@ -373,6 +382,9 @@ gnc_account_get_property (GObject *object,
case PROP_END_BALANCE: case PROP_END_BALANCE:
g_value_set_boxed(value, &priv->balance); g_value_set_boxed(value, &priv->balance);
break; break;
case PROP_END_NOCLOSING_BALANCE:
g_value_set_boxed(value, &priv->noclosing_balance);
break;
case PROP_END_CLEARED_BALANCE: case PROP_END_CLEARED_BALANCE:
g_value_set_boxed(value, &priv->cleared_balance); g_value_set_boxed(value, &priv->cleared_balance);
break; break;
@ -746,6 +758,23 @@ gnc_account_class_init (AccountClass *klass)
GNC_TYPE_NUMERIC, GNC_TYPE_NUMERIC,
static_cast<GParamFlags>(G_PARAM_READWRITE))); static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property
(gobject_class,
PROP_START_NOCLOSING_BALANCE,
g_param_spec_boxed("start-noclosing-balance",
"Starting No-closing Balance",
"The starting balance for the account, ignoring closing."
"This parameter is intended for use with backends "
"that do not return the complete list of splits "
"for an account, but rather return a partial "
"list. In such a case, the backend will "
"typically return all of the splits after "
"some certain date, and the 'starting noclosing "
"balance' will represent the summation of the "
"splits up to that date, ignoring closing splits.",
GNC_TYPE_NUMERIC,
static_cast<GParamFlags>(G_PARAM_READWRITE)));
g_object_class_install_property g_object_class_install_property
(gobject_class, (gobject_class,
PROP_START_CLEARED_BALANCE, PROP_START_CLEARED_BALANCE,
@ -791,6 +820,18 @@ gnc_account_class_init (AccountClass *klass)
GNC_TYPE_NUMERIC, GNC_TYPE_NUMERIC,
G_PARAM_READABLE)); G_PARAM_READABLE));
g_object_class_install_property
(gobject_class,
PROP_END_NOCLOSING_BALANCE,
g_param_spec_boxed("end-noclosing-balance",
"Ending Account Noclosing Balance",
"This is the current ending no-closing balance for "
"the account. It is computed from the sum of the "
"starting balance and all cleared splits in the "
"account.",
GNC_TYPE_NUMERIC,
G_PARAM_READABLE));
g_object_class_install_property g_object_class_install_property
(gobject_class, (gobject_class,
PROP_END_CLEARED_BALANCE, PROP_END_CLEARED_BALANCE,
@ -1269,6 +1310,7 @@ xaccFreeAccount (Account *acc)
priv->children = nullptr; priv->children = nullptr;
priv->balance = gnc_numeric_zero(); priv->balance = gnc_numeric_zero();
priv->noclosing_balance = gnc_numeric_zero();
priv->cleared_balance = gnc_numeric_zero(); priv->cleared_balance = gnc_numeric_zero();
priv->reconciled_balance = gnc_numeric_zero(); priv->reconciled_balance = gnc_numeric_zero();
@ -1565,6 +1607,22 @@ xaccAccountEqual(const Account *aa, const Account *ab, gboolean check_guids)
return FALSE; return FALSE;
} }
if (!gnc_numeric_equal(priv_aa->starting_noclosing_balance,
priv_ab->starting_noclosing_balance))
{
char *str_a;
char *str_b;
str_a = gnc_numeric_to_string(priv_aa->starting_noclosing_balance);
str_b = gnc_numeric_to_string(priv_ab->starting_noclosing_balance);
PWARN ("starting noclosing balances differ: %s vs %s", str_a, str_b);
g_free (str_a);
g_free (str_b);
return FALSE;
}
if (!gnc_numeric_equal(priv_aa->starting_cleared_balance, if (!gnc_numeric_equal(priv_aa->starting_cleared_balance,
priv_ab->starting_cleared_balance)) priv_ab->starting_cleared_balance))
{ {
@ -1615,6 +1673,21 @@ xaccAccountEqual(const Account *aa, const Account *ab, gboolean check_guids)
return FALSE; return FALSE;
} }
if (!gnc_numeric_equal(priv_aa->noclosing_balance, priv_ab->noclosing_balance))
{
char *str_a;
char *str_b;
str_a = gnc_numeric_to_string(priv_aa->noclosing_balance);
str_b = gnc_numeric_to_string(priv_ab->noclosing_balance);
PWARN ("noclosing balances differ: %s vs %s", str_a, str_b);
g_free (str_a);
g_free (str_b);
return FALSE;
}
if (!gnc_numeric_equal(priv_aa->cleared_balance, priv_ab->cleared_balance)) if (!gnc_numeric_equal(priv_aa->cleared_balance, priv_ab->cleared_balance))
{ {
char *str_a; char *str_a;
@ -2070,6 +2143,7 @@ xaccAccountRecomputeBalance (Account * acc)
{ {
AccountPrivate *priv; AccountPrivate *priv;
gnc_numeric balance; gnc_numeric balance;
gnc_numeric noclosing_balance;
gnc_numeric cleared_balance; gnc_numeric cleared_balance;
gnc_numeric reconciled_balance; gnc_numeric reconciled_balance;
GList *lp; GList *lp;
@ -2083,6 +2157,7 @@ xaccAccountRecomputeBalance (Account * acc)
if (qof_book_shutting_down(qof_instance_get_book(acc))) return; if (qof_book_shutting_down(qof_instance_get_book(acc))) return;
balance = priv->starting_balance; balance = priv->starting_balance;
noclosing_balance = priv->starting_noclosing_balance;
cleared_balance = priv->starting_cleared_balance; cleared_balance = priv->starting_cleared_balance;
reconciled_balance = priv->starting_reconciled_balance; reconciled_balance = priv->starting_reconciled_balance;
@ -2107,13 +2182,18 @@ xaccAccountRecomputeBalance (Account * acc)
gnc_numeric_add_fixed(reconciled_balance, amt); gnc_numeric_add_fixed(reconciled_balance, amt);
} }
if (!(xaccTransGetIsClosingTxn (split->parent)))
noclosing_balance = gnc_numeric_add_fixed(noclosing_balance, amt);
split->balance = balance; split->balance = balance;
split->noclosing_balance = noclosing_balance;
split->cleared_balance = cleared_balance; split->cleared_balance = cleared_balance;
split->reconciled_balance = reconciled_balance; split->reconciled_balance = reconciled_balance;
} }
priv->balance = balance; priv->balance = balance;
priv->noclosing_balance = noclosing_balance;
priv->cleared_balance = cleared_balance; priv->cleared_balance = cleared_balance;
priv->reconciled_balance = reconciled_balance; priv->reconciled_balance = reconciled_balance;
priv->balance_dirty = FALSE; priv->balance_dirty = FALSE;
@ -3287,8 +3367,8 @@ xaccAccountGetProjectedMinimumBalance (const Account *acc)
/********************************************************************\ /********************************************************************\
\********************************************************************/ \********************************************************************/
gnc_numeric static gnc_numeric
xaccAccountGetBalanceAsOfDate (Account *acc, time64 date) GetBalanceAsOfDate (Account *acc, time64 date, gboolean ignclosing)
{ {
/* Ideally this could use xaccAccountForEachSplit, but /* Ideally this could use xaccAccountForEachSplit, but
* it doesn't exist yet and I'm uncertain of exactly how * it doesn't exist yet and I'm uncertain of exactly how
@ -3307,6 +3387,9 @@ xaccAccountGetBalanceAsOfDate (Account *acc, time64 date)
xaccAccountRecomputeBalance (acc); /* just in case, normally a noop */ xaccAccountRecomputeBalance (acc); /* just in case, normally a noop */
priv = GET_PRIVATE(acc); priv = GET_PRIVATE(acc);
if (ignclosing)
balance = priv->noclosing_balance;
else
balance = priv->balance; balance = priv->balance;
lp = priv->splits; lp = priv->splits;
@ -3326,6 +3409,9 @@ xaccAccountGetBalanceAsOfDate (Account *acc, time64 date)
/* Since lp is now pointing to a split which was past the reconcile /* Since lp is now pointing to a split which was past the reconcile
* date, get the running balance of the previous split. * date, get the running balance of the previous split.
*/ */
if (ignclosing)
balance = xaccSplitGetNoclosingBalance( (Split *)lp->prev->data );
else
balance = xaccSplitGetBalance( (Split *)lp->prev->data ); balance = xaccSplitGetBalance( (Split *)lp->prev->data );
} }
else else
@ -3342,6 +3428,18 @@ xaccAccountGetBalanceAsOfDate (Account *acc, time64 date)
return( balance ); return( balance );
} }
gnc_numeric
xaccAccountGetBalanceAsOfDate (Account *acc, time64 date)
{
return GetBalanceAsOfDate (acc, date, FALSE);
}
static gnc_numeric
xaccAccountGetNoclosingBalanceAsOfDate (Account *acc, time64 date)
{
return GetBalanceAsOfDate (acc, date, TRUE);
}
/* /*
* Originally gsr_account_present_balance in gnc-split-reg.c * Originally gsr_account_present_balance in gnc-split-reg.c
* *
@ -3669,6 +3767,16 @@ xaccAccountGetBalanceAsOfDateInCurrency(
include_children); include_children);
} }
gnc_numeric
xaccAccountGetNoclosingBalanceAsOfDateInCurrency(
Account *acc, time64 date, gnc_commodity *report_commodity,
gboolean include_children)
{
return xaccAccountGetXxxBalanceAsOfDateInCurrencyRecursive
(acc, date, xaccAccountGetNoclosingBalanceAsOfDate,
report_commodity, include_children);
}
gnc_numeric gnc_numeric
xaccAccountGetBalanceChangeForPeriod (Account *acc, time64 t1, time64 t2, xaccAccountGetBalanceChangeForPeriod (Account *acc, time64 t1, time64 t2,
gboolean recurse) gboolean recurse)
@ -3680,6 +3788,17 @@ xaccAccountGetBalanceChangeForPeriod (Account *acc, time64 t1, time64 t2,
return gnc_numeric_sub(b2, b1, GNC_DENOM_AUTO, GNC_HOW_DENOM_FIXED); return gnc_numeric_sub(b2, b1, GNC_DENOM_AUTO, GNC_HOW_DENOM_FIXED);
} }
gnc_numeric
xaccAccountGetNoclosingBalanceChangeForPeriod (Account *acc, time64 t1,
time64 t2, gboolean recurse)
{
gnc_numeric b1, b2;
b1 = xaccAccountGetNoclosingBalanceAsOfDateInCurrency(acc, t1, NULL, recurse);
b2 = xaccAccountGetNoclosingBalanceAsOfDateInCurrency(acc, t2, NULL, recurse);
return gnc_numeric_sub(b2, b1, GNC_DENOM_AUTO, GNC_HOW_DENOM_FIXED);
}
/********************************************************************\ /********************************************************************\
\********************************************************************/ \********************************************************************/

View File

@ -595,12 +595,19 @@ gnc_numeric xaccAccountGetProjectedMinimumBalanceInCurrency (
const Account *account, const gnc_commodity *report_commodity, const Account *account, const gnc_commodity *report_commodity,
gboolean include_children); gboolean include_children);
/* This function gets the balance as of the given date, ignoring
closing entries, in the desired commodity. */
gnc_numeric xaccAccountGetNoclosingBalanceAsOfDateInCurrency(
Account *acc, time64 date, gnc_commodity *report_commodity,
gboolean include_children);
/* This function gets the balance as of the given date in the desired /* This function gets the balance as of the given date in the desired
commodity. */ commodity. */
gnc_numeric xaccAccountGetBalanceAsOfDateInCurrency( gnc_numeric xaccAccountGetBalanceAsOfDateInCurrency(
Account *account, time64 date, gnc_commodity *report_commodity, Account *account, time64 date, gnc_commodity *report_commodity,
gboolean include_children); gboolean include_children);
gnc_numeric xaccAccountGetNoclosingBalanceChangeForPeriod (
Account *acc, time64 date1, time64 date2, gboolean recurse);
gnc_numeric xaccAccountGetBalanceChangeForPeriod ( gnc_numeric xaccAccountGetBalanceChangeForPeriod (
Account *acc, time64 date1, time64 date2, gboolean recurse); Account *acc, time64 date1, time64 date2, gboolean recurse);
@ -1504,6 +1511,7 @@ const char * dxaccAccountGetQuoteTZ (const Account *account);
#define ACCOUNT_SORT_REVERSED_ "sort-reversed" #define ACCOUNT_SORT_REVERSED_ "sort-reversed"
#define ACCOUNT_NOTES_ "notes" #define ACCOUNT_NOTES_ "notes"
#define ACCOUNT_BALANCE_ "balance" #define ACCOUNT_BALANCE_ "balance"
#define ACCOUNT_NOCLOSING_ "noclosing"
#define ACCOUNT_CLEARED_ "cleared" #define ACCOUNT_CLEARED_ "cleared"
#define ACCOUNT_RECONCILED_ "reconciled" #define ACCOUNT_RECONCILED_ "reconciled"
#define ACCOUNT_PRESENT_ "present" #define ACCOUNT_PRESENT_ "present"

View File

@ -104,11 +104,13 @@ typedef struct AccountPrivate
/* protected data - should only be set by backends */ /* protected data - should only be set by backends */
gnc_numeric starting_balance; gnc_numeric starting_balance;
gnc_numeric starting_noclosing_balance;
gnc_numeric starting_cleared_balance; gnc_numeric starting_cleared_balance;
gnc_numeric starting_reconciled_balance; gnc_numeric starting_reconciled_balance;
/* cached parameters */ /* cached parameters */
gnc_numeric balance; gnc_numeric balance;
gnc_numeric noclosing_balance;
gnc_numeric cleared_balance; gnc_numeric cleared_balance;
gnc_numeric reconciled_balance; gnc_numeric reconciled_balance;

View File

@ -120,6 +120,7 @@ gnc_split_init(Split* split)
split->balance = gnc_numeric_zero(); split->balance = gnc_numeric_zero();
split->cleared_balance = gnc_numeric_zero(); split->cleared_balance = gnc_numeric_zero();
split->reconciled_balance = gnc_numeric_zero(); split->reconciled_balance = gnc_numeric_zero();
split->noclosing_balance = gnc_numeric_zero();
split->gains = GAINS_STATUS_UNKNOWN; split->gains = GAINS_STATUS_UNKNOWN;
split->gains_split = NULL; split->gains_split = NULL;
@ -513,6 +514,7 @@ xaccSplitReinit(Split * split)
split->balance = gnc_numeric_zero(); split->balance = gnc_numeric_zero();
split->cleared_balance = gnc_numeric_zero(); split->cleared_balance = gnc_numeric_zero();
split->reconciled_balance = gnc_numeric_zero(); split->reconciled_balance = gnc_numeric_zero();
split->noclosing_balance = gnc_numeric_zero();
qof_instance_set_idata(split, 0); qof_instance_set_idata(split, 0);
@ -597,6 +599,7 @@ xaccSplitCloneNoKvp (const Split *s)
split->balance = s->balance; split->balance = s->balance;
split->cleared_balance = s->cleared_balance; split->cleared_balance = s->cleared_balance;
split->reconciled_balance = s->reconciled_balance; split->reconciled_balance = s->reconciled_balance;
split->noclosing_balance = s->noclosing_balance;
split->gains = GAINS_STATUS_UNKNOWN; split->gains = GAINS_STATUS_UNKNOWN;
split->gains_split = NULL; split->gains_split = NULL;
@ -679,6 +682,7 @@ xaccSplitDump (const Split *split, const char *tag)
printf(" CBalance: %s\n", gnc_numeric_to_string(split->cleared_balance)); printf(" CBalance: %s\n", gnc_numeric_to_string(split->cleared_balance));
printf(" RBalance: %s\n", printf(" RBalance: %s\n",
gnc_numeric_to_string(split->reconciled_balance)); gnc_numeric_to_string(split->reconciled_balance));
printf(" NoClose: %s\n", gnc_numeric_to_string(split->noclosing_balance));
printf(" idata: %x\n", qof_instance_get_idata(split)); printf(" idata: %x\n", qof_instance_get_idata(split));
} }
#endif #endif
@ -868,6 +872,9 @@ xaccSplitEqual(const Split *sa, const Split *sb,
if (!xaccSplitEqualCheckBal ("reconciled ", sa->reconciled_balance, if (!xaccSplitEqualCheckBal ("reconciled ", sa->reconciled_balance,
sb->reconciled_balance)) sb->reconciled_balance))
return FALSE; return FALSE;
if (!xaccSplitEqualCheckBal ("noclosing ", sa->noclosing_balance,
sb->noclosing_balance))
return FALSE;
} }
if (!xaccTransEqual(sa->parent, sb->parent, check_guids, check_txn_splits, if (!xaccTransEqual(sa->parent, sb->parent, check_guids, check_txn_splits,
@ -1272,6 +1279,12 @@ xaccSplitGetBalance (const Split *s)
return s ? s->balance : gnc_numeric_zero(); return s ? s->balance : gnc_numeric_zero();
} }
gnc_numeric
xaccSplitGetNoclosingBalance (const Split *s)
{
return s ? s->noclosing_balance : gnc_numeric_zero();
}
gnc_numeric gnc_numeric
xaccSplitGetClearedBalance (const Split *s) xaccSplitGetClearedBalance (const Split *s)
{ {

View File

@ -296,6 +296,15 @@ gnc_numeric xaccSplitGetBaseValue (const Split *split,
*/ */
gnc_numeric xaccSplitGetBalance (const Split *split); gnc_numeric xaccSplitGetBalance (const Split *split);
/**
* The noclosing-balance is the currency-denominated balance of all
* transactions except 'closing' transactions. It is correctly
* adjusted for price fluctuations.
*
* Returns the running balance up to & including the indicated split.
*/
gnc_numeric xaccSplitGetNoclosingBalance (const Split *split);
/** /**
* The cleared-balance is the currency-denominated balance * The cleared-balance is the currency-denominated balance
* of all transactions that have been marked as cleared or reconciled. * of all transactions that have been marked as cleared or reconciled.

View File

@ -123,6 +123,7 @@ struct split_s
* These balances apply to a sorting order by date posted * These balances apply to a sorting order by date posted
* (not by date entered). */ * (not by date entered). */
gnc_numeric balance; gnc_numeric balance;
gnc_numeric noclosing_balance;
gnc_numeric cleared_balance; gnc_numeric cleared_balance;
gnc_numeric reconciled_balance; gnc_numeric reconciled_balance;
}; };

View File

@ -936,6 +936,8 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData)
split10->balance = split00->balance; split10->balance = split00->balance;
split11->balance = split01->balance; split11->balance = split01->balance;
split10->noclosing_balance = split00->noclosing_balance;
split11->noclosing_balance = split01->noclosing_balance;
g_assert (xaccTransEqual (txn1, txn0, TRUE, TRUE, TRUE, TRUE)); g_assert (xaccTransEqual (txn1, txn0, TRUE, TRUE, TRUE, TRUE));
} }
g_free (check3->msg); g_free (check3->msg);