Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
laermannjan opened this issue Jul 3, 2023 · 0 comments
Open

Comments

@laermannjan
Copy link

laermannjan commented Jul 3, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant