Issue #422: Allow importers to specify formatting of postings (blais/beancount)

119 views
Skip to first unread message

tbm13

unread,
Feb 25, 2020, 5:07:51 AM2/25/20
to bean...@googlegroups.com
New issue 422: Allow importers to specify formatting of postings
https://bitbucket.org/blais/beancount/issues/422/allow-importers-to-specify-formatting-of

Martin Michlmayr:

By default, bean-extract generates transactions like this:

```
2019-12-07 * "Anonymous" "Donation"
Assets:Receivable 100.00 USD
Income:Donations -100.00 USD
```

I know I can just pipe it into bean-format but I’m wondering if it would be possible to allow importers to format the postings, including spacing and amounts? \(I know I can do amounts by just rounding to the precision I want\).

In any ideal world, this would be per-posting? I like to align different postings with different spacing depending on their nature.

Good idea? Bad idea? Maybe I should just pipe the output to a script that formats it \(that’s actually what I do now\)


Frederick Zhu

unread,
Sep 15, 2023, 12:39:03 AM9/15/23
to Beancount
Hi!

I'd love to reopen this conversation. I think an easy way to go is to provide a way to set up the displaycontext when we write an Importer.

Any thoughts?

Thanks!

Daniele Nicolodi

unread,
Sep 15, 2023, 8:19:27 AM9/15/23
to bean...@googlegroups.com
On 15/09/23 06:29, Frederick Zhu wrote:
> Hi!
>
> I'd love to reopen this conversation. I think an easy way to go is to
> provide a way to set up the displaycontext when we write an Importer.
>
> Any thoughts?

What problem would this solve exactly and how?

Cheers,
Dan

Frederick Zhu

unread,
Sep 17, 2023, 11:02:18 AM9/17/23
to bean...@googlegroups.com
Hi,

I’d like to format my document when extracted. I know bean-format can make alignments for all entries, but first it is another round of iteration, and second, more importantly, it does not attach delimiter to numbers.

For my own usage, I specifically want my currency “USD” ending at column 80, with 2 decimal precision, and the comma delimiter.

Thanks.
> --
> You received this message because you are subscribed to a topic in the Google Groups "Beancount" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/beancount/VmAOLXaGb0s/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to beancount+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/d5d2ed63-811c-fee9-2a4c-3c16bf23805e%40grinta.net.

Daniele Nicolodi

unread,
Sep 17, 2023, 11:54:33 AM9/17/23
to bean...@googlegroups.com
On 17/09/23 17:02, Frederick Zhu wrote:
> Hi,
>
> I’d like to format my document when extracted. I know bean-format can make alignments for all entries, but first it is another round of iteration, and second, more importantly, it does not attach delimiter to numbers.
>
> For my own usage, I specifically want my currency “USD” ending at column 80, with 2 decimal precision, and the comma delimiter.

How is this fixed by letting the Importer specify the displaycontext?

Cheers,
Dan

Frederick Zhu

unread,
Sep 17, 2023, 11:16:22 PM9/17/23
to bean...@googlegroups.com
DisplayContext allows to set the delimiter. Is there any other way to set the delimiter?

Thanks!
Frederick
> --
> You received this message because you are subscribed to a topic in the Google Groups "Beancount" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/beancount/VmAOLXaGb0s/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to beancount+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/9f8c8751-615a-5b7b-f21e-5d9b28c8774a%40grinta.net.

Red S

unread,
Sep 21, 2023, 12:59:39 PM9/21/23
to Beancount

May not be what you’re looking for, but I find autobean-format to excel at at this. It’s now a part of my importer scripts, and is also a part of my editor. Here’s everything except precision:

bean-extract <your_args> | autobean-format - --indent " " --thousands-separator=add --spaces-in-braces --currency-column 80 --cost-column 85

And here’s how I use it in vim:

au Filetype beancount let &formatprg="autobean-format - --sort --indent ' ' --thousands-separator=add --spaces-in-braces --currency-column 80 --cost-column 85"

Frederick Zhu

unread,
Sep 24, 2023, 12:47:37 AM9/24/23
to Beancount
Hi! This is super helpful! I am using this now and it is very powerful.

Thanks!

Reply all
Reply to author
Forward
0 new messages