fix: validate Standard Working Hours
- use standard working hours in metrics calculation
This commit is contained in:
parent
b7a7e1b11a
commit
0decc2b66a
@ -146,7 +146,6 @@
|
|||||||
"label": "Send Leave Notification"
|
"label": "Send Leave Notification"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "8",
|
|
||||||
"fieldname": "standard_working_hours",
|
"fieldname": "standard_working_hours",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"label": "Standard Working Hours"
|
"label": "Standard Working Hours"
|
||||||
@ -156,7 +155,7 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-04-16 15:45:18.467699",
|
"modified": "2021-04-26 10:52:56.192773",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "HR Settings",
|
"name": "HR Settings",
|
||||||
|
@ -19,6 +19,7 @@ class EmployeeHoursReport:
|
|||||||
self.to_date = getdate(self.filters.to_date)
|
self.to_date = getdate(self.filters.to_date)
|
||||||
|
|
||||||
self.validate_dates()
|
self.validate_dates()
|
||||||
|
self.validate_standard_working_hours()
|
||||||
|
|
||||||
def validate_dates(self):
|
def validate_dates(self):
|
||||||
self.day_span = (self.to_date - self.from_date).days
|
self.day_span = (self.to_date - self.from_date).days
|
||||||
@ -26,6 +27,14 @@ class EmployeeHoursReport:
|
|||||||
if self.day_span <= 0:
|
if self.day_span <= 0:
|
||||||
frappe.throw(_('From Date must come before To Date'))
|
frappe.throw(_('From Date must come before To Date'))
|
||||||
|
|
||||||
|
def validate_standard_working_hours(self):
|
||||||
|
self.standard_working_hours = frappe.db.get_single_value('HR Settings', 'standard_working_hours')
|
||||||
|
if not self.standard_working_hours:
|
||||||
|
msg = _('The metrics for this report are calculated based on the Standard Working Hours. Please set {0} in {1}.').format(
|
||||||
|
frappe.bold('Standard Working Hours'), frappe.utils.get_link_to_form('HR Settings', 'HR Settings'))
|
||||||
|
|
||||||
|
frappe.throw(msg)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.generate_columns()
|
self.generate_columns()
|
||||||
self.generate_data()
|
self.generate_data()
|
||||||
@ -163,8 +172,7 @@ class EmployeeHoursReport:
|
|||||||
self.stats_by_employee[emp]['employee_name'] = emp_name
|
self.stats_by_employee[emp]['employee_name'] = emp_name
|
||||||
|
|
||||||
def calculate_utilizations(self):
|
def calculate_utilizations(self):
|
||||||
# (9.0) Will be fetched from HR settings
|
TOTAL_HOURS = flt(self.standard_working_hours * self.day_span, 2)
|
||||||
TOTAL_HOURS = flt(9.0 * self.day_span, 2)
|
|
||||||
for emp, data in iteritems(self.stats_by_employee):
|
for emp, data in iteritems(self.stats_by_employee):
|
||||||
data['total_hours'] = TOTAL_HOURS
|
data['total_hours'] = TOTAL_HOURS
|
||||||
data['untracked_hours'] = flt(TOTAL_HOURS - data['billed_hours'] - data['non_billed_hours'], 2)
|
data['untracked_hours'] = flt(TOTAL_HOURS - data['billed_hours'] - data['non_billed_hours'], 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user