From d054f376021280703124697c7dd02480c51569ff Mon Sep 17 00:00:00 2001 From: MOHAMMED NIYAS <76736615+niyazrazak@users.noreply.github.com> Date: Mon, 2 Jan 2023 09:17:14 +0530 Subject: [PATCH] feat: calculate hours (#33464) * feat: calculate hours * chore: Linting Issues Co-authored-by: Deepesh Garg --- erpnext/projects/doctype/timesheet/timesheet.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index b9bb37a05cf..1179364b834 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -25,12 +25,18 @@ class Timesheet(Document): def validate(self): self.set_status() self.validate_dates() + self.calculate_hours() self.validate_time_logs() self.update_cost() self.calculate_total_amounts() self.calculate_percentage_billed() self.set_dates() + def calculate_hours(self): + for row in self.time_logs: + if row.to_time and row.from_time: + row.hours = time_diff_in_hours(row.to_time, row.from_time) + def calculate_total_amounts(self): self.total_hours = 0.0 self.total_billable_hours = 0.0