Skip to content

Commit

Permalink
Test: create mr, create po against mr, create pi against po with part…
Browse files Browse the repository at this point in the history
…ial qty & again create pi against po with remaining qty
  • Loading branch information
Abhishek8848 committed Jan 10, 2025
1 parent 629c42f commit 26243a3
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions erpnext/stock/doctype/material_request/test_material_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -2978,6 +2978,57 @@ def test_mr_po_pi_TC_SCK_082(self):
gl_stock_debit = frappe.db.get_value('GL Entry',{'voucher_no':doc_pi.name, 'account': 'Creditors - _TC'},'credit')
self.assertEqual(gl_stock_debit, 1000)

def test_mr_po_2pi_TC_SCK_083(self):
# MR => PO => 2PI
mr_dict_list = [{
"company" : "_Test Company",
"item_code" : "Testing-31",
"warehouse" : "Stores - _TC",
"qty" : 10,
"rate" : 100,
},
]

doc_mr = make_material_request(**mr_dict_list[0])
self.assertEqual(doc_mr.docstatus, 1)

doc_po = make_test_po(doc_mr.name)
doc_pi = create_purchase_invoice(doc_po.name)
doc_pi.items[0].qty = 5
doc_pi.submit()

self.assertEqual(doc_pi.docstatus, 1)
doc_mr.reload()
self.assertEqual(doc_mr.status, "Ordered")

#if account setup in company
if frappe.db.exists('GL Entry',{'account': 'Stock Received But Not Billed - _TC'}):
gl_temp_credit = frappe.db.get_value('GL Entry',{'voucher_no':doc_pi.name, 'account': 'Stock Received But Not Billed - _TC'},'debit')
self.assertEqual(gl_temp_credit, 500)

#if account setup in company
if frappe.db.exists('GL Entry',{'account': 'Creditors - _TC'}):
gl_stock_debit = frappe.db.get_value('GL Entry',{'voucher_no':doc_pi.name, 'account': 'Creditors - _TC'},'credit')
self.assertEqual(gl_stock_debit, 500)

doc_pi = create_purchase_invoice(doc_po.name)
doc_pi.items[0].qty = 5
doc_pi.submit()

self.assertEqual(doc_pi.docstatus, 1)
doc_mr.reload()
self.assertEqual(doc_mr.status, "Ordered")

#if account setup in company
if frappe.db.exists('GL Entry',{'account': 'Stock Received But Not Billed - _TC'}):
gl_temp_credit = frappe.db.get_value('GL Entry',{'voucher_no':doc_pi.name, 'account': 'Stock Received But Not Billed - _TC'},'debit')
self.assertEqual(gl_temp_credit, 500)

#if account setup in company
if frappe.db.exists('GL Entry',{'account': 'Creditors - _TC'}):
gl_stock_debit = frappe.db.get_value('GL Entry',{'voucher_no':doc_pi.name, 'account': 'Creditors - _TC'},'credit')
self.assertEqual(gl_stock_debit, 500)

def get_in_transit_warehouse(company):
if not frappe.db.exists("Warehouse Type", "Transit"):
frappe.get_doc(
Expand Down

0 comments on commit 26243a3

Please sign in to comment.