Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As OneFM I want to determine Employee's Civil ID Assurance Level so that we can determine whether their leave application should pass through the DSS #3773

Open
wants to merge 7 commits into
base: staging
Choose a base branch
from
4 changes: 4 additions & 0 deletions one_fm/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@
"OAuth Bearer Token": {
"after_insert": "one_fm.api.doc_methods.oauth_bearer_token.revoke_and_delete_existing_tokens",
},
"Employee": {
"before_save": "one_fm.overrides.employee.get_assurance_level_of_employee"
}
}

standard_portal_menu_items = [
Expand Down Expand Up @@ -558,6 +561,7 @@
"one_fm.developer.doctype.bug_buster.bug_buster.roster_bug_buster",
'one_fm.utils.set_employee_status_to_vacation',
'one_fm.utils.set_out_of_office_for_leaves',
'one_fm.utils.update_active_employees_assurance_level'
],
"hourly": [
# "one_fm.api.tasks.send_checkin_hourly_reminder",
Expand Down
2 changes: 1 addition & 1 deletion one_fm/one_fm/custom/employee.json
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only": 1,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
Expand Down
123 changes: 95 additions & 28 deletions one_fm/one_fm/custom/leave_application.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,72 @@
{
"custom_fields": [
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"creation": "2024-11-06 10:27:26.011840",
"default": null,
"depends_on": null,
"description": null,
"docstatus": 0,
"dt": "Leave Application",
"fetch_from": "employee.custom_civil_id_assurance_level",
"fetch_if_empty": 0,
"fieldname": "custom_employee_civil_id_assurance_level",
"fieldtype": "Data",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 4,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "employee_name",
"is_system_generated": 0,
"is_virtual": 0,
"label": "Employee Civil ID Assurance Level",
"length": 0,
"link_filters": null,
"mandatory_depends_on": null,
"modified": "2024-11-06 10:27:26.011840",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-custom_employee_civil_id_assurance_level",
"no_copy": 0,
"non_negative": 0,
"options": null,
"owner": "Administrator",
"parent": null,
"parentfield": null,
"parenttype": null,
"permlevel": 0,
"placeholder": null,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 1,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"show_dashboard": 0,
"sort_options": 0,
"translatable": 0,
"unique": 0,
"width": null
},
{
"_assign": null,
"_comments": null,
Expand All @@ -25,7 +92,7 @@
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 20,
"idx": 21,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
Expand Down Expand Up @@ -92,7 +159,7 @@
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 21,
"idx": 22,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
Expand Down Expand Up @@ -147,7 +214,7 @@
"columns": 0,
"creation": "2024-10-31 15:32:25.595259",
"default": null,
"depends_on": "eval:doc.status === 'Cancelled' || doc.status === 'Approved'",
"depends_on": "eval:doc.status === 'Cancelled'",
"description": null,
"docstatus": 0,
"dt": "Leave Application",
Expand All @@ -159,7 +226,7 @@
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 18,
"idx": 19,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
Expand Down Expand Up @@ -226,7 +293,7 @@
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 42,
"idx": 43,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
Expand Down Expand Up @@ -293,7 +360,7 @@
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 35,
"idx": 36,
"ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_global_search": 0,
Expand Down Expand Up @@ -360,7 +427,7 @@
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 36,
"idx": 37,
"ignore_user_permissions": 1,
"ignore_xss_filter": 0,
"in_global_search": 0,
Expand Down Expand Up @@ -427,7 +494,7 @@
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 41,
"idx": 42,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
Expand Down Expand Up @@ -494,7 +561,7 @@
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 22,
"idx": 23,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
Expand Down Expand Up @@ -695,7 +762,7 @@
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 9,
"idx": 10,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
Expand Down Expand Up @@ -762,7 +829,7 @@
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 40,
"idx": 41,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
Expand Down Expand Up @@ -889,7 +956,7 @@
"field_name": "description",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.261830",
"modified": "2024-11-06 10:20:13.831199",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-description-read_only_depends_on",
Expand All @@ -915,7 +982,7 @@
"field_name": "employee",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.288195",
"modified": "2024-11-06 10:20:13.848142",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-employee-ignore_user_permissions",
Expand All @@ -941,7 +1008,7 @@
"field_name": "employee",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.315923",
"modified": "2024-11-06 10:20:13.867461",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-employee-read_only_depends_on",
Expand All @@ -967,7 +1034,7 @@
"field_name": "follow_via_email",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.331207",
"modified": "2024-11-06 10:20:13.886929",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-follow_via_email-default",
Expand All @@ -993,7 +1060,7 @@
"field_name": "from_date",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.345946",
"modified": "2024-11-06 10:20:13.903709",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-from_date-read_only_depends_on",
Expand All @@ -1019,7 +1086,7 @@
"field_name": "half_day",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.360798",
"modified": "2024-11-06 10:20:13.919794",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-half_day-read_only_depends_on",
Expand All @@ -1045,7 +1112,7 @@
"field_name": "leave_approver",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.374373",
"modified": "2024-11-06 10:20:13.937902",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-leave_approver-default",
Expand All @@ -1071,7 +1138,7 @@
"field_name": "leave_approver",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.390987",
"modified": "2024-11-06 10:20:13.954055",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-leave_approver-read_only_depends_on",
Expand All @@ -1097,7 +1164,7 @@
"field_name": "leave_type",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.404793",
"modified": "2024-11-06 10:20:13.970371",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-leave_type-read_only_depends_on",
Expand All @@ -1115,15 +1182,15 @@
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"creation": "2024-11-03 13:10:24.504036",
"creation": "2024-11-06 10:27:25.813900",
"default_value": null,
"doc_type": "Leave Application",
"docstatus": 0,
"doctype_or_field": "DocType",
"field_name": null,
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 13:10:24.504036",
"modified": "2024-11-06 10:27:25.813900",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-main-field_order",
Expand All @@ -1134,7 +1201,7 @@
"property": "field_order",
"property_type": "Data",
"row_name": null,
"value": "[\"workflow_state\", \"naming_series\", \"employee\", \"employee_name\", \"column_break_4\", \"leave_type\", \"is_proof_document_required\", \"proof_document\", \"proof_documents\", \"company\", \"department\", \"section_break_5\", \"from_date\", \"to_date\", \"half_day\", \"half_day_date\", \"total_leave_days\", \"custom_reason_for_cancel\", \"column_break1\", \"custom_propose_from_date\", \"custom_propose_to_date\", \"custom_total_propose_leave_days\", \"description\", \"leave_balance\", \"section_break_7\", \"leave_approver\", \"leave_approver_name\", \"follow_via_email\", \"column_break_18\", \"posting_date\", \"status\", \"sb_other_details\", \"salary_slip\", \"color\", \"custom_reliever_\", \"custom_reliever_name\", \"column_break_17\", \"letter_head\", \"amended_from\", \"source\", \"custom_section_break_neyf8\", \"custom_reassigned_documents\"]"
"value": "[\"workflow_state\", \"naming_series\", \"employee\", \"employee_name\", \"employee_civil_id_assurance_level\", \"column_break_4\", \"leave_type\", \"is_proof_document_required\", \"proof_document\", \"proof_documents\", \"company\", \"department\", \"section_break_5\", \"from_date\", \"to_date\", \"half_day\", \"half_day_date\", \"total_leave_days\", \"custom_reason_for_cancel\", \"column_break1\", \"custom_propose_from_date\", \"custom_propose_to_date\", \"custom_total_propose_leave_days\", \"description\", \"leave_balance\", \"section_break_7\", \"leave_approver\", \"leave_approver_name\", \"follow_via_email\", \"column_break_18\", \"posting_date\", \"status\", \"sb_other_details\", \"salary_slip\", \"color\", \"custom_reliever_\", \"custom_reliever_name\", \"column_break_17\", \"letter_head\", \"amended_from\", \"source\", \"custom_section_break_neyf8\", \"custom_reassigned_documents\"]"
},
{
"_assign": null,
Expand All @@ -1149,7 +1216,7 @@
"field_name": null,
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.438053",
"modified": "2024-11-06 10:20:14.005017",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-main-max_attachments",
Expand All @@ -1175,7 +1242,7 @@
"field_name": "naming_series",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.452278",
"modified": "2024-11-06 10:20:14.023809",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-naming_series-options",
Expand All @@ -1201,7 +1268,7 @@
"field_name": "status",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.464574",
"modified": "2024-11-06 10:20:14.042376",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-status-read_only",
Expand All @@ -1227,7 +1294,7 @@
"field_name": "status",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.478335",
"modified": "2024-11-06 10:20:14.066247",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-status-read_only_depends_on",
Expand All @@ -1253,7 +1320,7 @@
"field_name": "to_date",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-11-03 11:22:30.493450",
"modified": "2024-11-06 10:20:14.091867",
"modified_by": "Administrator",
"module": null,
"name": "Leave Application-to_date-read_only_depends_on",
Expand Down
12 changes: 11 additions & 1 deletion one_fm/overrides/employee.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from itertools import chain
from json import loads
import requests

import frappe
from frappe.utils import getdate, add_days, get_url_to_form, get_url
Expand All @@ -15,7 +16,7 @@
is_subcontract_employee
)
from one_fm.processor import sendemail,send_whatsapp
from one_fm.utils import get_domain, get_standard_notification_template, get_approver_user
from one_fm.utils import call_to_get_assurance_level, get_domain, get_standard_notification_template, get_approver_user, update_active_employees_assurance_level
from six import string_types
from frappe import _
from one_fm.operations.doctype.operations_shift.operations_shift import get_supervisor_operations_shifts
Expand Down Expand Up @@ -553,3 +554,12 @@ def toggle_auto_attendance(employee_names: list | str, status: bool):
except Exception as e:
frappe.log_error(title = f"{str(e)}",message = frappe.get_traceback())
return response(message=str(e), status_code=400)


@frappe.whitelist()
def get_assurance_level_of_employee(doc, method):
if doc.one_fm_civil_id:
verification_level = call_to_get_assurance_level(doc.one_fm_civil_id)
doc.custom_civil_id_assurance_level = verification_level
return True

Loading
Loading