previous showed income/expense/transfers/totals budget totals, of
uncertain meaning. now shows income/expense/asset/liability/equity
budget totals.
the 5 lines also become sensitive to global sign-reverses property
introduce new API
* gnc_using_unreversed_budgets - queries book's unreversed feature
* gnc_reverse_budget_balance - check if book unreversal status matches
2nd argument. if so, return account's reversal status. else, return
FALSE.
* gnome-budget-view can now show both natural and reversed budgets
* gnome-plugin-page-budget will now read&write both natural and
reversed budgets.
* use fold, more efficient, removes the need for intermediate list
(map cdr (filter filter-fn accounts-balances)): filter will create 1
intermediate list, which is passed as an argument to map which
creates the final list. using fold will remove the need for
intermediate list.
* list->vector for O(1) access
* If currencies are not converted, Unrealized Gains are
meaningless. Hide them.
* If there are no income/expense accounts, retained earnings will be
nil. Remove row.
AQBanking6 uses a separate method for retrieving account numbers
for account info and transactions, where the transactions method can
have additional characters, most often the ISO4217 currency code. That
results in match failures when importing.
As a work-around, compare only the length of the account-info-generated
online id when comparing it to the transaction-generated one.
Note that this is only a partial solution: At least one German bank
also appends characters to the transaction-generated bank id and that
will still cause the match to fail.
Previous code would call gnc:account-get-comm-value-at-date for each
report-date; this function generates qof-query, retrieves account
splits, scans them to accumulate split->transaction->currency and
split->value into a commodity collector.
This commit will hook into the existing gnc:account-accumulate
function, accumulating the same split->transaction->currency and
split->value into a collector.
Note we must make a copy of the accumulator at each report-date
via (gnc:collector+ val-coll) otherwise the same val-coll will be
mutated through subsequent splits.
For a multicolumn balsheet, for every account with N old splits, and
reporting on M report dates, it would run in O(N*M) time. This
algorithm will hook into existing accumulator, i.e. I think O(1).
The majority speed-up however comes from avoiding M qof-queries per
report.
This commit adds tests for multicolumn balance-sheet and
income-statement. It mainly tests:
* multiple periods
* unrealized gains calculators
* amounts/balances are predictable
srfi-9 records can contain complex objects eg lists/vectors also
gnc:monetary or gnc:html-table objects. previously gnc:strify would
use the default printer; this commit modifies so that they are
prettified.
example output; a :col-datum record from balsheet-pnl. the record's
split-balance contains a $0 monetary object.
Rec::col-datum{last-split=#f, split-balance=[$0.00]}
this last pretty-printer must be the last one before object->string,
because we want previous printers which may be records too
eg. monetary->str etc to use their own printer.
Previous would call gnc:account-get-balances-at-dates and
gnc:account-accumulate-at-dates to retrieve balances and
last-split. This commit reduces the O(2*N) operation to O(N) which
becomes significant with accounts with large number of splits.
Maybe we can reduce other account splitlist scans in the future; these
will be easier and would only require augmenting the record.
Some invalid txns with splits in the wrong APAR account can be
processed, creating cases whereby split->owner returns an invalid
freshly-allocated owner.
queries xaccSplitGetNoclosingBalance (which is a pointer dereference)
instead of a more complex conditional-based snippet for split->amount,
should be faster.
The category-barchart change will choose the appropriate split->elt
function according to the account type. This is more efficient than
the old split->amount function which includes a conditional.
Note we don't need to test for account being income/expense:
asset/liability accounts do not have Closing transactions. Therefore
we can use xaccSplitGetNoclosingBalance for splits from any account
type.
if acc has no splits before report-date, the nosplit->elt will specify
the default value to be inserted in the result list.
e.g. consider:
dates are (date1 date2 date3 date4 date5)
account has splits starting after date2:
(gnc:account-accumulate-at-dates account dates
#:split->elt (const 'yea) #:nosplit->elt 'nay)
results in '(nay nay yea yea yea)
previously the payment-amount deduction loop used the
payment-split-list to obtain the invoice-posting-split's amount. this
would occasionally fail and would return the invoice-payment-split
amount, obtaining the wrong sign.
modify to retrieve the invoice total via gncInvoice API.
therefore payment-amount, minus gncInvoiceGetTotal(inv) amounts,
results in the overpayment amount.
previous code was very inefficient: if an account had N old splits and
balance-sheet reported on M recent dates, it would scan splitlist
multiple times: (1) to retrieve splits, (2) filter until
column-date, (3) find the last one. i.e. total O(N * M * 3).
this algorithm pre-generates the account's report-date splits by
scanning each account only once, creating M splits which are queried
by get-cell-anchor-fn via list-ref. i.e. O(N)
it is immedialtely converted to a vector because we want O(1)
access. from get-cell-anchor-fn
a future optimisation may scan the accounts' splitlists once per
report run, acquiring all required data (i.e. last period split,
split->balance, closing entries) in 1 pass, to generate a column-data
record.
this is a generalised form from gnc:account-get-balances-at-dates to
accumulate a list from report dates.
this function will scan through account splitlist, processing each
split via split->elt, accumulating results at date boundaries into the
results list. it uses ice-9 match for conciseness.
in: acc - account
dates - a list of time64
split->elt - an unary lambda. the result of calling (split->elt split)
will be accumulated onto the resulting list. by
default it returns the last split-balance before
date boundary, similar to gnc:account-get-balances-at-dates
out: (list elt0 elt1 ...), each entry is the result of split->elt
because:
* list? is O(N), because it needs to test for an improper
list. improper lists are lists whose last pair's cdr cell is not
'(). null? and pair? are both O(1).
* avoids reverse which is also O(N): guile has unlimited stack
therefore we can do non-tail-call loop first to pass as parameter to
the tail-call loop. this removes the need for prepend-and-reverse.