Skip to content

Commit

Permalink
test: test case for over transfer of materials
Browse files Browse the repository at this point in the history
  • Loading branch information
noahjacob committed Jul 26, 2021
1 parent 3dc8389 commit c017360
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions erpnext/stock/doctype/material_request/test_material_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,58 @@ def test_completed_qty_for_transfer(self):
self.assertEqual(current_requested_qty_item1, existing_requested_qty_item1 + 54.0)
self.assertEqual(current_requested_qty_item2, existing_requested_qty_item2 + 3.0)

def test_over_transfer_qty_allowance(self):
mr = frappe.new_doc('Material Request')
mr.company = "_Test Company"
mr.scheduled_date = today()
mr.append('items',{
"item_code": "_Test FG Item",
"item_name": "_Test FG Item",
"qty": 10,
"schedule_date": today(),
"uom": "_Test UOM 1",
"warehouse": "_Test Warehouse - _TC"
})

mr.material_request_type = "Material Transfer"
mr.insert()
mr.submit()

frappe.db.set_value('Stock Settings', None, 'mr_qty_allowance', 20)

# map a stock entry

se_doc = make_stock_entry(mr.name)
se_doc.update({
"posting_date": today(),
"posting_time": "00:00",
})
se_doc.get("items")[0].update({
"qty": 13,
"transfer_qty": 12.0,
"s_warehouse": "_Test Warehouse - _TC",
"t_warehouse": "_Test Warehouse 1 - _TC",
"basic_rate": 1.0
})

# make available the qty in _Test Warehouse 1 before transfer
sr = frappe.new_doc("Stock Reconciliation")
sr.company = "_Test Company"
sr.purpose = "Opening Stock"
sr.append('items', {
"item_code": "_Test FG Item",
"warehouse": "_Test Warehouse - _TC",
"qty": 20,
"valuation_rate": 0.01
})
sr.insert()
sr.submit()
se = frappe.copy_doc(se_doc)
se.insert()
self.assertRaises(frappe.ValidationError)
se.items[0].qty = 12
se.submit()

def test_completed_qty_for_over_transfer(self):
existing_requested_qty_item1 = self._get_requested_qty("_Test Item Home Desktop 100", "_Test Warehouse - _TC")
existing_requested_qty_item2 = self._get_requested_qty("_Test Item Home Desktop 200", "_Test Warehouse - _TC")
Expand Down

0 comments on commit c017360

Please sign in to comment.