On 21/07/23 23:06, Eric Altendorf wrote:
> I'm trying to figure out whether I can use the Beangulp import driver
> with hooks, or if I need to write my own driver to call my importers and
> do postprocessing. As you may recall, my workflow is atypical, as I
> have no curated Beancount ledger file; my source of truth are my input
> data files and the Beancount ledger is a built artifact for running
> analysis.
>
> There are two things I'd like to do that I don't think are currently
> possible; I'd appreciate feedback on whether these seem like things
> Beangulp should support (I could contribute a patch), or if I'm better
> off finding a different solution:
>
> - I'd like to deduplicate entries among different importers in a single
> run, not just dedup against a pre-existing ledger
I was going to reply that this is already supported, then I realized
that I never merged the patch implementing it
https://github.com/beancount/beangulp/pull/64 I'm going to rebase and
merge it ASAP.
> - I'd like to be able to emit the output file globally sorted by date
> (first the official entry date, then secondarily by a timestamp attached
> to the metadata) rather than grouped by import file. (Broadly this will
> make it easier for me to debug issues sequentially, and ordering
> within-day may alleviate some of the issues I've seen with same-day
> purchase & transfer transactions.)
It is trivial to post-process the output of beangulp to apply any
ordering you like. Indeed I do something very similar for ledgers.
Writing from memory:
import beanquery.parser.parser
import beanquery.parser.printer
def key(entry):
return (entry.date, entry.meta['timestamp'])
entries, errors, options = parser.parse_file(filename)
entries.sort(key=key)
printer.print_entries(entries)
> And just to double check that this should already be possible:
>
> - I'd like to be able to add entries (i.e., account declarations,
> initial balance pads, etc.) via a hook
You can do this as part of the sorting post-processing step, or with a
beancount plugin. See for example the beancount.plugins.auto_accounts
(and other) plugins.
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/3fdc241b-1fae-062b-22c6-42b718bd00cf%40grinta.net.
On 23/07/23 03:58, Eric Altendorf wrote:
...
> I'm not sure how one is supposed to run multiple importers at once, the
> doc kind of only describes running one.
This is a design document, not user documentation. What has been
implemented does not necessarily exactly reflects that design.
Unfortunately the documentation for beangulp is coming along slowly. The
best there is are probably the examples in the package.
This looks correct, but you can simplify it a tiny bit: the Ingest
object can be called directly:
ingest = beangump.Ingest(importers, hooks)
ingest()
It should, but I just found that indeed I overlooked some divergence in
the code paths between the time the intra-importer deduplication patches
were written and the time I merged them. As a result, the intra-importer
deduplication is not run. This is what you get when you leave patches
not merged for years. I'm fixing it now.
> There seems to be a fairly good default implementation of similarity
> comparison, yes?
"fairly good" ?
> Hmm, OK, that may work fine, thanks.
"may work fine" ?
These tools have been written to scratch the itch of the persons that
wrote them. If you think that you can find something better elsewhere,
or that you can write something better yourself, you are free to do so.
Just let me know and I'll process a refund for your support contract.