Changeset - 708d48699ae3
[Not reviewed]
0 3 0
Brett Smith - 4 years ago 2020-07-20 19:13:20
brettcsmith@brettcsmith.org
accrual: Restore "since last nonzero" behavior to outgoing report.

Basically this behavior is an extension of the fact that the outgoing report
is grouped by RT ticket rather than "accrual data." Ripping this
functionality out of other reports was correct, but it needed to stay for
the outgoing report.
3 files changed with 20 insertions and 4 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/accrual.py
Show inline comments
...
 
@@ -539,6 +539,15 @@ class OutgoingReport(BaseReport):
 
            )
 
            requestor = f'{requestor_name} <{rt_requestor["EmailAddress"]}>'.strip()
 

	
 
        last_zero_index = -1
 
        for index, (post, balance) in enumerate(posts.iter_with_balance()):
 
            if balance.is_zero():
 
                prior_zero_index = last_zero_index
 
                last_zero_index = index
 
        if last_zero_index == index:
 
            last_zero_index = prior_zero_index
 
        posts = posts[last_zero_index + 1:]
 

	
 
        balance = -posts.balance_at_cost()
 
        balance_s = balance.format(None)
 
        raw_balance = -posts.balance()
setup.py
Show inline comments
...
 
@@ -5,7 +5,7 @@ from setuptools import setup
 
setup(
 
    name='conservancy_beancount',
 
    description="Plugin, library, and reports for reading Conservancy's books",
 
    version='1.5.10',
 
    version='1.5.11',
 
    author='Software Freedom Conservancy',
 
    author_email='info@sfconservancy.org',
 
    license='GNU AGPLv3+',
tests/test_reports_accrual.py
Show inline comments
...
 
@@ -510,9 +510,16 @@ def test_outgoing_report(accrual_postings, caplog):
 
        r'^TOTAL TO PAY: \$280\.00$',
 
        fr'^AGREEMENT: {contract_url}',
 
        r'^BEANCOUNT ENTRIES:$',
 
        # For each transaction, check for the date line, a metadata, and the
 
        # Expenses posting.
 
        r'^\s*2010-06-10\s',
 
    ])
 
    # Find the date line of the first transaction.
 
    # For each transaction, check for the date line, a metadata, and the
 
    # Expenses posting.
 
    for line in output:
 
        if not line.isspace():
 
            break
 
    assert re.match(r'\s*2010-06-10\s', line), \
 
        "first entry line did not have expected date"
 
    check_output(output, [
 
        fr'^\s+rt-id: "{rt_id_url}"$',
 
        r'^\s+Expenses:Services:Legal\s+220\.00 USD$',
 
        r'^\s*2010-06-10\s',
0 comments (0 inline, 0 general)