autobean icon indicating copy to clipboard operation
autobean copied to clipboard

autobean.share.include doesn't scope share policies inside ledgers

Open laermannjan opened this issue 1 year ago • 0 comments

Once more thanks for these plugins. I've been using them all over my ledgers and really enjoy them!

However, I've found a problem with the autobean.share.include - though I am not completely sure if I'm using this wrong.

The docs in advanced.md say

autobean.share.include is different from the builtin include directive in that it is hierarchical: Plugins are evaluated inside the included ledgers. Share policies are scoped inside the included ledger. Receivable account name and viewpoint are determined by the outermost ledger.

I cannot get this to work. I have the following test setup:

; accounts.beancount
2020-10-01 open Assets:DKB:Giro
2021-01-01 open Assets:GLS:Giro
  share-Jan: 1
  share-Sabs: 1
1990-01-01 open Assets:Transfers:Accounts

1990-01-01 open Expenses:Food:Groceries
1990-01-01 open Expenses:Home:Rent
1990-01-01 open Expenses:Leisure


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; jan.beancount

include "accounts.beancount"

2000-01-01 custom "autobean.share.policy" "Expenses:*"
  share-Jan: 1

2023-01-01 * "Salary"
  Income:Salary
  Assets:DKB:Giro   3000.00 EUR

2023-01-02 * "Rent & Groceries"
  Assets:DKB:Giro  -1300.00 EUR
  Assets:Transfers:Accounts
;
2023-01-03 * "TV"
  Assets:DKB:Giro   -500.00 EUR
  Expenses:Purchases:Electronics

2023-02-01 * "Party"
  Assets:DKB:Giro   -300.00 EUR
  Expenses:Leisure


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; shared.beancount

include "accounts.beancount"

2023-01-01 open Income:Sabs
  share-Sabs: 1

2023-01-01 custom "autobean.share.policy" "Expenses:*"
  share-Jan: 1
  share-Sabs: 1

2023-01-02 * "Jan" "Rent & Groceries"
  Assets:GLS:Giro   1300.00 EUR
  Assets:Transfers:Accounts

2023-01-02 * "Sabs" "Rent & Groceries"
  Assets:GLS:Giro   1100.00 EUR
  Income:Sabs

2023-01-03 * "Stefan" "Rent"
  Assets:GLS:Giro  -1800.00 EUR
  Expenses:Home:Rent
    share-Jan: 1000.00
    share-Sabs: 800.00

2023-01-04 * "Groceries"
  Assets:GLS:Giro   -200.00 EUR
  Expenses:Food:Groceries


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; main.beancount

option "operating_currency" "EUR"
plugin "autobean.share" "Jan"
2000-01-01 custom "autobean.share.include" "shared.beancount"
2000-01-01 custom "autobean.share.include" "jan.beancount"

note: I need to include "accounts.beancount" in every ledger, because including it in main.beancount will in fact complain that the accounts are undefined.

What happens is that the policy with the more recent date takes effect for every transaction starting from that date in every ledger. So the policy defined in shared.beancount will also apply to all transactions in jan.beancount. This is not affected by the include order or their dates in main.beancount. I assumed from the docs that I can specify policies in each file and they will be only evaluated within that file if I use autobean.share.include. Did I misunderstand this or am I using this wrong?

If I don't use default or wildcard policies, but attach the a policy to every posting instead, everything works as expected.

laermannjan avatar Jul 03 '23 05:07 laermannjan