diff --git a/DEVELOPER_NOTES.md b/DEVELOPER_NOTES.md index 1c13e5a8b..f183184d3 100644 --- a/DEVELOPER_NOTES.md +++ b/DEVELOPER_NOTES.md @@ -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. \ No newline at end of file +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 \ No newline at end of file diff --git a/pay-queue/src/pay_queue/services/eft/eft_reconciliation.py b/pay-queue/src/pay_queue/services/eft/eft_reconciliation.py index 74532644f..eaba12a67 100644 --- a/pay-queue/src/pay_queue/services/eft/eft_reconciliation.py +++ b/pay-queue/src/pay_queue/services/eft/eft_reconciliation.py @@ -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. diff --git a/pay-queue/tests/integration/test_eft_reconciliation.py b/pay-queue/tests/integration/test_eft_reconciliation.py index 4b6707b17..cd40ae87d 100644 --- a/pay-queue/tests/integration/test_eft_reconciliation.py +++ b/pay-queue/tests/integration/test_eft_reconciliation.py @@ -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()