From 6434055bb1cd3fac4b1c505f5fce65b42127703b Mon Sep 17 00:00:00 2001 From: Dave Peticolas Date: Fri, 21 Apr 2000 19:43:46 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2194 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 3 +++ src/engine/Query.c | 20 ++++++++++++++------ src/engine/Query.h | 3 --- src/quotes/gnc-prices.in | 20 +++++++++++++------- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1febd7613b..6c9dee99ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2000-04-21 Dave Peticolas + * src/engine/Query.c: (xaccFreeQuery): free the split list + (xaccQueryGetSplits) handle a null account group + * src/gnome/dialog-edit.c: figure out all the accounts affected by a currency/security/type change and ask the user whether the needed changes should be made. diff --git a/src/engine/Query.c b/src/engine/Query.c index 0d403f9b8d..59388c2ea7 100644 --- a/src/engine/Query.c +++ b/src/engine/Query.c @@ -96,7 +96,6 @@ xaccInitQuery(Query * q, QueryTerm * initial_term) { q->primary_sort = BY_STANDARD; q->secondary_sort = BY_NONE; q->tertiary_sort = BY_NONE; - } @@ -133,7 +132,6 @@ xaccQuerySingleTerm(Query * q, QueryTerm * qt) { and->data = qt; or->data = and; q->terms = or; - } @@ -163,6 +161,7 @@ xaccFreeQuery(Query * q) { g_list_free(g_list_nth_data(gl, i)); } g_list_free(gl); + g_free(q->split_list); g_free(q); } @@ -655,12 +654,12 @@ xaccQueryGetSplits(Query * q) { and_ptr = or_ptr->data; or_ptr->data = g_list_sort(and_ptr, query_sort_func); } - + /* iterate over accounts */ all_accts = xaccGetAccounts(q->acct_group); - for(ptr = all_accts; *ptr; ptr++) { + for(ptr = all_accts; ptr && *ptr; ptr++) { current = *ptr; - + /* first, check this account to see if we need to look at it at * all. If the query is "ANY" matching or "NONE" matching, you * get what you expect; if it's "ALL" matching, only the first @@ -804,7 +803,7 @@ xaccQueryAddSingleAccountMatch(Query * q, Account * acct, } else { qr = xaccQueryMerge(q, qs, QUERY_OR); - } + } xaccQuerySwapTerms(q, qr); xaccFreeQuery(qs); xaccFreeQuery(qr); @@ -1511,6 +1510,15 @@ xaccMemoMatchPredicate(Split * s, PredicateData * pd) { } +/******************************************************************* + * xaccMiscMatchPredicate + * *** Bill, please complete! *** + *******************************************************************/ +int xaccMiscMatchPredicate(Split * s, PredicateData * pd) { + return 0; +} + + /******************************************************************* * xaccAmountMatchPredicate *******************************************************************/ diff --git a/src/engine/Query.h b/src/engine/Query.h index bbd0083978..9b2276c19b 100644 --- a/src/engine/Query.h +++ b/src/engine/Query.h @@ -217,6 +217,3 @@ time_t xaccQueryGetLatestDateFound(Query * q); #endif - - - diff --git a/src/quotes/gnc-prices.in b/src/quotes/gnc-prices.in index 50a20e1e60..a8a426c775 100644 --- a/src/quotes/gnc-prices.in +++ b/src/quotes/gnc-prices.in @@ -47,24 +47,28 @@ sub account_flatlist } # -------------------------------------------------- -# &checkprice ($account, $date); +# &checkprice ($account, $date, $price); # This routine checks to see if the account has already stored a -# price for this day, returning 1 if yes otherwise 0/undefined. +# price for this day, returning 1 if yes and the price is the same +# as the one given, otherwise 0/undefined. sub checkprice { my $acct = $_[0]; my $dayte = $_[1]; + my $price = $_[2]; my ($query, $datesecs, $earliest, $latest); - my ($splitlist, $i, $split, $action); + my ($splitlist, $i, $split, $action, $pryce); my $retn_value = 0; $datesecs = gnucash::xaccScanDateS ($dayte); $earliest = $datesecs - 16*3600; # subtract 16 hours $latest = $datesecs + 16*3600; # add 16 hours $query = gnucash::xaccMallocQuery(); - gnucash::xaccQueryAddAccount ($query, $acct); - gnucash::xaccQuerySetDateRange ($query, $earliest, $latest); + gnucash::xaccQuerySetGroup($query, gnucash::xaccAccountGetParent($acct)); + gnucash::xaccQueryAddSingleAccountMatch ($query, $acct, $gnucash::QUERY_AND); + gnucash::xaccQueryAddDateMatchTT ($query, $earliest, $latest, + $gnucash::QUERY_AND); $splitlist = gnucash::xaccQueryGetSplits ($query); $i = 0; @@ -72,7 +76,8 @@ sub checkprice while ($split && ($retn_value == 0)) { $action = gnucash::xaccSplitGetAction ($split); - if ($action eq "Price") { $retn_value = 1; } + $pryce = gnucash::xaccSplitGetSharePrice ($split); + if (($action eq "Price") && ($price == $pryce)) { $retn_value = 1; } $i++; $split = gnucash::IthSplit ($splitlist, $i); } @@ -208,7 +213,8 @@ foreach $acct (@acctlist) print "$security $prodname last price = $price at $dayte\n"; # This || construction will store the price if its not already # stored (in the 28 hour period surrounding "dayte") - &checkprice ($acct, $dayte) || &setprice ($acct, $dayte, $price); + &checkprice ($acct, $dayte, $price) || + &setprice ($acct, $dayte, $price); } } }