On 10/01/25 17:54, E wrote:
Thank you for looking into this
I think there is the slight difference in that I am adding costs to the
transactions
[...]
Result:
[((1.0 TEST {1.0 USD, 2024-01-01}, 1.0 TEST {1.0 USD, 2024-01-02}, 1.0
TEST {1.0 USD, 2024-01-03}),)]
This is correct. You would get the same result in the interactive
bean-query shell. As you can see, the costs get an implicit date added,
thus the lots cannot be summed together without loss of information.
To get the result you get applying numberify you need to drop the cost
information and sum the units in each posting using the units() BQL
function:
>>> import beanquery
>>> conn = beanquery.connect('beancount:tests/test53.beans')
>>> curs = conn.execute('''
... SELECT sum(units(position))
... WHERE date <= 2024-04-01 AND account ~ "Assets:MyAsset"
... ''')
>>> curs.fetchall()
[((3.0 TEST),)]
Conversely, to sum the costs at the time of the transaction, you can use
the cost() function.
Cheers,
Dan
--
You received this message because you are subscribed to the Google Groups
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/beancount/7ae5435c-01c0-4183-82e2-1025054a9886%40grinta.net.