mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-20 07:22:13 +00:00
fix: purchase return from rejected warehouse (#42531)
(cherry picked from commit c5d68333c9)
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -640,6 +640,12 @@ def make_return_doc(doctype: str, source_name: str, target_doc=None, return_agai
|
|||||||
def update_terms(source_doc, target_doc, source_parent):
|
def update_terms(source_doc, target_doc, source_parent):
|
||||||
target_doc.payment_amount = -source_doc.payment_amount
|
target_doc.payment_amount = -source_doc.payment_amount
|
||||||
|
|
||||||
|
def item_condition(doc):
|
||||||
|
if return_against_rejected_qty:
|
||||||
|
return doc.rejected_qty
|
||||||
|
|
||||||
|
return doc.qty
|
||||||
|
|
||||||
doclist = get_mapped_doc(
|
doclist = get_mapped_doc(
|
||||||
doctype,
|
doctype,
|
||||||
source_name,
|
source_name,
|
||||||
@@ -654,6 +660,7 @@ def make_return_doc(doctype: str, source_name: str, target_doc=None, return_agai
|
|||||||
"doctype": doctype + " Item",
|
"doctype": doctype + " Item",
|
||||||
"field_map": {"serial_no": "serial_no", "batch_no": "batch_no", "bom": "bom"},
|
"field_map": {"serial_no": "serial_no", "batch_no": "batch_no", "bom": "bom"},
|
||||||
"postprocess": update_item,
|
"postprocess": update_item,
|
||||||
|
"condition": item_condition,
|
||||||
},
|
},
|
||||||
"Payment Schedule": {"doctype": "Payment Schedule", "postprocess": update_terms},
|
"Payment Schedule": {"doctype": "Payment Schedule", "postprocess": update_terms},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1886,9 +1886,19 @@ class TestPurchaseReceipt(FrappeTestCase):
|
|||||||
rate=100,
|
rate=100,
|
||||||
rejected_qty=2,
|
rejected_qty=2,
|
||||||
rejected_warehouse=rejected_warehouse,
|
rejected_warehouse=rejected_warehouse,
|
||||||
|
do_not_save=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
pr.append(
|
||||||
|
"items",
|
||||||
|
{"item_code": item_code, "qty": 2, "rate": 100, "warehouse": warehouse, "rejected_qty": 0},
|
||||||
|
)
|
||||||
|
pr.save()
|
||||||
|
pr.submit()
|
||||||
|
self.assertEqual(len(pr.items), 2)
|
||||||
|
|
||||||
pr_return = make_purchase_return_against_rejected_warehouse(pr.name)
|
pr_return = make_purchase_return_against_rejected_warehouse(pr.name)
|
||||||
|
self.assertEqual(len(pr_return.items), 1)
|
||||||
self.assertEqual(pr_return.items[0].warehouse, rejected_warehouse)
|
self.assertEqual(pr_return.items[0].warehouse, rejected_warehouse)
|
||||||
self.assertEqual(pr_return.items[0].qty, 2.0 * -1)
|
self.assertEqual(pr_return.items[0].qty, 2.0 * -1)
|
||||||
self.assertEqual(pr_return.items[0].rejected_qty, 0.0)
|
self.assertEqual(pr_return.items[0].rejected_qty, 0.0)
|
||||||
|
|||||||
Reference in New Issue
Block a user