On Thu, Nov 29, 2018 at 10:13 AM Zhuoyun Wei <[email protected]> wrote:
> 2018-11-29 14:14:44 Oon-Ee Ng <[email protected]>: > > On Thu, Nov 29, 2018 at 2:06 PM Daniele Nicolodi <[email protected]> > wrote: > > > > On 28/11/2018 20:53, Martin Blais wrote: > > > The current source file for importing that I'm working on lists > > > transaction in reverse chronological order (I want > chronological, in > > > this case) but also has a reference number that is > monotonically > > > increasing. So my current hack is to set line number for the > > > transactions to be that reference number. > > > > > > > > > That seems not unlike the idea of storing the time in metadata - > > > discussed in a prior thread but not yet implemented - and to use > that as > > > a secondary sort key. Maybe I can generalize this idea of a > secondary > > > sort key to let users put whatever they want in there (as long as > the > > > type is comparable, for sorting). > > > > Aren't directives written in the order in which they are returned by > the > > importer? I didn't see any mention of the fact that bean-extract > does > > any sorting on its own in the documentation, but I may have missed > it. > > > > Cheers, > > Dan > > > > > > That was my impression as well, but after testing it out I found this > was not the case. The returned ordered list of > > transactions is then sorted by date and line number. > > > > I was once troubled by this sorting behaviour as well. Intra-day > transactions are sorted reverse-chronologically (newer to older) in the > CSV file exported from my bank. My importer parses the entries in > reversed order, returning a correctly ordered list of transactions > (older to newer). However, Beancount will again sort the list returned > by importer, shuffling the intra-day transactions: > > > https://github.com/beancount/beancount/blob/fb2d29eed89a8e15f1635847beba0e5598c0ea06/beancount/ingest/extract.py#L73-L74 > > I had once submitted a pull request to disable this behaviour, it was > merged but later reverted by Martin. > The original context is here: https://bitbucket.org/blais/beancount/issues/219 https://bitbucket.org/blais/beancount/commits/03d9a5c3b2784a6f6a05c12eaeb7776f0478a96d So I came up with a workaround: > > ``` > # Re-generate "lineno" to force sorting > for lineno, entry in enumerate(entries, start=1): > entry.meta['lineno'] = lineno > ``` > > Just generate artificial "lineno" keys and insert them into the > transactions before returning them to Beancount. This way I can preserve > the order. > > A possible approach to make both parties happy would be to add a new > parameter to "extract_from_file()" function, allowing importers to > disable the sorting behaviour in post-processings. > > > > -- > > 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/ > > CAGQ70esZ%2BSFkn4VcaG1dh%2BP1i%3DNgQ9rHvSdx-_8eVKvJ1%3DcRMg% > 40mail.gmail.com. > > For more options, visit https://groups.google.com/d/optout. > > -- > Zhuoyun Wei > > -- > 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/20181129151330.GA28669%40tarball.wzyboy.org > . > 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%2BhPmLFSYoDHD6F1J92jW7xye7rCfwF4EKf4t7UdvO0KnWA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
