I am using beancount 2.3.5
<https://github.com/beancount/beancount/tree/2.3.5> and I am trying to
write a proof of concept file that does the following:
1. Creates a simple chart of accounts
2. Posts sample transactions into ledgers using double entry
This is my code:
from datetime import datetime
from decimal import Decimal as D
import beancount.core.data as data
line_number = 42
metadata = data.new_metadata(filename='./myfile.beancount',
lineno=line_number)
# define accounts
accounts = ["Assets:Bank", "Expenses:Groceries"]
# create postings
posting1 = data.Posting(accounts[0], data.Amount(D('1000'), 'USD'), None,
None, None, meta=metadata)
posting2 = data.Posting(accounts[1], data.Amount(D('200'), 'USD'), None,
None, None, meta=metadata)
# create transactions
transaction1 = data.Transaction( meta = metadata, date = datetime.strptime(
"2022-03-29", '%Y-%m-%d'), flag = "*", payee = "Bob's Grocery Store",
narration = "Groceries for the week", tags = set(), links = set(), postings
= [posting1, posting2] )
After I run the code, I expect to see a newly created file myfile.beancount
with
the above transactions in it. However, no file is generated.
I suspect that I might have to mark the accounts as open first, but I can't
see anywhere in the documentation (or a function/method in the source code)
that provides a clean entrypoint to do that.
How do I modify this code so that it creates the file and correctly posts
the transactions to the file?
--
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/dee9093c-4101-4595-b96a-b49dff2e2c6cn%40googlegroups.com.