From 82cdf49d3268ebf58540cbccdadc2d2295a03c64 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 1 Dec 2022 15:51:38 +0530 Subject: [PATCH 1/3] fix: Bundle item rates (cherry picked from commit 826f45ad603c581a7ea0c29e1274474ce124f6eb) --- erpnext/stock/doctype/packed_item/packed_item.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py index 4d05d7a345c..02f8e903bb4 100644 --- a/erpnext/stock/doctype/packed_item/packed_item.py +++ b/erpnext/stock/doctype/packed_item/packed_item.py @@ -259,7 +259,7 @@ def update_product_bundle_rate(parent_items_price, pi_row): if not rate: parent_items_price[key] = 0.0 - parent_items_price[key] += flt(pi_row.rate) + parent_items_price[key] += flt(pi_row.rate * pi_row.qty) def set_product_bundle_rate_amount(doc, parent_items_price): From 076027a68c8fd3de02ca0328bbdbea788c175a4d Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 6 Dec 2022 13:59:45 +0530 Subject: [PATCH 2/3] chore: Consider bundle qty as well (cherry picked from commit e5566b31d5b7d4c057b43b5f0fa7d8d9119c942c) --- erpnext/stock/doctype/packed_item/packed_item.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py index 02f8e903bb4..d6067516660 100644 --- a/erpnext/stock/doctype/packed_item/packed_item.py +++ b/erpnext/stock/doctype/packed_item/packed_item.py @@ -48,7 +48,7 @@ def make_packing_list(doc): update_packed_item_from_cancelled_doc(item_row, bundle_item, pi_row, doc) if set_price_from_children: # create/update bundle item wise price dict - update_product_bundle_rate(parent_items_price, pi_row) + update_product_bundle_rate(parent_items_price, pi_row, item_row) if parent_items_price: set_product_bundle_rate_amount(doc, parent_items_price) # set price in bundle item @@ -247,7 +247,7 @@ def get_cancelled_doc_packed_item_details(old_packed_items): return prev_doc_packed_items_map -def update_product_bundle_rate(parent_items_price, pi_row): +def update_product_bundle_rate(parent_items_price, pi_row, item_row): """ Update the price dict of Product Bundles based on the rates of the Items in the bundle. @@ -259,7 +259,7 @@ def update_product_bundle_rate(parent_items_price, pi_row): if not rate: parent_items_price[key] = 0.0 - parent_items_price[key] += flt(pi_row.rate * pi_row.qty) + parent_items_price[key] += flt((pi_row.rate * pi_row.qty) / item_row.stock_qty) def set_product_bundle_rate_amount(doc, parent_items_price): From 98bb446e98692234f116b26f4b2551856df43848 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Tue, 6 Dec 2022 15:14:48 +0530 Subject: [PATCH 3/3] chore: Update tests (cherry picked from commit b1242bc56c3485d37fd37627a3196a754abfb442) --- erpnext/stock/doctype/packed_item/test_packed_item.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/packed_item/test_packed_item.py b/erpnext/stock/doctype/packed_item/test_packed_item.py index ad7fd9a6976..ad06732bc3e 100644 --- a/erpnext/stock/doctype/packed_item/test_packed_item.py +++ b/erpnext/stock/doctype/packed_item/test_packed_item.py @@ -126,8 +126,8 @@ class TestPackedItem(FrappeTestCase): so.packed_items[1].rate = 200 so.save() - self.assertEqual(so.items[0].rate, 350) - self.assertEqual(so.items[0].amount, 700) + self.assertEqual(so.items[0].rate, 700) + self.assertEqual(so.items[0].amount, 1400) def test_newly_mapped_doc_packed_items(self): "Test impact on packed items in newly mapped DN from SO."