Landed Cost voucher test case for serialized items
This commit is contained in:
parent
a97e700371
commit
200e8d971f
@ -12,12 +12,24 @@ from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \
|
|||||||
class TestLandedCostVoucher(unittest.TestCase):
|
class TestLandedCostVoucher(unittest.TestCase):
|
||||||
def test_landed_cost_voucher(self):
|
def test_landed_cost_voucher(self):
|
||||||
set_perpetual_inventory(1)
|
set_perpetual_inventory(1)
|
||||||
pr = self.submit_pr()
|
pr = frappe.copy_doc(pr_test_records[0])
|
||||||
|
pr.submit()
|
||||||
|
|
||||||
|
bin_details = frappe.db.get_value("Bin", {"warehouse": "_Test Warehouse - _TC",
|
||||||
|
"item_code": "_Test Item"}, ["actual_qty", "stock_value"], as_dict=1)
|
||||||
|
|
||||||
self.submit_landed_cost_voucher(pr)
|
self.submit_landed_cost_voucher(pr)
|
||||||
|
|
||||||
pr_lc_value = frappe.db.get_value("Purchase Receipt Item", {"parent": pr.name}, "landed_cost_voucher_amount")
|
pr_lc_value = frappe.db.get_value("Purchase Receipt Item", {"parent": pr.name}, "landed_cost_voucher_amount")
|
||||||
self.assertEquals(pr_lc_value, 25.0)
|
self.assertEquals(pr_lc_value, 25.0)
|
||||||
|
|
||||||
|
bin_details_after_lcv = frappe.db.get_value("Bin", {"warehouse": "_Test Warehouse - _TC",
|
||||||
|
"item_code": "_Test Item"}, ["actual_qty", "stock_value"], as_dict=1)
|
||||||
|
|
||||||
|
self.assertEqual(bin_details.actual_qty, bin_details_after_lcv.actual_qty)
|
||||||
|
|
||||||
|
self.assertEqual(bin_details_after_lcv.stock_value - bin_details.stock_value, 25.0)
|
||||||
|
|
||||||
gl_entries = get_gl_entries("Purchase Receipt", pr.name)
|
gl_entries = get_gl_entries("Purchase Receipt", pr.name)
|
||||||
|
|
||||||
self.assertTrue(gl_entries)
|
self.assertTrue(gl_entries)
|
||||||
@ -39,6 +51,26 @@ class TestLandedCostVoucher(unittest.TestCase):
|
|||||||
|
|
||||||
set_perpetual_inventory(0)
|
set_perpetual_inventory(0)
|
||||||
|
|
||||||
|
def test_landed_cost_voucher_for_serialized_item(self):
|
||||||
|
set_perpetual_inventory(1)
|
||||||
|
frappe.db.sql("delete from `tabSerial No` where name in ('SN001', 'SN002', 'SN003', 'SN004', 'SN005')")
|
||||||
|
|
||||||
|
pr = frappe.copy_doc(pr_test_records[0])
|
||||||
|
pr.purchase_receipt_details[0].item_code = "_Test Serialized Item"
|
||||||
|
pr.purchase_receipt_details[0].serial_no = "SN001\nSN002\nSN003\nSN004\nSN005"
|
||||||
|
pr.submit()
|
||||||
|
|
||||||
|
self.submit_landed_cost_voucher(pr)
|
||||||
|
|
||||||
|
serial_no = frappe.db.get_value("Serial No", "SN001",
|
||||||
|
["status", "warehouse", "purchase_rate"], as_dict=1)
|
||||||
|
|
||||||
|
self.assertEquals(serial_no.status, "Available")
|
||||||
|
self.assertEquals(serial_no.purchase_rate, 80.0)
|
||||||
|
self.assertEquals(serial_no.warehouse, "_Test Warehouse - _TC")
|
||||||
|
|
||||||
|
set_perpetual_inventory(0)
|
||||||
|
|
||||||
def submit_landed_cost_voucher(self, pr):
|
def submit_landed_cost_voucher(self, pr):
|
||||||
lcv = frappe.new_doc("Landed Cost Voucher")
|
lcv = frappe.new_doc("Landed Cost Voucher")
|
||||||
lcv.company = "_Test Company"
|
lcv.company = "_Test Company"
|
||||||
@ -57,11 +89,5 @@ class TestLandedCostVoucher(unittest.TestCase):
|
|||||||
lcv.insert()
|
lcv.insert()
|
||||||
lcv.submit()
|
lcv.submit()
|
||||||
|
|
||||||
def submit_pr(self):
|
|
||||||
pr = frappe.copy_doc(pr_test_records[0])
|
|
||||||
pr.submit()
|
|
||||||
return pr
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test_records = frappe.get_test_records('Landed Cost Voucher')
|
test_records = frappe.get_test_records('Landed Cost Voucher')
|
Loading…
x
Reference in New Issue
Block a user