Skip to content

Commit

Permalink
test: delivery note for batch with non stock uom
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitwaghchaure committed Dec 29, 2023
1 parent 8c7fdac commit 311b8c6
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions erpnext/stock/doctype/delivery_note/test_delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,46 @@ def test_sales_return_valuation_for_moving_average_case2(self):
returned_dn.reload()
self.assertAlmostEqual(returned_dn.items[0].incoming_rate, 200.0)

def test_batch_with_non_stock_uom(self):
frappe.db.set_single_value(
"Stock Settings", "auto_create_serial_and_batch_bundle_for_outward", 1
)

item = make_item(
properties={
"has_batch_no": 1,
"create_new_batch": 1,
"batch_number_series": "TESTBATCH.#####",
"stock_uom": "Nos",
}
)
if not frappe.db.exists("UOM Conversion Detail", {"parent": item.name, "uom": "Kg"}):
item.append("uoms", {"uom": "Kg", "conversion_factor": 5.0})
item.save()

item_code = item.name

make_stock_entry(item_code=item_code, target="_Test Warehouse - _TC", qty=5, basic_rate=100.0)
dn = create_delivery_note(
item_code=item_code, qty=1, rate=500, warehouse="_Test Warehouse - _TC", do_not_save=True
)
dn.items[0].uom = "Kg"
dn.items[0].conversion_factor = 5.0

dn.save()
dn.submit()

self.assertEqual(dn.items[0].stock_qty, 5.0)
voucher_detail_no = dn.items[0].name
delivered_batch_qty = frappe.db.get_value(
"Serial and Batch Bundle", {"voucher_detail_no": voucher_detail_no}, "total_qty"
)
self.assertEqual(abs(delivered_batch_qty), 5.0)

frappe.db.set_single_value(
"Stock Settings", "auto_create_serial_and_batch_bundle_for_outward", 0
)


def create_delivery_note(**args):
dn = frappe.new_doc("Delivery Note")
Expand Down

0 comments on commit 311b8c6

Please sign in to comment.