From 6046ba007d5f56c4f3b0efed9f68ab61b0a0ffe9 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Tue, 21 Jan 2025 10:09:29 +0100 Subject: [PATCH] fix: Allow down payment return --- .../doctype/sales_invoice/sales_invoice.js | 17 +++++++++++++---- .../doctype/sales_invoice/sales_invoice.py | 9 ++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index b0353f9b77..2f995fe687 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -195,10 +195,19 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e if (doc.is_return && doc.status == "Return" && doc.return_against) { frappe.db.get_value("Sales Invoice", doc.return_against, "status", (r) => { if (r.status !== "Credit Note Issued") { - frappe.route_options = {"party_type": "Customer", "party": doc.customer} - const pr_dashboard = frappe.utils.get_form_link("Payment Reconciliation", "Payment Reconciliation", true, __("Payment Reconciliation")) - const msg = __("To reconcile this credit note with sales invoice {0}, use the {1} dashboard", [doc.return_against, pr_dashboard]) - me.frm.dashboard.set_headline(msg, "blue") + frappe.route_options = { party_type: "Customer", party: doc.customer }; + const pr_dashboard = frappe.utils.get_form_link( + "Payment Reconciliation", + "Payment Reconciliation", + true, + __("Payment Reconciliation") + ); + const msg = __( + "To reconcile this credit note with sales invoice {0}, use the {1} dashboard", + [doc.return_against, pr_dashboard] + ); + me.frm.dashboard.clear_headline(); + me.frm.dashboard.set_headline(msg, "blue"); } }) } diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 14b7e9ea7f..798b829e89 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -1492,7 +1492,7 @@ class SalesInvoice(SellingController): item=item, ) - if self.is_down_payment_invoice: + if self.is_down_payment_invoice or self.is_down_payment_return(): gl_dict.update({"party_type": "Customer", "party": self.customer}) gl_entries.append(gl_dict) @@ -1501,6 +1501,13 @@ class SalesInvoice(SellingController): if cint(self.update_stock) and erpnext.is_perpetual_inventory_enabled(self.company): gl_entries += super().get_gl_entries() + def is_down_payment_return(self): + return ( + self.is_return + and self.return_against + and frappe.db.get_value("Sales Invoice", self.return_against, "is_down_payment_invoice") + ) + def get_asset(self, item): if item.get("asset"): asset = frappe.get_doc("Asset", item.asset) -- GitLab