Skip to content

Commit

Permalink
fix: zero valuation rate for batched item (#41446)
Browse files Browse the repository at this point in the history
(cherry picked from commit e3a80eb)
  • Loading branch information
rohitwaghchaure authored and mergify[bot] committed May 13, 2024
1 parent b8db903 commit e31618a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
44 changes: 44 additions & 0 deletions erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2820,6 +2820,50 @@ def test_purchase_receipt_bill_for_rejected_quantity_in_purchase_invoice(self):
"Buying Settings", "bill_for_rejected_quantity_in_purchase_invoice", old_value
)

def test_zero_valuation_rate_for_batched_item(self):
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry

item = make_item(
"_Test Zero Valuation Rate For the Batch Item",
{
"is_purchase_item": 1,
"is_stock_item": 1,
"has_batch_no": 1,
"create_new_batch": 1,
"batch_number_series": "TZVRFORBATCH.#####",
"valuation_rate": 200,
},
)

pi = make_purchase_receipt(
qty=10,
rate=0,
item_code=item.name,
)

pi.reload()
batch_no = get_batch_from_bundle(pi.items[0].serial_and_batch_bundle)

se = make_stock_entry(
purpose="Material Issue",
item_code=item.name,
source=pi.items[0].warehouse,
qty=10,
batch_no=batch_no,
use_serial_batch_fields=0,
)

se.submit()

se.reload()

self.assertEqual(se.items[0].valuation_rate, 0)
self.assertEqual(se.items[0].basic_rate, 0)

sabb_doc = frappe.get_doc("Serial and Batch Bundle", se.items[0].serial_and_batch_bundle)
for row in sabb_doc.entries:
self.assertEqual(row.incoming_rate, 0)


def prepare_data_for_internal_transfer():
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ def set_incoming_rate_for_outward_transaction(self, row=None, save=False, allow_
if self.has_serial_no:
d.incoming_rate = abs(sn_obj.serial_no_incoming_rate.get(d.serial_no, 0.0))
else:
if sn_obj.batch_avg_rate.get(d.batch_no):
d.incoming_rate = abs(sn_obj.batch_avg_rate.get(d.batch_no))
d.incoming_rate = abs(flt(sn_obj.batch_avg_rate.get(d.batch_no)))

available_qty = flt(sn_obj.available_qty.get(d.batch_no), d.precision("qty"))
if self.docstatus == 1:
Expand Down

0 comments on commit e31618a

Please sign in to comment.