From 00a915b741413c97d0ef714f2e5a82e070334d64 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Sat, 20 Jan 2024 06:38:43 +0100 Subject: [PATCH] feat: hanled payment request failure reasons --- .../doctype/payment_request/payment_request.js | 4 ++++ .../doctype/payment_request/payment_request.json | 14 ++++++++++++-- .../payment_request/payment_request_list.js | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/payment_request/payment_request.js b/erpnext/accounts/doctype/payment_request/payment_request.js index e913912028..c85cd42e42 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.js +++ b/erpnext/accounts/doctype/payment_request/payment_request.js @@ -25,6 +25,10 @@ frappe.ui.form.on("Payment Request", "onload", function(frm, dt, dn){ }) frappe.ui.form.on("Payment Request", "refresh", function(frm) { + if(frm.doc.status == 'Failed'){ + frm.set_intro(__("Failure: {0}", [frm.doc.failed_reason]), "red"); + } + if(frm.doc.payment_request_type == 'Inward' && frm.doc.payment_channel !== "Phone" && !in_list(["Initiated", "Paid"], frm.doc.status) && !frm.doc.__islocal && frm.doc.docstatus==1){ frm.add_custom_button(__('Resend Payment Email'), function(){ diff --git a/erpnext/accounts/doctype/payment_request/payment_request.json b/erpnext/accounts/doctype/payment_request/payment_request.json index 66b5c4b983..f62b6241c8 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.json +++ b/erpnext/accounts/doctype/payment_request/payment_request.json @@ -7,6 +7,7 @@ "field_order": [ "payment_request_type", "transaction_date", + "failed_reason", "column_break_2", "naming_series", "mode_of_payment", @@ -389,13 +390,22 @@ "options": "Payment Request", "print_hide": 1, "read_only": 1 + }, + { + "fieldname": "failed_reason", + "fieldtype": "Data", + "hidden": 1, + "label": "Reason for Failure", + "no_copy": 1, + "print_hide": 1, + "read_only": 1 } ], "in_create": 1, "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2023-09-27 09:51:42.277638", + "modified": "2024-01-20 00:37:06.988919", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Request", @@ -433,4 +443,4 @@ "sort_field": "modified", "sort_order": "DESC", "states": [] -} \ No newline at end of file +} diff --git a/erpnext/accounts/doctype/payment_request/payment_request_list.js b/erpnext/accounts/doctype/payment_request/payment_request_list.js index 85d729cd61..43f7856929 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request_list.js +++ b/erpnext/accounts/doctype/payment_request/payment_request_list.js @@ -16,6 +16,9 @@ frappe.listview_settings['Payment Request'] = { else if(doc.status == "Paid") { return [__("Paid"), "blue", "status,=,Paid"]; } + else if(doc.status == "Failed") { + return [__("Failed"), "red", "status,=,Failed"]; + } else if(doc.status == "Cancelled") { return [__("Cancelled"), "red", "status,=,Cancelled"]; }