Skip to content

Commit

Permalink
24337-EFT-Auto-Payment-Update (#1824)
Browse files Browse the repository at this point in the history
  • Loading branch information
ochiu authored Nov 15, 2024
1 parent 8067e4e commit bb0afd1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
6 changes: 5 additions & 1 deletion DEVELOPER_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,8 @@ e.g. Set overdue status for overdue invoices on auth account 1234.
`python3 invoke_jobs.py STATEMENTS_DUE OVERDUE 2024-10-15 1234`

Date Override: The date you want to emulate the job is running on.
Account Id: The auth account id to run the job against.
Account Id: The auth account id to run the job against.


24. How do I manually apply an eft payment to a specific statement?
Here: https://drive.google.com/file/d/12WqEis2rQMyKHFNitZRukXWlSLKTa-x1/view?usp=drive_link
5 changes: 5 additions & 0 deletions pay-queue/src/pay_queue/services/eft/eft_reconciliation.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ def _apply_eft_pending_payments(context: EFTReconciliation, shortname_balance):

eft_credit_balance = EFTCreditModel.get_eft_credit_balance(eft_short_name.id)
shortname_links = EFTShortnamesService.get_shortname_links(eft_short_name.id).get("items", [])

# Don't apply auto payments for multi link accounts
if len(shortname_links) > 1:
continue

for shortname_link in shortname_links:
# We are expecting pending payments to have been cleared since this runs after the
# eft task job. Something may have gone wrong, we will skip this link.
Expand Down
34 changes: 34 additions & 0 deletions pay-queue/tests/integration/test_eft_reconciliation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,40 @@ def test_apply_pending_payments(session, app, client):
assert short_name_link.get("amount_owing") == 150.50


def test_multi_link_apply_pending_payments(session, app, client):
"""Test automatic payments do not apply to multi link accounts."""
payment_account, eft_short_name, invoice = create_test_data()
payment_account_2 = factory_create_eft_account(auth_account_id="2222")
EFTShortnameLinksModel(
eft_short_name_id=eft_short_name.id,
auth_account_id=payment_account_2.auth_account_id,
status_code=EFTShortnameStatus.LINKED.value,
updated_by="TEST",
updated_by_name="TEST",
updated_on=datetime.now(),
).save()
create_statement_from_invoices(payment_account, [invoice])
file_name: str = "test_eft_tdi17.txt"
generate_tdi17_file(file_name)

add_file_event_to_queue_and_process(
client,
file_name=file_name,
message_type=QueueMessageTypes.EFT_FILE_UPLOADED.value,
)
short_name_id = eft_short_name.id
eft_credit_balance = EFTCreditModel.get_eft_credit_balance(short_name_id)
assert eft_credit_balance == 150.50

short_name_links = EFTShortNamesService.get_shortname_links(short_name_id)
assert short_name_links["items"]
assert len(short_name_links["items"]) == 2

short_name_link = short_name_links["items"][0]
assert short_name_link.get("has_pending_payment") is False
assert short_name_link.get("amount_owing") == 150.50


def test_skip_on_existing_pending_payments(session, app, client):
"""Test auto payment skipping payment when there exists a pending payment."""
payment_account, eft_short_name, invoice = create_test_data()
Expand Down

0 comments on commit bb0afd1

Please sign in to comment.