fix(HR): changes as per PR review

> renamed 'Employee Checkin Log' DocType to 'Employee_attendance_log' DocType
> renamed biometric_id to biometric_rf_if
This commit is contained in:
karthikeyan5 2019-05-08 14:38:26 +05:30
parent e4bbda6ff5
commit a4d0ba222b
7 changed files with 38 additions and 38 deletions

View File

@ -16,7 +16,7 @@
"middle_name", "middle_name",
"last_name", "last_name",
"employee_name", "employee_name",
"biometric_id", "biometric_rf_id",
"image", "image",
"column_break1", "column_break1",
"company", "company",
@ -749,7 +749,7 @@
"label": "Old Parent" "label": "Old Parent"
}, },
{ {
"fieldname": "biometric_id", "fieldname": "biometric_rf_id",
"fieldtype": "Data", "fieldtype": "Data",
"label": "Biometric/RF tag ID ", "label": "Biometric/RF tag ID ",
"no_copy": 1, "no_copy": 1,
@ -759,7 +759,7 @@
"icon": "fa fa-user", "icon": "fa fa-user",
"idx": 24, "idx": 24,
"image_field": "image", "image_field": "image",
"modified": "2019-05-08 10:53:50.897464", "modified": "2019-05-08 14:32:06.443825",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Employee", "name": "Employee",

View File

@ -1,7 +1,7 @@
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt // For license information, please see license.txt
frappe.ui.form.on('Employee Checkin Log', { frappe.ui.form.on('Employee Attendance Log', {
// refresh: function(frm) { // refresh: function(frm) {
// } // }

View File

@ -1,6 +1,6 @@
{ {
"allow_import": 1, "allow_import": 1,
"autoname": "EMP-CHECKIN-.MM.-.YYYY.-.######", "autoname": "EMP-ATT-LOG-.MM.-.YYYY.-.######",
"creation": "2019-04-25 10:17:11.225671", "creation": "2019-04-25 10:17:11.225671",
"doctype": "DocType", "doctype": "DocType",
"engine": "InnoDB", "engine": "InnoDB",
@ -74,10 +74,10 @@
"options": "\nIN\nOUT" "options": "\nIN\nOUT"
} }
], ],
"modified": "2019-05-08 11:07:56.885960", "modified": "2019-05-08 14:10:22.468252",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Employee Checkin Log", "name": "Employee Attendance Log",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {

View File

@ -8,30 +8,30 @@ from frappe.utils import now
from frappe.model.document import Document from frappe.model.document import Document
from frappe import _ from frappe import _
class EmployeeCheckinLog(Document): class EmployeeAttendanceLog(Document):
pass pass
@frappe.whitelist() @frappe.whitelist()
def add_employee_checkin_log_based_on_biometric_id(biometric_id, timestamp, device_id=None, log_type=None): def add_log_based_on_biometric_rf_id(biometric_rf_id, timestamp, device_id=None, log_type=None):
"""Finds the relevant Employee using the biometric_id and creates a Employee Checkin Log. """Finds the relevant Employee using the biometric_rf_id and creates a Employee Attendance Log.
:param biometric_id: The Biometric/RF tag ID as set up in Employee DocType. :param biometric_rf_id: The Biometric/RF tag ID as set up in Employee DocType.
:param timestamp: The timestamp of the Log. Currently expected in the following format as string: '2019-05-08 10:48:08.000000' :param timestamp: The timestamp of the Log. Currently expected in the following format as string: '2019-05-08 10:48:08.000000'
:param device_id(optional): Location / Device ID. A short string is expected. :param device_id(optional): Location / Device ID. A short string is expected.
:param log_type(optional): Direction of the Check-in if available (IN/OUT). :param log_type(optional): Direction of the Punch if available (IN/OUT).
""" """
if not biometric_id or not timestamp: if not biometric_rf_id or not timestamp:
frappe.throw(_("'biometric_id' and 'timestamp' are required.")) frappe.throw(_("'biometric_rf_id' and 'timestamp' are required."))
employee = frappe.db.get_values("Employee", {"biometric_id": biometric_id},["name","employee_name","biometric_id"],as_dict=True) employee = frappe.db.get_values("Employee", {"biometric_rf_id": biometric_rf_id},["name","employee_name","biometric_rf_id"],as_dict=True)
if len(employee) != 0: if len(employee) != 0:
employee = employee[0] employee = employee[0]
else: else:
frappe.throw(_("No Employee found for the given 'biometric_id'.")) frappe.throw(_("No Employee found for the given 'biometric_rf_id'."))
doc = frappe.new_doc("Employee Checkin Log") doc = frappe.new_doc("Employee Attendance Log")
doc.employee = employee.name doc.employee = employee.name
doc.employee_name = employee.employee_name doc.employee_name = employee.employee_name
doc.time = timestamp doc.time = timestamp

View File

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
from erpnext.hr.doctype.employee_attendance_log.employee_attendance_log import add_log_based_on_biometric_rf_id
import frappe
import unittest
class TestEmployeeAttendanceLog(unittest.TestCase):
def test_add_log_based_on_biometric_rf_id(self):
employee = frappe.get_doc("Employee", frappe.db.sql_list("select name from tabEmployee limit 1")[0])
employee.biometric_rf_id = '12349'
employee.save()
employee_attendance_log = add_log_based_on_biometric_rf_id('12349', '2019-05-08 10:48:08.000000', 'mumbai_first_floor', 'IN')
self.assertTrue(employee_attendance_log.employee == employee.name)
self.assertTrue(employee_attendance_log.time == '2019-05-08 10:48:08.000000')
self.assertTrue(employee_attendance_log.device_id == 'mumbai_first_floor')
self.assertTrue(employee_attendance_log.log_type == 'IN')

View File

@ -1,21 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
from erpnext.hr.doctype.employee_checkin_log.employee_checkin_log import add_employee_checkin_log_based_on_biometric_id
import frappe
import unittest
class TestEmployeeCheckinLog(unittest.TestCase):
def test_add_employee_checkin_log_based_on_biometric_id(self):
employee = frappe.get_doc("Employee", frappe.db.sql_list("select name from tabEmployee limit 1")[0])
employee.biometric_id = '12349'
employee.save()
checkin_log = add_employee_checkin_log_based_on_biometric_id('12349', '2019-05-08 10:48:08.000000', 'mumbai_first_floor', 'IN')
self.assertTrue(checkin_log.employee == employee.name)
self.assertTrue(checkin_log.time == '2019-05-08 10:48:08.000000')
self.assertTrue(checkin_log.device_id == 'mumbai_first_floor')
self.assertTrue(checkin_log.log_type == 'IN')