diff --git a/pay-api/src/pay_api/models/statement.py b/pay-api/src/pay_api/models/statement.py index fb0d09565..0b3d23d59 100644 --- a/pay-api/src/pay_api/models/statement.py +++ b/pay-api/src/pay_api/models/statement.py @@ -125,3 +125,4 @@ class Meta: # pylint: disable=too-few-public-methods from_date = fields.Date(tzinfo=pytz.timezone(LEGISLATIVE_TIMEZONE)) to_date = fields.Date(tzinfo=pytz.timezone(LEGISLATIVE_TIMEZONE)) + is_overdue = fields.Boolean() diff --git a/pay-api/src/pay_api/services/statement.py b/pay-api/src/pay_api/services/statement.py index 675d91e07..fdedb5d3d 100644 --- a/pay-api/src/pay_api/services/statement.py +++ b/pay-api/src/pay_api/services/statement.py @@ -13,6 +13,7 @@ # limitations under the License. """Service class to control all the operations related to statements.""" from datetime import date, datetime +from typing import List from flask import current_app from sqlalchemy import func @@ -122,7 +123,7 @@ def find_by_account_id(auth_account_id: str, page: int, limit: int): """Find statements by account id.""" current_app.logger.debug(f' 0 + return statements diff --git a/pay-api/tests/unit/services/test_statement.py b/pay-api/tests/unit/services/test_statement.py index f7e6a17c0..f8f582e98 100644 --- a/pay-api/tests/unit/services/test_statement.py +++ b/pay-api/tests/unit/services/test_statement.py @@ -19,7 +19,7 @@ from pay_api.models import PaymentAccount from pay_api.services.statement import Statement as StatementService -from pay_api.utils.enums import StatementFrequency +from pay_api.utils.enums import InvoiceStatus, StatementFrequency from tests.utilities.base_test import ( factory_invoice, factory_invoice_reference, factory_payment, factory_payment_line_item, factory_premium_payment_account, factory_statement, factory_statement_invoices, factory_statement_settings, @@ -33,7 +33,7 @@ def test_statement_find_by_account(session): payment = factory_payment() payment.save() - i = factory_invoice(payment_account=bcol_account) + i = factory_invoice(payment_account=bcol_account, status_code=InvoiceStatus.OVERDUE.value) i.save() factory_invoice_reference(i.id).save() @@ -48,6 +48,7 @@ def test_statement_find_by_account(session): statements = StatementService.find_by_account_id(payment_account.auth_account_id, page=1, limit=10) assert statements is not None assert statements.get('total') == 1 + assert statements.get('items')[0].get('is_overdue') is True def test_get_statement_report(session):