accrual: Only try to generate an outgoing report for accruals with rt-id.
This commit is contained in:
parent
1124842ea7
commit
3330c834b2
4 changed files with 30 additions and 10 deletions
|
@ -701,8 +701,10 @@ def main(arglist: Optional[Sequence[str]]=None,
|
|||
groups = dict(AccrualPostings.group_by_first_meta_link(postings, 'rt-id'))
|
||||
if (args.report_type is None
|
||||
and len(groups) == 1
|
||||
and all(g.accrual_type is AccrualAccount.PAYABLE and not g.is_paid()
|
||||
for g in groups.values())
|
||||
and all(group.accrual_type is AccrualAccount.PAYABLE
|
||||
and not group.is_paid()
|
||||
and key # Make sure we have a usable rt-id
|
||||
for key, group in groups.items())
|
||||
):
|
||||
args.report_type = ReportType.OUTGOING
|
||||
if args.report_type is not ReportType.OUTGOING:
|
||||
|
|
2
setup.py
2
setup.py
|
@ -5,7 +5,7 @@ from setuptools import setup
|
|||
setup(
|
||||
name='conservancy_beancount',
|
||||
description="Plugin, library, and reports for reading Conservancy's books",
|
||||
version='1.1.10',
|
||||
version='1.1.11',
|
||||
author='Software Freedom Conservancy',
|
||||
author_email='info@sfconservancy.org',
|
||||
license='GNU AGPLv3+',
|
||||
|
|
|
@ -143,6 +143,13 @@
|
|||
Expenses:FilingFees 60.00 USD
|
||||
Liabilities:Payable:Accounts -60.00 USD
|
||||
|
||||
2010-06-15 * "GrantCo" "2010Q2 grant"
|
||||
rt-id: "rt:470"
|
||||
invoice: "rt:470/4700"
|
||||
project: "Development Grant"
|
||||
Assets:Receivable:Accounts 5500 USD
|
||||
Income:Donations -5500 USD
|
||||
|
||||
2010-06-18 * "EuroGov" "European legal fees"
|
||||
; Multiple rt-ids are used to test proper handling for both
|
||||
; searching and generating the outgoing report.
|
||||
|
@ -153,12 +160,12 @@
|
|||
Liabilities:Payable:Accounts -1,000 EUR {1.100 USD}
|
||||
Expenses:FilingFees 1,000 EUR {1.100 USD}
|
||||
|
||||
2010-06-15 * "GrantCo" "2010Q2 grant"
|
||||
rt-id: "rt:470"
|
||||
invoice: "rt:470/4700"
|
||||
project: "Development Grant"
|
||||
Assets:Receivable:Accounts 5500 USD
|
||||
Income:Donations -5500 USD
|
||||
2010-06-20 * "StateGov" "Business registration"
|
||||
; Intentionally has no rt-id
|
||||
invoice: "Invoices/2010StateRegistration.pdf"
|
||||
project: "Conservancy"
|
||||
Liabilities:Payable:Accounts -50 USD
|
||||
Expenses:FilingFees 50 USD
|
||||
|
||||
2010-09-15 * "GrantCo" "2010Q3 grant"
|
||||
rt-id: "rt:470"
|
||||
|
|
|
@ -79,7 +79,7 @@ class AgingRow(NamedTuple):
|
|||
date = datetime.datetime.strptime(date, '%Y-%m-%d').date()
|
||||
if not isinstance(at_cost, tuple):
|
||||
at_cost = testutil.Amount(at_cost)
|
||||
if rt_id is None:
|
||||
if rt_id is None and invoice.startswith('rt:'):
|
||||
rt_id, _, _ = invoice.partition('/')
|
||||
return cls(date, [entity], orig_amount, at_cost, [rt_id], [invoice], [project])
|
||||
|
||||
|
@ -111,6 +111,7 @@ AGING_AP = [
|
|||
AgingRow.make_simple('2010-06-10', 'Lawyer', 280, 'rt:510/6100'),
|
||||
AgingRow.make_simple('2010-06-18', 'EuroGov', 1100, 'rt:520/5200',
|
||||
orig_amount=[testutil.Amount(1000, 'EUR')]),
|
||||
AgingRow.make_simple('2010-06-20', 'StateGov', 50, 'Invoices/2010StateRegistration.pdf'),
|
||||
]
|
||||
|
||||
AGING_AR = [
|
||||
|
@ -654,6 +655,16 @@ def test_main_balance_report(arglist):
|
|||
r'^\s+1,500\.00 USD outstanding since 2010-05-15$',
|
||||
])
|
||||
|
||||
def test_main_balance_report_because_no_rt_id():
|
||||
invoice = 'Invoices/2010StateRegistration.pdf'
|
||||
retcode, output, errors = run_main([invoice])
|
||||
assert not errors.getvalue()
|
||||
assert retcode == 0
|
||||
check_output(output, [
|
||||
rf'\b{re.escape(invoice)}:$',
|
||||
r'^\s+-50\.00 USD outstanding since 2010-06-20$',
|
||||
])
|
||||
|
||||
@pytest.mark.parametrize('arglist', [
|
||||
[],
|
||||
['-t', 'aging', 'entity=Lawyer'],
|
||||
|
|
Loading…
Reference in a new issue