mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
miswc cleanup, add minor/misc lot support
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6908 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
+36
-21
@@ -406,7 +406,7 @@ xaccAccountCommitEdit (Account *acc)
|
||||
if (acc->do_free)
|
||||
{
|
||||
GList *lp;
|
||||
|
||||
|
||||
acc->editlevel++;
|
||||
|
||||
/* First, recursively free children */
|
||||
@@ -766,7 +766,8 @@ xaccAccountBringUpToDate(Account *acc)
|
||||
********************************************************************/
|
||||
|
||||
kvp_frame *
|
||||
xaccAccountGetSlots(Account * account) {
|
||||
xaccAccountGetSlots(Account * account)
|
||||
{
|
||||
if (!account) return NULL;
|
||||
return(account->kvp_data);
|
||||
}
|
||||
@@ -939,7 +940,7 @@ xaccClearMarkDownGr (AccountGroup *grp, short val)
|
||||
void
|
||||
xaccAccountInsertLot (Account *acc, GNCLot *lot)
|
||||
{
|
||||
GList *sl;
|
||||
GList *sl;
|
||||
Account * old_acc = NULL;
|
||||
|
||||
if (!acc || !lot) return;
|
||||
@@ -963,7 +964,7 @@ xaccAccountInsertLot (Account *acc, GNCLot *lot)
|
||||
{
|
||||
for (sl = lot->splits; sl; sl=sl->next)
|
||||
{
|
||||
Split *s = sl->data;
|
||||
Split *s = sl->data;
|
||||
if (s->acc != acc)
|
||||
{
|
||||
xaccAccountInsertSplit (acc, s);
|
||||
@@ -1000,7 +1001,7 @@ xaccAccountInsertSplit (Account *acc, Split *split)
|
||||
/* if the denominator can't be exactly converted, it's an error */
|
||||
/* FIXME : need to enforce ordering of insertion/value */
|
||||
split->amount = gnc_numeric_convert(split->amount,
|
||||
xaccAccountGetCommoditySCU(acc),
|
||||
acc->commodity_scu,
|
||||
GNC_RND_ROUND);
|
||||
|
||||
/* if this split belongs to another account, remove it from there
|
||||
@@ -1398,7 +1399,7 @@ update_split_commodity(Account * acc)
|
||||
|
||||
xaccTransBeginEdit (trans);
|
||||
s->amount = gnc_numeric_convert(s->amount,
|
||||
xaccAccountGetCommoditySCU(acc),
|
||||
acc->commodity_scu,
|
||||
GNC_RND_ROUND);
|
||||
xaccTransCommitEdit (trans);
|
||||
}
|
||||
@@ -1444,7 +1445,8 @@ xaccAccountSetCommoditySCU (Account *acc, int scu)
|
||||
}
|
||||
|
||||
int
|
||||
xaccAccountGetCommoditySCU (Account * acc) {
|
||||
xaccAccountGetCommoditySCU (Account * acc)
|
||||
{
|
||||
if (!acc) return 0;
|
||||
|
||||
return acc->commodity_scu;
|
||||
@@ -1600,7 +1602,7 @@ xaccAccountGetFullName(Account *account, const char separator)
|
||||
a = account;
|
||||
while (a != NULL)
|
||||
{
|
||||
name = xaccAccountGetName(a);
|
||||
name = a->accountName;
|
||||
|
||||
length += strlen(name) + 1; /* plus one for the separator */
|
||||
|
||||
@@ -1622,7 +1624,7 @@ xaccAccountGetFullName(Account *account, const char separator)
|
||||
a = account;
|
||||
while (a != NULL)
|
||||
{
|
||||
name = xaccAccountGetName(a);
|
||||
name = a->accountName;
|
||||
length = strlen(name);
|
||||
|
||||
/* copy the characters going backwards */
|
||||
@@ -1756,7 +1758,7 @@ xaccAccountGetBalanceAsOfDate (Account *acc, time_t date)
|
||||
xaccAccountSortSplits (acc, TRUE); /* just in case, normally a noop */
|
||||
xaccAccountRecomputeBalance (acc); /* just in case, normally a noop */
|
||||
|
||||
balance = xaccAccountGetBalance( acc );
|
||||
balance = acc->balance;
|
||||
|
||||
/* Since transaction post times are stored as a Timespec,
|
||||
* convert date into a Timespec as well rather than converting
|
||||
@@ -1765,7 +1767,7 @@ xaccAccountGetBalanceAsOfDate (Account *acc, time_t date)
|
||||
ts.tv_sec = date;
|
||||
ts.tv_nsec = 0;
|
||||
|
||||
lp = xaccAccountGetSplitList( acc );
|
||||
lp = acc->splits;
|
||||
while( lp && !found )
|
||||
{
|
||||
xaccTransGetDatePostedTS( xaccSplitGetParent( (Split *)lp->data ),
|
||||
@@ -1794,12 +1796,20 @@ xaccAccountGetBalanceAsOfDate (Account *acc, time_t date)
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
GList *
|
||||
xaccAccountGetSplitList (Account *acc) {
|
||||
SplitList *
|
||||
xaccAccountGetSplitList (Account *acc)
|
||||
{
|
||||
if (!acc) return NULL;
|
||||
return (acc->splits);
|
||||
}
|
||||
|
||||
LotList *
|
||||
xaccAccountGetLotList (Account *acc)
|
||||
{
|
||||
if (!acc) return NULL;
|
||||
return (acc->lots);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
@@ -2466,7 +2476,7 @@ xaccAccountSetPriceSrc(Account *acc, const char *src)
|
||||
|
||||
xaccAccountBeginEdit(acc);
|
||||
{
|
||||
GNCAccountType t = xaccAccountGetType(acc);
|
||||
GNCAccountType t = acc->type;
|
||||
|
||||
if((t == STOCK) || (t == MUTUAL) || (t == CURRENCY)) {
|
||||
kvp_frame_set_slot_nc(acc->kvp_data,
|
||||
@@ -2488,7 +2498,7 @@ xaccAccountGetPriceSrc(Account *acc)
|
||||
GNCAccountType t;
|
||||
if(!acc) return NULL;
|
||||
|
||||
t = xaccAccountGetType(acc);
|
||||
t = acc->type;
|
||||
if((t == STOCK) || (t == MUTUAL) || (t == CURRENCY))
|
||||
{
|
||||
kvp_value *value = kvp_frame_get_slot(acc->kvp_data, "old-price-source");
|
||||
@@ -2508,7 +2518,7 @@ xaccAccountSetQuoteTZ(Account *acc, const char *tz)
|
||||
|
||||
xaccAccountBeginEdit(acc);
|
||||
{
|
||||
GNCAccountType t = xaccAccountGetType(acc);
|
||||
GNCAccountType t = acc->type;
|
||||
|
||||
if((t == STOCK) || (t == MUTUAL) || (t == CURRENCY)) {
|
||||
kvp_frame_set_slot_nc(acc->kvp_data,
|
||||
@@ -2530,7 +2540,7 @@ xaccAccountGetQuoteTZ(Account *acc)
|
||||
GNCAccountType t;
|
||||
if(!acc) return NULL;
|
||||
|
||||
t = xaccAccountGetType(acc);
|
||||
t = acc->type;
|
||||
if((t == STOCK) || (t == MUTUAL) || (t == CURRENCY))
|
||||
{
|
||||
kvp_value *value = kvp_frame_get_slot(acc->kvp_data, "old-quote-tz");
|
||||
@@ -2589,7 +2599,8 @@ xaccAccountVisitUnvisitedTransactions(Account *acc,
|
||||
gboolean (*proc)(Transaction *t,
|
||||
void *data),
|
||||
void *data,
|
||||
GHashTable *visited_txns) {
|
||||
GHashTable *visited_txns)
|
||||
{
|
||||
gboolean keep_going = TRUE;
|
||||
GList *lp;
|
||||
|
||||
@@ -2597,7 +2608,7 @@ xaccAccountVisitUnvisitedTransactions(Account *acc,
|
||||
if(!proc) return(FALSE);
|
||||
if(!visited_txns) return(FALSE);
|
||||
|
||||
for(lp = xaccAccountGetSplitList(acc); lp && keep_going; lp = lp->next) {
|
||||
for(lp = acc->splits; lp && keep_going; lp = lp->next) {
|
||||
Split *s = (Split *) lp->data;
|
||||
Transaction *t = xaccSplitGetParent(s);
|
||||
|
||||
@@ -2620,7 +2631,8 @@ xaccAccountVisitUnvisitedTransactions(Account *acc,
|
||||
gboolean
|
||||
xaccAccountForEachTransaction(Account *acc,
|
||||
gboolean (*proc)(Transaction *t, void *data),
|
||||
void *data) {
|
||||
void *data)
|
||||
{
|
||||
GHashTable *visited_txns = NULL;
|
||||
gboolean result = FALSE;
|
||||
|
||||
@@ -2656,7 +2668,10 @@ finder_help_function(Account *account,
|
||||
|
||||
if (account == NULL) return;
|
||||
|
||||
for (slp = g_list_last (xaccAccountGetSplitList (account));
|
||||
/* Why is this loop iterated backwards ?? Presumably because the split
|
||||
* list is in date order, and the most recent matches should be
|
||||
* returned!? */
|
||||
for (slp = g_list_last (account->splits);
|
||||
slp;
|
||||
slp = slp->prev)
|
||||
{
|
||||
|
||||
@@ -299,7 +299,18 @@ gboolean xaccAccountGetReconcileChildrenStatus(Account *account);
|
||||
|
||||
gnc_numeric xaccAccountGetBalanceAsOfDate (Account *account, time_t date);
|
||||
|
||||
/* The xaccAccountGetSplitList() routine returns a pointer to a GList of
|
||||
* the splits in the account. This GList is the account's internal
|
||||
* data structure: do not delete it when done; treat it as a read-only
|
||||
* structure. Note that some routines (such as xaccAccountRemoveSplit())
|
||||
* modify this list directly, and could leave you with a corrupted
|
||||
* pointer.
|
||||
*
|
||||
* The xaccAccountGetLotList() routine returns a pointer to the GList of
|
||||
* the lots in this account. The same warnings as above apply.
|
||||
*/
|
||||
SplitList* xaccAccountGetSplitList (Account *account);
|
||||
LotList* xaccAccountGetLotList (Account *account);
|
||||
|
||||
gboolean xaccAccountGetTaxRelated (Account *account);
|
||||
void xaccAccountSetTaxRelated (Account *account,
|
||||
|
||||
@@ -2761,6 +2761,13 @@ xaccSplitGetParent (Split *split)
|
||||
return (split->parent);
|
||||
}
|
||||
|
||||
GNCLot *
|
||||
xaccSplitGetLot (Split *split)
|
||||
{
|
||||
if (!split) return NULL;
|
||||
return (split->lot);
|
||||
}
|
||||
|
||||
const char *
|
||||
xaccSplitGetMemo (Split *split)
|
||||
{
|
||||
|
||||
@@ -377,6 +377,7 @@ gnc_numeric xaccSplitGetBaseValue (Split *split,
|
||||
|
||||
/* return the parent transaction of the split */
|
||||
Transaction * xaccSplitGetParent (Split *split);
|
||||
GNCLot * xaccSplitGetLot (Split *);
|
||||
|
||||
/* return the memo, action strings */
|
||||
const char * xaccSplitGetMemo (Split *split);
|
||||
|
||||
+12
-3
@@ -119,6 +119,15 @@ gnc_lot_set_guid (GNCLot *lot, GUID uid)
|
||||
xaccStoreEntity(lot->book->entity_table, lot, &lot->guid, GNC_ID_LOT);
|
||||
}
|
||||
|
||||
GNCLot *
|
||||
gnc_lot_lookup (const GUID *guid, GNCBook *book)
|
||||
{
|
||||
if (!guid || !book) return NULL;
|
||||
return xaccLookupEntity (gnc_book_get_entity_table (book),
|
||||
guid, GNC_ID_LOT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ============================================================= */
|
||||
|
||||
@@ -126,7 +135,7 @@ gboolean
|
||||
gnc_lot_is_closed (GNCLot *lot)
|
||||
{
|
||||
if (!lot) return TRUE;
|
||||
if (0 > lot->is_closed) gnc_lot_get_balance (lot);
|
||||
if (0 > lot->is_closed) gnc_lot_get_balance (lot);
|
||||
return lot->is_closed;
|
||||
}
|
||||
|
||||
@@ -147,8 +156,8 @@ gnc_lot_get_slots (GNCLot *lot)
|
||||
SplitList *
|
||||
gnc_lot_get_split_list (GNCLot *lot)
|
||||
{
|
||||
if (!lot) return NULL;
|
||||
return lot->splits;
|
||||
if (!lot) return NULL;
|
||||
return lot->splits;
|
||||
}
|
||||
|
||||
/* ============================================================= */
|
||||
|
||||
@@ -44,6 +44,8 @@ GNCLot * gnc_lot_new (GNCBook *);
|
||||
void gnc_lot_destroy (GNCLot *);
|
||||
|
||||
const GUID * gnc_lot_get_guid (GNCLot *p);
|
||||
GNCLot * gnc_lot_lookup (const GUID *guid, GNCBook *book);
|
||||
|
||||
|
||||
/* The gnc_lot_add_split() routine adds a split to this lot. Note
|
||||
* that *all* splits in a lot must also be in the same account.
|
||||
|
||||
Reference in New Issue
Block a user