diff --git a/pay-api/src/pay_api/services/statement.py b/pay-api/src/pay_api/services/statement.py index 3973edef3..87c66fc22 100644 --- a/pay-api/src/pay_api/services/statement.py +++ b/pay-api/src/pay_api/services/statement.py @@ -237,17 +237,17 @@ def get_statement_invoices(statement_id: int) -> List[InvoiceModel]: .filter(StatementInvoicesModel.statement_id == statement_id)) @staticmethod - def get_statement_template(statement: StatementModel, ordered_invoices: List[InvoiceModel]) -> str: + def is_eft_statement(statement: StatementModel, ordered_invoices: List[InvoiceModel]) -> bool: """Return the statement template name.""" # Check invoice payment method for statement template if ordered_invoices and ordered_invoices[0].payment_method_code == PaymentMethod.EFT.value: - return StatementTemplate.EFT_STATEMENT.value + return True # In the event of an empty statement check statement payment methods, could be more than one on transition days if PaymentMethod.EFT.value in statement.payment_methods: - return StatementTemplate.EFT_STATEMENT.value + return True - return StatementTemplate.STATEMENT_REPORT.value + return False @staticmethod def get_invoices_owing_amount(auth_account_id: str): @@ -337,13 +337,12 @@ def get_statement_report(statement_id: str, content_type: str, **kwargs): statement['from_date'] = from_date_string statement['to_date'] = to_date_string - template_name = Statement.get_statement_template(statement_dao, statement_purchases) report_inputs = PaymentReportInput(content_type=content_type, report_name=report_name, - template_name=template_name, + template_name=StatementTemplate.STATEMENT_REPORT.value, results=result_items) - if template_name == StatementTemplate.EFT_STATEMENT.value: + if Statement.is_eft_statement(statement_dao, statement_purchases): report_inputs.statement_summary = Statement._populate_statement_summary(statement_dao, statement_purchases) diff --git a/pay-api/src/pay_api/utils/enums.py b/pay-api/src/pay_api/utils/enums.py index 81219ed9a..5d54da353 100644 --- a/pay-api/src/pay_api/utils/enums.py +++ b/pay-api/src/pay_api/utils/enums.py @@ -403,7 +403,6 @@ class EJVLinkType(Enum): class StatementTemplate(Enum): """Statement report templates.""" - EFT_STATEMENT = 'eft_statement' STATEMENT_REPORT = 'statement_report' diff --git a/pay-api/tests/unit/services/test_statement.py b/pay-api/tests/unit/services/test_statement.py index 8c268c29c..44f7b57d5 100644 --- a/pay-api/tests/unit/services/test_statement.py +++ b/pay-api/tests/unit/services/test_statement.py @@ -513,7 +513,7 @@ def test_get_eft_statement_for_empty_invoices(session): } } expected_report_inputs = ReportRequest(report_name=report_name, - template_name=StatementTemplate.EFT_STATEMENT.value, + template_name=StatementTemplate.STATEMENT_REPORT.value, template_vars=expected_template_vars, populate_page_number=True, content_type=ContentType.PDF.value) @@ -693,7 +693,7 @@ def test_get_eft_statement_with_invoices(session): } } expected_report_inputs = ReportRequest(report_name=report_name, - template_name=StatementTemplate.EFT_STATEMENT.value, + template_name=StatementTemplate.STATEMENT_REPORT.value, template_vars=expected_template_vars, populate_page_number=True, content_type=ContentType.PDF.value)