From 5f785ede16341ab9e8db12db21b08d70c140de1a Mon Sep 17 00:00:00 2001 From: Abdeali Chharchhoda Date: Sat, 23 Nov 2024 14:47:31 +0530 Subject: [PATCH 1/6] refactor: Used object to get payment request status indicator (cherry picked from commit e1c4d6e1e666ee539caf746ed303003ac89f8024) # Conflicts: # erpnext/accounts/doctype/payment_request/payment_request_list.js --- .../payment_request/payment_request_list.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/erpnext/accounts/doctype/payment_request/payment_request_list.js b/erpnext/accounts/doctype/payment_request/payment_request_list.js index 183ca7c45849..a1e1549e9d9d 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request_list.js +++ b/erpnext/accounts/doctype/payment_request/payment_request_list.js @@ -1,6 +1,17 @@ +const INDICATORS = { + "Partially Paid": "orange", + Cancelled: "red", + Draft: "gray", + Failed: "red", + Initiated: "green", + Paid: "blue", + Requested: "green", +}; + frappe.listview_settings["Payment Request"] = { add_fields: ["status"], get_indicator: function (doc) { +<<<<<<< HEAD if (doc.status == "Draft") { return [__("Draft"), "gray", "status,=,Draft"]; } @@ -15,5 +26,8 @@ frappe.listview_settings["Payment Request"] = { } else if (doc.status == "Cancelled") { return [__("Cancelled"), "red", "status,=,Cancelled"]; } +======= + return [__(doc.status), INDICATORS[doc.status] || "gray", `status,=,${doc.status}`]; +>>>>>>> e1c4d6e1e6 (refactor: Used object to get payment request status indicator) }, }; From 0d67c62f43758d453bc59ea0595046f48afa78ab Mon Sep 17 00:00:00 2001 From: Abdeali Chharchhoda Date: Sat, 23 Nov 2024 15:10:23 +0530 Subject: [PATCH 2/6] fix: Dashboard for `Payment Request` (cherry picked from commit 91955e27c38338ff72ae4d19d8f7e26880c5eb3a) --- .../payment_request/payment_request_dashboard.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 erpnext/accounts/doctype/payment_request/payment_request_dashboard.py diff --git a/erpnext/accounts/doctype/payment_request/payment_request_dashboard.py b/erpnext/accounts/doctype/payment_request/payment_request_dashboard.py new file mode 100644 index 000000000000..02ad5684792b --- /dev/null +++ b/erpnext/accounts/doctype/payment_request/payment_request_dashboard.py @@ -0,0 +1,14 @@ +from frappe import _ + + +def get_data(): + return { + "fieldname": "payment_request", + "internal_links": { + "Payment Entry": ["references", "payment_request"], + "Payment Order": ["references", "payment_order"], + }, + "transactions": [ + {"label": _("Payment"), "items": ["Payment Entry", "Payment Order"]}, + ], + } From 9c4b5814a65b9bed086326aa11538f5a9db99938 Mon Sep 17 00:00:00 2001 From: Abdeali Chharchhoda Date: Tue, 26 Nov 2024 12:10:05 +0530 Subject: [PATCH 3/6] revert: remove default `Payment Request` indicator color (cherry picked from commit 37ceb09955c4e5a12714d6422c6092a271382e4f) # Conflicts: # erpnext/accounts/doctype/payment_request/payment_request_list.js --- .../doctype/payment_request/payment_request_list.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/accounts/doctype/payment_request/payment_request_list.js b/erpnext/accounts/doctype/payment_request/payment_request_list.js index a1e1549e9d9d..61dae1451f96 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request_list.js +++ b/erpnext/accounts/doctype/payment_request/payment_request_list.js @@ -11,6 +11,7 @@ const INDICATORS = { frappe.listview_settings["Payment Request"] = { add_fields: ["status"], get_indicator: function (doc) { +<<<<<<< HEAD <<<<<<< HEAD if (doc.status == "Draft") { return [__("Draft"), "gray", "status,=,Draft"]; @@ -29,5 +30,10 @@ frappe.listview_settings["Payment Request"] = { ======= return [__(doc.status), INDICATORS[doc.status] || "gray", `status,=,${doc.status}`]; >>>>>>> e1c4d6e1e6 (refactor: Used object to get payment request status indicator) +======= + if (!doc.status || !INDICATORS[doc.status]) return; + + return [__(doc.status), INDICATORS[doc.status], `status,=,${doc.status}`]; +>>>>>>> 37ceb09955 (revert: remove default `Payment Request` indicator color) }, }; From 4b046160f8f9d43c34c1f9e093d052d4f9ca2e27 Mon Sep 17 00:00:00 2001 From: Abdeali Chharchhoda Date: Wed, 27 Nov 2024 15:52:45 +0530 Subject: [PATCH 4/6] refactor: Move `PR` link filters to client side (cherry picked from commit 2db2c8bce1c1f453818e7e693ded0c0eec8053ec) --- erpnext/accounts/doctype/payment_entry/payment_entry.js | 4 ++++ .../accounts/doctype/payment_request/payment_request.py | 7 +------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js index a377aa04db2d..2d27cccfff86 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.js +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js @@ -185,6 +185,10 @@ frappe.ui.form.on("Payment Entry", { filters: { reference_doctype: row.reference_doctype, reference_name: row.reference_name, + company: doc.company, + status: ["!=", "Paid"], + outstanding_amount: [">", 0], // for compatibility with old data + docstatus: 1, }, }; }); diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index 1d31fd4b67b7..27e3aa830926 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -987,12 +987,7 @@ def get_open_payment_requests_query(doctype, txt, searchfield, start, page_len, open_payment_requests = frappe.get_list( "Payment Request", - filters={ - **filters, - "status": ["!=", "Paid"], - "outstanding_amount": ["!=", 0], # for compatibility with old data - "docstatus": 1, - }, + filters=filters, fields=["name", "grand_total", "outstanding_amount"], order_by="transaction_date ASC,creation ASC", ) From 5999a8e24f908dc84bce88969bdb192c03c2cd08 Mon Sep 17 00:00:00 2001 From: Abdeali Chharchhoda Date: Wed, 27 Nov 2024 17:18:10 +0530 Subject: [PATCH 5/6] fix: Add filter for `outstanding_amount` to fetch open PRs (cherry picked from commit 214dfab2697ec13e70262cb4af92ca812a2dcb80) --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 89f52b466799..5ebe1dd87549 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -2877,6 +2877,7 @@ def get_open_payment_requests_for_references(references=None): .where(Tuple(PR.reference_doctype, PR.reference_name).isin(list(refs))) .where(PR.status != "Paid") .where(PR.docstatus == 1) + .where(PR.outstanding_amount > 0) # to avoid old PRs with 0 outstanding amount .orderby(Coalesce(PR.transaction_date, PR.creation), order=frappe.qb.asc) ).run(as_dict=True) From 1c50111371eea3eb1abffb73babb550013f748b5 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Fri, 29 Nov 2024 14:50:41 +0530 Subject: [PATCH 6/6] chore: resolve conflict --- .../payment_request/payment_request_list.js | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/erpnext/accounts/doctype/payment_request/payment_request_list.js b/erpnext/accounts/doctype/payment_request/payment_request_list.js index 61dae1451f96..1027385aaaf1 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request_list.js +++ b/erpnext/accounts/doctype/payment_request/payment_request_list.js @@ -11,29 +11,8 @@ const INDICATORS = { frappe.listview_settings["Payment Request"] = { add_fields: ["status"], get_indicator: function (doc) { -<<<<<<< HEAD -<<<<<<< HEAD - if (doc.status == "Draft") { - return [__("Draft"), "gray", "status,=,Draft"]; - } - if (doc.status == "Requested") { - return [__("Requested"), "green", "status,=,Requested"]; - } else if (doc.status == "Initiated") { - return [__("Initiated"), "green", "status,=,Initiated"]; - } else if (doc.status == "Partially Paid") { - return [__("Partially Paid"), "orange", "status,=,Partially Paid"]; - } else if (doc.status == "Paid") { - return [__("Paid"), "blue", "status,=,Paid"]; - } else if (doc.status == "Cancelled") { - return [__("Cancelled"), "red", "status,=,Cancelled"]; - } -======= - return [__(doc.status), INDICATORS[doc.status] || "gray", `status,=,${doc.status}`]; ->>>>>>> e1c4d6e1e6 (refactor: Used object to get payment request status indicator) -======= if (!doc.status || !INDICATORS[doc.status]) return; return [__(doc.status), INDICATORS[doc.status], `status,=,${doc.status}`]; ->>>>>>> 37ceb09955 (revert: remove default `Payment Request` indicator color) }, };