>
> >- Using prices in imports
>>
> >>
>> >> For some imports I would like to enhance the transactions with prices
>> >> based on current/daily price, I'm currently fetching and storing
>> >prices
>> >> in beancount, so prices are available in the beancount file but I'm
>> >not
>> >> sure what the best way to hook this into the importer framework is
>> >>
>> >
>> >Fetching prices automatically /is/ OTOH intended to be automated.
>> >(Note that we're in a funny situation right now with both Yahoo and
>> >Google
>> >Finance APIs disabled.)
>> >
>> >These are two separate processes at the moment; run one, then the
>> >other.
>> >Concatenate to a file if you want to.
>>
>> That's what I'm doing. What I'm looking is how to access the prices from 
>> the beancount file in the importer, do I have to parse/load the beancount 
>> file o  my own?
>>
>
> Yes.
> You'd call beancount.loader.load_file() on your existing file, and then 
> build a price_map dict.
> Grep for "price_map" in the source code, you'll find several examples of 
> doing that.
>
>
I'm wondering if it would make sense to slightly enhance the 
ImporterProtocol. Right now bean-extract has already the ability to parse 
an existing beancount file and use this for duplicate detection.
Now if those entries could be forwarded to the importer it would open up 
some use cases such as:

* custom duplicate logic (e.g. let's say my import file has a unique 
identifier which I map to metadata on the transaction, if I now get the 
existing import entries, I can make sure to only import new transactions 
and either completely ignore duplicates or tag them with the __duplicate__ 
meta

* my use case where I need data (e.g. prices) from the existing beancount 
file to enhance the new entries 

I think all that would be needed is to add existingEntries to the extract 
method:

importer.extract(file, existing_entries)


That way there is no additional parsing of beancount file needed and there 
is a clear way to define which file to parse (e.g. same way to do it when 
called from fava as well as from bean-extract)

-- 
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 post to this group, send email to beancount@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/6f03b0d2-eb20-41f2-a030-2a109753d9a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to