From f64143db44ed21efa09d8a28cbdea9ca147140d8 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Mon, 18 May 2020 14:44:34 -0400 Subject: [PATCH] accrual: Outgoing report handles requestors without RealName. --- conservancy_beancount/reports/accrual.py | 8 ++++++-- setup.py | 2 +- tests/test_reports_accrual.py | 4 ++-- tests/testutil.py | 6 ++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/conservancy_beancount/reports/accrual.py b/conservancy_beancount/reports/accrual.py index bbd9b68..f829f11 100644 --- a/conservancy_beancount/reports/accrual.py +++ b/conservancy_beancount/reports/accrual.py @@ -220,8 +220,12 @@ def outgoing_report(groups: PostGroups, requestor = '' requestor_name = '' else: - requestor = '{RealName} <{EmailAddress}>'.format_map(rt_requestor) - requestor_name = rt_requestor['RealName'] + requestor_name = ( + rt_requestor.get('RealName') + or rt_requestor.get('CF.{payment-to}') + or '' + ) + requestor = f'{requestor_name} <{rt_requestor["EmailAddress"]}>'.strip() contract_links = related.all_meta_links('contract') if contract_links: diff --git a/setup.py b/setup.py index 5a44c34..4968bbe 100755 --- a/setup.py +++ b/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.0.2', + version='1.0.3', author='Software Freedom Conservancy', author_email='info@sfconservancy.org', license='GNU AGPLv3+', diff --git a/tests/test_reports_accrual.py b/tests/test_reports_accrual.py index f9c9275..0586a90 100644 --- a/tests/test_reports_accrual.py +++ b/tests/test_reports_accrual.py @@ -343,8 +343,8 @@ def test_outgoing_report_custom_field_fallbacks(accrual_postings): contract_url = re.escape(f'<{rt_url}Ticket/Attachment/4000/4000/contract.pdf>') check_output(output, [ r'^PAYMENT FOR APPROVAL:$', - r'^REQUESTOR: Mx\. 510 $', - r'^PAYMENT TO: Mx\. 510$', + r'^REQUESTOR: $', + r'^PAYMENT TO:\s*$', r'^PAYMENT METHOD:\s*$', ]) diff --git a/tests/testutil.py b/tests/testutil.py index 6d671d8..3ef2604 100644 --- a/tests/testutil.py +++ b/tests/testutil.py @@ -363,9 +363,11 @@ class RTClient: else: email = user_id_s user_id_num = int(match.group(1)) - return { + retval = { 'id': f'user/{user_id_num}', 'EmailAddress': email, 'Name': email, - 'RealName': f'Mx. {user_id_num}', } + if self.want_cfs: + retval['RealName'] = f'Mx. {user_id_num}' + return retval