From c80e5fe7a1e7d39eb297ba73c3e1c3ebf6845be1 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 19 Aug 2019 14:38:15 +0530 Subject: [PATCH 1/6] fix: Failing sales and purchase return test cases --- erpnext/controllers/sales_and_purchase_return.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index 28dd4ea8b6..6a03c519ef 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -24,7 +24,12 @@ def validate_return_against(doc): else: ref_doc = frappe.get_doc(doc.doctype, doc.return_against) - if ref_doc.company == doc.company and ref_doc.customer == doc.customer and ref_doc.docstatus == 1: + if doc.doctype == "Sales Invoice": + party_type == "customer" + else: + party_type == "supplier" + + if ref_doc.company == doc.company and ref_doc.get(pary_type) == doc.get(party_type) and ref_doc.docstatus == 1: # validate posting date time return_posting_datetime = "%s %s" % (doc.posting_date, doc.get("posting_time") or "00:00:00") ref_posting_datetime = "%s %s" % (ref_doc.posting_date, ref_doc.get("posting_time") or "00:00:00") From 7d288437d8a119712dad5067f40c008648420736 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 19 Aug 2019 16:19:48 +0530 Subject: [PATCH 2/6] fix: Assignment --- erpnext/controllers/sales_and_purchase_return.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index 6a03c519ef..cb68315f9b 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -25,9 +25,9 @@ def validate_return_against(doc): ref_doc = frappe.get_doc(doc.doctype, doc.return_against) if doc.doctype == "Sales Invoice": - party_type == "customer" + party_type = "customer" else: - party_type == "supplier" + party_type = "supplier" if ref_doc.company == doc.company and ref_doc.get(pary_type) == doc.get(party_type) and ref_doc.docstatus == 1: # validate posting date time From e2acc748c81b4e2d7a4e96e8f64e7e9e09acf226 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 19 Aug 2019 16:38:04 +0530 Subject: [PATCH 3/6] fix: Check for return against delivery noteas well --- erpnext/controllers/sales_and_purchase_return.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index cb68315f9b..e9633558ef 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -24,7 +24,7 @@ def validate_return_against(doc): else: ref_doc = frappe.get_doc(doc.doctype, doc.return_against) - if doc.doctype == "Sales Invoice": + if doc.doctype in ("Sales Invoice", "Delivery Note"): party_type = "customer" else: party_type = "supplier" From 0487ad5515df3fd1535bd5d1271e69e842d186e4 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Mon, 19 Aug 2019 16:40:29 +0530 Subject: [PATCH 4/6] fix: Code cleanup --- erpnext/controllers/sales_and_purchase_return.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index e9633558ef..6054b9015a 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -24,10 +24,7 @@ def validate_return_against(doc): else: ref_doc = frappe.get_doc(doc.doctype, doc.return_against) - if doc.doctype in ("Sales Invoice", "Delivery Note"): - party_type = "customer" - else: - party_type = "supplier" + party_type == "customer" if doc.doctype in ("Sales Invoice", "Delivery Note") else "supplier" if ref_doc.company == doc.company and ref_doc.get(pary_type) == doc.get(party_type) and ref_doc.docstatus == 1: # validate posting date time From 3965451c7a78d3ea78d6fa5c57204448cbc24ec9 Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Mon, 19 Aug 2019 17:40:29 +0530 Subject: [PATCH 5/6] Update erpnext/controllers/sales_and_purchase_return.py Co-Authored-By: Mangesh-Khairnar --- erpnext/controllers/sales_and_purchase_return.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index 6054b9015a..bc2876f824 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -24,7 +24,7 @@ def validate_return_against(doc): else: ref_doc = frappe.get_doc(doc.doctype, doc.return_against) - party_type == "customer" if doc.doctype in ("Sales Invoice", "Delivery Note") else "supplier" + party_type = "customer" if doc.doctype in ("Sales Invoice", "Delivery Note") else "supplier" if ref_doc.company == doc.company and ref_doc.get(pary_type) == doc.get(party_type) and ref_doc.docstatus == 1: # validate posting date time From 33b392ac2be2075321856c6273ee4b18f1ab715e Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Mon, 19 Aug 2019 17:43:10 +0530 Subject: [PATCH 6/6] Update erpnext/controllers/sales_and_purchase_return.py Co-Authored-By: Mangesh-Khairnar --- erpnext/controllers/sales_and_purchase_return.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index bc2876f824..b713958b1b 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -26,7 +26,7 @@ def validate_return_against(doc): party_type = "customer" if doc.doctype in ("Sales Invoice", "Delivery Note") else "supplier" - if ref_doc.company == doc.company and ref_doc.get(pary_type) == doc.get(party_type) and ref_doc.docstatus == 1: + if ref_doc.company == doc.company and ref_doc.get(party_type) == doc.get(party_type) and ref_doc.docstatus == 1: # validate posting date time return_posting_datetime = "%s %s" % (doc.posting_date, doc.get("posting_time") or "00:00:00") ref_posting_datetime = "%s %s" % (ref_doc.posting_date, ref_doc.get("posting_time") or "00:00:00")