Changeset - 677c99b565d8
[Not reviewed]
0 3 0
Brett Smith - 4 years ago 2020-06-03 22:51:48
brettcsmith@brettcsmith.org
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.
3 files changed with 22 insertions and 8 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/accrual.py
Show inline comments
...
 
@@ -498,6 +498,7 @@ def main(arglist: Optional[Sequence[str]]=None,
 
            'lineno': 1,
 
        }
 
        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)
 
    groups: PostGroups = dict(AccrualPostings.group_by_meta(postings, 'invoice'))
 
    groups = AccrualAccount.filter_paid_accruals(groups) or groups
tests/books/accruals.beancount
Show inline comments
...
 
@@ -5,6 +5,12 @@
 
2020-01-01 open Expenses:Travel
 
2020-01-01 open Income:Donations
 
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"
 
  rt-id: "rt:40"
...
 
@@ -24,6 +30,13 @@
 
  Liabilities:Payable:Accounts  -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"
 
  rt-id: "rt:505"
 
  invoice: "rt:505/5050"
tests/test_reports_accrual.py
Show inline comments
...
 
@@ -33,10 +33,15 @@ from conservancy_beancount.reports import accrual
 
from conservancy_beancount.reports import core
 

	
 
_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(
 
    1
 
    for entry in _accruals_load[0]
 
    for post in getattr(entry, 'postings', ())
 
    for txn in ACCRUAL_TXNS
 
    for post in txn.postings
 
    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
 
def accrual_postings():
 
    entries = copy.deepcopy(_accruals_load[0])
 
    return data.Posting.from_entries(entries)
 
    return data.Posting.from_entries(copy.deepcopy(ACCRUAL_TXNS))
 

	
 
def check_link_regexp(regexp, match_s, first_link_only=False):
 
    assert regexp
0 comments (0 inline, 0 general)