accrual: Actually use RT caching as intended.
Basically none of the reports were reading or writing the RT link cache because they didn't instantiate an rtutil.RT properly to do that.
This commit is contained in:
parent
175ac3bd7a
commit
1124842ea7
3 changed files with 18 additions and 18 deletions
|
@ -293,13 +293,12 @@ class AgingODS(core.BaseODS[AccrualPostings, Optional[data.Account]]):
|
||||||
COL_COUNT = len(COLUMNS)
|
COL_COUNT = len(COLUMNS)
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
rt_client: rt.Rt,
|
rt_wrapper: rtutil.RT,
|
||||||
date: datetime.date,
|
date: datetime.date,
|
||||||
logger: logging.Logger,
|
logger: logging.Logger,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.rt_client = rt_client
|
self.rt_wrapper = rt_wrapper
|
||||||
self.rt_wrapper = rtutil.RT(self.rt_client)
|
|
||||||
self.date = date
|
self.date = date
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
|
|
||||||
|
@ -445,7 +444,7 @@ class AgingODS(core.BaseODS[AccrualPostings, Optional[data.Account]]):
|
||||||
|
|
||||||
class AgingReport(BaseReport):
|
class AgingReport(BaseReport):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
rt_client: rt.Rt,
|
rt_wrapper: rtutil.RT,
|
||||||
out_file: BinaryIO,
|
out_file: BinaryIO,
|
||||||
date: Optional[datetime.date]=None,
|
date: Optional[datetime.date]=None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -453,7 +452,7 @@ class AgingReport(BaseReport):
|
||||||
date = datetime.date.today()
|
date = datetime.date.today()
|
||||||
self.out_bin = out_file
|
self.out_bin = out_file
|
||||||
self.logger = logger.getChild(type(self).__name__)
|
self.logger = logger.getChild(type(self).__name__)
|
||||||
self.ods = AgingODS(rt_client, date, self.logger)
|
self.ods = AgingODS(rt_wrapper, date, self.logger)
|
||||||
|
|
||||||
def run(self, groups: PostGroups) -> None:
|
def run(self, groups: PostGroups) -> None:
|
||||||
rows: List[AccrualPostings] = []
|
rows: List[AccrualPostings] = []
|
||||||
|
@ -501,10 +500,10 @@ class BalanceReport(BaseReport):
|
||||||
|
|
||||||
|
|
||||||
class OutgoingReport(BaseReport):
|
class OutgoingReport(BaseReport):
|
||||||
def __init__(self, rt_client: rt.Rt, out_file: TextIO) -> None:
|
def __init__(self, rt_wrapper: rtutil.RT, out_file: TextIO) -> None:
|
||||||
super().__init__(out_file)
|
super().__init__(out_file)
|
||||||
self.rt_client = rt_client
|
self.rt_wrapper = rt_wrapper
|
||||||
self.rt_wrapper = rtutil.RT(rt_client)
|
self.rt_client = rt_wrapper.rt
|
||||||
|
|
||||||
def _primary_rt_id(self, posts: AccrualPostings) -> rtutil.TicketAttachmentIds:
|
def _primary_rt_id(self, posts: AccrualPostings) -> rtutil.TicketAttachmentIds:
|
||||||
rt_id = posts.rt_id
|
rt_id = posts.rt_id
|
||||||
|
@ -721,8 +720,8 @@ def main(arglist: Optional[Sequence[str]]=None,
|
||||||
report: Optional[BaseReport] = None
|
report: Optional[BaseReport] = None
|
||||||
output_path: Optional[Path] = None
|
output_path: Optional[Path] = None
|
||||||
if args.report_type is ReportType.AGING:
|
if args.report_type is ReportType.AGING:
|
||||||
rt_client = config.rt_client()
|
rt_wrapper = config.rt_wrapper()
|
||||||
if rt_client is None:
|
if rt_wrapper is None:
|
||||||
logger.error("unable to generate aging report: RT client is required")
|
logger.error("unable to generate aging report: RT client is required")
|
||||||
else:
|
else:
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
|
@ -730,14 +729,14 @@ def main(arglist: Optional[Sequence[str]]=None,
|
||||||
args.output_file = Path(now.strftime('AgingReport_%Y-%m-%d_%H:%M.ods'))
|
args.output_file = Path(now.strftime('AgingReport_%Y-%m-%d_%H:%M.ods'))
|
||||||
logger.info("Writing report to %s", args.output_file)
|
logger.info("Writing report to %s", args.output_file)
|
||||||
out_bin = cliutil.bytes_output(args.output_file, stdout)
|
out_bin = cliutil.bytes_output(args.output_file, stdout)
|
||||||
report = AgingReport(rt_client, out_bin)
|
report = AgingReport(rt_wrapper, out_bin)
|
||||||
elif args.report_type is ReportType.OUTGOING:
|
elif args.report_type is ReportType.OUTGOING:
|
||||||
rt_client = config.rt_client()
|
rt_wrapper = config.rt_wrapper()
|
||||||
if rt_client is None:
|
if rt_wrapper is None:
|
||||||
logger.error("unable to generate outgoing report: RT client is required")
|
logger.error("unable to generate outgoing report: RT client is required")
|
||||||
else:
|
else:
|
||||||
out_file = cliutil.text_output(args.output_file, stdout)
|
out_file = cliutil.text_output(args.output_file, stdout)
|
||||||
report = OutgoingReport(rt_client, out_file)
|
report = OutgoingReport(rt_wrapper, out_file)
|
||||||
else:
|
else:
|
||||||
out_file = cliutil.text_output(args.output_file, stdout)
|
out_file = cliutil.text_output(args.output_file, stdout)
|
||||||
report = BalanceReport(out_file)
|
report = BalanceReport(out_file)
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -5,7 +5,7 @@ from setuptools import setup
|
||||||
setup(
|
setup(
|
||||||
name='conservancy_beancount',
|
name='conservancy_beancount',
|
||||||
description="Plugin, library, and reports for reading Conservancy's books",
|
description="Plugin, library, and reports for reading Conservancy's books",
|
||||||
version='1.1.9',
|
version='1.1.10',
|
||||||
author='Software Freedom Conservancy',
|
author='Software Freedom Conservancy',
|
||||||
author_email='info@sfconservancy.org',
|
author_email='info@sfconservancy.org',
|
||||||
license='GNU AGPLv3+',
|
license='GNU AGPLv3+',
|
||||||
|
|
|
@ -425,10 +425,11 @@ def check_output(output, expect_patterns):
|
||||||
def run_outgoing(rt_id, postings, rt_client=None):
|
def run_outgoing(rt_id, postings, rt_client=None):
|
||||||
if rt_client is None:
|
if rt_client is None:
|
||||||
rt_client = RTClient()
|
rt_client = RTClient()
|
||||||
|
rt_wrapper = rtutil.RT(rt_client)
|
||||||
if not isinstance(postings, core.RelatedPostings):
|
if not isinstance(postings, core.RelatedPostings):
|
||||||
postings = accruals_by_meta(postings, rt_id, 'rt-id', wrap_type=accrual.AccrualPostings)
|
postings = accruals_by_meta(postings, rt_id, 'rt-id', wrap_type=accrual.AccrualPostings)
|
||||||
output = io.StringIO()
|
output = io.StringIO()
|
||||||
report = accrual.OutgoingReport(rt_client, output)
|
report = accrual.OutgoingReport(rt_wrapper, output)
|
||||||
report.run({rt_id: postings})
|
report.run({rt_id: postings})
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
@ -525,8 +526,8 @@ def run_aging_report(postings, today=None):
|
||||||
for key, group in related.make_consistent()
|
for key, group in related.make_consistent()
|
||||||
}
|
}
|
||||||
output = io.BytesIO()
|
output = io.BytesIO()
|
||||||
rt_client = RTClient()
|
rt_wrapper = rtutil.RT(RTClient())
|
||||||
report = accrual.AgingReport(rt_client, output, today)
|
report = accrual.AgingReport(rt_wrapper, output, today)
|
||||||
report.run(groups)
|
report.run(groups)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue