On Tue, Aug 27, 2019, at 19:50, Martin Blais wrote:
> 
> 
> On Tue, Aug 27, 2019 at 6:30 PM Aleksandra Culver <[email protected]> 
> wrote:
>> __
>> 
>> 
>> On Tue, Aug 27, 2019, at 06:17, Martin Blais wrote:
>>> On Tue, Aug 27, 2019 at 3:16 AM <[email protected]> wrote:
>>>> Hi,
>>>> 
>>>> I've recently migrated to Beancount from Ledger. I'm really happy with it 
>>>> so far. :)
>>>> 
>>>> One issue I've had is around transaction ordering across files. (To be 
>>>> clear, this is not at all a criticism of Beancount relative to Ledger; the 
>>>> plugin I'm trying to write wouldn't be possible in Ledger for a dozen 
>>>> reasons.)
>>>> 
>>>> I mostly keep one file per "physical" account (e.g. one file for my 
>>>> Vanguard 401k). I also have a "budget" file that keeps transactions I use 
>>>> for envelope budgeting. Some of the budget transactions are logically 
>>>> linked with a debit to my checking account; in effect, money is divided up 
>>>> the instant it arrives.
>>>> 
>>>> I'm trying to implement a plugin that ensures that my various budget 
>>>> accounts never drop below zero. However, if I'm reading the code 
>>>> correctly, transactions are sorted based on their date, type, and line 
>>>> number -- but not based on filename, and not based on anything that a 
>>>> plugin is supposed to be able to control.
>>>> 
>>>> My questions are:
>>>> 
>>>> 1. Is there a reason for this particular sorting order? It seems odd that 
>>>> line number would be used without filename -- it means that the order of 
>>>> two transactions could be changed by adding a lot of whitespace to one 
>>>> file, or by adding/removing metadata tags. (I tested this out, and 
>>>> confirmed that whitespace does have this effect.)
>>> 
>>> Hmm, I think it's an oversight. Sorting should be stable. I should add the 
>>> filename to the sort key.
>>> https://bitbucket.org/blais/beancount/src/fe747dea5ce9eddfb4910b9edfdec1134f0a6c85/beancount/core/data.py#lines-581
>>> 
>>> 
>>>> 2. More generally, are there any recommended patterns for imposing partial 
>>>> orders on transactions in different files? I know that I could put 
>>>> everything in one file, but I'd rather not; it's much easier for me to 
>>>> read and write (and make bulk changes to) my files if they're split up as 
>>>> they are now.
>>> 
>>> I think the absolute filename should disambiguate it enouhg.
>>> 
>>> 
>>>> 
>>>> 
>>>> Note that addressing #1 (e.g. by changing the sort key to include filename 
>>>> before lineno) would not fully address my use case, since I want to 
>>>> interleave transactions between different files.
>>> 
>>> I don't understand this. They would be sorted by date, but within each 
>>> date, sorted by file, and then by line number.
>>> (You're not supposed to rely on ordering within a day, Beancount does not 
>>> provide guarantees on ordering that way, just stable ordering.)
>> 
>> I guess I was too tired last night to think about this properly. :) I 
>> updated my plugin so that it only checks balances at day boundaries, and now 
>> it works perfectly. Thanks for your help! :)
> 
> Do you still need me to insert the filename in the sort key?
> (I think I should do that regardless, to ensure stable sort.) 
> Let me know,

It no longer makes a difference for my plugin, but I agree it's a good idea 
anyway. :)

> 
> 

> --
>  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/gFbCDBZ1dt4/unsubscribe.
>  To unsubscribe from this group and all its topics, send an email to 
> [email protected].
>  To view this discussion on the web visit 
> https://groups.google.com/d/msgid/beancount/CAK21%2BhPRftoWtd_njvZGVpm_c0tYWcWoLreZ4npWVbqAsRqQHA%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/beancount/CAK21%2BhPRftoWtd_njvZGVpm_c0tYWcWoLreZ4npWVbqAsRqQHA%40mail.gmail.com?utm_medium=email&utm_source=footer>.

--
 Aleksandra Culver (pronouns: she/her)
 [email protected]

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/ac0acf0c-80f6-49c7-b0a3-d7caa2f56f6b%40www.fastmail.com.

Reply via email to