fix: remove Service Level DocType
This commit is contained in:
parent
fc4c795661
commit
f77d7243dc
@ -1,6 +0,0 @@
|
||||
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Service Level', {
|
||||
|
||||
});
|
@ -1,111 +0,0 @@
|
||||
{
|
||||
"autoname": "field:service_level",
|
||||
"creation": "2018-11-19 12:44:30.407502",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"service_level",
|
||||
"employee_group",
|
||||
"column_break_2",
|
||||
"holiday_list",
|
||||
"default_priority",
|
||||
"response_and_resoution_time",
|
||||
"priorities",
|
||||
"section_break_01",
|
||||
"support_and_resolution"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "service_level",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "Level",
|
||||
"reqd": 1,
|
||||
"unique": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_2",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "holiday_list",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Holiday List (ignored during SLA calculation)",
|
||||
"options": "Holiday List",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "employee_group",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Employee Group",
|
||||
"options": "Employee Group"
|
||||
},
|
||||
{
|
||||
"fieldname": "response_and_resoution_time",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Response and Resoution Time"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_01",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Support Hours"
|
||||
},
|
||||
{
|
||||
"fieldname": "support_and_resolution",
|
||||
"fieldtype": "Table",
|
||||
"label": "Support and Resolution",
|
||||
"options": "Service Day",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "priorities",
|
||||
"fieldtype": "Table",
|
||||
"label": "Priorities",
|
||||
"options": "Service Level Priority",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "default_priority",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Priority",
|
||||
"options": "Issue Priority",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"modified": "2019-06-06 12:58:03.464056",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Support",
|
||||
"name": "Service Level",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "All",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC"
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from datetime import datetime
|
||||
from frappe.utils import get_weekdays
|
||||
|
||||
class ServiceLevel(Document):
|
||||
|
||||
def validate(self):
|
||||
self.check_priorities()
|
||||
self.check_support_and_resolution()
|
||||
|
||||
def check_priorities(self):
|
||||
default_priority = []
|
||||
priorities = []
|
||||
|
||||
for priority in self.priorities:
|
||||
# Check if response and resolution time is set for every priority
|
||||
if not (priority.response_time or priority.resolution_time):
|
||||
frappe.throw(_("Set Response Time and Resolution for Priority {0} at index {1}.").format(priority.priority, priority.idx))
|
||||
|
||||
priorities.append(priority.priority)
|
||||
|
||||
if priority.default_priority:
|
||||
default_priority.append(priority.default_priority)
|
||||
|
||||
if priority.response_time_period == "Hour":
|
||||
response = priority.response_time * 0.0416667
|
||||
elif priority.response_time_period == "Day":
|
||||
response = priority.response_time
|
||||
elif priority.response_time_period == "Week":
|
||||
response = priority.response_time * 7
|
||||
|
||||
if priority.resolution_time_period == "Hour":
|
||||
resolution = priority.resolution_time * 0.0416667
|
||||
elif priority.resolution_time_period == "Day":
|
||||
resolution = priority.resolution_time
|
||||
elif priority.resolution_time_period == "Week":
|
||||
resolution = priority.resolution_time * 7
|
||||
|
||||
if response > resolution:
|
||||
frappe.throw(_("Response Time for {0} at index {1} can't be greater than Resolution Time.").format(priority.priority, priority.idx))
|
||||
|
||||
# Check if repeated priority
|
||||
if not len(set(priorities)) == len(priorities):
|
||||
repeated_priority = get_repeated(priorities)
|
||||
frappe.throw(_("Priority {0} has been repeated.").format(repeated_priority))
|
||||
|
||||
# Check if repeated default priority
|
||||
if not len(set(default_priority)) == len(default_priority):
|
||||
frappe.throw(_("Select only one Priority as Default."))
|
||||
|
||||
# set default priority from priorities
|
||||
try:
|
||||
self.default_priority = next(d.priority for d in self.priorities if d.default_priority)
|
||||
except Exception:
|
||||
frappe.throw(_("Select a Default Priority."))
|
||||
|
||||
def check_support_and_resolution(self):
|
||||
week = get_weekdays()
|
||||
support_days = []
|
||||
|
||||
for support_and_resolution in self.support_and_resolution:
|
||||
# Check if start and end time is set for every support day
|
||||
if not (support_and_resolution.start_time or support_and_resolution.end_time):
|
||||
frappe.throw(_("Set Start Time and End Time for \
|
||||
Support Day {0} at index {1}.".format(support_and_resolution.workday, support_and_resolution.idx)))
|
||||
|
||||
support_days.append(support_and_resolution.workday)
|
||||
support_and_resolution.idx = week.index(support_and_resolution.workday) + 1
|
||||
|
||||
if support_and_resolution.start_time >= support_and_resolution.end_time:
|
||||
frappe.throw(_("Start Time can't be greater than or equal to End Time \
|
||||
for {0}.".format(support_and_resolution.workday)))
|
||||
|
||||
# Check for repeated workday
|
||||
if not len(set(support_days)) == len(support_days):
|
||||
repeated_days = get_repeated(support_days)
|
||||
frappe.throw(_("Workday {0} has been repeated.").format(repeated_days))
|
||||
|
||||
def get_repeated(values):
|
||||
unique_list = []
|
||||
diff = []
|
||||
for value in values:
|
||||
if value not in unique_list:
|
||||
unique_list.append(str(value))
|
||||
else:
|
||||
if value not in diff:
|
||||
diff.append(str(value))
|
||||
return " ".join(diff)
|
@ -1,12 +0,0 @@
|
||||
from frappe import _
|
||||
|
||||
def get_data():
|
||||
return {
|
||||
'fieldname': 'service_level',
|
||||
'transactions': [
|
||||
{
|
||||
'label': _('Service Level Agreement'),
|
||||
'items': ['Service Level Agreement']
|
||||
}
|
||||
]
|
||||
}
|
@ -1,149 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
from erpnext.hr.doctype.employee_group.test_employee_group import make_employee_group
|
||||
from erpnext.support.doctype.issue_priority.test_issue_priority import make_priorities
|
||||
|
||||
import frappe
|
||||
import unittest
|
||||
|
||||
class TestServiceLevel(unittest.TestCase):
|
||||
|
||||
def test_service_level(self):
|
||||
employee_group = make_employee_group()
|
||||
make_holiday_list()
|
||||
make_priorities()
|
||||
|
||||
# Default Service Level
|
||||
test_make_service_level = create_service_level("__Test Service Level", "__Test Holiday List", employee_group, 4, 6)
|
||||
get_make_service_level = get_service_level("__Test Service Level")
|
||||
|
||||
self.assertEqual(test_make_service_level.name, get_make_service_level.name)
|
||||
self.assertEqual(test_make_service_level.holiday_list, get_make_service_level.holiday_list)
|
||||
self.assertEqual(test_make_service_level.employee_group, get_make_service_level.employee_group)
|
||||
|
||||
# Service Level
|
||||
test_make_service_level = create_service_level("_Test Service Level", "__Test Holiday List", employee_group, 2, 3)
|
||||
get_make_service_level = get_service_level("_Test Service Level")
|
||||
|
||||
self.assertEqual(test_make_service_level.name, get_make_service_level.name)
|
||||
self.assertEqual(test_make_service_level.holiday_list, get_make_service_level.holiday_list)
|
||||
self.assertEqual(test_make_service_level.employee_group, get_make_service_level.employee_group)
|
||||
|
||||
|
||||
def create_service_level(service_level, holiday_list, employee_group, response_time, resolution_time):
|
||||
sl = frappe.get_doc({
|
||||
"doctype": "Service Level",
|
||||
"service_level": service_level,
|
||||
"holiday_list": holiday_list,
|
||||
"employee_group": employee_group,
|
||||
"priorities": [
|
||||
{
|
||||
"priority": "Low",
|
||||
"response_time": response_time,
|
||||
"response_time_period": "Hour",
|
||||
"resolution_time": resolution_time,
|
||||
"resolution_time_period": "Hour",
|
||||
},
|
||||
{
|
||||
"priority": "Medium",
|
||||
"response_time": response_time,
|
||||
"default_priority": 1,
|
||||
"response_time_period": "Hour",
|
||||
"resolution_time": resolution_time,
|
||||
"resolution_time_period": "Hour",
|
||||
},
|
||||
{
|
||||
"priority": "High",
|
||||
"response_time": response_time,
|
||||
"response_time_period": "Hour",
|
||||
"resolution_time": resolution_time,
|
||||
"resolution_time_period": "Hour",
|
||||
}
|
||||
],
|
||||
"support_and_resolution": [
|
||||
{
|
||||
"workday": "Monday",
|
||||
"start_time": "10:00:00",
|
||||
"end_time": "18:00:00",
|
||||
},
|
||||
{
|
||||
"workday": "Tuesday",
|
||||
"start_time": "10:00:00",
|
||||
"end_time": "18:00:00",
|
||||
},
|
||||
{
|
||||
"workday": "Wednesday",
|
||||
"start_time": "10:00:00",
|
||||
"end_time": "18:00:00",
|
||||
},
|
||||
{
|
||||
"workday": "Thursday",
|
||||
"start_time": "10:00:00",
|
||||
"end_time": "18:00:00",
|
||||
},
|
||||
{
|
||||
"workday": "Friday",
|
||||
"start_time": "10:00:00",
|
||||
"end_time": "18:00:00",
|
||||
},
|
||||
{
|
||||
"workday": "Saturday",
|
||||
"start_time": "10:00:00",
|
||||
"end_time": "18:00:00",
|
||||
},
|
||||
{
|
||||
"workday": "Sunday",
|
||||
"start_time": "10:00:00",
|
||||
"end_time": "18:00:00",
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
sl_exists = frappe.db.exists("Service Level", {"service_level": service_level})
|
||||
|
||||
if not sl_exists:
|
||||
sl.insert()
|
||||
return sl
|
||||
else:
|
||||
return frappe.get_doc("Service Level", {"service_level": service_level})
|
||||
|
||||
def get_service_level(service_level):
|
||||
return frappe.get_doc("Service Level", service_level)
|
||||
|
||||
def make_holiday_list():
|
||||
holiday_list = frappe.db.exists("Holiday List", "__Test Holiday List")
|
||||
if not holiday_list:
|
||||
now = frappe.utils.now_datetime()
|
||||
holiday_list = frappe.get_doc({
|
||||
"doctype": "Holiday List",
|
||||
"holiday_list_name": "__Test Holiday List",
|
||||
"from_date": "2019-01-01",
|
||||
"to_date": "2019-12-31",
|
||||
"holidays": [
|
||||
{
|
||||
"description": "Test Holiday 1",
|
||||
"holiday_date": "2019-03-05"
|
||||
},
|
||||
{
|
||||
"description": "Test Holiday 2",
|
||||
"holiday_date": "2019-03-07"
|
||||
},
|
||||
{
|
||||
"description": "Test Holiday 3",
|
||||
"holiday_date": "2019-02-11"
|
||||
},
|
||||
]
|
||||
}).insert()
|
||||
|
||||
def create_service_level_for_sla():
|
||||
employee_group = make_employee_group()
|
||||
make_holiday_list()
|
||||
make_priorities()
|
||||
|
||||
# Default Service Level
|
||||
create_service_level("__Test Service Level", "__Test Holiday List", employee_group, 4, 6)
|
||||
|
||||
# Service Level
|
||||
create_service_level("_Test Service Level", "__Test Holiday List", employee_group, 2, 3)
|
@ -40,7 +40,8 @@
|
||||
"fieldname": "holiday_list",
|
||||
"fieldtype": "Link",
|
||||
"label": "Holiday List",
|
||||
"options": "Holiday List"
|
||||
"options": "Holiday List",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_2",
|
||||
@ -92,13 +93,15 @@
|
||||
"fieldname": "support_and_resolution",
|
||||
"fieldtype": "Table",
|
||||
"label": "Support and Resolution",
|
||||
"options": "Service Day"
|
||||
"options": "Service Day",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "priorities",
|
||||
"fieldtype": "Table",
|
||||
"label": "Priorities",
|
||||
"options": "Service Level Priority"
|
||||
"options": "Service Level Priority",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"default": "1",
|
||||
@ -150,7 +153,7 @@
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"modified": "2020-04-28 14:10:18.767202",
|
||||
"modified": "2020-05-06 11:46:38.834810",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Support",
|
||||
"name": "Service Level Agreement",
|
||||
|
Loading…
x
Reference in New Issue
Block a user