Skip to content

Commit

Permalink
Merge pull request #3597 from ONE-F-M/staging
Browse files Browse the repository at this point in the history
Sprint 128 - Staging to Test-Production V15.1.0
  • Loading branch information
pjamsheer authored Aug 28, 2024
2 parents 0fa56a0 + 0144111 commit 7dc2126
Show file tree
Hide file tree
Showing 9 changed files with 461 additions and 86 deletions.
14 changes: 14 additions & 0 deletions one_fm/api/tasks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import itertools
from string import Template
from calendar import month, monthrange
from erpnext.crm.utils import get_open_todos
from datetime import datetime, timedelta
from frappe import enqueue
import frappe, erpnext
from frappe.desk.form.assign_to import remove
from frappe import _
from frappe.model.workflow import apply_workflow
from frappe.utils import (
Expand Down Expand Up @@ -368,6 +370,18 @@ def checkin_checkout_query(date, shift_type, log_type):
""".format(date=cstr(date), shift_type=shift_type, log_type=log_type, permission_type=permission_type), as_dict=1)
return query



def remove_assignment(docname,doctype=None):
"""Remove all user assignments in a document,
It defaults to attendance check if no doctype is set"""
if not doctype:
doctype="Attendance Check"
open_todo = get_open_todos(doctype,docname)
if open_todo:
for each in open_todo:
remove(doctype,docname,each.allocated_to,ignore_permissions=1)

@frappe.whitelist()
def get_action_user(employee, shift):
"""
Expand Down
4 changes: 4 additions & 0 deletions one_fm/grd/doctype/paci/paci.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class PACI(Document):
def validate(self):
self.set_grd_values()
self.set_new_expiry_date()


def set_grd_values(self):
Expand All @@ -25,6 +26,9 @@ def set_grd_values(self):
self.grd_operator = frappe.db.get_value('GRD Settings', None, 'default_grd_operator')
if not self.grd_operator_transfer:
self.grd_operator_transfer = frappe.db.get_value('GRD Settings', None, 'default_grd_operator_transfer')

def set_new_expiry_date(self):
self.new_civil_id_expiry_date = frappe.db.get_value("Employee", self.employee, "work_permit_expiry_date")


def on_update(self):
Expand Down
43 changes: 38 additions & 5 deletions one_fm/grd/doctype/work_permit/work_permit.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
"salary_certificate",
"column_break_64",
"iqrar",
"new_passport_details_section",
"new_passport_type",
"column_break_yjma",
"new_passport_number",
"column_break_jgpb",
"new_passport_expiry_date",
"documents_required_section",
"documents_required",
"amended_from",
Expand Down Expand Up @@ -581,16 +587,13 @@
"read_only": 1
},
{
"allow_on_submit": 1,
"fetch_from": "employee.one_fm_passport_type",
"fieldname": "passport_type",
"fieldtype": "Data",
"label": "Passport Type",
"read_only": 1,
"translatable": 1
"read_only": 1
},
{
"allow_on_submit": 1,
"fetch_from": "employee.passport_number",
"fieldname": "passport_number",
"fieldtype": "Data",
Expand Down Expand Up @@ -901,6 +904,36 @@
"print_hide": 1,
"read_only": 1
},
{
"description": "The details added in this section will update the employee passport details in Employee doctype",
"fieldname": "new_passport_details_section",
"fieldtype": "Section Break",
"label": "New Passport Details"
},
{
"fieldname": "new_passport_type",
"fieldtype": "Select",
"label": "Passport Type",
"options": "\nDiplomat\nNormal"
},
{
"fieldname": "column_break_yjma",
"fieldtype": "Column Break"
},
{
"fieldname": "new_passport_number",
"fieldtype": "Data",
"label": "Passport Number"
},
{
"fieldname": "column_break_jgpb",
"fieldtype": "Column Break"
},
{
"fieldname": "new_passport_expiry_date",
"fieldtype": "Date",
"label": "Passport Expiry Date"
},
{
"fieldname": "new_pam_details_section",
"fieldtype": "Section Break",
Expand Down Expand Up @@ -953,7 +986,7 @@
],
"is_submittable": 1,
"links": [],
"modified": "2024-08-18 11:30:35.755202",
"modified": "2024-08-26 10:15:55.860237",
"modified_by": "Administrator",
"module": "GRD",
"name": "Work Permit",
Expand Down
21 changes: 21 additions & 0 deletions one_fm/grd/doctype/work_permit/work_permit.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
class WorkPermit(Document):
def on_update(self):
self.update_work_permit_details_in_tp()
self.update_passport_details_in_employee()
self.check_required_document_for_workflow()
self.notify()
self.send_work_permit_receipt_to_perm_operator()
Expand Down Expand Up @@ -200,6 +201,26 @@ def update_work_permit_details_in_tp(self):
tp.save()
tp.reload()


def update_passport_details_in_employee(self):
"""
runs: `on_update`
param: work_permit object
This method sets employee passport details in employee doctype
"""
updated_values = {}

if self.new_passport_type:
updated_values['one_fm_passport_type'] = self.new_passport_type
if self.new_passport_number:
updated_values['passport_number'] = self.new_passport_number
if self.new_passport_expiry_date:
updated_values['valid_upto'] = self.new_passport_expiry_date

if self.employee and updated_values:
frappe.db.set_value('Employee', self.employee, updated_values)

def on_submit(self):
if self.work_permit_type not in ['Cancellation', 'New Kuwaiti', 'Local Transfer'] and self.workflow_state != "Rejected":
if self.workflow_state == "Completed" and self.upload_work_permit and self.attach_invoice and self.new_work_permit_expiry_date:
Expand Down
107 changes: 77 additions & 30 deletions one_fm/one_fm/custom/payroll_entry.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"idx": 10,
"idx": 11,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
Expand Down Expand Up @@ -267,22 +267,69 @@
],
"custom_perms": [],
"doctype": "Payroll Entry",
"links": [],
"links": [
{
"creation": "2024-08-27 09:55:29.539844",
"custom": 1,
"docstatus": 0,
"group": null,
"hidden": 0,
"idx": 0,
"is_child_table": 0,
"link_doctype": "Missing Payroll Information",
"link_fieldname": "payroll_entry",
"modified": "2024-08-27 09:55:29.539844",
"modified_by": "Administrator",
"name": "dcug485kh2",
"owner": "Administrator",
"parent": "Payroll Entry",
"parent_doctype": null,
"parentfield": "links",
"parenttype": "Customize Form",
"table_fieldname": null
}
],
"property_setters": [
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"creation": "2023-11-16 14:49:40.396485",
"creation": "2024-08-27 09:55:30.066461",
"default_value": null,
"doc_type": "Payroll Entry",
"docstatus": 0,
"doctype_or_field": "DocType",
"field_name": null,
"idx": 0,
"is_system_generated": 0,
"modified": "2024-08-27 09:55:30.066461",
"modified_by": "Administrator",
"module": null,
"name": "Payroll Entry-main-links_order",
"owner": "Administrator",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "links_order",
"property_type": "Small Text",
"row_name": null,
"value": "[\"dcug485kh2\"]"
},
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"creation": "2024-08-27 09:55:27.836379",
"default_value": null,
"doc_type": "Payroll Entry",
"docstatus": 0,
"doctype_or_field": "DocType",
"field_name": null,
"idx": 0,
"is_system_generated": 0,
"modified": "2024-08-13 11:58:46.748368",
"modified": "2024-08-27 09:55:27.836379",
"modified_by": "Administrator",
"module": null,
"name": "Payroll Entry-main-field_order",
Expand All @@ -293,51 +340,51 @@
"property": "field_order",
"property_type": "Data",
"row_name": null,
"value": "[\"select_payroll_period\", \"posting_date\", \"company\", \"payment_purpose\", \"column_break_5\", \"currency\", \"exchange_rate\", \"payroll_payable_account\", \"status\", \"section_break_cypo\", \"payroll_type\", \"payroll_frequency\", \"start_date\", \"end_date\", \"column_break_13\", \"salary_slip_based_on_timesheet\", \"deduct_tax_for_unclaimed_employee_benefits\", \"deduct_tax_for_unsubmitted_tax_exemption_proof\", \"employees_tab\", \"section_break_17\", \"branch\", \"department\", \"column_break_21\", \"designation\", \"number_of_employees\", \"section_break_24\", \"employees\", \"section_break_26\", \"validate_attendance\", \"attendance_detail_html\", \"accounting_dimensions_tab\", \"accounting_dimensions_section\", \"cost_center\", \"dimension_col_break\", \"project\", \"account\", \"payment_account\", \"column_break_35\", \"bank_account\", \"salary_slips_created\", \"salary_slips_submitted\", \"failure_details_section\", \"error_message\", \"section_break_41\", \"amended_from\", \"connections_tab\"]"
"value": "[\"select_payroll_period\", \"posting_date\", \"company\", \"payment_purpose\", \"column_break_5\", \"currency\", \"exchange_rate\", \"payroll_payable_account\", \"status\", \"section_break_cypo\", \"payroll_type\", \"payroll_frequency\", \"start_date\", \"end_date\", \"column_break_13\", \"salary_slip_based_on_timesheet\", \"deduct_tax_for_unclaimed_employee_benefits\", \"deduct_tax_for_unsubmitted_tax_exemption_proof\", \"employees_tab\", \"section_break_17\", \"branch\", \"department\", \"custom_project_configuration\", \"custom_project_filter\", \"column_break_21\", \"designation\", \"grade\", \"number_of_employees\", \"section_break_24\", \"employees\", \"section_break_26\", \"validate_attendance\", \"attendance_detail_html\", \"accounting_dimensions_tab\", \"accounting_dimensions_section\", \"cost_center\", \"dimension_col_break\", \"project\", \"account\", \"payment_account\", \"column_break_35\", \"bank_account\", \"salary_slips_created\", \"salary_slips_submitted\", \"failure_details_section\", \"error_message\", \"section_break_41\", \"amended_from\", \"connections_tab\"]"
},
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"creation": "2024-08-13 11:56:12.018201",
"creation": "2024-08-13 11:55:57.918303",
"default_value": null,
"doc_type": "Payroll Entry",
"docstatus": 0,
"doctype_or_field": "DocField",
"field_name": "payroll_frequency",
"field_name": "branch",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-08-05 15:25:04.412492",
"modified": "2024-08-26 13:00:33.833763",
"modified_by": "Administrator",
"module": "One Fm",
"name": "Payroll Entry-payroll_frequency-options",
"module": null,
"name": "Payroll Entry-branch-hidden",
"owner": "Administrator",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "options",
"property_type": "select",
"property": "hidden",
"property_type": "Check",
"row_name": null,
"value": "\nMonthly"
"value": "1"
},
{
"_assign": null,
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"creation": "2024-08-13 11:55:58.104054",
"creation": "2024-08-13 11:55:57.965212",
"default_value": null,
"doc_type": "Payroll Entry",
"docstatus": 0,
"doctype_or_field": "DocField",
"field_name": "grade",
"field_name": "department",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-08-05 12:36:51.244898",
"modified": "2024-08-26 13:00:33.650134",
"modified_by": "Administrator",
"module": null,
"name": "Payroll Entry-grade-hidden",
"name": "Payroll Entry-department-hidden",
"owner": "Administrator",
"parent": null,
"parentfield": null,
Expand All @@ -360,7 +407,7 @@
"field_name": "designation",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-08-05 12:36:50.839069",
"modified": "2024-08-26 13:00:33.499532",
"modified_by": "Administrator",
"module": null,
"name": "Payroll Entry-designation-hidden",
Expand All @@ -378,18 +425,18 @@
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"creation": "2024-08-13 11:55:57.965212",
"creation": "2024-08-13 11:55:58.104054",
"default_value": null,
"doc_type": "Payroll Entry",
"docstatus": 0,
"doctype_or_field": "DocField",
"field_name": "department",
"field_name": "grade",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-08-05 12:36:50.547681",
"modified": "2024-08-26 13:00:33.270135",
"modified_by": "Administrator",
"module": null,
"name": "Payroll Entry-department-hidden",
"name": "Payroll Entry-grade-hidden",
"owner": "Administrator",
"parent": null,
"parentfield": null,
Expand All @@ -404,26 +451,26 @@
"_comments": null,
"_liked_by": null,
"_user_tags": null,
"creation": "2024-08-13 11:55:57.918303",
"creation": "2024-08-13 11:56:12.018201",
"default_value": null,
"doc_type": "Payroll Entry",
"docstatus": 0,
"doctype_or_field": "DocField",
"field_name": "branch",
"field_name": "payroll_frequency",
"idx": 0,
"is_system_generated": 0,
"modified": "2024-08-05 12:36:49.870901",
"modified": "2024-08-26 13:00:32.987214",
"modified_by": "Administrator",
"module": null,
"name": "Payroll Entry-branch-hidden",
"module": "One Fm",
"name": "Payroll Entry-payroll_frequency-options",
"owner": "Administrator",
"parent": null,
"parentfield": null,
"parenttype": null,
"property": "hidden",
"property_type": "Check",
"property": "options",
"property_type": "select",
"row_name": null,
"value": "1"
"value": "\nMonthly"
}
],
"sync_on_migrate": 1
Expand Down
Loading

0 comments on commit 7dc2126

Please sign in to comment.