accrual: Filter opening balance txn before main reporting.

So far we've been implicitly relying on this by the user passing search
terms that filter out the opening balance transaction. That will stop
happening with the aging report, so we need to do it ourselves.
This commit is contained in:
Brett Smith 2020-06-02 13:40:21 -04:00
parent 39c9c0d83a
commit 677c99b565
3 changed files with 22 additions and 8 deletions

View file

@ -498,6 +498,7 @@ def main(arglist: Optional[Sequence[str]]=None,
'lineno': 1, 'lineno': 1,
} }
load_errors = [Error(source, "no books to load in configuration", None)] load_errors = [Error(source, "no books to load in configuration", None)]
filters.remove_opening_balance_txn(entries)
postings = filter_search(data.Posting.from_entries(entries), args.search_terms) postings = filter_search(data.Posting.from_entries(entries), args.search_terms)
groups: PostGroups = dict(AccrualPostings.group_by_meta(postings, 'invoice')) groups: PostGroups = dict(AccrualPostings.group_by_meta(postings, 'invoice'))
groups = AccrualAccount.filter_paid_accruals(groups) or groups groups = AccrualAccount.filter_paid_accruals(groups) or groups

View file

@ -5,6 +5,12 @@
2020-01-01 open Expenses:Travel 2020-01-01 open Expenses:Travel
2020-01-01 open Income:Donations 2020-01-01 open Income:Donations
2020-01-01 open Liabilities:Payable:Accounts 2020-01-01 open Liabilities:Payable:Accounts
2020-01-01 open Equity:Funds:Opening
2020-03-01 * "Opening balances"
Equity:Funds:Opening -1000 USD
Assets:Receivable:Accounts 6000 USD
Liabilities:Payable:Accounts -5000 USD
2020-03-05 * "EarlyBird" "Payment for receivable from previous FY" 2020-03-05 * "EarlyBird" "Payment for receivable from previous FY"
rt-id: "rt:40" rt-id: "rt:40"
@ -24,6 +30,13 @@
Liabilities:Payable:Accounts -75 USD Liabilities:Payable:Accounts -75 USD
Expenses:Travel 75 USD Expenses:Travel 75 USD
2020-04-30 ! "Vendor" "Travel reimbursement"
rt-id: "rt:310"
contract: "rt:310/3100"
invoice: "FIXME" ; still waiting on them to send it
Liabilities:Payable:Accounts -200 USD
Expenses:Travel 200 USD
2020-05-05 * "DonorA" "Donation pledge" 2020-05-05 * "DonorA" "Donation pledge"
rt-id: "rt:505" rt-id: "rt:505"
invoice: "rt:505/5050" invoice: "rt:505/5050"

View file

@ -33,10 +33,15 @@ from conservancy_beancount.reports import accrual
from conservancy_beancount.reports import core from conservancy_beancount.reports import core
_accruals_load = bc_loader.load_file(testutil.test_path('books/accruals.beancount')) _accruals_load = bc_loader.load_file(testutil.test_path('books/accruals.beancount'))
ACCRUAL_TXNS = [
entry for entry in _accruals_load[0]
if hasattr(entry, 'narration')
and entry.narration != 'Opening balances'
]
ACCRUALS_COUNT = sum( ACCRUALS_COUNT = sum(
1 1
for entry in _accruals_load[0] for txn in ACCRUAL_TXNS
for post in getattr(entry, 'postings', ()) for post in txn.postings
if post.account.startswith(('Assets:Receivable:', 'Liabilities:Payable:')) if post.account.startswith(('Assets:Receivable:', 'Liabilities:Payable:'))
) )
@ -74,14 +79,9 @@ class RTClient(testutil.RTClient):
} }
@pytest.fixture
def accrual_entries():
return copy.deepcopy(_accruals_load[0])
@pytest.fixture @pytest.fixture
def accrual_postings(): def accrual_postings():
entries = copy.deepcopy(_accruals_load[0]) return data.Posting.from_entries(copy.deepcopy(ACCRUAL_TXNS))
return data.Posting.from_entries(entries)
def check_link_regexp(regexp, match_s, first_link_only=False): def check_link_regexp(regexp, match_s, first_link_only=False):
assert regexp assert regexp