From be598108b672f75cfabab310f421ac6df1d822d7 Mon Sep 17 00:00:00 2001 From: Nishka Gosalia Date: Wed, 4 Mar 2026 14:40:24 +0530 Subject: [PATCH] fix: updating costing based on employee change in timesheet (cherry picked from commit e37d4a6f7c0f13d420c2844368192cdd59eadedf) --- .../projects/doctype/timesheet/timesheet.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js index 9b01d1c429f..e9d868e108a 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.js +++ b/erpnext/projects/doctype/timesheet/timesheet.js @@ -260,6 +260,33 @@ frappe.ui.form.on("Timesheet", { parent_project: function (frm) { set_project_in_timelog(frm); }, + + employee: function (frm) { + if (frm.doc.employee && frm.doc.time_logs) { + const selected_employee = frm.doc.employee; + frm.doc.time_logs.forEach((row) => { + if (row.activity_type) { + frappe.call({ + method: "erpnext.projects.doctype.timesheet.timesheet.get_activity_cost", + args: { + employee: frm.doc.employee, + activity_type: row.activity_type, + currency: frm.doc.currency, + }, + callback: function (r) { + if (r.message) { + if (selected_employee !== frm.doc.employee) return; + row.billing_rate = r.message["billing_rate"]; + row.costing_rate = r.message["costing_rate"]; + frm.refresh_fields("time_logs"); + calculate_billing_costing_amount(frm, row.doctype, row.name); + } + }, + }); + } + }); + } + }, }); frappe.ui.form.on("Timesheet Detail", {