From 8dc6894ce7e88426034d91c054e32809ee221880 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Mon, 8 Jun 2020 16:37:51 -0400 Subject: [PATCH] accrual: Outgoing report uses first rt-id as primary ticket number. This makes it consistent with the reporting and our general rule that the first link is primary. --- conservancy_beancount/reports/accrual.py | 7 ++++++- setup.py | 2 +- tests/books/accruals.beancount | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/conservancy_beancount/reports/accrual.py b/conservancy_beancount/reports/accrual.py index cc705fa..ad2015a 100644 --- a/conservancy_beancount/reports/accrual.py +++ b/conservancy_beancount/reports/accrual.py @@ -508,7 +508,12 @@ class OutgoingReport(BaseReport): self.rt_wrapper = rtutil.RT(rt_client) def _primary_rt_id(self, posts: AccrualPostings) -> rtutil.TicketAttachmentIds: - rt_ids = posts.all_meta_links('rt-id') + rt_ids: Set[str] = set() + for post in posts: + try: + rt_ids.add(post.meta.get_links('rt-id')[0]) + except (IndexError, TypeError): + pass rt_ids_count = len(rt_ids) if rt_ids_count != 1: raise ValueError(f"{rt_ids_count} rt-id links found") diff --git a/setup.py b/setup.py index d8e2c8e..eec26a0 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.1.3', + version='1.1.4', author='Software Freedom Conservancy', author_email='info@sfconservancy.org', license='GNU AGPLv3+', diff --git a/tests/books/accruals.beancount b/tests/books/accruals.beancount index 9789f0c..f005ac6 100644 --- a/tests/books/accruals.beancount +++ b/tests/books/accruals.beancount @@ -108,7 +108,7 @@ Liabilities:Payable:Accounts -60.00 USD 2010-06-18 * "EuroGov" "European legal fees" - rt-id: "rt:520" + rt-id: "rt:520 rt:525" invoice: "rt:520/5200" contract: "rt:520/5220" Liabilities:Payable:Accounts -1,000 EUR {1.100 USD}