Posting https://github.com/beancount/beancount/blob/master/beancount/core/data.py#L184
Position https://github.com/beancount/beancount/blob/master/beancount/core/position.py#L154 CostSpec (after parsing) https://github.com/beancount/beancount/blob/master/beancount/core/position.py#L40 Cost (after processing) https://github.com/beancount/beancount/blob/master/beancount/core/position.py#L25 On Sat, Feb 4, 2023 at 4:07 PM Chary Chary <chary...@gmail.com> wrote: > Martin, Dan, > > thanks > > Regarding: > > * A position is roughly (units, cost-basis) > * A Position is an Amount with attached a Cost specification. > > Question: what is then the formal definition of the cost, especially in > the situation, when > > units=100 EUR, > cost=None, > > As I understand, the cost will be 100 Euro. But what is the formal > definition of the cost in the beancount world? > > > On Saturday, February 4, 2023 at 3:30:06 PM UTC+1 bl...@furius.ca wrote: > On Sat, Feb 4, 2023 at 7:46 AM Daniele Nicolodi <dan...@grinta.net> wrote: > On 04/02/23 12:24, Chary Chary wrote: > > Dan, > > > > OK, thanks. But just some clarification. > > > > > > If I look at the following simple Transaction: > > > > 2000-01-02 * "Buying something in Euro" > > Assets:NL:ING:Payment -100 EUR > > Expenses:Misc 100 EUR > > > > Then does it have position or not? > > Transactions do not have positions. Transactions contain postings. Each > posting has an account and a position (although they are not spelled out > like that in the data structure, see below). > > That's right. > A position is roughly (units, cost-basis) > A posting is roughly position + (account, price) > In inventories we track positions (potentially across accounts) > Price is only used for conversions within the transactions. > So when accumulating postings, account and price can be dropped, thus > position. > > I'm sure there are many other ways to design data structures for > aggregation but that's what I chose at the time. > > > > > I can see *tarnsaction, postings*, *units*, but I do not see a *position* > > > > However if I use beanquery, then beanquery does see the position: > > There is not alway a 1:1 mapping between the Beancount data model and > the tables definitions used by beanquery. In this case, the 'position' > column is obtained from the units and cost fields in the Posting object. > > https://github.com/beancount/beanquery/blob/f224aa8161495b9fddb7c7f712e5103b8b8b59e3/beanquery/query_env.py#L1054-L1058 > > I don't know why it was chosen to have a 'position' column but not an > 'amount' column in beanquery. Most likely because a position without a > cost is pretty much equivalent to an amount from a beanquery point of view. > > Which amount? > There's a units amount, but a position can be reduced to its cost amount > by applying the cost basis to its units. > You can either > - aggregate the positions and then reduce to cost, or > - reduce all positions to their cost amount and then aggregate them > I think both work. > > select parent(account), cost(sum(position)) ... > select parent(account), sum(cost(position)) ... > > > > So, the position here is 100 EUR, however in Python data structure, > > it does not have a cost, which is, per your definition, is not a > position. > > > > So, once again, what is the definition of a *position *then? > > I forgot an "optional" in the definition of Position: > > A Position is an Amount with attached an /optional/ Cost specification > > I think > https://beancount.github.io/docs/beancount_query_language.html#data-types > does quite good job in explaining the data types used in BQL and what > they represent. > > Thanks! > Eventually I'll document those from a public API perspective, e.g. in v3 > there is > https://github.com/beancount/beancount/blob/master/beancount/api.py > In v3 it will be nice to break out the booking into its individual parts > and let users play with those with an import like > > import beancount as bn > inv = bn.Inventory(...) > ... > > > 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 beancount+...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/beancount/d3508404-780f-c55b-9b81-ba0e8fdd65c0%40grinta.net > . > > -- > 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 beancount+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/beancount/bdc48be7-baaf-4b3d-a77d-879e14fcfc3bn%40googlegroups.com > <https://groups.google.com/d/msgid/beancount/bdc48be7-baaf-4b3d-a77d-879e14fcfc3bn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 beancount+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CAK21%2BhNNQGh2xdchgP4uEC3yid44YLrUwRwh7B_CPMqDkL0b4Q%40mail.gmail.com.