From 0763a8d42d7924b7c34efa4728513cec30024ae1 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 28 Apr 2025 15:43:13 +0530 Subject: [PATCH 1/3] fix: set billing hours to hours --- erpnext/projects/doctype/timesheet/timesheet.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index 09fdfad66ba..ae055b3f5d2 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -108,15 +108,10 @@ class Timesheet(Document): self.per_billed = (self.total_billed_hours * 100) / self.total_billable_hours def update_billing_hours(self, args): - if args.is_billable: - if flt(args.billing_hours) == 0.0: - args.billing_hours = args.hours - elif flt(args.billing_hours) > flt(args.hours): - frappe.msgprint( - _("Warning - Row {0}: Billing Hours are more than Actual Hours").format(args.idx), - indicator="orange", - alert=True, - ) + if args.is_billable and ( + flt(args.billing_hours) == 0.0 or flt(args.billing_hours) != flt(args.hours) + ): + args.billing_hours = args.hours else: args.billing_hours = 0 From a9df1f5f6bac60c04067255c83e0bdfff2f5a262 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 28 Apr 2025 16:07:54 +0530 Subject: [PATCH 2/3] fix: update billing hours when hours is changed --- erpnext/projects/doctype/timesheet/timesheet.js | 1 + erpnext/projects/doctype/timesheet/timesheet.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js index 168b891e98c..4c78d939ebc 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.js +++ b/erpnext/projects/doctype/timesheet/timesheet.js @@ -296,6 +296,7 @@ frappe.ui.form.on("Timesheet Detail", { hours: function (frm, cdt, cdn) { calculate_end_time(frm, cdt, cdn); + update_billing_hours(frm, cdt, cdn); calculate_billing_costing_amount(frm, cdt, cdn); calculate_time_and_amount(frm); }, diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index ae055b3f5d2..aa344c74fe9 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -108,12 +108,15 @@ class Timesheet(Document): self.per_billed = (self.total_billed_hours * 100) / self.total_billable_hours def update_billing_hours(self, args): - if args.is_billable and ( - flt(args.billing_hours) == 0.0 or flt(args.billing_hours) != flt(args.hours) - ): - args.billing_hours = args.hours - else: - args.billing_hours = 0 + if args.is_billable: + if flt(args.billing_hours) == 0.0: + args.billing_hours = args.hours + elif flt(args.billing_hours) > flt(args.hours): + frappe.msgprint( + _("Warning - Row {0}: Billing Hours are more than Actual Hours").format(args.idx), + indicator="orange", + alert=True, + ) def set_status(self): self.status = {"0": "Draft", "1": "Submitted", "2": "Cancelled"}[str(self.docstatus or 0)] From 8a30a313023458771b094c824ac704bf378a80f9 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Mon, 28 Apr 2025 16:08:40 +0530 Subject: [PATCH 3/3] fix: missing else statement --- erpnext/projects/doctype/timesheet/timesheet.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index aa344c74fe9..09fdfad66ba 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -117,6 +117,8 @@ class Timesheet(Document): indicator="orange", alert=True, ) + else: + args.billing_hours = 0 def set_status(self): self.status = {"0": "Draft", "1": "Submitted", "2": "Cancelled"}[str(self.docstatus or 0)]