beancount / beanquery

A customizable lightweight SQL query tool that works on tabular data, including Beancount.
GNU General Public License v2.0
20 stars 12 forks source link

posting flag ignored / how to query posting flag? #41

Closed blais closed 2 years ago

blais commented 5 years ago

Original report by Martin Michlmayr (Bitbucket: tbm13, GitHub: tbm).


The syntax manual says "You can also attach flags to the postings themselves, if you want to flag one of the transaction’s legs in particular"

However, when I query f on an account (posting) I don't see the one marked as !:

beancount> SELECT account, position, flag WHERE account ~ ':A'
account  position  f
-------- --------- -
Assets:A 11.00 EUR *
Assets:A 22.00 EUR *
Assets:A 33.00 EUR *
beancount> 

Is there a different way to query the posting flag?

Test case:

2018-01-01 open Assets:A
2018-01-01 open Assets:B

2018-01-01 txn "Test 1"
    aXa: "foo"
    Assets:A      11.00 EUR
    Assets:B

2018-01-01 txn "Test 2"
    axa: "bar"
    ! Assets:A    22.00 EUR
    Assets:B

2018-01-01 txn "Test 3"
    axa: "bar"
    * Assets:A    33.00 EUR
    Assets:B
dnicolodi commented 2 years ago

For postings flags, the column name is called posting_flag. If you want the posting flag if defined otherwise the transaction flag, you can use something like

SELECT account, position, coalesce(posting_flag, flag) WHERE account ~ ':A'