mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Make xaccAccountSortSplits a private function so the backends can use it.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5781 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
88f759322d
commit
f55253d1ae
@ -604,15 +604,17 @@ split_sort_func(gconstpointer a, gconstpointer b) {
|
|||||||
return(xaccSplitDateOrder(sa, sb));
|
return(xaccSplitDateOrder(sa, sb));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
xaccAccountSortSplits (Account *acc)
|
xaccAccountSortSplits (Account *acc, gboolean force)
|
||||||
{
|
{
|
||||||
if(!acc) return;
|
if(!acc) return;
|
||||||
|
|
||||||
if(!acc->sort_dirty) return;
|
if(!acc->sort_dirty) return;
|
||||||
if(acc->editlevel > 0) return;
|
if(!force && acc->editlevel > 0) return;
|
||||||
|
|
||||||
acc->splits = g_list_sort(acc->splits, split_sort_func);
|
acc->splits = g_list_sort(acc->splits, split_sort_func);
|
||||||
|
|
||||||
acc->sort_dirty = FALSE;
|
acc->sort_dirty = FALSE;
|
||||||
|
acc->balance_dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -622,7 +624,7 @@ xaccAccountBringUpToDate(Account *acc)
|
|||||||
|
|
||||||
/* if a re-sort happens here, then everything will update, so the
|
/* if a re-sort happens here, then everything will update, so the
|
||||||
cost basis and balance calls are no-ops */
|
cost basis and balance calls are no-ops */
|
||||||
xaccAccountSortSplits(acc);
|
xaccAccountSortSplits(acc, FALSE);
|
||||||
xaccAccountRecomputeBalance(acc);
|
xaccAccountRecomputeBalance(acc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1597,29 +1599,20 @@ xaccAccountGetBalanceAsOfDate (Account *acc, time_t date)
|
|||||||
gboolean found = FALSE;
|
gboolean found = FALSE;
|
||||||
gnc_numeric balance;
|
gnc_numeric balance;
|
||||||
|
|
||||||
balance = xaccAccountGetBalance( acc );
|
if (!acc) return gnc_numeric_zero ();
|
||||||
|
|
||||||
xaccAccountSortSplits( acc ); /* just in case, normally a nop */
|
xaccAccountSortSplits (acc, TRUE); /* just in case, normally a noop */
|
||||||
|
xaccAccountRecomputeBalance (acc); /* just in case, normally a noop */
|
||||||
|
|
||||||
|
balance = xaccAccountGetBalance( acc );
|
||||||
|
|
||||||
/* Since transaction post times are stored as a Timespec,
|
/* Since transaction post times are stored as a Timespec,
|
||||||
* convert date into a Timespec as well rather than converting
|
* convert date into a Timespec as well rather than converting
|
||||||
* each transaction's Timespec into a time_t.
|
* each transaction's Timespec into a time_t.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ts.tv_sec = date;
|
ts.tv_sec = date;
|
||||||
ts.tv_nsec = 0;
|
ts.tv_nsec = 0;
|
||||||
|
|
||||||
/* Do checks from xaccAccountRecomputeBalance. balance_dirty isn't
|
|
||||||
* checked because it shouldn't be necessary.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if( NULL == acc ||
|
|
||||||
acc->editlevel > 0 ||
|
|
||||||
acc->do_free )
|
|
||||||
{
|
|
||||||
return ( balance );
|
|
||||||
}
|
|
||||||
|
|
||||||
lp = xaccAccountGetSplitList( acc );
|
lp = xaccAccountGetSplitList( acc );
|
||||||
while( lp && !found )
|
while( lp && !found )
|
||||||
{
|
{
|
||||||
|
@ -167,6 +167,11 @@ Account * xaccAccountLookupEntityTable (const GUID *guid,
|
|||||||
*/
|
*/
|
||||||
void xaccAccountRemoveSplit (Account *, Split *);
|
void xaccAccountRemoveSplit (Account *, Split *);
|
||||||
|
|
||||||
|
/* xaccAccountSortSplits() will resort the account's splits
|
||||||
|
* if the sort is dirty. If 'force' is true, the account is
|
||||||
|
* sorted even if the editlevel is not zero. */
|
||||||
|
void xaccAccountSortSplits (Account *acc, gboolean force);
|
||||||
|
|
||||||
/* the following recompute the partial balances (stored with the
|
/* the following recompute the partial balances (stored with the
|
||||||
* transaction) and the total balance, for this account */
|
* transaction) and the total balance, for this account */
|
||||||
void xaccAccountRecomputeBalance (Account *);
|
void xaccAccountRecomputeBalance (Account *);
|
||||||
|
@ -1005,7 +1005,16 @@ xaccTransEqual(const Transaction *ta, const Transaction *tb,
|
|||||||
{
|
{
|
||||||
if (!xaccSplitEqual(sa->data, sb->data, check_guids, FALSE))
|
if (!xaccSplitEqual(sa->data, sb->data, check_guids, FALSE))
|
||||||
{
|
{
|
||||||
PWARN ("splits differ");
|
char *str_a, *str_b;
|
||||||
|
|
||||||
|
str_a = guid_to_string (xaccSplitGetGUID (sa->data));
|
||||||
|
str_b = guid_to_string (xaccSplitGetGUID (sb->data));
|
||||||
|
|
||||||
|
PWARN ("splits %s and %s differ", str_a, str_b);
|
||||||
|
|
||||||
|
g_free (str_a);
|
||||||
|
g_free (str_b);
|
||||||
|
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2558,10 +2567,20 @@ xaccSplitSetReconcile (Split *split, char recn)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
split->reconciled = recn;
|
if (split->reconciled != recn)
|
||||||
|
{
|
||||||
|
Account *account = xaccSplitGetAccount (split);
|
||||||
|
|
||||||
xaccAccountRecomputeBalance (xaccSplitGetAccount(split));
|
split->reconciled = recn;
|
||||||
mark_split (split);
|
|
||||||
|
if (account)
|
||||||
|
{
|
||||||
|
account->balance_dirty = TRUE;
|
||||||
|
xaccAccountRecomputeBalance (account);
|
||||||
|
}
|
||||||
|
|
||||||
|
mark_split (split);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -2826,13 +2845,11 @@ xaccTransVoid(Transaction *transaction,
|
|||||||
void_reason_str,
|
void_reason_str,
|
||||||
val);
|
val);
|
||||||
|
|
||||||
|
|
||||||
now.tv_sec = time(NULL);
|
now.tv_sec = time(NULL);
|
||||||
now.tv_nsec = 0;
|
now.tv_nsec = 0;
|
||||||
|
|
||||||
gnc_timespec_to_iso8601_buff(now, iso8601_str);
|
gnc_timespec_to_iso8601_buff(now, iso8601_str);
|
||||||
|
|
||||||
|
|
||||||
val = kvp_value_new_string (iso8601_str);
|
val = kvp_value_new_string (iso8601_str);
|
||||||
|
|
||||||
kvp_frame_set_slot_nc(frame,
|
kvp_frame_set_slot_nc(frame,
|
||||||
@ -2856,18 +2873,13 @@ xaccTransVoid(Transaction *transaction,
|
|||||||
amt = xaccSplitGetValue(split);
|
amt = xaccSplitGetValue(split);
|
||||||
val = kvp_value_new_gnc_numeric(amt);
|
val = kvp_value_new_gnc_numeric(amt);
|
||||||
kvp_frame_set_slot_nc(frame, void_former_val_str, val);
|
kvp_frame_set_slot_nc(frame, void_former_val_str, val);
|
||||||
|
|
||||||
|
|
||||||
xaccSplitSetAmount(split, zero);
|
xaccSplitSetAmount(split, zero);
|
||||||
xaccSplitSetValue(split, zero);
|
xaccSplitSetValue(split, zero);
|
||||||
xaccSplitSetReconcile(split, VREC);
|
xaccSplitSetReconcile(split, VREC);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
xaccTransCommitEdit(transaction);
|
xaccTransCommitEdit(transaction);
|
||||||
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@ -2875,13 +2887,11 @@ xaccTransGetVoidStatus(Transaction *trans)
|
|||||||
{
|
{
|
||||||
kvp_frame *frame;
|
kvp_frame *frame;
|
||||||
|
|
||||||
|
|
||||||
g_return_val_if_fail(trans, FALSE);
|
g_return_val_if_fail(trans, FALSE);
|
||||||
|
|
||||||
frame = xaccTransGetSlots(trans);
|
frame = xaccTransGetSlots(trans);
|
||||||
|
|
||||||
return (gboolean) kvp_frame_get_slot(frame, void_reason_str);
|
return (kvp_frame_get_slot(frame, void_reason_str) != NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@ -2923,7 +2933,6 @@ xaccSplitVoidFormerAmount(Split *split)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return amt;
|
return amt;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gnc_numeric
|
gnc_numeric
|
||||||
|
Loading…
Reference in New Issue
Block a user