From 8a73e963ce56e1cccb9ecb61f3afda5bb3586467 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Wed, 16 Nov 2022 14:12:55 +0530 Subject: [PATCH] fix: don't set `rejected-qty` in return SCR --- .../controllers/sales_and_purchase_return.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index 39ef68a9fb..15c82af856 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -404,12 +404,17 @@ def make_return_doc(doctype: str, source_name: str, target_doc=None): returned_qty_map = get_returned_qty_map_for_row( source_parent.name, source_parent.supplier, source_doc.name, doctype ) - target_doc.received_qty = -1 * flt( - source_doc.received_qty - (returned_qty_map.get("received_qty") or 0) - ) - target_doc.rejected_qty = -1 * flt( - source_doc.rejected_qty - (returned_qty_map.get("rejected_qty") or 0) - ) + + if doctype == "Subcontracting Receipt": + target_doc.received_qty = -1 * flt(source_doc.qty) + else: + target_doc.received_qty = -1 * flt( + source_doc.received_qty - (returned_qty_map.get("received_qty") or 0) + ) + target_doc.rejected_qty = -1 * flt( + source_doc.rejected_qty - (returned_qty_map.get("rejected_qty") or 0) + ) + target_doc.qty = -1 * flt(source_doc.qty - (returned_qty_map.get("qty") or 0)) if hasattr(target_doc, "stock_qty"):