diff --git a/jobs/payment-jobs/tasks/eft_task.py b/jobs/payment-jobs/tasks/eft_task.py index f58cb3e78..94d36549b 100644 --- a/jobs/payment-jobs/tasks/eft_task.py +++ b/jobs/payment-jobs/tasks/eft_task.py @@ -323,7 +323,8 @@ def _rollback_receipt_and_invoice(cls, cfs_account: CfsAccountModel, f'not found for invoice id: {invoice.id} - {invoice.invoice_status_code}') is_invoice_refund = invoice.invoice_status_code == InvoiceStatus.REFUND_REQUESTED.value is_reversal = not is_invoice_refund - CFSService.reverse_rs_receipt_in_cfs(cfs_account, receipt_number, ReverseOperation.VOID.value) + if receipt_number: + CFSService.reverse_rs_receipt_in_cfs(cfs_account, receipt_number, ReverseOperation.VOID.value) if is_invoice_refund: cls._handle_invoice_refund(invoice, invoice_reference) else: diff --git a/pay-api/src/pay_api/services/eft_short_names.py b/pay-api/src/pay_api/services/eft_short_names.py index ec2d5b708..59c48e7b1 100644 --- a/pay-api/src/pay_api/services/eft_short_names.py +++ b/pay-api/src/pay_api/services/eft_short_names.py @@ -627,6 +627,10 @@ def get_statement_summary_query(): InvoiceModel.id == StatementInvoicesModel.invoice_id, InvoiceModel.payment_method_code == PaymentMethod.EFT.value ) + ).filter( + InvoiceModel.invoice_status_code.notin_([InvoiceStatus.CANCELLED.value, + InvoiceStatus.REFUND_REQUESTED.value, + InvoiceStatus.REFUNDED.value]) ).group_by(StatementModel.payment_account_id) @classmethod