feat(Asset Repair): Add value of consumed stock items to asset value
This commit is contained in:
parent
d2d31fd164
commit
0739d4bb1b
@ -17,8 +17,17 @@ frappe.ui.form.on('Asset Repair', {
|
||||
// });
|
||||
// },
|
||||
|
||||
// stock_items_add: function(frm){
|
||||
// var table = frm.doc.stock_items;
|
||||
// for(var i in table) {
|
||||
// if (table[i].valuation_rate == 0) {
|
||||
// frm.set_value(table[i].total_value, (table[i].valuation_rate * table[i].consumed_quantity))
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
|
||||
refresh: function(frm) {
|
||||
frm.toggle_display(['completion_date', 'repair_status', 'accounting_details'], !(frm.doc.__islocal));
|
||||
frm.toggle_display(['completion_date', 'repair_status', 'accounting_details', 'stock_items_section'], !(frm.doc.__islocal));
|
||||
},
|
||||
|
||||
repair_status: (frm) => {
|
||||
|
@ -23,7 +23,7 @@
|
||||
"capitalize_repair_cost",
|
||||
"column_break_8",
|
||||
"payable_account",
|
||||
"section_break_17",
|
||||
"stock_items_section",
|
||||
"stock_items",
|
||||
"section_break_9",
|
||||
"description",
|
||||
@ -113,10 +113,6 @@
|
||||
"fieldtype": "Long Text",
|
||||
"label": "Actions performed"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_17",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 1,
|
||||
"fieldname": "downtime",
|
||||
@ -188,12 +184,16 @@
|
||||
{
|
||||
"fieldname": "section_break_23",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "stock_items_section",
|
||||
"fieldtype": "Section Break"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2021-05-12 03:23:30.618741",
|
||||
"modified": "2021-05-12 04:45:38.714776",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Assets",
|
||||
"name": "Asset Repair",
|
||||
|
@ -16,17 +16,33 @@ class AssetRepair(Document):
|
||||
if self.repair_status == "Completed" and not self.completion_date:
|
||||
frappe.throw(_("Please select Completion Date for Completed Repair"))
|
||||
|
||||
self.update_status()
|
||||
self.set_total_value()
|
||||
|
||||
def set_total_value(self):
|
||||
for item in self.stock_items:
|
||||
item.total_value = flt(item.valuation_rate) * flt(item.consumed_quantity)
|
||||
|
||||
def update_status(self):
|
||||
if self.repair_status == 'Pending':
|
||||
frappe.db.set_value('Asset', self.asset, 'status', 'Out of Order')
|
||||
else:
|
||||
frappe.db.set_value('Asset', self.asset, 'status', 'Submitted')
|
||||
|
||||
def on_submit(self):
|
||||
if self.repair_status == "Pending":
|
||||
frappe.throw(_("Please update Repair Status."))
|
||||
|
||||
self.increase_asset_value()
|
||||
|
||||
def increase_asset_value(self):
|
||||
if self.capitalize_repair_cost:
|
||||
asset_value = frappe.db.get_value('Asset', self.asset, 'asset_value') + self.repair_cost
|
||||
for item in self.stock_items:
|
||||
asset_value += item.total_value
|
||||
|
||||
print("*" * 20)
|
||||
print(asset_value)
|
||||
frappe.db.set_value('Asset', self.asset, 'asset_value', asset_value)
|
||||
|
||||
# self.make_gl_entries()
|
||||
|
Loading…
x
Reference in New Issue
Block a user