mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-18 20:49:19 +00:00
test: add tests for PO->PI, PO->PR workflow
Add failing test cases for PR status and PR percent billed.
This commit is contained in:
@@ -912,6 +912,57 @@ class TestPurchaseReceipt(unittest.TestCase):
|
|||||||
ste1.cancel()
|
ste1.cancel()
|
||||||
po.cancel()
|
po.cancel()
|
||||||
|
|
||||||
|
|
||||||
|
def test_po_to_pi_and_po_to_pr_worflow_full(self):
|
||||||
|
"""Test following behaviour:
|
||||||
|
- Create PO
|
||||||
|
- Create PI from PO and submit
|
||||||
|
- Create PR from PO and submit
|
||||||
|
"""
|
||||||
|
from erpnext.buying.doctype.purchase_order import test_purchase_order
|
||||||
|
from erpnext.buying.doctype.purchase_order import purchase_order
|
||||||
|
|
||||||
|
po = test_purchase_order.create_purchase_order()
|
||||||
|
|
||||||
|
pi = purchase_order.make_purchase_invoice(po.name)
|
||||||
|
pi.submit()
|
||||||
|
|
||||||
|
pr = purchase_order.make_purchase_receipt(po.name)
|
||||||
|
pr.submit()
|
||||||
|
|
||||||
|
pr.load_from_db()
|
||||||
|
|
||||||
|
self.assertEqual(pr.status, "Completed")
|
||||||
|
self.assertEqual(pr.per_billed, 100)
|
||||||
|
|
||||||
|
def test_po_to_pi_and_po_to_pr_worflow_partial(self):
|
||||||
|
"""Test following behaviour:
|
||||||
|
- Create PO
|
||||||
|
- Create partial PI from PO and submit
|
||||||
|
- Create PR from PO and submit
|
||||||
|
"""
|
||||||
|
from erpnext.buying.doctype.purchase_order import test_purchase_order
|
||||||
|
from erpnext.buying.doctype.purchase_order import purchase_order
|
||||||
|
|
||||||
|
po = test_purchase_order.create_purchase_order()
|
||||||
|
|
||||||
|
pi = purchase_order.make_purchase_invoice(po.name)
|
||||||
|
pi.items[0].qty /= 2 # roughly 50%, ^ this function only creates PI with 1 item.
|
||||||
|
pi.submit()
|
||||||
|
|
||||||
|
pr = purchase_order.make_purchase_receipt(po.name)
|
||||||
|
pr.save()
|
||||||
|
# per_billed is only updated after submission.
|
||||||
|
self.assertEqual(flt(pr.per_billed), 0)
|
||||||
|
|
||||||
|
pr.submit()
|
||||||
|
|
||||||
|
pi.load_from_db()
|
||||||
|
pr.load_from_db()
|
||||||
|
|
||||||
|
self.assertEqual(pr.status, "To Bill")
|
||||||
|
self.assertAlmostEqual(pr.per_billed, 50.0, places=2)
|
||||||
|
|
||||||
def get_sl_entries(voucher_type, voucher_no):
|
def get_sl_entries(voucher_type, voucher_no):
|
||||||
return frappe.db.sql(""" select actual_qty, warehouse, stock_value_difference
|
return frappe.db.sql(""" select actual_qty, warehouse, stock_value_difference
|
||||||
from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s
|
from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s
|
||||||
|
|||||||
Reference in New Issue
Block a user