Skip to content

Commit

Permalink
add eft flag to "get payment account route"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jxio committed Oct 25, 2023
1 parent d4283fb commit d9cc82d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pay-api/src/pay_api/models/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from .base_schema import BaseSchema
from .db import db, ma
from .invoice_reference import InvoiceReferenceSchema
from .payment_account import PaymentAccountSchema, PaymentAccountSearchModel
from .payment_account import PaymentAccount, PaymentAccountSchema, PaymentAccountSearchModel
from .payment_line_item import PaymentLineItem, PaymentLineItemSchema
from .receipt import ReceiptSchema
from ..utils.util import current_local_time
Expand Down Expand Up @@ -175,6 +175,15 @@ def find_outstanding_invoices_for_account(cls, pay_account_id: int, from_date: d

return query.all()

@classmethod
def find_eft_invoices(cls, pay_account_id: str):
"""Return invoices paid with eft payment method."""
query = db.session.query(Invoice) \
.join(PaymentAccount, PaymentAccount.id == Invoice.payment_account_id) \
.filter(Invoice.payment_method_code == PaymentMethod.EFT.value) \
.filter(PaymentAccount.auth_account_id == pay_account_id)
return query.all()


class InvoiceSchema(AuditSchema, BaseSchema): # pylint: disable=too-many-ancestors
"""Main schema used to serialize the invoice."""
Expand Down
5 changes: 5 additions & 0 deletions pay-api/src/pay_api/services/payment_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from pay_api.models import PaymentAccount as PaymentAccountModel
from pay_api.models import PaymentAccountSchema
from pay_api.models import StatementSettings as StatementSettingsModel
from pay_api.models.invoice import Invoice
from pay_api.services.cfs_service import CFSService
from pay_api.services.distribution_code import DistributionCode
from pay_api.services.queue_publisher import publish_response
Expand Down Expand Up @@ -590,6 +591,10 @@ def asdict(self, **kwargs):
if account_fees := AccountFeeModel.find_by_account_id(self.id):
d['accountFees'] = AccountFeeSchema().dump(account_fees, many=True)

paid_by_eft = Invoice.find_eft_invoices(self.auth_account_id)
if len(paid_by_eft) > 0:
d['eft_eligible'] = True

return d

def _is_pad_in_pending_activation(self):
Expand Down

0 comments on commit d9cc82d

Please sign in to comment.