mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-24 17:18:30 +00:00
fix: set default repair cost to 0 if no value is returned
This commit is contained in:
@@ -116,9 +116,7 @@ frappe.ui.form.on("Asset Repair", {
|
|||||||
purchase_invoice: frm.doc.purchase_invoice,
|
purchase_invoice: frm.doc.purchase_invoice,
|
||||||
},
|
},
|
||||||
callback: function (r) {
|
callback: function (r) {
|
||||||
if (r.message) {
|
frm.set_value("repair_cost", r.message || 0);
|
||||||
frm.set_value("repair_cost", r.message);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -326,20 +326,21 @@ class TestAssetRepair(unittest.TestCase):
|
|||||||
def test_repair_cost_fetches_only_service_item_amount(self):
|
def test_repair_cost_fetches_only_service_item_amount(self):
|
||||||
"""Test that repair cost only includes service (non-stock) item amounts from purchase invoice."""
|
"""Test that repair cost only includes service (non-stock) item amounts from purchase invoice."""
|
||||||
|
|
||||||
|
company = "_Test Company with perpetual inventory"
|
||||||
service_item = create_item(
|
service_item = create_item(
|
||||||
"_Test Service Item for Repair",
|
"_Test Service Item for Repair",
|
||||||
is_stock_item=0,
|
is_stock_item=0,
|
||||||
company="_Test Company",
|
company=company,
|
||||||
)
|
)
|
||||||
|
|
||||||
stock_item = create_item(
|
stock_item = create_item(
|
||||||
"_Test Stock Item for Repair",
|
"_Test Stock Item for Repair",
|
||||||
is_stock_item=1,
|
is_stock_item=1,
|
||||||
company="_Test Company",
|
company=company,
|
||||||
)
|
)
|
||||||
|
|
||||||
expense_account = frappe.db.get_value("Company", "_Test Company", "default_expense_account")
|
expense_account = frappe.db.get_value("Company", company, "default_expense_account")
|
||||||
cost_center = frappe.db.get_value("Company", "_Test Company", "cost_center")
|
cost_center = frappe.db.get_value("Company", company, "cost_center")
|
||||||
|
|
||||||
pi = make_purchase_invoice(
|
pi = make_purchase_invoice(
|
||||||
item_code=service_item.name,
|
item_code=service_item.name,
|
||||||
@@ -349,6 +350,7 @@ class TestAssetRepair(unittest.TestCase):
|
|||||||
cost_center=cost_center,
|
cost_center=cost_center,
|
||||||
update_stock=0,
|
update_stock=0,
|
||||||
do_not_submit=1,
|
do_not_submit=1,
|
||||||
|
company=company,
|
||||||
)
|
)
|
||||||
|
|
||||||
pi.update_stock = 1
|
pi.update_stock = 1
|
||||||
@@ -358,7 +360,7 @@ class TestAssetRepair(unittest.TestCase):
|
|||||||
"item_code": stock_item.name,
|
"item_code": stock_item.name,
|
||||||
"qty": 2,
|
"qty": 2,
|
||||||
"rate": 300,
|
"rate": 300,
|
||||||
"warehouse": "_Test Warehouse - _TC",
|
"warehouse": "Stores - TCP1",
|
||||||
"cost_center": cost_center,
|
"cost_center": cost_center,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user