feat: calculate hours (#33464)

* feat: calculate hours

* chore: Linting Issues

Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
This commit is contained in:
MOHAMMED NIYAS 2023-01-02 09:17:14 +05:30 committed by GitHub
parent 010718ffed
commit d054f37602
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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