Ah! You're right. I hadn't noticed my version of root already takes a
number.
I'll remove TRUNCATE() you don't need it. Use ROOT()


On Wed, Sep 19, 2018 at 2:23 PM <[email protected]> wrote:

> Hmm.. How is TRUNCATE(account, 3) different from ROOT(account, 3)?
>
> # Operations on accounts.
>
> class Root(query_compile.EvalFunction):
>     "Get the root name(s) of the account."
>     __intypes__ = [str, int]
>
>     def __init__(self, operands):
>         super().__init__(operands, str)
>
>     def __call__(self, context):
>         args = self.eval_args(context)
>         return account.root(args[1], args[0])
>
>
>
> In accounts.py:
>
> def root(num_components, account_name):
>     """Return the first few components of an account's name.
>
>     Args:
>       num_components: An integer, the number of components to return.
>       account_name: A string, an account name.
>     Returns:
>       A string, the account root up to 'num_components' components.
>     """
>     return join(*(split(account_name)[:num_components]))
>
>
>
> Thanks
>
>
> On Tuesday, September 18, 2018 at 1:28:07 PM UTC-5, Martin Blais wrote:
>>
>> Pull & update:
>>
>> https://bitbucket.org/blais/beancount/commits/c5057262f77d7b16fa2250b22f115e9ecee26754
>>
>> bean-query $L 'select truncate(account, 3), convert(cost(sum(position)),
>> "USD") group by 1 order by 1'
>>
>> Also note the existence of the PARENT(), LEAF() and ROOT() functions to
>> act on account name strings.
>> Moreover, if you have mixed assets, you will want to convert or extract
>> the cost in order to view output that's manageable.
>>
>>
>>
>>
>> On Tue, Sep 18, 2018 at 10:29 AM Vikas Rawal <[email protected]> wrote:
>>
>>> I would like create a trial balance report with accounts truncated to a
>>> specific depth (say, two levels).
>>>
>>> How could I modify the following trial balance query to achieve this?
>>>
>>> SELECT account, sum(position)
>>> GROUP BY account
>>> ORDER BY account;
>>>
>>>
>>> Vikas
>>>
>>> --
>>> 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 post to this group, send email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/beancount/CALtzAB280FQqE20Pdkoj%2B7FTa0GCXy8JfDuxmvaNS0Z7ExNGsA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/beancount/CALtzAB280FQqE20Pdkoj%2B7FTa0GCXy8JfDuxmvaNS0Z7ExNGsA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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 post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/beancount/2edcf0d0-5510-4523-aaa1-97c2658b6014%40googlegroups.com
> <https://groups.google.com/d/msgid/beancount/2edcf0d0-5510-4523-aaa1-97c2658b6014%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAK21%2BhNgPyQ9%2BQ2p_5Ebe5Jx-d_oxmrO8RucdYXZXYu1o580pA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to