fix: Add test for consumption of serialized Assets
This commit is contained in:
parent
efac7b0904
commit
6b75d1439f
@ -5,6 +5,7 @@ import unittest
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import flt, nowdate
|
from frappe.utils import flt, nowdate
|
||||||
|
from traceback import print_exc
|
||||||
|
|
||||||
from erpnext.assets.doctype.asset.test_asset import (
|
from erpnext.assets.doctype.asset.test_asset import (
|
||||||
create_asset,
|
create_asset,
|
||||||
@ -76,6 +77,25 @@ class TestAssetRepair(unittest.TestCase):
|
|||||||
self.assertEqual(stock_entry.items[0].item_code, asset_repair.stock_items[0].item_code)
|
self.assertEqual(stock_entry.items[0].item_code, asset_repair.stock_items[0].item_code)
|
||||||
self.assertEqual(stock_entry.items[0].qty, asset_repair.stock_items[0].consumed_quantity)
|
self.assertEqual(stock_entry.items[0].qty, asset_repair.stock_items[0].consumed_quantity)
|
||||||
|
|
||||||
|
def test_serialized_item_consumption(self):
|
||||||
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_serialized_item
|
||||||
|
from erpnext.stock.doctype.serial_no.serial_no import SerialNoRequiredError
|
||||||
|
|
||||||
|
stock_entry = make_serialized_item()
|
||||||
|
serial_nos = stock_entry.get("items")[0].serial_no
|
||||||
|
serial_no = serial_nos.split("\n")[0]
|
||||||
|
|
||||||
|
# should not raise any error
|
||||||
|
create_asset_repair(stock_consumption = 1, item_code = stock_entry.get("items")[0].item_code,
|
||||||
|
warehouse = "_Test Warehouse - _TC", serial_no = serial_no, submit = 1)
|
||||||
|
|
||||||
|
# should raise error
|
||||||
|
asset_repair = create_asset_repair(stock_consumption = 1, warehouse = "_Test Warehouse - _TC",
|
||||||
|
item_code = stock_entry.get("items")[0].item_code)
|
||||||
|
|
||||||
|
asset_repair.repair_status = "Completed"
|
||||||
|
self.assertRaises(SerialNoRequiredError, asset_repair.submit)
|
||||||
|
|
||||||
def test_increase_in_asset_value_due_to_stock_consumption(self):
|
def test_increase_in_asset_value_due_to_stock_consumption(self):
|
||||||
asset = create_asset(calculate_depreciation = 1, submit=1)
|
asset = create_asset(calculate_depreciation = 1, submit=1)
|
||||||
initial_asset_value = get_asset_value(asset)
|
initial_asset_value = get_asset_value(asset)
|
||||||
@ -140,11 +160,12 @@ def create_asset_repair(**args):
|
|||||||
|
|
||||||
if args.stock_consumption:
|
if args.stock_consumption:
|
||||||
asset_repair.stock_consumption = 1
|
asset_repair.stock_consumption = 1
|
||||||
asset_repair.warehouse = create_warehouse("Test Warehouse", company = asset.company)
|
asset_repair.warehouse = args.warehouse or create_warehouse("Test Warehouse", company = asset.company)
|
||||||
asset_repair.append("stock_items", {
|
asset_repair.append("stock_items", {
|
||||||
"item_code": args.item_code or "_Test Stock Item",
|
"item_code": args.item_code or "_Test Stock Item",
|
||||||
"valuation_rate": args.rate if args.get("rate") is not None else 100,
|
"valuation_rate": args.rate if args.get("rate") is not None else 100,
|
||||||
"consumed_quantity": args.qty or 1
|
"consumed_quantity": args.qty or 1,
|
||||||
|
"serial_no": args.serial_no
|
||||||
})
|
})
|
||||||
|
|
||||||
asset_repair.insert(ignore_if_duplicate=True)
|
asset_repair.insert(ignore_if_duplicate=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user