modified leave application tests
This commit is contained in:
parent
05f7e14b5a
commit
4298bcfa40
@ -192,7 +192,7 @@ def mark_attendance():
|
||||
"attendance_date": attendance_date
|
||||
})
|
||||
leave = frappe.db.sql("""select name from `tabLeave Application`
|
||||
where employee = %s and %s between from_date and to_date and status = 'Approved'
|
||||
where employee = %s and %s between from_date and to_date and workflow_state = 'Approved'
|
||||
and docstatus = 1""", (employee.name, attendance_date))
|
||||
|
||||
if leave:
|
||||
|
@ -21,7 +21,7 @@ class Attendance(Document):
|
||||
|
||||
def check_leave_record(self):
|
||||
leave_record = frappe.db.sql("""select leave_type, half_day from `tabLeave Application`
|
||||
where employee = %s and %s between from_date and to_date and status = 'Approved'
|
||||
where employee = %s and %s between from_date and to_date and workflow_state = 'Approved'
|
||||
and docstatus = 1""", (self.employee, self.attendance_date), as_dict=True)
|
||||
if leave_record:
|
||||
if leave_record[0].half_day:
|
||||
|
@ -29,7 +29,6 @@ frappe.ui.form.on("Leave Application", {
|
||||
|
||||
refresh: function(frm) {
|
||||
if (frm.is_new()) {
|
||||
frm.set_value("status", "Open");
|
||||
frm.trigger("calculate_total_days");
|
||||
}
|
||||
},
|
||||
|
@ -59,7 +59,7 @@
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Status",
|
||||
"length": 0,
|
||||
"no_copy": 1,
|
||||
@ -796,7 +796,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 3,
|
||||
"modified": "2017-06-13 14:28:52.426044",
|
||||
"modified": "2018-01-16 00:21:59.025871",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Leave Application",
|
||||
|
@ -7,7 +7,7 @@ frappe.views.calendar["Leave Application"] = {
|
||||
"end": "to_date",
|
||||
"id": "name",
|
||||
"title": "title",
|
||||
"status": "status",
|
||||
"workflow_state": "workflow_state",
|
||||
},
|
||||
options: {
|
||||
header: {
|
||||
|
@ -1,8 +1,8 @@
|
||||
frappe.listview_settings['Leave Application'] = {
|
||||
add_fields: ["status", "leave_type", "employee", "employee_name", "total_leave_days", "from_date", "to_date"],
|
||||
filters:[["status","!=", "Rejected"]],
|
||||
add_fields: ["workflow_state", "leave_type", "employee", "employee_name", "total_leave_days", "from_date", "to_date"],
|
||||
filters:[["workflow_state","!=", "Rejected"]],
|
||||
get_indicator: function(doc) {
|
||||
return [__(doc.status), frappe.utils.guess_colour(doc.status),
|
||||
"status,=," + doc.status];
|
||||
return [__(doc.workflow_state), frappe.utils.guess_colour(doc.workflow_state),
|
||||
"workflow_state,=," + doc.workflow_state];
|
||||
}
|
||||
};
|
||||
|
@ -21,28 +21,21 @@ QUnit.test("Test: Leave application [HR]", function (assert) {
|
||||
]);
|
||||
},
|
||||
() => frappe.timeout(1),
|
||||
// check calculated total leave days
|
||||
() => assert.ok(!cur_frm.doc.docstatus,
|
||||
"leave application not submitted with status as open"),
|
||||
() => cur_frm.set_value("status", "Approved"), // approve the application [as administrator]
|
||||
|
||||
() => frappe.click_button('Actions'),
|
||||
() => frappe.timeout(0.5),
|
||||
// save form
|
||||
() => cur_frm.save(),
|
||||
() => frappe.timeout(1),
|
||||
() => cur_frm.savesubmit(),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Yes'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Approve'), // approve the application [as administrator]
|
||||
() => assert.ok(cur_frm.doc.docstatus,
|
||||
"leave application submitted after approval"),
|
||||
// check auto filled posting date [today]
|
||||
|
||||
() => assert.equal(today_date, cur_frm.doc.posting_date,
|
||||
"posting date correctly set"),
|
||||
() => frappe.set_route("List", "Leave Application", "List"),
|
||||
() => frappe.timeout(1),
|
||||
// check approved application in list
|
||||
() => assert.deepEqual(["Test Employee 1", "Approved"], [cur_list.data[0].employee_name, cur_list.data[0].status],
|
||||
"leave for correct employee is approved"),
|
||||
// // check approved application in list
|
||||
() => assert.deepEqual(["Test Employee 1", "Approved"], [cur_list.data[0].employee_name, cur_list.data[0].workflow_state],
|
||||
// "leave for correct employee is approved"),
|
||||
() => done()
|
||||
]);
|
||||
});
|
@ -103,7 +103,7 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
|
||||
application = self.get_application(_test_records[0])
|
||||
application.insert()
|
||||
application.status = "Approved"
|
||||
application.workflow_state = "Approved"
|
||||
self.assertRaises(LeaveDayBlockedError, application.submit)
|
||||
|
||||
frappe.set_user("test1@example.com")
|
||||
@ -257,7 +257,7 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
application.insert()
|
||||
|
||||
frappe.set_user("test@example.com")
|
||||
application.status = "Approved"
|
||||
application.workflow_state = "Approved"
|
||||
|
||||
# clear permlevel access cache on change user
|
||||
del application._has_access_to
|
||||
@ -297,7 +297,7 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
|
||||
# submit leave application by Leave Approver
|
||||
frappe.set_user("test1@example.com")
|
||||
application.status = "Approved"
|
||||
application.workflow_state = "Approved"
|
||||
del application._has_access_to
|
||||
application.submit()
|
||||
self.assertEqual(frappe.db.get_value("Leave Application", application.name,
|
||||
@ -339,7 +339,7 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
application.insert()
|
||||
frappe.set_user("test1@example.com")
|
||||
del application._has_access_to
|
||||
application.status = "Approved"
|
||||
application.workflow_state = "Approved"
|
||||
|
||||
from erpnext.hr.doctype.leave_application.leave_application import LeaveApproverIdentityError
|
||||
self.assertRaises(LeaveApproverIdentityError, application.submit)
|
||||
@ -364,7 +364,7 @@ class TestLeaveApplication(unittest.TestCase):
|
||||
|
||||
# change to valid leave approver and try to submit leave application
|
||||
frappe.set_user("test2@example.com")
|
||||
application.status = "Approved"
|
||||
application.workflow_state = "Approved"
|
||||
del application._has_access_to
|
||||
application.submit()
|
||||
self.assertEqual(frappe.db.get_value("Leave Application", application.name,
|
||||
|
@ -300,7 +300,7 @@ class SalarySlip(TransactionBase):
|
||||
where t2.name = t1.leave_type
|
||||
and t2.is_lwp = 1
|
||||
and t1.docstatus = 1
|
||||
and t1.status = 'Approved'
|
||||
and t1.workflow_state = 'Approved'
|
||||
and t1.employee = %(employee)s
|
||||
and CASE WHEN t2.include_holiday != 1 THEN %(dt)s not in ('{0}') and %(dt)s between from_date and to_date
|
||||
WHEN t2.include_holiday THEN %(dt)s between from_date and to_date
|
||||
|
Loading…
Reference in New Issue
Block a user