Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

22668 - Add in section for EFT CREATED -> to be returned as COMPLETED #1666

Merged
merged 6 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pay-api/src/pay_api/models/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ def _clean_up(self, data, many): # pylint: disable=unused-argument
if data.get('status_code') == InvoiceStatus.PAID.value:
data['status_code'] = PaymentStatus.COMPLETED.value

# Backwards compatibility - Important for ESRA, marking the invoice as COMPLETED.
if data.get('status_code') == InvoiceStatus.CREATED.value and \
data.get('payment_method') == PaymentMethod.EFT.value:
data['status_code'] = PaymentStatus.COMPLETED.value

return data


Expand Down Expand Up @@ -298,6 +303,7 @@ def from_row(cls, row):
https://www.attrs.org/en/stable/init.html
"""
# Similar to _clean_up in InvoiceSchema.
# In the future may need to add a mapping from EFT Status: CREATED -> COMPLETED
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left this one out for now, CSO uses this route for reconciliation.. they might need to see if it's CREATED VS PAID

status_code = PaymentStatus.COMPLETED.value if row.invoice_status_code == InvoiceStatus.PAID.value \
else row.invoice_status_code
business_identifier = None if row.business_identifier and row.business_identifier.startswith('T') \
Expand Down
19 changes: 19 additions & 0 deletions pay-api/tests/unit/services/test_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,29 @@
from pay_api.exceptions import BusinessException
from pay_api.models import FeeSchedule
from pay_api.services.invoice import Invoice as Invoice_service
from pay_api.utils.enums import PaymentMethod, PaymentStatus
from tests.utilities.base_test import (
factory_invoice, factory_payment, factory_payment_account, factory_payment_line_item)


def test_invoice_eft_created_return_completed(session):
"""Assert that the invoice is saved to the table."""
payment_account = factory_payment_account(payment_method_code='EFT')
payment = factory_payment()
payment_account.save()
payment.save()
i = factory_invoice(payment_account=payment_account)
i.save()
fee_schedule = FeeSchedule.find_by_filing_type_and_corp_type('CP', 'OTANN')
line = factory_payment_line_item(i.id, fee_schedule_id=fee_schedule.fee_schedule_id)
line.save()
invoice = Invoice_service.find_by_id(i.id, skip_auth_check=True).asdict()

assert invoice is not None
assert invoice.payment_method == PaymentMethod.EFT.value
assert invoice.invoice_status_code == PaymentStatus.COMPLETED.value


def test_invoice_saved_from_new(session):
"""Assert that the invoice is saved to the table."""
payment_account = factory_payment_account()
Expand Down
Loading