Landed Cost voucher test case for serialized items

This commit is contained in:
Nabin Hait 2014-08-11 16:12:11 +05:30
parent a97e700371
commit 200e8d971f

View File

@ -12,19 +12,31 @@ from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt \
class TestLandedCostVoucher(unittest.TestCase):
def test_landed_cost_voucher(self):
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)
pr_lc_value = frappe.db.get_value("Purchase Receipt Item", {"parent": pr.name}, "landed_cost_voucher_amount")
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)
self.assertTrue(gl_entries)
stock_in_hand_account = pr.get("purchase_receipt_details")[0].warehouse
fixed_asset_account = pr.get("purchase_receipt_details")[1].warehouse
expected_values = {
stock_in_hand_account: [400.0, 0.0],
@ -38,7 +50,27 @@ class TestLandedCostVoucher(unittest.TestCase):
self.assertEquals(expected_values[gle.account][1], gle.credit)
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):
lcv = frappe.new_doc("Landed Cost Voucher")
lcv.company = "_Test Company"
@ -53,15 +85,9 @@ class TestLandedCostVoucher(unittest.TestCase):
"account": "_Test Account Insurance Charges - _TC",
"amount": 50.0
}])
lcv.insert()
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')