From 68728db9b17878738e45580e9d43ae846d414fbb Mon Sep 17 00:00:00 2001 From: krantheman Date: Mon, 29 Apr 2024 11:49:26 +0530 Subject: [PATCH 01/20] fix(Employee Advance): selection of currency (cherry picked from commit d63ce0872b99b6d106434f397c19fa791042d66b) # Conflicts: # hrms/hr/doctype/employee_advance/employee_advance.js --- .../doctype/employee_advance/employee_advance.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hrms/hr/doctype/employee_advance/employee_advance.js b/hrms/hr/doctype/employee_advance/employee_advance.js index b3db16b363..80e6857fc0 100644 --- a/hrms/hr/doctype/employee_advance/employee_advance.js +++ b/hrms/hr/doctype/employee_advance/employee_advance.js @@ -154,6 +154,7 @@ frappe.ui.form.on('Employee Advance', { if (frm.doc.employee) frm.trigger('get_employee_currency') }, +<<<<<<< HEAD get_employee_currency: function(frm) { frappe.call({ method: "hrms.payroll.doctype.salary_structure_assignment.salary_structure_assignment.get_employee_currency", @@ -167,6 +168,19 @@ frappe.ui.form.on('Employee Advance', { } } }); +======= + get_employee_currency: function (frm) { + frappe.db.get_value( + "Salary Structure Assignment", + { employee: frm.doc.employee, docstatus: 1 }, + "currency", + (r) => { + if (r.currency) frm.set_value("currency", r.currency); + else frm.set_value("currency", erpnext.get_currency(frm.doc.company)); + frm.refresh_fields(); + }, + ); +>>>>>>> d63ce0872 (fix(Employee Advance): selection of currency) }, currency: function(frm) { From cccda2e14368c00084b7d7c1d7b8c484446ed963 Mon Sep 17 00:00:00 2001 From: krantheman Date: Mon, 29 Apr 2024 13:19:53 +0530 Subject: [PATCH 02/20] fix: merge conflicts --- .../doctype/employee_advance/employee_advance.js | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/hrms/hr/doctype/employee_advance/employee_advance.js b/hrms/hr/doctype/employee_advance/employee_advance.js index 80e6857fc0..87cb869665 100644 --- a/hrms/hr/doctype/employee_advance/employee_advance.js +++ b/hrms/hr/doctype/employee_advance/employee_advance.js @@ -154,21 +154,6 @@ frappe.ui.form.on('Employee Advance', { if (frm.doc.employee) frm.trigger('get_employee_currency') }, -<<<<<<< HEAD - get_employee_currency: function(frm) { - frappe.call({ - method: "hrms.payroll.doctype.salary_structure_assignment.salary_structure_assignment.get_employee_currency", - args: { - employee: frm.doc.employee, - }, - callback: function(r) { - if (r.message) { - frm.set_value('currency', r.message); - frm.refresh_fields(); - } - } - }); -======= get_employee_currency: function (frm) { frappe.db.get_value( "Salary Structure Assignment", @@ -180,7 +165,6 @@ frappe.ui.form.on('Employee Advance', { frm.refresh_fields(); }, ); ->>>>>>> d63ce0872 (fix(Employee Advance): selection of currency) }, currency: function(frm) { From af1b2ba407dfece574c14c652adc2395f31e95a3 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 11:34:33 +0530 Subject: [PATCH 03/20] fix(Employee Attendance Tool): 'On Leave' status showing as undefined in marked attendance summary (backport #1712) (#1732) (cherry picked from commit 7f60fda61a4c35eabd44e3ffdeeba52a86e5dd20) Co-authored-by: Parameshwari Palanisamy <101092028+creative-paramu@users.noreply.github.com> --- .../employee_attendance_tool/employee_attendance_tool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.js b/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.js index de927a80b3..7002ed2425 100644 --- a/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.js +++ b/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.js @@ -161,7 +161,7 @@ frappe.ui.form.on("Employee Attendance Tool", { return `${__(value)}`; else if (value == "Half Day") return `${__(value)}`; - else if (value == "Leave") + else if (value == "On Leave") return `${__(value)}`; } }, From cba98241971040dbb2b8775064fd1a7217fc7096 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 11:41:18 +0530 Subject: [PATCH 04/20] fix(Leave Application): half day date picker rendering (backport #1643) (#1730) * fix(Leave Application): half day date picker rendering (#1643) (cherry picked from commit 0137c2b7870cb4cd5c426dce57b8b26ca7998fda) # Conflicts: # hrms/hr/doctype/leave_application/leave_application.js # hrms/hr/doctype/leave_application/leave_application.json * chore: fix conflicts --------- Co-authored-by: Akash Tom <61287991+krantheman@users.noreply.github.com> Co-authored-by: Rucha Mahabal --- .../leave_application/leave_application.js | 26 ++++++++++--------- .../leave_application/leave_application.json | 4 +-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/hrms/hr/doctype/leave_application/leave_application.js b/hrms/hr/doctype/leave_application/leave_application.js index 3e4c6624a7..bd02891423 100755 --- a/hrms/hr/doctype/leave_application/leave_application.js +++ b/hrms/hr/doctype/leave_application/leave_application.js @@ -145,13 +145,15 @@ frappe.ui.form.on("Leave Application", { frm.trigger("calculate_total_days"); }, - from_date: function(frm) { + from_date: function (frm) { + frm.events.validate_from_to_date(frm, "to_date"); frm.trigger("make_dashboard"); frm.trigger("half_day_datepicker"); frm.trigger("calculate_total_days"); }, - to_date: function(frm) { + to_date: function (frm) { + frm.events.validate_from_to_date(frm, "from_date"); frm.trigger("make_dashboard"); frm.trigger("half_day_datepicker"); frm.trigger("calculate_total_days"); @@ -161,9 +163,17 @@ frappe.ui.form.on("Leave Application", { frm.trigger("calculate_total_days"); }, - half_day_datepicker: function(frm) { + validate_from_to_date: function (frm, null_date) { + const from_date = Date.parse(frm.doc.from_date); + const to_date = Date.parse(frm.doc.to_date); + if (to_date < from_date) frm.set_value(null_date, ""); + }, + + half_day_datepicker: function (frm) { frm.set_value("half_day_date", ""); - let half_day_datepicker = frm.fields_dict.half_day_date.datepicker; + if (!(frm.doc.half_day && frm.doc.from_date && frm.doc.to_date)) return; + + const half_day_datepicker = frm.fields_dict.half_day_date.datepicker; half_day_datepicker.update({ minDate: frappe.datetime.str_to_obj(frm.doc.from_date), maxDate: frappe.datetime.str_to_obj(frm.doc.to_date) @@ -194,14 +204,6 @@ frappe.ui.form.on("Leave Application", { calculate_total_days: function(frm) { if (frm.doc.from_date && frm.doc.to_date && frm.doc.employee && frm.doc.leave_type) { - let from_date = Date.parse(frm.doc.from_date); - let to_date = Date.parse(frm.doc.to_date); - - if (to_date < from_date) { - frappe.msgprint(__("To Date cannot be less than From Date")); - frm.set_value("to_date", ""); - return; - } // server call is done to include holidays in leave days calculations return frappe.call({ method: "hrms.hr.doctype.leave_application.leave_application.get_number_of_leave_days", diff --git a/hrms/hr/doctype/leave_application/leave_application.json b/hrms/hr/doctype/leave_application/leave_application.json index 58480a5892..74010d521e 100644 --- a/hrms/hr/doctype/leave_application/leave_application.json +++ b/hrms/hr/doctype/leave_application/leave_application.json @@ -123,7 +123,7 @@ "label": "Half Day" }, { - "depends_on": "eval:doc.half_day && (doc.from_date != doc.to_date)", + "depends_on": "eval:doc.half_day && doc.from_date && doc.to_date && (doc.from_date != doc.to_date)", "fieldname": "half_day_date", "fieldtype": "Date", "label": "Half Day Date" @@ -255,7 +255,7 @@ "is_submittable": 1, "links": [], "max_attachments": 3, - "modified": "2023-08-01 22:45:57.851854", + "modified": "2024-04-08 13:56:03.818019", "modified_by": "Administrator", "module": "HR", "name": "Leave Application", From fb5294ab1493e089b2b3f61215d5ea25949706c6 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 12:54:03 +0530 Subject: [PATCH 05/20] fix: autofill skills on entering designation in Interview Round (backport #1706) (#1734) * fix: autofill skills on entering designation in Interview Round (#1706) * fix: auto-fill skills on entering designation in Interview Round * fix: move designation field above skillset to convey association --------- Co-authored-by: Rucha Mahabal (cherry picked from commit 64386f112239d66bc8a8a1e04fa6c4c963dffdeb) # Conflicts: # hrms/hr/doctype/interview_round/interview_round.js # hrms/hr/doctype/interview_round/interview_round.json * chore: fix conflicts --------- Co-authored-by: Viny Selopal <52369157+vinyselopal@users.noreply.github.com> Co-authored-by: Rucha Mahabal --- .../doctype/interview_round/interview_round.js | 16 +++++++++++++++- .../doctype/interview_round/interview_round.json | 8 ++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/hrms/hr/doctype/interview_round/interview_round.js b/hrms/hr/doctype/interview_round/interview_round.js index 115dd860b5..b33f322609 100644 --- a/hrms/hr/doctype/interview_round/interview_round.js +++ b/hrms/hr/doctype/interview_round/interview_round.js @@ -9,7 +9,21 @@ frappe.ui.form.on("Interview Round", { }); } }, - create_interview: function(frm) { + designation: function (frm) { + if (frm.doc.designation) { + frappe.db.get_doc("Designation", frm.doc.designation).then((designation) => { + frappe.model.clear_table(frm.doc, "expected_skill_set"); + + designation.skills.forEach((designation_skill) => { + const row = frm.add_child("expected_skill_set"); + row.skill = designation_skill.skill; + }); + + refresh_field("expected_skill_set"); + }); + } + }, + create_interview: function (frm) { frappe.call({ method: "hrms.hr.doctype.interview_round.interview_round.create_interview", args: { diff --git a/hrms/hr/doctype/interview_round/interview_round.json b/hrms/hr/doctype/interview_round/interview_round.json index 9c95185e9c..73f66321dd 100644 --- a/hrms/hr/doctype/interview_round/interview_round.json +++ b/hrms/hr/doctype/interview_round/interview_round.json @@ -11,9 +11,9 @@ "interview_type", "interviewers", "column_break_3", - "designation", "expected_average_rating", "expected_skills_section", + "designation", "expected_skill_set" ], "fields": [ @@ -33,12 +33,12 @@ }, { "fieldname": "expected_skills_section", - "fieldtype": "Section Break", - "label": "Expected Skillset" + "fieldtype": "Section Break" }, { "fieldname": "expected_skill_set", "fieldtype": "Table", + "label": "Expected Skillset", "options": "Expected Skill Set", "reqd": 1 }, @@ -68,7 +68,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2021-09-30 13:01:25.666660", + "modified": "2024-05-01 11:57:32.754037", "modified_by": "Administrator", "module": "HR", "name": "Interview Round", From 12ff8c71bc9bd2475fff41c3e460a2ba2ae6b703 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 12:56:45 +0530 Subject: [PATCH 06/20] feat(Attendance Request): add 'Include Holidays' checkbox (backport #1040) (#1727) * feat(Attendance Request): add 'Include Holidays' checkbox (#1040) In this PR, added a new feature that introduces the 'Include Holidays' checkbox in the attendance request form. This checkbox allows users to bypass the holiday validation when creating attendance records. It enhances the flexibility of the system by enabling manual attendance marking on holidays when required. Additionally, with this feature, employees can apply for compensatory leave if they work on a holiday. https://github.com/frappe/hrms/assets/105106551/9256d331-2476-4a75-8440-ba8cc3c35b23 `no-docs` (cherry picked from commit f1e34133b315a38d17d37eb828fbd34686617a8c) # Conflicts: # hrms/hr/doctype/attendance_request/attendance_request.json * chore: fix conflicts --------- Co-authored-by: Vishnu VS Co-authored-by: Rucha Mahabal --- .../attendance_request.json | 9 +++++- .../attendance_request/attendance_request.py | 4 +-- .../test_attendance_request.py | 31 +++++++++++++------ 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/hrms/hr/doctype/attendance_request/attendance_request.json b/hrms/hr/doctype/attendance_request/attendance_request.json index 4900321664..a548635243 100644 --- a/hrms/hr/doctype/attendance_request/attendance_request.json +++ b/hrms/hr/doctype/attendance_request/attendance_request.json @@ -17,6 +17,7 @@ "to_date", "half_day", "half_day_date", + "include_holidays", "reason_section", "reason", "column_break_4", @@ -117,11 +118,17 @@ "options": "Attendance Request", "print_hide": 1, "read_only": 1 + }, + { + "default": "0", + "fieldname": "include_holidays", + "fieldtype": "Check", + "label": "Include Holidays" } ], "is_submittable": 1, "links": [], - "modified": "2023-05-03 09:31:53.325203", + "modified": "2023-12-20 16:18:31.864719", "modified_by": "Administrator", "module": "HR", "name": "Attendance Request", diff --git a/hrms/hr/doctype/attendance_request/attendance_request.py b/hrms/hr/doctype/attendance_request/attendance_request.py index ffa325cad8..64126779f5 100644 --- a/hrms/hr/doctype/attendance_request/attendance_request.py +++ b/hrms/hr/doctype/attendance_request/attendance_request.py @@ -117,7 +117,7 @@ def create_or_update_attendance(self, date: str): def should_mark_attendance(self, attendance_date: str) -> bool: # Check if attendance_date is a holiday - if is_holiday(self.employee, attendance_date): + if not self.include_holidays and is_holiday(self.employee, attendance_date): frappe.msgprint( _("Attendance not submitted for {0} as it is a Holiday.").format( frappe.bold(format_date(attendance_date)) @@ -173,7 +173,7 @@ def get_attendance_warnings(self) -> list: for day in range(request_days): attendance_date = add_days(self.from_date, day) - if is_holiday(self.employee, attendance_date): + if not self.include_holidays and is_holiday(self.employee, attendance_date): attendance_warnings.append({"date": attendance_date, "reason": "Holiday", "action": "Skip"}) elif self.has_leave_record(attendance_date): attendance_warnings.append({"date": attendance_date, "reason": "On Leave", "action": "Skip"}) diff --git a/hrms/hr/doctype/attendance_request/test_attendance_request.py b/hrms/hr/doctype/attendance_request/test_attendance_request.py index 4c20de32e9..c5dd46ab45 100644 --- a/hrms/hr/doctype/attendance_request/test_attendance_request.py +++ b/hrms/hr/doctype/attendance_request/test_attendance_request.py @@ -12,7 +12,7 @@ make_holiday_list, make_leave_application, ) -from hrms.tests.test_utils import get_first_sunday +from hrms.tests.test_utils import add_date_to_holiday_list, get_first_sunday test_dependencies = ["Employee"] @@ -107,15 +107,7 @@ def test_overwrite_attendance(self): def test_skip_attendance_on_holiday(self): today = getdate() - holiday_list = frappe.get_doc("Holiday List", self.holiday_list) - holiday_list.append( - "holidays", - { - "holiday_date": today, - "description": "Test Holiday", - }, - ) - holiday_list.save() + add_date_to_holiday_list(today, self.holiday_list) attendance_request = create_attendance_request( employee=self.employee.name, reason="On Duty", company="_Test Company" @@ -150,6 +142,25 @@ def test_skip_attendance_on_leave(self): self.assertEqual(records[0].attendance_date, add_days(today, -1)) self.assertEqual(records[0].status, "Present") + def test_include_holidays_check(self): + # Create a holiday on today's date + today = getdate() + add_date_to_holiday_list(today, self.holiday_list) + + # Create an Attendance Request with include_holidays checked + attendance_request = create_attendance_request( + employee=self.employee.name, + reason="On Duty", + company="_Test Company", + include_holidays=1, # Set include_holidays to True + ) + + # Check if the attendance record is created on the holiday + records = self.get_attendance_records(attendance_request.name) + self.assertEqual(len(records), 2) + self.assertEqual(records[0].status, "Present") + self.assertEqual(records[0].attendance_date, today) + def get_attendance_records(self, attendance_request: str) -> list[dict]: return frappe.db.get_all( "Attendance", From 380f7d164089bb724283445ccc5000001429c35b Mon Sep 17 00:00:00 2001 From: krantheman Date: Wed, 24 Apr 2024 12:24:55 +0530 Subject: [PATCH 07/20] ci: use prettier for js formatting and ruff for py formatting/linting (cherry picked from commit 82af9b051cfca029ad8cdaba0173bc5c0a61ba1d) --- .editorconfig | 15 +++++++ .flake8 | 37 ------------------ .github/helper/.flake8_strict | 73 ----------------------------------- .pre-commit-config.yaml | 39 +++++++++++-------- pyproject.toml | 64 +++++++++++++++++++++++------- sider.yml | 3 -- 6 files changed, 86 insertions(+), 145 deletions(-) create mode 100644 .editorconfig delete mode 100644 .flake8 delete mode 100644 .github/helper/.flake8_strict delete mode 100644 sider.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..667a837077 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# Root editor config file +root = true + +# Common settings +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +# js indentation settings +[{*.js,*.vue,*.css,*.scss,*.html}] +indent_style = tab +indent_size = 4 +max_line_length = 99 \ No newline at end of file diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 1828084a49..0000000000 --- a/.flake8 +++ /dev/null @@ -1,37 +0,0 @@ -[flake8] -ignore = - E121, - E126, - E127, - E128, - E203, - E225, - E226, - E231, - E241, - E251, - E261, - E265, - E302, - E303, - E305, - E402, - E501, - E741, - W291, - W292, - W293, - W391, - W503, - W504, - F403, - B007, - B950, - W191, - E124, # closing bracket, irritating while writing QB code - E131, # continuation line unaligned for hanging indent - E123, # closing bracket does not match indentation of opening bracket's line - E101, # ensured by use of black - -max-line-length = 200 -exclude=.github/helper/semgrep_rules \ No newline at end of file diff --git a/.github/helper/.flake8_strict b/.github/helper/.flake8_strict deleted file mode 100644 index 64539b29bb..0000000000 --- a/.github/helper/.flake8_strict +++ /dev/null @@ -1,73 +0,0 @@ -[flake8] -ignore = - B007, - B009, - B010, - B950, - E101, - E111, - E114, - E116, - E117, - E121, - E122, - E123, - E124, - E125, - E126, - E127, - E128, - E131, - E201, - E202, - E203, - E211, - E221, - E222, - E223, - E224, - E225, - E226, - E228, - E231, - E241, - E242, - E251, - E261, - E262, - E265, - E266, - E271, - E272, - E273, - E274, - E301, - E302, - E303, - E305, - E306, - E402, - E501, - E502, - E701, - E702, - E703, - E741, - F403, - W191, - W291, - W292, - W293, - W391, - W503, - W504, - E711, - E129, - F841, - E713, - E712, - B023 - - -max-line-length = 200 -exclude=.github/helper/semgrep_rules,test_*.py \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b05119772a..976fdd96e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,27 +16,32 @@ repos: - id: check-merge-conflict - id: check-ast - - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.1.0 hooks: - - id: flake8 - additional_dependencies: [ - 'flake8-bugbear', - ] - args: ['--config', '.github/helper/.flake8_strict'] - exclude: ".*setup.py$" + - id: prettier + types_or: [javascript, vue, css, scss] + # Ignore fronetend folder and any files that might contain jinja / bundles + exclude: | + (?x)^( + frontend/.*| + hrms/public/dist/.*| + .*node_modules.*| + .*boilerplate.*| + hrms/templates/includes/.*| + hrms/hr/doctype/employee_promotion/employee_promotion.js| + hrms/hr/doctype/employee_transfer/employee_transfer.js| + )$ - - repo: https://github.com/adityahase/black - rev: 9cb0a69f4d0030cdf687eddf314468b39ed54119 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.7 hooks: - - id: black - additional_dependencies: ['click==8.0.4'] + - id: ruff + name: "Run ruff linter and apply fixes" + args: ["--fix"] - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - exclude: ".*setup.py$" + - id: ruff-format + name: "Format Python code" ci: autoupdate_schedule: weekly diff --git a/pyproject.toml b/pyproject.toml index 84e452a461..8ca46bc187 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "hrms" authors = [ - { name = "Frappe Technologies Pvt Ltd", email = "developers@frappe.io"} + { name = "Frappe Technologies Pvt Ltd", email = "developers@frappe.io" }, ] description = "Open Source HR & Payroll Software" requires-python = ">=3.10" @@ -12,18 +12,52 @@ dynamic = ["version"] requires = ["flit_core >=3.4,<4"] build-backend = "flit_core.buildapi" -[tool.black] -line-length = 99 +[tool.ruff] +line-length = 110 +target-version = "py310" -[tool.isort] -line_length = 99 -multi_line_output = 3 -include_trailing_comma = true -force_grid_wrap = 0 -use_parentheses = true -ensure_newline_before_comments = true -indent = "\t" -known_frappe = ["frappe"] -known_erpnext = ["erpnext"] -known_hrms = ["hrms"] -sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FRAPPE", "ERPNEXT", "HRMS", "FIRSTPARTY", "LOCALFOLDER"] \ No newline at end of file +[tool.ruff.lint] +select = ["F", "E", "W", "I", "UP", "B", "RUF"] +ignore = [ + "B017", # assertRaises(Exception) - should be more specific + "B018", # useless expression, not assigned to anything + "B023", # function doesn't bind loop variable - will have last iteration's value + "B904", # raise inside except without from + "E101", # indentation contains mixed spaces and tabs + "E402", # module level import not at top of file + "E501", # line too long + "E741", # ambiguous variable name + "F401", # "unused" imports + "F403", # can't detect undefined names from * import + "F405", # can't detect undefined names from * import + "F722", # syntax error in forward type annotation + "W191", # indentation contains tabs + "RUF001", # string contains ambiguous unicode character +] +typing-modules = ["frappe.types.DF"] + +[tool.ruff.format] +quote-style = "double" +indent-style = "tab" +docstring-code-format = true + +[tool.ruff.lint.isort.sections] +"frappe" = ["frappe"] +"erpnext" = ["erpnext"] +"hrms" = ["hrms"] + +[tool.ruff.lint.isort] +section-order = [ + "future", + "standard-library", + "third-party", + "frappe", + "erpnext", + "hrms", + "first-party", + "local-folder", +] + +[tool.bench.frappe-dependencies] +frappe = ">=14.0.0,<15.0.0" +erpnext = ">=14.0.0,<15.0.0" diff --git a/sider.yml b/sider.yml deleted file mode 100644 index 2ca6e8deb1..0000000000 --- a/sider.yml +++ /dev/null @@ -1,3 +0,0 @@ -linter: - flake8: - config: .flake8 \ No newline at end of file From 31ec73d8a799efaf7c5023f90cf6df46155f4a94 Mon Sep 17 00:00:00 2001 From: krantheman Date: Wed, 24 Apr 2024 15:11:53 +0530 Subject: [PATCH 08/20] chore: format all JS, CSS, and SCSS files --- commitlint.config.js | 36 +- .../employees_by_age/employees_by_age.js | 4 +- .../hiring_vs_attrition_count.js | 10 +- .../appointment_letter/appointment_letter.js | 29 +- .../appointment_letter_template.js | 3 +- hrms/hr/doctype/appraisal/appraisal.js | 39 +- .../appraisal_cycle/appraisal_cycle.js | 80 +++-- .../appraisal_template/appraisal_template.js | 4 +- hrms/hr/doctype/attendance/attendance.js | 8 +- hrms/hr/doctype/attendance/attendance_list.js | 24 +- .../attendance_request/attendance_request.js | 6 +- .../compensatory_leave_request.js | 23 +- .../daily_work_summary/daily_work_summary.js | 6 +- .../daily_work_summary_group.js | 8 +- .../employee_advance/employee_advance.js | 170 +++++---- .../employee_attendance_tool.css | 10 +- .../employee_attendance_tool.js | 116 +++--- .../employee_checkin/employee_checkin.js | 3 +- .../doctype/employee_grade/employee_grade.js | 43 +-- .../employee_grievance/employee_grievance.js | 48 ++- .../employee_grievance_list.js | 12 +- .../employee_health_insurance.js | 6 +- .../hr/doctype/employee_loan/employee_loan.js | 126 +++---- .../employee_onboarding.js | 130 ++++--- .../employee_onboarding_list.js | 14 +- .../employee_onboarding_template.js | 12 +- .../employee_performance_feedback.js | 21 +- .../employee_referral/employee_referral.js | 54 +-- .../employee_referral_list.js | 2 +- .../employee_separation.js | 58 +-- .../employee_separation_list.js | 14 +- .../employee_separation_template.js | 6 +- .../employee_skill_map/employee_skill_map.js | 14 +- .../doctype/exit_interview/exit_interview.js | 43 ++- .../exit_interview/exit_interview_list.js | 28 +- .../hr/doctype/expense_claim/expense_claim.js | 334 ++++++++++-------- .../expense_claim/expense_claim_list.js | 12 +- .../expense_claim_type/expense_claim_type.js | 24 +- .../full_and_final_asset.js | 3 +- .../full_and_final_statement.js | 58 +-- .../full_and_final_statement_list.js | 12 +- hrms/hr/doctype/goal/goal.js | 72 ++-- hrms/hr/doctype/goal/goal_list.js | 18 +- hrms/hr/doctype/goal/goal_tree.js | 125 ++++--- .../doctype/grievance_type/grievance_type.js | 3 +- hrms/hr/doctype/hr_settings/hr_settings.js | 32 +- .../identification_document_type.js | 6 +- hrms/hr/doctype/interest/interest.js | 6 +- hrms/hr/doctype/interview/interview.js | 232 ++++++------ .../doctype/interview/interview_calendar.js | 19 +- hrms/hr/doctype/interview/interview_list.js | 16 +- .../interview_detail/interview_detail.js | 3 +- .../interview_feedback/interview_feedback.js | 49 ++- .../interview_round/interview_round.js | 10 +- .../doctype/interview_type/interview_type.js | 3 +- .../hr/doctype/job_applicant/job_applicant.js | 82 +++-- .../job_applicant/job_applicant_list.js | 4 +- .../job_applicant_source.js | 6 +- hrms/hr/doctype/job_offer/job_offer.js | 50 +-- hrms/hr/doctype/job_offer/job_offer_list.js | 4 +- hrms/hr/doctype/job_opening/job_opening.js | 47 ++- .../job_requisition/job_requisition.js | 113 +++--- .../job_requisition/job_requisition_list.js | 22 +- hrms/hr/doctype/kra/kra.js | 3 +- .../leave_allocation/leave_allocation.js | 100 +++--- .../leave_allocation/leave_allocation_list.js | 6 +- .../leave_application/leave_application.js | 106 +++--- .../leave_application_calendar.js | 24 +- .../leave_application_list.js | 4 +- .../leave_block_list/leave_block_list.js | 58 +-- .../leave_control_panel.js | 20 +- .../leave_encashment/leave_encashment.js | 56 +-- .../leave_ledger_entry/leave_ledger_entry.js | 3 +- .../leave_ledger_entry_list.js | 19 +- hrms/hr/doctype/leave_period/leave_period.js | 12 +- hrms/hr/doctype/leave_policy/leave_policy.js | 20 +- .../leave_policy_assignment.js | 55 +-- .../leave_policy_assignment_list.js | 202 ++++++----- .../leave_policy_detail.js | 6 +- hrms/hr/doctype/leave_type/leave_type.js | 34 +- hrms/hr/doctype/offer_term/offer_term.js | 6 +- .../purpose_of_travel/purpose_of_travel.js | 6 +- .../shift_assignment/shift_assignment.js | 6 +- .../shift_assignment_calendar.js | 16 +- .../hr/doctype/shift_request/shift_request.js | 10 +- hrms/hr/doctype/shift_type/shift_type.js | 53 ++- hrms/hr/doctype/skill/skill.js | 3 +- .../hr/doctype/staffing_plan/staffing_plan.js | 139 ++++---- .../doctype/training_event/training_event.js | 18 +- .../training_event/training_event_calendar.js | 12 +- .../training_feedback/training_feedback.js | 6 +- .../training_program/training_program.js | 3 +- .../training_result/training_result.js | 26 +- .../doctype/travel_request/travel_request.js | 6 +- .../upload_attendance/upload_attendance.js | 52 +-- hrms/hr/doctype/vehicle_log/vehicle_log.js | 32 +- .../vehicle_service_item.js | 3 +- hrms/hr/employee_property_update.js | 136 ++++--- .../organizational_chart.js | 22 +- hrms/hr/page/team_updates/team_updates.css | 22 +- hrms/hr/page/team_updates/team_updates.js | 73 ++-- .../appraisal_overview/appraisal_overview.js | 46 +-- .../daily_work_summary_replies.js | 26 +- .../employee_advance_summary.js | 50 +-- .../employee_analytics/employee_analytics.js | 28 +- .../employee_birthday/employee_birthday.js | 42 ++- .../report/employee_exits/employee_exits.js | 94 ++--- ...ee_hours_utilization_based_on_timesheet.js | 20 +- .../employee_leave_balance.js | 20 +- .../employee_leave_balance_summary.js | 48 +-- .../employees_working_on_a_holiday.js | 36 +- .../monthly_attendance_sheet.js | 124 ++++--- .../project_profitability.js | 62 ++-- .../recruitment_analytics.js | 26 +- .../unpaid_expense_claim.js | 16 +- .../vehicle_expenses/vehicle_expenses.js | 72 ++-- .../job_application/job_application.js | 4 +- .../additional_salary/additional_salary.js | 56 +-- .../employee_benefit_application.js | 72 ++-- .../employee_benefit_claim.js | 20 +- .../employee_incentive/employee_incentive.js | 44 +-- .../employee_other_income.js | 3 +- .../employee_tax_exemption_category.js | 6 +- .../employee_tax_exemption_declaration.js | 58 +-- ...employee_tax_exemption_proof_submission.js | 62 ++-- .../employee_tax_exemption_sub_category.js | 6 +- hrms/payroll/doctype/gratuity/gratuity.js | 35 +- .../payroll/doctype/gratuity/gratuity_list.js | 18 +- .../doctype/gratuity_rule/gratuity_rule.js | 8 +- .../income_tax_slab/income_tax_slab.js | 6 +- .../doctype/payroll_entry/payroll_entry.js | 227 ++++++------ .../payroll_entry/payroll_entry_list.js | 19 +- .../doctype/payroll_period/payroll_period.js | 6 +- .../payroll_settings/payroll_settings.js | 24 +- .../retention_bonus/retention_bonus.js | 28 +- .../salary_component/salary_component.js | 51 ++- .../doctype/salary_slip/salary_slip.js | 319 +++++++++++------ .../doctype/salary_slip/salary_slip_list.js | 20 +- .../salary_structure_assignment.js | 101 +++--- .../report/bank_remittance/bank_remittance.js | 15 +- .../income_tax_computation.js | 62 ++-- .../income_tax_deductions.js | 2 +- .../professional_tax_deductions.js | 5 +- .../provident_fund_deductions.js | 2 +- .../salary_payments_based_on_payment_mode.js | 5 +- .../salary_payments_via_ecs.js | 13 +- .../report/salary_register/salary_register.js | 80 ++--- hrms/public/js/erpnext/bank_transaction.js | 6 +- hrms/public/js/erpnext/company.js | 40 +-- hrms/public/js/erpnext/delivery_trip.js | 22 +- hrms/public/js/erpnext/department.js | 14 +- hrms/public/js/erpnext/employee.js | 19 +- hrms/public/js/erpnext/journal_entry.js | 36 +- hrms/public/js/erpnext/payment_entry.js | 57 +-- hrms/public/js/erpnext/timesheet.js | 6 +- hrms/public/js/performance.bundle.js | 2 +- .../js/performance/performance_feedback.js | 64 ++-- .../salary_slip_deductions_report_filters.js | 46 +-- hrms/public/js/utils.js | 8 +- hrms/public/scss/performance.scss | 2 +- 160 files changed, 3424 insertions(+), 2938 deletions(-) diff --git a/commitlint.config.js b/commitlint.config.js index d44e5ac626..1971c4d5c1 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,25 +1,25 @@ module.exports = { - parserPreset: 'conventional-changelog-conventionalcommits', + parserPreset: "conventional-changelog-conventionalcommits", rules: { - 'subject-empty': [2, 'never'], - 'type-case': [2, 'always', 'lower-case'], - 'type-empty': [2, 'never'], - 'type-enum': [ + "subject-empty": [2, "never"], + "type-case": [2, "always", "lower-case"], + "type-empty": [2, "never"], + "type-enum": [ 2, - 'always', + "always", [ - 'build', - 'chore', - 'ci', - 'docs', - 'feat', - 'fix', - 'perf', - 'refactor', - 'revert', - 'style', - 'test', - 'patch', + "build", + "chore", + "ci", + "docs", + "feat", + "fix", + "perf", + "refactor", + "revert", + "style", + "test", + "patch", ], ], }, diff --git a/hrms/hr/dashboard_chart_source/employees_by_age/employees_by_age.js b/hrms/hr/dashboard_chart_source/employees_by_age/employees_by_age.js index 35c10f954f..0ef8b3975a 100644 --- a/hrms/hr/dashboard_chart_source/employees_by_age/employees_by_age.js +++ b/hrms/hr/dashboard_chart_source/employees_by_age/employees_by_age.js @@ -8,7 +8,7 @@ frappe.dashboards.chart_sources["Employees by Age"] = { label: __("Company"), fieldtype: "Link", options: "Company", - default: frappe.defaults.get_user_default("Company") + default: frappe.defaults.get_user_default("Company"), }, - ] + ], }; diff --git a/hrms/hr/dashboard_chart_source/hiring_vs_attrition_count/hiring_vs_attrition_count.js b/hrms/hr/dashboard_chart_source/hiring_vs_attrition_count/hiring_vs_attrition_count.js index 114a33c4aa..d8e88bcf08 100644 --- a/hrms/hr/dashboard_chart_source/hiring_vs_attrition_count/hiring_vs_attrition_count.js +++ b/hrms/hr/dashboard_chart_source/hiring_vs_attrition_count/hiring_vs_attrition_count.js @@ -8,7 +8,7 @@ frappe.dashboards.chart_sources["Hiring vs Attrition Count"] = { label: __("Company"), fieldtype: "Link", options: "Company", - default: frappe.defaults.get_user_default("Company") + default: frappe.defaults.get_user_default("Company"), }, { fieldname: "from_date", @@ -21,15 +21,15 @@ frappe.dashboards.chart_sources["Hiring vs Attrition Count"] = { fieldname: "to_date", label: __("To Date"), fieldtype: "Date", - default: frappe.defaults.get_user_default("year_end_date"), + default: frappe.defaults.get_user_default("year_end_date"), }, { fieldname: "time_interval", label: __("Time Interval"), fieldtype: "Select", options: ["Monthly", "Quarterly", "Yearly"], - default: "Monthly", - reqd: 1 + default: "Monthly", + reqd: 1, }, - ] + ], }; diff --git a/hrms/hr/doctype/appointment_letter/appointment_letter.js b/hrms/hr/doctype/appointment_letter/appointment_letter.js index 1642bcca27..a3bd3cfc50 100644 --- a/hrms/hr/doctype/appointment_letter/appointment_letter.js +++ b/hrms/hr/doctype/appointment_letter/appointment_letter.js @@ -1,29 +1,30 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Appointment Letter', { - appointment_letter_template: function(frm){ - if (frm.doc.appointment_letter_template){ +frappe.ui.form.on("Appointment Letter", { + appointment_letter_template: function (frm) { + if (frm.doc.appointment_letter_template) { frappe.call({ - method: 'hrms.hr.doctype.appointment_letter.appointment_letter.get_appointment_letter_details', - args : { - template : frm.doc.appointment_letter_template + method: "hrms.hr.doctype.appointment_letter.appointment_letter.get_appointment_letter_details", + args: { + template: frm.doc.appointment_letter_template, }, - callback: function(r){ - if(r.message){ + callback: function (r) { + if (r.message) { let message_body = r.message; frm.set_value("introduction", message_body[0].introduction); frm.set_value("closing_notes", message_body[0].closing_notes); - frm.doc.terms = [] - for (var i in message_body[1].description){ + frm.doc.terms = []; + for (var i in message_body[1].description) { frm.add_child("terms"); - frm.fields_dict.terms.get_value()[i].title = message_body[1].description[i].title; - frm.fields_dict.terms.get_value()[i].description = message_body[1].description[i].description; + frm.fields_dict.terms.get_value()[i].title = + message_body[1].description[i].title; + frm.fields_dict.terms.get_value()[i].description = + message_body[1].description[i].description; } frm.refresh(); } - } - + }, }); } }, diff --git a/hrms/hr/doctype/appointment_letter_template/appointment_letter_template.js b/hrms/hr/doctype/appointment_letter_template/appointment_letter_template.js index 8270f7aca2..5dc699af13 100644 --- a/hrms/hr/doctype/appointment_letter_template/appointment_letter_template.js +++ b/hrms/hr/doctype/appointment_letter_template/appointment_letter_template.js @@ -1,8 +1,7 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Appointment Letter Template', { +frappe.ui.form.on("Appointment Letter Template", { // refresh: function(frm) { - // } }); diff --git a/hrms/hr/doctype/appraisal/appraisal.js b/hrms/hr/doctype/appraisal/appraisal.js index df802c0a87..e472259686 100644 --- a/hrms/hr/doctype/appraisal/appraisal.js +++ b/hrms/hr/doctype/appraisal/appraisal.js @@ -27,11 +27,19 @@ frappe.ui.form.on("Appraisal", { frappe.run_serially([ () => { if (frm.doc.__islocal && frm.doc.appraisal_cycle) { - frappe.db.get_value("Appraisal Cycle", frm.doc.appraisal_cycle, "kra_evaluation_method", (r) => { - if (r.kra_evaluation_method) { - frm.set_value("rate_goals_manually", cint(r.kra_evaluation_method === "Manual Rating")); - } - }); + frappe.db.get_value( + "Appraisal Cycle", + frm.doc.appraisal_cycle, + "kra_evaluation_method", + (r) => { + if (r.kra_evaluation_method) { + frm.set_value( + "rate_goals_manually", + cint(r.kra_evaluation_method === "Manual Rating"), + ); + } + }, + ); } }, () => { @@ -39,13 +47,13 @@ frappe.ui.form.on("Appraisal", { method: "set_appraisal_template", doc: frm.doc, }); - } + }, ]); } }, add_custom_buttons(frm) { - frm.add_custom_button(__("View Goals"), function() { + frm.add_custom_button(__("View Goals"), function () { frappe.route_options = { company: frm.doc.company, employee: frm.doc.employee, @@ -90,16 +98,16 @@ frappe.ui.form.on("Appraisal", { name: "Score Obtained", chartType: "bar", values: scores, - } - ] + }, + ], }, title: __("Scores"), height: 250, type: "bar", barOptions: { - spaceRatio: 0.7 + spaceRatio: 0.7, }, - colors: ["blue", "green"] + colors: ["blue", "green"], }); } }, @@ -112,10 +120,9 @@ frappe.ui.form.on("Appraisal", { }); frm.set_value("total_score", total); - } + }, }); - frappe.ui.form.on("Appraisal Goal", { score(frm, cdt, cdn) { let d = frappe.get_doc(cdt, cdn); @@ -140,9 +147,9 @@ frappe.ui.form.on("Appraisal Goal", { set_score_earned(frm, cdt, cdn) { let d = frappe.get_doc(cdt, cdn); - let score_earned = flt(d.score) * flt(d.per_weightage) / 100; + let score_earned = (flt(d.score) * flt(d.per_weightage)) / 100; frappe.model.set_value(cdt, cdn, "score_earned", score_earned); frm.trigger("calculate_total"); - } -}); \ No newline at end of file + }, +}); diff --git a/hrms/hr/doctype/appraisal_cycle/appraisal_cycle.js b/hrms/hr/doctype/appraisal_cycle/appraisal_cycle.js index c3a1368990..b342030618 100644 --- a/hrms/hr/doctype/appraisal_cycle/appraisal_cycle.js +++ b/hrms/hr/doctype/appraisal_cycle/appraisal_cycle.js @@ -6,9 +6,9 @@ frappe.ui.form.on("Appraisal Cycle", { frm.set_query("department", () => { return { filters: { - company: frm.doc.company - } - } + company: frm.doc.company, + }, + }; }); frm.trigger("show_custom_buttons"); @@ -30,14 +30,14 @@ frappe.ui.form.on("Appraisal Cycle", { let appraisals_created = frm.doc.__onload?.appraisals_created; if (frm.doc.status !== "Completed") { - className = appraisals_created ? "btn-default": "btn-primary"; + className = appraisals_created ? "btn-default" : "btn-primary"; frm.add_custom_button(__("Create Appraisals"), () => { frm.trigger("create_appraisals"); }).addClass(className); } - className = appraisals_created ? "btn-primary": "btn-default"; + className = appraisals_created ? "btn-primary" : "btn-default"; if (frm.doc.status === "Not Started") { frm.add_custom_button(__("Start"), () => { @@ -62,10 +62,10 @@ frappe.ui.form.on("Appraisal Cycle", { doc: frm.doc, freeze: true, freeze_message: __("Fetching Employees"), - callback: function() { + callback: function () { refresh_field("appraisees"); frm.dirty(); - } + }, }); }, @@ -82,39 +82,51 @@ frappe.ui.form.on("Appraisal Cycle", { }, complete_cycle(frm) { - let msg = __("This action will prevent making changes to the linked appraisal feedback/goals."); + let msg = __( + "This action will prevent making changes to the linked appraisal feedback/goals.", + ); msg += "
"; msg += __("Are you sure you want to proceed?"); - frappe.confirm( - msg, - () => { - frm.call({ - method: "complete_cycle", - doc: frm.doc, - freeze: true, - }).then((r) => { - if (!r.exc) { - frm.reload_doc(); - } - }); - } - ); + frappe.confirm(msg, () => { + frm.call({ + method: "complete_cycle", + doc: frm.doc, + freeze: true, + }).then((r) => { + if (!r.exc) { + frm.reload_doc(); + } + }); + }); }, show_appraisal_summary(frm) { if (frm.doc.__islocal) return; - frappe.call( - "hrms.hr.doctype.appraisal_cycle.appraisal_cycle.get_appraisal_cycle_summary", - {cycle_name: frm.doc.name} - ).then(r => { - if (r.message) { - frm.dashboard.add_indicator(__("Appraisees: {0}", [r.message.appraisees]), "blue"); - frm.dashboard.add_indicator(__("Self Appraisal Pending: {0}", [r.message.self_appraisal_pending]), "orange"); - frm.dashboard.add_indicator(__("Employees without Feedback: {0}", [r.message.feedback_missing]), "orange"); - frm.dashboard.add_indicator(__("Employees without Goals: {0}", [r.message.goals_missing]), "orange"); - } - }); - } + frappe + .call("hrms.hr.doctype.appraisal_cycle.appraisal_cycle.get_appraisal_cycle_summary", { + cycle_name: frm.doc.name, + }) + .then((r) => { + if (r.message) { + frm.dashboard.add_indicator( + __("Appraisees: {0}", [r.message.appraisees]), + "blue", + ); + frm.dashboard.add_indicator( + __("Self Appraisal Pending: {0}", [r.message.self_appraisal_pending]), + "orange", + ); + frm.dashboard.add_indicator( + __("Employees without Feedback: {0}", [r.message.feedback_missing]), + "orange", + ); + frm.dashboard.add_indicator( + __("Employees without Goals: {0}", [r.message.goals_missing]), + "orange", + ); + } + }); + }, }); diff --git a/hrms/hr/doctype/appraisal_template/appraisal_template.js b/hrms/hr/doctype/appraisal_template/appraisal_template.js index 162f97e78f..35f0a50eb8 100644 --- a/hrms/hr/doctype/appraisal_template/appraisal_template.js +++ b/hrms/hr/doctype/appraisal_template/appraisal_template.js @@ -4,8 +4,8 @@ frappe.ui.form.on("Appraisal Template", { setup(frm) { frm.get_field("rating_criteria").grid.editable_fields = [ - {fieldname: "criteria", columns: 6}, - {fieldname: "per_weightage", columns: 5}, + { fieldname: "criteria", columns: 6 }, + { fieldname: "per_weightage", columns: 5 }, ]; }, }); diff --git a/hrms/hr/doctype/attendance/attendance.js b/hrms/hr/doctype/attendance/attendance.js index 057789c903..413ab523be 100644 --- a/hrms/hr/doctype/attendance/attendance.js +++ b/hrms/hr/doctype/attendance/attendance.js @@ -9,8 +9,8 @@ frappe.ui.form.on("Attendance", { frm.set_query("employee", () => { return { - query: "erpnext.controllers.queries.employee_query" - } - }) + query: "erpnext.controllers.queries.employee_query", + }; + }); }, -}) +}); diff --git a/hrms/hr/doctype/attendance/attendance_list.js b/hrms/hr/doctype/attendance/attendance_list.js index fbbb93763b..2dc2cda6d2 100644 --- a/hrms/hr/doctype/attendance/attendance_list.js +++ b/hrms/hr/doctype/attendance/attendance_list.js @@ -15,7 +15,7 @@ frappe.listview_settings["Attendance"] = { let me = this; list_view.page.add_inner_button(__("Mark Attendance"), function () { - let first_day_of_month = moment().startOf('month'); + let first_day_of_month = moment().startOf("month"); if (moment().toDate().getDate() === 1) { first_day_of_month = first_day_of_month.subtract(1, "month"); @@ -59,7 +59,7 @@ frappe.listview_settings["Attendance"] = { fieldtype: "Date", fieldname: "to_date", reqd: 1, - default: moment().subtract(1, 'days').toDate(), + default: moment().subtract(1, "days").toDate(), onchange: () => me.get_unmarked_days(dialog), }, { @@ -94,8 +94,8 @@ frappe.listview_settings["Attendance"] = { frappe.msgprint( __( "Attendance from {0} to {1} has already been marked for the Employee {2}", - [data.from_date, data.to_date, data.employee] - ) + [data.from_date, data.to_date, data.employee], + ), ); } else { frappe.confirm( @@ -119,7 +119,7 @@ frappe.listview_settings["Attendance"] = { } }, }); - } + }, ); } dialog.hide(); @@ -134,11 +134,7 @@ frappe.listview_settings["Attendance"] = { reset_dialog: function (dialog) { let fields = dialog.fields_dict; - dialog.set_df_property( - "time_period_section", - "hidden", - fields.employee.value ? 0 : 1 - ); + dialog.set_df_property("time_period_section", "hidden", fields.employee.value ? 0 : 1); dialog.set_df_property("days_section", "hidden", 1); dialog.set_df_property("unmarked_days", "options", []); @@ -146,10 +142,10 @@ frappe.listview_settings["Attendance"] = { fields.exclude_holidays.value = false; fields.to_date.datepicker.update({ - maxDate: moment().subtract(1, 'days').toDate() - }); + maxDate: moment().subtract(1, "days").toDate(), + }); - this.get_unmarked_days(dialog) + this.get_unmarked_days(dialog); }, get_unmarked_days: function (dialog) { @@ -187,7 +183,7 @@ frappe.listview_settings["Attendance"] = { dialog.set_df_property( "unmarked_days", "options", - options.length > 0 ? options : [] + options.length > 0 ? options : [], ); dialog.no_unmarked_days_left = options.length === 0; }); diff --git a/hrms/hr/doctype/attendance_request/attendance_request.js b/hrms/hr/doctype/attendance_request/attendance_request.js index 0247fa563b..be67112f9d 100644 --- a/hrms/hr/doctype/attendance_request/attendance_request.js +++ b/hrms/hr/doctype/attendance_request/attendance_request.js @@ -16,11 +16,11 @@ frappe.ui.form.on("Attendance Request", { frappe.render_template("attendance_warnings", { warnings: r.message || [], }), - __("Attendance Warnings") + __("Attendance Warnings"), ); frm.dashboard.show(); } - }) + }); } - } + }, }); diff --git a/hrms/hr/doctype/compensatory_leave_request/compensatory_leave_request.js b/hrms/hr/doctype/compensatory_leave_request/compensatory_leave_request.js index 1baa1e04e3..7a3e355fae 100644 --- a/hrms/hr/doctype/compensatory_leave_request/compensatory_leave_request.js +++ b/hrms/hr/doctype/compensatory_leave_request/compensatory_leave_request.js @@ -1,22 +1,21 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Compensatory Leave Request', { - refresh: function(frm) { - frm.set_query("leave_type", function() { +frappe.ui.form.on("Compensatory Leave Request", { + refresh: function (frm) { + frm.set_query("leave_type", function () { return { filters: { - "is_compensatory": true - } + is_compensatory: true, + }, }; }); }, - half_day: function(frm) { - if(frm.doc.half_day == 1){ - frm.set_df_property('half_day_date', 'reqd', true); + half_day: function (frm) { + if (frm.doc.half_day == 1) { + frm.set_df_property("half_day_date", "reqd", true); + } else { + frm.set_df_property("half_day_date", "reqd", false); } - else{ - frm.set_df_property('half_day_date', 'reqd', false); - } - } + }, }); diff --git a/hrms/hr/doctype/daily_work_summary/daily_work_summary.js b/hrms/hr/doctype/daily_work_summary/daily_work_summary.js index 82364801ce..b6ecffcae8 100644 --- a/hrms/hr/doctype/daily_work_summary/daily_work_summary.js +++ b/hrms/hr/doctype/daily_work_summary/daily_work_summary.js @@ -1,8 +1,6 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Daily Work Summary', { - refresh: function (frm) { - - } +frappe.ui.form.on("Daily Work Summary", { + refresh: function (frm) {}, }); diff --git a/hrms/hr/doctype/daily_work_summary_group/daily_work_summary_group.js b/hrms/hr/doctype/daily_work_summary_group/daily_work_summary_group.js index 43206d5dcf..a602fd59fa 100644 --- a/hrms/hr/doctype/daily_work_summary_group/daily_work_summary_group.js +++ b/hrms/hr/doctype/daily_work_summary_group/daily_work_summary_group.js @@ -1,12 +1,12 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Daily Work Summary Group', { +frappe.ui.form.on("Daily Work Summary Group", { refresh: function (frm) { if (!frm.is_new()) { - frm.add_custom_button(__('Daily Work Summary'), function () { - frappe.set_route('List', 'Daily Work Summary'); + frm.add_custom_button(__("Daily Work Summary"), function () { + frappe.set_route("List", "Daily Work Summary"); }); } - } + }, }); diff --git a/hrms/hr/doctype/employee_advance/employee_advance.js b/hrms/hr/doctype/employee_advance/employee_advance.js index 87cb869665..e4229230c7 100644 --- a/hrms/hr/doctype/employee_advance/employee_advance.js +++ b/hrms/hr/doctype/employee_advance/employee_advance.js @@ -1,56 +1,61 @@ // Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Advance', { - setup: function(frm) { +frappe.ui.form.on("Employee Advance", { + setup: function (frm) { frm.add_fetch("employee", "company", "company"); frm.add_fetch("company", "default_employee_advance_account", "advance_account"); - frm.set_query("employee", function() { + frm.set_query("employee", function () { return { filters: { - "status": "Active" - } + status: "Active", + }, }; }); - frm.set_query("advance_account", function() { + frm.set_query("advance_account", function () { if (!frm.doc.employee) { frappe.msgprint(__("Please select employee first")); } let company_currency = erpnext.get_currency(frm.doc.company); let currencies = [company_currency]; - if (frm.doc.currency && (frm.doc.currency != company_currency)) { + if (frm.doc.currency && frm.doc.currency != company_currency) { currencies.push(frm.doc.currency); } return { filters: { - "root_type": "Asset", - "is_group": 0, - "company": frm.doc.company, - "account_currency": ["in", currencies], - } + root_type: "Asset", + is_group: 0, + company: frm.doc.company, + account_currency: ["in", currencies], + }, }; }); - frm.set_query('salary_component', function() { + frm.set_query("salary_component", function () { return { filters: { - "type": "Deduction" - } + type: "Deduction", + }, }; }); }, - refresh: function(frm) { - if (frm.doc.docstatus === 1 && - (flt(frm.doc.paid_amount) < flt(frm.doc.advance_amount)) && - frappe.model.can_create("Payment Entry")) { - frm.add_custom_button(__('Payment'), + refresh: function (frm) { + if ( + frm.doc.docstatus === 1 && + flt(frm.doc.paid_amount) < flt(frm.doc.advance_amount) && + frappe.model.can_create("Payment Entry") + ) { + frm.add_custom_button( + __("Payment"), function () { frm.events.make_payment_entry(frm); - }, __('Create')); + }, + __("Create"), + ); } else if ( frm.doc.docstatus === 1 && flt(frm.doc.claimed_amount) < flt(frm.doc.paid_amount) - flt(frm.doc.return_amount) && @@ -61,40 +66,54 @@ frappe.ui.form.on('Employee Advance', { function () { frm.events.make_expense_claim(frm); }, - __('Create') + __("Create"), ); } if ( - frm.doc.docstatus === 1 - && (flt(frm.doc.claimed_amount) < flt(frm.doc.paid_amount) - flt(frm.doc.return_amount)) + frm.doc.docstatus === 1 && + flt(frm.doc.claimed_amount) < flt(frm.doc.paid_amount) - flt(frm.doc.return_amount) ) { - if (frm.doc.repay_unclaimed_amount_from_salary == 0 && frappe.model.can_create("Journal Entry")) { - frm.add_custom_button(__("Return"), function() { - frm.trigger('make_return_entry'); - }, __('Create')); - } else if (frm.doc.repay_unclaimed_amount_from_salary == 1 && frappe.model.can_create("Additional Salary")) { - frm.add_custom_button(__("Deduction from Salary"), function() { - frm.events.make_deduction_via_additional_salary(frm); - }, __('Create')); + if ( + frm.doc.repay_unclaimed_amount_from_salary == 0 && + frappe.model.can_create("Journal Entry") + ) { + frm.add_custom_button( + __("Return"), + function () { + frm.trigger("make_return_entry"); + }, + __("Create"), + ); + } else if ( + frm.doc.repay_unclaimed_amount_from_salary == 1 && + frappe.model.can_create("Additional Salary") + ) { + frm.add_custom_button( + __("Deduction from Salary"), + function () { + frm.events.make_deduction_via_additional_salary(frm); + }, + __("Create"), + ); } } }, - make_deduction_via_additional_salary: function(frm) { + make_deduction_via_additional_salary: function (frm) { frappe.call({ method: "hrms.hr.doctype.employee_advance.employee_advance.create_return_through_additional_salary", args: { - doc: frm.doc + doc: frm.doc, }, - callback: function(r) { + callback: function (r) { var doclist = frappe.model.sync(r.message); frappe.set_route("Form", doclist[0].doctype, doclist[0].name); - } + }, }); }, - make_payment_entry: function(frm) { + make_payment_entry: function (frm) { let method = "hrms.overrides.employee_payment_entry.get_payment_entry_for_employee"; if (frm.doc.__onload && frm.doc.__onload.make_payment_via_journal_entry) { method = "hrms.hr.doctype.employee_advance.employee_advance.make_bank_entry"; @@ -102,56 +121,56 @@ frappe.ui.form.on('Employee Advance', { return frappe.call({ method: method, args: { - "dt": frm.doc.doctype, - "dn": frm.doc.name + dt: frm.doc.doctype, + dn: frm.doc.name, }, - callback: function(r) { + callback: function (r) { var doclist = frappe.model.sync(r.message); frappe.set_route("Form", doclist[0].doctype, doclist[0].name); - } + }, }); }, - make_expense_claim: function(frm) { + make_expense_claim: function (frm) { return frappe.call({ method: "hrms.hr.doctype.expense_claim.expense_claim.get_expense_claim", args: { - "employee_name": frm.doc.employee, - "company": frm.doc.company, - "employee_advance_name": frm.doc.name, - "posting_date": frm.doc.posting_date, - "paid_amount": frm.doc.paid_amount, - "claimed_amount": frm.doc.claimed_amount + employee_name: frm.doc.employee, + company: frm.doc.company, + employee_advance_name: frm.doc.name, + posting_date: frm.doc.posting_date, + paid_amount: frm.doc.paid_amount, + claimed_amount: frm.doc.claimed_amount, }, - callback: function(r) { + callback: function (r) { const doclist = frappe.model.sync(r.message); frappe.set_route("Form", doclist[0].doctype, doclist[0].name); - } + }, }); }, - make_return_entry: function(frm) { + make_return_entry: function (frm) { frappe.call({ - method: 'hrms.hr.doctype.employee_advance.employee_advance.make_return_entry', + method: "hrms.hr.doctype.employee_advance.employee_advance.make_return_entry", args: { - 'employee': frm.doc.employee, - 'company': frm.doc.company, - 'employee_advance_name': frm.doc.name, - 'return_amount': flt(frm.doc.paid_amount - frm.doc.claimed_amount), - 'advance_account': frm.doc.advance_account, - 'mode_of_payment': frm.doc.mode_of_payment, - 'currency': frm.doc.currency, - 'exchange_rate': frm.doc.exchange_rate + employee: frm.doc.employee, + company: frm.doc.company, + employee_advance_name: frm.doc.name, + return_amount: flt(frm.doc.paid_amount - frm.doc.claimed_amount), + advance_account: frm.doc.advance_account, + mode_of_payment: frm.doc.mode_of_payment, + currency: frm.doc.currency, + exchange_rate: frm.doc.exchange_rate, }, - callback: function(r) { + callback: function (r) { const doclist = frappe.model.sync(r.message); - frappe.set_route('Form', doclist[0].doctype, doclist[0].name); - } + frappe.set_route("Form", doclist[0].doctype, doclist[0].name); + }, }); }, - employee: function(frm) { - if (frm.doc.employee) frm.trigger('get_employee_currency') + employee: function (frm) { + if (frm.doc.employee) frm.trigger("get_employee_currency"); }, get_employee_currency: function (frm) { @@ -167,7 +186,7 @@ frappe.ui.form.on('Employee Advance', { ); }, - currency: function(frm) { + currency: function (frm) { if (frm.doc.currency) { var from_currency = frm.doc.currency; var company_currency; @@ -180,26 +199,29 @@ frappe.ui.form.on('Employee Advance', { frm.events.set_exchange_rate(frm, from_currency, company_currency); } else { frm.set_value("exchange_rate", 1.0); - frm.set_df_property('exchange_rate', 'hidden', 1); + frm.set_df_property("exchange_rate", "hidden", 1); frm.set_df_property("exchange_rate", "description", ""); } frm.refresh_fields(); } }, - set_exchange_rate: function(frm, from_currency, company_currency) { + set_exchange_rate: function (frm, from_currency, company_currency) { frappe.call({ method: "erpnext.setup.utils.get_exchange_rate", args: { from_currency: from_currency, to_currency: company_currency, }, - callback: function(r) { + callback: function (r) { frm.set_value("exchange_rate", flt(r.message)); - frm.set_df_property('exchange_rate', 'hidden', 0); - frm.set_df_property("exchange_rate", "description", "1 " + frm.doc.currency + - " = [?] " + company_currency); - } + frm.set_df_property("exchange_rate", "hidden", 0); + frm.set_df_property( + "exchange_rate", + "description", + "1 " + frm.doc.currency + " = [?] " + company_currency, + ); + }, }); - } + }, }); diff --git a/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.css b/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.css index c8d6644b2f..a90c396ea3 100644 --- a/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.css +++ b/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.css @@ -1,21 +1,21 @@ -.top-toolbar{ +.top-toolbar { padding-bottom: 30px; margin-left: -17px; } -.bottom-toolbar{ +.bottom-toolbar { margin-left: -17px; margin-top: 20px; } -.btn{ +.btn { margin-right: 5px; } -.marked-employee-label{ +.marked-employee-label { font-weight: normal; } -.checkbox{ +.checkbox { margin-top: -3px; } diff --git a/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.js b/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.js index 7002ed2425..20636a71f9 100644 --- a/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.js +++ b/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.js @@ -1,6 +1,6 @@ frappe.ui.form.on("Employee Attendance Tool", { refresh(frm) { - frm.trigger("reset_attendance_fields") + frm.trigger("reset_attendance_fields"); frm.trigger("load_employees"); frm.trigger("set_primary_action"); }, @@ -37,36 +37,37 @@ frappe.ui.form.on("Employee Attendance Tool", { }, load_employees(frm) { - if (!frm.doc.date) - return; - - frappe.call({ - method: "hrms.hr.doctype.employee_attendance_tool.employee_attendance_tool.get_employees", - args: { - date: frm.doc.date, - department: frm.doc.department, - branch: frm.doc.branch, - company: frm.doc.company - } - }).then((r) => { - frm.employees = r.message["unmarked"]; - - if (r.message["unmarked"].length > 0) { - unhide_field("unmarked_attendance_section"); - unhide_field("attendance_details_section"); - frm.events.show_unmarked_employees(frm, r.message["unmarked"]); - } else { - hide_field("unmarked_attendance_section"); - hide_field("attendance_details_section"); - } + if (!frm.doc.date) return; + + frappe + .call({ + method: "hrms.hr.doctype.employee_attendance_tool.employee_attendance_tool.get_employees", + args: { + date: frm.doc.date, + department: frm.doc.department, + branch: frm.doc.branch, + company: frm.doc.company, + }, + }) + .then((r) => { + frm.employees = r.message["unmarked"]; + + if (r.message["unmarked"].length > 0) { + unhide_field("unmarked_attendance_section"); + unhide_field("attendance_details_section"); + frm.events.show_unmarked_employees(frm, r.message["unmarked"]); + } else { + hide_field("unmarked_attendance_section"); + hide_field("attendance_details_section"); + } - if (r.message["marked"].length > 0) { - unhide_field("marked_attendance_html"); - frm.events.show_marked_employees(frm, r.message["marked"]); - } else { - hide_field("marked_attendance_html"); - } - }); + if (r.message["marked"].length > 0) { + unhide_field("marked_attendance_html"); + frm.events.show_marked_employees(frm, r.message["marked"]); + } else { + hide_field("marked_attendance_html"); + } + }); }, show_unmarked_employees(frm, unmarked_employees) { @@ -163,9 +164,9 @@ frappe.ui.form.on("Employee Attendance Tool", { return `${__(value)}`; else if (value == "On Leave") return `${__(value)}`; - } + }, }, - ] + ]; }, set_primary_action(frm) { @@ -173,9 +174,11 @@ frappe.ui.form.on("Employee Attendance Tool", { frm.page.set_primary_action(__("Mark Attendance"), () => { if (frm.employees.length === 0) { frappe.msgprint({ - message: __("Attendance for all the employees under this criteria has been marked already."), + message: __( + "Attendance for all the employees under this criteria has been marked already.", + ), title: __("Attendance Marked"), - indicator: "green" + indicator: "green", }); return; } @@ -183,14 +186,14 @@ frappe.ui.form.on("Employee Attendance Tool", { if (frm.employees_multicheck.get_checked_options().length === 0) { frappe.throw({ message: __("Please select the employees you want to mark attendance for."), - title: __("Mandatory") + title: __("Mandatory"), }); } if (!frm.doc.status) { frappe.throw({ message: __("Please select the attendance status."), - title: __("Mandatory") + title: __("Mandatory"), }); } @@ -201,23 +204,28 @@ frappe.ui.form.on("Employee Attendance Tool", { mark_attendance(frm) { const marked_employees = frm.employees_multicheck.get_checked_options(); - frappe.call({ - method: "hrms.hr.doctype.employee_attendance_tool.employee_attendance_tool.mark_employee_attendance", - args: { - employee_list: marked_employees, - status: frm.doc.status, - date: frm.doc.date, - late_entry: frm.doc.late_entry, - early_exit: frm.doc.early_exit, - shift: frm.doc.shift, - }, - freeze: true, - freeze_message: __("Marking Attendance") - }).then((r) => { - if (!r.exc) { - frappe.show_alert({ message: __("Attendance marked successfully"), indicator: "green" }); - frm.refresh(); - } - }); + frappe + .call({ + method: "hrms.hr.doctype.employee_attendance_tool.employee_attendance_tool.mark_employee_attendance", + args: { + employee_list: marked_employees, + status: frm.doc.status, + date: frm.doc.date, + late_entry: frm.doc.late_entry, + early_exit: frm.doc.early_exit, + shift: frm.doc.shift, + }, + freeze: true, + freeze_message: __("Marking Attendance"), + }) + .then((r) => { + if (!r.exc) { + frappe.show_alert({ + message: __("Attendance marked successfully"), + indicator: "green", + }); + frm.refresh(); + } + }); }, }); diff --git a/hrms/hr/doctype/employee_checkin/employee_checkin.js b/hrms/hr/doctype/employee_checkin/employee_checkin.js index 30a8812842..648b61d2b7 100644 --- a/hrms/hr/doctype/employee_checkin/employee_checkin.js +++ b/hrms/hr/doctype/employee_checkin/employee_checkin.js @@ -1,8 +1,7 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Checkin', { +frappe.ui.form.on("Employee Checkin", { // setup: (frm) => { - // } }); diff --git a/hrms/hr/doctype/employee_grade/employee_grade.js b/hrms/hr/doctype/employee_grade/employee_grade.js index 6c67f54160..0d34062c68 100644 --- a/hrms/hr/doctype/employee_grade/employee_grade.js +++ b/hrms/hr/doctype/employee_grade/employee_grade.js @@ -1,29 +1,24 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Grade', { - refresh: function (frm) { - - }, - setup: function (frm) { - frm.set_query("default_salary_structure", function () { - return { - "filters": { - "docstatus": 1, - "is_active": "Yes" - } - }; - }); - - frm.set_query("default_leave_policy", function () { - return { - "filters": { - "docstatus": 1 - } - }; - }); - - - } +frappe.ui.form.on("Employee Grade", { + refresh: function (frm) {}, + setup: function (frm) { + frm.set_query("default_salary_structure", function () { + return { + filters: { + docstatus: 1, + is_active: "Yes", + }, + }; + }); + frm.set_query("default_leave_policy", function () { + return { + filters: { + docstatus: 1, + }, + }; + }); + }, }); diff --git a/hrms/hr/doctype/employee_grievance/employee_grievance.js b/hrms/hr/doctype/employee_grievance/employee_grievance.js index 25c5badbc7..77bb34ce8a 100644 --- a/hrms/hr/doctype/employee_grievance/employee_grievance.js +++ b/hrms/hr/doctype/employee_grievance/employee_grievance.js @@ -1,38 +1,52 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Grievance', { - setup: function(frm) { - frm.set_query('grievance_against_party', function() { +frappe.ui.form.on("Employee Grievance", { + setup: function (frm) { + frm.set_query("grievance_against_party", function () { return { filters: { - name: ['in', [ - 'Company', 'Department', 'Employee Group', 'Employee Grade', 'Employee'] - ] - } + name: [ + "in", + ["Company", "Department", "Employee Group", "Employee Grade", "Employee"], + ], + }, }; }); - frm.set_query('associated_document_type', function() { - let ignore_modules = ["Setup", "Core", "Integrations", "Automation", "Website", - "Utilities", "Event Streaming", "Social", "Chat", "Data Migration", "Printing", "Desk", "Custom"]; + frm.set_query("associated_document_type", function () { + let ignore_modules = [ + "Setup", + "Core", + "Integrations", + "Automation", + "Website", + "Utilities", + "Event Streaming", + "Social", + "Chat", + "Data Migration", + "Printing", + "Desk", + "Custom", + ]; return { filters: { istable: 0, issingle: 0, - module: ["Not In", ignore_modules] - } + module: ["Not In", ignore_modules], + }, }; }); }, - grievance_against_party: function(frm) { + grievance_against_party: function (frm) { let filters = {}; - if (frm.doc.grievance_against_party == 'Employee' && frm.doc.raised_by) { - filters.name = ["!=", frm.doc.raised_by]; + if (frm.doc.grievance_against_party == "Employee" && frm.doc.raised_by) { + filters.name = ["!=", frm.doc.raised_by]; } - frm.set_query('grievance_against', function() { + frm.set_query("grievance_against", function () { return { - filters: filters + filters: filters, }; }); }, diff --git a/hrms/hr/doctype/employee_grievance/employee_grievance_list.js b/hrms/hr/doctype/employee_grievance/employee_grievance_list.js index 11672ca4e0..b45ba42ead 100644 --- a/hrms/hr/doctype/employee_grievance/employee_grievance_list.js +++ b/hrms/hr/doctype/employee_grievance/employee_grievance_list.js @@ -1,12 +1,12 @@ frappe.listview_settings["Employee Grievance"] = { has_indicator_for_draft: 1, - get_indicator: function(doc) { + get_indicator: function (doc) { var colors = { - "Open": "red", - "Investigated": "orange", - "Resolved": "green", - "Invalid": "grey" + Open: "red", + Investigated: "orange", + Resolved: "green", + Invalid: "grey", }; return [__(doc.status), colors[doc.status], "status,=," + doc.status]; - } + }, }; diff --git a/hrms/hr/doctype/employee_health_insurance/employee_health_insurance.js b/hrms/hr/doctype/employee_health_insurance/employee_health_insurance.js index 69d46e20d0..74e764ce2d 100644 --- a/hrms/hr/doctype/employee_health_insurance/employee_health_insurance.js +++ b/hrms/hr/doctype/employee_health_insurance/employee_health_insurance.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Health Insurance', { - refresh: function(frm) { - - } +frappe.ui.form.on("Employee Health Insurance", { + refresh: function (frm) {}, }); diff --git a/hrms/hr/doctype/employee_loan/employee_loan.js b/hrms/hr/doctype/employee_loan/employee_loan.js index f1e3dd9ff1..0874c71527 100644 --- a/hrms/hr/doctype/employee_loan/employee_loan.js +++ b/hrms/hr/doctype/employee_loan/employee_loan.js @@ -1,54 +1,57 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Loan', { +frappe.ui.form.on("Employee Loan", { onload: function (frm) { frm.set_query("employee_loan_application", function () { return { - "filters": { - "employee": frm.doc.employee, - "docstatus": 1, - "status": "Approved" - } + filters: { + employee: frm.doc.employee, + docstatus: 1, + status: "Approved", + }, }; }); frm.set_query("interest_income_account", function () { return { - "filters": { - "company": frm.doc.company, - "root_type": "Income", - "is_group": 0 - } + filters: { + company: frm.doc.company, + root_type: "Income", + is_group: 0, + }, }; }); - frm.set_query("employee", function() { + frm.set_query("employee", function () { return { - "filters": { - "company": frm.doc.company, - } + filters: { + company: frm.doc.company, + }, }; }); $.each(["payment_account", "employee_loan_account"], function (i, field) { frm.set_query(field, function () { return { - "filters": { - "company": frm.doc.company, - "root_type": "Asset", - "is_group": 0 - } + filters: { + company: frm.doc.company, + root_type: "Asset", + is_group: 0, + }, }; }); - }) + }); }, refresh: function (frm) { - if (frm.doc.docstatus == 1 && (frm.doc.status == "Sanctioned" || frm.doc.status == "Partially Disbursed")) { - frm.add_custom_button(__('Create Disbursement Entry'), function () { + if ( + frm.doc.docstatus == 1 && + (frm.doc.status == "Sanctioned" || frm.doc.status == "Partially Disbursed") + ) { + frm.add_custom_button(__("Create Disbursement Entry"), function () { frm.trigger("make_jv"); - }) + }); } frm.trigger("toggle_fields"); }, @@ -56,20 +59,19 @@ frappe.ui.form.on('Employee Loan', { make_jv: function (frm) { frappe.call({ args: { - "employee_loan": frm.doc.name, - "company": frm.doc.company, - "employee_loan_account": frm.doc.employee_loan_account, - "employee": frm.doc.employee, - "loan_amount": frm.doc.loan_amount, - "payment_account": frm.doc.payment_account + employee_loan: frm.doc.name, + company: frm.doc.company, + employee_loan_account: frm.doc.employee_loan_account, + employee: frm.doc.employee, + loan_amount: frm.doc.loan_amount, + payment_account: frm.doc.payment_account, }, method: "hrms.hr.doctype.employee_loan.employee_loan.make_jv_entry", callback: function (r) { - if (r.message) - var doc = frappe.model.sync(r.message)[0]; + if (r.message) var doc = frappe.model.sync(r.message)[0]; frappe.set_route("Form", doc.doctype, doc.name); - } - }) + }, + }); }, mode_of_payment: function (frm) { @@ -77,45 +79,51 @@ frappe.ui.form.on('Employee Loan', { frappe.call({ method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.get_bank_cash_account", args: { - "mode_of_payment": frm.doc.mode_of_payment, - "company": frm.doc.company + mode_of_payment: frm.doc.mode_of_payment, + company: frm.doc.company, }, callback: function (r, rt) { if (r.message) { frm.set_value("payment_account", r.message.account); } - } + }, }); } }, employee_loan_application: function (frm) { - if(frm.doc.employee_loan_application){ - return frappe.call({ - method: "hrms.hr.doctype.employee_loan.employee_loan.get_employee_loan_application", - args: { - "employee_loan_application": frm.doc.employee_loan_application - }, - callback: function (r) { - if (!r.exc && r.message) { - frm.set_value("loan_type", r.message.loan_type); - frm.set_value("loan_amount", r.message.loan_amount); - frm.set_value("repayment_method", r.message.repayment_method); - frm.set_value("monthly_repayment_amount", r.message.repayment_amount); - frm.set_value("repayment_periods", r.message.repayment_periods); - frm.set_value("rate_of_interest", r.message.rate_of_interest); - } - } - }); - } + if (frm.doc.employee_loan_application) { + return frappe.call({ + method: "hrms.hr.doctype.employee_loan.employee_loan.get_employee_loan_application", + args: { + employee_loan_application: frm.doc.employee_loan_application, + }, + callback: function (r) { + if (!r.exc && r.message) { + frm.set_value("loan_type", r.message.loan_type); + frm.set_value("loan_amount", r.message.loan_amount); + frm.set_value("repayment_method", r.message.repayment_method); + frm.set_value("monthly_repayment_amount", r.message.repayment_amount); + frm.set_value("repayment_periods", r.message.repayment_periods); + frm.set_value("rate_of_interest", r.message.rate_of_interest); + } + }, + }); + } }, repayment_method: function (frm) { - frm.trigger("toggle_fields") + frm.trigger("toggle_fields"); }, toggle_fields: function (frm) { - frm.toggle_enable("monthly_repayment_amount", frm.doc.repayment_method == "Repay Fixed Amount per Period") - frm.toggle_enable("repayment_periods", frm.doc.repayment_method == "Repay Over Number of Periods") - } + frm.toggle_enable( + "monthly_repayment_amount", + frm.doc.repayment_method == "Repay Fixed Amount per Period", + ); + frm.toggle_enable( + "repayment_periods", + frm.doc.repayment_method == "Repay Over Number of Periods", + ); + }, }); diff --git a/hrms/hr/doctype/employee_onboarding/employee_onboarding.js b/hrms/hr/doctype/employee_onboarding/employee_onboarding.js index 3aa2f75715..89d8343ffd 100644 --- a/hrms/hr/doctype/employee_onboarding/employee_onboarding.js +++ b/hrms/hr/doctype/employee_onboarding/employee_onboarding.js @@ -1,101 +1,123 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Onboarding', { - setup: function(frm) { +frappe.ui.form.on("Employee Onboarding", { + setup: function (frm) { frm.set_query("job_applicant", function () { return { - filters:{ - "status": "Accepted", - } + filters: { + status: "Accepted", + }, }; }); - frm.set_query('job_offer', function () { + frm.set_query("job_offer", function () { return { filters: { - 'job_applicant': frm.doc.job_applicant, - 'docstatus': 1 - } + job_applicant: frm.doc.job_applicant, + docstatus: 1, + }, }; }); }, - refresh: function(frm) { + refresh: function (frm) { if (frm.doc.employee) { - frm.add_custom_button(__('Employee'), function() { - frappe.set_route("Form", "Employee", frm.doc.employee); - },__("View")); + frm.add_custom_button( + __("Employee"), + function () { + frappe.set_route("Form", "Employee", frm.doc.employee); + }, + __("View"), + ); } if (frm.doc.project) { - frm.add_custom_button(__('Project'), function() { - frappe.set_route("Form", "Project", frm.doc.project); - },__("View")); - frm.add_custom_button(__('Task'), function() { - frappe.set_route('List', 'Task', {project: frm.doc.project}); - },__("View")); + frm.add_custom_button( + __("Project"), + function () { + frappe.set_route("Form", "Project", frm.doc.project); + }, + __("View"), + ); + frm.add_custom_button( + __("Task"), + function () { + frappe.set_route("List", "Task", { project: frm.doc.project }); + }, + __("View"), + ); } - if ((!frm.doc.employee) && (frm.doc.docstatus === 1)) { - frm.add_custom_button(__('Employee'), function () { - frappe.model.open_mapped_doc({ - method: "hrms.hr.doctype.employee_onboarding.employee_onboarding.make_employee", - frm: frm - }); - }, __('Create')); - frm.page.set_inner_btn_group_as_primary(__('Create')); + if (!frm.doc.employee && frm.doc.docstatus === 1) { + frm.add_custom_button( + __("Employee"), + function () { + frappe.model.open_mapped_doc({ + method: "hrms.hr.doctype.employee_onboarding.employee_onboarding.make_employee", + frm: frm, + }); + }, + __("Create"), + ); + frm.page.set_inner_btn_group_as_primary(__("Create")); } - if (frm.doc.docstatus === 1 && (frm.doc.boarding_status === "Pending" || frm.doc.boarding_status === "In Process")) { - frm.add_custom_button(__("Mark as Completed"), function() { + if ( + frm.doc.docstatus === 1 && + (frm.doc.boarding_status === "Pending" || frm.doc.boarding_status === "In Process") + ) { + frm.add_custom_button(__("Mark as Completed"), function () { frm.trigger("mark_as_completed"); }); } }, - employee_onboarding_template: function(frm) { - frm.set_value("activities" ,""); + employee_onboarding_template: function (frm) { + frm.set_value("activities", ""); if (frm.doc.employee_onboarding_template) { frappe.call({ method: "hrms.controllers.employee_boarding_controller.get_onboarding_details", args: { - "parent": frm.doc.employee_onboarding_template, - "parenttype": "Employee Onboarding Template" + parent: frm.doc.employee_onboarding_template, + parenttype: "Employee Onboarding Template", }, - callback: function(r) { + callback: function (r) { if (r.message) { r.message.forEach((d) => { frm.add_child("activities", d); }); refresh_field("activities"); } - } + }, }); } }, - job_applicant: function(frm) { + job_applicant: function (frm) { if (frm.doc.job_applicant) { - frappe.db.get_value('Employee', {'job_applicant': frm.doc.job_applicant}, 'name', (r) => { - if (r.name) { - frm.set_value('employee', r.name); - } else { - frm.set_value('employee', ''); - } - }); + frappe.db.get_value( + "Employee", + { job_applicant: frm.doc.job_applicant }, + "name", + (r) => { + if (r.name) { + frm.set_value("employee", r.name); + } else { + frm.set_value("employee", ""); + } + }, + ); } else { - frm.set_value('employee', ''); + frm.set_value("employee", ""); } }, mark_as_completed(frm) { - frm - .call({ - method: "mark_onboarding_as_completed", - doc: frm.doc, - freeze: true, - freeze_message: __("Completing onboarding"), - }) - .then((r) => { - frm.refresh(); - }); + frm.call({ + method: "mark_onboarding_as_completed", + doc: frm.doc, + freeze: true, + freeze_message: __("Completing onboarding"), + }).then((r) => { + frm.refresh(); + }); }, }); diff --git a/hrms/hr/doctype/employee_onboarding/employee_onboarding_list.js b/hrms/hr/doctype/employee_onboarding/employee_onboarding_list.js index a33619bed4..3330ff5d34 100644 --- a/hrms/hr/doctype/employee_onboarding/employee_onboarding_list.js +++ b/hrms/hr/doctype/employee_onboarding/employee_onboarding_list.js @@ -1,7 +1,11 @@ -frappe.listview_settings['Employee Onboarding'] = { +frappe.listview_settings["Employee Onboarding"] = { add_fields: ["boarding_status", "employee_name", "date_of_joining", "department"], - filters:[["boarding_status","=", "Pending"]], - get_indicator: function(doc) { - return [__(doc.boarding_status), frappe.utils.guess_colour(doc.boarding_status), "status,=," + doc.boarding_status]; - } + filters: [["boarding_status", "=", "Pending"]], + get_indicator: function (doc) { + return [ + __(doc.boarding_status), + frappe.utils.guess_colour(doc.boarding_status), + "status,=," + doc.boarding_status, + ]; + }, }; diff --git a/hrms/hr/doctype/employee_onboarding_template/employee_onboarding_template.js b/hrms/hr/doctype/employee_onboarding_template/employee_onboarding_template.js index 5e1b6e9946..7ac10d6672 100644 --- a/hrms/hr/doctype/employee_onboarding_template/employee_onboarding_template.js +++ b/hrms/hr/doctype/employee_onboarding_template/employee_onboarding_template.js @@ -1,14 +1,14 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Onboarding Template', { - setup: function(frm) { - frm.set_query("department", function() { +frappe.ui.form.on("Employee Onboarding Template", { + setup: function (frm) { + frm.set_query("department", function () { return { filters: { - company: frm.doc.company - } + company: frm.doc.company, + }, }; }); - } + }, }); diff --git a/hrms/hr/doctype/employee_performance_feedback/employee_performance_feedback.js b/hrms/hr/doctype/employee_performance_feedback/employee_performance_feedback.js index 310f4530a6..687835a45e 100644 --- a/hrms/hr/doctype/employee_performance_feedback/employee_performance_feedback.js +++ b/hrms/hr/doctype/employee_performance_feedback/employee_performance_feedback.js @@ -27,26 +27,27 @@ frappe.ui.form.on("Employee Performance Feedback", { return { filters: { employee: frm.doc.employee, - } - } + }, + }; }); frm.set_query("reviewer", () => { return { filters: { employee: ["!=", frm.doc.employee], - } - } + }, + }; }); }, set_reviewer(frm) { if (!frm.doc.reviewer) { - frappe.db.get_value("Employee", { user_id: frappe.session.user }, "name").then(employee_record => { - const session_employee = employee_record?.message?.name; - if (session_employee) - frm.set_value("reviewer", session_employee); - }); + frappe.db + .get_value("Employee", { user_id: frappe.session.user }, "name") + .then((employee_record) => { + const session_employee = employee_record?.message?.name; + if (session_employee) frm.set_value("reviewer", session_employee); + }); } - } + }, }); diff --git a/hrms/hr/doctype/employee_referral/employee_referral.js b/hrms/hr/doctype/employee_referral/employee_referral.js index 9f822d098c..bcf312d2e6 100644 --- a/hrms/hr/doctype/employee_referral/employee_referral.js +++ b/hrms/hr/doctype/employee_referral/employee_referral.js @@ -2,65 +2,65 @@ // For license information, please see license.txt frappe.ui.form.on("Employee Referral", { - refresh: function(frm) { + refresh: function (frm) { if (frm.doc.docstatus === 1 && frm.doc.status === "Pending") { - frm.add_custom_button(__("Reject Employee Referral"), function() { + frm.add_custom_button(__("Reject Employee Referral"), function () { frappe.confirm( __("Are you sure you want to reject the Employee Referral?"), - function() { + function () { frm.doc.status = "Rejected"; frm.dirty(); frm.save_or_update(); }, - function() { + function () { window.close(); - } + }, ); }); - frm.add_custom_button(__("Create Job Applicant"), function() { + frm.add_custom_button(__("Create Job Applicant"), function () { frm.events.create_job_applicant(frm); }).addClass("btn-primary"); } // To check whether Payment is done or not if (frm.doc.docstatus === 1 && frm.doc.status === "Accepted") { - frappe.db.get_list("Additional Salary", { - filters: { - ref_docname: cur_frm.doc.name, - docstatus: 1 - }, - fields: ["count(name) as additional_salary_count"] - }).then((data) => { - - let additional_salary_count = data[0].additional_salary_count; + frappe.db + .get_list("Additional Salary", { + filters: { + ref_docname: cur_frm.doc.name, + docstatus: 1, + }, + fields: ["count(name) as additional_salary_count"], + }) + .then((data) => { + let additional_salary_count = data[0].additional_salary_count; - if (frm.doc.is_applicable_for_referral_bonus && !additional_salary_count) { - frm.add_custom_button(__("Create Additional Salary"), function() { - frm.events.create_additional_salary(frm); - }).addClass("btn-primary"); - } - }); + if (frm.doc.is_applicable_for_referral_bonus && !additional_salary_count) { + frm.add_custom_button(__("Create Additional Salary"), function () { + frm.events.create_additional_salary(frm); + }).addClass("btn-primary"); + } + }); } - }, - create_job_applicant: function(frm) { + create_job_applicant: function (frm) { frappe.model.open_mapped_doc({ method: "hrms.hr.doctype.employee_referral.employee_referral.create_job_applicant", - frm: frm + frm: frm, }); }, - create_additional_salary: function(frm) { + create_additional_salary: function (frm) { frappe.call({ method: "hrms.hr.doctype.employee_referral.employee_referral.create_additional_salary", args: { - doc: frm.doc + doc: frm.doc, }, callback: function (r) { var doclist = frappe.model.sync(r.message); frappe.set_route("Form", doclist[0].doctype, doclist[0].name); - } + }, }); }, }); diff --git a/hrms/hr/doctype/employee_referral/employee_referral_list.js b/hrms/hr/doctype/employee_referral/employee_referral_list.js index 38dfc4d4c8..7f782adaf4 100644 --- a/hrms/hr/doctype/employee_referral/employee_referral_list.js +++ b/hrms/hr/doctype/employee_referral/employee_referral_list.js @@ -1,4 +1,4 @@ -frappe.listview_settings['Employee Referral'] = { +frappe.listview_settings["Employee Referral"] = { add_fields: ["status"], get_indicator: function (doc) { if (doc.status == "Pending") { diff --git a/hrms/hr/doctype/employee_separation/employee_separation.js b/hrms/hr/doctype/employee_separation/employee_separation.js index d2829af1a3..e95ee0694e 100644 --- a/hrms/hr/doctype/employee_separation/employee_separation.js +++ b/hrms/hr/doctype/employee_separation/employee_separation.js @@ -1,49 +1,65 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Separation', { - setup: function(frm) { +frappe.ui.form.on("Employee Separation", { + setup: function (frm) { frm.add_fetch("employee_separation_template", "company", "company"); frm.add_fetch("employee_separation_template", "department", "department"); frm.add_fetch("employee_separation_template", "designation", "designation"); frm.add_fetch("employee_separation_template", "employee_grade", "employee_grade"); }, - refresh: function(frm) { + refresh: function (frm) { if (frm.doc.employee) { - frm.add_custom_button(__('Employee'), function() { - frappe.set_route("Form", "Employee", frm.doc.employee); - },__("View")); + frm.add_custom_button( + __("Employee"), + function () { + frappe.set_route("Form", "Employee", frm.doc.employee); + }, + __("View"), + ); } if (frm.doc.project) { - frm.add_custom_button(__('Project'), function() { - frappe.set_route("Form", "Project", frm.doc.project); - },__("View")); - frm.add_custom_button(__('Task'), function() { - frappe.set_route('List', 'Task', {project: frm.doc.project}); - },__("View")); + frm.add_custom_button( + __("Project"), + function () { + frappe.set_route("Form", "Project", frm.doc.project); + }, + __("View"), + ); + frm.add_custom_button( + __("Task"), + function () { + frappe.set_route("List", "Task", { project: frm.doc.project }); + }, + __("View"), + ); } }, - employee_separation_template: function(frm) { - frm.set_value("activities" ,""); + employee_separation_template: function (frm) { + frm.set_value("activities", ""); if (frm.doc.employee_separation_template) { frappe.call({ method: "hrms.controllers.employee_boarding_controller.get_onboarding_details", args: { - "parent": frm.doc.employee_separation_template, - "parenttype": "Employee Separation Template" + parent: frm.doc.employee_separation_template, + parenttype: "Employee Separation Template", }, - callback: function(r) { + callback: function (r) { if (r.message) { - $.each(r.message, function(i, d) { - var row = frappe.model.add_child(frm.doc, "Employee Boarding Activity", "activities"); + $.each(r.message, function (i, d) { + var row = frappe.model.add_child( + frm.doc, + "Employee Boarding Activity", + "activities", + ); $.extend(row, d); }); } refresh_field("activities"); - } + }, }); } - } + }, }); diff --git a/hrms/hr/doctype/employee_separation/employee_separation_list.js b/hrms/hr/doctype/employee_separation/employee_separation_list.js index 76c58f5632..5f489e4e9c 100644 --- a/hrms/hr/doctype/employee_separation/employee_separation_list.js +++ b/hrms/hr/doctype/employee_separation/employee_separation_list.js @@ -1,7 +1,11 @@ -frappe.listview_settings['Employee Separation'] = { +frappe.listview_settings["Employee Separation"] = { add_fields: ["boarding_status", "employee_name", "department"], - filters:[["boarding_status","=", "Pending"]], - get_indicator: function(doc) { - return [__(doc.boarding_status), frappe.utils.guess_colour(doc.boarding_status), "status,=," + doc.boarding_status]; - } + filters: [["boarding_status", "=", "Pending"]], + get_indicator: function (doc) { + return [ + __(doc.boarding_status), + frappe.utils.guess_colour(doc.boarding_status), + "status,=," + doc.boarding_status, + ]; + }, }; diff --git a/hrms/hr/doctype/employee_separation_template/employee_separation_template.js b/hrms/hr/doctype/employee_separation_template/employee_separation_template.js index 172ff9fc5b..3710c4c84f 100644 --- a/hrms/hr/doctype/employee_separation_template/employee_separation_template.js +++ b/hrms/hr/doctype/employee_separation_template/employee_separation_template.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Separation Template', { - refresh: function(frm) { - - } +frappe.ui.form.on("Employee Separation Template", { + refresh: function (frm) {}, }); diff --git a/hrms/hr/doctype/employee_skill_map/employee_skill_map.js b/hrms/hr/doctype/employee_skill_map/employee_skill_map.js index b82b18d43b..9b9d36ff0d 100644 --- a/hrms/hr/doctype/employee_skill_map/employee_skill_map.js +++ b/hrms/hr/doctype/employee_skill_map/employee_skill_map.js @@ -1,21 +1,21 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Skill Map', { +frappe.ui.form.on("Employee Skill Map", { // refresh: function(frm) { // } designation: (frm) => { - frm.set_value('employee_skills', null); + frm.set_value("employee_skills", null); if (frm.doc.designation) { - frappe.db.get_doc('Designation', frm.doc.designation).then((designation) => { - designation.skills.forEach(designation_skill => { - let row = frappe.model.add_child(frm.doc, 'Employee Skill', 'employee_skills'); + frappe.db.get_doc("Designation", frm.doc.designation).then((designation) => { + designation.skills.forEach((designation_skill) => { + let row = frappe.model.add_child(frm.doc, "Employee Skill", "employee_skills"); row.skill = designation_skill.skill; row.proficiency = 1; }); - refresh_field('employee_skills'); + refresh_field("employee_skills"); }); } - } + }, }); diff --git a/hrms/hr/doctype/exit_interview/exit_interview.js b/hrms/hr/doctype/exit_interview/exit_interview.js index c4fefd0164..fefdce9324 100644 --- a/hrms/hr/doctype/exit_interview/exit_interview.js +++ b/hrms/hr/doctype/exit_interview/exit_interview.js @@ -1,38 +1,47 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Exit Interview', { - refresh: function(frm) { - if (!frm.doc.__islocal && !frm.doc.questionnaire_email_sent && frappe.boot.user.can_write.includes('Exit Interview')) { - frm.add_custom_button(__('Send Exit Questionnaire'), function () { - frm.trigger('send_exit_questionnaire'); +frappe.ui.form.on("Exit Interview", { + refresh: function (frm) { + if ( + !frm.doc.__islocal && + !frm.doc.questionnaire_email_sent && + frappe.boot.user.can_write.includes("Exit Interview") + ) { + frm.add_custom_button(__("Send Exit Questionnaire"), function () { + frm.trigger("send_exit_questionnaire"); }); } }, - employee: function(frm) { - frappe.db.get_value('Employee', frm.doc.employee, 'relieving_date', (message) => { + employee: function (frm) { + frappe.db.get_value("Employee", frm.doc.employee, "relieving_date", (message) => { if (!message.relieving_date) { frappe.throw({ - message: __('Please set the relieving date for employee {0}', - ['' + frm.doc.employee + '']), - title: __('Relieving Date Missing') + message: __("Please set the relieving date for employee {0}", [ + '' + + frm.doc.employee + + "", + ]), + title: __("Relieving Date Missing"), }); } }); }, - send_exit_questionnaire: function(frm) { + send_exit_questionnaire: function (frm) { frappe.call({ - method: 'hrms.hr.doctype.exit_interview.exit_interview.send_exit_questionnaire', + method: "hrms.hr.doctype.exit_interview.exit_interview.send_exit_questionnaire", args: { - 'interviews': [frm.doc] + interviews: [frm.doc], }, - callback: function(r) { + callback: function (r) { if (!r.exc) { - frm.refresh_field('questionnaire_email_sent'); + frm.refresh_field("questionnaire_email_sent"); } - } + }, }); - } + }, }); diff --git a/hrms/hr/doctype/exit_interview/exit_interview_list.js b/hrms/hr/doctype/exit_interview/exit_interview_list.js index 32d366875f..936e5d825e 100644 --- a/hrms/hr/doctype/exit_interview/exit_interview_list.js +++ b/hrms/hr/doctype/exit_interview/exit_interview_list.js @@ -1,27 +1,27 @@ -frappe.listview_settings['Exit Interview'] = { +frappe.listview_settings["Exit Interview"] = { has_indicator_for_draft: 1, - get_indicator: function(doc) { + get_indicator: function (doc) { let status_color = { - 'Pending': 'orange', - 'Scheduled': 'yellow', - 'Completed': 'green', - 'Cancelled': 'red', + Pending: "orange", + Scheduled: "yellow", + Completed: "green", + Cancelled: "red", }; - return [__(doc.status), status_color[doc.status], 'status,=,'+doc.status]; + return [__(doc.status), status_color[doc.status], "status,=," + doc.status]; }, - onload: function(listview) { - if (frappe.boot.user.can_write.includes('Exit Interview')) { - listview.page.add_action_item(__('Send Exit Questionnaires'), function() { + onload: function (listview) { + if (frappe.boot.user.can_write.includes("Exit Interview")) { + listview.page.add_action_item(__("Send Exit Questionnaires"), function () { const interviews = listview.get_checked_items(); frappe.call({ - method: 'hrms.hr.doctype.exit_interview.exit_interview.send_exit_questionnaire', + method: "hrms.hr.doctype.exit_interview.exit_interview.send_exit_questionnaire", freeze: true, args: { - 'interviews': interviews - } + interviews: interviews, + }, }); }); } - } + }, }; diff --git a/hrms/hr/doctype/expense_claim/expense_claim.js b/hrms/hr/doctype/expense_claim/expense_claim.js index cde8b40434..29492bb581 100644 --- a/hrms/hr/doctype/expense_claim/expense_claim.js +++ b/hrms/hr/doctype/expense_claim/expense_claim.js @@ -4,11 +4,11 @@ frappe.provide("hrms.hr"); frappe.provide("erpnext.accounts.dimensions"); -frappe.ui.form.on('Expense Claim', { - onload: function(frm) { +frappe.ui.form.on("Expense Claim", { + onload: function (frm) { erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype); }, - company: function(frm) { + company: function (frm) { erpnext.accounts.dimensions.update_dimension(frm, frm.doctype); var expenses = frm.doc.expenses; for (var i = 0; i < expenses.length; i++) { @@ -19,22 +19,22 @@ frappe.ui.form.on('Expense Claim', { frappe.call({ method: "hrms.hr.doctype.expense_claim.expense_claim.get_expense_claim_account_and_cost_center", args: { - "expense_claim_type": expense.expense_type, - "company": frm.doc.company + expense_claim_type: expense.expense_type, + company: frm.doc.company, }, - callback: function(r) { + callback: function (r) { if (r.message) { expense.default_account = r.message.account; expense.cost_center = r.message.cost_center; } - } + }, }); } }, }); -frappe.ui.form.on('Expense Claim Detail', { - expense_type: function(frm, cdt, cdn) { +frappe.ui.form.on("Expense Claim Detail", { + expense_type: function (frm, cdt, cdn) { var d = locals[cdt][cdn]; if (!frm.doc.company) { d.expense_type = ""; @@ -43,39 +43,38 @@ frappe.ui.form.on('Expense Claim Detail', { return; } - if(!d.expense_type) { + if (!d.expense_type) { return; } return frappe.call({ method: "hrms.hr.doctype.expense_claim.expense_claim.get_expense_claim_account_and_cost_center", args: { - "expense_claim_type": d.expense_type, - "company": frm.doc.company + expense_claim_type: d.expense_type, + company: frm.doc.company, }, - callback: function(r) { + callback: function (r) { if (r.message) { d.default_account = r.message.account; d.cost_center = r.message.cost_center; } - } + }, }); - } + }, }); -cur_frm.add_fetch('employee', 'company', 'company'); -cur_frm.add_fetch('employee','employee_name','employee_name'); -cur_frm.add_fetch('expense_type','description','description'); +cur_frm.add_fetch("employee", "company", "company"); +cur_frm.add_fetch("employee", "employee_name", "employee_name"); +cur_frm.add_fetch("expense_type", "description", "description"); -cur_frm.cscript.refresh = function(doc) { +cur_frm.cscript.refresh = function (doc) { cur_frm.cscript.set_help(doc); - if(!doc.__islocal) { - - if (doc.docstatus===1) { + if (!doc.__islocal) { + if (doc.docstatus === 1) { /* eslint-disable */ // no idea how `me` works here var entry_doctype, entry_reference_doctype, entry_reference_name; - if(doc.__onload.make_payment_via_journal_entry){ + if (doc.__onload.make_payment_via_journal_entry) { entry_doctype = "Journal Entry"; entry_reference_doctype = "Journal Entry Account.reference_type"; entry_reference_name = "Journal Entry.reference_name"; @@ -86,181 +85,200 @@ cur_frm.cscript.refresh = function(doc) { } if (cint(doc.total_amount_reimbursed) > 0 && frappe.model.can_read(entry_doctype)) { - cur_frm.add_custom_button(__('Bank Entries'), function() { - frappe.route_options = { - party_type: "Employee", - party: doc.employee, - company: doc.company - }; - frappe.set_route("List", entry_doctype); - }, __("View")); + cur_frm.add_custom_button( + __("Bank Entries"), + function () { + frappe.route_options = { + party_type: "Employee", + party: doc.employee, + company: doc.company, + }; + frappe.set_route("List", entry_doctype); + }, + __("View"), + ); } /* eslint-enable */ } } }; -cur_frm.cscript.set_help = function(doc) { +cur_frm.cscript.set_help = function (doc) { cur_frm.set_intro(""); - if(doc.__islocal && !in_list(frappe.user_roles, "HR User")) { + if (doc.__islocal && !in_list(frappe.user_roles, "HR User")) { cur_frm.set_intro(__("Fill the form and save it")); } }; -cur_frm.cscript.validate = function(doc) { +cur_frm.cscript.validate = function (doc) { cur_frm.cscript.calculate_total(doc); }; -cur_frm.cscript.calculate_total = function(doc){ +cur_frm.cscript.calculate_total = function (doc) { doc.total_claimed_amount = 0; doc.total_sanctioned_amount = 0; - $.each((doc.expenses || []), function(i, d) { + $.each(doc.expenses || [], function (i, d) { doc.total_claimed_amount += d.amount; doc.total_sanctioned_amount += d.sanctioned_amount; }); }; -cur_frm.cscript.calculate_total_amount = function(doc,cdt,cdn){ - cur_frm.cscript.calculate_total(doc,cdt,cdn); +cur_frm.cscript.calculate_total_amount = function (doc, cdt, cdn) { + cur_frm.cscript.calculate_total(doc, cdt, cdn); }; -cur_frm.fields_dict['cost_center'].get_query = function(doc) { +cur_frm.fields_dict["cost_center"].get_query = function (doc) { return { filters: { - "company": doc.company - } - } + company: doc.company, + }, + }; }; erpnext.expense_claim = { - set_title: function(frm) { + set_title: function (frm) { if (!frm.doc.task) { frm.set_value("title", frm.doc.employee_name); + } else { + frm.set_value("title", frm.doc.employee_name + " for " + frm.doc.task); } - else { - frm.set_value("title", frm.doc.employee_name + " for "+ frm.doc.task); - } - } + }, }; frappe.ui.form.on("Expense Claim", { - setup: function(frm) { + setup: function (frm) { frm.add_fetch("company", "cost_center", "cost_center"); frm.add_fetch("company", "default_expense_claim_payable_account", "payable_account"); - frm.set_query("employee_advance", "advances", function() { + frm.set_query("employee_advance", "advances", function () { return { filters: [ - ['docstatus', '=', 1], - ['employee', '=', frm.doc.employee], - ['paid_amount', '>', 0], - ['status', 'not in', ['Claimed', 'Returned', 'Partly Claimed and Returned']] - ] + ["docstatus", "=", 1], + ["employee", "=", frm.doc.employee], + ["paid_amount", ">", 0], + ["status", "not in", ["Claimed", "Returned", "Partly Claimed and Returned"]], + ], }; }); - frm.set_query("expense_approver", function() { + frm.set_query("expense_approver", function () { return { query: "hrms.hr.doctype.department_approver.department_approver.get_approvers", filters: { employee: frm.doc.employee, - doctype: frm.doc.doctype - } + doctype: frm.doc.doctype, + }, }; }); - frm.set_query("account_head", "taxes", function() { + frm.set_query("account_head", "taxes", function () { return { filters: [ - ['company', '=', frm.doc.company], - ['account_type', 'in', ["Tax", "Chargeable", "Income Account", "Expenses Included In Valuation"]] - ] + ["company", "=", frm.doc.company], + [ + "account_type", + "in", + ["Tax", "Chargeable", "Income Account", "Expenses Included In Valuation"], + ], + ], }; }); - frm.set_query("payable_account", function() { + frm.set_query("payable_account", function () { return { filters: { - "report_type": "Balance Sheet", - "account_type": "Payable", - "company": frm.doc.company, - "is_group": 0 - } + report_type: "Balance Sheet", + account_type: "Payable", + company: frm.doc.company, + is_group: 0, + }, }; }); - frm.set_query("task", function() { + frm.set_query("task", function () { return { filters: { - 'project': frm.doc.project - } + project: frm.doc.project, + }, }; }); - frm.set_query("employee", function() { + frm.set_query("employee", function () { return { - query: "erpnext.controllers.queries.employee_query" + query: "erpnext.controllers.queries.employee_query", }; }); }, - onload: function(frm) { + onload: function (frm) { if (frm.doc.docstatus == 0) { return frappe.call({ method: "hrms.hr.doctype.leave_application.leave_application.get_mandatory_approval", args: { doctype: frm.doc.doctype, }, - callback: function(r) { + callback: function (r) { if (!r.exc && r.message) { frm.toggle_reqd("expense_approver", true); } - } + }, }); } }, - refresh: function(frm) { + refresh: function (frm) { frm.trigger("toggle_fields"); - if(frm.doc.docstatus > 0 && frm.doc.approval_status !== "Rejected") { - frm.add_custom_button(__('Accounting Ledger'), function() { - frappe.route_options = { - voucher_no: frm.doc.name, - company: frm.doc.company, - from_date: frm.doc.posting_date, - to_date: moment(frm.doc.modified).format('YYYY-MM-DD'), - group_by: '', - show_cancelled_entries: frm.doc.docstatus === 2 - }; - frappe.set_route("query-report", "General Ledger"); - }, __("View")); + if (frm.doc.docstatus > 0 && frm.doc.approval_status !== "Rejected") { + frm.add_custom_button( + __("Accounting Ledger"), + function () { + frappe.route_options = { + voucher_no: frm.doc.name, + company: frm.doc.company, + from_date: frm.doc.posting_date, + to_date: moment(frm.doc.modified).format("YYYY-MM-DD"), + group_by: "", + show_cancelled_entries: frm.doc.docstatus === 2, + }; + frappe.set_route("query-report", "General Ledger"); + }, + __("View"), + ); } if ( - frm.doc.docstatus === 1 - && frm.doc.status !== "Paid" - && frappe.model.can_create("Payment Entry") + frm.doc.docstatus === 1 && + frm.doc.status !== "Paid" && + frappe.model.can_create("Payment Entry") ) { - frm.add_custom_button(__('Payment'), - function() { frm.events.make_payment_entry(frm); }, __('Create')); + frm.add_custom_button( + __("Payment"), + function () { + frm.events.make_payment_entry(frm); + }, + __("Create"), + ); } }, - calculate_grand_total: function(frm) { - var grand_total = flt(frm.doc.total_sanctioned_amount) + flt(frm.doc.total_taxes_and_charges) - flt(frm.doc.total_advance_amount); + calculate_grand_total: function (frm) { + var grand_total = + flt(frm.doc.total_sanctioned_amount) + + flt(frm.doc.total_taxes_and_charges) - + flt(frm.doc.total_advance_amount); frm.set_value("grand_total", grand_total); frm.refresh_fields(); }, - grand_total: function(frm) { + grand_total: function (frm) { frm.trigger("update_employee_advance_claimed_amount"); }, - update_employee_advance_claimed_amount: function(frm) { + update_employee_advance_claimed_amount: function (frm) { let amount_to_be_allocated = frm.doc.grand_total; - $.each(frm.doc.advances || [], function(i, advance){ - if (amount_to_be_allocated >= advance.unclaimed_amount){ + $.each(frm.doc.advances || [], function (i, advance) { + if (amount_to_be_allocated >= advance.unclaimed_amount) { advance.allocated_amount = frm.doc.advances[i].unclaimed_amount; amount_to_be_allocated -= advance.allocated_amount; } else { @@ -271,85 +289,88 @@ frappe.ui.form.on("Expense Claim", { }); }, - make_payment_entry: function(frm) { + make_payment_entry: function (frm) { let method = "hrms.overrides.employee_payment_entry.get_payment_entry_for_employee"; - if(frm.doc.__onload && frm.doc.__onload.make_payment_via_journal_entry) { + if (frm.doc.__onload && frm.doc.__onload.make_payment_via_journal_entry) { method = "hrms.hr.doctype.expense_claim.expense_claim.make_bank_entry"; } return frappe.call({ method: method, args: { - "dt": frm.doc.doctype, - "dn": frm.doc.name + dt: frm.doc.doctype, + dn: frm.doc.name, }, - callback: function(r) { + callback: function (r) { var doclist = frappe.model.sync(r.message); frappe.set_route("Form", doclist[0].doctype, doclist[0].name); - } + }, }); }, - is_paid: function(frm) { + is_paid: function (frm) { frm.trigger("toggle_fields"); }, - toggle_fields: function(frm) { + toggle_fields: function (frm) { frm.toggle_reqd("mode_of_payment", frm.doc.is_paid); }, - employee_name: function(frm) { + employee_name: function (frm) { erpnext.expense_claim.set_title(frm); }, - task: function(frm) { + task: function (frm) { erpnext.expense_claim.set_title(frm); }, - employee: function(frm) { + employee: function (frm) { frm.events.get_advances(frm); }, - cost_center: function(frm) { + cost_center: function (frm) { frm.events.set_child_cost_center(frm); }, - validate: function(frm) { + validate: function (frm) { frm.events.set_child_cost_center(frm); }, - set_child_cost_center: function(frm){ - (frm.doc.expenses || []).forEach(function(d) { - if (!d.cost_center){ + set_child_cost_center: function (frm) { + (frm.doc.expenses || []).forEach(function (d) { + if (!d.cost_center) { d.cost_center = frm.doc.cost_center; } }); }, - get_taxes: function(frm) { - if(frm.doc.taxes) { + get_taxes: function (frm) { + if (frm.doc.taxes) { frappe.call({ method: "calculate_taxes", doc: frm.doc, callback: () => { refresh_field("taxes"); frm.trigger("update_employee_advance_claimed_amount"); - } + }, }); } }, - get_advances: function(frm) { + get_advances: function (frm) { frappe.model.clear_table(frm.doc, "advances"); if (frm.doc.employee) { return frappe.call({ method: "hrms.hr.doctype.expense_claim.expense_claim.get_advances", args: { - employee: frm.doc.employee + employee: frm.doc.employee, }, - callback: function(r, rt) { - - if(r.message) { - $.each(r.message, function(i, d) { - var row = frappe.model.add_child(frm.doc, "Expense Claim Advance", "advances"); + callback: function (r, rt) { + if (r.message) { + $.each(r.message, function (i, d) { + var row = frappe.model.add_child( + frm.doc, + "Expense Claim Advance", + "advances", + ); row.employee_advance = d.name; row.posting_date = d.posting_date; row.advance_account = d.advance_account; @@ -359,94 +380,95 @@ frappe.ui.form.on("Expense Claim", { }); refresh_field("advances"); } - } + }, }); } - } + }, }); frappe.ui.form.on("Expense Claim Detail", { - amount: function(frm, cdt, cdn) { + amount: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; - frappe.model.set_value(cdt, cdn, 'sanctioned_amount', child.amount); + frappe.model.set_value(cdt, cdn, "sanctioned_amount", child.amount); }, - sanctioned_amount: function(frm, cdt, cdn) { + sanctioned_amount: function (frm, cdt, cdn) { cur_frm.cscript.calculate_total(frm.doc, cdt, cdn); frm.trigger("get_taxes"); frm.trigger("calculate_grand_total"); }, - cost_center: function(frm, cdt, cdn) { + cost_center: function (frm, cdt, cdn) { erpnext.utils.copy_value_in_all_rows(frm.doc, cdt, cdn, "expenses", "cost_center"); - } + }, }); frappe.ui.form.on("Expense Claim Advance", { - employee_advance: function(frm, cdt, cdn) { + employee_advance: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; - if(!frm.doc.employee){ - frappe.msgprint(__('Select an employee to get the employee advance.')); + if (!frm.doc.employee) { + frappe.msgprint(__("Select an employee to get the employee advance.")); frm.doc.advances = []; refresh_field("advances"); - } - else { + } else { return frappe.call({ method: "hrms.hr.doctype.expense_claim.expense_claim.get_advances", args: { employee: frm.doc.employee, - advance_id: child.employee_advance + advance_id: child.employee_advance, }, - callback: function(r, rt) { - if(r.message) { + callback: function (r, rt) { + if (r.message) { child.employee_advance = r.message[0].name; child.posting_date = r.message[0].posting_date; child.advance_account = r.message[0].advance_account; child.advance_paid = r.message[0].paid_amount; - child.unclaimed_amount = flt(r.message[0].paid_amount) - flt(r.message[0].claimed_amount); - child.allocated_amount = flt(r.message[0].paid_amount) - flt(r.message[0].claimed_amount); - frm.trigger('calculate_grand_total'); + child.unclaimed_amount = + flt(r.message[0].paid_amount) - flt(r.message[0].claimed_amount); + child.allocated_amount = + flt(r.message[0].paid_amount) - flt(r.message[0].claimed_amount); + frm.trigger("calculate_grand_total"); refresh_field("advances"); } - } + }, }); } - } + }, }); frappe.ui.form.on("Expense Taxes and Charges", { - account_head: function(frm, cdt, cdn) { + account_head: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; - if(child.account_head && !child.description) { + if (child.account_head && !child.description) { // set description from account head - child.description = child.account_head.split(' - ').slice(0, -1).join(' - '); + child.description = child.account_head.split(" - ").slice(0, -1).join(" - "); refresh_field("taxes"); } }, - calculate_total_tax: function(frm, cdt, cdn) { + calculate_total_tax: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; child.total = flt(frm.doc.total_sanctioned_amount) + flt(child.tax_amount); frm.trigger("calculate_tax_amount", cdt, cdn); }, - calculate_tax_amount: function(frm) { + calculate_tax_amount: function (frm) { frm.doc.total_taxes_and_charges = 0; - (frm.doc.taxes || []).forEach(function(d) { + (frm.doc.taxes || []).forEach(function (d) { frm.doc.total_taxes_and_charges += d.tax_amount; }); frm.trigger("calculate_grand_total"); }, - rate: function(frm, cdt, cdn) { + rate: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; - if(!child.amount) { - child.tax_amount = flt(frm.doc.total_sanctioned_amount) * (flt(child.rate)/100); + if (!child.amount) { + child.tax_amount = flt(frm.doc.total_sanctioned_amount) * (flt(child.rate) / 100); } frm.trigger("calculate_total_tax", cdt, cdn); }, - tax_amount: function(frm, cdt, cdn) { + tax_amount: function (frm, cdt, cdn) { frm.trigger("calculate_total_tax", cdt, cdn); - } + }, }); diff --git a/hrms/hr/doctype/expense_claim/expense_claim_list.js b/hrms/hr/doctype/expense_claim/expense_claim_list.js index 9bafc18562..fb97726818 100644 --- a/hrms/hr/doctype/expense_claim/expense_claim_list.js +++ b/hrms/hr/doctype/expense_claim/expense_claim_list.js @@ -1,12 +1,12 @@ -frappe.listview_settings['Expense Claim'] = { +frappe.listview_settings["Expense Claim"] = { add_fields: ["total_claimed_amount", "docstatus", "company"], - get_indicator: function(doc) { - if(doc.status == "Paid") { + get_indicator: function (doc) { + if (doc.status == "Paid") { return [__("Paid"), "green", "status,=,Paid"]; - }else if(doc.status == "Unpaid") { + } else if (doc.status == "Unpaid") { return [__("Unpaid"), "orange", "status,=,Unpaid"]; - } else if(doc.status == "Rejected") { + } else if (doc.status == "Rejected") { return [__("Rejected"), "grey", "status,=,Rejected"]; } - } + }, }; diff --git a/hrms/hr/doctype/expense_claim_type/expense_claim_type.js b/hrms/hr/doctype/expense_claim_type/expense_claim_type.js index d007e1a6c2..9344908be8 100644 --- a/hrms/hr/doctype/expense_claim_type/expense_claim_type.js +++ b/hrms/hr/doctype/expense_claim_type/expense_claim_type.js @@ -2,16 +2,20 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Expense Claim Type", { - refresh: function(frm) { - frm.fields_dict["accounts"].grid.get_field("default_account").get_query = function(doc, cdt, cdn) { + refresh: function (frm) { + frm.fields_dict["accounts"].grid.get_field("default_account").get_query = function ( + doc, + cdt, + cdn, + ) { var d = locals[cdt][cdn]; return { filters: { - "is_group": 0, - "root_type": frm.doc.deferred_expense_account ? "Asset" : "Expense", - 'company': d.company - } - } - } - } -}) + is_group: 0, + root_type: frm.doc.deferred_expense_account ? "Asset" : "Expense", + company: d.company, + }, + }; + }; + }, +}); diff --git a/hrms/hr/doctype/full_and_final_asset/full_and_final_asset.js b/hrms/hr/doctype/full_and_final_asset/full_and_final_asset.js index 1965b46651..4709b0db8e 100644 --- a/hrms/hr/doctype/full_and_final_asset/full_and_final_asset.js +++ b/hrms/hr/doctype/full_and_final_asset/full_and_final_asset.js @@ -1,8 +1,7 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Full and Final Asset', { +frappe.ui.form.on("Full and Final Asset", { // refresh: function(frm) { - // } }); diff --git a/hrms/hr/doctype/full_and_final_statement/full_and_final_statement.js b/hrms/hr/doctype/full_and_final_statement/full_and_final_statement.js index 76464790bb..4258e1986b 100644 --- a/hrms/hr/doctype/full_and_final_statement/full_and_final_statement.js +++ b/hrms/hr/doctype/full_and_final_statement/full_and_final_statement.js @@ -1,8 +1,8 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Full and Final Statement', { - refresh: function(frm) { +frappe.ui.form.on("Full and Final Statement", { + refresh: function (frm) { frm.events.set_queries(frm, "payables"); frm.events.set_queries(frm, "receivables"); @@ -13,103 +13,103 @@ frappe.ui.form.on('Full and Final Statement', { } }, - set_queries: function(frm, type) { + set_queries: function (frm, type) { frm.set_query("reference_document_type", type, function () { let modules = ["HR", "Payroll", "Loan Management"]; return { filters: { istable: 0, issingle: 0, - module: ["In", modules] - } + module: ["In", modules], + }, }; }); let filters = {}; - frm.set_query('reference_document', type, function(doc, cdt, cdn) { + frm.set_query("reference_document", type, function (doc, cdt, cdn) { let fnf_doc = frappe.get_doc(cdt, cdn); - frappe.model.with_doctype(fnf_doc.reference_document_type, function() { + frappe.model.with_doctype(fnf_doc.reference_document_type, function () { if (frappe.model.is_tree(fnf_doc.reference_document_type)) { - filters['is_group'] = 0; + filters["is_group"] = 0; } - if (frappe.meta.has_field(fnf_doc.reference_document_type, 'company')) { - filters['company'] = frm.doc.company; + if (frappe.meta.has_field(fnf_doc.reference_document_type, "company")) { + filters["company"] = frm.doc.company; } - if (frappe.meta.has_field(fnf_doc.reference_document_type, 'employee')) { - filters['employee'] = frm.doc.employee; + if (frappe.meta.has_field(fnf_doc.reference_document_type, "employee")) { + filters["employee"] = frm.doc.employee; } }); return { - filters: filters + filters: filters, }; }); }, - employee: function(frm) { + employee: function (frm) { frm.events.get_outstanding_statements(frm); }, - get_outstanding_statements: function(frm) { + get_outstanding_statements: function (frm) { if (frm.doc.employee) { frappe.call({ method: "get_outstanding_statements", doc: frm.doc, - callback: function() { + callback: function () { frm.refresh(); - } + }, }); } }, - create_journal_entry: function(frm) { + create_journal_entry: function (frm) { frappe.call({ method: "create_journal_entry", doc: frm.doc, - callback: function(r) { + callback: function (r) { var doclist = frappe.model.sync(r.message); frappe.set_route("Form", doclist[0].doctype, doclist[0].name); - } + }, }); - } + }, }); frappe.ui.form.on("Full and Final Outstanding Statement", { - reference_document: function(frm, cdt, cdn) { + reference_document: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; if (child.reference_document_type && child.reference_document) { frappe.call({ method: "hrms.hr.doctype.full_and_final_statement.full_and_final_statement.get_account_and_amount", args: { ref_doctype: child.reference_document_type, - ref_document: child.reference_document + ref_document: child.reference_document, }, - callback: function(r) { + callback: function (r) { if (r.message) { frappe.model.set_value(cdt, cdn, "account", r.message[0]); frappe.model.set_value(cdt, cdn, "amount", r.message[1]); } - } + }, }); } }, - amount: function(frm) { + amount: function (frm) { var total_payable_amount = 0; var total_receivable_amount = 0; - frm.doc.payables.forEach(element => { + frm.doc.payables.forEach((element) => { total_payable_amount = total_payable_amount + element.amount; }); - frm.doc.receivables.forEach(element => { + frm.doc.receivables.forEach((element) => { total_receivable_amount = total_receivable_amount + element.amount; }); frm.set_value("total_payable_amount", flt(total_payable_amount)); frm.set_value("total_receivable_amount", flt(total_receivable_amount)); - } + }, }); diff --git a/hrms/hr/doctype/full_and_final_statement/full_and_final_statement_list.js b/hrms/hr/doctype/full_and_final_statement/full_and_final_statement_list.js index 4aedec7c89..94a2c18919 100644 --- a/hrms/hr/doctype/full_and_final_statement/full_and_final_statement_list.js +++ b/hrms/hr/doctype/full_and_final_statement/full_and_final_statement_list.js @@ -1,11 +1,11 @@ frappe.listview_settings["Full and Final Statement"] = { - get_indicator: function(doc) { + get_indicator: function (doc) { var colors = { - "Draft": "red", - "Unpaid": "orange", - "Paid": "green", - "Cancelled": "red" + Draft: "red", + Unpaid: "orange", + Paid: "green", + Cancelled: "red", }; return [__(doc.status), colors[doc.status], "status,=," + doc.status]; - } + }, }; diff --git a/hrms/hr/doctype/goal/goal.js b/hrms/hr/doctype/goal/goal.js index 7c193aac30..25d4adf097 100644 --- a/hrms/hr/doctype/goal/goal.js +++ b/hrms/hr/doctype/goal/goal.js @@ -10,7 +10,7 @@ frappe.ui.form.on("Goal", { frm.set_df_property( "progress", "description", - __("Group goal's progress is auto-calculated based on the child goals.") + __("Group goal's progress is auto-calculated based on the child goals."), ); } }, @@ -22,8 +22,8 @@ frappe.ui.form.on("Goal", { is_group: 1, name: ["!=", frm.doc.name], employee: frm.doc.employee, - } - } + }, + }; }); frm.set_query("kra", () => { @@ -32,7 +32,7 @@ frappe.ui.form.on("Goal", { filters: { employee: frm.doc.employee, appraisal_cycle: frm.doc.appraisal_cycle, - } + }, }; }); @@ -41,7 +41,7 @@ frappe.ui.form.on("Goal", { filters: { status: ["!=", "Completed"], company: frm.doc.company, - } + }, }; }); }, @@ -51,31 +51,47 @@ frappe.ui.form.on("Goal", { const doc_status = frm.doc.status; if (doc_status === "Archived") { - frm.add_custom_button(__("Unarchive"), () => { - frm.set_value("status", ""); - frm.save(); - }, __("Status")); + frm.add_custom_button( + __("Unarchive"), + () => { + frm.set_value("status", ""); + frm.save(); + }, + __("Status"), + ); } if (doc_status === "Closed") { - frm.add_custom_button(__("Reopen"), () => { - frm.set_value("status", ""); - frm.save(); - }, __("Status")); + frm.add_custom_button( + __("Reopen"), + () => { + frm.set_value("status", ""); + frm.save(); + }, + __("Status"), + ); } if (doc_status !== "Archived") { - frm.add_custom_button(__("Archive"), () => { - frm.set_value("status", "Archived"); - frm.save(); - }, __("Status")); + frm.add_custom_button( + __("Archive"), + () => { + frm.set_value("status", "Archived"); + frm.save(); + }, + __("Status"), + ); } if (doc_status !== "Closed") { - frm.add_custom_button(__("Close"), () => { - frm.set_value("status", "Closed"); - frm.save(); - }, __("Status")); + frm.add_custom_button( + __("Close"), + () => { + frm.set_value("status", "Closed"); + frm.save(); + }, + __("Status"), + ); } }, @@ -85,7 +101,7 @@ frappe.ui.form.on("Goal", { frappe.msgprint({ message: __("Please select the Appraisal Cycle first."), - title: __("Mandatory") + title: __("Mandatory"), }); return; @@ -93,7 +109,9 @@ frappe.ui.form.on("Goal", { if (frm.doc.__islocal || !frm.doc.is_group) return; - let msg = __("Changing KRA in this parent goal will align all the child goals to the same KRA, if any."); + let msg = __( + "Changing KRA in this parent goal will align all the child goals to the same KRA, if any.", + ); msg += "
"; msg += __("Do you still want to proceed?"); @@ -101,8 +119,10 @@ frappe.ui.form.on("Goal", { msg, () => {}, () => { - frappe.db.get_value("Goal", frm.doc.name, "kra", (r) => frm.set_value("kra", r.kra)); - } + frappe.db.get_value("Goal", frm.doc.name, "kra", (r) => + frm.set_value("kra", r.kra), + ); + }, ); }, @@ -110,5 +130,5 @@ frappe.ui.form.on("Goal", { if (frm.doc.__islocal && frm.doc.is_group) { frm.set_value("progress", 0); } - } + }, }); diff --git a/hrms/hr/doctype/goal/goal_list.js b/hrms/hr/doctype/goal/goal_list.js index 2c1ddfe693..f55e82a2a3 100644 --- a/hrms/hr/doctype/goal/goal_list.js +++ b/hrms/hr/doctype/goal/goal_list.js @@ -1,18 +1,18 @@ frappe.listview_settings["Goal"] = { add_fields: ["end_date", "status"], - get_indicator: function(doc) { + get_indicator: function (doc) { const status_color = { - "Pending": "yellow", + Pending: "yellow", "In Progress": "orange", - "Completed": "green", - "Archived": "gray", - "Closed": "red", + Completed: "green", + Archived: "gray", + Closed: "red", }; return [__(doc.status), status_color[doc.status], "status,=," + doc.status]; }, formatters: { end_date(value, df, doc) { - if (!value) return "" + if (!value) return ""; if (doc.status === "Completed" || doc.status === "Archived") return ""; const d = moment(value); @@ -26,6 +26,6 @@ frappe.listview_settings["Goal"] = { ${d.fromNow()} `; - } - } -} + }, + }, +}; diff --git a/hrms/hr/doctype/goal/goal_tree.js b/hrms/hr/doctype/goal/goal_tree.js index 76c899e77f..f68965031c 100644 --- a/hrms/hr/doctype/goal/goal_tree.js +++ b/hrms/hr/doctype/goal/goal_tree.js @@ -8,7 +8,7 @@ frappe.treeview_settings["Goal"] = { fieldtype: "Select", options: erpnext.utils.get_tree_options("company"), label: __("Company"), - default: erpnext.utils.get_tree_default("company") + default: erpnext.utils.get_tree_default("company"), }, { fieldname: "appraisal_cycle", @@ -16,12 +16,13 @@ frappe.treeview_settings["Goal"] = { options: "Appraisal Cycle", label: __("Appraisal Cycle"), get_query() { - const company = frappe.treeview_settings["Goal"].page.fields_dict.company.get_value(); + const company = + frappe.treeview_settings["Goal"].page.fields_dict.company.get_value(); return { filters: { - company: company - } + company: company, + }, }; }, }, @@ -29,12 +30,12 @@ frappe.treeview_settings["Goal"] = { fieldname: "employee", fieldtype: "Link", options: "Employee", - label: __("Employee") + label: __("Employee"), }, { fieldname: "date_range", fieldtype: "DateRange", - label: __("Date Range") + label: __("Date Range"), }, ], fields: [ @@ -61,10 +62,10 @@ frappe.treeview_settings["Goal"] = { reqd: 1, default() { const treeview = frappe.treeview_settings["Goal"].treeview; - let employee = ( + let employee = treeview.tree.get_selected_node().data.employee || - treeview.tree.session_employee || "" - ); + treeview.tree.session_employee || + ""; return employee; }, @@ -93,7 +94,9 @@ frappe.treeview_settings["Goal"] = { { fieldtype: "Section Break", label: __("Appraisal Linking"), - description: __("Link the cycle and tag KRA to your goal to update the appraisal's goal score based on the goal progress"), + description: __( + "Link the cycle and tag KRA to your goal to update the appraisal's goal score based on the goal progress", + ), depends_on: "eval:doc.employee", }, { @@ -102,21 +105,22 @@ frappe.treeview_settings["Goal"] = { label: __("Appraisal Cycle"), options: "Appraisal Cycle", get_query() { - const company = frappe.treeview_settings["Goal"].page.fields_dict.company.get_value(); + const company = + frappe.treeview_settings["Goal"].page.fields_dict.company.get_value(); return { filters: { company: company, - status: ["!=", "Completed"] - } - } + status: ["!=", "Completed"], + }, + }; }, default() { const treeview = frappe.treeview_settings["Goal"].treeview; - let appraisal_cycle = ( + let appraisal_cycle = treeview.page.fields_dict.appraisal_cycle.get_value() || - treeview.tree.get_selected_node().data.appraisal_cycle || "" - ); + treeview.tree.get_selected_node().data.appraisal_cycle || + ""; return appraisal_cycle; }, @@ -134,15 +138,15 @@ frappe.treeview_settings["Goal"] = { return { query: "hrms.hr.doctype.appraisal.appraisal.get_kras_for_employee", filters: { - "employee": cur_dialog.get_value("employee"), - "appraisal_cycle": cur_dialog.get_value("appraisal_cycle"), - } + employee: cur_dialog.get_value("employee"), + appraisal_cycle: cur_dialog.get_value("appraisal_cycle"), + }, }; }, default() { - const treeview = frappe.treeview_settings["Goal"].treeview - return treeview.tree.get_selected_node().data.kra - } + const treeview = frappe.treeview_settings["Goal"].treeview; + return treeview.tree.get_selected_node().data.kra; + }, }, { fieldtype: "Section Break", @@ -162,9 +166,11 @@ frappe.treeview_settings["Goal"] = { treeview.make_tree(); // set the current session employee - frappe.db.get_value("Employee", { user_id: frappe.session.user }, "name").then(employee_record => { - treeview.tree.session_employee = employee_record?.message?.name; - }); + frappe.db + .get_value("Employee", { user_id: frappe.session.user }, "name") + .then((employee_record) => { + treeview.tree.session_employee = employee_record?.message?.name; + }); }, onrender(node) { // show KRA against the goal @@ -187,15 +193,17 @@ frappe.treeview_settings["Goal"] = { `).insertBefore(node.$ul); } else if (node.data && node.data.status !== undefined) { const status_color = { - "Pending": "yellow", + Pending: "yellow", "In Progress": "orange", - "Completed": "green", - "Archived": "gray", + Completed: "green", + Archived: "gray", }; $(` + style="background-color: var(--bg-${status_color[node.data.status]}); color: var(--text-on-${ + status_color[node.data.status] + }); font-weight:500"> ${node.data.status} `).insertBefore(node.$ul); @@ -212,7 +220,9 @@ frappe.treeview_settings["Goal"] = { }, get_label(node) { if (node.title && node.title !== node.label) { - return __(node.title) + ` (${node.data.employee_name})`; + return ( + __(node.title) + ` (${node.data.employee_name})` + ); } else { return __(node.title || node.label); } @@ -220,10 +230,10 @@ frappe.treeview_settings["Goal"] = { toolbar: [ { label: __("Update Progress"), - condition: function(node) { + condition: function (node) { return !node.root && !node.expandable; }, - click: function(node) { + click: function (node) { const dialog = new frappe.ui.Dialog({ title: __("Update Progress"), fields: [ @@ -234,32 +244,37 @@ frappe.treeview_settings["Goal"] = { default: node.data.progress, }, ], - primary_action: function() { + primary_action: function () { dialog.hide(); - return frappe.call({ - method: "hrms.hr.doctype.goal.goal.update_progress", - args: { - progress: dialog.get_values()["progress"], - goal: node.data.value - }, - }).then(r => { - if (!r.exc && r.message) { - frappe.treeview_settings["Goal"].treeview.tree.load_children(node.parent_node, true); + return frappe + .call({ + method: "hrms.hr.doctype.goal.goal.update_progress", + args: { + progress: dialog.get_values()["progress"], + goal: node.data.value, + }, + }) + .then((r) => { + if (!r.exc && r.message) { + frappe.treeview_settings["Goal"].treeview.tree.load_children( + node.parent_node, + true, + ); - frappe.show_alert({ - message: __("Progress Updated successfully"), - indicator: "green" - }); - } else { - frappe.msgprint(__("Could not update progress")); - } - }); + frappe.show_alert({ + message: __("Progress Updated successfully"), + indicator: "green", + }); + } else { + frappe.msgprint(__("Could not update progress")); + } + }); }, - primary_action_label: __("Update") + primary_action_label: __("Update"), }); dialog.show(); - } - } + }, + }, ], - extend_toolbar: true + extend_toolbar: true, }; diff --git a/hrms/hr/doctype/grievance_type/grievance_type.js b/hrms/hr/doctype/grievance_type/grievance_type.js index 425f2fd5b5..a6015304dd 100644 --- a/hrms/hr/doctype/grievance_type/grievance_type.js +++ b/hrms/hr/doctype/grievance_type/grievance_type.js @@ -1,8 +1,7 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Grievance Type', { +frappe.ui.form.on("Grievance Type", { // refresh: function(frm) { - // } }); diff --git a/hrms/hr/doctype/hr_settings/hr_settings.js b/hrms/hr/doctype/hr_settings/hr_settings.js index ce1374498a..f2bdf26944 100644 --- a/hrms/hr/doctype/hr_settings/hr_settings.js +++ b/hrms/hr/doctype/hr_settings/hr_settings.js @@ -1,7 +1,7 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('HR Settings', { +frappe.ui.form.on("HR Settings", { refresh: function (frm) { frm.set_query("sender", () => { return { @@ -17,23 +17,29 @@ frappe.ui.form.on('HR Settings', { }, }; }); - } + }, }); -frappe.tour['HR Settings'] = [ +frappe.tour["HR Settings"] = [ { - fieldname: 'emp_created_by', - title: 'Employee Naming By', - description: __('Employee can be named by Employee ID if you assign one, or via Naming Series. Select your preference here.'), + fieldname: "emp_created_by", + title: "Employee Naming By", + description: __( + "Employee can be named by Employee ID if you assign one, or via Naming Series. Select your preference here.", + ), }, { - fieldname: 'standard_working_hours', - title: 'Standard Working Hours', - description: __('Enter the Standard Working Hours for a normal work day. These hours will be used in calculations of reports such as Employee Hours Utilization and Project Profitability analysis.'), + fieldname: "standard_working_hours", + title: "Standard Working Hours", + description: __( + "Enter the Standard Working Hours for a normal work day. These hours will be used in calculations of reports such as Employee Hours Utilization and Project Profitability analysis.", + ), }, { - fieldname: 'leave_and_expense_claim_settings', - title: 'Leave and Expense Clain Settings', - description: __('Review various other settings related to Employee Leaves and Expense Claim') - } + fieldname: "leave_and_expense_claim_settings", + title: "Leave and Expense Clain Settings", + description: __( + "Review various other settings related to Employee Leaves and Expense Claim", + ), + }, ]; diff --git a/hrms/hr/doctype/identification_document_type/identification_document_type.js b/hrms/hr/doctype/identification_document_type/identification_document_type.js index 351cf9d9ff..04e38383cf 100644 --- a/hrms/hr/doctype/identification_document_type/identification_document_type.js +++ b/hrms/hr/doctype/identification_document_type/identification_document_type.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Identification Document Type', { - refresh: function(frm) { - - } +frappe.ui.form.on("Identification Document Type", { + refresh: function (frm) {}, }); diff --git a/hrms/hr/doctype/interest/interest.js b/hrms/hr/doctype/interest/interest.js index 70e1b6aaaa..76a5ce6564 100644 --- a/hrms/hr/doctype/interest/interest.js +++ b/hrms/hr/doctype/interest/interest.js @@ -1,8 +1,6 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Interest', { - refresh: function(frm) { - - } +frappe.ui.form.on("Interest", { + refresh: function (frm) {}, }); diff --git a/hrms/hr/doctype/interview/interview.js b/hrms/hr/doctype/interview/interview.js index 1264dfe68c..475c744e37 100644 --- a/hrms/hr/doctype/interview/interview.js +++ b/hrms/hr/doctype/interview/interview.js @@ -1,90 +1,95 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Interview', { +frappe.ui.form.on("Interview", { onload: function (frm) { frm.events.set_job_applicant_query(frm); - frm.set_query('interviewer', 'interview_details', function () { + frm.set_query("interviewer", "interview_details", function () { return { - query: 'hrms.hr.doctype.interview.interview.get_interviewer_list' + query: "hrms.hr.doctype.interview.interview.get_interviewer_list", }; }); }, refresh: function (frm) { if (frm.doc.docstatus != 2 && !frm.doc.__islocal) { - if (frm.doc.status === 'Pending') { - frm.add_custom_button(__('Reschedule Interview'), function() { + if (frm.doc.status === "Pending") { + frm.add_custom_button(__("Reschedule Interview"), function () { frm.events.show_reschedule_dialog(frm); frm.refresh(); }); } let allowed_interviewers = []; - frm.doc.interview_details.forEach(values => { + frm.doc.interview_details.forEach((values) => { allowed_interviewers.push(values.interviewer); }); - if ((allowed_interviewers.includes(frappe.session.user))) { - frappe.db.get_value('Interview Feedback', {'interviewer': frappe.session.user, 'interview': frm.doc.name, 'docstatus': 1}, 'name', (r) => { - if (Object.keys(r).length === 0) { - frm.add_custom_button(__('Submit Feedback'), function () { - frappe.call({ - method: 'hrms.hr.doctype.interview.interview.get_expected_skill_set', - args: { - interview_round: frm.doc.interview_round - }, - callback: function (r) { - frm.events.show_feedback_dialog(frm, r.message); - frm.refresh(); - } - }); - }).addClass('btn-primary'); - } - }); + if (allowed_interviewers.includes(frappe.session.user)) { + frappe.db.get_value( + "Interview Feedback", + { interviewer: frappe.session.user, interview: frm.doc.name, docstatus: 1 }, + "name", + (r) => { + if (Object.keys(r).length === 0) { + frm.add_custom_button(__("Submit Feedback"), function () { + frappe.call({ + method: "hrms.hr.doctype.interview.interview.get_expected_skill_set", + args: { + interview_round: frm.doc.interview_round, + }, + callback: function (r) { + frm.events.show_feedback_dialog(frm, r.message); + frm.refresh(); + }, + }); + }).addClass("btn-primary"); + } + }, + ); } } }, show_reschedule_dialog: function (frm) { let d = new frappe.ui.Dialog({ - title: 'Reschedule Interview', + title: "Reschedule Interview", fields: [ { - label: 'Schedule On', - fieldname: 'scheduled_on', - fieldtype: 'Date', - reqd: 1 + label: "Schedule On", + fieldname: "scheduled_on", + fieldtype: "Date", + reqd: 1, }, { - label: 'From Time', - fieldname: 'from_time', - fieldtype: 'Time', - reqd: 1 + label: "From Time", + fieldname: "from_time", + fieldtype: "Time", + reqd: 1, }, { - label: 'To Time', - fieldname: 'to_time', - fieldtype: 'Time', - reqd: 1 - } + label: "To Time", + fieldname: "to_time", + fieldtype: "Time", + reqd: 1, + }, ], - primary_action_label: 'Reschedule', + primary_action_label: "Reschedule", primary_action(values) { frm.call({ - method: 'reschedule_interview', + method: "reschedule_interview", doc: frm.doc, args: { scheduled_on: values.scheduled_on, from_time: values.from_time, - to_time: values.to_time - } + to_time: values.to_time, + }, }).then(() => { frm.refresh(); d.hide(); }); - } + }, }); d.show(); }, @@ -93,46 +98,48 @@ frappe.ui.form.on('Interview', { let fields = frm.events.get_fields_for_feedback(); let d = new frappe.ui.Dialog({ - title: __('Submit Feedback'), + title: __("Submit Feedback"), fields: [ { - fieldname: 'skill_set', - fieldtype: 'Table', - label: __('Skill Assessment'), + fieldname: "skill_set", + fieldtype: "Table", + label: __("Skill Assessment"), cannot_add_rows: false, in_editable_grid: true, reqd: 1, fields: fields, - data: data + data: data, }, { - fieldname: 'result', - fieldtype: 'Select', - options: ['', 'Cleared', 'Rejected'], - label: __('Result'), + fieldname: "result", + fieldtype: "Select", + options: ["", "Cleared", "Rejected"], + label: __("Result"), reqd: 1, }, { - fieldname: 'feedback', - fieldtype: 'Small Text', - label: __('Feedback') - } + fieldname: "feedback", + fieldtype: "Small Text", + label: __("Feedback"), + }, ], - size: 'large', + size: "large", minimizable: true, static: true, - primary_action: function(values) { - frappe.call({ - method: 'hrms.hr.doctype.interview.interview.create_interview_feedback', - args: { - data: values, - interview_name: frm.doc.name, - interviewer: frappe.session.user, - job_applicant: frm.doc.job_applicant - } - }).then(() => { - frm.refresh(); - }); + primary_action: function (values) { + frappe + .call({ + method: "hrms.hr.doctype.interview.interview.create_interview_feedback", + args: { + data: values, + interview_name: frm.doc.name, + interviewer: frappe.session.user, + job_applicant: frm.doc.job_applicant, + }, + }) + .then(() => { + frm.refresh(); + }); d.hide(); }, }); @@ -141,71 +148,76 @@ frappe.ui.form.on('Interview', { }, get_fields_for_feedback: function () { - return [{ - fieldtype: 'Link', - fieldname: 'skill', - options: 'Skill', - in_list_view: 1, - label: __('Skill') - }, { - fieldtype: 'Rating', - fieldname: 'rating', - label: __('Rating'), - in_list_view: 1, - reqd: 1, - }]; + return [ + { + fieldtype: "Link", + fieldname: "skill", + options: "Skill", + in_list_view: 1, + label: __("Skill"), + }, + { + fieldtype: "Rating", + fieldname: "rating", + label: __("Rating"), + in_list_view: 1, + reqd: 1, + }, + ]; }, set_job_applicant_query: function (frm) { - frm.set_query('job_applicant', function () { + frm.set_query("job_applicant", function () { let job_applicant_filters = { - status: ['!=', 'Rejected'] + status: ["!=", "Rejected"], }; if (frm.doc.designation) { job_applicant_filters.designation = frm.doc.designation; } return { - filters: job_applicant_filters + filters: job_applicant_filters, }; }); }, interview_round: async function (frm) { frm.events.reset_values(frm); - frm.set_value('job_applicant', ''); + frm.set_value("job_applicant", ""); - let round_data = (await frappe.db.get_value('Interview Round', frm.doc.interview_round, 'designation')).message; - frm.set_value('designation', round_data.designation); + let round_data = ( + await frappe.db.get_value("Interview Round", frm.doc.interview_round, "designation") + ).message; + frm.set_value("designation", round_data.designation); frm.events.set_job_applicant_query(frm); if (frm.doc.interview_round) { frm.events.set_interview_details(frm); } else { - frm.set_value('interview_details', []); + frm.set_value("interview_details", []); } }, set_interview_details: function (frm) { frappe.call({ - method: 'hrms.hr.doctype.interview.interview.get_interviewers', + method: "hrms.hr.doctype.interview.interview.get_interviewers", args: { - interview_round: frm.doc.interview_round + interview_round: frm.doc.interview_round, }, callback: function (data) { let interview_details = data.message; - frm.set_value('interview_details', []); + frm.set_value("interview_details", []); if (data.message.length) { - frm.set_value('interview_details', interview_details); + frm.set_value("interview_details", interview_details); } - } + }, }); }, job_applicant: function (frm) { if (!frm.doc.interview_round) { - frm.doc.job_applicant = ''; + frm.doc.job_applicant = ""; frm.refresh(); - frappe.throw(__('Select Interview Round First')); + frappe.throw(__("Select Interview Round First")); } if (frm.doc.job_applicant) { @@ -216,25 +228,31 @@ frappe.ui.form.on('Interview', { }, set_designation_and_job_opening: async function (frm) { - let round_data = (await frappe.db.get_value('Interview Round', frm.doc.interview_round, 'designation')).message; - frm.set_value('designation', round_data.designation); + let round_data = ( + await frappe.db.get_value("Interview Round", frm.doc.interview_round, "designation") + ).message; + frm.set_value("designation", round_data.designation); frm.events.set_job_applicant_query(frm); - let job_applicant_data = (await frappe.db.get_value( - 'Job Applicant', frm.doc.job_applicant, ['designation', 'job_title', 'resume_link'], - )).message; + let job_applicant_data = ( + await frappe.db.get_value("Job Applicant", frm.doc.job_applicant, [ + "designation", + "job_title", + "resume_link", + ]) + ).message; if (!round_data.designation) { - frm.set_value('designation', job_applicant_data.designation); + frm.set_value("designation", job_applicant_data.designation); } - frm.set_value('job_opening', job_applicant_data.job_title); - frm.set_value('resume_link', job_applicant_data.resume_link); + frm.set_value("job_opening", job_applicant_data.job_title); + frm.set_value("resume_link", job_applicant_data.resume_link); }, reset_values: function (frm) { - frm.set_value('designation', ''); - frm.set_value('job_opening', ''); - frm.set_value('resume_link', ''); - } + frm.set_value("designation", ""); + frm.set_value("job_opening", ""); + frm.set_value("resume_link", ""); + }, }); diff --git a/hrms/hr/doctype/interview/interview_calendar.js b/hrms/hr/doctype/interview/interview_calendar.js index 6d12134db8..92438cc4a9 100644 --- a/hrms/hr/doctype/interview/interview_calendar.js +++ b/hrms/hr/doctype/interview/interview_calendar.js @@ -1,14 +1,13 @@ - -frappe.views.calendar['Interview'] = { +frappe.views.calendar["Interview"] = { field_map: { - 'start': 'from', - 'end': 'to', - 'id': 'name', - 'title': 'subject', - 'allDay': 'allDay', - 'color': 'color' + start: "from", + end: "to", + id: "name", + title: "subject", + allDay: "allDay", + color: "color", }, - order_by: 'scheduled_on', + order_by: "scheduled_on", gantt: true, - get_events_method: 'hrms.hr.doctype.interview.interview.get_events' + get_events_method: "hrms.hr.doctype.interview.interview.get_events", }; diff --git a/hrms/hr/doctype/interview/interview_list.js b/hrms/hr/doctype/interview/interview_list.js index b1f072f0d4..e1a07c5df4 100644 --- a/hrms/hr/doctype/interview/interview_list.js +++ b/hrms/hr/doctype/interview/interview_list.js @@ -1,12 +1,12 @@ -frappe.listview_settings['Interview'] = { +frappe.listview_settings["Interview"] = { has_indicator_for_draft: 1, - get_indicator: function(doc) { + get_indicator: function (doc) { let status_color = { - 'Pending': 'orange', - 'Under Review': 'blue', - 'Cleared': 'green', - 'Rejected': 'red', + Pending: "orange", + "Under Review": "blue", + Cleared: "green", + Rejected: "red", }; - return [__(doc.status), status_color[doc.status], 'status,=,'+doc.status]; - } + return [__(doc.status), status_color[doc.status], "status,=," + doc.status]; + }, }; diff --git a/hrms/hr/doctype/interview_detail/interview_detail.js b/hrms/hr/doctype/interview_detail/interview_detail.js index 88518ca4cc..ba3b803031 100644 --- a/hrms/hr/doctype/interview_detail/interview_detail.js +++ b/hrms/hr/doctype/interview_detail/interview_detail.js @@ -1,8 +1,7 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Interview Detail', { +frappe.ui.form.on("Interview Detail", { // refresh: function(frm) { - // } }); diff --git a/hrms/hr/doctype/interview_feedback/interview_feedback.js b/hrms/hr/doctype/interview_feedback/interview_feedback.js index 2c5b6a7a0b..0487db1889 100644 --- a/hrms/hr/doctype/interview_feedback/interview_feedback.js +++ b/hrms/hr/doctype/interview_feedback/interview_feedback.js @@ -1,54 +1,53 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Interview Feedback', { - onload: function(frm) { - frm.ignore_doctypes_on_cancel_all = ['Interview']; +frappe.ui.form.on("Interview Feedback", { + onload: function (frm) { + frm.ignore_doctypes_on_cancel_all = ["Interview"]; - frm.set_query('interview', function() { + frm.set_query("interview", function () { return { filters: { - docstatus: ['!=', 2] - } + docstatus: ["!=", 2], + }, }; }); }, - interview_round: function(frm) { + interview_round: function (frm) { frappe.call({ - method: 'hrms.hr.doctype.interview.interview.get_expected_skill_set', + method: "hrms.hr.doctype.interview.interview.get_expected_skill_set", args: { - interview_round: frm.doc.interview_round + interview_round: frm.doc.interview_round, + }, + callback: function (r) { + frm.set_value("skill_assessment", r.message); }, - callback: function(r) { - frm.set_value('skill_assessment', r.message); - } }); }, - interview: function(frm) { + interview: function (frm) { frappe.call({ - method: 'hrms.hr.doctype.interview_feedback.interview_feedback.get_applicable_interviewers', + method: "hrms.hr.doctype.interview_feedback.interview_feedback.get_applicable_interviewers", args: { - interview: frm.doc.interview || '' + interview: frm.doc.interview || "", }, - callback: function(r) { - frm.set_query('interviewer', function() { + callback: function (r) { + frm.set_query("interviewer", function () { return { filters: { - name: ['in', r.message] - } + name: ["in", r.message], + }, }; }); - } + }, }); - }, - interviewer: function(frm) { + interviewer: function (frm) { if (!frm.doc.interview) { - frappe.throw(__('Select Interview first')); - frm.set_value('interviewer', ''); + frappe.throw(__("Select Interview first")); + frm.set_value("interviewer", ""); } - } + }, }); diff --git a/hrms/hr/doctype/interview_round/interview_round.js b/hrms/hr/doctype/interview_round/interview_round.js index b33f322609..d91eb34913 100644 --- a/hrms/hr/doctype/interview_round/interview_round.js +++ b/hrms/hr/doctype/interview_round/interview_round.js @@ -2,9 +2,9 @@ // For license information, please see license.txt frappe.ui.form.on("Interview Round", { - refresh: function(frm) { + refresh: function (frm) { if (!frm.doc.__islocal) { - frm.add_custom_button(__("Create Interview"), function() { + frm.add_custom_button(__("Create Interview"), function () { frm.events.create_interview(frm); }); } @@ -27,12 +27,12 @@ frappe.ui.form.on("Interview Round", { frappe.call({ method: "hrms.hr.doctype.interview_round.interview_round.create_interview", args: { - doc: frm.doc + doc: frm.doc, }, callback: function (r) { var doclist = frappe.model.sync(r.message); frappe.set_route("Form", doclist[0].doctype, doclist[0].name); - } + }, }); - } + }, }); diff --git a/hrms/hr/doctype/interview_type/interview_type.js b/hrms/hr/doctype/interview_type/interview_type.js index af77b527d4..9f74c8dfee 100644 --- a/hrms/hr/doctype/interview_type/interview_type.js +++ b/hrms/hr/doctype/interview_type/interview_type.js @@ -1,8 +1,7 @@ // Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Interview Type', { +frappe.ui.form.on("Interview Type", { // refresh: function(frm) { - // } }); diff --git a/hrms/hr/doctype/job_applicant/job_applicant.js b/hrms/hr/doctype/job_applicant/job_applicant.js index 259392fb0d..9cbdc77191 100644 --- a/hrms/hr/doctype/job_applicant/job_applicant.js +++ b/hrms/hr/doctype/job_applicant/job_applicant.js @@ -7,84 +7,96 @@ cur_frm.email_field = "email_id"; frappe.ui.form.on("Job Applicant", { - refresh: function(frm) { - frm.set_query("job_title", function() { + refresh: function (frm) { + frm.set_query("job_title", function () { return { filters: { - 'status': 'Open' - } + status: "Open", + }, }; }); frm.events.create_custom_buttons(frm); frm.events.make_dashboard(frm); }, - create_custom_buttons: function(frm) { + create_custom_buttons: function (frm) { if (!frm.doc.__islocal && frm.doc.status !== "Rejected" && frm.doc.status !== "Accepted") { - frm.add_custom_button(__("Interview"), function() { - frm.events.create_dialog(frm); - }, __("Create")); + frm.add_custom_button( + __("Interview"), + function () { + frm.events.create_dialog(frm); + }, + __("Create"), + ); } if (!frm.doc.__islocal && frm.doc.status == "Accepted") { if (frm.doc.__onload && frm.doc.__onload.job_offer) { $('[data-doctype="Employee Onboarding"]').find("button").show(); $('[data-doctype="Job Offer"]').find("button").hide(); - frm.add_custom_button(__("Job Offer"), function() { - frappe.set_route("Form", "Job Offer", frm.doc.__onload.job_offer); - }, __("View")); + frm.add_custom_button( + __("Job Offer"), + function () { + frappe.set_route("Form", "Job Offer", frm.doc.__onload.job_offer); + }, + __("View"), + ); } else { $('[data-doctype="Employee Onboarding"]').find("button").hide(); $('[data-doctype="Job Offer"]').find("button").show(); - frm.add_custom_button(__("Job Offer"), function() { - frappe.route_options = { - "job_applicant": frm.doc.name, - "applicant_name": frm.doc.applicant_name, - "designation": frm.doc.job_opening || frm.doc.designation, - }; - frappe.new_doc("Job Offer"); - }, __("Create")); + frm.add_custom_button( + __("Job Offer"), + function () { + frappe.route_options = { + job_applicant: frm.doc.name, + applicant_name: frm.doc.applicant_name, + designation: frm.doc.job_opening || frm.doc.designation, + }; + frappe.new_doc("Job Offer"); + }, + __("Create"), + ); } } }, - make_dashboard: function(frm) { + make_dashboard: function (frm) { frappe.call({ method: "hrms.hr.doctype.job_applicant.job_applicant.get_interview_details", args: { - job_applicant: frm.doc.name + job_applicant: frm.doc.name, }, - callback: function(r) { + callback: function (r) { if (r.message) { $("div").remove(".form-dashboard-section.custom"); frm.dashboard.add_section( frappe.render_template("job_applicant_dashboard", { data: r.message.interviews, - number_of_stars: r.message.stars + number_of_stars: r.message.stars, }), - __("Interview Summary") + __("Interview Summary"), ); } - } + }, }); }, - create_dialog: function(frm) { + create_dialog: function (frm) { let d = new frappe.ui.Dialog({ - title: 'Enter Interview Round', + title: "Enter Interview Round", fields: [ { - label: 'Interview Round', - fieldname: 'interview_round', - fieldtype: 'Link', - options: 'Interview Round' + label: "Interview Round", + fieldname: "interview_round", + fieldtype: "Link", + options: "Interview Round", }, ], primary_action_label: __("Create Interview"), primary_action(values) { frm.events.create_interview(frm, values); d.hide(); - } + }, }); d.show(); }, @@ -94,12 +106,12 @@ frappe.ui.form.on("Job Applicant", { method: "hrms.hr.doctype.job_applicant.job_applicant.create_interview", args: { doc: frm.doc, - interview_round: values.interview_round + interview_round: values.interview_round, }, callback: function (r) { var doclist = frappe.model.sync(r.message); frappe.set_route("Form", doclist[0].doctype, doclist[0].name); - } + }, }); - } + }, }); diff --git a/hrms/hr/doctype/job_applicant/job_applicant_list.js b/hrms/hr/doctype/job_applicant/job_applicant_list.js index 2ad0d591d8..266e7e85c5 100644 --- a/hrms/hr/doctype/job_applicant/job_applicant_list.js +++ b/hrms/hr/doctype/job_applicant/job_applicant_list.js @@ -1,7 +1,7 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors // MIT License. See license.txt -frappe.listview_settings['Job Applicant'] = { +frappe.listview_settings["Job Applicant"] = { add_fields: ["status"], get_indicator: function (doc) { if (doc.status == "Accepted") { @@ -11,5 +11,5 @@ frappe.listview_settings['Job Applicant'] = { } else if (["Hold", "Rejected"].includes(doc.status)) { return [__(doc.status), "red", "status,=," + doc.status]; } - } + }, }; diff --git a/hrms/hr/doctype/job_applicant_source/job_applicant_source.js b/hrms/hr/doctype/job_applicant_source/job_applicant_source.js index 8725f2312b..230f935885 100644 --- a/hrms/hr/doctype/job_applicant_source/job_applicant_source.js +++ b/hrms/hr/doctype/job_applicant_source/job_applicant_source.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Job Applicant Source', { - refresh: function() { - - } +frappe.ui.form.on("Job Applicant Source", { + refresh: function () {}, }); diff --git a/hrms/hr/doctype/job_offer/job_offer.js b/hrms/hr/doctype/job_offer/job_offer.js index a8b446f6d8..2a4fc56ada 100755 --- a/hrms/hr/doctype/job_offer/job_offer.js +++ b/hrms/hr/doctype/job_offer/job_offer.js @@ -5,7 +5,7 @@ frappe.provide("erpnext.job_offer"); frappe.ui.form.on("Job Offer", { onload: function (frm) { - frm.set_query("select_terms", function() { + frm.set_query("select_terms", function () { return { filters: { hr: 1 } }; }); }, @@ -24,40 +24,40 @@ frappe.ui.form.on("Job Offer", { job_offer_term_template: function (frm) { if (!frm.doc.job_offer_term_template) return; - frappe.db.get_doc("Job Offer Term Template", frm.doc.job_offer_term_template).then((doc) => { - frm.clear_table("offer_terms"); - doc.offer_terms.forEach((term) => { - frm.add_child("offer_terms", term); - }) - refresh_field("offer_terms"); - }) - + frappe.db + .get_doc("Job Offer Term Template", frm.doc.job_offer_term_template) + .then((doc) => { + frm.clear_table("offer_terms"); + doc.offer_terms.forEach((term) => { + frm.add_child("offer_terms", term); + }); + refresh_field("offer_terms"); + }); }, refresh: function (frm) { - if ((!frm.doc.__islocal) && (frm.doc.status == 'Accepted') - && (frm.doc.docstatus === 1) && (!frm.doc.__onload || !frm.doc.__onload.employee)) { - frm.add_custom_button(__('Create Employee'), - function () { - erpnext.job_offer.make_employee(frm); - } - ); + if ( + !frm.doc.__islocal && + frm.doc.status == "Accepted" && + frm.doc.docstatus === 1 && + (!frm.doc.__onload || !frm.doc.__onload.employee) + ) { + frm.add_custom_button(__("Create Employee"), function () { + erpnext.job_offer.make_employee(frm); + }); } - if(frm.doc.__onload && frm.doc.__onload.employee) { - frm.add_custom_button(__('Show Employee'), - function () { - frappe.set_route("Form", "Employee", frm.doc.__onload.employee); - } - ); + if (frm.doc.__onload && frm.doc.__onload.employee) { + frm.add_custom_button(__("Show Employee"), function () { + frappe.set_route("Form", "Employee", frm.doc.__onload.employee); + }); } - } - + }, }); erpnext.job_offer.make_employee = function (frm) { frappe.model.open_mapped_doc({ method: "hrms.hr.doctype.job_offer.job_offer.make_employee", - frm: frm + frm: frm, }); }; diff --git a/hrms/hr/doctype/job_offer/job_offer_list.js b/hrms/hr/doctype/job_offer/job_offer_list.js index 4fa5be7cc8..c6a2479d46 100644 --- a/hrms/hr/doctype/job_offer/job_offer_list.js +++ b/hrms/hr/doctype/job_offer/job_offer_list.js @@ -1,7 +1,7 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors // MIT License. See license.txt -frappe.listview_settings['Job Offer'] = { +frappe.listview_settings["Job Offer"] = { add_fields: ["company", "designation", "job_applicant", "status"], get_indicator: function (doc) { if (doc.status == "Accepted") { @@ -11,5 +11,5 @@ frappe.listview_settings['Job Offer'] = { } else if (doc.status == "Rejected") { return [__(doc.status), "red", "status,=," + doc.status]; } - } + }, }; diff --git a/hrms/hr/doctype/job_opening/job_opening.js b/hrms/hr/doctype/job_opening/job_opening.js index 9cdb44e9fd..e86364da04 100644 --- a/hrms/hr/doctype/job_opening/job_opening.js +++ b/hrms/hr/doctype/job_opening/job_opening.js @@ -1,46 +1,45 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Job Opening', { - onload: function(frm) { - frm.set_query("department", function() { +frappe.ui.form.on("Job Opening", { + onload: function (frm) { + frm.set_query("department", function () { return { - "filters": { - "company": frm.doc.company, - } + filters: { + company: frm.doc.company, + }, }; }); }, - designation: function(frm) { - if(frm.doc.designation && frm.doc.company){ + designation: function (frm) { + if (frm.doc.designation && frm.doc.company) { frappe.call({ - "method": "hrms.hr.doctype.staffing_plan.staffing_plan.get_active_staffing_plan_details", + method: "hrms.hr.doctype.staffing_plan.staffing_plan.get_active_staffing_plan_details", args: { company: frm.doc.company, designation: frm.doc.designation, - date: frappe.datetime.now_date() // ToDo - Date in Job Opening? + date: frappe.datetime.now_date(), // ToDo - Date in Job Opening? }, callback: function (data) { - if(data.message){ - frm.set_value('staffing_plan', data.message[0].name); - frm.set_value('planned_vacancies', data.message[0].vacancies); + if (data.message) { + frm.set_value("staffing_plan", data.message[0].name); + frm.set_value("planned_vacancies", data.message[0].vacancies); } else { - frm.set_value('staffing_plan', ""); - frm.set_value('planned_vacancies', 0); + frm.set_value("staffing_plan", ""); + frm.set_value("planned_vacancies", 0); frappe.show_alert({ - indicator: 'orange', - message: __('No Staffing Plans found for this Designation') + indicator: "orange", + message: __("No Staffing Plans found for this Designation"), }); } - } + }, }); - } - else{ - frm.set_value('staffing_plan', ""); - frm.set_value('planned_vacancies', 0); + } else { + frm.set_value("staffing_plan", ""); + frm.set_value("planned_vacancies", 0); } }, - company: function(frm) { - frm.set_value('designation', ""); + company: function (frm) { + frm.set_value("designation", ""); }, }); diff --git a/hrms/hr/doctype/job_requisition/job_requisition.js b/hrms/hr/doctype/job_requisition/job_requisition.js index 61c112493b..fd723ac915 100644 --- a/hrms/hr/doctype/job_requisition/job_requisition.js +++ b/hrms/hr/doctype/job_requisition/job_requisition.js @@ -2,64 +2,83 @@ // For license information, please see license.txt frappe.ui.form.on("Job Requisition", { - refresh: function(frm) { + refresh: function (frm) { if (!frm.doc.__islocal && !["Filled", "On Hold", "Cancelled"].includes(frm.doc.status)) { - frappe.db.get_list("Employee Referral", { - filters: { for_designation: frm.doc.designation, status: "Pending" } - }).then((data) => { - if (data && data.length) { - const link = data.length > 1 - ? `${__("Employee Referrals")}` - : `${__("Employee Referral")}`; + frappe.db + .get_list("Employee Referral", { + filters: { for_designation: frm.doc.designation, status: "Pending" }, + }) + .then((data) => { + if (data && data.length) { + const link = + data.length > 1 + ? `${__( + "Employee Referrals", + )}` + : `${__( + "Employee Referral", + )}`; - const headline = __("{} {} open for this position.", [data.length, link]); - frm.dashboard.clear_headline(); - frm.dashboard.set_headline(headline, "yellow"); + const headline = __("{} {} open for this position.", [data.length, link]); + frm.dashboard.clear_headline(); + frm.dashboard.set_headline(headline, "yellow"); - $("#referral_links").on("click", (e) => { - e.preventDefault(); - frappe.set_route("List", "Employee Referral", { - for_designation: frm.doc.designation, - status: "Pending" + $("#referral_links").on("click", (e) => { + e.preventDefault(); + frappe.set_route("List", "Employee Referral", { + for_designation: frm.doc.designation, + status: "Pending", + }); }); - }); - } - }) + } + }); } if (frm.doc.status === "Open & Approved") { - frm.add_custom_button(__("Create Job Opening"), () => { - frappe.model.open_mapped_doc({ - method: "hrms.hr.doctype.job_requisition.job_requisition.make_job_opening", - frm: frm - }); - }, __("Actions")); + frm.add_custom_button( + __("Create Job Opening"), + () => { + frappe.model.open_mapped_doc({ + method: "hrms.hr.doctype.job_requisition.job_requisition.make_job_opening", + frm: frm, + }); + }, + __("Actions"), + ); - frm.add_custom_button(__("Associate Job Opening"), () => { - frappe.prompt({ - label: __("Job Opening"), - fieldname: "job_opening", - fieldtype: "Link", - options: "Job Opening", - reqd: 1, - get_query: () => { - const filters = { - company: frm.doc.company, - status: "Open", - designation: frm.doc.designation, - } + frm.add_custom_button( + __("Associate Job Opening"), + () => { + frappe.prompt( + { + label: __("Job Opening"), + fieldname: "job_opening", + fieldtype: "Link", + options: "Job Opening", + reqd: 1, + get_query: () => { + const filters = { + company: frm.doc.company, + status: "Open", + designation: frm.doc.designation, + }; - if (frm.doc.department) - filters.department = frm.doc.department; + if (frm.doc.department) filters.department = frm.doc.department; - return { filters: filters }; - } - }, (values) => { - frm.call("associate_job_opening", { job_opening: values.job_opening }); - }, __("Associate Job Opening"), __("Submit")); - }, __("Actions")); + return { filters: filters }; + }, + }, + (values) => { + frm.call("associate_job_opening", { job_opening: values.job_opening }); + }, + __("Associate Job Opening"), + __("Submit"), + ); + }, + __("Actions"), + ); frm.page.set_inner_btn_group_as_primary(__("Actions")); } - } + }, }); diff --git a/hrms/hr/doctype/job_requisition/job_requisition_list.js b/hrms/hr/doctype/job_requisition/job_requisition_list.js index 6e2d3d8b38..d0e19abfc5 100644 --- a/hrms/hr/doctype/job_requisition/job_requisition_list.js +++ b/hrms/hr/doctype/job_requisition/job_requisition_list.js @@ -1,23 +1,23 @@ frappe.listview_settings["Job Requisition"] = { - get_indicator: function(doc) { + get_indicator: function (doc) { const status_color = { - "Pending": "yellow", + Pending: "yellow", "Open & Approved": "blue", - "Rejected": "red", - "Filled": "green", - "Cancelled": "gray", - "On Hold": "gray" + Rejected: "red", + Filled: "green", + Cancelled: "gray", + "On Hold": "gray", }; return [__(doc.status), status_color[doc.status], "status,=," + doc.status]; }, formatters: { expected_by(value, df, doc) { - if (!value || (["Filled", "Cancelled", "On Hold"].includes(doc.status))) return ""; + if (!value || ["Filled", "Cancelled", "On Hold"].includes(doc.status)) return ""; const now = moment(); const expected_by = moment(value); - const color = (now > expected_by) ? "red" : "green"; + const color = now > expected_by ? "red" : "green"; return `
`; - } - } -} + }, + }, +}; diff --git a/hrms/hr/doctype/kra/kra.js b/hrms/hr/doctype/kra/kra.js index 237ba0ecb0..6d65f9405f 100644 --- a/hrms/hr/doctype/kra/kra.js +++ b/hrms/hr/doctype/kra/kra.js @@ -1,8 +1,7 @@ // Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('KRA', { +frappe.ui.form.on("KRA", { // refresh: function(frm) { - // } }); diff --git a/hrms/hr/doctype/leave_allocation/leave_allocation.js b/hrms/hr/doctype/leave_allocation/leave_allocation.js index 4bd60bfb67..1f11057b22 100755 --- a/hrms/hr/doctype/leave_allocation/leave_allocation.js +++ b/hrms/hr/doctype/leave_allocation/leave_allocation.js @@ -1,35 +1,38 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.add_fetch('employee', 'employee_name', 'employee_name'); +cur_frm.add_fetch("employee", "employee_name", "employee_name"); frappe.ui.form.on("Leave Allocation", { - onload: function(frm) { + onload: function (frm) { // Ignore cancellation of doctype on cancel all. frm.ignore_doctypes_on_cancel_all = ["Leave Ledger Entry"]; if (!frm.doc.from_date) frm.set_value("from_date", frappe.datetime.get_today()); - frm.set_query("employee", function() { + frm.set_query("employee", function () { return { - query: "erpnext.controllers.queries.employee_query" + query: "erpnext.controllers.queries.employee_query", }; }); - frm.set_query("leave_type", function() { + frm.set_query("leave_type", function () { return { filters: { - is_lwp: 0 - } + is_lwp: 0, + }, }; }); }, - refresh: function(frm) { + refresh: function (frm) { if (frm.doc.docstatus === 1 && frm.doc.expired) { - var valid_expiry = moment(frappe.datetime.get_today()).isBetween(frm.doc.from_date, frm.doc.to_date); + var valid_expiry = moment(frappe.datetime.get_today()).isBetween( + frm.doc.from_date, + frm.doc.to_date, + ); if (valid_expiry) { // expire current allocation - frm.add_custom_button(__('Expire Allocation'), function() { + frm.add_custom_button(__("Expire Allocation"), function () { frm.trigger("expire_allocation"); }); } @@ -43,96 +46,109 @@ frappe.ui.form.on("Leave Allocation", { } }, - expire_allocation: function(frm) { + expire_allocation: function (frm) { frappe.call({ - method: 'hrms.hr.doctype.leave_ledger_entry.leave_ledger_entry.expire_allocation', + method: "hrms.hr.doctype.leave_ledger_entry.leave_ledger_entry.expire_allocation", args: { - 'allocation': frm.doc, - 'expiry_date': frappe.datetime.get_today() + allocation: frm.doc, + expiry_date: frappe.datetime.get_today(), }, freeze: true, - callback: function(r) { + callback: function (r) { if (!r.exc) { frappe.msgprint(__("Allocation Expired!")); } frm.refresh(); - } + }, }); }, - employee: function(frm) { + employee: function (frm) { frm.trigger("calculate_total_leaves_allocated"); }, - leave_type: function(frm) { + leave_type: function (frm) { frm.trigger("leave_policy"); frm.trigger("calculate_total_leaves_allocated"); }, - carry_forward: function(frm) { + carry_forward: function (frm) { frm.trigger("calculate_total_leaves_allocated"); }, - unused_leaves: function(frm) { - frm.set_value("total_leaves_allocated", - flt(frm.doc.unused_leaves) + flt(frm.doc.new_leaves_allocated)); + unused_leaves: function (frm) { + frm.set_value( + "total_leaves_allocated", + flt(frm.doc.unused_leaves) + flt(frm.doc.new_leaves_allocated), + ); }, - new_leaves_allocated: function(frm) { - frm.set_value("total_leaves_allocated", - flt(frm.doc.unused_leaves) + flt(frm.doc.new_leaves_allocated)); + new_leaves_allocated: function (frm) { + frm.set_value( + "total_leaves_allocated", + flt(frm.doc.unused_leaves) + flt(frm.doc.new_leaves_allocated), + ); }, - leave_policy: function(frm) { + leave_policy: function (frm) { if (frm.doc.leave_policy && frm.doc.leave_type) { - frappe.db.get_value("Leave Policy Detail", { - 'parent': frm.doc.leave_policy, - 'leave_type': frm.doc.leave_type - }, 'annual_allocation', (r) => { - if (r && !r.exc) frm.set_value("new_leaves_allocated", flt(r.annual_allocation)); - }, "Leave Policy"); + frappe.db.get_value( + "Leave Policy Detail", + { + parent: frm.doc.leave_policy, + leave_type: frm.doc.leave_type, + }, + "annual_allocation", + (r) => { + if (r && !r.exc) + frm.set_value("new_leaves_allocated", flt(r.annual_allocation)); + }, + "Leave Policy", + ); } }, - calculate_total_leaves_allocated: function(frm) { + calculate_total_leaves_allocated: function (frm) { if (cint(frm.doc.carry_forward) == 1 && frm.doc.leave_type && frm.doc.employee) { return frappe.call({ method: "set_total_leaves_allocated", doc: frm.doc, - callback: function() { + callback: function () { frm.refresh_fields(); - } + }, }); } else if (cint(frm.doc.carry_forward) == 0) { frm.set_value("unused_leaves", 0); frm.set_value("total_leaves_allocated", flt(frm.doc.new_leaves_allocated)); } - } + }, }); frappe.tour["Leave Allocation"] = [ { fieldname: "employee", title: "Employee", - description: __("Select the Employee for which you want to allocate leaves.") + description: __("Select the Employee for which you want to allocate leaves."), }, { fieldname: "leave_type", title: "Leave Type", - description: __("Select the Leave Type like Sick leave, Privilege Leave, Casual Leave, etc.") + description: __( + "Select the Leave Type like Sick leave, Privilege Leave, Casual Leave, etc.", + ), }, { fieldname: "from_date", title: "From Date", - description: __("Select the date from which this Leave Allocation will be valid.") + description: __("Select the date from which this Leave Allocation will be valid."), }, { fieldname: "to_date", title: "To Date", - description: __("Select the date after which this Leave Allocation will expire.") + description: __("Select the date after which this Leave Allocation will expire."), }, { fieldname: "new_leaves_allocated", title: "New Leaves Allocated", - description: __("Enter the number of leaves you want to allocate for the period.") - } + description: __("Enter the number of leaves you want to allocate for the period."), + }, ]; diff --git a/hrms/hr/doctype/leave_allocation/leave_allocation_list.js b/hrms/hr/doctype/leave_allocation/leave_allocation_list.js index 3ab176f809..d004a62fb1 100644 --- a/hrms/hr/doctype/leave_allocation/leave_allocation_list.js +++ b/hrms/hr/doctype/leave_allocation/leave_allocation_list.js @@ -2,9 +2,9 @@ // License: GNU General Public License v3. See license.txt // render -frappe.listview_settings['Leave Allocation'] = { - get_indicator: function(doc) { - if(doc.status==="Expired") { +frappe.listview_settings["Leave Allocation"] = { + get_indicator: function (doc) { + if (doc.status === "Expired") { return [__("Expired"), "gray", "expired, =, 1"]; } }, diff --git a/hrms/hr/doctype/leave_application/leave_application.js b/hrms/hr/doctype/leave_application/leave_application.js index bd02891423..28b3933366 100755 --- a/hrms/hr/doctype/leave_application/leave_application.js +++ b/hrms/hr/doctype/leave_application/leave_application.js @@ -2,21 +2,21 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Leave Application", { - setup: function(frm) { - frm.set_query("leave_approver", function() { + setup: function (frm) { + frm.set_query("leave_approver", function () { return { query: "hrms.hr.doctype.department_approver.department_approver.get_approvers", filters: { employee: frm.doc.employee, - doctype: frm.doc.doctype - } + doctype: frm.doc.doctype, + }, }; }); frm.set_query("employee", erpnext.queries.employee); }, - onload: function(frm) { + onload: function (frm) { // Ignore cancellation of doctype on cancel all. frm.ignore_doctypes_on_cancel_all = ["Leave Ledger Entry"]; @@ -29,16 +29,16 @@ frappe.ui.form.on("Leave Application", { args: { doctype: frm.doc.doctype, }, - callback: function(r) { + callback: function (r) { if (!r.exc && r.message) { frm.toggle_reqd("leave_approver", true); } - } + }, }); } }, - validate: function(frm) { + validate: function (frm) { if (frm.doc.from_date === frm.doc.to_date && cint(frm.doc.half_day)) { frm.doc.half_day_date = frm.doc.from_date; } else if (frm.doc.half_day === 0) { @@ -47,7 +47,7 @@ frappe.ui.form.on("Leave Application", { frm.toggle_reqd("half_day_date", cint(frm.doc.half_day)); }, - make_dashboard: function(frm) { + make_dashboard: function (frm) { let leave_details; let lwps; @@ -57,9 +57,9 @@ frappe.ui.form.on("Leave Application", { async: false, args: { employee: frm.doc.employee, - date: frm.doc.from_date || frm.doc.posting_date + date: frm.doc.from_date || frm.doc.posting_date, }, - callback: function(r) { + callback: function (r) { if (!r.exc && r.message["leave_allocation"]) { leave_details = r.message["leave_allocation"]; } @@ -67,16 +67,16 @@ frappe.ui.form.on("Leave Application", { frm.set_value("leave_approver", r.message["leave_approver"]); } lwps = r.message["lwps"]; - } + }, }); $("div").remove(".form-dashboard-section.custom"); frm.dashboard.add_section( frappe.render_template("leave_application_dashboard", { - data: leave_details + data: leave_details, }), - __("Allocated Leaves") + __("Allocated Leaves"), ); frm.dashboard.show(); @@ -84,17 +84,15 @@ frappe.ui.form.on("Leave Application", { // lwps should be allowed for selection as they don't have any allocation allowed_leave_types = allowed_leave_types.concat(lwps); - frm.set_query("leave_type", function() { + frm.set_query("leave_type", function () { return { - filters: [ - ["leave_type_name", "in", allowed_leave_types] - ] + filters: [["leave_type_name", "in", allowed_leave_types]], }; }); } }, - refresh: function(frm) { + refresh: function (frm) { if (frm.is_new()) { frm.trigger("calculate_total_days"); } @@ -116,23 +114,23 @@ frappe.ui.form.on("Leave Application", { } }, - employee: function(frm) { + employee: function (frm) { frm.trigger("make_dashboard"); frm.trigger("get_leave_balance"); frm.trigger("set_leave_approver"); }, - leave_approver: function(frm) { + leave_approver: function (frm) { if (frm.doc.leave_approver) { frm.set_value("leave_approver_name", frappe.user.full_name(frm.doc.leave_approver)); } }, - leave_type: function(frm) { + leave_type: function (frm) { frm.trigger("get_leave_balance"); }, - half_day: function(frm) { + half_day: function (frm) { if (frm.doc.half_day) { if (frm.doc.from_date == frm.doc.to_date) { frm.set_value("half_day_date", frm.doc.from_date); @@ -176,12 +174,18 @@ frappe.ui.form.on("Leave Application", { const half_day_datepicker = frm.fields_dict.half_day_date.datepicker; half_day_datepicker.update({ minDate: frappe.datetime.str_to_obj(frm.doc.from_date), - maxDate: frappe.datetime.str_to_obj(frm.doc.to_date) + maxDate: frappe.datetime.str_to_obj(frm.doc.to_date), }); }, - get_leave_balance: function(frm) { - if (frm.doc.docstatus === 0 && frm.doc.employee && frm.doc.leave_type && frm.doc.from_date && frm.doc.to_date) { + get_leave_balance: function (frm) { + if ( + frm.doc.docstatus === 0 && + frm.doc.employee && + frm.doc.leave_type && + frm.doc.from_date && + frm.doc.to_date + ) { return frappe.call({ method: "hrms.hr.doctype.leave_application.leave_application.get_leave_balance_on", args: { @@ -189,7 +193,7 @@ frappe.ui.form.on("Leave Application", { date: frm.doc.from_date, to_date: frm.doc.to_date, leave_type: frm.doc.leave_type, - consider_all_leaves_in_the_allocation_period: 1 + consider_all_leaves_in_the_allocation_period: 1, }, callback: function (r) { if (!r.exc && r.message) { @@ -197,80 +201,84 @@ frappe.ui.form.on("Leave Application", { } else { frm.set_value("leave_balance", "0"); } - } + }, }); } }, - calculate_total_days: function(frm) { + calculate_total_days: function (frm) { if (frm.doc.from_date && frm.doc.to_date && frm.doc.employee && frm.doc.leave_type) { // server call is done to include holidays in leave days calculations return frappe.call({ method: "hrms.hr.doctype.leave_application.leave_application.get_number_of_leave_days", args: { - "employee": frm.doc.employee, - "leave_type": frm.doc.leave_type, - "from_date": frm.doc.from_date, - "to_date": frm.doc.to_date, - "half_day": frm.doc.half_day, - "half_day_date": frm.doc.half_day_date, + employee: frm.doc.employee, + leave_type: frm.doc.leave_type, + from_date: frm.doc.from_date, + to_date: frm.doc.to_date, + half_day: frm.doc.half_day, + half_day_date: frm.doc.half_day_date, }, - callback: function(r) { + callback: function (r) { if (r && r.message) { frm.set_value("total_leave_days", r.message); frm.trigger("get_leave_balance"); } - } + }, }); } }, - set_leave_approver: function(frm) { + set_leave_approver: function (frm) { if (frm.doc.employee) { return frappe.call({ method: "hrms.hr.doctype.leave_application.leave_application.get_leave_approver", args: { - "employee": frm.doc.employee, + employee: frm.doc.employee, }, - callback: function(r) { + callback: function (r) { if (r && r.message) { frm.set_value("leave_approver", r.message); } - } + }, }); } - } + }, }); frappe.tour["Leave Application"] = [ { fieldname: "employee", title: "Employee", - description: __("Select the Employee.") + description: __("Select the Employee."), }, { fieldname: "leave_type", title: "Leave Type", - description: __("Select type of leave the employee wants to apply for, like Sick Leave, Privilege Leave, Casual Leave, etc.") + description: __( + "Select type of leave the employee wants to apply for, like Sick Leave, Privilege Leave, Casual Leave, etc.", + ), }, { fieldname: "from_date", title: "From Date", - description: __("Select the start date for your Leave Application.") + description: __("Select the start date for your Leave Application."), }, { fieldname: "to_date", title: "To Date", - description: __("Select the end date for your Leave Application.") + description: __("Select the end date for your Leave Application."), }, { fieldname: "half_day", title: "Half Day", - description: __("To apply for a Half Day check 'Half Day' and select the Half Day Date") + description: __("To apply for a Half Day check 'Half Day' and select the Half Day Date"), }, { fieldname: "leave_approver", title: "Leave Approver", - description: __("Select your Leave Approver i.e. the person who approves or rejects your leaves.") - } + description: __( + "Select your Leave Approver i.e. the person who approves or rejects your leaves.", + ), + }, ]; diff --git a/hrms/hr/doctype/leave_application/leave_application_calendar.js b/hrms/hr/doctype/leave_application/leave_application_calendar.js index 8bb4584cfa..6fc85da2e2 100644 --- a/hrms/hr/doctype/leave_application/leave_application_calendar.js +++ b/hrms/hr/doctype/leave_application/leave_application_calendar.js @@ -3,19 +3,19 @@ frappe.views.calendar["Leave Application"] = { field_map: { - "start": "from_date", - "end": "to_date", - "id": "name", - "title": "title", - "docstatus": 1, - "color": "color", + start: "from_date", + end: "to_date", + id: "name", + title: "title", + docstatus: 1, + color: "color", }, options: { header: { - left: 'prev,next today', - center: 'title', - right: 'month' - } + left: "prev,next today", + center: "title", + right: "month", + }, }, - get_events_method: "hrms.hr.doctype.leave_application.leave_application.get_events" -} + get_events_method: "hrms.hr.doctype.leave_application.leave_application.get_events", +}; diff --git a/hrms/hr/doctype/leave_application/leave_application_list.js b/hrms/hr/doctype/leave_application/leave_application_list.js index 76e0b41d56..983a05fef8 100644 --- a/hrms/hr/doctype/leave_application/leave_application_list.js +++ b/hrms/hr/doctype/leave_application/leave_application_list.js @@ -18,9 +18,7 @@ frappe.listview_settings["Leave Application"] = { Submitted: "blue", }; const status = - !doc.docstatus && ["Approved", "Rejected"].includes(doc.status) - ? "Draft" - : doc.status; + !doc.docstatus && ["Approved", "Rejected"].includes(doc.status) ? "Draft" : doc.status; return [__(status), status_color[status], "status,=," + doc.status]; }, }; diff --git a/hrms/hr/doctype/leave_block_list/leave_block_list.js b/hrms/hr/doctype/leave_block_list/leave_block_list.js index 85563a9c60..1e37b238f3 100644 --- a/hrms/hr/doctype/leave_block_list/leave_block_list.js +++ b/hrms/hr/doctype/leave_block_list/leave_block_list.js @@ -1,30 +1,30 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Leave Block List', { - add_day_wise_dates: function(frm) { +frappe.ui.form.on("Leave Block List", { + add_day_wise_dates: function (frm) { let d = new frappe.ui.Dialog({ - title: 'Add Leave Block Dates', + title: "Add Leave Block Dates", fields: [ { - label: 'Start Date', - fieldname: 'start_date', - fieldtype: 'Date', - reqd: 1 + label: "Start Date", + fieldname: "start_date", + fieldtype: "Date", + reqd: 1, }, { - fieldname: 'col_break_0', - fieldtype: 'Column Break' + fieldname: "col_break_0", + fieldtype: "Column Break", }, { - label: 'End Date', - fieldname: 'end_date', - fieldtype: 'Date', - reqd: 1 + label: "End Date", + fieldname: "end_date", + fieldtype: "Date", + reqd: 1, }, { - fieldname: 'sec_break_0', - fieldtype: 'Section Break' + fieldname: "sec_break_0", + fieldtype: "Section Break", }, { fieldname: "days", @@ -71,29 +71,29 @@ frappe.ui.form.on('Leave Block List', { ], }, { - fieldname: 'sec_break_0', - fieldtype: 'Section Break' + fieldname: "sec_break_0", + fieldtype: "Section Break", }, { - label: 'Reason', - fieldname: 'reason', - fieldtype: 'Small Text', - reqd: 1 + label: "Reason", + fieldname: "reason", + fieldtype: "Small Text", + reqd: 1, }, ], - primary_action_label: 'Add', + primary_action_label: "Add", primary_action(values) { - frm.call('set_weekly_off_dates', { - 'start_date': d.get_value('start_date'), - 'end_date': d.get_value('end_date'), - 'reason': d.get_value('reason'), - 'days': d.get_value('days') + frm.call("set_weekly_off_dates", { + start_date: d.get_value("start_date"), + end_date: d.get_value("end_date"), + reason: d.get_value("reason"), + days: d.get_value("days"), }); frm.dirty(); d.hide(); - } + }, }); d.show(); - } + }, }); diff --git a/hrms/hr/doctype/leave_control_panel/leave_control_panel.js b/hrms/hr/doctype/leave_control_panel/leave_control_panel.js index 4a450807cc..2a5850f317 100644 --- a/hrms/hr/doctype/leave_control_panel/leave_control_panel.js +++ b/hrms/hr/doctype/leave_control_panel/leave_control_panel.js @@ -2,23 +2,23 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Leave Control Panel", { - onload: function(frm) { + onload: function (frm) { if (!frm.doc.from_date) { - frm.set_value('from_date', frappe.datetime.get_today()); + frm.set_value("from_date", frappe.datetime.get_today()); } }, - refresh: function(frm) { + refresh: function (frm) { frm.disable_save(); }, - company: function(frm) { - if(frm.doc.company) { - frm.set_query("department", function() { + company: function (frm) { + if (frm.doc.company) { + frm.set_query("department", function () { return { - "filters": { - "company": frm.doc.company, - } + filters: { + company: frm.doc.company, + }, }; }); } - } + }, }); diff --git a/hrms/hr/doctype/leave_encashment/leave_encashment.js b/hrms/hr/doctype/leave_encashment/leave_encashment.js index a321b72291..09b1b698ec 100644 --- a/hrms/hr/doctype/leave_encashment/leave_encashment.js +++ b/hrms/hr/doctype/leave_encashment/leave_encashment.js @@ -1,71 +1,71 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Leave Encashment', { - onload: function(frm) { +frappe.ui.form.on("Leave Encashment", { + onload: function (frm) { // Ignore cancellation of doctype on cancel all. frm.ignore_doctypes_on_cancel_all = ["Leave Ledger Entry"]; }, - setup: function(frm) { - frm.set_query("leave_type", function() { + setup: function (frm) { + frm.set_query("leave_type", function () { return { filters: { - allow_encashment: 1 - } - } - }) - frm.set_query("leave_period", function() { + allow_encashment: 1, + }, + }; + }); + frm.set_query("leave_period", function () { return { filters: { - is_active: 1 - } - } - }) + is_active: 1, + }, + }; + }); }, - refresh: function(frm) { + refresh: function (frm) { cur_frm.set_intro(""); - if(frm.doc.__islocal && !in_list(frappe.user_roles, "Employee")) { + if (frm.doc.__islocal && !in_list(frappe.user_roles, "Employee")) { frm.set_intro(__("Fill the form and save it")); } }, - employee: function(frm) { + employee: function (frm) { if (frm.doc.employee) { frappe.run_serially([ - () => frm.trigger('get_employee_currency'), - () => frm.trigger('get_leave_details_for_encashment') + () => frm.trigger("get_employee_currency"), + () => frm.trigger("get_leave_details_for_encashment"), ]); } }, - leave_type: function(frm) { + leave_type: function (frm) { frm.trigger("get_leave_details_for_encashment"); }, - encashment_date: function(frm) { + encashment_date: function (frm) { frm.trigger("get_leave_details_for_encashment"); }, - get_leave_details_for_encashment: function(frm) { - if(frm.doc.docstatus==0 && frm.doc.employee && frm.doc.leave_type) { + get_leave_details_for_encashment: function (frm) { + if (frm.doc.docstatus == 0 && frm.doc.employee && frm.doc.leave_type) { return frappe.call({ method: "get_leave_details_for_encashment", doc: frm.doc, - callback: function(r) { + callback: function (r) { frm.refresh_fields(); - } + }, }); } }, - get_employee_currency: function(frm) { + get_employee_currency: function (frm) { frappe.call({ method: "hrms.payroll.doctype.salary_structure_assignment.salary_structure_assignment.get_employee_currency", args: { employee: frm.doc.employee, }, - callback: function(r) { + callback: function (r) { if (r.message) { - frm.set_value('currency', r.message); + frm.set_value("currency", r.message); frm.refresh_fields(); } - } + }, }); }, }); diff --git a/hrms/hr/doctype/leave_ledger_entry/leave_ledger_entry.js b/hrms/hr/doctype/leave_ledger_entry/leave_ledger_entry.js index c68d518f67..fd159025b7 100644 --- a/hrms/hr/doctype/leave_ledger_entry/leave_ledger_entry.js +++ b/hrms/hr/doctype/leave_ledger_entry/leave_ledger_entry.js @@ -1,8 +1,7 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Leave Ledger Entry', { +frappe.ui.form.on("Leave Ledger Entry", { // refresh: function(frm) { - // } }); diff --git a/hrms/hr/doctype/leave_ledger_entry/leave_ledger_entry_list.js b/hrms/hr/doctype/leave_ledger_entry/leave_ledger_entry_list.js index 889325bf2b..c95ca743a8 100644 --- a/hrms/hr/doctype/leave_ledger_entry/leave_ledger_entry_list.js +++ b/hrms/hr/doctype/leave_ledger_entry/leave_ledger_entry_list.js @@ -1,13 +1,16 @@ -frappe.listview_settings['Leave Ledger Entry'] = { - onload: function(listview) { - if(listview.page.fields_dict.transaction_type) { - listview.page.fields_dict.transaction_type.get_query = function() { +frappe.listview_settings["Leave Ledger Entry"] = { + onload: function (listview) { + if (listview.page.fields_dict.transaction_type) { + listview.page.fields_dict.transaction_type.get_query = function () { return { - "filters": { - "name": ["in", ["Leave Allocation", "Leave Application", "Leave Encashment"]], - } + filters: { + name: [ + "in", + ["Leave Allocation", "Leave Application", "Leave Encashment"], + ], + }, }; }; } - } + }, }; diff --git a/hrms/hr/doctype/leave_period/leave_period.js b/hrms/hr/doctype/leave_period/leave_period.js index 0e88bc1671..a8ac9c50d2 100644 --- a/hrms/hr/doctype/leave_period/leave_period.js +++ b/hrms/hr/doctype/leave_period/leave_period.js @@ -1,19 +1,19 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Leave Period', { - from_date: (frm)=>{ +frappe.ui.form.on("Leave Period", { + from_date: (frm) => { if (frm.doc.from_date && !frm.doc.to_date) { var a_year_from_start = frappe.datetime.add_months(frm.doc.from_date, 12); frm.set_value("to_date", frappe.datetime.add_days(a_year_from_start, -1)); } }, onload: (frm) => { - frm.set_query("department", function() { + frm.set_query("department", function () { return { - "filters": { - "company": frm.doc.company, - } + filters: { + company: frm.doc.company, + }, }; }); }, diff --git a/hrms/hr/doctype/leave_policy/leave_policy.js b/hrms/hr/doctype/leave_policy/leave_policy.js index fdf8e0cdbb..e5ab2c13db 100644 --- a/hrms/hr/doctype/leave_policy/leave_policy.js +++ b/hrms/hr/doctype/leave_policy/leave_policy.js @@ -1,31 +1,29 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Leave Policy', { -}); +frappe.ui.form.on("Leave Policy", {}); -frappe.ui.form.on('Leave Policy Detail',{ - leave_type: function(frm, cdt, cdn) { +frappe.ui.form.on("Leave Policy Detail", { + leave_type: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; - if(child.leave_type){ + if (child.leave_type) { frappe.call({ method: "frappe.client.get_value", args: { doctype: "Leave Type", fieldname: "max_leaves_allowed", - filters: { name: child.leave_type } + filters: { name: child.leave_type }, }, - callback: function(r) { + callback: function (r) { if (r.message) { child.annual_allocation = r.message.max_leaves_allowed; refresh_field("leave_policy_details"); } - } + }, }); - } - else{ + } else { child.annual_allocation = ""; refresh_field("leave_policy_details"); } - } + }, }); diff --git a/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.js b/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.js index 0aaf4cf616..7c06584fcd 100644 --- a/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.js +++ b/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.js @@ -1,59 +1,72 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Leave Policy Assignment', { - onload: function(frm) { +frappe.ui.form.on("Leave Policy Assignment", { + onload: function (frm) { frm.ignore_doctypes_on_cancel_all = ["Leave Ledger Entry"]; - frm.set_query('leave_policy', function() { + frm.set_query("leave_policy", function () { return { filters: { - "docstatus": 1 - } + docstatus: 1, + }, }; }); - frm.set_query('leave_period', function() { + frm.set_query("leave_period", function () { return { filters: { - "is_active": 1, - "company": frm.doc.company - } + is_active: 1, + company: frm.doc.company, + }, }; }); }, - assignment_based_on: function(frm) { + assignment_based_on: function (frm) { if (frm.doc.assignment_based_on) { frm.events.set_effective_date(frm); } else { - frm.set_value("effective_from", ''); - frm.set_value("effective_to", ''); + frm.set_value("effective_from", ""); + frm.set_value("effective_to", ""); } }, - leave_period: function(frm) { + leave_period: function (frm) { if (frm.doc.leave_period) { frm.events.set_effective_date(frm); } }, - set_effective_date: function(frm) { + set_effective_date: function (frm) { if (frm.doc.assignment_based_on == "Leave Period" && frm.doc.leave_period) { frappe.model.with_doc("Leave Period", frm.doc.leave_period, function () { - let from_date = frappe.model.get_value("Leave Period", frm.doc.leave_period, "from_date"); - let to_date = frappe.model.get_value("Leave Period", frm.doc.leave_period, "to_date"); + let from_date = frappe.model.get_value( + "Leave Period", + frm.doc.leave_period, + "from_date", + ); + let to_date = frappe.model.get_value( + "Leave Period", + frm.doc.leave_period, + "to_date", + ); frm.set_value("effective_from", from_date); frm.set_value("effective_to", to_date); - }); } else if (frm.doc.assignment_based_on == "Joining Date" && frm.doc.employee) { frappe.model.with_doc("Employee", frm.doc.employee, function () { - let from_date = frappe.model.get_value("Employee", frm.doc.employee, "date_of_joining"); + let from_date = frappe.model.get_value( + "Employee", + frm.doc.employee, + "date_of_joining", + ); frm.set_value("effective_from", from_date); - frm.set_value("effective_to", frappe.datetime.add_months(frm.doc.effective_from, 12)); + frm.set_value( + "effective_to", + frappe.datetime.add_months(frm.doc.effective_from, 12), + ); }); } frm.refresh(); - } - + }, }); diff --git a/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment_list.js b/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment_list.js index 75230a3670..e6fc68a294 100644 --- a/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment_list.js +++ b/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment_list.js @@ -1,4 +1,4 @@ -frappe.listview_settings['Leave Policy Assignment'] = { +frappe.listview_settings["Leave Policy Assignment"] = { onload: function (list_view) { let me = this; list_view.page.add_inner_button(__("Bulk Leave Policy Assignment"), function () { @@ -6,120 +6,140 @@ frappe.listview_settings['Leave Policy Assignment'] = { doctype: "Employee", target: cur_list, setters: { - employee_name: '', - company: '', - department: '', + employee_name: "", + company: "", + department: "", }, - data_fields: [{ - fieldname: 'leave_policy', - fieldtype: 'Link', - options: 'Leave Policy', - label: __('Leave Policy'), - reqd: 1 - }, - { - fieldname: 'assignment_based_on', - fieldtype: 'Select', - options: ["", "Leave Period", "Joining Date"], - label: __('Assignment Based On'), - onchange: () => { - if (cur_dialog.fields_dict.assignment_based_on.value === "Leave Period") { - cur_dialog.set_df_property("effective_from", "reqd", 1); - cur_dialog.set_df_property("effective_from", "hidden", 0); - cur_dialog.set_df_property("effective_from", "read_only", 1); - cur_dialog.set_df_property("leave_period", "reqd", 1); - cur_dialog.set_df_property("effective_to", "read_only", 1); - } else if (cur_dialog.fields_dict.assignment_based_on.value === "Joining Date") { - cur_dialog.set_df_property("effective_from", "reqd", 0); - cur_dialog.set_df_property("effective_from", "hidden", 1); - cur_dialog.set_value("effective_from", ""); - } else { - cur_dialog.set_df_property("effective_from", "reqd", 1); - cur_dialog.set_df_property("effective_from", "hidden", 0); - cur_dialog.set_df_property("effective_from", "read_only", 0); - cur_dialog.set_df_property("leave_period", "reqd", 0); - cur_dialog.set_df_property("effective_to", "read_only", 0); - cur_dialog.set_value("effective_from", ""); - cur_dialog.set_value("effective_to", ""); - } - } - }, - { - fieldname: "leave_period", - fieldtype: 'Link', - options: "Leave Period", - label: __('Leave Period'), - depends_on: doc => { - return doc.assignment_based_on == 'Leave Period'; + data_fields: [ + { + fieldname: "leave_policy", + fieldtype: "Link", + options: "Leave Policy", + label: __("Leave Policy"), + reqd: 1, }, - onchange: () => { - if (cur_dialog.fields_dict.leave_period.value) { - me.set_effective_date(); - } + { + fieldname: "assignment_based_on", + fieldtype: "Select", + options: ["", "Leave Period", "Joining Date"], + label: __("Assignment Based On"), + onchange: () => { + if ( + cur_dialog.fields_dict.assignment_based_on.value === "Leave Period" + ) { + cur_dialog.set_df_property("effective_from", "reqd", 1); + cur_dialog.set_df_property("effective_from", "hidden", 0); + cur_dialog.set_df_property("effective_from", "read_only", 1); + cur_dialog.set_df_property("leave_period", "reqd", 1); + cur_dialog.set_df_property("effective_to", "read_only", 1); + } else if ( + cur_dialog.fields_dict.assignment_based_on.value === "Joining Date" + ) { + cur_dialog.set_df_property("effective_from", "reqd", 0); + cur_dialog.set_df_property("effective_from", "hidden", 1); + cur_dialog.set_value("effective_from", ""); + } else { + cur_dialog.set_df_property("effective_from", "reqd", 1); + cur_dialog.set_df_property("effective_from", "hidden", 0); + cur_dialog.set_df_property("effective_from", "read_only", 0); + cur_dialog.set_df_property("leave_period", "reqd", 0); + cur_dialog.set_df_property("effective_to", "read_only", 0); + cur_dialog.set_value("effective_from", ""); + cur_dialog.set_value("effective_to", ""); + } + }, }, - get_query() { - let filters = {"is_active": 1}; - if (cur_dialog?.fields_dict?.company?.value) - filters["company"] = cur_dialog.fields_dict.company.value; + { + fieldname: "leave_period", + fieldtype: "Link", + options: "Leave Period", + label: __("Leave Period"), + depends_on: (doc) => { + return doc.assignment_based_on == "Leave Period"; + }, + onchange: () => { + if (cur_dialog.fields_dict.leave_period.value) { + me.set_effective_date(); + } + }, + get_query() { + let filters = { is_active: 1 }; + if (cur_dialog?.fields_dict?.company?.value) + filters["company"] = cur_dialog.fields_dict.company.value; - return { - filters: filters - }; + return { + filters: filters, + }; + }, + }, + { + fieldtype: "Column Break", + }, + { + fieldname: "effective_from", + fieldtype: "Date", + label: __("Effective From"), + reqd: 1, + }, + { + fieldname: "effective_to", + fieldtype: "Date", + label: __("Effective To"), + reqd: 1, + }, + { + fieldname: "carry_forward", + fieldtype: "Check", + label: __("Add unused leaves from previous allocations"), }, - }, - { - fieldtype: "Column Break" - }, - { - fieldname: 'effective_from', - fieldtype: 'Date', - label: __('Effective From'), - reqd: 1 - }, - { - fieldname: 'effective_to', - fieldtype: 'Date', - label: __('Effective To'), - reqd: 1 - }, - { - fieldname: 'carry_forward', - fieldtype: 'Check', - label: __('Add unused leaves from previous allocations') - } ], get_query() { return { filters: { - status: ['=', 'Active'] - } + status: ["=", "Active"], + }, }; }, add_filters_group: 1, primary_action_label: "Assign", action(employees, data) { frappe.call({ - method: 'hrms.hr.doctype.leave_policy_assignment.leave_policy_assignment.create_assignment_for_multiple_employees', + method: "hrms.hr.doctype.leave_policy_assignment.leave_policy_assignment.create_assignment_for_multiple_employees", async: false, args: { employees: employees, - data: data - } + data: data, + }, }); cur_dialog.hide(); - } + }, }); }); }, set_effective_date: function () { - if (cur_dialog.fields_dict.assignment_based_on.value === "Leave Period" && cur_dialog.fields_dict.leave_period.value) { - frappe.model.with_doc("Leave Period", cur_dialog.fields_dict.leave_period.value, function () { - let from_date = frappe.model.get_value("Leave Period", cur_dialog.fields_dict.leave_period.value, "from_date"); - let to_date = frappe.model.get_value("Leave Period", cur_dialog.fields_dict.leave_period.value, "to_date"); - cur_dialog.set_value("effective_from", from_date); - cur_dialog.set_value("effective_to", to_date); - }); + if ( + cur_dialog.fields_dict.assignment_based_on.value === "Leave Period" && + cur_dialog.fields_dict.leave_period.value + ) { + frappe.model.with_doc( + "Leave Period", + cur_dialog.fields_dict.leave_period.value, + function () { + let from_date = frappe.model.get_value( + "Leave Period", + cur_dialog.fields_dict.leave_period.value, + "from_date", + ); + let to_date = frappe.model.get_value( + "Leave Period", + cur_dialog.fields_dict.leave_period.value, + "to_date", + ); + cur_dialog.set_value("effective_from", from_date); + cur_dialog.set_value("effective_to", to_date); + }, + ); } - } + }, }; diff --git a/hrms/hr/doctype/leave_policy_detail/leave_policy_detail.js b/hrms/hr/doctype/leave_policy_detail/leave_policy_detail.js index ee21f8d3ae..6fb1e4f159 100644 --- a/hrms/hr/doctype/leave_policy_detail/leave_policy_detail.js +++ b/hrms/hr/doctype/leave_policy_detail/leave_policy_detail.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Leave Policy Detail', { - refresh: function(frm) { - - } +frappe.ui.form.on("Leave Policy Detail", { + refresh: function (frm) {}, }); diff --git a/hrms/hr/doctype/leave_type/leave_type.js b/hrms/hr/doctype/leave_type/leave_type.js index 6fc531cae3..c4cae2afe0 100644 --- a/hrms/hr/doctype/leave_type/leave_type.js +++ b/hrms/hr/doctype/leave_type/leave_type.js @@ -1,24 +1,28 @@ frappe.ui.form.on("Leave Type", { - refresh: function(frm) { - } + refresh: function (frm) {}, }); - frappe.tour["Leave Type"] = [ { fieldname: "max_leaves_allowed", title: "Maximum Leave Allocation Allowed", - description: __("This field allows you to set the maximum number of leaves that can be allocated annually for this Leave Type while creating the Leave Policy") + description: __( + "This field allows you to set the maximum number of leaves that can be allocated annually for this Leave Type while creating the Leave Policy", + ), }, { fieldname: "max_continuous_days_allowed", title: "Maximum Consecutive Leaves Allowed", - description: __("This field allows you to set the maximum number of consecutive leaves an Employee can apply for.") + description: __( + "This field allows you to set the maximum number of consecutive leaves an Employee can apply for.", + ), }, { fieldname: "is_optional_leave", title: "Is Optional Leave", - description: __("Optional Leaves are holidays that Employees can choose to avail from a list of holidays published by the company.") + description: __( + "Optional Leaves are holidays that Employees can choose to avail from a list of holidays published by the company.", + ), }, { fieldname: "is_compensatory", @@ -26,18 +30,22 @@ frappe.tour["Leave Type"] = [ description: __( "Leaves you can avail against a holiday you worked on. You can claim Compensatory Off Leave using Compensatory Leave Request. Click {0} to know more", [ - `${__("here")}` - ] - ) + `${__( + "here", + )}`, + ], + ), }, { fieldname: "allow_encashment", title: "Allow Encashment", - description: __("From here, you can enable encashment for the balance leaves.") + description: __("From here, you can enable encashment for the balance leaves."), }, { fieldname: "is_earned_leave", title: "Is Earned Leaves", - description: __("Earned Leaves are leaves earned by an Employee after working with the company for a certain amount of time. Enabling this will allocate leaves on pro-rata basis by automatically updating Leave Allocation for leaves of this type at intervals set by 'Earned Leave Frequency.") - } -]; \ No newline at end of file + description: __( + "Earned Leaves are leaves earned by an Employee after working with the company for a certain amount of time. Enabling this will allocate leaves on pro-rata basis by automatically updating Leave Allocation for leaves of this type at intervals set by 'Earned Leave Frequency.", + ), + }, +]; diff --git a/hrms/hr/doctype/offer_term/offer_term.js b/hrms/hr/doctype/offer_term/offer_term.js index 3be6e7b5f9..17dc120045 100644 --- a/hrms/hr/doctype/offer_term/offer_term.js +++ b/hrms/hr/doctype/offer_term/offer_term.js @@ -1,8 +1,6 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Offer Term', { - refresh: function(frm) { - - } +frappe.ui.form.on("Offer Term", { + refresh: function (frm) {}, }); diff --git a/hrms/hr/doctype/purpose_of_travel/purpose_of_travel.js b/hrms/hr/doctype/purpose_of_travel/purpose_of_travel.js index a9424d6175..948104b55c 100644 --- a/hrms/hr/doctype/purpose_of_travel/purpose_of_travel.js +++ b/hrms/hr/doctype/purpose_of_travel/purpose_of_travel.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Purpose of Travel', { - refresh: function(frm) { - - } +frappe.ui.form.on("Purpose of Travel", { + refresh: function (frm) {}, }); diff --git a/hrms/hr/doctype/shift_assignment/shift_assignment.js b/hrms/hr/doctype/shift_assignment/shift_assignment.js index 74708b1aaa..2c3d9da193 100644 --- a/hrms/hr/doctype/shift_assignment/shift_assignment.js +++ b/hrms/hr/doctype/shift_assignment/shift_assignment.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Shift Assignment', { - refresh: function(frm) { - - } +frappe.ui.form.on("Shift Assignment", { + refresh: function (frm) {}, }); diff --git a/hrms/hr/doctype/shift_assignment/shift_assignment_calendar.js b/hrms/hr/doctype/shift_assignment/shift_assignment_calendar.js index 1b80a2a7c0..d114533238 100644 --- a/hrms/hr/doctype/shift_assignment/shift_assignment_calendar.js +++ b/hrms/hr/doctype/shift_assignment/shift_assignment_calendar.js @@ -3,12 +3,12 @@ frappe.views.calendar["Shift Assignment"] = { field_map: { - "start": "start_date", - "end": "end_date", - "id": "name", - "docstatus": 1, - "allDay": "allDay", - "convertToUserTz": "convertToUserTz", + start: "start_date", + end: "end_date", + id: "name", + docstatus: 1, + allDay: "allDay", + convertToUserTz: "convertToUserTz", }, - get_events_method: "hrms.hr.doctype.shift_assignment.shift_assignment.get_events" -} + get_events_method: "hrms.hr.doctype.shift_assignment.shift_assignment.get_events", +}; diff --git a/hrms/hr/doctype/shift_request/shift_request.js b/hrms/hr/doctype/shift_request/shift_request.js index 5f939607f8..a988716736 100644 --- a/hrms/hr/doctype/shift_request/shift_request.js +++ b/hrms/hr/doctype/shift_request/shift_request.js @@ -1,15 +1,15 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Shift Request', { - setup: function(frm) { - frm.set_query("approver", function() { +frappe.ui.form.on("Shift Request", { + setup: function (frm) { + frm.set_query("approver", function () { return { query: "hrms.hr.doctype.department_approver.department_approver.get_approvers", filters: { employee: frm.doc.employee, - doctype: frm.doc.doctype - } + doctype: frm.doc.doctype, + }, }; }); frm.set_query("employee", erpnext.queries.employee); diff --git a/hrms/hr/doctype/shift_type/shift_type.js b/hrms/hr/doctype/shift_type/shift_type.js index 7138e3bcf3..e73130aaa1 100644 --- a/hrms/hr/doctype/shift_type/shift_type.js +++ b/hrms/hr/doctype/shift_type/shift_type.js @@ -1,35 +1,32 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Shift Type', { - refresh: function(frm) { - frm.add_custom_button( - __('Mark Attendance'), - () => { - if (!frm.doc.enable_auto_attendance) { - frm.scroll_to_field('enable_auto_attendance'); - frappe.throw(__('Please Enable Auto Attendance and complete the setup first.')); - } - - if (!frm.doc.process_attendance_after) { - frm.scroll_to_field('process_attendance_after'); - frappe.throw(__('Please set {0}.', [__('Process Attendance After').bold()])); - } +frappe.ui.form.on("Shift Type", { + refresh: function (frm) { + frm.add_custom_button(__("Mark Attendance"), () => { + if (!frm.doc.enable_auto_attendance) { + frm.scroll_to_field("enable_auto_attendance"); + frappe.throw(__("Please Enable Auto Attendance and complete the setup first.")); + } - if (!frm.doc.last_sync_of_checkin) { - frm.scroll_to_field('last_sync_of_checkin'); - frappe.throw(__('Please set {0}.', [__('Last Sync of Checkin').bold()])); - } + if (!frm.doc.process_attendance_after) { + frm.scroll_to_field("process_attendance_after"); + frappe.throw(__("Please set {0}.", [__("Process Attendance After").bold()])); + } - frm.call({ - doc: frm.doc, - method: 'process_auto_attendance', - freeze: true, - callback: () => { - frappe.msgprint(__('Attendance has been marked as per employee check-ins')); - } - }); + if (!frm.doc.last_sync_of_checkin) { + frm.scroll_to_field("last_sync_of_checkin"); + frappe.throw(__("Please set {0}.", [__("Last Sync of Checkin").bold()])); } - ); - } + + frm.call({ + doc: frm.doc, + method: "process_auto_attendance", + freeze: true, + callback: () => { + frappe.msgprint(__("Attendance has been marked as per employee check-ins")); + }, + }); + }); + }, }); diff --git a/hrms/hr/doctype/skill/skill.js b/hrms/hr/doctype/skill/skill.js index a939ff0dab..7f87a7d62c 100644 --- a/hrms/hr/doctype/skill/skill.js +++ b/hrms/hr/doctype/skill/skill.js @@ -1,8 +1,7 @@ // Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Skill', { +frappe.ui.form.on("Skill", { // refresh: function(frm) { - // } }); diff --git a/hrms/hr/doctype/staffing_plan/staffing_plan.js b/hrms/hr/doctype/staffing_plan/staffing_plan.js index 3542d9835e..f41f883c66 100644 --- a/hrms/hr/doctype/staffing_plan/staffing_plan.js +++ b/hrms/hr/doctype/staffing_plan/staffing_plan.js @@ -1,33 +1,31 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Staffing Plan', { - setup: function(frm) { - frm.set_query("designation", "staffing_details", function() { +frappe.ui.form.on("Staffing Plan", { + setup: function (frm) { + frm.set_query("designation", "staffing_details", function () { let designations = []; - (frm.doc.staffing_details || []).forEach(function(staff_detail) { - if(staff_detail.designation){ - designations.push(staff_detail.designation) + (frm.doc.staffing_details || []).forEach(function (staff_detail) { + if (staff_detail.designation) { + designations.push(staff_detail.designation); } - }) + }); // Filter out designations already selected in Staffing Plan Detail return { - filters: [ - ['Designation', 'name', 'not in', designations], - ] - } + filters: [["Designation", "name", "not in", designations]], + }; }); - frm.set_query("department", function() { + frm.set_query("department", function () { return { - "filters": { - "company": frm.doc.company, - } + filters: { + company: frm.doc.company, + }, }; }); }, - get_job_requisitions: function(frm) { + get_job_requisitions: function (frm) { new frappe.ui.form.MultiSelectDialog({ doctype: "Job Requisition", target: frm, @@ -41,106 +39,111 @@ frappe.ui.form.on('Staffing Plan', { let filters = { company: frm.doc.company, status: ["in", ["Pending", "Open & Approved"]], - } + }; - if (frm.doc.department) - filters.department = frm.doc.department; + if (frm.doc.department) filters.department = frm.doc.department; return { - filters: filters + filters: filters, }; }, action(selections) { const plan_name = frm.doc.__newname; - frappe.call({ - method: "set_job_requisitions", - doc: frm.doc, - args: selections, - }).then(() => { - // hack to retain prompt name that gets lost on frappe.call - frm.doc.__newname = plan_name; - refresh_field("staffing_details"); - }); + frappe + .call({ + method: "set_job_requisitions", + doc: frm.doc, + args: selections, + }) + .then(() => { + // hack to retain prompt name that gets lost on frappe.call + frm.doc.__newname = plan_name; + refresh_field("staffing_details"); + }); cur_dialog.hide(); - } + }, }); - } + }, }); -frappe.ui.form.on('Staffing Plan Detail', { - designation: function(frm, cdt, cdn) { +frappe.ui.form.on("Staffing Plan Detail", { + designation: function (frm, cdt, cdn) { let child = locals[cdt][cdn]; - if(frm.doc.company && child.designation) { + if (frm.doc.company && child.designation) { set_number_of_positions(frm, cdt, cdn); } }, - vacancies: function(frm, cdt, cdn) { + vacancies: function (frm, cdt, cdn) { let child = locals[cdt][cdn]; - if(child.vacancies < child.current_openings) { + if (child.vacancies < child.current_openings) { frappe.throw(__("Vacancies cannot be lower than the current openings")); } set_number_of_positions(frm, cdt, cdn); }, - current_count: function(frm, cdt, cdn) { + current_count: function (frm, cdt, cdn) { set_number_of_positions(frm, cdt, cdn); }, - estimated_cost_per_position: function(frm, cdt, cdn) { + estimated_cost_per_position: function (frm, cdt, cdn) { set_total_estimated_cost(frm, cdt, cdn); - } + }, }); -var set_number_of_positions = function(frm, cdt, cdn) { +var set_number_of_positions = function (frm, cdt, cdn) { let child = locals[cdt][cdn]; if (!child.designation) frappe.throw(__("Please enter the designation")); frappe.call({ - "method": "hrms.hr.doctype.staffing_plan.staffing_plan.get_designation_counts", + method: "hrms.hr.doctype.staffing_plan.staffing_plan.get_designation_counts", args: { designation: child.designation, - company: frm.doc.company + company: frm.doc.company, }, callback: function (data) { - if(data.message){ - frappe.model.set_value(cdt, cdn, 'current_count', data.message.employee_count); - frappe.model.set_value(cdt, cdn, 'current_openings', data.message.job_openings); + if (data.message) { + frappe.model.set_value(cdt, cdn, "current_count", data.message.employee_count); + frappe.model.set_value(cdt, cdn, "current_openings", data.message.job_openings); let total_positions = cint(data.message.employee_count) + cint(child.vacancies); - if (cint(child.number_of_positions) < total_positions){ - frappe.model.set_value(cdt, cdn, 'number_of_positions', total_positions); + if (cint(child.number_of_positions) < total_positions) { + frappe.model.set_value(cdt, cdn, "number_of_positions", total_positions); } + } else { + // No employees for this designation + frappe.model.set_value(cdt, cdn, "current_count", 0); + frappe.model.set_value(cdt, cdn, "current_openings", 0); } - else{ // No employees for this designation - frappe.model.set_value(cdt, cdn, 'current_count', 0); - frappe.model.set_value(cdt, cdn, 'current_openings', 0); - } - } + }, }); refresh_field("staffing_details"); set_total_estimated_cost(frm, cdt, cdn); -} +}; // Note: Estimated Cost is calculated on number of Vacancies -var set_total_estimated_cost = function(frm, cdt, cdn) { - let child = locals[cdt][cdn] - if(child.vacancies > 0 && child.estimated_cost_per_position) { - frappe.model.set_value(cdt, cdn, 'total_estimated_cost', child.vacancies * child.estimated_cost_per_position); - } - else { - frappe.model.set_value(cdt, cdn, 'total_estimated_cost', 0); +var set_total_estimated_cost = function (frm, cdt, cdn) { + let child = locals[cdt][cdn]; + if (child.vacancies > 0 && child.estimated_cost_per_position) { + frappe.model.set_value( + cdt, + cdn, + "total_estimated_cost", + child.vacancies * child.estimated_cost_per_position, + ); + } else { + frappe.model.set_value(cdt, cdn, "total_estimated_cost", 0); } set_total_estimated_budget(frm); }; -var set_total_estimated_budget = function(frm) { - let estimated_budget = 0.0 - if(frm.doc.staffing_details) { - (frm.doc.staffing_details || []).forEach(function(staff_detail) { - if(staff_detail.total_estimated_cost){ - estimated_budget += staff_detail.total_estimated_cost +var set_total_estimated_budget = function (frm) { + let estimated_budget = 0.0; + if (frm.doc.staffing_details) { + (frm.doc.staffing_details || []).forEach(function (staff_detail) { + if (staff_detail.total_estimated_cost) { + estimated_budget += staff_detail.total_estimated_cost; } - }) - frm.set_value('total_estimated_budget', estimated_budget); + }); + frm.set_value("total_estimated_budget", estimated_budget); } }; diff --git a/hrms/hr/doctype/training_event/training_event.js b/hrms/hr/doctype/training_event/training_event.js index 642e6a1fd7..50b7898cfc 100644 --- a/hrms/hr/doctype/training_event/training_event.js +++ b/hrms/hr/doctype/training_event/training_event.js @@ -1,7 +1,7 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Training Event', { +frappe.ui.form.on("Training Event", { onload_post_render: function (frm) { frm.get_field("employees").grid.set_multiple_add("employee"); }, @@ -9,13 +9,13 @@ frappe.ui.form.on('Training Event', { if (!frm.doc.__islocal) { frm.add_custom_button(__("Training Result"), function () { frappe.route_options = { - training_event: frm.doc.name + training_event: frm.doc.name, }; frappe.set_route("List", "Training Result"); }); frm.add_custom_button(__("Training Feedback"), function () { frappe.route_options = { - training_event: frm.doc.name + training_event: frm.doc.name, }; frappe.set_route("List", "Training Feedback"); }); @@ -23,7 +23,7 @@ frappe.ui.form.on('Training Event', { frm.events.set_employee_query(frm); }, - set_employee_query: function(frm) { + set_employee_query: function (frm) { let emp = []; for (let d in frm.doc.employees) { if (frm.doc.employees[d].employee) { @@ -34,15 +34,15 @@ frappe.ui.form.on('Training Event', { return { filters: { name: ["NOT IN", emp], - status: "Active" - } + status: "Active", + }, }; }); - } + }, }); frappe.ui.form.on("Training Event Employee", { - employee: function(frm) { + employee: function (frm) { frm.events.set_employee_query(frm); - } + }, }); diff --git a/hrms/hr/doctype/training_event/training_event_calendar.js b/hrms/hr/doctype/training_event/training_event_calendar.js index cb168c01d5..96c3232ae1 100644 --- a/hrms/hr/doctype/training_event/training_event_calendar.js +++ b/hrms/hr/doctype/training_event/training_event_calendar.js @@ -3,12 +3,12 @@ frappe.views.calendar["Training Event"] = { field_map: { - "start": "start_time", - "end": "end_time", - "id": "name", - "title": "event_name", - "allDay": "allDay" + start: "start_time", + end: "end_time", + id: "name", + title: "event_name", + allDay: "allDay", }, gantt: true, get_events_method: "frappe.desk.calendar.get_events", -} +}; diff --git a/hrms/hr/doctype/training_feedback/training_feedback.js b/hrms/hr/doctype/training_feedback/training_feedback.js index 5e875c1b43..abf338a6a2 100644 --- a/hrms/hr/doctype/training_feedback/training_feedback.js +++ b/hrms/hr/doctype/training_feedback/training_feedback.js @@ -1,10 +1,10 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Training Feedback', { - onload: function(frm) { +frappe.ui.form.on("Training Feedback", { + onload: function (frm) { frm.add_fetch("training_event", "course", "course"); frm.add_fetch("training_event", "event_name", "event_name"); frm.add_fetch("training_event", "trainer_name", "trainer_name"); - } + }, }); diff --git a/hrms/hr/doctype/training_program/training_program.js b/hrms/hr/doctype/training_program/training_program.js index a4ccf54063..c15678dbfa 100644 --- a/hrms/hr/doctype/training_program/training_program.js +++ b/hrms/hr/doctype/training_program/training_program.js @@ -1,5 +1,4 @@ // Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Training Program', { -}); +frappe.ui.form.on("Training Program", {}); diff --git a/hrms/hr/doctype/training_result/training_result.js b/hrms/hr/doctype/training_result/training_result.js index a8358a051f..4906650df8 100644 --- a/hrms/hr/doctype/training_result/training_result.js +++ b/hrms/hr/doctype/training_result/training_result.js @@ -1,34 +1,38 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Training Result', { - onload: function(frm) { +frappe.ui.form.on("Training Result", { + onload: function (frm) { frm.trigger("training_event"); }, - training_event: function(frm) { + training_event: function (frm) { frm.trigger("training_event"); }, - training_event: function(frm) { + training_event: function (frm) { if (frm.doc.training_event && !frm.doc.docstatus && !frm.doc.employees) { frappe.call({ method: "hrms.hr.doctype.training_result.training_result.get_employees", args: { - "training_event": frm.doc.training_event + training_event: frm.doc.training_event, }, - callback: function(r) { - frm.set_value("employees" ,""); + callback: function (r) { + frm.set_value("employees", ""); if (r.message) { - $.each(r.message, function(i, d) { - var row = frappe.model.add_child(frm.doc, "Training Result Employee", "employees"); + $.each(r.message, function (i, d) { + var row = frappe.model.add_child( + frm.doc, + "Training Result Employee", + "employees", + ); row.employee = d.employee; row.employee_name = d.employee_name; }); } refresh_field("employees"); - } + }, }); } - } + }, }); diff --git a/hrms/hr/doctype/travel_request/travel_request.js b/hrms/hr/doctype/travel_request/travel_request.js index 9dd48eb38e..05eb0d0ebf 100644 --- a/hrms/hr/doctype/travel_request/travel_request.js +++ b/hrms/hr/doctype/travel_request/travel_request.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Travel Request', { - refresh: function(frm) { - - } +frappe.ui.form.on("Travel Request", { + refresh: function (frm) {}, }); diff --git a/hrms/hr/doctype/upload_attendance/upload_attendance.js b/hrms/hr/doctype/upload_attendance/upload_attendance.js index cd5c15b841..99ae709947 100644 --- a/hrms/hr/doctype/upload_attendance/upload_attendance.js +++ b/hrms/hr/doctype/upload_attendance/upload_attendance.js @@ -1,8 +1,6 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt - - frappe.provide("hrms.hr"); hrms.hr.AttendanceControlPanel = class AttendanceControlPanel extends frappe.ui.form.Controller { @@ -18,52 +16,60 @@ hrms.hr.AttendanceControlPanel = class AttendanceControlPanel extends frappe.ui. } get_template() { - if(!this.frm.doc.att_fr_date || !this.frm.doc.att_to_date) { + if (!this.frm.doc.att_fr_date || !this.frm.doc.att_to_date) { frappe.msgprint(__("Attendance From Date and Attendance To Date is mandatory")); return; } - window.location.href = repl(frappe.request.url + - '?cmd=%(cmd)s&from_date=%(from_date)s&to_date=%(to_date)s', { - cmd: "hrms.hr.doctype.upload_attendance.upload_attendance.get_template", - from_date: this.frm.doc.att_fr_date, - to_date: this.frm.doc.att_to_date, - }); + window.location.href = repl( + frappe.request.url + "?cmd=%(cmd)s&from_date=%(from_date)s&to_date=%(to_date)s", + { + cmd: "hrms.hr.doctype.upload_attendance.upload_attendance.get_template", + from_date: this.frm.doc.att_fr_date, + to_date: this.frm.doc.att_to_date, + }, + ); } show_upload() { var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty(); new frappe.ui.FileUploader({ wrapper: $wrapper, - method: 'hrms.hr.doctype.upload_attendance.upload_attendance.upload' + method: "hrms.hr.doctype.upload_attendance.upload_attendance.upload", }); } setup_import_progress() { var $log_wrapper = $(this.frm.fields_dict.import_log.wrapper).empty(); - frappe.realtime.on('import_attendance', (data) => { + frappe.realtime.on("import_attendance", (data) => { if (data.progress) { - this.frm.dashboard.show_progress('Import Attendance', data.progress / data.total * 100, - __('Importing {0} of {1}', [data.progress, data.total])); + this.frm.dashboard.show_progress( + "Import Attendance", + (data.progress / data.total) * 100, + __("Importing {0} of {1}", [data.progress, data.total]), + ); if (data.progress === data.total) { - this.frm.dashboard.hide_progress('Import Attendance'); + this.frm.dashboard.hide_progress("Import Attendance"); } } else if (data.error) { this.frm.dashboard.hide(); - let messages = [`${__('Error in some rows')}`].concat(data.messages - .filter(message => message.includes('Error')) - .map(message => `${message}`)) - .join(''); + let messages = [`${__("Error in some rows")}`] + .concat( + data.messages + .filter((message) => message.includes("Error")) + .map((message) => `${message}`), + ) + .join(""); $log_wrapper.append('' + messages); } else if (data.messages) { this.frm.dashboard.hide(); - let messages = [``].concat(data.messages - .map(message => ``)) - .join(''); + let messages = [``] + .concat(data.messages.map((message) => ``)) + .join(""); $log_wrapper.append('
${__('Import Successful')}
${message}
${__("Import Successful")}
${message}
' + messages); } }); } -} +}; -cur_frm.cscript = new hrms.hr.AttendanceControlPanel({frm: cur_frm}); +cur_frm.cscript = new hrms.hr.AttendanceControlPanel({ frm: cur_frm }); diff --git a/hrms/hr/doctype/vehicle_log/vehicle_log.js b/hrms/hr/doctype/vehicle_log/vehicle_log.js index 25e6f937df..1a544594fd 100644 --- a/hrms/hr/doctype/vehicle_log/vehicle_log.js +++ b/hrms/hr/doctype/vehicle_log/vehicle_log.js @@ -3,7 +3,7 @@ frappe.ui.form.on("Vehicle Log", { setup: function (frm) { - frm.set_query("employee", function() { + frm.set_query("employee", function () { return { filters: { status: "Active", @@ -11,25 +11,29 @@ frappe.ui.form.on("Vehicle Log", { }; }); }, - refresh: function(frm) { - if(frm.doc.docstatus == 1) { - frm.add_custom_button(__('Expense Claim'), function() { - frm.events.expense_claim(frm); - }, __('Create')); - frm.page.set_inner_btn_group_as_primary(__('Create')); + refresh: function (frm) { + if (frm.doc.docstatus == 1) { + frm.add_custom_button( + __("Expense Claim"), + function () { + frm.events.expense_claim(frm); + }, + __("Create"), + ); + frm.page.set_inner_btn_group_as_primary(__("Create")); } }, - expense_claim: function(frm){ + expense_claim: function (frm) { frappe.call({ method: "hrms.hr.doctype.vehicle_log.vehicle_log.make_expense_claim", - args:{ - docname: frm.doc.name + args: { + docname: frm.doc.name, }, - callback: function(r){ + callback: function (r) { var doc = frappe.model.sync(r.message); - frappe.set_route('Form', 'Expense Claim', r.message.name); - } + frappe.set_route("Form", "Expense Claim", r.message.name); + }, }); - } + }, }); diff --git a/hrms/hr/doctype/vehicle_service_item/vehicle_service_item.js b/hrms/hr/doctype/vehicle_service_item/vehicle_service_item.js index 2b975a2a62..f7fe37bbb7 100644 --- a/hrms/hr/doctype/vehicle_service_item/vehicle_service_item.js +++ b/hrms/hr/doctype/vehicle_service_item/vehicle_service_item.js @@ -1,8 +1,7 @@ // Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Vehicle Service Item', { +frappe.ui.form.on("Vehicle Service Item", { // refresh: function(frm) { - // } }); diff --git a/hrms/hr/employee_property_update.js b/hrms/hr/employee_property_update.js index 887b9065c4..cb3e891212 100644 --- a/hrms/hr/employee_property_update.js +++ b/hrms/hr/employee_property_update.js @@ -1,32 +1,31 @@ frappe.ui.form.on(cur_frm.doctype, { - setup: function(frm) { - frm.set_query("employee", function() { + setup: function (frm) { + frm.set_query("employee", function () { return { filters: { - "status": "Active" - } + status: "Active", + }, }; }); }, - onload: function(frm) { - if (frm.doc.__islocal && !frm.doc.amended_from) - frm.trigger("clear_property_table"); + onload: function (frm) { + if (frm.doc.__islocal && !frm.doc.amended_from) frm.trigger("clear_property_table"); }, - employee: function(frm) { + employee: function (frm) { frm.trigger("clear_property_table"); }, - clear_property_table: function(frm) { - let table = (frm.doctype == "Employee Promotion") ? "promotion_details" : "transfer_details"; + clear_property_table: function (frm) { + let table = frm.doctype == "Employee Promotion" ? "promotion_details" : "transfer_details"; frm.clear_table(table); frm.refresh_field(table); frm.fields_dict[table].grid.wrapper.find(".grid-add-row").hide(); }, - refresh: function(frm) { + refresh: function (frm) { let table; if (frm.doctype == "Employee Promotion") { table = "promotion_details"; @@ -34,14 +33,13 @@ frappe.ui.form.on(cur_frm.doctype, { table = "transfer_details"; } - if (!table) - return; + if (!table) return; frm.fields_dict[table].grid.wrapper.find(".grid-add-row").hide(); frm.events.setup_employee_property_button(frm, table); }, - setup_employee_property_button: function(frm, table) { + setup_employee_property_button: function (frm, table) { frm.fields_dict[table].grid.add_custom_button(__("Add Employee Property"), () => { if (!frm.doc.employee) { frappe.msgprint(__("Please select Employee first.")); @@ -49,20 +47,45 @@ frappe.ui.form.on(cur_frm.doctype, { } const allowed_fields = []; - const exclude_fields = ["naming_series", "employee", "first_name", "middle_name", "last_name", "marital_status", "ctc", - "employee_name", "status", "image", "gender", "date_of_birth", "date_of_joining", "lft", "rgt", "old_parent"]; - - const exclude_field_types = ["HTML", "Section Break", "Column Break", "Button", "Read Only", "Tab Break", "Table"]; + const exclude_fields = [ + "naming_series", + "employee", + "first_name", + "middle_name", + "last_name", + "marital_status", + "ctc", + "employee_name", + "status", + "image", + "gender", + "date_of_birth", + "date_of_joining", + "lft", + "rgt", + "old_parent", + ]; + + const exclude_field_types = [ + "HTML", + "Section Break", + "Column Break", + "Button", + "Read Only", + "Tab Break", + "Table", + ]; frappe.model.with_doctype("Employee", () => { const field_label_map = {}; - frappe.get_meta("Employee").fields.forEach(d => { - field_label_map[d.fieldname] = __(d.label, null, d.parent) + ` (${d.fieldname})`; + frappe.get_meta("Employee").fields.forEach((d) => { + field_label_map[d.fieldname] = + __(d.label, null, d.parent) + ` (${d.fieldname})`; if ( - !in_list(exclude_field_types, d.fieldtype) - && !in_list(exclude_fields, d.fieldname) - && !d.hidden - && !d.read_only + !in_list(exclude_field_types, d.fieldtype) && + !in_list(exclude_fields, d.fieldname) && + !d.hidden && + !d.read_only ) { allowed_fields.push({ label: field_label_map[d.fieldname], @@ -74,16 +97,21 @@ frappe.ui.form.on(cur_frm.doctype, { show_dialog(frm, table, allowed_fields); }); }); - } + }, }); -var show_dialog = function(frm, table, field_labels) { +var show_dialog = function (frm, table, field_labels) { var d = new frappe.ui.Dialog({ title: "Update Property", fields: [ - {fieldname: "property", label: __("Select Property"), fieldtype: "Autocomplete", options: field_labels}, - {fieldname: "current", fieldtype: "Data", label: __("Current"), read_only: true}, - {fieldname: "new_value", fieldtype: "Data", label: __("New")} + { + fieldname: "property", + label: __("Select Property"), + fieldtype: "Autocomplete", + options: field_labels, + }, + { fieldname: "current", fieldtype: "Data", label: __("Current"), read_only: true }, + { fieldname: "new_value", fieldtype: "Data", label: __("New") }, ], primary_action_label: __("Add to Details"), primary_action: () => { @@ -92,58 +120,60 @@ var show_dialog = function(frm, table, field_labels) { d.data.new = d.get_values().new_value; add_to_details(frm, d, table); } - } + }, }); d.fields_dict["property"].df.onchange = () => { let property = d.get_values().property; d.data.fieldname = property; - if(!property){return;} + if (!property) { + return; + } frappe.call({ - method: 'hrms.hr.utils.get_employee_field_property', - args: {employee: frm.doc.employee, fieldname: property}, - callback: function(r) { + method: "hrms.hr.utils.get_employee_field_property", + args: { employee: frm.doc.employee, fieldname: property }, + callback: function (r) { if (r.message) { d.data.current = r.message.value; d.data.property = r.message.label; - d.set_value('current', r.message.value); + d.set_value("current", r.message.value); render_dynamic_field(d, r.message.datatype, r.message.options, property); - d.get_primary_btn().attr('disabled', false); + d.get_primary_btn().attr("disabled", false); } - } + }, }); }; - d.get_primary_btn().attr('disabled', true); + d.get_primary_btn().attr("disabled", true); d.data = {}; d.show(); }; -var render_dynamic_field = function(d, fieldtype, options, fieldname) { +var render_dynamic_field = function (d, fieldtype, options, fieldname) { d.data.new = null; var dynamic_field = frappe.ui.form.make_control({ df: { - "fieldtype": fieldtype, - "fieldname": fieldname, - "options": options || '', - "label": __("New") + fieldtype: fieldtype, + fieldname: fieldname, + options: options || "", + label: __("New"), }, parent: d.fields_dict.new_value.wrapper, - only_input: false + only_input: false, }); dynamic_field.make_input(); d.replace_field("new_value", dynamic_field.df); }; -var add_to_details = function(frm, d, table) { +var add_to_details = function (frm, d, table) { let data = d.data; if (data.fieldname) { if (validate_duplicate(frm, table, data.fieldname)) { - frappe.show_alert({message: __("Property already added"), indicator: "orange"}); + frappe.show_alert({ message: __("Property already added"), indicator: "orange" }); return false; } if (data.current == data.new) { - frappe.show_alert({message: __("Nothing to change"), indicator: "orange"}); + frappe.show_alert({ message: __("Nothing to change"), indicator: "orange" }); d.get_primary_btn().attr("disabled", false); return false; } @@ -151,7 +181,7 @@ var add_to_details = function(frm, d, table) { fieldname: data.fieldname, property: data.property, current: data.current, - new: data.new + new: data.new, }); frm.refresh_field(table); @@ -160,17 +190,17 @@ var add_to_details = function(frm, d, table) { d.fields_dict.new_value.$wrapper.html(""); d.set_value("property", ""); d.set_value("current", ""); - frappe.show_alert({message: __("Added to details"), indicator: "green"}); + frappe.show_alert({ message: __("Added to details"), indicator: "green" }); d.data = {}; } else { - frappe.show_alert({message: __("Value missing"), indicator: "red"}); + frappe.show_alert({ message: __("Value missing"), indicator: "red" }); } }; -var validate_duplicate = function(frm, table, fieldname){ +var validate_duplicate = function (frm, table, fieldname) { let duplicate = false; - $.each(frm.doc[table], function(i, detail) { - if(detail.fieldname === fieldname){ + $.each(frm.doc[table], function (i, detail) { + if (detail.fieldname === fieldname) { duplicate = true; return; } diff --git a/hrms/hr/page/organizational_chart/organizational_chart.js b/hrms/hr/page/organizational_chart/organizational_chart.js index c526f562b9..7d01fabbc3 100644 --- a/hrms/hr/page/organizational_chart/organizational_chart.js +++ b/hrms/hr/page/organizational_chart/organizational_chart.js @@ -1,22 +1,26 @@ -frappe.pages['organizational-chart'].on_page_load = function(wrapper) { +frappe.pages["organizational-chart"].on_page_load = function (wrapper) { frappe.ui.make_app_page({ parent: wrapper, - title: __('Organizational Chart'), - single_column: true + title: __("Organizational Chart"), + single_column: true, }); - $(wrapper).bind('show', () => { - frappe.require('hierarchy-chart.bundle.js', () => { + $(wrapper).bind("show", () => { + frappe.require("hierarchy-chart.bundle.js", () => { let organizational_chart; - let method = 'hrms.hr.page.organizational_chart.organizational_chart.get_children'; + let method = "hrms.hr.page.organizational_chart.organizational_chart.get_children"; if (frappe.is_mobile()) { - organizational_chart = new erpnext.HierarchyChartMobile('Employee', wrapper, method); + organizational_chart = new erpnext.HierarchyChartMobile( + "Employee", + wrapper, + method, + ); } else { - organizational_chart = new erpnext.HierarchyChart('Employee', wrapper, method); + organizational_chart = new erpnext.HierarchyChart("Employee", wrapper, method); } - frappe.breadcrumbs.add('HR'); + frappe.breadcrumbs.add("HR"); organizational_chart.show(); }); }); diff --git a/hrms/hr/page/team_updates/team_updates.css b/hrms/hr/page/team_updates/team_updates.css index d37e7826b1..9fe2de8b6e 100644 --- a/hrms/hr/page/team_updates/team_updates.css +++ b/hrms/hr/page/team_updates/team_updates.css @@ -1,17 +1,17 @@ .date-indicator { - background:none; - font-size:12px; - vertical-align:middle; - font-weight:bold; - color:#6c7680; + background: none; + font-size: 12px; + vertical-align: middle; + font-weight: bold; + color: #6c7680; } .date-indicator::after { - margin:0 -4px 0 12px; - content:''; - display:inline-block; - height:8px; - width:8px; - border-radius:8px; + margin: 0 -4px 0 12px; + content: ""; + display: inline-block; + height: 8px; + width: 8px; + border-radius: 8px; background: #d1d8dd; } diff --git a/hrms/hr/page/team_updates/team_updates.js b/hrms/hr/page/team_updates/team_updates.js index 3ea7946a5e..8973d538c1 100644 --- a/hrms/hr/page/team_updates/team_updates.js +++ b/hrms/hr/page/team_updates/team_updates.js @@ -1,53 +1,58 @@ -frappe.pages['team-updates'].on_page_load = function(wrapper) { +frappe.pages["team-updates"].on_page_load = function (wrapper) { var page = frappe.ui.make_app_page({ parent: wrapper, - title: __('Team Updates'), - single_column: true + title: __("Team Updates"), + single_column: true, }); frappe.team_updates.make(page); frappe.team_updates.run(); - if(frappe.model.can_read('Daily Work Summary Group')) { - page.add_menu_item(__('Daily Work Summary Group'), function() { - frappe.set_route('Form', 'Daily Work Summary Group'); + if (frappe.model.can_read("Daily Work Summary Group")) { + page.add_menu_item(__("Daily Work Summary Group"), function () { + frappe.set_route("Form", "Daily Work Summary Group"); }); } -} +}; frappe.team_updates = { start: 0, - make: function(page) { + make: function (page) { var me = frappe.team_updates; me.page = page; - me.body = $('
').appendTo(me.page.main); - me.more = $('
').appendTo(me.page.main) - .find('.btn-more').on('click', function() { + me.body = $("
").appendTo(me.page.main); + me.more = $( + '
", + ) + .appendTo(me.page.main) + .find(".btn-more") + .on("click", function () { me.start += 40; me.run(); }); }, - run: function() { + run: function () { var me = frappe.team_updates; frappe.call({ - method: 'hrms.hr.page.team_updates.team_updates.get_data', + method: "hrms.hr.page.team_updates.team_updates.get_data", args: { - start: me.start + start: me.start, }, - callback: function(r) { + callback: function (r) { if (r.message && r.message.length > 0) { - r.message.forEach(function(d) { + r.message.forEach(function (d) { me.add_row(d); }); } else { - frappe.show_alert({message: __('No more updates'), indicator: 'gray'}); - me.more.parent().addClass('hidden'); + frappe.show_alert({ message: __("No more updates"), indicator: "gray" }); + me.more.parent().addClass("hidden"); } - } + }, }); }, - add_row: function(data) { + add_row: function (data) { var me = frappe.team_updates; data.by = frappe.user.full_name(data.sender); @@ -57,24 +62,30 @@ frappe.team_updates = { var date = frappe.datetime.str_to_obj(data.creation); var last = me.last_feed_date; - if((last && frappe.datetime.obj_to_str(last) != frappe.datetime.obj_to_str(date)) || (!last)) { - var diff = frappe.datetime.get_day_diff(frappe.datetime.get_today(), frappe.datetime.obj_to_str(date)); + if ( + (last && frappe.datetime.obj_to_str(last) != frappe.datetime.obj_to_str(date)) || + !last + ) { + var diff = frappe.datetime.get_day_diff( + frappe.datetime.get_today(), + frappe.datetime.obj_to_str(date), + ); var pdate; - if(diff < 1) { - pdate = 'Today'; - } else if(diff < 2) { - pdate = 'Yesterday'; + if (diff < 1) { + pdate = "Today"; + } else if (diff < 2) { + pdate = "Yesterday"; } else { pdate = frappe.datetime.global_date_format(date); } data.date_sep = pdate; - data.date_class = pdate=='Today' ? "date-indicator blue" : "date-indicator"; + data.date_class = pdate == "Today" ? "date-indicator blue" : "date-indicator"; } else { data.date_sep = null; data.date_class = ""; } me.last_feed_date = date; - $(frappe.render_template('team_update_row', data)).appendTo(me.body); - } -} + $(frappe.render_template("team_update_row", data)).appendTo(me.body); + }, +}; diff --git a/hrms/hr/report/appraisal_overview/appraisal_overview.js b/hrms/hr/report/appraisal_overview/appraisal_overview.js index 858f20ba87..61cbd33911 100644 --- a/hrms/hr/report/appraisal_overview/appraisal_overview.js +++ b/hrms/hr/report/appraisal_overview/appraisal_overview.js @@ -5,36 +5,36 @@ frappe.query_reports["Appraisal Overview"] = { filters: [ { - "fieldname": "company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "reqd": 1, - "default": frappe.defaults.get_user_default("Company"), + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + reqd: 1, + default: frappe.defaults.get_user_default("Company"), }, { - "fieldname": "appraisal_cycle", - "fieldtype": "Link", - "label": __("Appraisal Cycle"), - "options": "Appraisal Cycle", + fieldname: "appraisal_cycle", + fieldtype: "Link", + label: __("Appraisal Cycle"), + options: "Appraisal Cycle", }, { - "fieldname": "employee", - "fieldtype": "Link", - "label": __("Employee"), - "options": "Employee", + fieldname: "employee", + fieldtype: "Link", + label: __("Employee"), + options: "Employee", }, { - "fieldname": "department", - "label": __("Department"), - "fieldtype": "Link", - "options": "Department" + fieldname: "department", + label: __("Department"), + fieldtype: "Link", + options: "Department", }, { - "fieldname": "designation", - "label": __("Designation"), - "fieldtype": "Link", - "options": "Designation" + fieldname: "designation", + label: __("Designation"), + fieldtype: "Link", + options: "Designation", }, - ] + ], }; diff --git a/hrms/hr/report/daily_work_summary_replies/daily_work_summary_replies.js b/hrms/hr/report/daily_work_summary_replies/daily_work_summary_replies.js index 0980c6957b..2b477fb02e 100644 --- a/hrms/hr/report/daily_work_summary_replies/daily_work_summary_replies.js +++ b/hrms/hr/report/daily_work_summary_replies/daily_work_summary_replies.js @@ -3,19 +3,19 @@ /* eslint-disable */ frappe.query_reports["Daily Work Summary Replies"] = { - "filters": [ + filters: [ { - "fieldname":"group", - "label": __("Group"), - "fieldtype": "Link", - "options": "Daily Work Summary Group", - "reqd": 1 + fieldname: "group", + label: __("Group"), + fieldtype: "Link", + options: "Daily Work Summary Group", + reqd: 1, }, { - "fieldname": "range", - "label": __("Date Range"), - "fieldtype": "DateRange", - "reqd": 1 - } - ] -} + fieldname: "range", + label: __("Date Range"), + fieldtype: "DateRange", + reqd: 1, + }, + ], +}; diff --git a/hrms/hr/report/employee_advance_summary/employee_advance_summary.js b/hrms/hr/report/employee_advance_summary/employee_advance_summary.js index 8de4af5d4f..68178eb843 100644 --- a/hrms/hr/report/employee_advance_summary/employee_advance_summary.js +++ b/hrms/hr/report/employee_advance_summary/employee_advance_summary.js @@ -3,38 +3,38 @@ /* eslint-disable */ frappe.query_reports["Employee Advance Summary"] = { - "filters": [ + filters: [ { - "fieldname":"employee", - "label": __("Employee"), - "fieldtype": "Link", - "options": "Employee", - "width": "80" + fieldname: "employee", + label: __("Employee"), + fieldtype: "Link", + options: "Employee", + width: "80", }, { - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", - "default": frappe.defaults.get_user_default("year_start_date"), - "width": "80" + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + default: frappe.defaults.get_user_default("year_start_date"), + width: "80", }, { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", - "default": frappe.datetime.get_today() + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + default: frappe.datetime.get_today(), }, { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company" + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", }, { - "fieldname":"status", - "label": __("Status"), - "fieldtype": "Select", - "options": "\nDraft\nPaid\nUnpaid\nClaimed\nCancelled" - } - ] + fieldname: "status", + label: __("Status"), + fieldtype: "Select", + options: "\nDraft\nPaid\nUnpaid\nClaimed\nCancelled", + }, + ], }; diff --git a/hrms/hr/report/employee_analytics/employee_analytics.js b/hrms/hr/report/employee_analytics/employee_analytics.js index 8620a65a90..63564f45cc 100644 --- a/hrms/hr/report/employee_analytics/employee_analytics.js +++ b/hrms/hr/report/employee_analytics/employee_analytics.js @@ -3,21 +3,21 @@ /* eslint-disable */ frappe.query_reports["Employee Analytics"] = { - "filters": [ + filters: [ { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "reqd": 1 + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + reqd: 1, }, { - "fieldname":"parameter", - "label": __("Parameter"), - "fieldtype": "Select", - "options": ["Branch","Grade","Department","Designation", "Employment Type"], - "reqd": 1 - } - ] + fieldname: "parameter", + label: __("Parameter"), + fieldtype: "Select", + options: ["Branch", "Grade", "Department", "Designation", "Employment Type"], + reqd: 1, + }, + ], }; diff --git a/hrms/hr/report/employee_birthday/employee_birthday.js b/hrms/hr/report/employee_birthday/employee_birthday.js index bbe4a8d179..6ce733aaae 100644 --- a/hrms/hr/report/employee_birthday/employee_birthday.js +++ b/hrms/hr/report/employee_birthday/employee_birthday.js @@ -2,21 +2,33 @@ // License: GNU General Public License v3. See license.txt frappe.query_reports["Employee Birthday"] = { - "filters": [ + filters: [ { - "fieldname":"month", - "label": __("Month"), - "fieldtype": "Select", - "options": "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec", - "default": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", - "Dec"][frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth()], + fieldname: "month", + label: __("Month"), + fieldtype: "Select", + options: "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec", + default: [ + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec", + ][frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth()], }, { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company") - } - ] -} + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + }, + ], +}; diff --git a/hrms/hr/report/employee_exits/employee_exits.js b/hrms/hr/report/employee_exits/employee_exits.js index ac677d87e7..a85be5a0de 100644 --- a/hrms/hr/report/employee_exits/employee_exits.js +++ b/hrms/hr/report/employee_exits/employee_exits.js @@ -5,73 +5,73 @@ frappe.query_reports["Employee Exits"] = { filters: [ { - "fieldname": "from_date", - "label": __("From Date"), - "fieldtype": "Date", - "default": frappe.datetime.add_months(frappe.datetime.nowdate(), -12) + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + default: frappe.datetime.add_months(frappe.datetime.nowdate(), -12), }, { - "fieldname": "to_date", - "label": __("To Date"), - "fieldtype": "Date", - "default": frappe.datetime.nowdate() + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + default: frappe.datetime.nowdate(), }, { - "fieldname": "company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company" + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", }, { - "fieldname": "department", - "label": __("Department"), - "fieldtype": "Link", - "options": "Department" + fieldname: "department", + label: __("Department"), + fieldtype: "Link", + options: "Department", }, { - "fieldname": "designation", - "label": __("Designation"), - "fieldtype": "Link", - "options": "Designation" + fieldname: "designation", + label: __("Designation"), + fieldtype: "Link", + options: "Designation", }, { - "fieldname": "employee", - "label": __("Employee"), - "fieldtype": "Link", - "options": "Employee" + fieldname: "employee", + label: __("Employee"), + fieldtype: "Link", + options: "Employee", }, { - "fieldname": "reports_to", - "label": __("Reports To"), - "fieldtype": "Link", - "options": "Employee" + fieldname: "reports_to", + label: __("Reports To"), + fieldtype: "Link", + options: "Employee", }, { - "fieldname": "interview_status", - "label": __("Interview Status"), - "fieldtype": "Select", - "options": ["", "Pending", "Scheduled", "Completed"] + fieldname: "interview_status", + label: __("Interview Status"), + fieldtype: "Select", + options: ["", "Pending", "Scheduled", "Completed"], }, { - "fieldname": "final_decision", - "label": __("Final Decision"), - "fieldtype": "Select", - "options": ["", "Employee Retained", "Exit Confirmed"] + fieldname: "final_decision", + label: __("Final Decision"), + fieldtype: "Select", + options: ["", "Employee Retained", "Exit Confirmed"], }, { - "fieldname": "exit_interview_pending", - "label": __("Exit Interview Pending"), - "fieldtype": "Check" + fieldname: "exit_interview_pending", + label: __("Exit Interview Pending"), + fieldtype: "Check", }, { - "fieldname": "questionnaire_pending", - "label": __("Exit Questionnaire Pending"), - "fieldtype": "Check" + fieldname: "questionnaire_pending", + label: __("Exit Questionnaire Pending"), + fieldtype: "Check", }, { - "fieldname": "fnf_pending", - "label": __("FnF Pending"), - "fieldtype": "Check" - } - ] + fieldname: "fnf_pending", + label: __("FnF Pending"), + fieldtype: "Check", + }, + ], }; diff --git a/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.js b/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.js index 9a30b99f9b..9b45702f49 100644 --- a/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.js +++ b/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.js @@ -3,46 +3,46 @@ /* eslint-disable */ frappe.query_reports["Employee Hours Utilization Based On Timesheet"] = { - "filters": [ + filters: [ { fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", default: frappe.defaults.get_user_default("Company"), - reqd: 1 + reqd: 1, }, { fieldname: "from_date", label: __("From Date"), fieldtype: "Date", default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), - reqd: 1 + reqd: 1, }, { - fieldname:"to_date", + fieldname: "to_date", label: __("To Date"), fieldtype: "Date", default: frappe.datetime.now_date(), - reqd: 1 + reqd: 1, }, { fieldname: "employee", label: __("Employee"), fieldtype: "Link", - options: "Employee" + options: "Employee", }, { fieldname: "department", label: __("Department"), fieldtype: "Link", - options: "Department" + options: "Department", }, { fieldname: "project", label: __("Project"), fieldtype: "Link", - options: "Project" - } - ] + options: "Project", + }, + ], }; diff --git a/hrms/hr/report/employee_leave_balance/employee_leave_balance.js b/hrms/hr/report/employee_leave_balance/employee_leave_balance.js index 317fdd5dc2..b87e60e13e 100644 --- a/hrms/hr/report/employee_leave_balance/employee_leave_balance.js +++ b/hrms/hr/report/employee_leave_balance/employee_leave_balance.js @@ -8,14 +8,14 @@ frappe.query_reports["Employee Leave Balance"] = { label: __("From Date"), fieldtype: "Date", reqd: 1, - default: frappe.defaults.get_default("year_start_date") + default: frappe.defaults.get_default("year_start_date"), }, { fieldname: "to_date", label: __("To Date"), fieldtype: "Date", reqd: 1, - default: frappe.defaults.get_default("year_end_date") + default: frappe.defaults.get_default("year_end_date"), }, { label: __("Company"), @@ -23,7 +23,7 @@ frappe.query_reports["Employee Leave Balance"] = { fieldtype: "Link", options: "Company", reqd: 1, - default: frappe.defaults.get_user_default("Company") + default: frappe.defaults.get_user_default("Company"), }, { fieldname: "department", @@ -56,7 +56,7 @@ frappe.query_reports["Employee Leave Balance"] = { fieldtype: "Check", default: 1, depends_on: "eval: !doc.employee", - } + }, ], onload: () => { const today = frappe.datetime.now_date(); @@ -65,15 +65,15 @@ frappe.query_reports["Employee Leave Balance"] = { type: "GET", method: "hrms.hr.utils.get_leave_period", args: { - "from_date": today, - "to_date": today, - "company": frappe.defaults.get_user_default("Company") + from_date: today, + to_date: today, + company: frappe.defaults.get_user_default("Company"), }, freeze: true, callback: (data) => { frappe.query_report.set_filter_value("from_date", data.message[0].from_date); frappe.query_report.set_filter_value("to_date", data.message[0].to_date); - } + }, }); - } -} + }, +}; diff --git a/hrms/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.js b/hrms/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.js index 26dd782533..1e10ec4938 100644 --- a/hrms/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.js +++ b/hrms/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.js @@ -2,34 +2,34 @@ // For license information, please see license.txt /* eslint-disable */ -frappe.query_reports['Employee Leave Balance Summary'] = { +frappe.query_reports["Employee Leave Balance Summary"] = { filters: [ { - fieldname:'date', - label: __('Date'), - fieldtype: 'Date', + fieldname: "date", + label: __("Date"), + fieldtype: "Date", reqd: 1, - default: frappe.datetime.now_date() + default: frappe.datetime.now_date(), }, { - fieldname:'company', - label: __('Company'), - fieldtype: 'Link', - options: 'Company', + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", reqd: 1, - default: frappe.defaults.get_user_default('Company') + default: frappe.defaults.get_user_default("Company"), }, { - fieldname:'employee', - label: __('Employee'), - fieldtype: 'Link', - options: 'Employee', + fieldname: "employee", + label: __("Employee"), + fieldtype: "Link", + options: "Employee", }, { - fieldname:'department', - label: __('Department'), - fieldtype: 'Link', - options: 'Department', + fieldname: "department", + label: __("Department"), + fieldtype: "Link", + options: "Department", }, { fieldname: "employee_status", @@ -37,12 +37,12 @@ frappe.query_reports['Employee Leave Balance Summary'] = { fieldtype: "Select", options: [ "", - { "value": "Active", "label": __("Active") }, - { "value": "Inactive", "label": __("Inactive") }, - { "value": "Suspended", "label": __("Suspended") }, - { "value": "Left", "label": __("Left") }, + { value: "Active", label: __("Active") }, + { value: "Inactive", label: __("Inactive") }, + { value: "Suspended", label: __("Suspended") }, + { value: "Left", label: __("Left") }, ], default: "Active", - } - ] + }, + ], }; diff --git a/hrms/hr/report/employees_working_on_a_holiday/employees_working_on_a_holiday.js b/hrms/hr/report/employees_working_on_a_holiday/employees_working_on_a_holiday.js index 97108e8575..4ce5ba4bc5 100644 --- a/hrms/hr/report/employees_working_on_a_holiday/employees_working_on_a_holiday.js +++ b/hrms/hr/report/employees_working_on_a_holiday/employees_working_on_a_holiday.js @@ -2,26 +2,26 @@ // For license information, please see license.txt frappe.query_reports["Employees working on a holiday"] = { - "filters": [ + filters: [ { - "fieldname":"from_date", - "label": __("From Date"), - "fieldtype": "Date", - "reqd": 1, - "default": frappe.datetime.year_start() + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + reqd: 1, + default: frappe.datetime.year_start(), }, { - "fieldname":"to_date", - "label": __("To Date"), - "fieldtype": "Date", - "reqd": 1, - "default": frappe.datetime.year_end() + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + reqd: 1, + default: frappe.datetime.year_end(), }, { - "fieldname":"holiday_list", - "label": __("Holiday List"), - "fieldtype": "Link", - "options": "Holiday List" - } - ] -} + fieldname: "holiday_list", + label: __("Holiday List"), + fieldtype: "Link", + options: "Holiday List", + }, + ], +}; diff --git a/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js b/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js index 277eaf4e56..ee6ad2af3c 100644 --- a/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js +++ b/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.js @@ -1,87 +1,86 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt - frappe.query_reports["Monthly Attendance Sheet"] = { - "filters": [ + filters: [ { - "fieldname": "month", - "label": __("Month"), - "fieldtype": "Select", - "reqd": 1 , - "options": [ - { "value": 1, "label": __("Jan") }, - { "value": 2, "label": __("Feb") }, - { "value": 3, "label": __("Mar") }, - { "value": 4, "label": __("Apr") }, - { "value": 5, "label": __("May") }, - { "value": 6, "label": __("June") }, - { "value": 7, "label": __("July") }, - { "value": 8, "label": __("Aug") }, - { "value": 9, "label": __("Sep") }, - { "value": 10, "label": __("Oct") }, - { "value": 11, "label": __("Nov") }, - { "value": 12, "label": __("Dec") }, + fieldname: "month", + label: __("Month"), + fieldtype: "Select", + reqd: 1, + options: [ + { value: 1, label: __("Jan") }, + { value: 2, label: __("Feb") }, + { value: 3, label: __("Mar") }, + { value: 4, label: __("Apr") }, + { value: 5, label: __("May") }, + { value: 6, label: __("June") }, + { value: 7, label: __("July") }, + { value: 8, label: __("Aug") }, + { value: 9, label: __("Sep") }, + { value: 10, label: __("Oct") }, + { value: 11, label: __("Nov") }, + { value: 12, label: __("Dec") }, ], - "default": frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth() + 1 + default: frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth() + 1, }, { - "fieldname":"year", - "label": __("Year"), - "fieldtype": "Select", - "reqd": 1 + fieldname: "year", + label: __("Year"), + fieldtype: "Select", + reqd: 1, }, { - "fieldname":"employee", - "label": __("Employee"), - "fieldtype": "Link", - "options": "Employee", + fieldname: "employee", + label: __("Employee"), + fieldtype: "Link", + options: "Employee", get_query: () => { - var company = frappe.query_report.get_filter_value('company'); + var company = frappe.query_report.get_filter_value("company"); return { filters: { - 'company': company - } + company: company, + }, }; - } + }, }, { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "reqd": 1 + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + reqd: 1, }, { - "fieldname":"group_by", - "label": __("Group By"), - "fieldtype": "Select", - "options": ["","Branch","Grade","Department","Designation"] + fieldname: "group_by", + label: __("Group By"), + fieldtype: "Select", + options: ["", "Branch", "Grade", "Department", "Designation"], }, { - "fieldname":"summarized_view", - "label": __("Summarized View"), - "fieldtype": "Check", - "Default": 0, - } + fieldname: "summarized_view", + label: __("Summarized View"), + fieldtype: "Check", + Default: 0, + }, ], - onload: function() { - return frappe.call({ + onload: function () { + return frappe.call({ method: "hrms.hr.report.monthly_attendance_sheet.monthly_attendance_sheet.get_attendance_years", - callback: function(r) { - var year_filter = frappe.query_report.get_filter('year'); + callback: function (r) { + var year_filter = frappe.query_report.get_filter("year"); year_filter.df.options = r.message; year_filter.df.default = r.message.split("\n")[0]; year_filter.refresh(); year_filter.set_input(year_filter.df.default); - } + }, }); }, - formatter: function(value, row, column, data, default_formatter) { + formatter: function (value, row, column, data, default_formatter) { value = default_formatter(value, row, column, data); - const summarized_view = frappe.query_report.get_filter_value('summarized_view'); - const group_by = frappe.query_report.get_filter_value('group_by'); + const summarized_view = frappe.query_report.get_filter_value("summarized_view"); + const group_by = frappe.query_report.get_filter_value("group_by"); if (group_by && column.colIndex === 1) { value = "" + value + ""; @@ -89,17 +88,14 @@ frappe.query_reports["Monthly Attendance Sheet"] = { if (!summarized_view) { if ((group_by && column.colIndex > 3) || (!group_by && column.colIndex > 2)) { - if (value == 'P' || value == 'WFH') + if (value == "P" || value == "WFH") value = "" + value + ""; - else if (value == 'A') - value = "" + value + ""; - else if (value == 'HD') - value = "" + value + ""; - else if (value == 'L') - value = "" + value + ""; + else if (value == "A") value = "" + value + ""; + else if (value == "HD") value = "" + value + ""; + else if (value == "L") value = "" + value + ""; } } return value; - } -} + }, +}; diff --git a/hrms/hr/report/project_profitability/project_profitability.js b/hrms/hr/report/project_profitability/project_profitability.js index 0d8156d3d7..a55639fcca 100644 --- a/hrms/hr/report/project_profitability/project_profitability.js +++ b/hrms/hr/report/project_profitability/project_profitability.js @@ -3,46 +3,46 @@ /* eslint-disable */ frappe.query_reports["Project Profitability"] = { - "filters": [ + filters: [ { - "fieldname": "company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "reqd": 1 + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + reqd: 1, }, { - "fieldname": "start_date", - "label": __("Start Date"), - "fieldtype": "Date", - "reqd": 1, - "default": frappe.datetime.add_months(frappe.datetime.get_today(), -1) + fieldname: "start_date", + label: __("Start Date"), + fieldtype: "Date", + reqd: 1, + default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), }, { - "fieldname": "end_date", - "label": __("End Date"), - "fieldtype": "Date", - "reqd": 1, - "default": frappe.datetime.now_date() + fieldname: "end_date", + label: __("End Date"), + fieldtype: "Date", + reqd: 1, + default: frappe.datetime.now_date(), }, { - "fieldname": "customer", - "label": __("Customer"), - "fieldtype": "Link", - "options": "Customer" + fieldname: "customer", + label: __("Customer"), + fieldtype: "Link", + options: "Customer", }, { - "fieldname": "employee", - "label": __("Employee"), - "fieldtype": "Link", - "options": "Employee" + fieldname: "employee", + label: __("Employee"), + fieldtype: "Link", + options: "Employee", }, { - "fieldname": "project", - "label": __("Project"), - "fieldtype": "Link", - "options": "Project" - } - ] + fieldname: "project", + label: __("Project"), + fieldtype: "Link", + options: "Project", + }, + ], }; diff --git a/hrms/hr/report/recruitment_analytics/recruitment_analytics.js b/hrms/hr/report/recruitment_analytics/recruitment_analytics.js index 51dc7ff85b..83ed311592 100644 --- a/hrms/hr/report/recruitment_analytics/recruitment_analytics.js +++ b/hrms/hr/report/recruitment_analytics/recruitment_analytics.js @@ -3,21 +3,21 @@ /* eslint-disable */ frappe.query_reports["Recruitment Analytics"] = { - "filters": [ + filters: [ { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "reqd": 1 + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + reqd: 1, }, { - "fieldname":"on_date", - "label": __("On Date"), - "fieldtype": "Date", - "default": frappe.datetime.now_date(), - "reqd": 1, + fieldname: "on_date", + label: __("On Date"), + fieldtype: "Date", + default: frappe.datetime.now_date(), + reqd: 1, }, - ] + ], }; diff --git a/hrms/hr/report/unpaid_expense_claim/unpaid_expense_claim.js b/hrms/hr/report/unpaid_expense_claim/unpaid_expense_claim.js index f0ba78c960..83fb711a4e 100644 --- a/hrms/hr/report/unpaid_expense_claim/unpaid_expense_claim.js +++ b/hrms/hr/report/unpaid_expense_claim/unpaid_expense_claim.js @@ -2,12 +2,12 @@ // For license information, please see license.txt frappe.query_reports["Unpaid Expense Claim"] = { - "filters": [ + filters: [ { - "fieldname": "employee", - "label": __("Employee"), - "fieldtype": "Link", - "options": "Employee" - } - ] -} + fieldname: "employee", + label: __("Employee"), + fieldtype: "Link", + options: "Employee", + }, + ], +}; diff --git a/hrms/hr/report/vehicle_expenses/vehicle_expenses.js b/hrms/hr/report/vehicle_expenses/vehicle_expenses.js index 2d0aa0f36d..afa7b1eab2 100644 --- a/hrms/hr/report/vehicle_expenses/vehicle_expenses.js +++ b/hrms/hr/report/vehicle_expenses/vehicle_expenses.js @@ -1,51 +1,51 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt frappe.query_reports["Vehicle Expenses"] = { - "filters": [ + filters: [ { - "fieldname": "filter_based_on", - "label": __("Filter Based On"), - "fieldtype": "Select", - "options": ["Fiscal Year", "Date Range"], - "default": ["Fiscal Year"], - "reqd": 1 + fieldname: "filter_based_on", + label: __("Filter Based On"), + fieldtype: "Select", + options: ["Fiscal Year", "Date Range"], + default: ["Fiscal Year"], + reqd: 1, }, { - "fieldname": "fiscal_year", - "label": __("Fiscal Year"), - "fieldtype": "Link", - "options": "Fiscal Year", - "default": frappe.defaults.get_user_default("fiscal_year"), - "depends_on": "eval: doc.filter_based_on == 'Fiscal Year'", - "reqd": 1 + fieldname: "fiscal_year", + label: __("Fiscal Year"), + fieldtype: "Link", + options: "Fiscal Year", + default: frappe.defaults.get_user_default("fiscal_year"), + depends_on: "eval: doc.filter_based_on == 'Fiscal Year'", + reqd: 1, }, { - "fieldname": "from_date", - "label": __("From Date"), - "fieldtype": "Date", - "reqd": 1, - "depends_on": "eval: doc.filter_based_on == 'Date Range'", - "default": frappe.datetime.add_months(frappe.datetime.nowdate(), -12) + fieldname: "from_date", + label: __("From Date"), + fieldtype: "Date", + reqd: 1, + depends_on: "eval: doc.filter_based_on == 'Date Range'", + default: frappe.datetime.add_months(frappe.datetime.nowdate(), -12), }, { - "fieldname": "to_date", - "label": __("To Date"), - "fieldtype": "Date", - "reqd": 1, - "depends_on": "eval: doc.filter_based_on == 'Date Range'", - "default": frappe.datetime.nowdate() + fieldname: "to_date", + label: __("To Date"), + fieldtype: "Date", + reqd: 1, + depends_on: "eval: doc.filter_based_on == 'Date Range'", + default: frappe.datetime.nowdate(), }, { - "fieldname": "vehicle", - "label": __("Vehicle"), - "fieldtype": "Link", - "options": "Vehicle" + fieldname: "vehicle", + label: __("Vehicle"), + fieldtype: "Link", + options: "Vehicle", }, { - "fieldname": "employee", - "label": __("Employee"), - "fieldtype": "Link", - "options": "Employee" - } - ] + fieldname: "employee", + label: __("Employee"), + fieldtype: "Link", + options: "Employee", + }, + ], }; diff --git a/hrms/hr/web_form/job_application/job_application.js b/hrms/hr/web_form/job_application/job_application.js index ffc5e98425..8f56ebb353 100644 --- a/hrms/hr/web_form/job_application/job_application.js +++ b/hrms/hr/web_form/job_application/job_application.js @@ -1,3 +1,3 @@ -frappe.ready(function() { +frappe.ready(function () { // bind events here -}) +}); diff --git a/hrms/payroll/doctype/additional_salary/additional_salary.js b/hrms/payroll/doctype/additional_salary/additional_salary.js index 19b6b6e438..fa74380ab3 100644 --- a/hrms/payroll/doctype/additional_salary/additional_salary.js +++ b/hrms/payroll/doctype/additional_salary/additional_salary.js @@ -1,85 +1,89 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Additional Salary', { - setup: function(frm) { - frm.add_fetch("salary_component", "deduct_full_tax_on_selected_payroll_date", "deduct_full_tax_on_selected_payroll_date"); +frappe.ui.form.on("Additional Salary", { + setup: function (frm) { + frm.add_fetch( + "salary_component", + "deduct_full_tax_on_selected_payroll_date", + "deduct_full_tax_on_selected_payroll_date", + ); - frm.set_query("employee", function() { + frm.set_query("employee", function () { return { filters: { company: frm.doc.company, - status: ['!=', 'Inactive'] - } + status: ["!=", "Inactive"], + }, }; }); }, - onload: function(frm) { + onload: function (frm) { if (frm.doc.type) { - frm.trigger('set_component_query'); + frm.trigger("set_component_query"); } }, - employee: function(frm) { + employee: function (frm) { if (frm.doc.employee) { frappe.run_serially([ - () => frm.trigger('get_employee_currency'), - () => frm.trigger('set_company') + () => frm.trigger("get_employee_currency"), + () => frm.trigger("set_company"), ]); } else { frm.set_value("company", null); } }, - set_company: function(frm) { + set_company: function (frm) { frappe.call({ method: "frappe.client.get_value", args: { doctype: "Employee", fieldname: "company", filters: { - name: frm.doc.employee - } + name: frm.doc.employee, + }, }, - callback: function(data) { + callback: function (data) { if (data.message) { frm.set_value("company", data.message.company); } - } + }, }); }, - company: function(frm) { + company: function (frm) { frm.set_value("type", ""); - frm.trigger('set_component_query'); + frm.trigger("set_component_query"); }, - set_component_query: function(frm) { + set_component_query: function (frm) { if (!frm.doc.company) return; - let filters = {company: frm.doc.company}; + let filters = { company: frm.doc.company }; if (frm.doc.type) { filters.type = frm.doc.type; } - frm.set_query("salary_component", function() { + frm.set_query("salary_component", function () { return { - filters: filters + filters: filters, }; }); }, - get_employee_currency: function(frm) { + get_employee_currency: function (frm) { frappe.call({ method: "hrms.payroll.doctype.salary_structure_assignment.salary_structure_assignment.get_employee_currency", args: { employee: frm.doc.employee, }, - callback: function(r) { + callback: function (r) { if (r.message) { - frm.set_value('currency', r.message); + frm.set_value("currency", r.message); frm.refresh_fields(); } - } + }, }); }, }); diff --git a/hrms/payroll/doctype/employee_benefit_application/employee_benefit_application.js b/hrms/payroll/doctype/employee_benefit_application/employee_benefit_application.js index 7eb3f6f435..f207c922e1 100644 --- a/hrms/payroll/doctype/employee_benefit_application/employee_benefit_application.js +++ b/hrms/payroll/doctype/employee_benefit_application/employee_benefit_application.js @@ -1,83 +1,85 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Benefit Application', { - employee: function(frm) { +frappe.ui.form.on("Employee Benefit Application", { + employee: function (frm) { if (frm.doc.employee) { frappe.run_serially([ - () => frm.trigger('get_employee_currency'), - () => frm.trigger('set_earning_component') + () => frm.trigger("get_employee_currency"), + () => frm.trigger("set_earning_component"), ]); } var method, args; - if(frm.doc.employee && frm.doc.date && frm.doc.payroll_period){ - method = "hrms.payroll.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits_remaining"; + if (frm.doc.employee && frm.doc.date && frm.doc.payroll_period) { + method = + "hrms.payroll.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits_remaining"; args = { employee: frm.doc.employee, on_date: frm.doc.date, - payroll_period: frm.doc.payroll_period + payroll_period: frm.doc.payroll_period, }; get_max_benefits(frm, method, args); - } - else if(frm.doc.employee && frm.doc.date){ - method = "hrms.payroll.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits"; + } else if (frm.doc.employee && frm.doc.date) { + method = + "hrms.payroll.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits"; args = { employee: frm.doc.employee, - on_date: frm.doc.date + on_date: frm.doc.date, }; get_max_benefits(frm, method, args); } }, - date: function(frm) { - frm.trigger('set_earning_component'); + date: function (frm) { + frm.trigger("set_earning_component"); }, - set_earning_component: function(frm) { - if(!frm.doc.employee && !frm.doc.date) return; - frm.set_query("earning_component", "employee_benefits", function() { + set_earning_component: function (frm) { + if (!frm.doc.employee && !frm.doc.date) return; + frm.set_query("earning_component", "employee_benefits", function () { return { - query : "hrms.payroll.doctype.employee_benefit_application.employee_benefit_application.get_earning_components", - filters: {date: frm.doc.date, employee: frm.doc.employee} + query: "hrms.payroll.doctype.employee_benefit_application.employee_benefit_application.get_earning_components", + filters: { date: frm.doc.date, employee: frm.doc.employee }, }; }); }, - get_employee_currency: function(frm) { + get_employee_currency: function (frm) { if (frm.doc.employee) { frappe.call({ method: "hrms.payroll.doctype.salary_structure_assignment.salary_structure_assignment.get_employee_currency", args: { employee: frm.doc.employee, }, - callback: function(r) { + callback: function (r) { if (r.message) { - frm.set_value('currency', r.message); + frm.set_value("currency", r.message); frm.refresh_fields(); } - } + }, }); } }, - payroll_period: function(frm) { + payroll_period: function (frm) { var method, args; if (frm.doc.employee && frm.doc.date && frm.doc.payroll_period) { - method = "hrms.payroll.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits_remaining"; + method = + "hrms.payroll.doctype.employee_benefit_application.employee_benefit_application.get_max_benefits_remaining"; args = { employee: frm.doc.employee, on_date: frm.doc.date, - payroll_period: frm.doc.payroll_period + payroll_period: frm.doc.payroll_period, }; get_max_benefits(frm, method, args); } }, - max_benefits: function(frm) { + max_benefits: function (frm) { calculate_all(frm.doc); - } + }, }); -var get_max_benefits=function(frm, method, args) { +var get_max_benefits = function (frm, method, args) { frappe.call({ method: method, args: args, @@ -90,20 +92,20 @@ var get_max_benefits=function(frm, method, args) { } } frm.refresh_fields(); - } + }, }); }; -frappe.ui.form.on("Employee Benefit Application Detail",{ - amount: function(frm) { +frappe.ui.form.on("Employee Benefit Application Detail", { + amount: function (frm) { calculate_all(frm.doc); }, - employee_benefits_remove: function(frm) { + employee_benefits_remove: function (frm) { calculate_all(frm.doc); - } + }, }); -var calculate_all = function(doc) { +var calculate_all = function (doc) { var tbl = doc.employee_benefits || []; var pro_rata_dispensed_amount = 0; var total_amount = 0; @@ -123,5 +125,5 @@ var calculate_all = function(doc) { doc.total_amount = total_amount; doc.remaining_benefit = doc.max_benefits - total_amount; doc.pro_rata_dispensed_amount = pro_rata_dispensed_amount; - refresh_many(['pro_rata_dispensed_amount', 'total_amount','remaining_benefit']); + refresh_many(["pro_rata_dispensed_amount", "total_amount", "remaining_benefit"]); }; diff --git a/hrms/payroll/doctype/employee_benefit_claim/employee_benefit_claim.js b/hrms/payroll/doctype/employee_benefit_claim/employee_benefit_claim.js index 8d3fc228e0..35ec62263b 100644 --- a/hrms/payroll/doctype/employee_benefit_claim/employee_benefit_claim.js +++ b/hrms/payroll/doctype/employee_benefit_claim/employee_benefit_claim.js @@ -1,16 +1,16 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Benefit Claim', { - setup: function(frm) { - frm.set_query("earning_component", function() { +frappe.ui.form.on("Employee Benefit Claim", { + setup: function (frm) { + frm.set_query("earning_component", function () { return { - query : "hrms.payroll.doctype.employee_benefit_application.employee_benefit_application.get_earning_components", - filters: {date: frm.doc.claim_date, employee: frm.doc.employee} + query: "hrms.payroll.doctype.employee_benefit_application.employee_benefit_application.get_earning_components", + filters: { date: frm.doc.claim_date, employee: frm.doc.employee }, }; }); }, - employee: function(frm) { + employee: function (frm) { frm.set_value("earning_component", null); if (frm.doc.employee) { frappe.call({ @@ -18,11 +18,11 @@ frappe.ui.form.on('Employee Benefit Claim', { args: { employee: frm.doc.employee, }, - callback: function(r) { + callback: function (r) { if (r.message) { - frm.set_value('currency', r.message); + frm.set_value("currency", r.message); } - } + }, }); } if (!frm.doc.earning_component) { @@ -30,5 +30,5 @@ frappe.ui.form.on('Employee Benefit Claim', { frm.doc.claimed_amount = null; } frm.refresh_fields(); - } + }, }); diff --git a/hrms/payroll/doctype/employee_incentive/employee_incentive.js b/hrms/payroll/doctype/employee_incentive/employee_incentive.js index 4056094435..0f73d99b55 100644 --- a/hrms/payroll/doctype/employee_incentive/employee_incentive.js +++ b/hrms/payroll/doctype/employee_incentive/employee_incentive.js @@ -1,69 +1,69 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Incentive', { - setup: function(frm) { - frm.set_query("employee", function() { +frappe.ui.form.on("Employee Incentive", { + setup: function (frm) { + frm.set_query("employee", function () { return { filters: { - "status": "Active" - } + status: "Active", + }, }; }); - frm.trigger('set_earning_component'); + frm.trigger("set_earning_component"); }, - employee: function(frm) { + employee: function (frm) { if (frm.doc.employee) { frappe.run_serially([ - () => frm.trigger('get_employee_currency'), - () => frm.trigger('set_company') + () => frm.trigger("get_employee_currency"), + () => frm.trigger("set_company"), ]); } else { frm.set_value("company", null); } }, - set_company: function(frm) { + set_company: function (frm) { frappe.call({ method: "frappe.client.get_value", args: { doctype: "Employee", fieldname: "company", filters: { - name: frm.doc.employee - } + name: frm.doc.employee, + }, }, - callback: function(data) { + callback: function (data) { if (data.message) { frm.set_value("company", data.message.company); - frm.trigger('set_earning_component'); + frm.trigger("set_earning_component"); } - } + }, }); }, - set_earning_component: function(frm) { + set_earning_component: function (frm) { if (!frm.doc.company) return; - frm.set_query("salary_component", function() { + frm.set_query("salary_component", function () { return { - filters: {type: "earning", company: frm.doc.company} + filters: { type: "earning", company: frm.doc.company }, }; }); }, - get_employee_currency: function(frm) { + get_employee_currency: function (frm) { frappe.call({ method: "hrms.payroll.doctype.salary_structure_assignment.salary_structure_assignment.get_employee_currency", args: { employee: frm.doc.employee, }, - callback: function(r) { + callback: function (r) { if (r.message) { - frm.set_value('currency', r.message); + frm.set_value("currency", r.message); frm.refresh_fields(); } - } + }, }); }, }); diff --git a/hrms/payroll/doctype/employee_other_income/employee_other_income.js b/hrms/payroll/doctype/employee_other_income/employee_other_income.js index c1a74e863b..d53415edbb 100644 --- a/hrms/payroll/doctype/employee_other_income/employee_other_income.js +++ b/hrms/payroll/doctype/employee_other_income/employee_other_income.js @@ -1,8 +1,7 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Other Income', { +frappe.ui.form.on("Employee Other Income", { // refresh: function(frm) { - // } }); diff --git a/hrms/payroll/doctype/employee_tax_exemption_category/employee_tax_exemption_category.js b/hrms/payroll/doctype/employee_tax_exemption_category/employee_tax_exemption_category.js index 1df609f320..446f7506a3 100644 --- a/hrms/payroll/doctype/employee_tax_exemption_category/employee_tax_exemption_category.js +++ b/hrms/payroll/doctype/employee_tax_exemption_category/employee_tax_exemption_category.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Tax Exemption Category', { - refresh: function(frm) { - - } +frappe.ui.form.on("Employee Tax Exemption Category", { + refresh: function (frm) {}, }); diff --git a/hrms/payroll/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js b/hrms/payroll/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js index 68237c2f0a..315da0cb4f 100644 --- a/hrms/payroll/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js +++ b/hrms/payroll/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js @@ -1,72 +1,72 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Tax Exemption Declaration', { - setup: function(frm) { - frm.set_query('employee', function() { +frappe.ui.form.on("Employee Tax Exemption Declaration", { + setup: function (frm) { + frm.set_query("employee", function () { return { filters: { - 'status': "Active" - } - } + status: "Active", + }, + }; }); - frm.set_query('payroll_period', function() { - const fields = {'employee': 'Employee', 'company': 'Company'}; + frm.set_query("payroll_period", function () { + const fields = { employee: "Employee", company: "Company" }; for (let [field, label] of Object.entries(fields)) { if (!frm.doc[field]) { - frappe.msgprint(__("Please select {0}", [label])) + frappe.msgprint(__("Please select {0}", [label])); } - }; + } - if (frm.doc.employee && frm.doc.company){ + if (frm.doc.employee && frm.doc.company) { return { filters: { - 'company': frm.doc.company - } - } + company: frm.doc.company, + }, + }; } }); - frm.set_query('exemption_sub_category', 'declarations', function() { + frm.set_query("exemption_sub_category", "declarations", function () { return { filters: { - 'is_active': 1 - } - } + is_active: 1, + }, + }; }); }, - refresh: function(frm) { - if(frm.doc.docstatus==1) { - frm.add_custom_button(__('Submit Proof'), function() { + refresh: function (frm) { + if (frm.doc.docstatus == 1) { + frm.add_custom_button(__("Submit Proof"), function () { frappe.model.open_mapped_doc({ method: "hrms.payroll.doctype.employee_tax_exemption_declaration.employee_tax_exemption_declaration.make_proof_submission", - frm: frm + frm: frm, }); }).addClass("btn-primary"); } }, - employee: function(frm) { + employee: function (frm) { if (frm.doc.employee) { - frm.trigger('get_employee_currency'); + frm.trigger("get_employee_currency"); } }, - get_employee_currency: function(frm) { + get_employee_currency: function (frm) { frappe.call({ method: "hrms.payroll.doctype.salary_structure_assignment.salary_structure_assignment.get_employee_currency", args: { employee: frm.doc.employee, }, - callback: function(r) { + callback: function (r) { if (r.message) { - frm.set_value('currency', r.message); + frm.set_value("currency", r.message); frm.refresh_fields(); } - } + }, }); - } + }, }); diff --git a/hrms/payroll/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.js b/hrms/payroll/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.js index bd7fbba972..8b7c87c28d 100644 --- a/hrms/payroll/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.js +++ b/hrms/payroll/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.js @@ -1,83 +1,83 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Tax Exemption Proof Submission', { - setup: function(frm) { - frm.set_query('employee', function() { +frappe.ui.form.on("Employee Tax Exemption Proof Submission", { + setup: function (frm) { + frm.set_query("employee", function () { return { filters: { - 'status': "Active" - } - } + status: "Active", + }, + }; }); - frm.set_query('payroll_period', function() { - if(frm.doc.employee && frm.doc.company){ + frm.set_query("payroll_period", function () { + if (frm.doc.employee && frm.doc.company) { return { filters: { - 'company': frm.doc.company - } - } - }else { + company: frm.doc.company, + }, + }; + } else { frappe.msgprint(__("Please select Employee")); } }); - frm.set_query('exemption_sub_category', 'tax_exemption_proofs', function() { + frm.set_query("exemption_sub_category", "tax_exemption_proofs", function () { return { filters: { - 'is_active': 1 - } - } + is_active: 1, + }, + }; }); }, - refresh: function(frm) { - if(frm.doc.docstatus === 0) { + refresh: function (frm) { + if (frm.doc.docstatus === 0) { let filters = { docstatus: 1, - company: frm.doc.company + company: frm.doc.company, }; - if(frm.doc.employee) filters["employee"] = frm.doc.employee; - if(frm.doc.payroll_period) filters["payroll_period"] = frm.doc.payroll_period; + if (frm.doc.employee) filters["employee"] = frm.doc.employee; + if (frm.doc.payroll_period) filters["payroll_period"] = frm.doc.payroll_period; - frm.add_custom_button(__('Get Details From Declaration'), function() { + frm.add_custom_button(__("Get Details From Declaration"), function () { erpnext.utils.map_current_doc({ method: "hrms.payroll.doctype.employee_tax_exemption_declaration.employee_tax_exemption_declaration.make_proof_submission", source_doctype: "Employee Tax Exemption Declaration", target: frm, date_field: "creation", setters: { - employee: frm.doc.employee || undefined + employee: frm.doc.employee || undefined, }, - get_query_filters: filters + get_query_filters: filters, }); }); } }, - currency: function(frm) { + currency: function (frm) { frm.refresh_fields(); }, - employee: function(frm) { + employee: function (frm) { if (frm.doc.employee) { - frm.trigger('get_employee_currency'); + frm.trigger("get_employee_currency"); } }, - get_employee_currency: function(frm) { + get_employee_currency: function (frm) { frappe.call({ method: "hrms.payroll.doctype.salary_structure_assignment.salary_structure_assignment.get_employee_currency", args: { employee: frm.doc.employee, }, - callback: function(r) { + callback: function (r) { if (r.message) { - frm.set_value('currency', r.message); + frm.set_value("currency", r.message); frm.refresh_fields(); } - } + }, }); }, }); diff --git a/hrms/payroll/doctype/employee_tax_exemption_sub_category/employee_tax_exemption_sub_category.js b/hrms/payroll/doctype/employee_tax_exemption_sub_category/employee_tax_exemption_sub_category.js index 8a83a2739c..8b62d09008 100644 --- a/hrms/payroll/doctype/employee_tax_exemption_sub_category/employee_tax_exemption_sub_category.js +++ b/hrms/payroll/doctype/employee_tax_exemption_sub_category/employee_tax_exemption_sub_category.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Employee Tax Exemption Sub Category', { - refresh: function(frm) { - - } +frappe.ui.form.on("Employee Tax Exemption Sub Category", { + refresh: function (frm) {}, }); diff --git a/hrms/payroll/doctype/gratuity/gratuity.js b/hrms/payroll/doctype/gratuity/gratuity.js index 21d01a24de..4d93430e02 100644 --- a/hrms/payroll/doctype/gratuity/gratuity.js +++ b/hrms/payroll/doctype/gratuity/gratuity.js @@ -1,33 +1,33 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Gratuity', { +frappe.ui.form.on("Gratuity", { setup: function (frm) { frm.set_query("salary_component", function () { return { filters: { - type: "Earning" - } + type: "Earning", + }, }; }); frm.set_query("expense_account", function () { return { filters: { - "root_type": "Expense", - "is_group": 0, - "company": frm.doc.company - } + root_type: "Expense", + is_group: 0, + company: frm.doc.company, + }, }; }); frm.set_query("payable_account", function () { return { filters: { - "root_type": "Liability", - "is_group": 0, - "company": frm.doc.company - } + root_type: "Liability", + is_group: 0, + company: frm.doc.company, + }, }; }); }, @@ -37,13 +37,13 @@ frappe.ui.form.on('Gratuity', { return frappe.call({ method: "hrms.overrides.employee_payment_entry.get_payment_entry_for_employee", args: { - "dt": frm.doc.doctype, - "dn": frm.doc.name + dt: frm.doc.doctype, + dn: frm.doc.name, }, callback: function (r) { var doclist = frappe.model.sync(r.message); frappe.set_route("Form", doclist[0].doctype, doclist[0].name); - } + }, }); }); } @@ -60,10 +60,9 @@ frappe.ui.form.on('Gratuity', { calculate_work_experience_and_amount: function (frm) { if (frm.doc.employee && frm.doc.gratuity_rule) { frm.call("calculate_work_experience_and_amount").then((r) => { - frm.set_value("current_work_experience", r.message['current_work_experience']); - frm.set_value("amount", r.message['amount']); + frm.set_value("current_work_experience", r.message["current_work_experience"]); + frm.set_value("amount", r.message["amount"]); }); } - } - + }, }); diff --git a/hrms/payroll/doctype/gratuity/gratuity_list.js b/hrms/payroll/doctype/gratuity/gratuity_list.js index 20e3d5b4e5..a81d4db213 100644 --- a/hrms/payroll/doctype/gratuity/gratuity_list.js +++ b/hrms/payroll/doctype/gratuity/gratuity_list.js @@ -1,12 +1,12 @@ frappe.listview_settings["Gratuity"] = { - get_indicator: function(doc) { + get_indicator: function (doc) { let status_color = { - "Draft": "red", - "Submitted": "blue", - "Cancelled": "red", - "Paid": "green", - "Unpaid": "orange", + Draft: "red", + Submitted: "blue", + Cancelled: "red", + Paid: "green", + Unpaid: "orange", }; - return [__(doc.status), status_color[doc.status], "status,=,"+doc.status]; - } -}; \ No newline at end of file + return [__(doc.status), status_color[doc.status], "status,=," + doc.status]; + }, +}; diff --git a/hrms/payroll/doctype/gratuity_rule/gratuity_rule.js b/hrms/payroll/doctype/gratuity_rule/gratuity_rule.js index 7290a9eafa..66fa62fcf8 100644 --- a/hrms/payroll/doctype/gratuity_rule/gratuity_rule.js +++ b/hrms/payroll/doctype/gratuity_rule/gratuity_rule.js @@ -1,14 +1,12 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Gratuity Rule', { +frappe.ui.form.on("Gratuity Rule", { // refresh: function(frm) { - // } }); -frappe.ui.form.on('Gratuity Rule Slab', { - +frappe.ui.form.on("Gratuity Rule Slab", { /* Slabs should be in order like @@ -36,5 +34,5 @@ frappe.ui.form.on('Gratuity Rule Slab', { if (row.to_year <= row.from_year && row.to_year === 0) { frappe.throw(__("To(Year) year can not be less than From(year)")); } - } + }, }); diff --git a/hrms/payroll/doctype/income_tax_slab/income_tax_slab.js b/hrms/payroll/doctype/income_tax_slab/income_tax_slab.js index 7d780d3b04..a11f0a83fa 100644 --- a/hrms/payroll/doctype/income_tax_slab/income_tax_slab.js +++ b/hrms/payroll/doctype/income_tax_slab/income_tax_slab.js @@ -1,8 +1,8 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Income Tax Slab', { - currency: function(frm) { +frappe.ui.form.on("Income Tax Slab", { + currency: function (frm) { frm.refresh_fields(); - } + }, }); diff --git a/hrms/payroll/doctype/payroll_entry/payroll_entry.js b/hrms/payroll/doctype/payroll_entry/payroll_entry.js index 1149d6bc20..cb12c2a56e 100644 --- a/hrms/payroll/doctype/payroll_entry/payroll_entry.js +++ b/hrms/payroll/doctype/payroll_entry/payroll_entry.js @@ -5,24 +5,24 @@ var in_progress = false; frappe.provide("erpnext.accounts.dimensions"); -frappe.ui.form.on('Payroll Entry', { +frappe.ui.form.on("Payroll Entry", { onload: function (frm) { if (!frm.doc.posting_date) { frm.doc.posting_date = frappe.datetime.nowdate(); } - frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet); + frm.toggle_reqd(["payroll_frequency"], !frm.doc.salary_slip_based_on_timesheet); erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype); frm.events.department_filters(frm); frm.events.payroll_payable_account_filters(frm); frappe.realtime.off("completed_salary_slip_creation"); - frappe.realtime.on("completed_salary_slip_creation", function() { + frappe.realtime.on("completed_salary_slip_creation", function () { frm.reload_doc(); }); frappe.realtime.off("completed_salary_slip_submission"); - frappe.realtime.on("completed_salary_slip_submission", function() { + frappe.realtime.on("completed_salary_slip_submission", function () { frm.reload_doc(); }); }, @@ -30,9 +30,9 @@ frappe.ui.form.on('Payroll Entry', { department_filters: function (frm) { frm.set_query("department", function () { return { - "filters": { - "company": frm.doc.company, - } + filters: { + company: frm.doc.company, + }, }; }); }, @@ -41,31 +41,29 @@ frappe.ui.form.on('Payroll Entry', { frm.set_query("payroll_payable_account", function () { return { filters: { - "company": frm.doc.company, - "root_type": "Liability", - "is_group": 0, - } + company: frm.doc.company, + root_type: "Liability", + is_group: 0, + }, }; }); }, refresh: function (frm) { - if (frm.doc.status === "Queued") frm.page.btn_secondary.hide() + if (frm.doc.status === "Queued") frm.page.btn_secondary.hide(); if (frm.doc.docstatus === 0 && !frm.is_new()) { frm.page.clear_primary_action(); - frm.add_custom_button(__("Get Employees"), - function() { - frm.events.get_employee_details(frm); - } - ).toggleClass("btn-primary", !(frm.doc.employees || []).length); + frm.add_custom_button(__("Get Employees"), function () { + frm.events.get_employee_details(frm); + }).toggleClass("btn-primary", !(frm.doc.employees || []).length); } if ( - (frm.doc.employees || []).length - && !frappe.model.has_workflow(frm.doctype) - && !cint(frm.doc.salary_slips_created) - && (frm.doc.docstatus != 2) + (frm.doc.employees || []).length && + !frappe.model.has_workflow(frm.doctype) && + !cint(frm.doc.salary_slips_created) && + frm.doc.docstatus != 2 ) { if (frm.doc.docstatus == 0 && !frm.is_new()) { frm.page.clear_primary_action(); @@ -89,10 +87,13 @@ frappe.ui.form.on('Payroll Entry', { if (frm.doc.status == "Failed" && frm.doc.error_message) { const issue = `issue`; - let process = (cint(frm.doc.salary_slips_created)) ? "submission" : "creation"; + let process = cint(frm.doc.salary_slips_created) ? "submission" : "creation"; frm.dashboard.set_headline( - __("Salary Slip {0} failed. You can resolve the {1} and retry {0}.", [process, issue]) + __("Salary Slip {0} failed. You can resolve the {1} and retry {0}.", [ + process, + issue, + ]), ); $("#jump_to_error").on("click", (e) => { @@ -103,21 +104,23 @@ frappe.ui.form.on('Payroll Entry', { }, get_employee_details: function (frm) { - return frappe.call({ - doc: frm.doc, - method: 'fill_employee_details', - }).then(r => { - if (r.docs && r.docs[0].employees) { - frm.employees = r.docs[0].employees; - frm.dirty(); - frm.save(); - frm.refresh(); - if (r.docs[0].validate_attendance) { - render_employee_attendance(frm, r.message); + return frappe + .call({ + doc: frm.doc, + method: "fill_employee_details", + }) + .then((r) => { + if (r.docs && r.docs[0].employees) { + frm.employees = r.docs[0].employees; + frm.dirty(); + frm.save(); + frm.refresh(); + if (r.docs[0].validate_attendance) { + render_employee_attendance(frm, r.message); + } + frm.scroll_to_field("employees"); } - frm.scroll_to_field("employees"); - } - }); + }); }, create_salary_slips: function (frm) { @@ -128,14 +131,17 @@ frappe.ui.form.on('Payroll Entry', { }, add_context_buttons: function (frm) { - if (frm.doc.salary_slips_submitted || (frm.doc.__onload && frm.doc.__onload.submitted_ss)) { + if ( + frm.doc.salary_slips_submitted || + (frm.doc.__onload && frm.doc.__onload.submitted_ss) + ) { frm.events.add_bank_entry_button(frm); } else if (frm.doc.salary_slips_created && frm.doc.status !== "Queued") { - frm.add_custom_button(__("Submit Salary Slip"), function() { + frm.add_custom_button(__("Submit Salary Slip"), function () { submit_salary_slip(frm); }).addClass("btn-primary"); } else if (!frm.doc.salary_slips_created && frm.doc.status === "Failed") { - frm.add_custom_button(__("Create Salary Slips"), function() { + frm.add_custom_button(__("Create Salary Slips"), function () { frm.trigger("create_salary_slips"); }).addClass("btn-primary"); } @@ -143,10 +149,10 @@ frappe.ui.form.on('Payroll Entry', { add_bank_entry_button: function (frm) { frappe.call({ - method: 'hrms.payroll.doctype.payroll_entry.payroll_entry.payroll_entry_has_bank_entries', + method: "hrms.payroll.doctype.payroll_entry.payroll_entry.payroll_entry_has_bank_entries", args: { - 'name': frm.doc.name, - 'payroll_payable_account': frm.doc.payroll_payable_account + name: frm.doc.name, + payroll_payable_account: frm.doc.payroll_payable_account, }, callback: function (r) { if (r.message && !r.message.submitted) { @@ -154,48 +160,48 @@ frappe.ui.form.on('Payroll Entry', { make_bank_entry(frm); }).addClass("btn-primary"); } - } + }, }); }, setup: function (frm) { - frm.add_fetch('company', 'cost_center', 'cost_center'); + frm.add_fetch("company", "cost_center", "cost_center"); frm.set_query("payment_account", function () { var account_types = ["Bank", "Cash"]; return { filters: { - "account_type": ["in", account_types], - "is_group": 0, - "company": frm.doc.company - } + account_type: ["in", account_types], + is_group: 0, + company: frm.doc.company, + }, }; }); - frm.set_query('employee', 'employees', () => { + frm.set_query("employee", "employees", () => { let error_fields = []; - let mandatory_fields = ['company', 'payroll_frequency', 'start_date', 'end_date']; + let mandatory_fields = ["company", "payroll_frequency", "start_date", "end_date"]; - let message = __('Mandatory fields required in {0}', [__(frm.doc.doctype)]); + let message = __("Mandatory fields required in {0}", [__(frm.doc.doctype)]); - mandatory_fields.forEach(field => { + mandatory_fields.forEach((field) => { if (!frm.doc[field]) { error_fields.push(frappe.unscrub(field)); } }); if (error_fields && error_fields.length) { - message = message + '

  • ' + error_fields.join('
  • ') + "
"; + message = message + "

  • " + error_fields.join("
  • ") + "
"; frappe.throw({ message: message, - indicator: 'red', - title: __('Missing Fields') + indicator: "red", + title: __("Missing Fields"), }); } return { query: "hrms.payroll.doctype.payroll_entry.payroll_entry.employee_query", - filters: frm.events.get_employee_filters(frm) + filters: frm.events.get_employee_filters(frm), }; }); }, @@ -203,26 +209,36 @@ frappe.ui.form.on('Payroll Entry', { get_employee_filters: function (frm) { let filters = {}; - let fields = ['company', 'start_date', 'end_date', 'payroll_frequency', 'payroll_payable_account', - 'currency', 'department', 'branch', 'designation', 'salary_slip_based_on_timesheet']; - - fields.forEach(field => { + let fields = [ + "company", + "start_date", + "end_date", + "payroll_frequency", + "payroll_payable_account", + "currency", + "department", + "branch", + "designation", + "salary_slip_based_on_timesheet", + ]; + + fields.forEach((field) => { if (frm.doc[field] || frm.doc[field] === 0) { filters[field] = frm.doc[field]; } }); if (frm.doc.employees) { - let employees = frm.doc.employees.filter(d => d.employee).map(d => d.employee); + let employees = frm.doc.employees.filter((d) => d.employee).map((d) => d.employee); if (employees && employees.length) { - filters['employees'] = employees; + filters["employees"] = employees; } } return filters; }, payroll_frequency: function (frm) { - frm.trigger("set_start_end_dates").then( ()=> { + frm.trigger("set_start_end_dates").then(() => { frm.events.clear_employee_table(frm); }); }, @@ -234,12 +250,17 @@ frappe.ui.form.on('Payroll Entry', { }, set_payable_account_and_currency: function (frm) { - frappe.db.get_value("Company", {"name": frm.doc.company}, "default_currency", (r) => { - frm.set_value('currency', r.default_currency); - }); - frappe.db.get_value("Company", {"name": frm.doc.company}, "default_payroll_payable_account", (r) => { - frm.set_value('payroll_payable_account', r.default_payroll_payable_account); + frappe.db.get_value("Company", { name: frm.doc.company }, "default_currency", (r) => { + frm.set_value("currency", r.default_currency); }); + frappe.db.get_value( + "Company", + { name: frm.doc.company }, + "default_payroll_payable_account", + (r) => { + frm.set_value("payroll_payable_account", r.default_payroll_payable_account); + }, + ); }, currency: function (frm) { @@ -259,14 +280,17 @@ frappe.ui.form.on('Payroll Entry', { }, callback: function (r) { frm.set_value("exchange_rate", flt(r.message)); - frm.set_df_property('exchange_rate', 'hidden', 0); - frm.set_df_property("exchange_rate", "description", "1 " + frm.doc.currency + - " = [?] " + company_currency); - } + frm.set_df_property("exchange_rate", "hidden", 0); + frm.set_df_property( + "exchange_rate", + "description", + "1 " + frm.doc.currency + " = [?] " + company_currency, + ); + }, }); } else { frm.set_value("exchange_rate", 1.0); - frm.set_df_property('exchange_rate', 'hidden', 1); + frm.set_df_property("exchange_rate", "hidden", 1); frm.set_df_property("exchange_rate", "description", ""); } } @@ -299,55 +323,55 @@ frappe.ui.form.on('Payroll Entry', { }, salary_slip_based_on_timesheet: function (frm) { - frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet); + frm.toggle_reqd(["payroll_frequency"], !frm.doc.salary_slip_based_on_timesheet); hrms.set_payroll_frequency_to_null(frm); }, set_start_end_dates: function (frm) { if (!frm.doc.salary_slip_based_on_timesheet) { frappe.call({ - method: 'hrms.payroll.doctype.payroll_entry.payroll_entry.get_start_end_dates', + method: "hrms.payroll.doctype.payroll_entry.payroll_entry.get_start_end_dates", args: { payroll_frequency: frm.doc.payroll_frequency, - start_date: frm.doc.posting_date + start_date: frm.doc.posting_date, }, callback: function (r) { if (r.message) { in_progress = true; - frm.set_value('start_date', r.message.start_date); - frm.set_value('end_date', r.message.end_date); + frm.set_value("start_date", r.message.start_date); + frm.set_value("end_date", r.message.end_date); } - } + }, }); } }, set_end_date: function (frm) { frappe.call({ - method: 'hrms.payroll.doctype.payroll_entry.payroll_entry.get_end_date', + method: "hrms.payroll.doctype.payroll_entry.payroll_entry.get_end_date", args: { frequency: frm.doc.payroll_frequency, - start_date: frm.doc.start_date + start_date: frm.doc.start_date, }, callback: function (r) { if (r.message) { - frm.set_value('end_date', r.message.end_date); + frm.set_value("end_date", r.message.end_date); } - } + }, }); }, validate_attendance: function (frm) { if (frm.doc.validate_attendance && frm.doc.employees) { frappe.call({ - method: 'get_employees_with_unmarked_attendance', + method: "get_employees_with_unmarked_attendance", args: {}, callback: function (r) { render_employee_attendance(frm, r.message); }, doc: frm.doc, freeze: true, - freeze_message: __('Validating Employee Attendance...') + freeze_message: __("Validating Employee Attendance..."), }); } else { frm.fields_dict.attendance_detail_html.html(""); @@ -355,7 +379,7 @@ frappe.ui.form.on('Payroll Entry', { }, clear_employee_table: function (frm) { - frm.clear_table('employees'); + frm.clear_table("employees"); frm.refresh(); }, }); @@ -363,21 +387,24 @@ frappe.ui.form.on('Payroll Entry', { // Submit salary slips const submit_salary_slip = function (frm) { - frappe.confirm(__('This will submit Salary Slips and create accrual Journal Entry. Do you want to proceed?'), + frappe.confirm( + __( + "This will submit Salary Slips and create accrual Journal Entry. Do you want to proceed?", + ), function () { frappe.call({ - method: 'submit_salary_slips', + method: "submit_salary_slips", args: {}, doc: frm.doc, freeze: true, - freeze_message: __('Submitting Salary Slips and creating Journal Entry...') + freeze_message: __("Submitting Salary Slips and creating Journal Entry..."), }); }, function () { if (frappe.dom.freeze_count) { frappe.dom.unfreeze(); } - } + }, ); }; @@ -388,25 +415,23 @@ let make_bank_entry = function (frm) { doc: cur_frm.doc, method: "make_payment_entry", callback: function () { - frappe.set_route( - 'List', 'Journal Entry', { - "Journal Entry Account.reference_name": frm.doc.name - } - ); + frappe.set_route("List", "Journal Entry", { + "Journal Entry Account.reference_name": frm.doc.name, + }); }, freeze: true, - freeze_message: __("Creating Payment Entries......") + freeze_message: __("Creating Payment Entries......"), }); } else { frappe.msgprint(__("Payment Account is mandatory")); - frm.scroll_to_field('payment_account'); + frm.scroll_to_field("payment_account"); } }; let render_employee_attendance = function (frm, data) { frm.fields_dict.attendance_detail_html.html( - frappe.render_template('employees_with_unmarked_attendance', { - data: data - }) + frappe.render_template("employees_with_unmarked_attendance", { + data: data, + }), ); }; diff --git a/hrms/payroll/doctype/payroll_entry/payroll_entry_list.js b/hrms/payroll/doctype/payroll_entry/payroll_entry_list.js index 56390b79d8..9c6c78e25b 100644 --- a/hrms/payroll/doctype/payroll_entry/payroll_entry_list.js +++ b/hrms/payroll/doctype/payroll_entry/payroll_entry_list.js @@ -2,17 +2,16 @@ // License: GNU General Public License v3. See license.txt // render -frappe.listview_settings['Payroll Entry'] = { +frappe.listview_settings["Payroll Entry"] = { has_indicator_for_draft: 1, - get_indicator: function(doc) { + get_indicator: function (doc) { var status_color = { - 'Draft': 'red', - 'Submitted': 'blue', - 'Queued': 'orange', - 'Failed': 'red', - 'Cancelled': 'red' - + Draft: "red", + Submitted: "blue", + Queued: "orange", + Failed: "red", + Cancelled: "red", }; - return [__(doc.status), status_color[doc.status], 'status,=,'+doc.status]; - } + return [__(doc.status), status_color[doc.status], "status,=," + doc.status]; + }, }; diff --git a/hrms/payroll/doctype/payroll_period/payroll_period.js b/hrms/payroll/doctype/payroll_period/payroll_period.js index 67caf9d101..5f4bc7c113 100644 --- a/hrms/payroll/doctype/payroll_period/payroll_period.js +++ b/hrms/payroll/doctype/payroll_period/payroll_period.js @@ -1,8 +1,6 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Payroll Period', { - refresh: function(frm) { - - } +frappe.ui.form.on("Payroll Period", { + refresh: function (frm) {}, }); diff --git a/hrms/payroll/doctype/payroll_settings/payroll_settings.js b/hrms/payroll/doctype/payroll_settings/payroll_settings.js index 3154b64620..fccb2a5165 100644 --- a/hrms/payroll/doctype/payroll_settings/payroll_settings.js +++ b/hrms/payroll/doctype/payroll_settings/payroll_settings.js @@ -1,7 +1,7 @@ // Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Payroll Settings', { +frappe.ui.form.on("Payroll Settings", { refresh: function (frm) { frm.set_query("sender", () => { return { @@ -12,18 +12,28 @@ frappe.ui.form.on('Payroll Settings', { }); }, - encrypt_salary_slips_in_emails: function(frm) { + encrypt_salary_slips_in_emails: function (frm) { let encrypt_state = frm.doc.encrypt_salary_slips_in_emails; - frm.set_df_property('password_policy', 'reqd', encrypt_state); + frm.set_df_property("password_policy", "reqd", encrypt_state); }, - validate: function(frm) { + validate: function (frm) { let policy = frm.doc.password_policy; if (policy) { - if (policy.includes(' ') || policy.includes('--')) { - frappe.msgprint(__("Password policy cannot contain spaces or simultaneous hyphens. The format will be restructured automatically")); + if (policy.includes(" ") || policy.includes("--")) { + frappe.msgprint( + __( + "Password policy cannot contain spaces or simultaneous hyphens. The format will be restructured automatically", + ), + ); } - frm.set_value('password_policy', policy.split(new RegExp(" |-", 'g')).filter((token) => token).join('-')); + frm.set_value( + "password_policy", + policy + .split(new RegExp(" |-", "g")) + .filter((token) => token) + .join("-"), + ); } }, }); diff --git a/hrms/payroll/doctype/retention_bonus/retention_bonus.js b/hrms/payroll/doctype/retention_bonus/retention_bonus.js index 99a21f678a..77af1052cd 100644 --- a/hrms/payroll/doctype/retention_bonus/retention_bonus.js +++ b/hrms/payroll/doctype/retention_bonus/retention_bonus.js @@ -1,43 +1,43 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Retention Bonus', { - setup: function(frm) { - frm.set_query("employee", function() { +frappe.ui.form.on("Retention Bonus", { + setup: function (frm) { + frm.set_query("employee", function () { if (!frm.doc.company) { frappe.msgprint(__("Please Select Company First")); } return { filters: { - "status": "Active", - "company": frm.doc.company - } + status: "Active", + company: frm.doc.company, + }, }; }); - frm.set_query("salary_component", function() { + frm.set_query("salary_component", function () { return { filters: { - "type": "Earning" - } + type: "Earning", + }, }; }); }, - employee: function(frm) { + employee: function (frm) { if (frm.doc.employee) { frappe.call({ method: "hrms.payroll.doctype.salary_structure_assignment.salary_structure_assignment.get_employee_currency", args: { employee: frm.doc.employee, }, - callback: function(r) { + callback: function (r) { if (r.message) { - frm.set_value('currency', r.message); + frm.set_value("currency", r.message); frm.refresh_fields(); } - } + }, }); } - } + }, }); diff --git a/hrms/payroll/doctype/salary_component/salary_component.js b/hrms/payroll/doctype/salary_component/salary_component.js index dbf75140ac..a97d62c7fc 100644 --- a/hrms/payroll/doctype/salary_component/salary_component.js +++ b/hrms/payroll/doctype/salary_component/salary_component.js @@ -1,65 +1,64 @@ // Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Salary Component', { - setup: function(frm) { - frm.set_query("account", "accounts", function(doc, cdt, cdn) { +frappe.ui.form.on("Salary Component", { + setup: function (frm) { + frm.set_query("account", "accounts", function (doc, cdt, cdn) { var d = locals[cdt][cdn]; return { filters: { - "is_group": 0, - "company": d.company - } + is_group: 0, + company: d.company, + }, }; }); - frm.set_query("earning_component_group", function() { + frm.set_query("earning_component_group", function () { return { filters: { - "is_group": 1, - "is_flexible_benefit": 1 - } + is_group: 1, + is_flexible_benefit: 1, + }, }; }); }, - is_flexible_benefit: function(frm) { - if(frm.doc.is_flexible_benefit){ + is_flexible_benefit: function (frm) { + if (frm.doc.is_flexible_benefit) { set_value_for_condition_and_formula(frm); - frm.set_value("formula", ''); + frm.set_value("formula", ""); frm.set_value("amount", 0); } }, - type: function(frm) { - if(frm.doc.type=="Earning"){ + type: function (frm) { + if (frm.doc.type == "Earning") { frm.set_value("is_tax_applicable", 1); frm.set_value("variable_based_on_taxable_salary", 0); } - if(frm.doc.type=="Deduction"){ + if (frm.doc.type == "Deduction") { frm.set_value("is_tax_applicable", 0); frm.set_value("is_flexible_benefit", 0); } }, - variable_based_on_taxable_salary: function(frm) { - if(frm.doc.variable_based_on_taxable_salary){ + variable_based_on_taxable_salary: function (frm) { + if (frm.doc.variable_based_on_taxable_salary) { set_value_for_condition_and_formula(frm); } }, - create_separate_payment_entry_against_benefit_claim: function(frm) { - if(frm.doc.create_separate_payment_entry_against_benefit_claim){ + create_separate_payment_entry_against_benefit_claim: function (frm) { + if (frm.doc.create_separate_payment_entry_against_benefit_claim) { frm.set_df_property("accounts", "reqd", 1); frm.set_value("only_tax_impact", 0); - } - else{ + } else { frm.set_df_property("accounts", "reqd", 0); } }, - only_tax_impact: function(frm) { - if(frm.only_tax_impact){ + only_tax_impact: function (frm) { + if (frm.only_tax_impact) { frm.set_value("create_separate_payment_entry_against_benefit_claim", 0); } - } + }, }); -var set_value_for_condition_and_formula = function(frm) { +var set_value_for_condition_and_formula = function (frm) { frm.set_value("formula", null); frm.set_value("condition", null); frm.set_value("amount_based_on_formula", 0); diff --git a/hrms/payroll/doctype/salary_slip/salary_slip.js b/hrms/payroll/doctype/salary_slip/salary_slip.js index dc1d49b9cf..6a646c41a6 100644 --- a/hrms/payroll/doctype/salary_slip/salary_slip.js +++ b/hrms/payroll/doctype/salary_slip/salary_slip.js @@ -2,106 +2,106 @@ // License: GNU General Public License v3. See license.txt frappe.ui.form.on("Salary Slip", { - setup: function(frm) { - $.each(["earnings", "deductions"], function(i, table_fieldname) { + setup: function (frm) { + $.each(["earnings", "deductions"], function (i, table_fieldname) { frm.get_field(table_fieldname).grid.editable_fields = [ - {fieldname: 'salary_component', columns: 6}, - {fieldname: 'amount', columns: 4} + { fieldname: "salary_component", columns: 6 }, + { fieldname: "amount", columns: 4 }, ]; }); - frm.fields_dict["timesheets"].grid.get_field("time_sheet").get_query = function() { + frm.fields_dict["timesheets"].grid.get_field("time_sheet").get_query = function () { return { filters: { - employee: frm.doc.employee - } + employee: frm.doc.employee, + }, }; }; - frm.set_query("salary_component", "earnings", function() { + frm.set_query("salary_component", "earnings", function () { return { filters: { - type: "earning" - } + type: "earning", + }, }; }); - frm.set_query("salary_component", "deductions", function() { + frm.set_query("salary_component", "deductions", function () { return { filters: { - type: "deduction" - } + type: "deduction", + }, }; }); - frm.set_query("employee", function() { + frm.set_query("employee", function () { return { query: "erpnext.controllers.queries.employee_query", filters: { - company: frm.doc.company - } + company: frm.doc.company, + }, }; }); frm.trigger("set_payment_days_description"); }, - validate: function(frm) { + validate: function (frm) { frm.trigger("set_payment_days_description"); }, - start_date: function(frm) { + start_date: function (frm) { if (frm.doc.start_date) { frm.trigger("set_end_date"); } }, - end_date: function(frm) { + end_date: function (frm) { frm.events.get_emp_and_working_day_details(frm); }, - set_end_date: function(frm) { + set_end_date: function (frm) { frappe.call({ - method: 'hrms.payroll.doctype.payroll_entry.payroll_entry.get_end_date', + method: "hrms.payroll.doctype.payroll_entry.payroll_entry.get_end_date", args: { frequency: frm.doc.payroll_frequency, - start_date: frm.doc.start_date + start_date: frm.doc.start_date, }, callback: function (r) { if (r.message) { - frm.set_value('end_date', r.message.end_date); + frm.set_value("end_date", r.message.end_date); } - } + }, }); }, - company: function(frm) { - var company = locals[':Company'][frm.doc.company]; + company: function (frm) { + var company = locals[":Company"][frm.doc.company]; if (!frm.doc.letter_head && company.default_letter_head) { - frm.set_value('letter_head', company.default_letter_head); + frm.set_value("letter_head", company.default_letter_head); } }, - currency: function(frm) { + currency: function (frm) { frm.trigger("update_currency_changes"); }, - update_currency_changes: function(frm) { + update_currency_changes: function (frm) { frm.trigger("set_exchange_rate"); frm.trigger("set_dynamic_labels"); }, - set_dynamic_labels: function(frm) { + set_dynamic_labels: function (frm) { if (frm.doc.employee && frm.doc.currency) { frappe.run_serially([ () => frm.events.change_form_labels(frm), () => frm.events.change_grid_labels(frm), - () => frm.refresh_fields() + () => frm.refresh_fields(), ]); } }, - set_exchange_rate: function(frm) { + set_exchange_rate: function (frm) { const company_currency = erpnext.get_currency(frm.doc.company); if (frm.doc.docstatus === 0) { @@ -115,114 +115,168 @@ frappe.ui.form.on("Salary Slip", { from_currency: from_currency, to_currency: company_currency, }, - callback: function(r) { + callback: function (r) { if (r.message) { frm.set_value("exchange_rate", flt(r.message)); - frm.set_df_property('exchange_rate', 'hidden', 0); - frm.set_df_property("exchange_rate", "description", "1 " + frm.doc.currency - + " = [?] " + company_currency); + frm.set_df_property("exchange_rate", "hidden", 0); + frm.set_df_property( + "exchange_rate", + "description", + "1 " + frm.doc.currency + " = [?] " + company_currency, + ); } - } + }, }); } else { frm.set_value("exchange_rate", 1.0); - frm.set_df_property('exchange_rate', 'hidden', 1); - frm.set_df_property("exchange_rate", "description", "" ); + frm.set_df_property("exchange_rate", "hidden", 1); + frm.set_df_property("exchange_rate", "description", ""); } } } }, - exchange_rate: function(frm) { + exchange_rate: function (frm) { set_totals(frm); }, - hide_loan_section: function(frm) { - frm.set_df_property('section_break_43', 'hidden', 1); + hide_loan_section: function (frm) { + frm.set_df_property("section_break_43", "hidden", 1); }, - change_form_labels: function(frm) { + change_form_labels: function (frm) { const company_currency = erpnext.get_currency(frm.doc.company); - frm.set_currency_labels(["base_hour_rate", "base_gross_pay", "base_total_deduction", - "base_net_pay", "base_rounded_total", "base_total_in_words", "base_year_to_date", "base_month_to_date", "base_gross_year_to_date"], - company_currency); - - frm.set_currency_labels(["hour_rate", "gross_pay", "total_deduction", "net_pay", "rounded_total", "total_in_words", "year_to_date", "month_to_date", "gross_year_to_date"], - frm.doc.currency); + frm.set_currency_labels( + [ + "base_hour_rate", + "base_gross_pay", + "base_total_deduction", + "base_net_pay", + "base_rounded_total", + "base_total_in_words", + "base_year_to_date", + "base_month_to_date", + "base_gross_year_to_date", + ], + company_currency, + ); + + frm.set_currency_labels( + [ + "hour_rate", + "gross_pay", + "total_deduction", + "net_pay", + "rounded_total", + "total_in_words", + "year_to_date", + "month_to_date", + "gross_year_to_date", + ], + frm.doc.currency, + ); // toggle fields - frm.toggle_display(["exchange_rate", "base_hour_rate", "base_gross_pay", "base_total_deduction", - "base_net_pay", "base_rounded_total", "base_total_in_words", "base_year_to_date", "base_month_to_date", "base_gross_year_to_date"], - frm.doc.currency != company_currency); + frm.toggle_display( + [ + "exchange_rate", + "base_hour_rate", + "base_gross_pay", + "base_total_deduction", + "base_net_pay", + "base_rounded_total", + "base_total_in_words", + "base_year_to_date", + "base_month_to_date", + "base_gross_year_to_date", + ], + frm.doc.currency != company_currency, + ); }, - change_grid_labels: function(frm) { - let fields = ["amount", "year_to_date", "default_amount", "additional_amount", "tax_on_flexible_benefit", - "tax_on_additional_salary"]; + change_grid_labels: function (frm) { + let fields = [ + "amount", + "year_to_date", + "default_amount", + "additional_amount", + "tax_on_flexible_benefit", + "tax_on_additional_salary", + ]; frm.set_currency_labels(fields, frm.doc.currency, "earnings"); frm.set_currency_labels(fields, frm.doc.currency, "deductions"); }, - refresh: function(frm) { + refresh: function (frm) { frm.trigger("toggle_fields"); - var salary_detail_fields = ["formula", "abbr", "statistical_component", "variable_based_on_taxable_salary"]; - frm.fields_dict['earnings'].grid.set_column_disp(salary_detail_fields, false); - frm.fields_dict['deductions'].grid.set_column_disp(salary_detail_fields, false); + var salary_detail_fields = [ + "formula", + "abbr", + "statistical_component", + "variable_based_on_taxable_salary", + ]; + frm.fields_dict["earnings"].grid.set_column_disp(salary_detail_fields, false); + frm.fields_dict["deductions"].grid.set_column_disp(salary_detail_fields, false); frm.trigger("set_dynamic_labels"); }, - salary_slip_based_on_timesheet: function(frm) { + salary_slip_based_on_timesheet: function (frm) { frm.trigger("toggle_fields"); frm.events.get_emp_and_working_day_details(frm); }, - payroll_frequency: function(frm) { + payroll_frequency: function (frm) { frm.trigger("toggle_fields"); - frm.set_value('end_date', ''); + frm.set_value("end_date", ""); }, - employee: function(frm) { + employee: function (frm) { frm.events.get_emp_and_working_day_details(frm); }, - leave_without_pay: function(frm) { + leave_without_pay: function (frm) { if (frm.doc.employee && frm.doc.start_date && frm.doc.end_date) { return frappe.call({ - method: 'process_salary_based_on_working_days', + method: "process_salary_based_on_working_days", doc: frm.doc, - callback: function() { + callback: function () { frm.refresh(); - } + }, }); } }, - toggle_fields: function(frm) { - frm.toggle_display(['hourly_wages', 'timesheets'], cint(frm.doc.salary_slip_based_on_timesheet)===1); + toggle_fields: function (frm) { + frm.toggle_display( + ["hourly_wages", "timesheets"], + cint(frm.doc.salary_slip_based_on_timesheet) === 1, + ); - frm.toggle_display(['payment_days', 'total_working_days', 'leave_without_pay'], - frm.doc.payroll_frequency != ""); + frm.toggle_display( + ["payment_days", "total_working_days", "leave_without_pay"], + frm.doc.payroll_frequency != "", + ); }, - get_emp_and_working_day_details: function(frm) { + get_emp_and_working_day_details: function (frm) { if (frm.doc.employee) { return frappe.call({ - method: 'get_emp_and_working_day_details', + method: "get_emp_and_working_day_details", doc: frm.doc, - callback: function(r) { + callback: function (r) { frm.refresh(); // triggering events explicitly because structure is set on the server-side // and currency is fetched from the structure frm.trigger("update_currency_changes"); - } + }, }); } }, - set_payment_days_description: function(frm) { + set_payment_days_description: function (frm) { if (frm.doc.docstatus !== 0) return; frappe.call("hrms.payroll.utils.get_payroll_settings_for_payment_days").then((r) => { @@ -230,7 +284,7 @@ frappe.ui.form.on("Salary Slip", { payroll_based_on, consider_unmarked_attendance_as, include_holidays_in_total_working_days, - consider_marked_attendance_on_holidays + consider_marked_attendance_on_holidays, } = r.message; const message = ` @@ -240,14 +294,20 @@ frappe.ui.form.on("Salary Slip", {
${__("Consider Unmarked Attendance As")}: ${consider_unmarked_attendance_as.bold()}
${__("Consider Marked Attendance on Holidays")}: ${ - cint(include_holidays_in_total_working_days) && cint(consider_marked_attendance_on_holidays) - ? __("Enabled").bold() : __("Disabled").bold() + cint(include_holidays_in_total_working_days) && + cint(consider_marked_attendance_on_holidays) + ? __("Enabled").bold() + : __("Disabled").bold() }

- ${ - __("Click {0} to change the configuration and then resave salary slip", - [frappe.utils.get_form_link("Payroll Settings", "Payroll Settings", true, "" + __("here") + "")]) - } + ${__("Click {0} to change the configuration and then resave salary slip", [ + frappe.utils.get_form_link( + "Payroll Settings", + "Payroll Settings", + true, + "" + __("here") + "", + ), + ])} `; @@ -256,81 +316,116 @@ frappe.ui.form.on("Salary Slip", { }, }); -frappe.ui.form.on('Salary Slip Timesheet', { - time_sheet: function(frm) { +frappe.ui.form.on("Salary Slip Timesheet", { + time_sheet: function (frm) { set_totals(frm); }, - timesheets_remove: function(frm) { + timesheets_remove: function (frm) { set_totals(frm); - } + }, }); -var set_totals = function(frm) { +var set_totals = function (frm) { if (frm.doc.docstatus === 0 && frm.doc.doctype === "Salary Slip") { if (frm.doc.earnings || frm.doc.deductions) { frappe.call({ method: "set_totals", doc: frm.doc, - callback: function() { + callback: function () { frm.refresh_fields(); - } + }, }); } } }; -frappe.ui.form.on('Salary Detail', { - amount: function(frm) { +frappe.ui.form.on("Salary Detail", { + amount: function (frm) { set_totals(frm); }, - earnings_remove: function(frm) { + earnings_remove: function (frm) { set_totals(frm); }, - deductions_remove: function(frm) { + deductions_remove: function (frm) { set_totals(frm); }, - salary_component: function(frm, cdt, cdn) { + salary_component: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; if (child.salary_component) { frappe.call({ method: "frappe.client.get", args: { doctype: "Salary Component", - name: child.salary_component + name: child.salary_component, }, - callback: function(data) { + callback: function (data) { if (data.message) { var result = data.message; - frappe.model.set_value(cdt, cdn, 'condition', result.condition); - frappe.model.set_value(cdt, cdn, 'amount_based_on_formula', result.amount_based_on_formula); + frappe.model.set_value(cdt, cdn, "condition", result.condition); + frappe.model.set_value( + cdt, + cdn, + "amount_based_on_formula", + result.amount_based_on_formula, + ); if (result.amount_based_on_formula === 1) { - frappe.model.set_value(cdt, cdn, 'formula', result.formula); + frappe.model.set_value(cdt, cdn, "formula", result.formula); } else { - frappe.model.set_value(cdt, cdn, 'amount', result.amount); + frappe.model.set_value(cdt, cdn, "amount", result.amount); } - frappe.model.set_value(cdt, cdn, 'statistical_component', result.statistical_component); - frappe.model.set_value(cdt, cdn, 'depends_on_payment_days', result.depends_on_payment_days); - frappe.model.set_value(cdt, cdn, 'do_not_include_in_total', result.do_not_include_in_total); - frappe.model.set_value(cdt, cdn, 'variable_based_on_taxable_salary', result.variable_based_on_taxable_salary); - frappe.model.set_value(cdt, cdn, 'is_tax_applicable', result.is_tax_applicable); - frappe.model.set_value(cdt, cdn, 'is_flexible_benefit', result.is_flexible_benefit); + frappe.model.set_value( + cdt, + cdn, + "statistical_component", + result.statistical_component, + ); + frappe.model.set_value( + cdt, + cdn, + "depends_on_payment_days", + result.depends_on_payment_days, + ); + frappe.model.set_value( + cdt, + cdn, + "do_not_include_in_total", + result.do_not_include_in_total, + ); + frappe.model.set_value( + cdt, + cdn, + "variable_based_on_taxable_salary", + result.variable_based_on_taxable_salary, + ); + frappe.model.set_value( + cdt, + cdn, + "is_tax_applicable", + result.is_tax_applicable, + ); + frappe.model.set_value( + cdt, + cdn, + "is_flexible_benefit", + result.is_flexible_benefit, + ); refresh_field("earnings"); refresh_field("deductions"); } - } + }, }); } }, - amount_based_on_formula: function(frm, cdt, cdn) { + amount_based_on_formula: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; if (child.amount_based_on_formula === 1) { - frappe.model.set_value(cdt, cdn, 'amount', null); + frappe.model.set_value(cdt, cdn, "amount", null); } else { - frappe.model.set_value(cdt, cdn, 'formula', null); + frappe.model.set_value(cdt, cdn, "formula", null); } - } + }, }); diff --git a/hrms/payroll/doctype/salary_slip/salary_slip_list.js b/hrms/payroll/doctype/salary_slip/salary_slip_list.js index 9f378c17dd..a839039db1 100644 --- a/hrms/payroll/doctype/salary_slip/salary_slip_list.js +++ b/hrms/payroll/doctype/salary_slip/salary_slip_list.js @@ -1,6 +1,14 @@ frappe.listview_settings["Salary Slip"] = { - onload: function(listview) { - if (!has_common(frappe.user_roles, ["Administrator", "System Manager", "HR Manager", "HR User"])) return; + onload: function (listview) { + if ( + !has_common(frappe.user_roles, [ + "Administrator", + "System Manager", + "HR Manager", + "HR User", + ]) + ) + return; listview.page.add_menu_item(__("Email Salary Slips"), () => { if (!listview.get_checked_items().length) { @@ -9,8 +17,10 @@ frappe.listview_settings["Salary Slip"] = { } frappe.confirm(__("Are you sure you want to email the selected salary slips?"), () => { - listview.call_for_selected_items("hrms.payroll.doctype.salary_slip.salary_slip.enqueue_email_salary_slips"); + listview.call_for_selected_items( + "hrms.payroll.doctype.salary_slip.salary_slip.enqueue_email_salary_slips", + ); }); }); - } -} \ No newline at end of file + }, +}; diff --git a/hrms/payroll/doctype/salary_structure_assignment/salary_structure_assignment.js b/hrms/payroll/doctype/salary_structure_assignment/salary_structure_assignment.js index 8ffc0d058a..905fb40ff7 100644 --- a/hrms/payroll/doctype/salary_structure_assignment/salary_structure_assignment.js +++ b/hrms/payroll/doctype/salary_structure_assignment/salary_structure_assignment.js @@ -1,118 +1,123 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt -frappe.ui.form.on('Salary Structure Assignment', { - setup: function(frm) { - frm.set_query("employee", function() { +frappe.ui.form.on("Salary Structure Assignment", { + setup: function (frm) { + frm.set_query("employee", function () { return { query: "erpnext.controllers.queries.employee_query", filters: { company: frm.doc.company }, - } + }; }); - frm.set_query("salary_structure", function() { + frm.set_query("salary_structure", function () { return { filters: { company: frm.doc.company, docstatus: 1, - is_active: "Yes" - } - } + is_active: "Yes", + }, + }; }); - frm.set_query("income_tax_slab", function() { + frm.set_query("income_tax_slab", function () { return { filters: { company: frm.doc.company, docstatus: 1, disabled: 0, - currency: frm.doc.currency - } + currency: frm.doc.currency, + }, }; }); - frm.set_query("payroll_payable_account", function() { + frm.set_query("payroll_payable_account", function () { var company_currency = erpnext.get_currency(frm.doc.company); return { filters: { - "company": frm.doc.company, - "root_type": "Liability", - "is_group": 0, - "account_currency": ["in", [frm.doc.currency, company_currency]], - } - } + company: frm.doc.company, + root_type: "Liability", + is_group: 0, + account_currency: ["in", [frm.doc.currency, company_currency]], + }, + }; }); - frm.set_query("cost_center", "payroll_cost_centers", function() { + frm.set_query("cost_center", "payroll_cost_centers", function () { return { filters: { - "company": frm.doc.company, - "is_group": 0 - } + company: frm.doc.company, + is_group: 0, + }, }; }); }, - refresh: function(frm) { - if(frm.doc.__onload){ - frm.unhide_earnings_and_taxation_section = frm.doc.__onload.earning_and_deduction_entries_does_not_exists; + refresh: function (frm) { + if (frm.doc.__onload) { + frm.unhide_earnings_and_taxation_section = + frm.doc.__onload.earning_and_deduction_entries_does_not_exists; frm.trigger("set_earnings_and_taxation_section_visibility"); } }, - employee: function(frm) { + employee: function (frm) { if (frm.doc.employee) { frm.trigger("set_payroll_cost_centers"); frm.trigger("valiadte_joining_date_and_salary_slips"); - } - else { + } else { frm.set_value("payroll_cost_centers", []); } }, - company: function(frm) { + company: function (frm) { if (frm.doc.company) { - frappe.db.get_value("Company", frm.doc.company, "default_payroll_payable_account", (r) => { - frm.set_value("payroll_payable_account", r.default_payroll_payable_account); - }); + frappe.db.get_value( + "Company", + frm.doc.company, + "default_payroll_payable_account", + (r) => { + frm.set_value("payroll_payable_account", r.default_payroll_payable_account); + }, + ); } }, - set_payroll_cost_centers: function(frm) { + set_payroll_cost_centers: function (frm) { if (frm.doc.payroll_cost_centers && frm.doc.payroll_cost_centers.length < 1) { frappe.call({ method: "set_payroll_cost_centers", doc: frm.doc, - callback: function(data) { + callback: function (data) { refresh_field("payroll_cost_centers"); - } - }) + }, + }); } }, - valiadte_joining_date_and_salary_slips: function(frm) { + valiadte_joining_date_and_salary_slips: function (frm) { frappe.call({ method: "earning_and_deduction_entries_does_not_exists", doc: frm.doc, - callback: function(data) { + callback: function (data) { let earning_and_deduction_entries_does_not_exists = data.message; - frm.unhide_earnings_and_taxation_section = earning_and_deduction_entries_does_not_exists; + frm.unhide_earnings_and_taxation_section = + earning_and_deduction_entries_does_not_exists; frm.trigger("set_earnings_and_taxation_section_visibility"); - } + }, }); }, - set_earnings_and_taxation_section_visibility: function(frm) { - if(frm.unhide_earnings_and_taxation_section){ - frm.set_df_property('earnings_and_taxation_section', 'hidden', 0); - } - else{ - frm.set_df_property('earnings_and_taxation_section', 'hidden', 1); + set_earnings_and_taxation_section_visibility: function (frm) { + if (frm.unhide_earnings_and_taxation_section) { + frm.set_df_property("earnings_and_taxation_section", "hidden", 0); + } else { + frm.set_df_property("earnings_and_taxation_section", "hidden", 1); } }, - from_date: function(frm) { + from_date: function (frm) { if (frm.doc.from_date) { - frm.trigger("valiadte_joining_date_and_salary_slips" ); + frm.trigger("valiadte_joining_date_and_salary_slips"); } }, }); diff --git a/hrms/payroll/report/bank_remittance/bank_remittance.js b/hrms/payroll/report/bank_remittance/bank_remittance.js index 8b75b4face..c83b9ea4e7 100644 --- a/hrms/payroll/report/bank_remittance/bank_remittance.js +++ b/hrms/payroll/report/bank_remittance/bank_remittance.js @@ -3,25 +3,24 @@ /* eslint-disable */ frappe.query_reports["Bank Remittance"] = { - "filters": [ + filters: [ { - fieldname:"company", + fieldname: "company", label: __("Company"), fieldtype: "Link", options: "Company", default: frappe.defaults.get_user_default("Company"), - reqd: 1 + reqd: 1, }, { - fieldname:"from_date", + fieldname: "from_date", label: __("From Date"), fieldtype: "Date", }, { - fieldname:"to_date", + fieldname: "to_date", label: __("To Date"), fieldtype: "Date", }, - - ] -} + ], +}; diff --git a/hrms/payroll/report/income_tax_computation/income_tax_computation.js b/hrms/payroll/report/income_tax_computation/income_tax_computation.js index 26e463f268..db6b3718cf 100644 --- a/hrms/payroll/report/income_tax_computation/income_tax_computation.js +++ b/hrms/payroll/report/income_tax_computation/income_tax_computation.js @@ -3,45 +3,43 @@ /* eslint-disable */ frappe.query_reports["Income Tax Computation"] = { - "filters": [ + filters: [ { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "width": "100px", - "reqd": 1 + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + width: "100px", + reqd: 1, }, { - "fieldname":"payroll_period", - "label": __("Payroll Period"), - "fieldtype": "Link", - "options": "Payroll Period", - "width": "100px", - "reqd": 1 + fieldname: "payroll_period", + label: __("Payroll Period"), + fieldtype: "Link", + options: "Payroll Period", + width: "100px", + reqd: 1, }, { - "fieldname":"employee", - "label": __("Employee"), - "fieldtype": "Link", - "options": "Employee", - "width": "100px" + fieldname: "employee", + label: __("Employee"), + fieldtype: "Link", + options: "Employee", + width: "100px", }, { - "fieldname":"department", - "label": __("Department"), - "fieldtype": "Link", - "options": "Department", - "width": "100px", + fieldname: "department", + label: __("Department"), + fieldtype: "Link", + options: "Department", + width: "100px", }, { - "fieldname":"consider_tax_exemption_declaration", - "label": __("Consider Tax Exemption Declaration"), - "fieldtype": "Check", - "width": "180px" - } - ] + fieldname: "consider_tax_exemption_declaration", + label: __("Consider Tax Exemption Declaration"), + fieldtype: "Check", + width: "180px", + }, + ], }; - - diff --git a/hrms/payroll/report/income_tax_deductions/income_tax_deductions.js b/hrms/payroll/report/income_tax_deductions/income_tax_deductions.js index c3ed6ea71a..0acbda4807 100644 --- a/hrms/payroll/report/income_tax_deductions/income_tax_deductions.js +++ b/hrms/payroll/report/income_tax_deductions/income_tax_deductions.js @@ -2,6 +2,6 @@ // For license information, please see license.txt /* eslint-disable */ -frappe.require("assets/hrms/js/salary_slip_deductions_report_filters.js", function() { +frappe.require("assets/hrms/js/salary_slip_deductions_report_filters.js", function () { frappe.query_reports["Income Tax Deductions"] = hrms.salary_slip_deductions_report_filters; }); diff --git a/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.js b/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.js index fa15a39881..469c3f5861 100644 --- a/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.js +++ b/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.js @@ -2,6 +2,7 @@ // For license information, please see license.txt /* eslint-disable */ -frappe.require("assets/hrms/js/salary_slip_deductions_report_filters.js", function() { - frappe.query_reports["Professional Tax Deductions"] = hrms.salary_slip_deductions_report_filters; +frappe.require("assets/hrms/js/salary_slip_deductions_report_filters.js", function () { + frappe.query_reports["Professional Tax Deductions"] = + hrms.salary_slip_deductions_report_filters; }); diff --git a/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.js b/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.js index 879da50737..b288a758f6 100644 --- a/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.js +++ b/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.js @@ -2,6 +2,6 @@ // For license information, please see license.txt /* eslint-disable */ -frappe.require("assets/hrms/js/salary_slip_deductions_report_filters.js", function() { +frappe.require("assets/hrms/js/salary_slip_deductions_report_filters.js", function () { frappe.query_reports["Provident Fund Deductions"] = hrms.salary_slip_deductions_report_filters; }); diff --git a/hrms/payroll/report/salary_payments_based_on_payment_mode/salary_payments_based_on_payment_mode.js b/hrms/payroll/report/salary_payments_based_on_payment_mode/salary_payments_based_on_payment_mode.js index e82dba64b5..0eb4e78320 100644 --- a/hrms/payroll/report/salary_payments_based_on_payment_mode/salary_payments_based_on_payment_mode.js +++ b/hrms/payroll/report/salary_payments_based_on_payment_mode/salary_payments_based_on_payment_mode.js @@ -2,6 +2,7 @@ // For license information, please see license.txt /* eslint-disable */ -frappe.require("assets/hrms/js/salary_slip_deductions_report_filters.js", function() { - frappe.query_reports["Salary Payments Based On Payment Mode"] = hrms.salary_slip_deductions_report_filters; +frappe.require("assets/hrms/js/salary_slip_deductions_report_filters.js", function () { + frappe.query_reports["Salary Payments Based On Payment Mode"] = + hrms.salary_slip_deductions_report_filters; }); diff --git a/hrms/payroll/report/salary_payments_via_ecs/salary_payments_via_ecs.js b/hrms/payroll/report/salary_payments_via_ecs/salary_payments_via_ecs.js index 75e87a45c0..163dc0144d 100644 --- a/hrms/payroll/report/salary_payments_via_ecs/salary_payments_via_ecs.js +++ b/hrms/payroll/report/salary_payments_via_ecs/salary_payments_via_ecs.js @@ -2,15 +2,14 @@ // For license information, please see license.txt /* eslint-disable */ -frappe.require("assets/hrms/js/salary_slip_deductions_report_filters.js", function() { - - let ecs_checklist_filter = hrms.salary_slip_deductions_report_filters - ecs_checklist_filter['filters'].push({ +frappe.require("assets/hrms/js/salary_slip_deductions_report_filters.js", function () { + let ecs_checklist_filter = hrms.salary_slip_deductions_report_filters; + ecs_checklist_filter["filters"].push({ fieldname: "type", label: __("Type"), fieldtype: "Select", - options:["", "Bank", "Cash", "Cheque"] - }) + options: ["", "Bank", "Cash", "Cheque"], + }); - frappe.query_reports["Salary Payments via ECS"] = ecs_checklist_filter + frappe.query_reports["Salary Payments via ECS"] = ecs_checklist_filter; }); diff --git a/hrms/payroll/report/salary_register/salary_register.js b/hrms/payroll/report/salary_register/salary_register.js index eb4acb91a7..49dbd9b977 100644 --- a/hrms/payroll/report/salary_register/salary_register.js +++ b/hrms/payroll/report/salary_register/salary_register.js @@ -2,54 +2,54 @@ // For license information, please see license.txt frappe.query_reports["Salary Register"] = { - "filters": [ + filters: [ { - "fieldname":"from_date", - "label": __("From"), - "fieldtype": "Date", - "default": frappe.datetime.add_months(frappe.datetime.get_today(),-1), - "reqd": 1, - "width": "100px" + fieldname: "from_date", + label: __("From"), + fieldtype: "Date", + default: frappe.datetime.add_months(frappe.datetime.get_today(), -1), + reqd: 1, + width: "100px", }, { - "fieldname":"to_date", - "label": __("To"), - "fieldtype": "Date", - "default": frappe.datetime.get_today(), - "reqd": 1, - "width": "100px" + fieldname: "to_date", + label: __("To"), + fieldtype: "Date", + default: frappe.datetime.get_today(), + reqd: 1, + width: "100px", }, { - "fieldname": "currency", - "fieldtype": "Link", - "options": "Currency", - "label": __("Currency"), - "default": erpnext.get_currency(frappe.defaults.get_default("Company")), - "width": "50px" + fieldname: "currency", + fieldtype: "Link", + options: "Currency", + label: __("Currency"), + default: erpnext.get_currency(frappe.defaults.get_default("Company")), + width: "50px", }, { - "fieldname":"employee", - "label": __("Employee"), - "fieldtype": "Link", - "options": "Employee", - "width": "100px" + fieldname: "employee", + label: __("Employee"), + fieldtype: "Link", + options: "Employee", + width: "100px", }, { - "fieldname":"company", - "label": __("Company"), - "fieldtype": "Link", - "options": "Company", - "default": frappe.defaults.get_user_default("Company"), - "width": "100px", - "reqd": 1 + fieldname: "company", + label: __("Company"), + fieldtype: "Link", + options: "Company", + default: frappe.defaults.get_user_default("Company"), + width: "100px", + reqd: 1, }, { - "fieldname":"docstatus", - "label":__("Document Status"), - "fieldtype":"Select", - "options":["Draft", "Submitted", "Cancelled"], - "default": "Submitted", - "width": "100px" - } - ] -} + fieldname: "docstatus", + label: __("Document Status"), + fieldtype: "Select", + options: ["Draft", "Submitted", "Cancelled"], + default: "Submitted", + width: "100px", + }, + ], +}; diff --git a/hrms/public/js/erpnext/bank_transaction.js b/hrms/public/js/erpnext/bank_transaction.js index 5dad99dd24..cdf3d6de70 100644 --- a/hrms/public/js/erpnext/bank_transaction.js +++ b/hrms/public/js/erpnext/bank_transaction.js @@ -2,7 +2,7 @@ // For license information, please see license.txt frappe.ui.form.on("Bank Transaction", { - get_payment_doctypes: function() { + get_payment_doctypes: function () { return [ "Payment Entry", "Journal Entry", @@ -10,5 +10,5 @@ frappe.ui.form.on("Bank Transaction", { "Purchase Invoice", "Expense Claim", ]; - } -}) \ No newline at end of file + }, +}); diff --git a/hrms/public/js/erpnext/company.js b/hrms/public/js/erpnext/company.js index e8c4ac8b07..f0c5166246 100644 --- a/hrms/public/js/erpnext/company.js +++ b/hrms/public/js/erpnext/company.js @@ -2,40 +2,40 @@ // For license information, please see license.txt frappe.ui.form.on("Company", { - refresh: function(frm) { - frm.set_query("default_expense_claim_payable_account", function() { + refresh: function (frm) { + frm.set_query("default_expense_claim_payable_account", function () { return { filters: { - "company": frm.doc.name, - "is_group": 0, - } + company: frm.doc.name, + is_group: 0, + }, }; }); - frm.set_query("default_employee_advance_account", function() { + frm.set_query("default_employee_advance_account", function () { return { filters: { - "company": frm.doc.name, - "is_group": 0, - "root_type": "Asset", - } + company: frm.doc.name, + is_group: 0, + root_type: "Asset", + }, }; }); - frm.set_query("default_payroll_payable_account", function() { + frm.set_query("default_payroll_payable_account", function () { return { filters: { - "company": frm.doc.name, - "is_group": 0, - "root_type": "Liability", - } + company: frm.doc.name, + is_group: 0, + root_type: "Liability", + }, }; }); - frm.set_query("hra_component", function() { + frm.set_query("hra_component", function () { return { - filters: {"type": "Earning"} - } + filters: { type: "Earning" }, + }; }); - } -}) \ No newline at end of file + }, +}); diff --git a/hrms/public/js/erpnext/delivery_trip.js b/hrms/public/js/erpnext/delivery_trip.js index 4960c97c14..0fa7ec0006 100644 --- a/hrms/public/js/erpnext/delivery_trip.js +++ b/hrms/public/js/erpnext/delivery_trip.js @@ -2,14 +2,18 @@ // For license information, please see license.txt frappe.ui.form.on("Delivery Trip", { - refresh: function(frm) { + refresh: function (frm) { if (frm.doc.docstatus === 1 && frm.doc.employee) { - frm.add_custom_button(__("Expense Claim"), function() { - frappe.model.open_mapped_doc({ - method: "hrms.hr.doctype.expense_claim.expense_claim.make_expense_claim_for_delivery_trip", - frm: frm, - }); - }, __("Create")); + frm.add_custom_button( + __("Expense Claim"), + function () { + frappe.model.open_mapped_doc({ + method: "hrms.hr.doctype.expense_claim.expense_claim.make_expense_claim_for_delivery_trip", + frm: frm, + }); + }, + __("Create"), + ); } - } -}) \ No newline at end of file + }, +}); diff --git a/hrms/public/js/erpnext/department.js b/hrms/public/js/erpnext/department.js index f29c6ae63e..92184dece1 100644 --- a/hrms/public/js/erpnext/department.js +++ b/hrms/public/js/erpnext/department.js @@ -2,14 +2,14 @@ // For license information, please see license.txt frappe.ui.form.on("Department", { - refresh: function(frm) { - frm.set_query("payroll_cost_center", function() { + refresh: function (frm) { + frm.set_query("payroll_cost_center", function () { return { filters: { - "company": frm.doc.company, - "is_group": 0 - } + company: frm.doc.company, + is_group: 0, + }, }; }); - } -}) \ No newline at end of file + }, +}); diff --git a/hrms/public/js/erpnext/employee.js b/hrms/public/js/erpnext/employee.js index da1449a2e9..cec83f2eb7 100644 --- a/hrms/public/js/erpnext/employee.js +++ b/hrms/public/js/erpnext/employee.js @@ -3,12 +3,12 @@ frappe.ui.form.on("Employee", { refresh: function (frm) { - frm.set_query("payroll_cost_center", function() { + frm.set_query("payroll_cost_center", function () { return { filters: { - "company": frm.doc.company, - "is_group": 0 - } + company: frm.doc.company, + is_group: 0, + }, }; }); }, @@ -17,11 +17,10 @@ frappe.ui.form.on("Employee", { frm.call({ method: "hrms.overrides.employee_master.get_retirement_date", args: { - date_of_birth: frm.doc.date_of_birth - } + date_of_birth: frm.doc.date_of_birth, + }, }).then((r) => { - if (r && r.message) - frm.set_value("date_of_retirement", r.message); + if (r && r.message) frm.set_value("date_of_retirement", r.message); }); - } -}) \ No newline at end of file + }, +}); diff --git a/hrms/public/js/erpnext/journal_entry.js b/hrms/public/js/erpnext/journal_entry.js index 39984096ad..00325d167c 100644 --- a/hrms/public/js/erpnext/journal_entry.js +++ b/hrms/public/js/erpnext/journal_entry.js @@ -3,25 +3,25 @@ frappe.ui.form.on("Journal Entry", { refresh(frm) { - frm.set_query("reference_name", "accounts", function(frm, cdt, cdn) { + frm.set_query("reference_name", "accounts", function (frm, cdt, cdn) { let jvd = frappe.get_doc(cdt, cdn); // filters for hrms doctypes if (jvd.reference_type === "Expense Claim") { return { filters: { - "total_sanctioned_amount": [">", 0], - "status": ["!=", "Paid"], - "docstatus": 1 - } + total_sanctioned_amount: [">", 0], + status: ["!=", "Paid"], + docstatus: 1, + }, }; } if (jvd.reference_type === "Employee Advance") { return { filters: { - "docstatus": 1 - } + docstatus: 1, + }, }; } @@ -38,26 +38,30 @@ frappe.ui.form.on("Journal Entry", { query: "erpnext.accounts.doctype.journal_entry.journal_entry.get_against_jv", filters: { account: jvd.account, - party: jvd.party - } + party: jvd.party, + }, }; } const out = { - filters: [ - [jvd.reference_type, "docstatus", "=", 1] - ] + filters: [[jvd.reference_type, "docstatus", "=", 1]], }; if (["Sales Invoice", "Purchase Invoice"].includes(jvd.reference_type)) { out.filters.push([jvd.reference_type, "outstanding_amount", "!=", 0]); // Filter by cost center if (jvd.cost_center) { - out.filters.push([jvd.reference_type, "cost_center", "in", ["", jvd.cost_center]]); + out.filters.push([ + jvd.reference_type, + "cost_center", + "in", + ["", jvd.cost_center], + ]); } // account filter frappe.model.validate_missing(jvd, "account"); - const party_account_field = jvd.reference_type === "Sales Invoice" ? "debit_to": "credit_to"; + const party_account_field = + jvd.reference_type === "Sales Invoice" ? "debit_to" : "credit_to"; out.filters.push([jvd.reference_type, party_account_field, "=", jvd.account]); } @@ -84,5 +88,5 @@ frappe.ui.form.on("Journal Entry", { return out; }); - } -}) \ No newline at end of file + }, +}); diff --git a/hrms/public/js/erpnext/payment_entry.js b/hrms/public/js/erpnext/payment_entry.js index ab80e3cd9a..0bb343017e 100644 --- a/hrms/public/js/erpnext/payment_entry.js +++ b/hrms/public/js/erpnext/payment_entry.js @@ -2,8 +2,8 @@ // For license information, please see license.txt frappe.ui.form.on("Payment Entry", { - refresh: function(frm) { - frm.set_query("reference_doctype", "references", function() { + refresh: function (frm) { + frm.set_query("reference_doctype", "references", function () { let doctypes = []; if (frm.doc.party_type == "Customer") { @@ -17,15 +17,21 @@ frappe.ui.form.on("Payment Entry", { } return { - filters: { "name": ["in", doctypes] } + filters: { name: ["in", doctypes] }, }; }); - frm.set_query("reference_name", "references", function(doc, cdt, cdn) { + frm.set_query("reference_name", "references", function (doc, cdt, cdn) { const child = locals[cdt][cdn]; - const filters = {"docstatus": 1, "company": doc.company}; - const party_type_doctypes = ["Sales Invoice", "Sales Order", "Purchase Invoice", - "Purchase Order", "Expense Claim", "Dunning"]; + const filters = { docstatus: 1, company: doc.company }; + const party_type_doctypes = [ + "Sales Invoice", + "Sales Order", + "Purchase Invoice", + "Purchase Order", + "Expense Claim", + "Dunning", + ]; if (in_list(party_type_doctypes, child.reference_doctype)) { filters[doc.party_type.toLowerCase()] = doc.party; @@ -40,23 +46,22 @@ frappe.ui.form.on("Payment Entry", { } return { - filters: filters + filters: filters, }; }); }, - get_order_doctypes: function(frm) { + get_order_doctypes: function (frm) { return ["Sales Order", "Purchase Order", "Expense Claim"]; }, - get_invoice_doctypes: function(frm) { - return ['Sales Invoice', 'Purchase Invoice', "Expense Claim"]; + get_invoice_doctypes: function (frm) { + return ["Sales Invoice", "Purchase Invoice", "Expense Claim"]; }, -}) - +}); frappe.ui.form.on("Payment Entry Reference", { - reference_name: function(frm, cdt, cdn) { + reference_name: function (frm, cdt, cdn) { let row = locals[cdt][cdn]; if (row.reference_name && row.reference_doctype) { @@ -65,23 +70,27 @@ frappe.ui.form.on("Payment Entry Reference", { args: { reference_doctype: row.reference_doctype, reference_name: row.reference_name, - party_account_currency: (frm.doc.payment_type == "Receive") ? - frm.doc.paid_from_account_currency : frm.doc.paid_to_account_currency + party_account_currency: + frm.doc.payment_type == "Receive" + ? frm.doc.paid_from_account_currency + : frm.doc.paid_to_account_currency, }, - callback: function(r, rt) { + callback: function (r, rt) { if (r.message) { - $.each(r.message, function(field, value) { + $.each(r.message, function (field, value) { frappe.model.set_value(cdt, cdn, field, value); - }) + }); - let allocated_amount = frm.doc.unallocated_amount > row.outstanding_amount ? - row.outstanding_amount : frm.doc.unallocated_amount; + let allocated_amount = + frm.doc.unallocated_amount > row.outstanding_amount + ? row.outstanding_amount + : frm.doc.unallocated_amount; frappe.model.set_value(cdt, cdn, "allocated_amount", allocated_amount); frm.refresh_fields(); } - } - }) + }, + }); } }, -}) \ No newline at end of file +}); diff --git a/hrms/public/js/erpnext/timesheet.js b/hrms/public/js/erpnext/timesheet.js index c92aff4c71..ab31468289 100644 --- a/hrms/public/js/erpnext/timesheet.js +++ b/hrms/public/js/erpnext/timesheet.js @@ -5,17 +5,17 @@ frappe.ui.form.on("Timesheet", { refresh(frm) { if (frm.doc.docstatus === 1 && frappe.model.can_create("Salary Slip")) { if (!frm.doc.salary_slip && frm.doc.employee) { - frm.add_custom_button(__("Create Salary Slip"), function() { + frm.add_custom_button(__("Create Salary Slip"), function () { frm.trigger("make_salary_slip"); }); } } }, - make_salary_slip: function(frm) { + make_salary_slip: function (frm) { frappe.model.open_mapped_doc({ method: "hrms.payroll.doctype.salary_slip.salary_slip.make_salary_slip_from_timesheet", - frm: frm + frm: frm, }); }, }); diff --git a/hrms/public/js/performance.bundle.js b/hrms/public/js/performance.bundle.js index cd447ca5f2..9d501274f3 100644 --- a/hrms/public/js/performance.bundle.js +++ b/hrms/public/js/performance.bundle.js @@ -1,4 +1,4 @@ import "./performance/performance_feedback.js"; import "./templates/performance_feedback_history.html"; import "./templates/performance_feedback_summary.html"; -import "./templates/rating.html"; \ No newline at end of file +import "./templates/rating.html"; diff --git a/hrms/public/js/performance/performance_feedback.js b/hrms/public/js/performance/performance_feedback.js index 1035681e8b..25f8d04079 100644 --- a/hrms/public/js/performance/performance_feedback.js +++ b/hrms/public/js/performance/performance_feedback.js @@ -1,4 +1,3 @@ - frappe.provide("hrms"); hrms.PerformanceFeedback = class PerformanceFeedback { @@ -21,20 +20,22 @@ hrms.PerformanceFeedback = class PerformanceFeedback { () => this.get_feedback_history(), (data) => this.render_feedback_history(data), () => this.setup_actions(), - ]) + ]); } get_feedback_history() { let me = this; - return new Promise(resolve => { - frappe.call({ - method: "hrms.hr.doctype.appraisal.appraisal.get_feedback_history", - args: { - employee: me.frm.doc.employee, - appraisal: me.frm.doc.name - } - }).then(r => resolve(r.message)); + return new Promise((resolve) => { + frappe + .call({ + method: "hrms.hr.doctype.appraisal.appraisal.get_feedback_history", + args: { + employee: me.frm.doc.employee, + appraisal: me.frm.doc.name, + }, + }) + .then((r) => resolve(r.message)); }); } @@ -46,7 +47,7 @@ hrms.PerformanceFeedback = class PerformanceFeedback { feedback_history: feedback_history, average_feedback_score: avg_feedback_score, reviews_per_rating: reviews_per_rating, - can_create: can_create + can_create: can_create, }); $(this.wrapper).empty(); @@ -71,15 +72,16 @@ hrms.PerformanceFeedback = class PerformanceFeedback { get_feedback_criteria_data() { let me = this; - return new Promise(resolve => { - frappe.db.get_doc("Appraisal Template", me.frm.doc.appraisal_template) + return new Promise((resolve) => { + frappe.db + .get_doc("Appraisal Template", me.frm.doc.appraisal_template) .then(({ rating_criteria }) => { const criteria_list = []; rating_criteria.forEach((entry) => { criteria_list.push({ - "criteria": entry.criteria, - "per_weightage": entry.per_weightage, - }) + criteria: entry.criteria, + per_weightage: entry.per_weightage, + }); }); resolve(criteria_list); }); @@ -96,7 +98,7 @@ hrms.PerformanceFeedback = class PerformanceFeedback { minimizable: true, static: true, primary_action_label: __("Submit"), - primary_action: function() { + primary_action: function () { const data = dialog.get_values(); frappe.call({ @@ -104,30 +106,32 @@ hrms.PerformanceFeedback = class PerformanceFeedback { doc: me.frm.doc, args: { feedback: data.feedback, - feedback_ratings: data.feedback_ratings + feedback_ratings: data.feedback_ratings, }, freeze: true, - callback: function(r) { + callback: function (r) { if (!r.exc) { frappe.run_serially([ () => me.frm.refresh_fields(), - () => me.refresh() + () => me.refresh(), ]); frappe.show_alert({ - message: __("Feedback {0} added successfully", [r.message?.name?.bold()]), + message: __("Feedback {0} added successfully", [ + r.message?.name?.bold(), + ]), indicator: "green", }); } dialog.hide(); - } + }, }); }, }); dialog.show(); dialog.get_close_btn().show(); - }; + } get_feedback_dialog_fields(criteria_data) { return [ @@ -164,17 +168,17 @@ hrms.PerformanceFeedback = class PerformanceFeedback { fieldtype: "Rating", in_list_view: 1, label: "Rating", - } - ] - } + }, + ], + }, ]; } async can_create() { - const is_employee = ( - await frappe.db.get_value("Employee", {"user_id": frappe.session.user}, "name") - )?.message?.name || false; + const is_employee = + (await frappe.db.get_value("Employee", { user_id: frappe.session.user }, "name")) + ?.message?.name || false; - return (is_employee && frappe.model.can_create("Employee Performance Feedback")); + return is_employee && frappe.model.can_create("Employee Performance Feedback"); } }; diff --git a/hrms/public/js/salary_slip_deductions_report_filters.js b/hrms/public/js/salary_slip_deductions_report_filters.js index 0dc181095a..3ca648b0dd 100644 --- a/hrms/public/js/salary_slip_deductions_report_filters.js +++ b/hrms/public/js/salary_slip_deductions_report_filters.js @@ -16,26 +16,26 @@ hrms.salary_slip_deductions_report_filters = { fieldtype: "Select", reqd: 1, options: [ - { "value": 1, "label": __("Jan") }, - { "value": 2, "label": __("Feb") }, - { "value": 3, "label": __("Mar") }, - { "value": 4, "label": __("Apr") }, - { "value": 5, "label": __("May") }, - { "value": 6, "label": __("June") }, - { "value": 7, "label": __("July") }, - { "value": 8, "label": __("Aug") }, - { "value": 9, "label": __("Sep") }, - { "value": 10, "label": __("Oct") }, - { "value": 11, "label": __("Nov") }, - { "value": 12, "label": __("Dec") }, + { value: 1, label: __("Jan") }, + { value: 2, label: __("Feb") }, + { value: 3, label: __("Mar") }, + { value: 4, label: __("Apr") }, + { value: 5, label: __("May") }, + { value: 6, label: __("June") }, + { value: 7, label: __("July") }, + { value: 8, label: __("Aug") }, + { value: 9, label: __("Sep") }, + { value: 10, label: __("Oct") }, + { value: 11, label: __("Nov") }, + { value: 12, label: __("Dec") }, ], - default: frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth() + 1 + default: frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth() + 1, }, { - fieldname:"year", + fieldname: "year", label: __("Year"), fieldtype: "Select", - reqd: 1 + reqd: 1, }, { fieldname: "department", @@ -48,18 +48,18 @@ hrms.salary_slip_deductions_report_filters = { label: __("Branch"), fieldtype: "Link", options: "Branch", - } + }, ], - onload: function() { - return frappe.call({ + onload: function () { + return frappe.call({ method: "hrms.payroll.report.provident_fund_deductions.provident_fund_deductions.get_years", - callback: function(r) { - var year_filter = frappe.query_report.get_filter('year'); + callback: function (r) { + var year_filter = frappe.query_report.get_filter("year"); year_filter.df.options = r.message; year_filter.df.default = r.message.split("\n")[0]; year_filter.refresh(); year_filter.set_input(year_filter.df.default); - } + }, }); - } -} + }, +}; diff --git a/hrms/public/js/utils.js b/hrms/public/js/utils.js index 560dd9f41a..799f164059 100644 --- a/hrms/public/js/utils.js +++ b/hrms/public/js/utils.js @@ -5,10 +5,10 @@ $.extend(hrms, { proceed_save_with_reminders_frequency_change: () => { frappe.ui.hide_open_dialog(); frappe.call({ - method: 'hrms.hr.doctype.hr_settings.hr_settings.set_proceed_with_frequency_change', + method: "hrms.hr.doctype.hr_settings.hr_settings.set_proceed_with_frequency_change", callback: () => { cur_frm.save(); - } + }, }); }, @@ -20,9 +20,9 @@ $.extend(hrms, { get_current_employee: async (frm) => { const employee = ( - await frappe.db.get_value("Employee", {"user_id": frappe.session.user}, "name") + await frappe.db.get_value("Employee", { user_id: frappe.session.user }, "name") )?.message?.name; return employee; }, -}) \ No newline at end of file +}); diff --git a/hrms/public/scss/performance.scss b/hrms/public/scss/performance.scss index 41414caf93..7917161134 100644 --- a/hrms/public/scss/performance.scss +++ b/hrms/public/scss/performance.scss @@ -45,7 +45,7 @@ .ratings-pill { background-color: var(--gray-100); - padding: .5rem 1rem; + padding: 0.5rem 1rem; border-radius: 66px; } } From 6409c64cdae47b52f0847bebcad862d69679f5e8 Mon Sep 17 00:00:00 2001 From: krantheman Date: Wed, 24 Apr 2024 15:12:20 +0530 Subject: [PATCH 09/20] chore: format all Python files --- .github/helper/documentation.py | 11 +-- .github/helper/translation.py | 34 ++++--- .../tests/test_employee_reminders.py | 8 +- hrms/hooks.py | 8 +- .../hiring_vs_attrition_count.py | 4 +- hrms/hr/doctype/appraisal/appraisal.py | 11 ++- hrms/hr/doctype/appraisal/test_appraisal.py | 40 ++------ .../appraisal_cycle/test_appraisal_cycle.py | 4 +- hrms/hr/doctype/attendance/attendance.py | 11 ++- hrms/hr/doctype/attendance/test_attendance.py | 12 +-- .../attendance_request/attendance_request.py | 8 +- .../test_attendance_request.py | 4 +- .../compensatory_leave_request.py | 7 +- .../test_compensatory_leave_request.py | 4 +- .../test_daily_work_summary.py | 6 +- .../department_approver.py | 5 +- .../employee_advance/test_employee_advance.py | 4 +- .../employee_checkin/employee_checkin.py | 4 +- .../employee_checkin/test_employee_checkin.py | 50 +++------- .../employee_promotion/employee_promotion.py | 4 +- .../employee_transfer/employee_transfer.py | 6 +- .../doctype/exit_interview/exit_interview.py | 12 +-- .../expense_claim/test_expense_claim.py | 25 ++--- .../expense_claim_type/expense_claim_type.py | 4 +- .../full_and_final_statement.py | 4 +- .../test_full_and_final_statement.py | 4 +- hrms/hr/doctype/interview/interview.py | 24 ++--- .../interview_feedback/interview_feedback.py | 4 +- .../test_interview_feedback.py | 4 +- hrms/hr/doctype/job_opening/job_opening.py | 8 +- .../doctype/job_opening/test_job_opening.py | 4 +- .../job_requisition/test_job_requisition.py | 3 +- .../leave_allocation/leave_allocation.py | 18 ++-- .../leave_allocation/test_earned_leaves.py | 16 +--- .../leave_allocation/test_leave_allocation.py | 4 +- .../leave_application/leave_application.py | 93 ++++++++----------- .../test_leave_application.py | 12 +-- .../leave_block_list/test_leave_block_list.py | 8 +- .../leave_control_panel.py | 6 +- .../leave_encashment/leave_encashment.py | 4 +- .../leave_encashment/test_leave_encashment.py | 12 +-- .../leave_policy_assignment.py | 6 +- .../shift_assignment/shift_assignment.py | 37 +++----- .../shift_assignment/test_shift_assignment.py | 20 +--- hrms/hr/doctype/shift_type/shift_type.py | 8 +- .../shift_type/shift_type_dashboard.py | 4 +- hrms/hr/doctype/shift_type/test_shift_type.py | 24 ++--- .../hr/doctype/staffing_plan/staffing_plan.py | 12 +-- .../upload_attendance/upload_attendance.py | 6 +- .../doctype/vehicle_log/test_vehicle_log.py | 4 +- hrms/hr/page/team_updates/team_updates.py | 4 +- .../test_appraisal_overview.py | 8 +- ...ee_hours_utilization_based_on_timesheet.py | 16 ++-- .../employee_leave_balance.py | 14 +-- .../employees_working_on_a_holiday.py | 4 +- .../monthly_attendance_sheet.py | 60 +++++------- .../test_monthly_attendance_sheet.py | 20 +--- .../recruitment_analytics.py | 12 +-- .../unpaid_expense_claim.py | 6 +- .../vehicle_expenses/test_vehicle_expenses.py | 4 +- .../vehicle_expenses/vehicle_expenses.py | 8 +- hrms/hr/utils.py | 14 +-- hrms/overrides/dashboard_overrides.py | 4 +- hrms/overrides/employee_payment_entry.py | 10 +- ..._from_payroll_period_to_income_tax_slab.py | 16 +--- .../remove_denied_leaves_from_leave_ledger.py | 4 +- .../set_training_event_attendance.py | 4 +- .../updates_for_multi_currency_payroll.py | 15 +-- ...lary_and_payroll_payable_account_fields.py | 4 +- .../employee_benefit_application.py | 19 ++-- .../employee_benefit_claim.py | 18 ++-- ...employee_tax_exemption_proof_submission.py | 3 +- hrms/payroll/doctype/gratuity/gratuity.py | 13 +-- .../payroll/doctype/gratuity/test_gratuity.py | 4 +- .../doctype/gratuity_rule/gratuity_rule.py | 8 +- .../doctype/payroll_entry/payroll_entry.py | 31 +++---- .../payroll_entry/test_payroll_entry.py | 28 ++---- .../doctype/payroll_period/payroll_period.py | 6 +- .../retention_bonus/retention_bonus.py | 1 - .../doctype/salary_slip/salary_slip.py | 92 +++++------------- .../doctype/salary_slip/test_salary_slip.py | 82 ++++------------ .../salary_structure/salary_structure.py | 18 ++-- .../salary_structure/test_salary_structure.py | 5 +- .../salary_structure_assignment.py | 16 ++-- .../report/bank_remittance/bank_remittance.py | 4 +- .../income_tax_computation.py | 6 +- .../test_income_tax_computation.py | 4 +- .../income_tax_deductions.py | 4 +- .../test_income_tax_deductions.py | 8 +- .../professional_tax_deductions.py | 2 - .../provident_fund_deductions.py | 1 - .../salary_payments_based_on_payment_mode.py | 9 +- .../salary_payments_via_ecs.py | 2 - .../report/salary_register/salary_register.py | 4 +- hrms/regional/india/utils.py | 8 +- hrms/tests/test_utils.py | 8 +- hrms/utils/__init__.py | 4 +- 97 files changed, 416 insertions(+), 854 deletions(-) diff --git a/.github/helper/documentation.py b/.github/helper/documentation.py index 8ceb7f7436..fce884e412 100644 --- a/.github/helper/documentation.py +++ b/.github/helper/documentation.py @@ -7,13 +7,14 @@ def uri_validator(x): result = urlparse(x) return all([result.scheme, result.netloc, result.path]) + def docs_link_exists(body): for line in body.splitlines(): for word in line.split(): - if word.startswith('http') and uri_validator(word): + if word.startswith("http") and uri_validator(word): parsed_url = urlparse(word) if parsed_url.netloc == "github.com": - parts = parsed_url.path.split('/') + parts = parsed_url.path.split("/") if len(parts) == 5 and parts[1] == "frappe" and parts[2] == "hrms": return True elif parsed_url.netloc == "frappehr.com": @@ -30,11 +31,7 @@ def docs_link_exists(body): head_sha = (payload.get("head") or {}).get("sha") body = (payload.get("body") or "").lower() - if (title.startswith("feat") - and head_sha - and "no-docs" not in body - and "backport" not in body - ): + if title.startswith("feat") and head_sha and "no-docs" not in body and "backport" not in body: if docs_link_exists(body): print("Documentation Link Found. You're Awesome! 🎉") diff --git a/.github/helper/translation.py b/.github/helper/translation.py index 07004f4689..9b0dc93951 100644 --- a/.github/helper/translation.py +++ b/.github/helper/translation.py @@ -2,7 +2,9 @@ import sys errors_encounter = 0 -pattern = re.compile(r"_\(([\"']{,3})(?P((?!\1).)*)\1(\s*,\s*context\s*=\s*([\"'])(?P((?!\5).)*)\5)*(\s*,(\s*?.*?\n*?)*(,\s*([\"'])(?P((?!\11).)*)\11)*)*\)") +pattern = re.compile( + r"_\(([\"']{,3})(?P((?!\1).)*)\1(\s*,\s*context\s*=\s*([\"'])(?P((?!\5).)*)\5)*(\s*,(\s*?.*?\n*?)*(,\s*([\"'])(?P((?!\11).)*)\11)*)*\)" +) words_pattern = re.compile(r"_{1,2}\([\"'`]{1,3}.*?[a-zA-Z]") start_pattern = re.compile(r"_{1,2}\([f\"'`]{1,3}") f_string_pattern = re.compile(r"_\(f[\"']") @@ -10,14 +12,14 @@ # skip first argument files = sys.argv[1:] -files_to_scan = [_file for _file in files if _file.endswith(('.py', '.js'))] +files_to_scan = [_file for _file in files if _file.endswith((".py", ".js"))] for _file in files_to_scan: - with open(_file, 'r') as f: - print(f'Checking: {_file}') + with open(_file, "r") as f: + print(f"Checking: {_file}") file_lines = f.readlines() for line_number, line in enumerate(file_lines, 1): - if 'frappe-lint: disable-translate' in line: + if "frappe-lint: disable-translate" in line: continue start_matches = start_pattern.search(line) @@ -28,7 +30,9 @@ has_f_string = f_string_pattern.search(line) if has_f_string: errors_encounter += 1 - print(f'\nF-strings are not supported for translations at line number {line_number}\n{line.strip()[:100]}') + print( + f"\nF-strings are not supported for translations at line number {line_number}\n{line.strip()[:100]}" + ) continue else: continue @@ -36,25 +40,29 @@ match = pattern.search(line) error_found = False - if not match and line.endswith((',\n', '[\n')): + if not match and line.endswith((",\n", "[\n")): # concat remaining text to validate multiline pattern - line = "".join(file_lines[line_number - 1:]) - line = line[start_matches.start() + 1:] + line = "".join(file_lines[line_number - 1 :]) + line = line[start_matches.start() + 1 :] match = pattern.match(line) if not match: error_found = True - print(f'\nTranslation syntax error at line number {line_number}\n{line.strip()[:100]}') + print(f"\nTranslation syntax error at line number {line_number}\n{line.strip()[:100]}") if not error_found and not words_pattern.search(line): error_found = True - print(f'\nTranslation is useless because it has no words at line number {line_number}\n{line.strip()[:100]}') + print( + f"\nTranslation is useless because it has no words at line number {line_number}\n{line.strip()[:100]}" + ) if error_found: errors_encounter += 1 if errors_encounter > 0: - print('\nVisit "https://frappeframework.com/docs/user/en/translations" to learn about valid translation strings.') + print( + '\nVisit "https://frappeframework.com/docs/user/en/translations" to learn about valid translation strings.' + ) sys.exit(1) else: - print('\nGood To Go!') \ No newline at end of file + print("\nGood To Go!") diff --git a/hrms/controllers/tests/test_employee_reminders.py b/hrms/controllers/tests/test_employee_reminders.py index e9ff45a2d9..dcf9ba5ec2 100644 --- a/hrms/controllers/tests/test_employee_reminders.py +++ b/hrms/controllers/tests/test_employee_reminders.py @@ -36,9 +36,7 @@ def setUpClass(cls): to_date=getdate() + timedelta(weeks=5), ) - test_employee = frappe.get_doc( - "Employee", make_employee("test@gopher.io", company="_Test Company") - ) + test_employee = frappe.get_doc("Employee", make_employee("test@gopher.io", company="_Test Company")) # Attach the holiday list to employee test_employee.holiday_list = test_holiday_list.name @@ -102,9 +100,7 @@ def test_is_holiday(self): self.assertTrue("test holiday1" in descriptions) def test_birthday_reminders(self): - employee = frappe.get_doc( - "Employee", frappe.db.sql_list("select name from tabEmployee limit 1")[0] - ) + employee = frappe.get_doc("Employee", frappe.db.sql_list("select name from tabEmployee limit 1")[0]) employee.date_of_birth = "1992" + frappe.utils.nowdate()[4:] employee.company_email = "test@example.com" employee.company = "_Test Company" diff --git a/hrms/hooks.py b/hrms/hooks.py index f5d2a496ec..77f5df1a47 100644 --- a/hrms/hooks.py +++ b/hrms/hooks.py @@ -110,9 +110,7 @@ # "Event": "frappe.desk.doctype.event.event.has_permission", # } -has_upload_permission = { - "Employee": "erpnext.setup.doctype.employee.employee.has_upload_permission" -} +has_upload_permission = {"Employee": "erpnext.setup.doctype.employee.employee.has_upload_permission"} # DocType Class # --------------- @@ -167,9 +165,7 @@ "after_insert": "hrms.overrides.employee_master.update_job_applicant_and_offer", "on_trash": "hrms.overrides.employee_master.update_employee_transfer", }, - "Project": { - "validate": "hrms.controllers.employee_boarding_controller.update_employee_boarding_status" - }, + "Project": {"validate": "hrms.controllers.employee_boarding_controller.update_employee_boarding_status"}, "Task": {"on_update": "hrms.controllers.employee_boarding_controller.update_task"}, } diff --git a/hrms/hr/dashboard_chart_source/hiring_vs_attrition_count/hiring_vs_attrition_count.py b/hrms/hr/dashboard_chart_source/hiring_vs_attrition_count/hiring_vs_attrition_count.py index bddec58e1b..9f27ffc336 100644 --- a/hrms/hr/dashboard_chart_source/hiring_vs_attrition_count/hiring_vs_attrition_count.py +++ b/hrms/hr/dashboard_chart_source/hiring_vs_attrition_count/hiring_vs_attrition_count.py @@ -47,9 +47,7 @@ def get_data( } -def get_records( - from_date: str, to_date: str, datefield: str, company: str -) -> tuple[tuple[str, float, int]]: +def get_records(from_date: str, to_date: str, datefield: str, company: str) -> tuple[tuple[str, float, int]]: filters = [ ["Employee", "company", "=", company], ["Employee", datefield, ">=", from_date, False], diff --git a/hrms/hr/doctype/appraisal/appraisal.py b/hrms/hr/doctype/appraisal/appraisal.py index b00f402ee8..9ea9b1b9d4 100644 --- a/hrms/hr/doctype/appraisal/appraisal.py +++ b/hrms/hr/doctype/appraisal/appraisal.py @@ -41,7 +41,10 @@ def validate_duplicate(self): | ( (Appraisal.start_date.between(self.start_date, self.end_date)) | (Appraisal.end_date.between(self.start_date, self.end_date)) - | ((self.start_date >= Appraisal.start_date) & (self.start_date <= Appraisal.end_date)) + | ( + (self.start_date >= Appraisal.start_date) + & (self.start_date <= Appraisal.end_date) + ) | ((self.end_date >= Appraisal.start_date) & (self.end_date <= Appraisal.end_date)) ) ) @@ -53,9 +56,7 @@ def validate_duplicate(self): frappe.throw( _( "Appraisal {0} already exists for Employee {1} for this Appraisal Cycle or overlapping period" - ).format( - get_link_to_form("Appraisal", duplicate), frappe.bold(self.employee_name) - ), + ).format(get_link_to_form("Appraisal", duplicate), frappe.bold(self.employee_name)), exc=frappe.DuplicateEntryError, title=_("Duplicate Entry"), ) @@ -308,7 +309,7 @@ def get_kras_for_employee(doctype, txt, searchfield, start, page_len, filters): return frappe.get_all( "Appraisal KRA", - filters={"parent": appraisal, "kra": ("like", "{0}%".format(txt))}, + filters={"parent": appraisal, "kra": ("like", f"{txt}%")}, fields=["kra"], as_list=1, ) diff --git a/hrms/hr/doctype/appraisal/test_appraisal.py b/hrms/hr/doctype/appraisal/test_appraisal.py index dbde091696..216e77a26d 100644 --- a/hrms/hr/doctype/appraisal/test_appraisal.py +++ b/hrms/hr/doctype/appraisal/test_appraisal.py @@ -30,9 +30,7 @@ def setUp(self): engineer.appraisal_template = self.template.name engineer.save() - self.employee1 = make_employee( - "employee1@example.com", company=self.company, designation="Engineer" - ) + self.employee1 = make_employee("employee1@example.com", company=self.company, designation="Engineer") def test_validate_duplicate(self): cycle = create_appraisal_cycle(designation="Engineer") @@ -53,9 +51,7 @@ def test_manual_kra_rating(self): cycle = create_appraisal_cycle(designation="Engineer", kra_evaluation_method="Manual Rating") cycle.create_appraisals() - appraisal = frappe.db.exists( - "Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1} - ) + appraisal = frappe.db.exists("Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1}) appraisal = frappe.get_doc("Appraisal", appraisal) # 30% weightage @@ -74,9 +70,7 @@ def test_final_score(self): cycle = create_appraisal_cycle(designation="Engineer", kra_evaluation_method="Manual Rating") cycle.create_appraisals() - appraisal = frappe.db.exists( - "Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1} - ) + appraisal = frappe.db.exists("Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1}) appraisal = frappe.get_doc("Appraisal", appraisal) # GOAL SCORE @@ -128,9 +122,7 @@ def test_goal_score(self): child2_1 = create_goal(self.employee1, parent_goal=parent2.name, progress=100) child2_2 = create_goal(self.employee1, parent_goal=parent2.name) - appraisal = frappe.db.exists( - "Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1} - ) + appraisal = frappe.db.exists("Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1}) appraisal = frappe.get_doc("Appraisal", appraisal) # Quality KRA, 30% weightage @@ -173,9 +165,7 @@ def test_goal_score_after_parent_goal_change(self): child2_1 = create_goal(self.employee1, parent_goal=parent2.name, progress=50) child2_2 = create_goal(self.employee1, parent_goal=parent2.name) - appraisal = frappe.db.exists( - "Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1} - ) + appraisal = frappe.db.exists("Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1}) appraisal = frappe.get_doc("Appraisal", appraisal) # Quality KRA, 30% weightage @@ -205,9 +195,7 @@ def test_goal_score_after_kra_change(self): goal = create_goal(self.employee1, "Quality", appraisal_cycle=cycle.name, progress=50) - appraisal = frappe.db.exists( - "Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1} - ) + appraisal = frappe.db.exists("Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1}) appraisal = frappe.get_doc("Appraisal", appraisal) # Quality KRA, 30% weightage @@ -231,9 +219,7 @@ def test_goal_score_after_goal_deletion(self): goal = create_goal(self.employee1, "Quality", appraisal_cycle=cycle.name, progress=50) - appraisal = frappe.db.exists( - "Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1} - ) + appraisal = frappe.db.exists("Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1}) appraisal = frappe.get_doc("Appraisal", appraisal) # Quality KRA, 30% weightage @@ -249,9 +235,7 @@ def test_calculate_self_appraisal_score(self): cycle = create_appraisal_cycle(designation="Engineer") cycle.create_appraisals() - appraisal = frappe.db.exists( - "Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1} - ) + appraisal = frappe.db.exists("Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1}) appraisal = frappe.get_doc("Appraisal", appraisal) ratings = appraisal.self_ratings @@ -270,9 +254,7 @@ def test_cycle_completion(self): # unsubmitted appraisals self.assertRaises(frappe.ValidationError, cycle.complete_cycle) - appraisal = frappe.db.exists( - "Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1} - ) + appraisal = frappe.db.exists("Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1}) appraisal = frappe.get_doc("Appraisal", appraisal) appraisal.submit() @@ -295,9 +277,7 @@ def test_cycle_summary(self): cycle = create_appraisal_cycle(designation="Engineer") cycle.create_appraisals() - appraisal = frappe.db.exists( - "Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1} - ) + appraisal = frappe.db.exists("Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1}) appraisal = frappe.get_doc("Appraisal", appraisal) goal = create_goal(self.employee1, "Quality", appraisal_cycle=cycle.name) diff --git a/hrms/hr/doctype/appraisal_cycle/test_appraisal_cycle.py b/hrms/hr/doctype/appraisal_cycle/test_appraisal_cycle.py index 43512a5bc2..6ac8268edc 100644 --- a/hrms/hr/doctype/appraisal_cycle/test_appraisal_cycle.py +++ b/hrms/hr/doctype/appraisal_cycle/test_appraisal_cycle.py @@ -23,9 +23,7 @@ def setUp(self): create_designation(designation_name="Consultant") self.employee1 = make_employee("employee1@example.com", company=company, designation="Engineer") - self.employee2 = make_employee( - "employee2@example.com", company=company, designation="Consultant" - ) + self.employee2 = make_employee("employee2@example.com", company=company, designation="Consultant") def test_set_employees(self): cycle = create_appraisal_cycle(designation="Engineer") diff --git a/hrms/hr/doctype/attendance/attendance.py b/hrms/hr/doctype/attendance/attendance.py index 67d655161d..7a34db7ee7 100644 --- a/hrms/hr/doctype/attendance/attendance.py +++ b/hrms/hr/doctype/attendance/attendance.py @@ -101,7 +101,8 @@ def get_duplicate_attendance_record(self) -> str | None: query = query.where( ((Attendance.shift.isnull()) | (Attendance.shift == "")) | ( - ((Attendance.shift.isnotnull()) | (Attendance.shift != "")) & (Attendance.shift == self.shift) + ((Attendance.shift.isnotnull()) | (Attendance.shift != "")) + & (Attendance.shift == self.shift) ) ) @@ -174,12 +175,16 @@ def check_leave_record(self): if d.half_day_date == getdate(self.attendance_date): self.status = "Half Day" frappe.msgprint( - _("Employee {0} on Half day on {1}").format(self.employee, format_date(self.attendance_date)) + _("Employee {0} on Half day on {1}").format( + self.employee, format_date(self.attendance_date) + ) ) else: self.status = "On Leave" frappe.msgprint( - _("Employee {0} is on Leave on {1}").format(self.employee, format_date(self.attendance_date)) + _("Employee {0} is on Leave on {1}").format( + self.employee, format_date(self.attendance_date) + ) ) if self.status in ("On Leave", "Half Day"): diff --git a/hrms/hr/doctype/attendance/test_attendance.py b/hrms/hr/doctype/attendance/test_attendance.py index 757f2f6cbc..765723321e 100644 --- a/hrms/hr/doctype/attendance/test_attendance.py +++ b/hrms/hr/doctype/attendance/test_attendance.py @@ -147,9 +147,7 @@ def test_mark_absent(self): self.assertEqual(attendance, fetch_attendance) def test_unmarked_days(self): - first_sunday = get_first_sunday( - self.holiday_list, for_date=get_last_day(add_months(getdate(), -1)) - ) + first_sunday = get_first_sunday(self.holiday_list, for_date=get_last_day(add_months(getdate(), -1))) attendance_date = add_days(first_sunday, 1) employee = make_employee( @@ -172,9 +170,7 @@ def test_unmarked_days(self): self.assertIn(first_sunday, unmarked_days) def test_unmarked_days_excluding_holidays(self): - first_sunday = get_first_sunday( - self.holiday_list, for_date=get_last_day(add_months(getdate(), -1)) - ) + first_sunday = get_first_sunday(self.holiday_list, for_date=get_last_day(add_months(getdate(), -1))) attendance_date = add_days(first_sunday, 1) employee = make_employee( @@ -197,9 +193,7 @@ def test_unmarked_days_excluding_holidays(self): self.assertNotIn(first_sunday, unmarked_days) def test_unmarked_days_as_per_joining_and_relieving_dates(self): - first_sunday = get_first_sunday( - self.holiday_list, for_date=get_last_day(add_months(getdate(), -1)) - ) + first_sunday = get_first_sunday(self.holiday_list, for_date=get_last_day(add_months(getdate(), -1))) date = add_days(first_sunday, 1) doj = add_days(date, 1) diff --git a/hrms/hr/doctype/attendance_request/attendance_request.py b/hrms/hr/doctype/attendance_request/attendance_request.py index 64126779f5..15751a4bdf 100644 --- a/hrms/hr/doctype/attendance_request/attendance_request.py +++ b/hrms/hr/doctype/attendance_request/attendance_request.py @@ -49,16 +49,12 @@ def validate_request_overlap(self): self.throw_overlap_error(overlapping_request[0].name) def throw_overlap_error(self, overlapping_request: str): - msg = _( - "Employee {0} already has an Attendance Request {1} that overlaps with this period" - ).format( + msg = _("Employee {0} already has an Attendance Request {1} that overlaps with this period").format( frappe.bold(self.employee), get_link_to_form("Attendance Request", overlapping_request), ) - frappe.throw( - msg, title=_("Overlapping Attendance Request"), exc=OverlappingAttendanceRequestError - ) + frappe.throw(msg, title=_("Overlapping Attendance Request"), exc=OverlappingAttendanceRequestError) def on_submit(self): self.create_attendance_records() diff --git a/hrms/hr/doctype/attendance_request/test_attendance_request.py b/hrms/hr/doctype/attendance_request/test_attendance_request.py index c5dd46ab45..966af4e010 100644 --- a/hrms/hr/doctype/attendance_request/test_attendance_request.py +++ b/hrms/hr/doctype/attendance_request/test_attendance_request.py @@ -125,9 +125,7 @@ def test_skip_attendance_on_leave(self): dict(leave_type_name="Test Skip Attendance", doctype="Leave Type") ).insert() - make_allocation_record( - leave_type=leave_type.name, from_date=self.from_date, to_date=self.to_date - ) + make_allocation_record(leave_type=leave_type.name, from_date=self.from_date, to_date=self.to_date) today = getdate() make_leave_application(self.employee.name, today, add_days(today, 1), leave_type.name) diff --git a/hrms/hr/doctype/compensatory_leave_request/compensatory_leave_request.py b/hrms/hr/doctype/compensatory_leave_request/compensatory_leave_request.py index 49e1c0965c..7302e2ddd1 100644 --- a/hrms/hr/doctype/compensatory_leave_request/compensatory_leave_request.py +++ b/hrms/hr/doctype/compensatory_leave_request/compensatory_leave_request.py @@ -24,9 +24,7 @@ def validate(self): if self.half_day: if not self.half_day_date: frappe.throw(_("Half Day Date is mandatory")) - if ( - not getdate(self.work_from_date) <= getdate(self.half_day_date) <= getdate(self.work_end_date) - ): + if not getdate(self.work_from_date) <= getdate(self.half_day_date) <= getdate(self.work_end_date): frappe.throw(_("Half Day Date should be in between Work From Date and Work End Date")) validate_overlap(self, self.work_from_date, self.work_end_date) self.validate_holidays() @@ -63,7 +61,8 @@ def validate_holidays(self): if len(holidays) < date_diff(self.work_end_date, self.work_from_date) + 1: if date_diff(self.work_end_date, self.work_from_date): msg = _("The days between {0} to {1} are not valid holidays.").format( - frappe.bold(format_date(self.work_from_date)), frappe.bold(format_date(self.work_end_date)) + frappe.bold(format_date(self.work_from_date)), + frappe.bold(format_date(self.work_end_date)), ) else: msg = _("{0} is not a holiday.").format(frappe.bold(format_date(self.work_from_date))) diff --git a/hrms/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py b/hrms/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py index d699f82413..22c6e2f1dc 100644 --- a/hrms/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py +++ b/hrms/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py @@ -38,9 +38,7 @@ def test_leave_balance_on_submit(self): compensatory_leave_request.submit() self.assertEqual( - get_leave_balance_on( - employee.name, compensatory_leave_request.leave_type, add_days(today(), 1) - ), + get_leave_balance_on(employee.name, compensatory_leave_request.leave_type, add_days(today(), 1)), before + 1, ) diff --git a/hrms/hr/doctype/daily_work_summary/test_daily_work_summary.py b/hrms/hr/doctype/daily_work_summary/test_daily_work_summary.py index 1dca9ac8e5..05c725ef91 100644 --- a/hrms/hr/doctype/daily_work_summary/test_daily_work_summary.py +++ b/hrms/hr/doctype/daily_work_summary/test_daily_work_summary.py @@ -36,7 +36,7 @@ def test_email_trigger_failed(self): def test_incoming(self): # get test mail with message-id as in-reply-to self.setup_and_prepare_test() - with open(os.path.join(os.path.dirname(__file__), "test_data", "test-reply.raw"), "r") as f: + with open(os.path.join(os.path.dirname(__file__), "test_data", "test-reply.raw")) as f: if not self.emails: return test_mails = [ @@ -65,9 +65,7 @@ def setup_and_prepare_test(self, hour=None): frappe.db.sql("delete from `tabCommunication`") frappe.db.sql("delete from `tabDaily Work Summary Group`") - self.users = frappe.get_all( - "User", fields=["email"], filters=dict(email=("!=", "test@example.com")) - ) + self.users = frappe.get_all("User", fields=["email"], filters=dict(email=("!=", "test@example.com"))) self.setup_groups(hour) from hrms.hr.doctype.daily_work_summary_group.daily_work_summary_group import trigger_emails diff --git a/hrms/hr/doctype/department_approver/department_approver.py b/hrms/hr/doctype/department_approver/department_approver.py index 7db8bff263..cea20c3679 100644 --- a/hrms/hr/doctype/department_approver/department_approver.py +++ b/hrms/hr/doctype/department_approver/department_approver.py @@ -14,7 +14,6 @@ class DepartmentApprover(Document): @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs def get_approvers(doctype, txt, searchfield, start, page_len, filters): - if not filters.get("employee"): frappe.throw(_("Please select Employee first.")) @@ -55,9 +54,7 @@ def get_approvers(doctype, txt, searchfield, start, page_len, filters): if filters.get("doctype") == "Shift Request" and employee.shift_request_approver: approvers.append( - frappe.db.get_value( - "User", employee.shift_request_approver, ["name", "first_name", "last_name"] - ) + frappe.db.get_value("User", employee.shift_request_approver, ["name", "first_name", "last_name"]) ) if filters.get("doctype") == "Leave Application": diff --git a/hrms/hr/doctype/employee_advance/test_employee_advance.py b/hrms/hr/doctype/employee_advance/test_employee_advance.py index 109722b3ac..a37f9ad938 100644 --- a/hrms/hr/doctype/employee_advance/test_employee_advance.py +++ b/hrms/hr/doctype/employee_advance/test_employee_advance.py @@ -166,9 +166,7 @@ def test_repay_unclaimed_amount_from_salary(self): args = {"type": "Deduction"} create_salary_component("Advance Salary - Deduction", **args) - make_salary_structure( - "Test Additional Salary for Advance Return", "Monthly", employee=employee_name - ) + make_salary_structure("Test Additional Salary for Advance Return", "Monthly", employee=employee_name) # additional salary for 700 first advance.reload() diff --git a/hrms/hr/doctype/employee_checkin/employee_checkin.py b/hrms/hr/doctype/employee_checkin/employee_checkin.py index 90eed4d760..2027ac4b9d 100644 --- a/hrms/hr/doctype/employee_checkin/employee_checkin.py +++ b/hrms/hr/doctype/employee_checkin/employee_checkin.py @@ -197,9 +197,7 @@ def calculate_working_hours(logs, check_in_out_type, working_hours_calc_type): elif check_in_out_type == "Strictly based on Log Type in Employee Checkin": if working_hours_calc_type == "First Check-in and Last Check-out": first_in_log_index = find_index_in_dict(logs, "log_type", "IN") - first_in_log = ( - logs[first_in_log_index] if first_in_log_index or first_in_log_index == 0 else None - ) + first_in_log = logs[first_in_log_index] if first_in_log_index or first_in_log_index == 0 else None last_out_log_index = find_index_in_dict(reversed(logs), "log_type", "OUT") last_out_log = ( logs[len(logs) - 1 - last_out_log_index] diff --git a/hrms/hr/doctype/employee_checkin/test_employee_checkin.py b/hrms/hr/doctype/employee_checkin/test_employee_checkin.py index 8cda9b017f..c25a30bed7 100644 --- a/hrms/hr/doctype/employee_checkin/test_employee_checkin.py +++ b/hrms/hr/doctype/employee_checkin/test_employee_checkin.py @@ -85,7 +85,7 @@ def test_unlink_attendance_on_cancellation(self): attendance.cancel() linked_logs = frappe.db.get_all("Employee Checkin", {"attendance": attendance.name}) - self.assertEquals(len(linked_logs), 0) + self.assertEqual(len(linked_logs), 0) def test_calculate_working_hours(self): check_in_out_type = [ @@ -116,24 +116,16 @@ def test_calculate_working_hours(self): logs_type_1 = [frappe._dict(x) for x in logs_type_1] logs_type_2 = [frappe._dict(x) for x in logs_type_2] - working_hours = calculate_working_hours( - logs_type_1, check_in_out_type[0], working_hours_calc_type[0] - ) + working_hours = calculate_working_hours(logs_type_1, check_in_out_type[0], working_hours_calc_type[0]) self.assertEqual(working_hours, (6.5, logs_type_1[0].time, logs_type_1[-1].time)) - working_hours = calculate_working_hours( - logs_type_1, check_in_out_type[0], working_hours_calc_type[1] - ) + working_hours = calculate_working_hours(logs_type_1, check_in_out_type[0], working_hours_calc_type[1]) self.assertEqual(working_hours, (4.5, logs_type_1[0].time, logs_type_1[-1].time)) - working_hours = calculate_working_hours( - logs_type_2, check_in_out_type[1], working_hours_calc_type[0] - ) + working_hours = calculate_working_hours(logs_type_2, check_in_out_type[1], working_hours_calc_type[0]) self.assertEqual(working_hours, (5, logs_type_2[1].time, logs_type_2[-1].time)) - working_hours = calculate_working_hours( - logs_type_2, check_in_out_type[1], working_hours_calc_type[1] - ) + working_hours = calculate_working_hours(logs_type_2, check_in_out_type[1], working_hours_calc_type[1]) self.assertEqual(working_hours, (4.5, logs_type_2[1].time, logs_type_2[-1].time)) working_hours = calculate_working_hours( @@ -229,9 +221,7 @@ def test_fetch_shift_based_on_default_shift(self): def test_fetch_night_shift_for_assignment_without_end_date(self): """Tests if shift is correctly fetched in logs when assignment has no end date""" employee = make_employee("test_employee_checkin@example.com", company="_Test Company") - shift_type = setup_shift_type( - shift_type="Midnight Shift", start_time="23:00:00", end_time="01:00:00" - ) + shift_type = setup_shift_type(shift_type="Midnight Shift", start_time="23:00:00", end_time="01:00:00") date = getdate() next_day = add_days(date, 1) make_shift_assignment(shift_type.name, employee, date) @@ -256,9 +246,7 @@ def test_fetch_night_shift_on_assignment_boundary(self): Tests if shift is correctly fetched in logs when assignment starts and ends on the same day """ employee = make_employee("test_employee_checkin@example.com", company="_Test Company") - shift_type = setup_shift_type( - shift_type="Midnight Shift", start_time="23:00:00", end_time="07:00:00" - ) + shift_type = setup_shift_type(shift_type="Midnight Shift", start_time="23:00:00", end_time="07:00:00") date = getdate() next_day = add_days(date, 1) @@ -280,9 +268,7 @@ def test_fetch_night_shift_on_assignment_boundary(self): def test_night_shift_not_fetched_outside_assignment_boundary_for_diff_start_date(self): employee = make_employee("test_employee_checkin@example.com", company="_Test Company") - shift_type = setup_shift_type( - shift_type="Midnight Shift", start_time="23:00:00", end_time="07:00:00" - ) + shift_type = setup_shift_type(shift_type="Midnight Shift", start_time="23:00:00", end_time="07:00:00") date = getdate() next_day = add_days(date, 1) prev_day = add_days(date, -1) @@ -304,9 +290,7 @@ def test_night_shift_not_fetched_outside_assignment_boundary_for_diff_start_date def test_night_shift_not_fetched_outside_assignment_boundary_for_diff_end_date(self): employee = make_employee("test_employee_checkin@example.com", company="_Test Company") - shift_type = setup_shift_type( - shift_type="Midnight Shift", start_time="19:00:00", end_time="00:30:00" - ) + shift_type = setup_shift_type(shift_type="Midnight Shift", start_time="19:00:00", end_time="00:30:00") date = getdate() next_day = add_days(date, 1) prev_day = add_days(date, -1) @@ -328,9 +312,7 @@ def test_night_shift_not_fetched_outside_assignment_boundary_for_diff_end_date(s def test_night_shift_not_fetched_outside_before_shift_margin(self): employee = make_employee("test_employee_checkin@example.com", company="_Test Company") - shift_type = setup_shift_type( - shift_type="Midnight Shift", start_time="00:30:00", end_time="10:00:00" - ) + shift_type = setup_shift_type(shift_type="Midnight Shift", start_time="00:30:00", end_time="10:00:00") date = getdate() next_day = add_days(date, 1) prev_day = add_days(date, -1) @@ -352,9 +334,7 @@ def test_night_shift_not_fetched_outside_before_shift_margin(self): def test_night_shift_not_fetched_outside_after_shift_margin(self): employee = make_employee("test_employee_checkin@example.com", company="_Test Company") - shift_type = setup_shift_type( - shift_type="Midnight Shift", start_time="15:00:00", end_time="23:30:00" - ) + shift_type = setup_shift_type(shift_type="Midnight Shift", start_time="15:00:00", end_time="23:30:00") date = getdate() next_day = add_days(date, 1) prev_day = add_days(date, -1) @@ -451,9 +431,7 @@ def test_consecutive_shift_assignments_overlapping_within_grace_period(self): # 8 - 12 shift1 = setup_shift_type() # 12:30 - 16:30 - shift2 = setup_shift_type( - shift_type="Consecutive Shift", start_time="12:30:00", end_time="16:30:00" - ) + shift2 = setup_shift_type(shift_type="Consecutive Shift", start_time="12:30:00", end_time="16:30:00") # the actual start and end times (with grace) for these shifts are 7 - 13 and 11:30 - 17:30 date = getdate() @@ -483,9 +461,7 @@ def test_consecutive_shift_assignments_overlapping_within_grace_period(self): def make_n_checkins(employee, n, hours_to_reverse=1): logs = [make_checkin(employee, now_datetime() - timedelta(hours=hours_to_reverse, minutes=n + 1))] for i in range(n - 1): - logs.append( - make_checkin(employee, now_datetime() - timedelta(hours=hours_to_reverse, minutes=n - i)) - ) + logs.append(make_checkin(employee, now_datetime() - timedelta(hours=hours_to_reverse, minutes=n - i))) return logs diff --git a/hrms/hr/doctype/employee_promotion/employee_promotion.py b/hrms/hr/doctype/employee_promotion/employee_promotion.py index e0cc316a8e..e40ca5b677 100644 --- a/hrms/hr/doctype/employee_promotion/employee_promotion.py +++ b/hrms/hr/doctype/employee_promotion/employee_promotion.py @@ -23,9 +23,7 @@ def before_submit(self): def on_submit(self): employee = frappe.get_doc("Employee", self.employee) - employee = update_employee_work_history( - employee, self.promotion_details, date=self.promotion_date - ) + employee = update_employee_work_history(employee, self.promotion_details, date=self.promotion_date) if self.revised_ctc: employee.ctc = self.revised_ctc diff --git a/hrms/hr/doctype/employee_transfer/employee_transfer.py b/hrms/hr/doctype/employee_transfer/employee_transfer.py index 2cdb49294f..7b71552da3 100644 --- a/hrms/hr/doctype/employee_transfer/employee_transfer.py +++ b/hrms/hr/doctype/employee_transfer/employee_transfer.py @@ -41,9 +41,7 @@ def on_submit(self): employee.db_set("relieving_date", self.transfer_date) employee.db_set("status", "Left") else: - employee = update_employee_work_history( - employee, self.transfer_details, date=self.transfer_date - ) + employee = update_employee_work_history(employee, self.transfer_details, date=self.transfer_date) if self.new_company and self.company != self.new_company: employee.company = self.new_company employee.date_of_joining = self.transfer_date @@ -55,7 +53,7 @@ def on_cancel(self): if self.new_employee_id: frappe.throw( _("Please delete the Employee {0} to cancel this document").format( - "{0}".format(self.new_employee_id) + f"{self.new_employee_id}" ) ) # mark the employee as active diff --git a/hrms/hr/doctype/exit_interview/exit_interview.py b/hrms/hr/doctype/exit_interview/exit_interview.py index ea247654c5..ebfcd82e43 100644 --- a/hrms/hr/doctype/exit_interview/exit_interview.py +++ b/hrms/hr/doctype/exit_interview/exit_interview.py @@ -75,9 +75,7 @@ def send_exit_questionnaire(interviews): context = interview.as_dict() context.update(employee.as_dict()) - template_name = frappe.db.get_single_value( - "HR Settings", "exit_questionnaire_notification_template" - ) + template_name = frappe.db.get_single_value("HR Settings", "exit_questionnaire_notification_template") template = frappe.get_doc("Email Template", template_name) if email: @@ -117,9 +115,7 @@ def validate_questionnaire_settings(): as_dict=True, ) - if ( - not settings.exit_questionnaire_web_form or not settings.exit_questionnaire_notification_template - ): + if not settings.exit_questionnaire_web_form or not settings.exit_questionnaire_notification_template: frappe.throw( _("Please set {0} and {1} in {2}.").format( frappe.bold("Exit Questionnaire Web Form"), @@ -141,6 +137,4 @@ def show_email_summary(email_success, email_failure): frappe.bold("Sending Failed"), ", ".join(email_failure) ) - frappe.msgprint( - message, title=_("Exit Questionnaire"), indicator="blue", is_minimizable=True, wide=True - ) + frappe.msgprint(message, title=_("Exit Questionnaire"), indicator="blue", is_minimizable=True, wide=True) diff --git a/hrms/hr/doctype/expense_claim/test_expense_claim.py b/hrms/hr/doctype/expense_claim/test_expense_claim.py index b4f99c0714..634ba94e39 100644 --- a/hrms/hr/doctype/expense_claim/test_expense_claim.py +++ b/hrms/hr/doctype/expense_claim/test_expense_claim.py @@ -49,9 +49,7 @@ def test_total_expense_claim_for_project(self): payable_account = get_payable_account(company_name) - make_expense_claim( - payable_account, 300, 200, company_name, "Travel Expenses - _TC3", project, task - ) + make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC3", project, task) self.assertEqual(frappe.db.get_value("Task", task, "total_expense_claim"), 200) self.assertEqual(frappe.db.get_value("Project", project, "total_expense_claim"), 200) @@ -71,9 +69,7 @@ def test_total_expense_claim_for_project(self): def test_expense_claim_status_as_payment_from_journal_entry(self): # Via Journal Entry payable_account = get_payable_account(company_name) - expense_claim = make_expense_claim( - payable_account, 300, 200, company_name, "Travel Expenses - _TC3" - ) + expense_claim = make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC3") je = make_journal_entry(expense_claim) @@ -90,18 +86,14 @@ def test_expense_claim_status_as_payment_from_journal_entry(self): self.assertEqual(claim.status, "Submitted") # no gl entries created - gl_entry = frappe.get_all( - "GL Entry", {"voucher_type": "Expense Claim", "voucher_no": claim.name} - ) + gl_entry = frappe.get_all("GL Entry", {"voucher_type": "Expense Claim", "voucher_no": claim.name}) self.assertEqual(len(gl_entry), 0) def test_expense_claim_status_as_payment_from_payment_entry(self): # Via Payment Entry payable_account = get_payable_account(company_name) - expense_claim = make_expense_claim( - payable_account, 300, 200, company_name, "Travel Expenses - _TC3" - ) + expense_claim = make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC3") pe = make_payment_entry(expense_claim, 200) @@ -124,9 +116,7 @@ def test_expense_claim_status_as_payment_allocation_using_pr(self): if not employee: employee = make_employee("test_employee1@expenseclaim.com", company=company_name) - expense_claim1 = make_expense_claim( - payable_account, 300, 200, company_name, "Travel Expenses - _TC3" - ) + expense_claim1 = make_expense_claim(payable_account, 300, 200, company_name, "Travel Expenses - _TC3") expense_claim2 = make_expense_claim( payable_account, 300, 200, company_name, "Travel Expenses - _TC3", employee=employee @@ -614,15 +604,12 @@ def make_expense_claim( taxes=None, employee=None, ): - if not employee: employee = frappe.db.get_value("Employee", {"status": "Active", "company": company}) if not employee: employee = make_employee("test_employee@expenseclaim.com", company=company) - currency, cost_center = frappe.db.get_value( - "Company", company, ["default_currency", "cost_center"] - ) + currency, cost_center = frappe.db.get_value("Company", company, ["default_currency", "cost_center"]) expense_claim = { "doctype": "Expense Claim", "employee": employee, diff --git a/hrms/hr/doctype/expense_claim_type/expense_claim_type.py b/hrms/hr/doctype/expense_claim_type/expense_claim_type.py index 6d29f7d8e7..0fb974794c 100644 --- a/hrms/hr/doctype/expense_claim_type/expense_claim_type.py +++ b/hrms/hr/doctype/expense_claim_type/expense_claim_type.py @@ -26,5 +26,7 @@ def validate_accounts(self): """Error when Company of Ledger account doesn't match with Company Selected""" if frappe.db.get_value("Account", entry.default_account, "company") != entry.company: frappe.throw( - _("Account {0} does not match with Company {1}").format(entry.default_account, entry.company) + _("Account {0} does not match with Company {1}").format( + entry.default_account, entry.company + ) ) diff --git a/hrms/hr/doctype/full_and_final_statement/full_and_final_statement.py b/hrms/hr/doctype/full_and_final_statement/full_and_final_statement.py index d08cdafde7..5bb3026cd0 100644 --- a/hrms/hr/doctype/full_and_final_statement/full_and_final_statement.py +++ b/hrms/hr/doctype/full_and_final_statement/full_and_final_statement.py @@ -182,9 +182,7 @@ def get_account_and_amount(ref_doctype, ref_document): return [payable_account, amount] if ref_doctype == "Gratuity": - payable_account, amount = frappe.db.get_value( - "Gratuity", ref_document, ["payable_account", "amount"] - ) + payable_account, amount = frappe.db.get_value("Gratuity", ref_document, ["payable_account", "amount"]) return [payable_account, amount] if ref_doctype == "Expense Claim": diff --git a/hrms/hr/doctype/full_and_final_statement/test_full_and_final_statement.py b/hrms/hr/doctype/full_and_final_statement/test_full_and_final_statement.py index b9dccd9d67..b400e6ccd4 100644 --- a/hrms/hr/doctype/full_and_final_statement/test_full_and_final_statement.py +++ b/hrms/hr/doctype/full_and_final_statement/test_full_and_final_statement.py @@ -68,9 +68,7 @@ def create_asset_movement(employee): def create_asset(): - pr = make_purchase_receipt( - item_code="Macbook Pro", qty=1, rate=100000.0, location="Test Location" - ) + pr = make_purchase_receipt(item_code="Macbook Pro", qty=1, rate=100000.0, location="Test Location") asset_name = frappe.db.get_value("Asset", {"purchase_receipt": pr.name}, "name") asset = frappe.get_doc("Asset", asset_name) diff --git a/hrms/hr/doctype/interview/interview.py b/hrms/hr/doctype/interview/interview.py index 1294576ff4..09154afff1 100644 --- a/hrms/hr/doctype/interview/interview.py +++ b/hrms/hr/doctype/interview/interview.py @@ -52,9 +52,7 @@ def validate_designation(self): frappe.throw( _( "Interview Round {0} is only for Designation {1}. Job Applicant has applied for the role {2}" - ).format( - self.interview_round, frappe.bold(self.designation), applicant_designation - ), + ).format(self.interview_round, frappe.bold(self.designation), applicant_designation), exc=DuplicateInterviewRoundError, ) else: @@ -155,7 +153,9 @@ def reschedule_interview(self, scheduled_on, from_time, to_time): ) except Exception: frappe.msgprint( - _("Failed to send the Interview Reschedule notification. Please configure your email account.") + _( + "Failed to send the Interview Reschedule notification. Please configure your email account." + ) ) frappe.msgprint(_("Interview Rescheduled successfully"), indicator="green") @@ -204,9 +204,7 @@ def update_job_applicant_status(args): @frappe.whitelist() def get_interviewers(interview_round): - return frappe.get_all( - "Interviewer", filters={"parent": interview_round}, fields=["user as interviewer"] - ) + return frappe.get_all("Interviewer", filters={"parent": interview_round}, fields=["user as interviewer"]) def send_interview_reminder(): @@ -236,9 +234,7 @@ def send_interview_reminder(): }, ) - interview_template = frappe.get_doc( - "Email Template", reminder_settings.interview_reminder_template - ) + interview_template = frappe.get_doc("Email Template", reminder_settings.interview_reminder_template) for d in interviews: doc = frappe.get_doc("Interview", d.name) @@ -349,7 +345,7 @@ def create_interview_feedback(data, interview_name, interviewer, job_applicant): @frappe.validate_and_sanitize_search_inputs def get_interviewer_list(doctype, txt, searchfield, start, page_len, filters): filters = [ - ["Has Role", "parent", "like", "%{}%".format(txt)], + ["Has Role", "parent", "like", f"%{txt}%"], ["Has Role", "role", "=", "interviewer"], ["Has Role", "parenttype", "=", "User"], ] @@ -389,7 +385,7 @@ def get_events(start, end, filters=None): conditions = get_event_conditions("Interview", filters) interviews = frappe.db.sql( - """ + f""" SELECT DISTINCT `tabInterview`.name, `tabInterview`.job_applicant, `tabInterview`.interview_round, `tabInterview`.scheduled_on, `tabInterview`.status, `tabInterview`.from_time as from_time, @@ -400,9 +396,7 @@ def get_events(start, end, filters=None): (`tabInterview`.scheduled_on between %(start)s and %(end)s) and docstatus != 2 {conditions} - """.format( - conditions=conditions - ), + """, {"start": start, "end": end}, as_dict=True, update={"allDay": 0}, diff --git a/hrms/hr/doctype/interview_feedback/interview_feedback.py b/hrms/hr/doctype/interview_feedback/interview_feedback.py index 5bb498fa54..f6669e90fb 100644 --- a/hrms/hr/doctype/interview_feedback/interview_feedback.py +++ b/hrms/hr/doctype/interview_feedback/interview_feedback.py @@ -50,9 +50,7 @@ def validate_duplicate(self): frappe.throw( _( "Feedback already submitted for the Interview {0}. Please cancel the previous Interview Feedback {1} to continue." - ).format( - self.interview, get_link_to_form("Interview Feedback", duplicate_feedback) - ) + ).format(self.interview, get_link_to_form("Interview Feedback", duplicate_feedback)) ) def calculate_average_rating(self): diff --git a/hrms/hr/doctype/interview_feedback/test_interview_feedback.py b/hrms/hr/doctype/interview_feedback/test_interview_feedback.py index 1fff4c86e2..5c0e51a58e 100644 --- a/hrms/hr/doctype/interview_feedback/test_interview_feedback.py +++ b/hrms/hr/doctype/interview_feedback/test_interview_feedback.py @@ -104,9 +104,7 @@ def create_interview_feedback(interview, interviewer, skills_ratings): def get_skills_rating(interview_round): import random - skills = frappe.get_all( - "Expected Skill Set", filters={"parent": interview_round}, fields=["skill"] - ) + skills = frappe.get_all("Expected Skill Set", filters={"parent": interview_round}, fields=["skill"]) for d in skills: d["rating"] = random.random() return skills diff --git a/hrms/hr/doctype/job_opening/job_opening.py b/hrms/hr/doctype/job_opening/job_opening.py index 266a6a21d3..cb9d85cb45 100644 --- a/hrms/hr/doctype/job_opening/job_opening.py +++ b/hrms/hr/doctype/job_opening/job_opening.py @@ -82,9 +82,7 @@ def get_list_context(context): context.get_list = get_job_openings -def get_job_openings( - doctype, txt=None, filters=None, limit_start=0, limit_page_length=20, order_by=None -): +def get_job_openings(doctype, txt=None, filters=None, limit_start=0, limit_page_length=20, order_by=None): fields = [ "name", "status", @@ -101,9 +99,7 @@ def get_job_openings( filters.update({"status": "Open"}) if txt: - filters.update( - {"job_title": ["like", "%{0}%".format(txt)], "description": ["like", "%{0}%".format(txt)]} - ) + filters.update({"job_title": ["like", f"%{txt}%"], "description": ["like", f"%{txt}%"]}) return frappe.get_all( doctype, filters, fields, start=limit_start, page_length=limit_page_length, order_by=order_by diff --git a/hrms/hr/doctype/job_opening/test_job_opening.py b/hrms/hr/doctype/job_opening/test_job_opening.py index 2148281678..60aaab4fbd 100644 --- a/hrms/hr/doctype/job_opening/test_job_opening.py +++ b/hrms/hr/doctype/job_opening/test_job_opening.py @@ -20,9 +20,7 @@ def setUp(self): frappe.db.delete("Employee", {"company": "_Test Opening Company"}) def test_vacancies_fulfilled(self): - make_employee( - "test_job_opening@example.com", company="_Test Opening Company", designation="Designer" - ) + make_employee("test_job_opening@example.com", company="_Test Opening Company", designation="Designer") staffing_plan = frappe.get_doc( { diff --git a/hrms/hr/doctype/job_requisition/test_job_requisition.py b/hrms/hr/doctype/job_requisition/test_job_requisition.py index 2d68ab5952..808ea51ffc 100644 --- a/hrms/hr/doctype/job_requisition/test_job_requisition.py +++ b/hrms/hr/doctype/job_requisition/test_job_requisition.py @@ -54,8 +54,7 @@ def make_job_requisition(**args): { "doctype": "Job Requisition", "designation": args.designation or create_designation().name, - "department": args.department - or frappe.db.get_value("Employee", args.requested_by, "department"), + "department": args.department or frappe.db.get_value("Employee", args.requested_by, "department"), "no_of_positions": args.no_of_positions or 1, "expected_compensation": args.expected_compensation or 500000, "company": "_Test Company", diff --git a/hrms/hr/doctype/leave_allocation/leave_allocation.py b/hrms/hr/doctype/leave_allocation/leave_allocation.py index ae1c3521f0..2631f691db 100755 --- a/hrms/hr/doctype/leave_allocation/leave_allocation.py +++ b/hrms/hr/doctype/leave_allocation/leave_allocation.py @@ -205,7 +205,7 @@ def validate_allocation_overlap(self): frappe.throw( _("Reference") - + ': {0}'.format(leave_allocation[0][0]), + + f': {leave_allocation[0][0]}', OverlapError, ) @@ -248,9 +248,7 @@ def set_total_leaves_allocated(self): and not frappe.db.get_value("Leave Type", self.leave_type, "is_earned_leave") and not frappe.db.get_value("Leave Type", self.leave_type, "is_compensatory") ): - frappe.throw( - _("Total leaves allocated is mandatory for Leave Type {0}").format(self.leave_type) - ) + frappe.throw(_("Total leaves allocated is mandatory for Leave Type {0}").format(self.leave_type)) def limit_carry_forward_based_on_max_allowed_leaves(self): max_leaves_allowed = frappe.db.get_value("Leave Type", self.leave_type, "max_leaves_allowed") @@ -277,13 +275,17 @@ def validate_total_leaves_allocated(self): if date_difference < self.total_leaves_allocated: if frappe.db.get_value("Leave Type", self.leave_type, "allow_over_allocation"): frappe.msgprint( - _("Total Leaves Allocated are more than the number of days in the allocation period"), + _( + "Total Leaves Allocated are more than the number of days in the allocation period" + ), indicator="orange", alert=True, ) else: frappe.throw( - _("Total Leaves Allocated are more than the number of days in the allocation period"), + _( + "Total Leaves Allocated are more than the number of days in the allocation period" + ), exc=OverAllocationError, title=_("Over Allocation"), ) @@ -336,9 +338,7 @@ def get_previous_allocation(from_date, leave_type, employee): return allocations[0] if allocations else None -def get_leave_allocation_for_period( - employee, leave_type, from_date, to_date, exclude_allocation=None -): +def get_leave_allocation_for_period(employee, leave_type, from_date, to_date, exclude_allocation=None): from frappe.query_builder.functions import Sum Allocation = frappe.qb.DocType("Leave Allocation") diff --git a/hrms/hr/doctype/leave_allocation/test_earned_leaves.py b/hrms/hr/doctype/leave_allocation/test_earned_leaves.py index a8dc9c45f1..5f036b04e6 100644 --- a/hrms/hr/doctype/leave_allocation/test_earned_leaves.py +++ b/hrms/hr/doctype/leave_allocation/test_earned_leaves.py @@ -140,9 +140,7 @@ def test_alloc_based_on_joining_date(self): # assignment created on the last day of the current month frappe.flags.current_date = get_last_day(getdate()) - leave_policy_assignments = make_policy_assignment( - self.employee, assignment_based_on="Joining Date" - ) + leave_policy_assignments = make_policy_assignment(self.employee, assignment_based_on="Joining Date") leaves_allocated = get_allocated_leaves(leave_policy_assignments[0]) effective_from = frappe.db.get_value( "Leave Policy Assignment", leave_policy_assignments[0], "effective_from" @@ -356,9 +354,7 @@ def test_allocate_on_date_of_joining(self): self.employee, allocate_on_day="Date of Joining", start_date=start_date ) leaves_allocated = get_allocated_leaves(leave_policy_assignments[0]) - pro_rated_leave = round_earned_leaves( - calculate_pro_rated_leaves(1, doj, start_date, end_date), "0.5" - ) + pro_rated_leave = round_earned_leaves(calculate_pro_rated_leaves(1, doj, start_date, end_date), "0.5") self.assertEqual(leaves_allocated, pro_rated_leave) # Case 2: Doesn't allocate before the current month's doj (via scheduler) @@ -540,9 +536,7 @@ def make_policy_assignment( { "doctype": "Leave Policy", "title": "Test Earned Leave Policy", - "leave_policy_details": [ - {"leave_type": leave_type.name, "annual_allocation": annual_allocation} - ], + "leave_policy_details": [{"leave_type": leave_type.name, "annual_allocation": annual_allocation}], } ).insert() @@ -553,9 +547,7 @@ def make_policy_assignment( "carry_forward": carry_forward, } - leave_policy_assignments = create_assignment_for_multiple_employees( - [employee.name], frappe._dict(data) - ) + leave_policy_assignments = create_assignment_for_multiple_employees([employee.name], frappe._dict(data)) return leave_policy_assignments diff --git a/hrms/hr/doctype/leave_allocation/test_leave_allocation.py b/hrms/hr/doctype/leave_allocation/test_leave_allocation.py index 990d0ed7e2..7a8d960108 100644 --- a/hrms/hr/doctype/leave_allocation/test_leave_allocation.py +++ b/hrms/hr/doctype/leave_allocation/test_leave_allocation.py @@ -475,9 +475,7 @@ def test_creation_of_leave_ledger_entry_on_submit(self): # check if leave ledger entry is deleted on cancellation leave_allocation.cancel() - self.assertFalse( - frappe.db.exists("Leave Ledger Entry", {"transaction_name": leave_allocation.name}) - ) + self.assertFalse(frappe.db.exists("Leave Ledger Entry", {"transaction_name": leave_allocation.name})) def test_leave_addition_after_submit(self): leave_allocation = create_leave_allocation( diff --git a/hrms/hr/doctype/leave_application/leave_application.py b/hrms/hr/doctype/leave_application/leave_application.py index 30c53dc67a..53890393d8 100755 --- a/hrms/hr/doctype/leave_application/leave_application.py +++ b/hrms/hr/doctype/leave_application/leave_application.py @@ -91,9 +91,7 @@ def on_update(self): def on_submit(self): if self.status in ["Open", "Cancelled"]: - frappe.throw( - _("Only Leave Applications with status 'Approved' and 'Rejected' can be submitted") - ) + frappe.throw(_("Only Leave Applications with status 'Approved' and 'Rejected' can be submitted")) self.validate_back_dated_application() self.update_attendance() @@ -170,7 +168,6 @@ def validate_dates(self): or getdate(self.half_day_date) > getdate(self.to_date) ) ): - frappe.throw(_("Half Day Date should be between From Date and To Date")) if not is_lwp(self.leave_type): @@ -191,7 +188,7 @@ def validate_dates_across_allocation(self): exc=LeaveAcrossAllocationsError, ) - def get_allocation_based_on_application_dates(self) -> Tuple[Dict, Dict]: + def get_allocation_based_on_application_dates(self) -> tuple[dict, dict]: """Returns allocation name, from and to dates for application dates""" def _get_leave_allocation_record(date): @@ -260,9 +257,7 @@ def update_attendance(self): def create_or_update_attendance(self, attendance_name, date): status = ( - "Half Day" - if self.half_day_date and getdate(date) == getdate(self.half_day_date) - else "On Leave" + "Half Day" if self.half_day_date and getdate(date) == getdate(self.half_day_date) else "On Leave" ) if attendance_name: @@ -312,9 +307,7 @@ def validate_salary_processed_days(self): frappe.throw( _( "Salary already processed for period between {0} and {1}, Leave application period cannot be between this date range." - ).format( - formatdate(last_processed_pay_slip[0][0]), formatdate(last_processed_pay_slip[0][1]) - ) + ).format(formatdate(last_processed_pay_slip[0][0]), formatdate(last_processed_pay_slip[0][1])) ) def show_block_day_warning(self): @@ -343,7 +336,12 @@ def validate_block_days(self): def validate_balance_leaves(self): if self.from_date and self.to_date: self.total_leave_days = get_number_of_leave_days( - self.employee, self.leave_type, self.from_date, self.to_date, self.half_day, self.half_day_date + self.employee, + self.leave_type, + self.from_date, + self.to_date, + self.half_day, + self.half_day_date, ) if self.total_leave_days <= 0: @@ -416,7 +414,6 @@ def validate_leave_overlap(self): }, as_dict=1, ): - if ( cint(self.half_day) == 1 and getdate(self.half_day_date) == getdate(d.half_day_date) @@ -426,7 +423,6 @@ def validate_leave_overlap(self): or getdate(self.to_date) == getdate(d.from_date) ) ): - total_leaves_on_half_day = self.get_total_leaves_on_half_day() if total_leaves_on_half_day >= 1: self.throw_overlap_error(d) @@ -467,7 +463,9 @@ def validate_max_days(self): ) if details.leave_applications: msg += "

" + _("Reference: {0}").format( - ", ".join(get_link_to_form("Leave Application", name) for name in details.leave_applications) + ", ".join( + get_link_to_form("Leave Application", name) for name in details.leave_applications + ) ) frappe.throw(msg, title=_("Maximum Consecutive Leaves Exceeded")) @@ -673,15 +671,13 @@ def create_leave_ledger_entry(self, submit=True): create_leave_ledger_entry(self, args, submit) def is_separate_ledger_entry_required( - self, alloc_on_from_date: Optional[Dict] = None, alloc_on_to_date: Optional[Dict] = None + self, alloc_on_from_date: dict | None = None, alloc_on_to_date: dict | None = None ) -> bool: """Checks if application dates fall in separate allocations""" if ( (alloc_on_from_date and not alloc_on_to_date) or (not alloc_on_from_date and alloc_on_to_date) - or ( - alloc_on_from_date and alloc_on_to_date and alloc_on_from_date.name != alloc_on_to_date.name - ) + or (alloc_on_from_date and alloc_on_to_date and alloc_on_from_date.name != alloc_on_to_date.name) ): return True return False @@ -732,8 +728,7 @@ def create_separate_ledger_entries(self, alloc_on_from_date, alloc_on_to_date, s args = dict( is_lwp=lwp, - holiday_list=get_holiday_list_for_employee(self.employee, raise_exception=raise_exception) - or "", + holiday_list=get_holiday_list_for_employee(self.employee, raise_exception=raise_exception) or "", ) if leaves_in_first_alloc: @@ -806,9 +801,9 @@ def get_number_of_leave_days( leave_type: str, from_date: datetime.date, to_date: datetime.date, - half_day: Union[int, str, None] = None, - half_day_date: Union[datetime.date, str, None] = None, - holiday_list: Optional[str] = None, + half_day: int | str | None = None, + half_day_date: datetime.date | str | None = None, + holiday_list: str | None = None, ) -> float: """Returns number of leave days between 2 dates after considering half day and holidays (Based on the include_holiday setting in Leave Type)""" @@ -844,9 +839,7 @@ def get_leave_details(employee, date): end_date = allocation.to_date leaves_taken = get_leaves_for_period(employee, d, allocation.from_date, end_date) * -1 - leaves_pending = get_leaves_pending_approval_for_period( - employee, d, allocation.from_date, end_date - ) + leaves_pending = get_leaves_pending_approval_for_period(employee, d, allocation.from_date, end_date) expired_leaves = allocation.total_leaves_allocated - (remaining_leaves + leaves_taken) leave_allocation[d] = { @@ -872,7 +865,7 @@ def get_leave_balance_on( employee: str, leave_type: str, date: datetime.date, - to_date: Union[datetime.date, None] = None, + to_date: datetime.date | None = None, consider_all_leaves_in_the_allocation_period: bool = False, for_consumption: bool = False, ): @@ -897,9 +890,7 @@ def get_leave_balance_on( allocation = allocation_records.get(leave_type, frappe._dict()) end_date = allocation.to_date if cint(consider_all_leaves_in_the_allocation_period) else date - cf_expiry = get_allocation_expiry_for_cf_leaves( - employee, leave_type, to_date, allocation.from_date - ) + cf_expiry = get_allocation_expiry_for_cf_leaves(employee, leave_type, to_date, allocation.from_date) leaves_taken = get_leaves_for_period(employee, leave_type, allocation.from_date, end_date) @@ -916,14 +907,10 @@ def get_leave_allocation_records(employee, date, leave_type=None): Ledger = frappe.qb.DocType("Leave Ledger Entry") LeaveAllocation = frappe.qb.DocType("Leave Allocation") - cf_leave_case = ( - frappe.qb.terms.Case().when(Ledger.is_carry_forward == "1", Ledger.leaves).else_(0) - ) + cf_leave_case = frappe.qb.terms.Case().when(Ledger.is_carry_forward == "1", Ledger.leaves).else_(0) sum_cf_leaves = Sum(cf_leave_case).as_("cf_leaves") - new_leaves_case = ( - frappe.qb.terms.Case().when(Ledger.is_carry_forward == "0", Ledger.leaves).else_(0) - ) + new_leaves_case = frappe.qb.terms.Case().when(Ledger.is_carry_forward == "0", Ledger.leaves).else_(0) sum_new_leaves = Sum(new_leaves_case).as_("new_leaves") query = ( @@ -962,7 +949,7 @@ def get_leave_allocation_records(employee, date, leave_type=None): ) if leave_type: - query = query.where((Ledger.leave_type == leave_type)) + query = query.where(Ledger.leave_type == leave_type) query = query.groupby(Ledger.employee, Ledger.leave_type) allocation_details = query.run(as_dict=True) @@ -1003,8 +990,8 @@ def get_leaves_pending_approval_for_period( def get_remaining_leaves( - allocation: Dict, leaves_taken: float, date: str, cf_expiry: str -) -> Dict[str, float]: + allocation: dict, leaves_taken: float, date: str, cf_expiry: str +) -> dict[str, float]: """Returns a dict of leave_balance and leave_balance_for_consumption leave_balance returns the available leave balance leave_balance_for_consumption returns the minimum leaves remaining after comparing with remaining days for allocation expiry @@ -1032,9 +1019,9 @@ def _get_remaining_leaves(remaining_leaves, end_date): # new leaves allocated - new leaves taken + cf leave balance # Note: `new_leaves_taken` is added here because its already a -ve number in the ledger leave_balance = (flt(allocation.new_leaves_allocated) + flt(new_leaves_taken)) + flt(cf_leaves) - leave_balance_for_consumption = ( - flt(allocation.new_leaves_allocated) + flt(new_leaves_taken) - ) + flt(remaining_cf_leaves) + leave_balance_for_consumption = (flt(allocation.new_leaves_allocated) + flt(new_leaves_taken)) + flt( + remaining_cf_leaves + ) else: # allocation only contains newly allocated leaves leave_balance = leave_balance_for_consumption = flt(allocation.total_leaves_allocated) + flt( @@ -1045,7 +1032,7 @@ def _get_remaining_leaves(remaining_leaves, end_date): return frappe._dict(leave_balance=leave_balance, leave_balance_for_consumption=remaining_leaves) -def get_new_and_cf_leaves_taken(allocation: Dict, cf_expiry: str) -> Tuple[float, float]: +def get_new_and_cf_leaves_taken(allocation: dict, cf_expiry: str) -> tuple[float, float]: """returns new leaves taken and carry forwarded leaves taken within an allocation period based on cf leave expiry""" cf_leaves_taken = get_leaves_for_period( allocation.employee, allocation.leave_type, allocation.from_date, cf_expiry @@ -1074,9 +1061,9 @@ def get_leaves_for_period( leave_days = 0 for leave_entry in leave_entries: - inclusive_period = leave_entry.from_date >= getdate( - from_date - ) and leave_entry.to_date <= getdate(to_date) + inclusive_period = leave_entry.from_date >= getdate(from_date) and leave_entry.to_date <= getdate( + to_date + ) if inclusive_period and leave_entry.transaction_type == "Leave Encashment": leave_days += leave_entry.leaves @@ -1288,13 +1275,9 @@ def add_holidays(events, start, end, employee, company): def get_mandatory_approval(doctype): mandatory = "" if doctype == "Leave Application": - mandatory = frappe.db.get_single_value( - "HR Settings", "leave_approver_mandatory_in_leave_application" - ) + mandatory = frappe.db.get_single_value("HR Settings", "leave_approver_mandatory_in_leave_application") else: - mandatory = frappe.db.get_single_value( - "HR Settings", "expense_approver_mandatory_in_expense_claim" - ) + mandatory = frappe.db.get_single_value("HR Settings", "expense_approver_mandatory_in_expense_claim") return mandatory @@ -1346,9 +1329,7 @@ def get_approved_leaves_for_period(employee, leave_type, from_date, to_date): @frappe.whitelist() def get_leave_approver(employee): - leave_approver, department = frappe.db.get_value( - "Employee", employee, ["leave_approver", "department"] - ) + leave_approver, department = frappe.db.get_value("Employee", employee, ["leave_approver", "department"]) if not leave_approver and department: leave_approver = frappe.db.get_value( diff --git a/hrms/hr/doctype/leave_application/test_leave_application.py b/hrms/hr/doctype/leave_application/test_leave_application.py index a61b047639..f15d8381b1 100644 --- a/hrms/hr/doctype/leave_application/test_leave_application.py +++ b/hrms/hr/doctype/leave_application/test_leave_application.py @@ -360,9 +360,7 @@ def test_attendance_update_for_exclude_holidays(self): # Case 2: leave type with 'Include holidays within leaves as leaves' disabled frappe.delete_doc_if_exists("Leave Type", "Test Do Not Include Holidays", force=1) leave_type = frappe.get_doc( - dict( - leave_type_name="Test Do Not Include Holidays", doctype="Leave Type", include_holiday=False - ) + dict(leave_type_name="Test Do Not Include Holidays", doctype="Leave Type", include_holiday=False) ).insert() date = getdate() @@ -865,9 +863,7 @@ def test_creation_of_leave_ledger_entry_on_submit(self): # check if leave ledger entry is deleted on cancellation leave_application.cancel() - self.assertFalse( - frappe.db.exists("Leave Ledger Entry", {"transaction_name": leave_application.name}) - ) + self.assertFalse(frappe.db.exists("Leave Ledger Entry", {"transaction_name": leave_application.name})) def test_ledger_entry_creation_on_intermediate_allocation_expiry(self): employee = get_employee() @@ -974,9 +970,7 @@ def test_get_leave_details_for_dashboard(self): year_end = getdate(get_year_ending(date)) # ALLOCATION = 30 - allocation = make_allocation_record( - employee=employee.name, from_date=year_start, to_date=year_end - ) + allocation = make_allocation_record(employee=employee.name, from_date=year_start, to_date=year_end) # USED LEAVES = 4 first_sunday = get_first_sunday(self.holiday_list) diff --git a/hrms/hr/doctype/leave_block_list/test_leave_block_list.py b/hrms/hr/doctype/leave_block_list/test_leave_block_list.py index 7d606b24f9..72c208edec 100644 --- a/hrms/hr/doctype/leave_block_list/test_leave_block_list.py +++ b/hrms/hr/doctype/leave_block_list/test_leave_block_list.py @@ -30,9 +30,7 @@ def test_get_applicable_block_dates_for_allowed_user(self): frappe.db.set_value( "Department", "_Test Department 1 - _TC", "leave_block_list", "_Test Leave Block List" ) - self.assertEqual( - [], [d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03")] - ) + self.assertEqual([], [d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03")]) def test_get_applicable_block_dates_all_lists(self): frappe.set_user("test1@example.com") @@ -41,9 +39,7 @@ def test_get_applicable_block_dates_all_lists(self): ) self.assertTrue( getdate("2013-01-02") - in [ - d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03", all_lists=True) - ] + in [d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03", all_lists=True)] ) def test_get_applicable_block_dates_all_lists_for_leave_type(self): diff --git a/hrms/hr/doctype/leave_control_panel/leave_control_panel.py b/hrms/hr/doctype/leave_control_panel/leave_control_panel.py index 86cd543389..77e7e4e8b7 100644 --- a/hrms/hr/doctype/leave_control_panel/leave_control_panel.py +++ b/hrms/hr/doctype/leave_control_panel/leave_control_panel.py @@ -26,16 +26,14 @@ def get_employees(self): elif field == "employee_grade": conditions.append("grade=%s") else: - conditions.append("{0}=%s".format(field)) + conditions.append(f"{field}=%s") values.append(self.get(field)) condition_str = " and " + " and ".join(conditions) if len(conditions) else "" e = frappe.db.sql( - "select name from tabEmployee where status='Active' {condition}".format( - condition=condition_str - ), + f"select name from tabEmployee where status='Active' {condition_str}", tuple(values), ) diff --git a/hrms/hr/doctype/leave_encashment/leave_encashment.py b/hrms/hr/doctype/leave_encashment/leave_encashment.py index dad89fcb19..09a47a1424 100644 --- a/hrms/hr/doctype/leave_encashment/leave_encashment.py +++ b/hrms/hr/doctype/leave_encashment/leave_encashment.py @@ -121,9 +121,7 @@ def get_leave_details_for_encashment(self): per_day_encashment = frappe.db.get_value( "Salary Structure", salary_structure, "leave_encashment_amount_per_day" ) - self.encashment_amount = ( - self.encashable_days * per_day_encashment if per_day_encashment > 0 else 0 - ) + self.encashment_amount = self.encashable_days * per_day_encashment if per_day_encashment > 0 else 0 self.leave_allocation = allocation.name return True diff --git a/hrms/hr/doctype/leave_encashment/test_leave_encashment.py b/hrms/hr/doctype/leave_encashment/test_leave_encashment.py index 6f88bb317b..76dd62ec5d 100644 --- a/hrms/hr/doctype/leave_encashment/test_leave_encashment.py +++ b/hrms/hr/doctype/leave_encashment/test_leave_encashment.py @@ -41,9 +41,7 @@ def setUp(self): make_holiday_list("_Test Leave Encashment", year_start, year_end) # create the leave policy - leave_policy = create_leave_policy( - leave_type="_Test Leave Type Encashment", annual_allocation=10 - ) + leave_policy = create_leave_policy(leave_type="_Test Leave Type Encashment", annual_allocation=10) leave_policy.submit() # create employee, salary structure and assignment @@ -148,11 +146,7 @@ def test_creation_of_leave_ledger_entry_on_submit(self): # check if leave ledger entry is deleted on cancellation - frappe.db.sql( - "Delete from `tabAdditional Salary` WHERE ref_docname = %s", (leave_encashment.name) - ) + frappe.db.sql("Delete from `tabAdditional Salary` WHERE ref_docname = %s", (leave_encashment.name)) leave_encashment.cancel() - self.assertFalse( - frappe.db.exists("Leave Ledger Entry", {"transaction_name": leave_encashment.name}) - ) + self.assertFalse(frappe.db.exists("Leave Ledger Entry", {"transaction_name": leave_encashment.name})) diff --git a/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.py b/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.py index 030d7ef389..fadd49526e 100644 --- a/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.py +++ b/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.py @@ -131,9 +131,7 @@ def create_leave_allocation(self, annual_allocation, leave_details, date_of_join def get_new_leaves(self, annual_allocation, leave_details, date_of_joining): from frappe.model.meta import get_field_precision - precision = get_field_precision( - frappe.get_meta("Leave Allocation").get_field("new_leaves_allocated") - ) + precision = get_field_precision(frappe.get_meta("Leave Allocation").get_field("new_leaves_allocated")) # Earned Leaves and Compensatory Leaves are allocated by scheduler, initially allocate 0 if leave_details.is_compensatory: @@ -304,7 +302,7 @@ def create_assignment_for_multiple_employees(employees, data): try: frappe.db.savepoint(savepoint) assignment.submit() - except Exception as e: + except Exception: frappe.db.rollback(save_point=savepoint) assignment.log_error("Leave Policy Assignment submission failed") failed.append(assignment.name) diff --git a/hrms/hr/doctype/shift_assignment/shift_assignment.py b/hrms/hr/doctype/shift_assignment/shift_assignment.py index 0ec3ce37cc..50f80125de 100644 --- a/hrms/hr/doctype/shift_assignment/shift_assignment.py +++ b/hrms/hr/doctype/shift_assignment/shift_assignment.py @@ -47,7 +47,8 @@ def validate_same_date_multiple_shifts(self, overlapping_dates): _( "Warning: {0} already has an active Shift Assignment {1} for some/all of these dates." ).format( - frappe.bold(self.employee), get_link_to_form("Shift Assignment", overlapping_dates[0].name) + frappe.bold(self.employee), + get_link_to_form("Shift Assignment", overlapping_dates[0].name), ) ) else: @@ -243,7 +244,7 @@ def get_shift_type_timing(shift_types): return shift_timing_map -def get_shift_for_time(shifts: List[Dict], for_timestamp: datetime) -> Dict: +def get_shift_for_time(shifts: list[dict], for_timestamp: datetime) -> dict: """Returns shift with details for given timestamp""" valid_shifts = [] @@ -273,17 +274,13 @@ def _is_shift_outside_assignment_period(shift_details: dict, assignment: dict) - if _is_shift_start_before_assignment(shift_details, assignment, is_midnight_shift): return True - if assignment.end_date and _is_shift_end_after_assignment( - shift_details, assignment, is_midnight_shift - ): + if assignment.end_date and _is_shift_end_after_assignment(shift_details, assignment, is_midnight_shift): return True return False -def _is_shift_start_before_assignment( - shift_details: dict, assignment: dict, is_midnight_shift: bool -) -> bool: +def _is_shift_start_before_assignment(shift_details: dict, assignment: dict, is_midnight_shift: bool) -> bool: if shift_details.actual_start.date() < assignment.start_date: # log's start date can only precede assignment's start date if its a midnight shift if not is_midnight_shift: @@ -303,9 +300,7 @@ def _is_shift_start_before_assignment( return False -def _is_shift_end_after_assignment( - shift_details: dict, assignment: dict, is_midnight_shift: bool -) -> bool: +def _is_shift_end_after_assignment(shift_details: dict, assignment: dict, is_midnight_shift: bool) -> bool: if shift_details.actual_start.date() > assignment.end_date: return True @@ -353,7 +348,7 @@ def _adjust_overlapping_shifts(shifts: dict): shifts[i + 1] = next_shift -def get_shifts_for_date(employee: str, for_timestamp: datetime) -> List[Dict[str, str]]: +def get_shifts_for_date(employee: str, for_timestamp: datetime) -> list[dict[str, str]]: """Returns list of shifts with details for given date""" for_date = for_timestamp.date() prev_day = add_days(for_date, -1) @@ -389,7 +384,7 @@ def get_shifts_for_date(employee: str, for_timestamp: datetime) -> List[Dict[str ).run(as_dict=True) -def get_shift_for_timestamp(employee: str, for_timestamp: datetime) -> Dict: +def get_shift_for_timestamp(employee: str, for_timestamp: datetime) -> dict: shifts = get_shifts_for_date(employee, for_timestamp) if shifts: return get_shift_for_time(shifts, for_timestamp) @@ -401,7 +396,7 @@ def get_employee_shift( for_timestamp: datetime = None, consider_default_shift: bool = False, next_shift_direction: str = None, -) -> Dict: +) -> dict: """Returns a Shift Type for the given employee on the given date :param employee: Employee for which shift is required. @@ -434,7 +429,7 @@ def get_prev_or_next_shift( consider_default_shift: bool, default_shift: str, next_shift_direction: str, -) -> Dict: +) -> dict: """Returns a dict of shift details for the next or prev shift based on the next_shift_direction""" MAX_DAYS = 366 shift_details = {} @@ -480,7 +475,7 @@ def get_prev_or_next_shift( def get_employee_shift_timings( employee: str, for_timestamp: datetime = None, consider_default_shift: bool = False -) -> List[Dict]: +) -> list[dict]: """Returns previous shift, current/upcoming shift, next_shift for the given timestamp and employee""" if for_timestamp is None: for_timestamp = now_datetime() @@ -532,7 +527,7 @@ def get_employee_shift_timings( def get_actual_start_end_datetime_of_shift( employee: str, for_timestamp: datetime, consider_default_shift: bool = False -) -> Dict: +) -> dict: """Returns a Dict containing shift details with actual_start and actual_end datetime values Here 'actual' means taking into account the "begin_check_in_before_shift_start_time" and "allow_check_out_after_shift_end_time". Empty Dict is returned if the timestamp is outside any actual shift timings. @@ -548,7 +543,7 @@ def get_actual_start_end_datetime_of_shift( return get_exact_shift(shift_timings_as_per_timestamp, for_timestamp) -def get_exact_shift(shifts: List, for_timestamp: datetime) -> Dict: +def get_exact_shift(shifts: list, for_timestamp: datetime) -> dict: """Returns the shift details (dict) for the exact shift in which the 'for_timestamp' value falls among multiple shifts""" return next( @@ -561,7 +556,7 @@ def get_exact_shift(shifts: List, for_timestamp: datetime) -> Dict: ) -def get_shift_details(shift_type_name: str, for_timestamp: datetime = None) -> Dict: +def get_shift_details(shift_type_name: str, for_timestamp: datetime = None) -> dict: """Returns a Dict containing shift details with the following data: 'shift_type' - Object of DocType Shift Type, 'start_datetime' - datetime of shift start on given timestamp, @@ -581,9 +576,7 @@ def get_shift_details(shift_type_name: str, for_timestamp: datetime = None) -> D shift_type = get_shift_type(shift_type_name) start_datetime, end_datetime = get_shift_timings(shift_type, for_timestamp) - actual_start = start_datetime - timedelta( - minutes=shift_type.begin_check_in_before_shift_start_time - ) + actual_start = start_datetime - timedelta(minutes=shift_type.begin_check_in_before_shift_start_time) actual_end = end_datetime + timedelta(minutes=shift_type.allow_check_out_after_shift_end_time) return frappe._dict( diff --git a/hrms/hr/doctype/shift_assignment/test_shift_assignment.py b/hrms/hr/doctype/shift_assignment/test_shift_assignment.py index fe45b45cff..569cf65c74 100644 --- a/hrms/hr/doctype/shift_assignment/test_shift_assignment.py +++ b/hrms/hr/doctype/shift_assignment/test_shift_assignment.py @@ -236,9 +236,7 @@ def test_calendar(self): date = getdate() shift1 = make_shift_assignment(shift_type.name, employee1, date) # 1 day make_shift_assignment(shift_type.name, employee2, date) # excluded due to employee filter - make_shift_assignment( - shift_type.name, employee3, add_days(date, -3), add_days(date, -2) - ) # excluded + make_shift_assignment(shift_type.name, employee3, add_days(date, -3), add_days(date, -2)) # excluded shift2 = make_shift_assignment(shift_type.name, employee3, add_days(date, -1), date) # 2 days shift3 = make_shift_assignment( shift_type.name, employee3, add_days(date, 1), add_days(date, 2) @@ -275,9 +273,7 @@ def test_consecutive_day_and_night_shifts(self): yesterday = add_days(today, -1) # default shift - shift_type = setup_shift_type( - shift_type="Test Security", start_time="07:00:00", end_time="19:00:00" - ) + shift_type = setup_shift_type(shift_type="Test Security", start_time="07:00:00", end_time="19:00:00") frappe.db.set_value("Employee", employee, "default_shift", shift_type.name) # night shift @@ -287,21 +283,15 @@ def test_consecutive_day_and_night_shifts(self): make_shift_assignment(shift_type.name, employee, yesterday, yesterday) # prev shift log - prev_shift = get_actual_start_end_datetime_of_shift( - employee, get_datetime(f"{today} 07:00:00"), True - ) + prev_shift = get_actual_start_end_datetime_of_shift(employee, get_datetime(f"{today} 07:00:00"), True) self.assertEqual(prev_shift.shift_type.name, "Test Security - Night") self.assertEqual(prev_shift.actual_start.date(), yesterday) self.assertEqual(prev_shift.actual_end.date(), today) # current shift IN - checkin = get_actual_start_end_datetime_of_shift( - employee, get_datetime(f"{today} 07:01:00"), True - ) + checkin = get_actual_start_end_datetime_of_shift(employee, get_datetime(f"{today} 07:01:00"), True) # current shift OUT - checkout = get_actual_start_end_datetime_of_shift( - employee, get_datetime(f"{today} 19:00:00"), True - ) + checkout = get_actual_start_end_datetime_of_shift(employee, get_datetime(f"{today} 19:00:00"), True) self.assertEqual(checkin.shift_type, checkout.shift_type) self.assertEqual(checkin.actual_start.date(), today) self.assertEqual(checkout.actual_end.date(), today) diff --git a/hrms/hr/doctype/shift_type/shift_type.py b/hrms/hr/doctype/shift_type/shift_type.py index 810d8c338a..442990e2ab 100644 --- a/hrms/hr/doctype/shift_type/shift_type.py +++ b/hrms/hr/doctype/shift_type/shift_type.py @@ -182,9 +182,7 @@ def get_dates_for_attendance(self, employee: str) -> list[str]: holiday_list = self.get_holiday_list(employee) holiday_dates = get_holiday_dates_between(holiday_list, start_date, end_date) # skip dates with attendance - marked_attendance_dates = self.get_marked_attendance_dates_between( - employee, start_date, end_date - ) + marked_attendance_dates = self.get_marked_attendance_dates_between(employee, start_date, end_date) return sorted(set(date_range) - set(holiday_dates) - set(marked_attendance_dates)) @@ -222,9 +220,7 @@ def get_start_and_end_dates(self, employee): return None, None return start_date, end_date - def get_marked_attendance_dates_between( - self, employee: str, start_date: str, end_date: str - ) -> list[str]: + def get_marked_attendance_dates_between(self, employee: str, start_date: str, end_date: str) -> list[str]: Attendance = frappe.qb.DocType("Attendance") return ( frappe.qb.from_(Attendance) diff --git a/hrms/hr/doctype/shift_type/shift_type_dashboard.py b/hrms/hr/doctype/shift_type/shift_type_dashboard.py index 920d8fd547..f4f15f445e 100644 --- a/hrms/hr/doctype/shift_type/shift_type_dashboard.py +++ b/hrms/hr/doctype/shift_type/shift_type_dashboard.py @@ -2,7 +2,5 @@ def get_data(): return { "fieldname": "shift", "non_standard_fieldnames": {"Shift Request": "shift_type", "Shift Assignment": "shift_type"}, - "transactions": [ - {"items": ["Attendance", "Employee Checkin", "Shift Request", "Shift Assignment"]} - ], + "transactions": [{"items": ["Attendance", "Employee Checkin", "Shift Request", "Shift Assignment"]}], } diff --git a/hrms/hr/doctype/shift_type/test_shift_type.py b/hrms/hr/doctype/shift_type/test_shift_type.py index 5de624c4b1..1d3c742782 100644 --- a/hrms/hr/doctype/shift_type/test_shift_type.py +++ b/hrms/hr/doctype/shift_type/test_shift_type.py @@ -80,9 +80,7 @@ def test_attendance_date_for_different_start_and_actual_start_date(self): from hrms.hr.doctype.employee_checkin.test_employee_checkin import make_checkin employee = make_employee("test_employee_checkin@example.com", company="_Test Company") - shift_type = setup_shift_type( - shift_type="Midnight Shift", start_time="00:30:00", end_time="10:00:00" - ) + shift_type = setup_shift_type(shift_type="Midnight Shift", start_time="00:30:00", end_time="10:00:00") date = getdate() make_shift_assignment(shift_type.name, employee, date, date) @@ -253,9 +251,7 @@ def test_mark_auto_attendance_on_holiday_enabled(self): date = getdate() add_date_to_holiday_list(date, self.holiday_list) - shift_type = setup_shift_type( - shift_type="Test Holiday Shift", mark_auto_attendance_on_holidays=True - ) + shift_type = setup_shift_type(shift_type="Test Holiday Shift", mark_auto_attendance_on_holidays=True) shift_type.holiday_list = None shift_type.save() @@ -284,9 +280,7 @@ def test_mark_auto_attendance_on_holiday_disabled(self): date = getdate() add_date_to_holiday_list(date, self.holiday_list) - shift_type = setup_shift_type( - shift_type="Test Holiday Shift", mark_auto_attendance_on_holidays=False - ) + shift_type = setup_shift_type(shift_type="Test Holiday Shift", mark_auto_attendance_on_holidays=False) shift_type.holiday_list = None shift_type.save() @@ -383,9 +377,7 @@ def test_do_not_mark_absent_before_shift_actual_end_time(self): curr_date = getdate() # this shift's valid checkout period (+60 mins) will be till 00:30:00 today, so it goes beyond a day - shift_type = setup_shift_type( - shift_type="Test Absent", start_time="15:00:00", end_time="23:30:00" - ) + shift_type = setup_shift_type(shift_type="Test Absent", start_time="15:00:00", end_time="23:30:00") shift_type.last_sync_of_checkin = datetime.combine(curr_date, get_time("00:30:00")) shift_type.save() @@ -415,7 +407,7 @@ def test_do_not_mark_absent_before_shift_actual_end_time(self): attendance = frappe.db.get_value( "Attendance", {"attendance_date": prev_date, "employee": employee}, "status" ) - self.assertEquals(attendance, "Present") + self.assertEqual(attendance, "Present") @set_holiday_list("Salary Slip Test Holiday List", "_Test Company") def test_skip_marking_absent_on_a_holiday(self): @@ -512,16 +504,14 @@ def test_get_start_and_end_dates(self): shift_type.process_auto_attendance() # should not mark absent before shift assignment/process attendance after date - attendance = frappe.db.get_value( - "Attendance", {"attendance_date": doj, "employee": employee}, "name" - ) + attendance = frappe.db.get_value("Attendance", {"attendance_date": doj, "employee": employee}, "name") self.assertIsNone(attendance) # mark absent on Relieving Date attendance = frappe.db.get_value( "Attendance", {"attendance_date": relieving_date, "employee": employee}, "status" ) - self.assertEquals(attendance, "Absent") + self.assertEqual(attendance, "Absent") # should not mark absent after Relieving Date attendance = frappe.db.get_value( diff --git a/hrms/hr/doctype/staffing_plan/staffing_plan.py b/hrms/hr/doctype/staffing_plan/staffing_plan.py index 8192418104..4d2933fdc8 100644 --- a/hrms/hr/doctype/staffing_plan/staffing_plan.py +++ b/hrms/hr/doctype/staffing_plan/staffing_plan.py @@ -47,7 +47,9 @@ def set_total_estimated_budget(self): detail.total_estimated_cost = 0 if detail.number_of_positions > 0: if detail.vacancies and detail.estimated_cost_per_position: - detail.total_estimated_cost = cint(detail.vacancies) * flt(detail.estimated_cost_per_position) + detail.total_estimated_cost = cint(detail.vacancies) * flt( + detail.estimated_cost_per_position + ) self.total_estimated_budget += detail.total_estimated_cost @@ -121,9 +123,7 @@ def validate_with_parent_plan(self, staffing_plan_detail): < (cint(staffing_plan_detail.vacancies) + cint(all_sibling_details.vacancies)) ) or ( flt(parent_plan_details[0].total_estimated_cost) - < ( - flt(staffing_plan_detail.total_estimated_cost) + flt(all_sibling_details.total_estimated_cost) - ) + < (flt(staffing_plan_detail.total_estimated_cost) + flt(all_sibling_details.total_estimated_cost)) ): frappe.throw( _( @@ -236,9 +236,7 @@ def get_active_staffing_plan_details(company, designation, from_date=None, to_da if not staffing_plan: parent_company = frappe.get_cached_value("Company", company, "parent_company") if parent_company: - staffing_plan = get_active_staffing_plan_details( - parent_company, designation, from_date, to_date - ) + staffing_plan = get_active_staffing_plan_details(parent_company, designation, from_date, to_date) # Only a single staffing plan can be active for a designation on given date return staffing_plan if staffing_plan else None diff --git a/hrms/hr/doctype/upload_attendance/upload_attendance.py b/hrms/hr/doctype/upload_attendance/upload_attendance.py index 68eef4b591..ca897ff4c8 100644 --- a/hrms/hr/doctype/upload_attendance/upload_attendance.py +++ b/hrms/hr/doctype/upload_attendance/upload_attendance.py @@ -46,9 +46,7 @@ def get_template(): def add_header(w): - status = ", ".join( - (frappe.get_meta("Attendance").get_field("status").options or "").strip().split("\n") - ) + status = ", ".join((frappe.get_meta("Attendance").get_field("status").options or "").strip().split("\n")) w.writerow(["Notes:"]) w.writerow(["Please do not change the template headings"]) w.writerow(["Status should be one of these values: " + status]) @@ -198,7 +196,7 @@ def remove_holidays(rows): if not row: continue row_idx = i + 5 - d = frappe._dict(zip(columns, row)) + d = frappe._dict(zip(columns, row, strict=False)) d["doctype"] = "Attendance" if d.name: diff --git a/hrms/hr/doctype/vehicle_log/test_vehicle_log.py b/hrms/hr/doctype/vehicle_log/test_vehicle_log.py index 73bc3ae18c..9ac8c346e3 100644 --- a/hrms/hr/doctype/vehicle_log/test_vehicle_log.py +++ b/hrms/hr/doctype/vehicle_log/test_vehicle_log.py @@ -12,9 +12,7 @@ class TestVehicleLog(FrappeTestCase): def setUp(self): - employee_id = frappe.db.sql( - """select name from `tabEmployee` where name='testdriver@example.com'""" - ) + employee_id = frappe.db.sql("""select name from `tabEmployee` where name='testdriver@example.com'""") self.employee_id = employee_id[0][0] if employee_id else None if not self.employee_id: diff --git a/hrms/hr/page/team_updates/team_updates.py b/hrms/hr/page/team_updates/team_updates.py index 432995c10f..9c32f9ae2f 100644 --- a/hrms/hr/page/team_updates/team_updates.py +++ b/hrms/hr/page/team_updates/team_updates.py @@ -16,9 +16,7 @@ def get_data(start=0): ) for d in data: - d.sender_name = ( - frappe.db.get_value("Employee", {"user_id": d.sender}, "employee_name") or d.sender - ) + d.sender_name = frappe.db.get_value("Employee", {"user_id": d.sender}, "employee_name") or d.sender if d.text_content: d.content = frappe.utils.md_to_html(EmailReplyParser.parse_reply(d.text_content)) diff --git a/hrms/hr/report/appraisal_overview/test_appraisal_overview.py b/hrms/hr/report/appraisal_overview/test_appraisal_overview.py index 9d2d5d0cd2..c03c03c9ea 100644 --- a/hrms/hr/report/appraisal_overview/test_appraisal_overview.py +++ b/hrms/hr/report/appraisal_overview/test_appraisal_overview.py @@ -28,15 +28,11 @@ def setUp(self): consultant.appraisal_template = create_appraisal_template("Consultant").name consultant.save() - self.employee1 = make_employee( - "employee1@example.com", company=self.company, designation="Engineer" - ) + self.employee1 = make_employee("employee1@example.com", company=self.company, designation="Engineer") self.employee2 = make_employee( "employee3@example.com", company=self.company, designation="Consultant" ) - self.reviewer = make_employee( - "reviewer@example.com", company=self.company, designation="Engineer" - ) + self.reviewer = make_employee("reviewer@example.com", company=self.company, designation="Engineer") def test_appraisal_overview(self): cycle = create_appraisal_cycle(kra_evaluation_method="Manual Rating") diff --git a/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py b/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py index b0fe8a21f4..151a17f986 100644 --- a/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py +++ b/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py @@ -141,18 +141,16 @@ def generate_filtered_time_logs(self): additional_filters += f" AND tt.{field} = {self.filters.get(field)!r}" self.filtered_time_logs = frappe.db.sql( - """ + f""" SELECT tt.employee AS employee, ttd.hours AS hours, ttd.is_billable AS is_billable, ttd.project AS project FROM `tabTimesheet Detail` AS ttd JOIN `tabTimesheet` AS tt ON ttd.parent = tt.name WHERE tt.employee IS NOT NULL - AND tt.start_date BETWEEN '{0}' AND '{1}' - AND tt.end_date BETWEEN '{0}' AND '{1}' - {2} - """.format( - self.filters.from_date, self.filters.to_date, additional_filters - ) + AND tt.start_date BETWEEN '{self.filters.from_date}' AND '{self.filters.to_date}' + AND tt.end_date BETWEEN '{self.filters.from_date}' AND '{self.filters.to_date}' + {additional_filters} + """ ) def generate_stats_by_employee(self): @@ -186,9 +184,7 @@ def calculate_utilizations(self): if data["untracked_hours"] < 0: data["untracked_hours"] = 0.0 - data["per_util"] = flt( - ((data["billed_hours"] + data["non_billed_hours"]) / TOTAL_HOURS) * 100, 2 - ) + data["per_util"] = flt(((data["billed_hours"] + data["non_billed_hours"]) / TOTAL_HOURS) * 100, 2) data["per_util_billed_only"] = flt((data["billed_hours"] / TOTAL_HOURS) * 100, 2) def generate_report_summary(self): diff --git a/hrms/hr/report/employee_leave_balance/employee_leave_balance.py b/hrms/hr/report/employee_leave_balance/employee_leave_balance.py index 41e38bfd6b..d8289bd07e 100644 --- a/hrms/hr/report/employee_leave_balance/employee_leave_balance.py +++ b/hrms/hr/report/employee_leave_balance/employee_leave_balance.py @@ -132,9 +132,7 @@ def get_data(filters: Filters) -> list: def get_leave_types() -> list[str]: LeaveType = frappe.qb.DocType("Leave Type") - return (frappe.qb.from_(LeaveType).select(LeaveType.name).orderby(LeaveType.name)).run( - pluck="name" - ) + return (frappe.qb.from_(LeaveType).select(LeaveType.name).orderby(LeaveType.name)).run(pluck="name") def get_employees(filters: Filters) -> list[dict]: @@ -147,7 +145,7 @@ def get_employees(filters: Filters) -> list[dict]: for field in ["company", "department"]: if filters.get(field): - query = query.where((getattr(Employee, field) == filters.get(field))) + query = query.where(getattr(Employee, field) == filters.get(field)) if filters.get("employee"): query = query.where(Employee.name == filters.get("employee")) @@ -201,9 +199,7 @@ def get_allocated_and_expired_leaves( # leave allocations ending before to_date, reduce leaves taken within that period # since they are already used, they won't expire expired_leaves += record.leaves - leaves_for_period = get_leaves_for_period( - employee, leave_type, record.from_date, record.to_date - ) + leaves_for_period = get_leaves_for_period(employee, leave_type, record.from_date, record.to_date) expired_leaves -= min(abs(leaves_for_period), record.leaves) if record.from_date >= getdate(from_date): @@ -215,9 +211,7 @@ def get_allocated_and_expired_leaves( return new_allocation, expired_leaves, carry_forwarded_leaves -def get_leave_ledger_entries( - from_date: str, to_date: str, employee: str, leave_type: str -) -> list[dict]: +def get_leave_ledger_entries(from_date: str, to_date: str, employee: str, leave_type: str) -> list[dict]: ledger = frappe.qb.DocType("Leave Ledger Entry") return ( frappe.qb.from_(ledger) diff --git a/hrms/hr/report/employees_working_on_a_holiday/employees_working_on_a_holiday.py b/hrms/hr/report/employees_working_on_a_holiday/employees_working_on_a_holiday.py index f9fec8237b..b9522c2d37 100644 --- a/hrms/hr/report/employees_working_on_a_holiday/employees_working_on_a_holiday.py +++ b/hrms/hr/report/employees_working_on_a_holiday/employees_working_on_a_holiday.py @@ -33,9 +33,7 @@ def get_employees(filters): if filters.holiday_list: holiday_filter.append(["parent", "=", filters.holiday_list]) - holidays = frappe.get_all( - "Holiday", fields=["holiday_date", "description"], filters=holiday_filter - ) + holidays = frappe.get_all("Holiday", fields=["holiday_date", "description"], filters=holiday_filter) holiday_names = {} holidays_list = [] diff --git a/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py b/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py index 3337c5c184..58c5dfa1ed 100644 --- a/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py +++ b/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py @@ -26,7 +26,7 @@ day_abbr = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] -def execute(filters: Optional[Filters] = None) -> Tuple: +def execute(filters: Filters | None = None) -> tuple: filters = frappe._dict(filters or {}) if not (filters.month and filters.year): @@ -41,9 +41,7 @@ def execute(filters: Optional[Filters] = None) -> Tuple: data = get_data(filters, attendance_map) if not data: - frappe.msgprint( - _("No attendance records found for this criteria."), alert=True, indicator="orange" - ) + frappe.msgprint(_("No attendance records found for this criteria."), alert=True, indicator="orange") return columns, [], None, None message = get_message() if not filters.summarized_view else "" @@ -68,7 +66,7 @@ def get_message() -> str: return message -def get_columns(filters: Filters) -> List[Dict]: +def get_columns(filters: Filters) -> list[dict]: columns = [] if filters.group_by: @@ -151,29 +149,27 @@ def get_columns(filters: Filters) -> List[Dict]: return columns -def get_columns_for_leave_types() -> List[Dict]: +def get_columns_for_leave_types() -> list[dict]: leave_types = frappe.db.get_all("Leave Type", pluck="name") types = [] for entry in leave_types: - types.append( - {"label": entry, "fieldname": frappe.scrub(entry), "fieldtype": "Float", "width": 120} - ) + types.append({"label": entry, "fieldname": frappe.scrub(entry), "fieldtype": "Float", "width": 120}) return types -def get_columns_for_days(filters: Filters) -> List[Dict]: +def get_columns_for_days(filters: Filters) -> list[dict]: total_days = get_total_days_in_month(filters) days = [] for day in range(1, total_days + 1): day = cstr(day) # forms the dates from selected year and month from filters - date = "{}-{}-{}".format(cstr(filters.year), cstr(filters.month), day) + date = f"{cstr(filters.year)}-{cstr(filters.month)}-{day}" # gets abbr from weekday number weekday = day_abbr[getdate(date).weekday()] # sets days as 1 Mon, 2 Tue, 3 Wed - label = "{} {}".format(day, weekday) + label = f"{day} {weekday}" days.append({"label": label, "fieldtype": "Data", "fieldname": day, "width": 65}) return days @@ -183,7 +179,7 @@ def get_total_days_in_month(filters: Filters) -> int: return monthrange(cint(filters.year), cint(filters.month))[1] -def get_data(filters: Filters, attendance_map: Dict) -> List[Dict]: +def get_data(filters: Filters, attendance_map: dict) -> list[dict]: employee_details, group_by_param_values = get_employee_related_details(filters) holiday_map = get_holiday_map(filters) data = [] @@ -206,7 +202,7 @@ def get_data(filters: Filters, attendance_map: Dict) -> List[Dict]: return data -def get_attendance_map(filters: Filters) -> Dict: +def get_attendance_map(filters: Filters) -> dict: """Returns a dictionary of employee wise attendance map as per shifts for all the days of the month like { 'employee1': { @@ -250,7 +246,7 @@ def get_attendance_map(filters: Filters) -> Dict: return attendance_map -def get_attendance_records(filters: Filters) -> List[Dict]: +def get_attendance_records(filters: Filters) -> list[dict]: Attendance = frappe.qb.DocType("Attendance") query = ( frappe.qb.from_(Attendance) @@ -275,7 +271,7 @@ def get_attendance_records(filters: Filters) -> List[Dict]: return query.run(as_dict=1) -def get_employee_related_details(filters: Filters) -> Tuple[Dict, List]: +def get_employee_related_details(filters: Filters) -> tuple[dict, list]: """Returns 1. nested dict for employee details 2. list of values for the group by filter @@ -323,7 +319,7 @@ def get_employee_related_details(filters: Filters) -> Tuple[Dict, List]: return emp_map, group_by_param_values -def get_holiday_map(filters: Filters) -> Dict[str, List[Dict]]: +def get_holiday_map(filters: Filters) -> dict[str, list[dict]]: """ Returns a dict of holidays falling in the filter month and year with list name as key and list of holidays as values like @@ -365,9 +361,7 @@ def get_holiday_map(filters: Filters) -> Dict[str, List[Dict]]: return holiday_map -def get_rows( - employee_details: Dict, filters: Filters, holiday_map: Dict, attendance_map: Dict -) -> List[Dict]: +def get_rows(employee_details: dict, filters: Filters, holiday_map: dict, attendance_map: dict) -> list[dict]: records = [] default_holiday_list = frappe.get_cached_value("Company", filters.company, "default_holiday_list") @@ -399,9 +393,7 @@ def get_rows( employee, filters, employee_attendance, holidays ) # set employee details in the first row - attendance_for_employee[0].update( - {"employee": employee, "employee_name": details.employee_name} - ) + attendance_for_employee[0].update({"employee": employee, "employee_name": details.employee_name}) records.extend(attendance_for_employee) @@ -414,9 +406,7 @@ def set_defaults_for_summarized_view(filters, row): row[entry.get("fieldname")] = 0.0 -def get_attendance_status_for_summarized_view( - employee: str, filters: Filters, holidays: List -) -> Dict: +def get_attendance_status_for_summarized_view(employee: str, filters: Filters, holidays: list) -> dict: """Returns dict of attendance status for employee like {'total_present': 1.5, 'total_leaves': 0.5, 'total_absent': 13.5, 'total_holidays': 8, 'unmarked_days': 5} """ @@ -446,7 +436,7 @@ def get_attendance_status_for_summarized_view( } -def get_attendance_summary_and_days(employee: str, filters: Filters) -> Tuple[Dict, List]: +def get_attendance_summary_and_days(employee: str, filters: Filters) -> tuple[dict, list]: Attendance = frappe.qb.DocType("Attendance") present_case = ( @@ -499,8 +489,8 @@ def get_attendance_summary_and_days(employee: str, filters: Filters) -> Tuple[Di def get_attendance_status_for_detailed_view( - employee: str, filters: Filters, employee_attendance: Dict, holidays: List -) -> List[Dict]: + employee: str, filters: Filters, employee_attendance: dict, holidays: list +) -> list[dict]: """Returns list of shift-wise attendance status for employee [ {'shift': 'Morning Shift', 1: 'A', 2: 'P', 3: 'A'....}, @@ -526,7 +516,7 @@ def get_attendance_status_for_detailed_view( return attendance_values -def get_holiday_status(day: int, holidays: List) -> str: +def get_holiday_status(day: int, holidays: list) -> str: status = None if holidays: for holiday in holidays: @@ -539,7 +529,7 @@ def get_holiday_status(day: int, holidays: List) -> str: return status -def get_leave_summary(employee: str, filters: Filters) -> Dict[str, float]: +def get_leave_summary(employee: str, filters: Filters) -> dict[str, float]: """Returns a dict of leave type and corresponding leaves taken by employee like: {'leave_without_pay': 1.0, 'sick_leave': 2.0} """ @@ -569,7 +559,7 @@ def get_leave_summary(employee: str, filters: Filters) -> Dict[str, float]: return leaves -def get_entry_exits_summary(employee: str, filters: Filters) -> Dict[str, float]: +def get_entry_exits_summary(employee: str, filters: Filters) -> dict[str, float]: """Returns total late entries and total early exits for employee like: {'total_late_entries': 5, 'total_early_exits': 2} """ @@ -601,9 +591,7 @@ def get_attendance_years() -> str: """Returns all the years for which attendance records exist""" Attendance = frappe.qb.DocType("Attendance") year_list = ( - frappe.qb.from_(Attendance) - .select(Extract("year", Attendance.attendance_date).as_("year")) - .distinct() + frappe.qb.from_(Attendance).select(Extract("year", Attendance.attendance_date).as_("year")).distinct() ).run(as_dict=True) if year_list: @@ -614,7 +602,7 @@ def get_attendance_years() -> str: return "\n".join(cstr(entry.year) for entry in year_list) -def get_chart_data(attendance_map: Dict, filters: Filters) -> Dict: +def get_chart_data(attendance_map: dict, filters: Filters) -> dict: days = get_columns_for_days(filters) labels = [] absent = [] diff --git a/hrms/hr/report/monthly_attendance_sheet/test_monthly_attendance_sheet.py b/hrms/hr/report/monthly_attendance_sheet/test_monthly_attendance_sheet.py index 82e3e5e7ee..71fa9745e1 100644 --- a/hrms/hr/report/monthly_attendance_sheet/test_monthly_attendance_sheet.py +++ b/hrms/hr/report/monthly_attendance_sheet/test_monthly_attendance_sheet.py @@ -68,9 +68,7 @@ def test_detailed_view(self): # attendance with shift mark_attendance(self.employee, previous_month_first, "Absent", "Day Shift") - mark_attendance( - self.employee, previous_month_first + relativedelta(days=1), "Present", "Day Shift" - ) + mark_attendance(self.employee, previous_month_first + relativedelta(days=1), "Present", "Day Shift") # attendance without shift mark_attendance(self.employee, previous_month_first + relativedelta(days=2), "On Leave") @@ -104,9 +102,7 @@ def test_single_shift_with_leaves_in_detailed_view(self): # attendance with shift mark_attendance(self.employee, previous_month_first, "Absent", "Day Shift") - mark_attendance( - self.employee, previous_month_first + relativedelta(days=1), "Present", "Day Shift" - ) + mark_attendance(self.employee, previous_month_first + relativedelta(days=1), "Present", "Day Shift") # attendance without shift mark_attendance(self.employee, previous_month_first + relativedelta(days=2), "On Leave") @@ -158,12 +154,8 @@ def test_summarized_view(self): # attendance with shift mark_attendance(self.employee, previous_month_first, "Absent", "Day Shift") - mark_attendance( - self.employee, previous_month_first + relativedelta(days=1), "Present", "Day Shift" - ) - mark_attendance( - self.employee, previous_month_first + relativedelta(days=2), "Half Day" - ) # half day + mark_attendance(self.employee, previous_month_first + relativedelta(days=1), "Present", "Day Shift") + mark_attendance(self.employee, previous_month_first + relativedelta(days=2), "Half Day") # half day mark_attendance( self.employee, previous_month_first + relativedelta(days=3), "Present" @@ -207,9 +199,7 @@ def test_attendance_with_group_by_filter(self): # attendance with shift mark_attendance(self.employee, previous_month_first, "Absent", "Day Shift") - mark_attendance( - self.employee, previous_month_first + relativedelta(days=1), "Present", "Day Shift" - ) + mark_attendance(self.employee, previous_month_first + relativedelta(days=1), "Present", "Day Shift") # attendance without shift mark_attendance(self.employee, previous_month_first + relativedelta(days=2), "On Leave") diff --git a/hrms/hr/report/recruitment_analytics/recruitment_analytics.py b/hrms/hr/report/recruitment_analytics/recruitment_analytics.py index b6caf400dd..ae6710fb45 100644 --- a/hrms/hr/report/recruitment_analytics/recruitment_analytics.py +++ b/hrms/hr/report/recruitment_analytics/recruitment_analytics.py @@ -7,7 +7,6 @@ def execute(filters=None): - if not filters: filters = {} filters = frappe._dict(filters) @@ -118,9 +117,8 @@ def get_child_row(jo, jo_ja_map, ja_joff_map): def get_staffing_plan(filters): - staffing_plan = frappe.db.sql( - """ + f""" select sp.name, sp.department, spd.designation, spd.vacancies, spd.current_count, spd.parent, sp.to_date from @@ -128,10 +126,8 @@ def get_staffing_plan(filters): where spd.parent = sp.name And - sp.to_date > '{0}' - """.format( - filters.on_date - ), + sp.to_date > '{filters.on_date}' + """, as_dict=1, ) @@ -139,7 +135,6 @@ def get_staffing_plan(filters): def get_job_opening(sp_list): - job_openings = frappe.get_all( "Job Opening", filters=[["staffing_plan", "IN", sp_list]], fields=["name", "staffing_plan"] ) @@ -159,7 +154,6 @@ def get_job_opening(sp_list): def get_job_applicant(jo_list): - jo_ja_map = {} ja_list = [] diff --git a/hrms/hr/report/unpaid_expense_claim/unpaid_expense_claim.py b/hrms/hr/report/unpaid_expense_claim/unpaid_expense_claim.py index 62b4f63b3a..7289822582 100644 --- a/hrms/hr/report/unpaid_expense_claim/unpaid_expense_claim.py +++ b/hrms/hr/report/unpaid_expense_claim/unpaid_expense_claim.py @@ -30,7 +30,7 @@ def get_unclaimed_expese_claims(filters): cond = "ec.employee = %(employee)s" return frappe.db.sql( - """ + f""" select ec.employee, ec.employee_name, ec.name, ec.total_sanctioned_amount, ec.total_amount_reimbursed, sum(gle.credit_in_account_currency - gle.debit_in_account_currency) as outstanding_amt @@ -41,9 +41,7 @@ def get_unclaimed_expese_claims(filters): and gle.party is not null and ec.docstatus = 1 and ec.is_paid = 0 and {cond} group by ec.name having outstanding_amt > 0 - """.format( - cond=cond - ), + """, filters, as_list=1, ) diff --git a/hrms/hr/report/vehicle_expenses/test_vehicle_expenses.py b/hrms/hr/report/vehicle_expenses/test_vehicle_expenses.py index 8e941f7ecb..9c4960dbc1 100644 --- a/hrms/hr/report/vehicle_expenses/test_vehicle_expenses.py +++ b/hrms/hr/report/vehicle_expenses/test_vehicle_expenses.py @@ -20,9 +20,7 @@ def setUpClass(self): super().setUpClass() frappe.db.sql("delete from `tabVehicle Log`") - employee_id = frappe.db.sql( - """select name from `tabEmployee` where name='testdriver@example.com'""" - ) + employee_id = frappe.db.sql("""select name from `tabEmployee` where name='testdriver@example.com'""") self.employee_id = employee_id[0][0] if employee_id else None if not self.employee_id: self.employee_id = make_employee("testdriver@example.com", company="_Test Company") diff --git a/hrms/hr/report/vehicle_expenses/vehicle_expenses.py b/hrms/hr/report/vehicle_expenses/vehicle_expenses.py index fc5510ddad..22284bfbac 100644 --- a/hrms/hr/report/vehicle_expenses/vehicle_expenses.py +++ b/hrms/hr/report/vehicle_expenses/vehicle_expenses.py @@ -64,7 +64,7 @@ def get_vehicle_log_data(filters): conditions, values = get_conditions(filters) data = frappe.db.sql( - """ + f""" SELECT vhcl.license_plate as vehicle, vhcl.make, vhcl.model, vhcl.location, log.name as log_name, log.odometer, @@ -77,10 +77,8 @@ def get_vehicle_log_data(filters): vhcl.license_plate = log.license_plate and log.docstatus = 1 and date between %(start_date)s and %(end_date)s - {0} - ORDER BY date""".format( - conditions - ), + {conditions} + ORDER BY date""", values, as_dict=1, ) diff --git a/hrms/hr/utils.py b/hrms/hr/utils.py index 45dd39daa0..8c44b4b634 100644 --- a/hrms/hr/utils.py +++ b/hrms/hr/utils.py @@ -230,7 +230,7 @@ def throw_overlap_error(doc, exists_for, overlap_doc, from_date, to_date): _("A {0} exists between {1} and {2} (").format( doc.doctype, formatdate(from_date), formatdate(to_date) ) - + """ {1}""".format(doc.doctype, overlap_doc) + + f""" {overlap_doc}""" + _(") for {0}").format(exists_for) ) frappe.throw(msg) @@ -248,9 +248,7 @@ def validate_duplicate_exemption_for_payroll_period(doctype, docname, payroll_pe ) if existing_record: frappe.throw( - _("{0} already exists for employee {1} and period {2}").format( - doctype, employee, payroll_period - ), + _("{0} already exists for employee {1} and period {2}").format(doctype, employee, payroll_period), DuplicateDeclarationError, ) @@ -578,9 +576,7 @@ def get_holiday_dates_for_employee(employee, start_date, end_date): return [cstr(h.holiday_date) for h in holidays] -def get_holidays_for_employee( - employee, start_date, end_date, raise_exception=True, only_non_weekly=False -): +def get_holidays_for_employee(employee, start_date, end_date, raise_exception=True, only_non_weekly=False): """Get Holidays for a given employee `employee` (str) @@ -734,9 +730,7 @@ def get_matching_queries( queries = [] if transaction.withdrawal > 0: if "expense_claim" in document_types: - ec_amount_matching = get_ec_matching_query( - bank_account, company, exact_match, from_date, to_date - ) + ec_amount_matching = get_ec_matching_query(bank_account, company, exact_match, from_date, to_date) queries.extend([ec_amount_matching]) return queries diff --git a/hrms/overrides/dashboard_overrides.py b/hrms/overrides/dashboard_overrides.py index c2a6f3068b..88c5e0639a 100644 --- a/hrms/overrides/dashboard_overrides.py +++ b/hrms/overrides/dashboard_overrides.py @@ -48,9 +48,7 @@ def get_dashboard_for_employee(data): ] ) - data["non_standard_fieldnames"].update( - {"Bank Account": "party", "Employee Grievance": "raised_by"} - ) + data["non_standard_fieldnames"].update({"Bank Account": "party", "Employee Grievance": "raised_by"}) data.update( { "heatmap": True, diff --git a/hrms/overrides/employee_payment_entry.py b/hrms/overrides/employee_payment_entry.py index 8fb2a0bba4..b5567ed372 100644 --- a/hrms/overrides/employee_payment_entry.py +++ b/hrms/overrides/employee_payment_entry.py @@ -36,7 +36,7 @@ def set_missing_ref_details( for d in self.get("references"): if d.allocated_amount: if update_ref_details_only_for and ( - not (d.reference_doctype, d.reference_name) in update_ref_details_only_for + (d.reference_doctype, d.reference_name) not in update_ref_details_only_for ): continue @@ -204,9 +204,7 @@ def get_paid_amount_and_received_amount( @frappe.whitelist() def get_payment_reference_details(reference_doctype, reference_name, party_account_currency): if reference_doctype in ("Expense Claim", "Employee Advance", "Gratuity"): - return get_reference_details_for_employee( - reference_doctype, reference_name, party_account_currency - ) + return get_reference_details_for_employee(reference_doctype, reference_name, party_account_currency) else: return get_reference_details(reference_doctype, reference_name, party_account_currency) @@ -220,9 +218,7 @@ def get_reference_details_for_employee(reference_doctype, reference_name, party_ total_amount = outstanding_amount = exchange_rate = None ref_doc = frappe.get_doc(reference_doctype, reference_name) - company_currency = ref_doc.get("company_currency") or erpnext.get_company_currency( - ref_doc.company - ) + company_currency = ref_doc.get("company_currency") or erpnext.get_company_currency(ref_doc.company) total_amount, exchange_rate = get_total_amount_and_exchange_rate( ref_doc, party_account_currency, company_currency diff --git a/hrms/patches/post_install/move_tax_slabs_from_payroll_period_to_income_tax_slab.py b/hrms/patches/post_install/move_tax_slabs_from_payroll_period_to_income_tax_slab.py index 43dc412fb6..f662b5acc3 100644 --- a/hrms/patches/post_install/move_tax_slabs_from_payroll_period_to_income_tax_slab.py +++ b/hrms/patches/post_install/move_tax_slabs_from_payroll_period_to_income_tax_slab.py @@ -6,9 +6,7 @@ def execute(): - if not ( - frappe.db.table_exists("Payroll Period") and frappe.db.table_exists("Taxable Salary Slab") - ): + if not (frappe.db.table_exists("Payroll Period") and frappe.db.table_exists("Taxable Salary Slab")): return if frappe.db.a_row_exists("Income Tax Slab"): @@ -32,16 +30,14 @@ def execute(): for company in frappe.get_all("Company"): payroll_periods = frappe.db.sql( - """ + f""" SELECT - {0} + {select_fields} FROM `tabPayroll Period` WHERE company=%s ORDER BY start_date DESC - """.format( - select_fields - ), + """, company.name, as_dict=1, ) @@ -92,9 +88,7 @@ def execute(): if not frappe.db.table_exists("Employee Tax Exemption Proof Submission"): return - if not frappe.db.has_column( - "Employee Tax Exemption Proof Submission", "income_from_other_sources" - ): + if not frappe.db.has_column("Employee Tax Exemption Proof Submission", "income_from_other_sources"): return migrated = [] diff --git a/hrms/patches/post_install/remove_denied_leaves_from_leave_ledger.py b/hrms/patches/post_install/remove_denied_leaves_from_leave_ledger.py index 4029a3f0e2..c0c9134e3f 100644 --- a/hrms/patches/post_install/remove_denied_leaves_from_leave_ledger.py +++ b/hrms/patches/post_install/remove_denied_leaves_from_leave_ledger.py @@ -17,9 +17,7 @@ def execute(): def get_denied_leave_application_list(): - return frappe.db.sql_list( - """ Select name from `tabLeave Application` where status <> 'Approved' """ - ) + return frappe.db.sql_list(""" Select name from `tabLeave Application` where status <> 'Approved' """) def delete_denied_leaves_from_leave_ledger_entry(leave_application_list): diff --git a/hrms/patches/post_install/set_training_event_attendance.py b/hrms/patches/post_install/set_training_event_attendance.py index 8d2b22932d..72827a72d6 100644 --- a/hrms/patches/post_install/set_training_event_attendance.py +++ b/hrms/patches/post_install/set_training_event_attendance.py @@ -6,9 +6,7 @@ def execute(): frappe.reload_doc("hr", "doctype", "training_event_employee") # no need to run the update query as there is no old data - if not frappe.db.exists( - "Training Event Employee", {"attendance": ("in", ("Mandatory", "Optional"))} - ): + if not frappe.db.exists("Training Event Employee", {"attendance": ("in", ("Mandatory", "Optional"))}): return frappe.db.sql( diff --git a/hrms/patches/post_install/updates_for_multi_currency_payroll.py b/hrms/patches/post_install/updates_for_multi_currency_payroll.py index 8031b26c13..a582c5da24 100644 --- a/hrms/patches/post_install/updates_for_multi_currency_payroll.py +++ b/hrms/patches/post_install/updates_for_multi_currency_payroll.py @@ -7,7 +7,6 @@ def execute(): - frappe.reload_doc("payroll", "doctype", "Salary Component Account") if frappe.db.has_column("Salary Component Account", "default_account"): rename_field("Salary Component Account", "default_account", "account") @@ -40,13 +39,11 @@ def execute(): "Employee Benefit Claim", ]: frappe.db.sql( - """ - update `tab{doctype}` - set company = (select company from tabEmployee where name=`tab{doctype}`.employee) + f""" + update `tab{dt}` + set company = (select company from tabEmployee where name=`tab{dt}`.employee) where company IS NULL - """.format( - doctype=dt - ) + """ ) # update exchange rate for employee advance @@ -89,9 +86,7 @@ def execute(): for dt in doctypes_for_currency: frappe.db.sql( - """update `tab{doctype}` set currency = %s where company=%s and currency IS NULL""".format( - doctype=dt - ), + f"""update `tab{dt}` set currency = %s where company=%s and currency IS NULL""", (company_currency, company), ) diff --git a/hrms/patches/v14_0/update_repay_from_salary_and_payroll_payable_account_fields.py b/hrms/patches/v14_0/update_repay_from_salary_and_payroll_payable_account_fields.py index 2749b47697..38ff74cb75 100644 --- a/hrms/patches/v14_0/update_repay_from_salary_and_payroll_payable_account_fields.py +++ b/hrms/patches/v14_0/update_repay_from_salary_and_payroll_payable_account_fields.py @@ -3,9 +3,7 @@ def execute(): if frappe.db.exists("Custom Field", {"name": "Loan Repayment-repay_from_salary"}): - frappe.db.set_value( - "Custom Field", {"name": "Loan Repayment-repay_from_salary"}, "fetch_if_empty", 1 - ) + frappe.db.set_value("Custom Field", {"name": "Loan Repayment-repay_from_salary"}, "fetch_if_empty", 1) if frappe.db.exists("Custom Field", {"name": "Loan Repayment-payroll_payable_account"}): frappe.db.set_value( diff --git a/hrms/payroll/doctype/employee_benefit_application/employee_benefit_application.py b/hrms/payroll/doctype/employee_benefit_application/employee_benefit_application.py index aeaa15a0a2..1d5580b633 100644 --- a/hrms/payroll/doctype/employee_benefit_application/employee_benefit_application.py +++ b/hrms/payroll/doctype/employee_benefit_application/employee_benefit_application.py @@ -57,9 +57,7 @@ def validate_prev_benefit_claim(self): frappe.throw( _( "An amount of {0} already claimed for the component {1}, set the amount equal or greater than {2}" - ).format( - benefit_claimed, benefit.earning_component, benefit_claim_remining - ) + ).format(benefit_claimed, benefit.earning_component, benefit_claim_remining) ) def validate_remaining_benefit_amount(self): @@ -78,7 +76,10 @@ def validate_remaining_benefit_amount(self): salary_structure = frappe.get_doc("Salary Structure", salary_struct_name) if salary_structure.earnings: for earnings in salary_structure.earnings: - if earnings.is_flexible_benefit == 1 and earnings.salary_component not in benefit_components: + if ( + earnings.is_flexible_benefit == 1 + and earnings.salary_component not in benefit_components + ): pay_against_benefit_claim, max_benefit_amount = frappe.db.get_value( "Salary Component", earnings.salary_component, @@ -103,9 +104,9 @@ def validate_remaining_benefit_amount(self): ) elif non_pro_rata_amount == 0: frappe.throw( - _("Please add the remaining benefits {0} to the application as pro-rata component").format( - self.remaining_benefit - ) + _( + "Please add the remaining benefits {0} to the application as pro-rata component" + ).format(self.remaining_benefit) ) def validate_max_benefit_for_component(self): @@ -233,7 +234,7 @@ def calculate_lwp(employee, start_date, holidays, working_days): query = ( frappe.qb.from_(LeaveApplication) .inner_join(LeaveType) - .on((LeaveType.name == LeaveApplication.leave_type)) + .on(LeaveType.name == LeaveApplication.leave_type) .select(LeaveApplication.name, is_half_day) .where( (LeaveType.is_lwp == 1) @@ -246,7 +247,7 @@ def calculate_lwp(employee, start_date, holidays, working_days): # if it's a holiday only include if leave type has "include holiday" enabled if date in holidays: - query = query.where((LeaveType.include_holiday == "1")) + query = query.where(LeaveType.include_holiday == "1") leaves = query.run(as_dict=True) if leaves: diff --git a/hrms/payroll/doctype/employee_benefit_claim/employee_benefit_claim.py b/hrms/payroll/doctype/employee_benefit_claim/employee_benefit_claim.py index 6bff537794..057403f568 100644 --- a/hrms/payroll/doctype/employee_benefit_claim/employee_benefit_claim.py +++ b/hrms/payroll/doctype/employee_benefit_claim/employee_benefit_claim.py @@ -77,16 +77,16 @@ def validate_non_pro_rata_benefit_claim(self, max_benefits, payroll_period): sal_struct_name = get_assigned_salary_structure(self.employee, self.claim_date) if sal_struct_name: sal_struct = frappe.get_doc("Salary Structure", sal_struct_name) - pro_rata_amount = get_benefit_pro_rata_ratio_amount(self.employee, self.claim_date, sal_struct) + pro_rata_amount = get_benefit_pro_rata_ratio_amount( + self.employee, self.claim_date, sal_struct + ) claimed_amount += get_previous_claimed_amount(self.employee, payroll_period, non_pro_rata=True) if max_benefits < pro_rata_amount + claimed_amount: frappe.throw( _( "Maximum benefit of employee {0} exceeds {1} by the sum {2} of benefit application pro-rata component amount and previous claimed amount" - ).format( - self.employee, max_benefits, pro_rata_amount + claimed_amount - max_benefits - ) + ).format(self.employee, max_benefits, pro_rata_amount + claimed_amount - max_benefits) ) def get_pro_rata_amount_in_application(self, payroll_period): @@ -179,9 +179,7 @@ def get_total_benefit_dispensed(employee, sal_struct, sal_slip_start_date, payro else: pro_rata_amount = get_benefit_pro_rata_ratio_amount(employee, sal_slip_start_date, sal_struct) - claimed_amount += get_benefit_claim_amount( - employee, payroll_period.start_date, payroll_period.end_date - ) + claimed_amount += get_benefit_claim_amount(employee, payroll_period.start_date, payroll_period.end_date) return claimed_amount + pro_rata_amount @@ -226,9 +224,9 @@ def get_last_payroll_period_benefits( struct_row["do_not_include_in_total"] = salary_component.do_not_include_in_total struct_row["is_tax_applicable"] = (salary_component.is_tax_applicable,) struct_row["is_flexible_benefit"] = (salary_component.is_flexible_benefit,) - struct_row[ - "variable_based_on_taxable_salary" - ] = salary_component.variable_based_on_taxable_salary + struct_row["variable_based_on_taxable_salary"] = ( + salary_component.variable_based_on_taxable_salary + ) salary_components_dict["amount"] = amount salary_components_dict["struct_row"] = struct_row salary_components_array.append(salary_components_dict) diff --git a/hrms/payroll/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.py b/hrms/payroll/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.py index d1a39cf0f0..b75427a4ec 100644 --- a/hrms/payroll/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.py +++ b/hrms/payroll/doctype/employee_tax_exemption_proof_submission/employee_tax_exemption_proof_submission.py @@ -49,5 +49,6 @@ def calculate_hra_exemption(self): hra_exemption["monthly_house_rent"], self.precision("monthly_house_rent") ) self.total_eligible_hra_exemption = flt( - hra_exemption["total_eligible_hra_exemption"], self.precision("total_eligible_hra_exemption") + hra_exemption["total_eligible_hra_exemption"], + self.precision("total_eligible_hra_exemption"), ) diff --git a/hrms/payroll/doctype/gratuity/gratuity.py b/hrms/payroll/doctype/gratuity/gratuity.py index 63085ef010..c95db90fbb 100644 --- a/hrms/payroll/doctype/gratuity/gratuity.py +++ b/hrms/payroll/doctype/gratuity/gratuity.py @@ -42,9 +42,7 @@ def set_status(self, update=False): if self.docstatus == 0: status = "Draft" elif self.docstatus == 1: - if flt(self.paid_amount) > 0 and flt(self.amount, precision) == flt( - self.paid_amount, precision - ): + if flt(self.paid_amount) > 0 and flt(self.amount, precision) == flt(self.paid_amount, precision): status = "Paid" else: status = "Unpaid" @@ -196,9 +194,7 @@ def calculate_employee_total_workings_days(employee, date_of_joining, relieving_ return employee_total_workings_days -def get_work_experience_using_method( - method, current_work_experience, minimum_year_for_gratuity, employee -): +def get_work_experience_using_method(method, current_work_experience, minimum_year_for_gratuity, employee): if method == "Round off Work Experience": current_work_experience = round(current_work_experience) else: @@ -214,7 +210,6 @@ def get_work_experience_using_method( def get_non_working_days(employee, relieving_date, status): - filters = { "docstatus": 1, "status": status, @@ -337,9 +332,7 @@ def calculate_amount_based_on_current_slab( slab_found = False gratuity_amount = 0 if experience >= from_year and (to_year == 0 or experience < to_year): - gratuity_amount = ( - total_applicable_components_amount * experience * fraction_of_applicable_earnings - ) + gratuity_amount = total_applicable_components_amount * experience * fraction_of_applicable_earnings if fraction_of_applicable_earnings: slab_found = True diff --git a/hrms/payroll/doctype/gratuity/test_gratuity.py b/hrms/payroll/doctype/gratuity/test_gratuity.py index 2b64ccb220..20ab04a8d0 100644 --- a/hrms/payroll/doctype/gratuity/test_gratuity.py +++ b/hrms/payroll/doctype/gratuity/test_gratuity.py @@ -198,9 +198,7 @@ def set_mode_of_payment_account(): mode_of_payment = frappe.get_doc("Mode of Payment", "Cash") mode_of_payment.accounts = [] - mode_of_payment.append( - "accounts", {"company": "_Test Company", "default_account": "_Test Bank - _TC"} - ) + mode_of_payment.append("accounts", {"company": "_Test Company", "default_account": "_Test Bank - _TC"}) mode_of_payment.save() diff --git a/hrms/payroll/doctype/gratuity_rule/gratuity_rule.py b/hrms/payroll/doctype/gratuity_rule/gratuity_rule.py index 5cde79a162..b3cb7e73bb 100644 --- a/hrms/payroll/doctype/gratuity_rule/gratuity_rule.py +++ b/hrms/payroll/doctype/gratuity_rule/gratuity_rule.py @@ -16,7 +16,9 @@ def validate(self): ) if ( - current_slab.to_year == 0 and current_slab.from_year == 0 and len(self.gratuity_rule_slabs) > 1 + current_slab.to_year == 0 + and current_slab.from_year == 0 + and len(self.gratuity_rule_slabs) > 1 ): frappe.throw( _("You can not define multiple slabs if you have a slab with no lower and upper limits.") @@ -28,9 +30,7 @@ def get_gratuity_rule(name, slabs, **args): rule = frappe.new_doc("Gratuity Rule") rule.name = name - rule.calculate_gratuity_amount_based_on = ( - args.calculate_gratuity_amount_based_on or "Current Slab" - ) + rule.calculate_gratuity_amount_based_on = args.calculate_gratuity_amount_based_on or "Current Slab" rule.work_experience_calculation_method = ( args.work_experience_calculation_method or "Take Exact Completed Years" ) diff --git a/hrms/payroll/doctype/payroll_entry/payroll_entry.py b/hrms/payroll/doctype/payroll_entry/payroll_entry.py index c099da0ae3..b28cf35af2 100644 --- a/hrms/payroll/doctype/payroll_entry/payroll_entry.py +++ b/hrms/payroll/doctype/payroll_entry/payroll_entry.py @@ -290,7 +290,8 @@ def get_salary_components(self, component_type): ss.employee, ) .where( - (ssd.parentfield == component_type) & (ss.name.isin(tuple([d.name for d in salary_slips]))) + (ssd.parentfield == component_type) + & (ss.name.isin(tuple([d.name for d in salary_slips]))) ) ).run(as_dict=True) @@ -561,7 +562,9 @@ def make_accrual_jv_entry(self): } """ for employee, employee_details in self.employee_based_payroll_payable_entries.items(): - payable_amount = employee_details.get("earnings", 0) - employee_details.get("deductions", 0) + payable_amount = employee_details.get("earnings", 0) - employee_details.get( + "deductions", 0 + ) payable_amount = self.get_accounting_entries_and_payable_amount( payroll_payable_account, @@ -693,9 +696,7 @@ def update_accounting_dimensions(self, row, accounting_dimensions): return row - def get_amount_and_exchange_rate_for_journal_entry( - self, account, amount, company_currency, currencies - ): + def get_amount_and_exchange_rate_for_journal_entry(self, account, amount, company_currency, currencies): conversion_rate = 1 exchange_rate = self.exchange_rate account_currency = frappe.db.get_value("Account", account, "account_currency") @@ -1106,9 +1107,7 @@ def get_frequency_kwargs(frequency_name): def get_end_date(start_date, frequency): start_date = getdate(start_date) frequency = frequency.lower() if frequency else "monthly" - kwargs = ( - get_frequency_kwargs(frequency) if frequency != "bimonthly" else get_frequency_kwargs("monthly") - ) + kwargs = get_frequency_kwargs(frequency) if frequency != "bimonthly" else get_frequency_kwargs("monthly") # weekly, fortnightly and daily intervals have fixed days so no problems end_date = add_to_date(start_date, **kwargs) - relativedelta(days=1) @@ -1286,7 +1285,9 @@ def submit_salary_slips_for_employees(payroll_entry, salary_slips, publish_progr count += 1 if publish_progress: - frappe.publish_progress(count * 100 / len(salary_slips), title=_("Submitting Salary Slips...")) + frappe.publish_progress( + count * 100 / len(salary_slips), title=_("Submitting Salary Slips...") + ) if submitted: payroll_entry.make_accrual_jv_entry() @@ -1310,15 +1311,13 @@ def submit_salary_slips_for_employees(payroll_entry, salary_slips, publish_progr @frappe.validate_and_sanitize_search_inputs def get_payroll_entries_for_jv(doctype, txt, searchfield, start, page_len, filters): return frappe.db.sql( - """ + f""" select name from `tabPayroll Entry` - where `{key}` LIKE %(txt)s + where `{searchfield}` LIKE %(txt)s and name not in (select reference_name from `tabJournal Entry Account` where reference_type="Payroll Entry") - order by name limit %(start)s, %(page_len)s""".format( - key=searchfield - ), + order by name limit %(start)s, %(page_len)s""", {"txt": "%%%s%%" % txt, "start": start, "page_len": page_len}, ) @@ -1362,9 +1361,7 @@ def employee_query(doctype, txt, searchfield, start, page_len, filters): if filters.start_date and filters.end_date: employee_list = get_employee_list(filters) emp = filters.get("employees") or [] - include_employees = [ - employee.employee for employee in employee_list if employee.employee not in emp - ] + include_employees = [employee.employee for employee in employee_list if employee.employee not in emp] filters.pop("start_date") filters.pop("end_date") if "salary_slip_based_on_timesheet" in filters: diff --git a/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py b/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py index d3d017f202..c919456132 100644 --- a/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py +++ b/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py @@ -72,9 +72,7 @@ def setUp(self): frappe.db.set_value("Payroll Settings", None, "email_salary_slip_to_employee", 0) # set default payable account - default_account = frappe.db.get_value( - "Company", "_Test Company", "default_payroll_payable_account" - ) + default_account = frappe.db.get_value("Company", "_Test Company", "default_payroll_payable_account") if not default_account or default_account != "_Test Payroll Payable - _TC": create_account( account_name="_Test Payroll Payable", @@ -157,9 +155,7 @@ def test_payroll_entry_with_employee_cost_center(self): department=department, company="_Test Company", ) - employee2 = make_employee( - "test_emp2@example.com", department=department, company="_Test Company" - ) + employee2 = make_employee("test_emp2@example.com", department=department, company="_Test Company") create_assignments_with_cost_centers(employee1, employee2) @@ -252,9 +248,7 @@ def test_loan(self): loan.repay_from_salary = 1 loan.submit() - make_loan_disbursement_entry( - loan.name, loan.loan_amount, disbursement_date=add_months(nowdate(), -1) - ) + make_loan_disbursement_entry(loan.name, loan.loan_amount, disbursement_date=add_months(nowdate(), -1)) process_loan_interest_accrual_for_term_loans(posting_date=nowdate()) dates = get_start_end_dates("Monthly", nowdate()) @@ -269,9 +263,7 @@ def test_loan(self): payment_account="Cash - _TC", ) - name = frappe.db.get_value( - "Salary Slip", {"posting_date": nowdate(), "employee": applicant}, "name" - ) + name = frappe.db.get_value("Salary Slip", {"posting_date": nowdate(), "employee": applicant}, "name") salary_slip = frappe.get_doc("Salary Slip", name) for row in salary_slip.loans: @@ -568,9 +560,7 @@ def test_employee_wise_bank_entry_with_cost_centers(self): department=department, company="_Test Company", ) - employee2 = make_employee( - "test_emp2@example.com", department=department, company="_Test Company" - ) + employee2 = make_employee("test_emp2@example.com", department=department, company="_Test Company") create_assignments_with_cost_centers(employee1, employee2) @@ -772,10 +762,6 @@ def create_assignments_with_cost_centers(employee1, employee2): ssa_doc = frappe.get_doc("Salary Structure Assignment", ssa) ssa_doc.payroll_cost_centers = [] - ssa_doc.append( - "payroll_cost_centers", {"cost_center": "_Test Cost Center - _TC", "percentage": 60} - ) - ssa_doc.append( - "payroll_cost_centers", {"cost_center": "_Test Cost Center 2 - _TC", "percentage": 40} - ) + ssa_doc.append("payroll_cost_centers", {"cost_center": "_Test Cost Center - _TC", "percentage": 60}) + ssa_doc.append("payroll_cost_centers", {"cost_center": "_Test Cost Center 2 - _TC", "percentage": 40}) ssa_doc.save() diff --git a/hrms/payroll/doctype/payroll_period/payroll_period.py b/hrms/payroll/doctype/payroll_period/payroll_period.py index ba20490f61..9b1054b4c5 100644 --- a/hrms/payroll/doctype/payroll_period/payroll_period.py +++ b/hrms/payroll/doctype/payroll_period/payroll_period.py @@ -48,7 +48,7 @@ def validate_overlap(self): _("A {0} exists between {1} and {2} (").format( self.doctype, formatdate(self.start_date), formatdate(self.end_date) ) - + """ {1}""".format(self.doctype, overlap_doc[0].name) + + f""" {overlap_doc[0].name}""" + _(") for {0}").format(self.company) ) frappe.throw(msg) @@ -72,9 +72,7 @@ def get_payroll_period_days(start_date, end_date, employee, company=None): if len(payroll_period) > 0: actual_no_of_days = date_diff(getdate(payroll_period[0][2]), getdate(payroll_period[0][1])) + 1 working_days = actual_no_of_days - if not cint( - frappe.db.get_value("Payroll Settings", None, "include_holidays_in_total_working_days") - ): + if not cint(frappe.db.get_value("Payroll Settings", None, "include_holidays_in_total_working_days")): holidays = get_holiday_dates_for_employee( employee, getdate(payroll_period[0][1]), getdate(payroll_period[0][2]) ) diff --git a/hrms/payroll/doctype/retention_bonus/retention_bonus.py b/hrms/payroll/doctype/retention_bonus/retention_bonus.py index ac23572ece..d670160321 100644 --- a/hrms/payroll/doctype/retention_bonus/retention_bonus.py +++ b/hrms/payroll/doctype/retention_bonus/retention_bonus.py @@ -41,7 +41,6 @@ def on_submit(self): self.db_set("additional_salary", additional_salary) def on_cancel(self): - additional_salary = self.get_additional_salary() if additional_salary: bonus_removed = ( diff --git a/hrms/payroll/doctype/salary_slip/salary_slip.py b/hrms/payroll/doctype/salary_slip/salary_slip.py index 800e8902bd..b30cb4c338 100644 --- a/hrms/payroll/doctype/salary_slip/salary_slip.py +++ b/hrms/payroll/doctype/salary_slip/salary_slip.py @@ -58,7 +58,7 @@ class SalarySlip(TransactionBase): def __init__(self, *args, **kwargs): super(SalarySlip, self).__init__(*args, **kwargs) - self.series = "Sal Slip/{0}/.#####".format(self.employee) + self.series = f"Sal Slip/{self.employee}/.#####" self.whitelisted_globals = { "int": int, "float": float, @@ -373,15 +373,11 @@ def pull_sal_struct(self): self.total_working_hours = sum([d.working_hours or 0.0 for d in self.timesheets]) or 0.0 wages_amount = self.hour_rate * self.total_working_hours - self.add_earning_for_hourly_wages( - self, self._salary_structure_doc.salary_component, wages_amount - ) + self.add_earning_for_hourly_wages(self, self._salary_structure_doc.salary_component, wages_amount) make_salary_slip(self._salary_structure_doc.name, self) - def get_working_days_details( - self, joining_date=None, relieving_date=None, lwp=None, for_preview=0 - ): + def get_working_days_details(self, joining_date=None, relieving_date=None, lwp=None, for_preview=0): payroll_based_on = frappe.db.get_value("Payroll Settings", None, "payroll_based_on") include_holidays_in_total_working_days = frappe.db.get_single_value( "Payroll Settings", "include_holidays_in_total_working_days" @@ -397,9 +393,7 @@ def get_working_days_details( return holidays = self.get_holidays_for_employee(self.start_date, self.end_date) - working_days_list = [ - add_days(getdate(self.start_date), days=day) for day in range(0, working_days) - ] + working_days_list = [add_days(getdate(self.start_date), days=day) for day in range(0, working_days)] if not cint(include_holidays_in_total_working_days): working_days_list = [i for i in working_days_list if i not in holidays] @@ -576,9 +570,7 @@ def get_payment_days(self, joining_date, relieving_date, include_holidays_in_tot def get_holidays_for_employee(self, start_date, end_date): return get_holiday_dates_for_employee(self.employee, start_date, end_date) - def calculate_lwp_or_ppl_based_on_leave_application( - self, holidays, working_days_list, relieving_date - ): + def calculate_lwp_or_ppl_based_on_leave_application(self, holidays, working_days_list, relieving_date): lwp = 0 holidays = "','".join(holidays) daily_wages_fraction_for_half_day = ( @@ -631,9 +623,7 @@ def calculate_lwp_ppl_and_absent_days_based_on_attendance(self, holidays, reliev and payroll_settings.consider_marked_attendance_on_holidays ) - daily_wages_fraction_for_half_day = ( - flt(payroll_settings.daily_wages_fraction_for_half_day) or 0.5 - ) + daily_wages_fraction_for_half_day = flt(payroll_settings.daily_wages_fraction_for_half_day) or 0.5 leave_types = frappe.get_all( "Leave Type", @@ -749,9 +739,7 @@ def set_net_pay(self): ) self.net_pay = flt(self.gross_pay) - (flt(self.total_deduction) + flt(self.total_loan_repayment)) self.rounded_total = rounded(self.net_pay) - self.base_net_pay = flt( - flt(self.net_pay) * flt(self.exchange_rate), self.precision("base_net_pay") - ) + self.base_net_pay = flt(flt(self.net_pay) * flt(self.exchange_rate), self.precision("base_net_pay")) self.base_rounded_total = flt(rounded(self.base_net_pay), self.precision("base_net_pay")) if self.hour_rate: self.base_hour_rate = flt( @@ -765,9 +753,7 @@ def compute_taxable_earnings_for_year(self): self.payroll_period.start_date, self.start_date, self.tax_slab.allow_tax_exemption ) - self.previous_taxable_earnings_before_exemption = ( - self.previous_taxable_earnings + exempted_amount - ) + self.previous_taxable_earnings_before_exemption = self.previous_taxable_earnings + exempted_amount self.compute_current_and_future_taxable_earnings() @@ -831,9 +817,7 @@ def compute_current_and_future_taxable_earnings(self): + self.current_taxable_earnings_for_payment_days.amount_exempted_from_income_tax ) - self.current_additional_earnings = ( - self.current_taxable_earnings_for_payment_days.additional_income - ) + self.current_additional_earnings = self.current_taxable_earnings_for_payment_days.additional_income self.current_additional_earnings_with_full_tax = ( self.current_taxable_earnings_for_payment_days.additional_income_with_full_tax @@ -875,9 +859,7 @@ def compute_income_tax_breakup(self): self.income_tax_deducted_till_date = self.get_income_tax_deducted_till_date() - if hasattr(self, "total_structured_tax_amount") and hasattr( - self, "current_structured_tax_amount" - ): + if hasattr(self, "total_structured_tax_amount") and hasattr(self, "current_structured_tax_amount"): self.future_income_tax_deductions = ( self.total_structured_tax_amount - self.income_tax_deducted_till_date ) @@ -891,7 +873,6 @@ def compute_income_tax_breakup(self): def compute_ctc(self): if hasattr(self, "previous_taxable_earnings"): - return ( self.previous_taxable_earnings_before_exemption + self.current_structured_taxable_earnings_before_exemption @@ -1091,9 +1072,7 @@ def get_data_for_eval(self): employee = frappe.get_doc("Employee", self.employee).as_dict() start_date = getdate(self.start_date) - date_to_validate = ( - employee.date_of_joining if employee.date_of_joining > start_date else start_date - ) + date_to_validate = employee.date_of_joining if employee.date_of_joining > start_date else start_date salary_structure_assignment = frappe.get_value( "Salary Structure Assignment", @@ -1277,9 +1256,7 @@ def get_tax_components(self) -> list: it returns the default tax components. """ - tax_components = frappe.cache().get_value( - "tax_components", self._fetch_company_wise_tax_components - ) + tax_components = frappe.cache().get_value("tax_components", self._fetch_company_wise_tax_components) default_tax_components = tax_components.get("default", []) @@ -1397,9 +1374,7 @@ def update_component_row( if data: data[component_row.abbr] = component_row.amount - def update_component_amount_based_on_payment_days( - self, component_row, remove_if_zero_valued=None - ): + def update_component_amount_based_on_payment_days(self, component_row, remove_if_zero_valued=None): joining_date, relieving_date = self.get_joining_and_relieving_dates() component_row.amount = self.get_amount_based_on_payment_days( component_row, joining_date, relieving_date @@ -1508,9 +1483,7 @@ def get_taxable_earnings_for_prev_period(self, start_date, end_date, allow_tax_e start_date, end_date, parentfield="deductions", exempted_from_income_tax=1 ) - opening_taxable_earning = self.get_opening_for( - "taxable_earnings_till_date", start_date, end_date - ) + opening_taxable_earning = self.get_opening_for("taxable_earnings_till_date", start_date, end_date) return (taxable_earnings + opening_taxable_earning) - exempted_amount, exempted_amount @@ -1667,9 +1640,7 @@ def get_future_recurring_period(self, additional_salary): if getdate(to_date) > getdate(self.payroll_period.end_date): to_date = getdate(self.payroll_period.end_date) - future_recurring_period = ((to_date.year - from_date.year) * 12) + ( - to_date.month - from_date.month - ) + future_recurring_period = ((to_date.year - from_date.year) * 12) + (to_date.month - from_date.month) return future_recurring_period @@ -1725,9 +1696,7 @@ def get_amount_based_on_payment_days(self, row, joining_date, relieving_date): amount = flt(row.default_amount) + flt(row.additional_amount) # apply rounding - if frappe.get_cached_value( - "Salary Component", row.salary_component, "round_to_the_nearest_integer" - ): + if frappe.get_cached_value("Salary Component", row.salary_component, "round_to_the_nearest_integer"): amount, additional_amount = rounded(amount or 0), rounded(additional_amount or 0) return amount, additional_amount @@ -1837,7 +1806,6 @@ def set_loan_repayment(self): if not self.get("loans"): for loan in self.get_loan_details(): - amounts = calculate_amounts(loan.name, self.posting_date, "Regular Payment") if amounts["interest_amount"] or amounts["payable_principal_amount"]: @@ -1937,17 +1905,15 @@ def email_salary_slip(self): password = None if payroll_settings.encrypt_salary_slips_in_emails: password = generate_password_for_pdf(payroll_settings.password_policy, self.employee) - message += """
Note: Your salary slip is password protected, - the password to unlock the PDF is of the format {0}. """.format( - payroll_settings.password_policy - ) + message += f"""
Note: Your salary slip is password protected, + the password to unlock the PDF is of the format {payroll_settings.password_policy}. """ if receiver: email_args = { "sender": payroll_settings.sender_email, "recipients": [receiver], "message": _(message), - "subject": "Salary Slip - from {0} to {1}".format(self.start_date, self.end_date), + "subject": f"Salary Slip - from {self.start_date} to {self.end_date}", "attachments": [ frappe.attach_print(self.doctype, self.name, file_name=self.name, password=password) ], @@ -2189,16 +2155,12 @@ def get_payroll_payable_account(company, payroll_entry): "Payroll Entry", payroll_entry, "payroll_payable_account" ) else: - payroll_payable_account = frappe.db.get_value( - "Company", company, "default_payroll_payable_account" - ) + payroll_payable_account = frappe.db.get_value("Company", company, "default_payroll_payable_account") return payroll_payable_account -def calculate_tax_by_tax_slab( - annual_taxable_earning, tax_slab, eval_globals=None, eval_locals=None -): +def calculate_tax_by_tax_slab(annual_taxable_earning, tax_slab, eval_globals=None, eval_locals=None): eval_locals.update({"annual_taxable_earning": annual_taxable_earning}) tax_amount = 0 for slab in tax_slab.slabs: @@ -2273,7 +2235,7 @@ def get_lwp_or_ppl_for_date(date, employee, holidays): query = ( frappe.qb.from_(LeaveApplication) .inner_join(LeaveType) - .on((LeaveType.name == LeaveApplication.leave_type)) + .on(LeaveType.name == LeaveApplication.leave_type) .select( LeaveApplication.name, LeaveType.is_ppl, @@ -2281,7 +2243,7 @@ def get_lwp_or_ppl_for_date(date, employee, holidays): (is_half_day), ) .where( - (((LeaveType.is_lwp == 1) | (LeaveType.is_ppl == 1))) + ((LeaveType.is_lwp == 1) | (LeaveType.is_ppl == 1)) & (LeaveApplication.docstatus == 1) & (LeaveApplication.status == "Approved") & (LeaveApplication.employee == employee) @@ -2292,7 +2254,7 @@ def get_lwp_or_ppl_for_date(date, employee, holidays): # if it's a holiday only include if leave type has "include holiday" enabled if date in holidays: - query = query.where((LeaveType.include_holiday == "1")) + query = query.where(LeaveType.include_holiday == "1") return query.run(as_dict=True) @@ -2378,11 +2340,7 @@ def _check_attributes(code: str) -> None: for node in ast.walk(tree): if isinstance(node, BLOCKED_NODES): raise SyntaxError(f"Operation not allowed: line {node.lineno} column {node.col_offset}") - if ( - isinstance(node, ast.Attribute) - and isinstance(node.attr, str) - and node.attr in UNSAFE_ATTRIBUTES - ): + if isinstance(node, ast.Attribute) and isinstance(node.attr, str) and node.attr in UNSAFE_ATTRIBUTES: raise SyntaxError(f'Illegal rule {frappe.bold(code)}. Cannot use "{node.attr}"') diff --git a/hrms/payroll/doctype/salary_slip/test_salary_slip.py b/hrms/payroll/doctype/salary_slip/test_salary_slip.py index 5cd65e5b49..eaebda7af3 100644 --- a/hrms/payroll/doctype/salary_slip/test_salary_slip.py +++ b/hrms/payroll/doctype/salary_slip/test_salary_slip.py @@ -66,9 +66,7 @@ def test_employee_status_inactive(self): make_holiday_list() frappe.db.set_value("Company", employee_doc.company, "default_holiday_list", HOLIDAY_LIST) - frappe.db.sql( - """delete from `tabSalary Structure` where name='Test Inactive Employee Salary Slip'""" - ) + frappe.db.sql("""delete from `tabSalary Structure` where name='Test Inactive Employee Salary Slip'""") salary_structure = make_salary_structure( "Test Inactive Employee Salary Slip", "Monthly", @@ -342,9 +340,7 @@ def test_payment_days_in_salary_slip_based_on_timesheet(self): # mark attendance first_sunday = get_first_sunday() - mark_attendance( - emp, add_days(first_sunday, 1), "Absent", ignore_validate=True - ) # counted as absent + mark_attendance(emp, add_days(first_sunday, 1), "Absent", ignore_validate=True) # counted as absent # salary structure based on timesheet make_salary_structure_for_timesheet(emp, "_Test Company") @@ -370,9 +366,7 @@ def test_payment_days_in_salary_slip_based_on_timesheet(self): amount = row.amount precision = row.precision("amount") break - expected_amount = flt( - (50000 * salary_slip.payment_days / salary_slip.total_working_days), precision - ) + expected_amount = flt((50000 * salary_slip.payment_days / salary_slip.total_working_days), precision) self.assertEqual(amount, expected_amount) @@ -535,9 +529,7 @@ def test_consider_marked_attendance_on_holidays_with_unmarked_attendance(self): mark_attendance(emp_id, first_sunday, "Absent", ignore_validate=True) # unmarked attendance for a day - frappe.db.delete( - "Attendance", {"employee": emp_id, "attendance_date": add_days(first_sunday, 1)} - ) + frappe.db.delete("Attendance", {"employee": emp_id, "attendance_date": add_days(first_sunday, 1)}) ss = make_employee_salary_slip( emp_id, @@ -736,9 +728,7 @@ def test_loan_repayment_salary_slip(self): payroll_period=payroll_period, ) - frappe.db.sql( - "delete from tabLoan where applicant = 'test_loan_repayment_salary_slip@salary.com'" - ) + frappe.db.sql("delete from tabLoan where applicant = 'test_loan_repayment_salary_slip@salary.com'") loan = create_loan( applicant, "Car Loan", @@ -750,9 +740,7 @@ def test_loan_repayment_salary_slip(self): loan.repay_from_salary = 1 loan.submit() - make_loan_disbursement_entry( - loan.name, loan.loan_amount, disbursement_date=add_months(nowdate(), -1) - ) + make_loan_disbursement_entry(loan.name, loan.loan_amount, disbursement_date=add_months(nowdate(), -1)) process_loan_interest_accrual_for_term_loans(posting_date=nowdate()) @@ -834,9 +822,7 @@ def test_loan_write_off_salary_slip(self): payroll_period=payroll_period, ) - frappe.db.sql( - "delete from tabLoan where applicant = 'test_loan_repayment_salary_slip@salary.com'" - ) + frappe.db.sql("delete from tabLoan where applicant = 'test_loan_repayment_salary_slip@salary.com'") loan = create_loan( applicant, "Personal Loan", @@ -848,13 +834,9 @@ def test_loan_write_off_salary_slip(self): loan.repay_from_salary = 1 loan.submit() - make_loan_disbursement_entry( - loan.name, loan.loan_amount, disbursement_date=payroll_period.start_date - ) + make_loan_disbursement_entry(loan.name, loan.loan_amount, disbursement_date=payroll_period.start_date) - process_loan_interest_accrual_for_term_loans( - posting_date=add_months(payroll_period.start_date, 12) - ) + process_loan_interest_accrual_for_term_loans(posting_date=add_months(payroll_period.start_date, 12)) repayment_entry = create_repayment_entry( loan.name, applicant, add_months(payroll_period.start_date, 7), 7000 @@ -882,9 +864,7 @@ def test_multi_currency_salary_slip(self): from hrms.payroll.doctype.salary_structure.test_salary_structure import make_salary_structure applicant = make_employee("test_multi_currency_salary_slip@salary.com", company="_Test Company") - frappe.db.sql( - """delete from `tabSalary Structure` where name='Test Multi Currency Salary Slip'""" - ) + frappe.db.sql("""delete from `tabSalary Structure` where name='Test Multi Currency Salary Slip'""") salary_structure = make_salary_structure( "Test Multi Currency Salary Slip", "Monthly", @@ -1063,9 +1043,7 @@ def test_tax_for_payroll_period(self): # Submit benefit claim for total 50000 data["benefit-1"] = create_benefit_claim(employee, payroll_period, 15000, "Medical Allowance") - data["benefit-2"] = create_benefit_claim( - employee, payroll_period, 35000, "Leave Travel Allowance" - ) + data["benefit-2"] = create_benefit_claim(employee, payroll_period, 35000, "Leave Travel Allowance") frappe.db.sql("""delete from `tabSalary Slip` where employee=%s""", (employee)) data["deducted_dates"] = create_salary_slips_for_payroll_period( @@ -1382,9 +1360,7 @@ def test_income_tax_breakup_fields(self): payroll_period = frappe.get_all("Payroll Period", filters={"company": "_Test Company"}, limit=1) payroll_period = frappe.get_cached_doc("Payroll Period", payroll_period[0].name) - create_tax_slab( - payroll_period, effective_date=payroll_period.start_date, allow_tax_exemption=True - ) + create_tax_slab(payroll_period, effective_date=payroll_period.start_date, allow_tax_exemption=True) salary_structure_name = "Test Salary Structure to test Income Tax Breakup" if not frappe.db.exists("Salary Structure", salary_structure_name): @@ -1626,9 +1602,7 @@ def test_get_income_tax_slabs(self): salary_structures.append(salary_structure) # fetches the correct tax slab for backdated salary slip - salary_slip = make_salary_slip( - salary_structures[0].name, employee=employee, posting_date=year_start - ) + salary_slip = make_salary_slip(salary_structures[0].name, employee=employee, posting_date=year_start) salary_slip.insert() self.assertEqual(salary_slip.get_income_tax_slabs().name, tax_slabs[0]) @@ -1661,9 +1635,7 @@ def test_safe_eval_for_salary_slip(self): user.user_type = "System User" user.enabled = 1 self.assertTrue(_safe_eval("user_type == 'System User'", eval_locals=user.as_dict())) - self.assertEqual( - "System User Test", _safe_eval("user_type + ' Test'", eval_locals=user.as_dict()) - ) + self.assertEqual("System User Test", _safe_eval("user_type + ' Test'", eval_locals=user.as_dict())) self.assertEqual(1, _safe_eval("int(enabled)", eval_locals=user.as_dict())) # Walrus not allowed @@ -1699,11 +1671,7 @@ def make_income_tax_components(): def get_no_of_days(): no_of_days_in_month = calendar.monthrange(getdate(nowdate()).year, getdate(nowdate()).month) no_of_holidays_in_month = len( - [ - 1 - for i in calendar.monthcalendar(getdate(nowdate()).year, getdate(nowdate()).month) - if i[6] != 0 - ] + [1 for i in calendar.monthcalendar(getdate(nowdate()).year, getdate(nowdate()).month) if i[6] != 0] ) return [no_of_days_in_month[1], no_of_holidays_in_month] @@ -1715,9 +1683,7 @@ def make_employee_salary_slip(emp_id, payroll_frequency, salary_structure=None, if not salary_structure: salary_structure = payroll_frequency + " Salary Structure Test for Salary Slip" - employee = frappe.db.get_value( - "Employee", emp_id, ["name", "company", "employee_name"], as_dict=True - ) + employee = frappe.db.get_value("Employee", emp_id, ["name", "company", "employee_name"], as_dict=True) salary_structure_doc = make_salary_structure( salary_structure, @@ -1730,9 +1696,7 @@ def make_employee_salary_slip(emp_id, payroll_frequency, salary_structure=None, if not salary_slip_name: date = posting_date or nowdate() - salary_slip = make_salary_slip( - salary_structure_doc.name, employee=employee.name, posting_date=date - ) + salary_slip = make_salary_slip(salary_structure_doc.name, employee=employee.name, posting_date=date) salary_slip.employee_name = employee.employee_name salary_slip.payroll_frequency = payroll_frequency salary_slip.posting_date = date @@ -2167,9 +2131,7 @@ def setup_test(): make_holiday_list() make_payroll_period() - frappe.db.set_value( - "Company", erpnext.get_default_company(), "default_holiday_list", HOLIDAY_LIST - ) + frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", HOLIDAY_LIST) frappe.db.set_value("Payroll Settings", None, "email_salary_slip_to_employee", 0) frappe.db.set_value("HR Settings", None, "leave_status_notification_template", None) @@ -2330,9 +2292,7 @@ def make_salary_slip_for_payment_days_dependency_test(employee, salary_structure return salary_slip -def create_recurring_additional_salary( - employee, salary_component, amount, from_date, to_date, company=None -): +def create_recurring_additional_salary(employee, salary_component, amount, from_date, to_date, company=None): frappe.get_doc( { "doctype": "Additional Salary", @@ -2359,9 +2319,7 @@ def make_salary_structure_for_timesheet(employee, company=None): frequency = "Monthly" if not frappe.db.exists("Salary Component", "Timesheet Component"): - frappe.get_doc( - {"doctype": "Salary Component", "salary_component": "Timesheet Component"} - ).insert() + frappe.get_doc({"doctype": "Salary Component", "salary_component": "Timesheet Component"}).insert() salary_structure = make_salary_structure( salary_structure_name, frequency, company=company, dont_submit=True diff --git a/hrms/payroll/doctype/salary_structure/salary_structure.py b/hrms/payroll/doctype/salary_structure/salary_structure.py index c73717a47b..f41091e57d 100644 --- a/hrms/payroll/doctype/salary_structure/salary_structure.py +++ b/hrms/payroll/doctype/salary_structure/salary_structure.py @@ -28,7 +28,9 @@ def validate_formula_setup(self): for row in self.get(table): if not row.amount_based_on_formula and row.formula: frappe.msgprint( - _("{0} Row #{1}: Formula is set but {2} is disabled for the Salary Component {3}.").format( + _( + "{0} Row #{1}: Formula is set but {2} is disabled for the Salary Component {3}." + ).format( table.capitalize(), row.idx, frappe.bold(_("Amount Based on Formula")), @@ -95,9 +97,7 @@ def validate_payment_days_based_dependent_component(self): ) message += "

" + _( "Disable {0} for the {1} component, to prevent the amount from being deducted twice, as its formula already uses a payment-days-based component." - ).format( - frappe.bold("Depends On Payment Days"), frappe.bold(row.salary_component) - ) + ).format(frappe.bold("Depends On Payment Days"), frappe.bold(row.salary_component)) frappe.throw(message, title=_("Payment Days Dependency")) def get_component_abbreviations(self): @@ -160,15 +160,13 @@ def get_employees(self, **kwargs): conditions, values = [], [] for field, value in kwargs.items(): if value: - conditions.append("{0}=%s".format(field)) + conditions.append(f"{field}=%s") values.append(value) condition_str = " and " + " and ".join(conditions) if conditions else "" employees = frappe.db.sql_list( - "select name from tabEmployee where status='Active' {condition}".format( - condition=condition_str - ), + f"select name from tabEmployee where status='Active' {condition_str}", tuple(values), ) @@ -358,7 +356,7 @@ def postprocess(source, target): ) if cint(as_print): - doc.name = "Preview for {0}".format(employee) + doc.name = f"Preview for {employee}" return frappe.get_print(doc.doctype, doc.name, doc=doc, print_format=print_format) else: return doc @@ -395,7 +393,7 @@ def get_salary_component(doctype, txt, searchfield, start, page_len, filters): .where( (sc.type == filters.get("component_type")) & (sc.disabled == 0) - & (sc[searchfield].like("%{0}%".format(txt)) | sc.name.like("%{0}%".format(txt))) + & (sc[searchfield].like(f"%{txt}%") | sc.name.like(f"%{txt}%")) ) .limit(page_len) .offset(start) diff --git a/hrms/payroll/doctype/salary_structure/test_salary_structure.py b/hrms/payroll/doctype/salary_structure/test_salary_structure.py index 9ad62a728d..abdf86ac26 100644 --- a/hrms/payroll/doctype/salary_structure/test_salary_structure.py +++ b/hrms/payroll/doctype/salary_structure/test_salary_structure.py @@ -53,7 +53,6 @@ def make_holiday_list(self): holiday_list.save() def test_salary_structure_deduction_based_on_gross_pay(self): - emp = make_employee("test_employee_3@salary.com") sal_struct = make_salary_structure("Salary Structure 2", "Monthly", dont_submit=True) @@ -233,9 +232,7 @@ def create_salary_structure_assignment( base=None, allow_duplicate=False, ): - if not allow_duplicate and frappe.db.exists( - "Salary Structure Assignment", {"employee": employee} - ): + if not allow_duplicate and frappe.db.exists("Salary Structure Assignment", {"employee": employee}): frappe.db.sql("""delete from `tabSalary Structure Assignment` where employee=%s""", (employee)) if not payroll_period: diff --git a/hrms/payroll/doctype/salary_structure_assignment/salary_structure_assignment.py b/hrms/payroll/doctype/salary_structure_assignment/salary_structure_assignment.py index 9076089c22..4e79771315 100644 --- a/hrms/payroll/doctype/salary_structure_assignment/salary_structure_assignment.py +++ b/hrms/payroll/doctype/salary_structure_assignment/salary_structure_assignment.py @@ -59,7 +59,9 @@ def validate_dates(self): "Salary Structure Assignment", {"employee": self.employee, "from_date": self.from_date, "docstatus": 1}, ): - frappe.throw(_("Salary Structure Assignment for Employee already exists"), DuplicateAssignment) + frappe.throw( + _("Salary Structure Assignment for Employee already exists"), DuplicateAssignment + ) if joining_date and getdate(self.from_date) < joining_date: frappe.throw( @@ -91,9 +93,7 @@ def validate_income_tax_slab(self): if not self.income_tax_slab: return - income_tax_slab_currency = frappe.db.get_value( - "Income Tax Slab", self.income_tax_slab, "currency" - ) + income_tax_slab_currency = frappe.db.get_value("Income Tax Slab", self.income_tax_slab, "currency") if self.currency != income_tax_slab_currency: frappe.throw( _("Currency of selected Income Tax Slab should be {0} instead of {1}").format( @@ -166,9 +166,7 @@ def enabled_settings_to_specify_earnings_and_deductions_till_date(self): def have_salary_slips(self): """returns True if salary structure assignment has salary slips else False""" - salary_slip = frappe.db.get_value( - "Salary Slip", filters={"employee": self.employee, "docstatus": 1} - ) + salary_slip = frappe.db.get_value("Salary Slip", filters={"employee": self.employee, "docstatus": 1}) if salary_slip: return True @@ -210,9 +208,7 @@ def get_assigned_salary_structure(employee, on_date): @frappe.whitelist() def get_employee_currency(employee): - employee_currency = frappe.db.get_value( - "Salary Structure Assignment", {"employee": employee}, "currency" - ) + employee_currency = frappe.db.get_value("Salary Structure Assignment", {"employee": employee}, "currency") if not employee_currency: frappe.throw( _("There is no Salary Structure assigned to {0}. First assign a Salary Stucture.").format( diff --git a/hrms/payroll/report/bank_remittance/bank_remittance.py b/hrms/payroll/report/bank_remittance/bank_remittance.py index dbcb6d6501..a571d6385b 100644 --- a/hrms/payroll/report/bank_remittance/bank_remittance.py +++ b/hrms/payroll/report/bank_remittance/bank_remittance.py @@ -45,9 +45,7 @@ def execute(filters=None): ] if frappe.db.has_column("Employee", "ifsc_code"): - columns.append( - {"label": _("IFSC Code"), "fieldtype": "Data", "fieldname": "bank_code", "width": 100} - ) + columns.append({"label": _("IFSC Code"), "fieldtype": "Data", "fieldname": "bank_code", "width": 100}) columns += [ {"label": _("Currency"), "fieldtype": "Data", "fieldname": "currency", "width": 50}, diff --git a/hrms/payroll/report/income_tax_computation/income_tax_computation.py b/hrms/payroll/report/income_tax_computation/income_tax_computation.py index 2bbce0385f..4cd6d3bdb7 100644 --- a/hrms/payroll/report/income_tax_computation/income_tax_computation.py +++ b/hrms/payroll/report/income_tax_computation/income_tax_computation.py @@ -14,7 +14,7 @@ def execute(filters=None): return IncomeTaxComputationReport(filters).run() -class IncomeTaxComputationReport(object): +class IncomeTaxComputationReport: def __init__(self, filters=None): self.filters = frappe._dict(filters or {}) self.columns = [] @@ -220,9 +220,7 @@ def get_tax_exempted_earnings_and_deductions(self): existing_ss_exemptions = frappe._dict() for d in records: - existing_ss_exemptions.setdefault(d.employee, {}).setdefault( - scrub(d.salary_component), d.amount - ) + existing_ss_exemptions.setdefault(d.employee, {}).setdefault(scrub(d.salary_component), d.amount) for employee in list(self.employees.keys()): if not self.employees[employee]["allow_tax_exemption"]: diff --git a/hrms/payroll/report/income_tax_computation/test_income_tax_computation.py b/hrms/payroll/report/income_tax_computation/test_income_tax_computation.py index d423861f3c..da1cd764b3 100644 --- a/hrms/payroll/report/income_tax_computation/test_income_tax_computation.py +++ b/hrms/payroll/report/income_tax_computation/test_income_tax_computation.py @@ -41,9 +41,7 @@ def create_records(self): date_of_joining=getdate("01-10-2021"), ) - self.payroll_period = create_payroll_period( - name="_Test Payroll Period 1", company="_Test Company" - ) + self.payroll_period = create_payroll_period(name="_Test Payroll Period 1", company="_Test Company") self.income_tax_slab = create_tax_slab( self.payroll_period, diff --git a/hrms/payroll/report/income_tax_deductions/income_tax_deductions.py b/hrms/payroll/report/income_tax_deductions/income_tax_deductions.py index d946601628..c8ca5b39d0 100644 --- a/hrms/payroll/report/income_tax_deductions/income_tax_deductions.py +++ b/hrms/payroll/report/income_tax_deductions/income_tax_deductions.py @@ -93,9 +93,7 @@ def get_data(filters: Filters, is_indian_company: bool) -> list[dict]: def get_income_tax_deductions(filters: Filters) -> list[dict]: - component_types = frappe.get_all( - "Salary Component", filters={"is_income_tax_component": 1}, pluck="name" - ) + component_types = frappe.get_all("Salary Component", filters={"is_income_tax_component": 1}, pluck="name") if not component_types: return [] diff --git a/hrms/payroll/report/income_tax_deductions/test_income_tax_deductions.py b/hrms/payroll/report/income_tax_deductions/test_income_tax_deductions.py index 2e3545b550..d1cb70a89c 100644 --- a/hrms/payroll/report/income_tax_deductions/test_income_tax_deductions.py +++ b/hrms/payroll/report/income_tax_deductions/test_income_tax_deductions.py @@ -35,9 +35,7 @@ def create_records(cls): date_of_joining=getdate("01-10-2021"), ) - cls.payroll_period = create_payroll_period( - name="_Test Payroll Period 1", company="_Test Company" - ) + cls.payroll_period = create_payroll_period(name="_Test Payroll Period 1", company="_Test Company") salary_structure = make_salary_structure( "Monthly Salary Structure Test Income Tax Deduction", "Monthly", @@ -48,9 +46,7 @@ def create_records(cls): test_tax=True, ) - create_salary_slips_for_payroll_period( - cls.employee, salary_structure.name, cls.payroll_period, num=1 - ) + create_salary_slips_for_payroll_period(cls.employee, salary_structure.name, cls.payroll_period, num=1) def test_report(self): filters = frappe._dict({"company": "_Test Company"}) diff --git a/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py b/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py index 974a9ad55a..95dfb99937 100644 --- a/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py +++ b/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py @@ -36,7 +36,6 @@ def get_columns(filters): def get_data(filters): - data = [] component_type_dict = frappe._dict( @@ -66,7 +65,6 @@ def get_data(filters): ) for d in entry: - employee = {"employee": d.employee, "employee_name": d.employee_name, "amount": d.amount} data.append(employee) diff --git a/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.py b/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.py index 0cc78a6b78..6815a801a8 100644 --- a/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.py +++ b/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.py @@ -75,7 +75,6 @@ def prepare_data(entry, component_type_dict): ) for d in entry: - component_type = component_type_dict.get(d.salary_component) if data_list.get(d.name): diff --git a/hrms/payroll/report/salary_payments_based_on_payment_mode/salary_payments_based_on_payment_mode.py b/hrms/payroll/report/salary_payments_based_on_payment_mode/salary_payments_based_on_payment_mode.py index 8a001181f8..33c3b53cf3 100644 --- a/hrms/payroll/report/salary_payments_based_on_payment_mode/salary_payments_based_on_payment_mode.py +++ b/hrms/payroll/report/salary_payments_based_on_payment_mode/salary_payments_based_on_payment_mode.py @@ -117,15 +117,12 @@ def get_data(filters, mode_of_payments): data.append({"branch": "Total Net Pay", mode_of_payments[0]: total_row.get("total")}) currency = erpnext.get_company_currency(filters.company) - report_summary = get_report_summary( - gross_pay, total_deductions, total_row.get("total"), currency - ) + report_summary = get_report_summary(gross_pay, total_deductions, total_row.get("total"), currency) return data, total_row, report_summary def get_total_based_on_mode_of_payment(data, mode_of_payments): - total = 0 total_row = {"branch": "Total"} for mode in mode_of_payments: @@ -172,8 +169,6 @@ def get_chart(mode_of_payments, data): values.append(data[mode]) labels.append([mode]) - chart = { - "data": {"labels": labels, "datasets": [{"name": "Mode Of Payments", "values": values}]} - } + chart = {"data": {"labels": labels, "datasets": [{"name": "Mode Of Payments", "values": values}]}} chart["type"] = "bar" return chart diff --git a/hrms/payroll/report/salary_payments_via_ecs/salary_payments_via_ecs.py b/hrms/payroll/report/salary_payments_via_ecs/salary_payments_via_ecs.py index 4f9370b742..46fdacf152 100644 --- a/hrms/payroll/report/salary_payments_via_ecs/salary_payments_via_ecs.py +++ b/hrms/payroll/report/salary_payments_via_ecs/salary_payments_via_ecs.py @@ -79,7 +79,6 @@ def get_conditions(filters): def get_data(filters): - data = [] fields = ["employee", "branch", "bank_name", "bank_ac_no", "salary_mode"] @@ -113,7 +112,6 @@ def get_data(filters): ) for d in entry: - employee = { "branch": employee_data_dict.get(d.employee).get("branch"), "employee_name": d.employee_name, diff --git a/hrms/payroll/report/salary_register/salary_register.py b/hrms/payroll/report/salary_register/salary_register.py index 398269a71c..b2bf16fdab 100644 --- a/hrms/payroll/report/salary_register/salary_register.py +++ b/hrms/payroll/report/salary_register/salary_register.py @@ -87,9 +87,7 @@ def get_earning_and_deduction_types(salary_slips): component_type = get_salary_component_type(salary_compoent) salary_component_and_type[_(component_type)].append(salary_compoent) - return sorted(salary_component_and_type[_("Earning")]), sorted( - salary_component_and_type[_("Deduction")] - ) + return sorted(salary_component_and_type[_("Earning")]), sorted(salary_component_and_type[_("Deduction")]) def update_column_width(ss, columns): diff --git a/hrms/regional/india/utils.py b/hrms/regional/india/utils.py index 4797225e24..70998aadf8 100644 --- a/hrms/regional/india/utils.py +++ b/hrms/regional/india/utils.py @@ -26,9 +26,7 @@ def calculate_annual_eligible_hra_exemption(doc): assignments = get_salary_assignments(doc.employee, doc.payroll_period) if not assignments and doc.docstatus == 1: - frappe.throw( - _("Salary Structure must be submitted before submission of {0}").format(doc.doctype) - ) + frappe.throw(_("Salary Structure must be submitted before submission of {0}").format(doc.doctype)) period_start_date = frappe.db.get_value("Payroll Period", doc.payroll_period, "start_date") @@ -105,9 +103,7 @@ def get_end_date_for_assignment(assignment_dates, idx, payroll_period): return end_date -def get_component_amt_from_salary_slip( - employee, salary_structure, basic_component, hra_component, from_date -): +def get_component_amt_from_salary_slip(employee, salary_structure, basic_component, hra_component, from_date): salary_slip = make_salary_slip( salary_structure, employee=employee, diff --git a/hrms/tests/test_utils.py b/hrms/tests/test_utils.py index bf2e7aa844..8658c32c5b 100644 --- a/hrms/tests/test_utils.py +++ b/hrms/tests/test_utils.py @@ -41,14 +41,10 @@ def set_defaults(): from hrms.payroll.doctype.salary_slip.test_salary_slip import make_holiday_list make_holiday_list("Salary Slip Test Holiday List") - frappe.db.set_value( - "Company", "_Test Company", "default_holiday_list", "Salary Slip Test Holiday List" - ) + frappe.db.set_value("Company", "_Test Company", "default_holiday_list", "Salary Slip Test Holiday List") -def get_first_sunday( - holiday_list="Salary Slip Test Holiday List", for_date=None, find_after_for_date=False -): +def get_first_sunday(holiday_list="Salary Slip Test Holiday List", for_date=None, find_after_for_date=False): date = for_date or getdate() month_start_date = get_first_day(date) diff --git a/hrms/utils/__init__.py b/hrms/utils/__init__.py index ae98b764a3..c0d68f48ad 100644 --- a/hrms/utils/__init__.py +++ b/hrms/utils/__init__.py @@ -36,9 +36,7 @@ def get_date_range(start_date: str, end_date: str) -> list[str]: return [add_days(start_date, i) for i in range(no_of_days)] -def generate_date_range( - start_date: str, end_date: str, reverse: bool = False -) -> Generator[str, None, None]: +def generate_date_range(start_date: str, end_date: str, reverse: bool = False) -> Generator[str, None, None]: no_of_days = date_diff(end_date, start_date) + 1 date_field = end_date if reverse else start_date From 070b45798724dd7b45391a1dbc2fce5d503562df Mon Sep 17 00:00:00 2001 From: krantheman Date: Wed, 24 Apr 2024 15:13:34 +0530 Subject: [PATCH 10/20] chore: ignore formatting commits --- .git-blame-ignore-revs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 5f7965ba0b..219872879c 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -15,4 +15,10 @@ 76c895a6c659356151433715a1efe9337e348c11 # bulk formatting -b55d6e27af6bd274dfa47e66a3012ddec68ce798 \ No newline at end of file +b55d6e27af6bd274dfa47e66a3012ddec68ce798 + +# js, scss prettier formatting +4a224b988a254a053e9c49cd101cd67d433aed90 + +# python ruff formatting +7b0d00220047545d3d18650235dac9cebe0d2bca \ No newline at end of file From 8141c89985021da9982d87d6378246af359ef4c7 Mon Sep 17 00:00:00 2001 From: krantheman Date: Wed, 24 Apr 2024 15:24:01 +0530 Subject: [PATCH 11/20] fix: ruff linting issues --- hrms/hr/doctype/goal/goal.py | 2 +- hrms/hr/doctype/job_offer/test_job_offer.py | 4 ++-- hrms/hr/doctype/staffing_plan/test_staffing_plan.py | 2 +- hrms/hr/report/appraisal_overview/appraisal_overview.py | 6 +++--- hrms/overrides/company.py | 4 ++-- hrms/setup.py | 9 +++++---- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/hrms/hr/doctype/goal/goal.py b/hrms/hr/doctype/goal/goal.py index dea62be1c7..0b36178205 100644 --- a/hrms/hr/doctype/goal/goal.py +++ b/hrms/hr/doctype/goal/goal.py @@ -94,7 +94,7 @@ def update_kra_in_child_goals(self, doc_before_save): """Aligns children's KRA to parent goal's KRA if parent goal's KRA is changed""" if doc_before_save.kra != self.kra and self.is_group: Goal = frappe.qb.DocType("Goal") - (frappe.qb.update(Goal).set(Goal.kra, self.kra).where((Goal.parent_goal == self.name))).run() + (frappe.qb.update(Goal).set(Goal.kra, self.kra).where(Goal.parent_goal == self.name)).run() frappe.msgprint(_("KRA updated for all child goals."), alert=True, indicator="green") diff --git a/hrms/hr/doctype/job_offer/test_job_offer.py b/hrms/hr/doctype/job_offer/test_job_offer.py index 497d66a41a..3ab75ccc62 100644 --- a/hrms/hr/doctype/job_offer/test_job_offer.py +++ b/hrms/hr/doctype/job_offer/test_job_offer.py @@ -51,7 +51,7 @@ def test_job_applicant_update(self): job_offer.status = "Rejected" job_offer.submit() job_applicant.reload() - self.assertEquals(job_applicant.status, "Rejected") + self.assertEqual(job_applicant.status, "Rejected") frappe.db.set_value("HR Settings", None, "check_vacancies", 1) def test_recruitment_metrics(self): @@ -76,7 +76,7 @@ def create_job_offer(**args): job_applicant = create_job_applicant() if not frappe.db.exists("Designation", args.designation): - designation = create_designation(designation_name=args.designation) + create_designation(designation_name=args.designation) job_offer = frappe.get_doc( { diff --git a/hrms/hr/doctype/staffing_plan/test_staffing_plan.py b/hrms/hr/doctype/staffing_plan/test_staffing_plan.py index 7611a683cf..966163f198 100644 --- a/hrms/hr/doctype/staffing_plan/test_staffing_plan.py +++ b/hrms/hr/doctype/staffing_plan/test_staffing_plan.py @@ -77,7 +77,7 @@ def test_staffing_plan_parent_company(self): def _set_up(): for doctype in ["Staffing Plan", "Staffing Plan Detail"]: - frappe.db.sql("delete from `tab{doctype}`".format(doctype=doctype)) + frappe.db.sql(f"delete from `tab{doctype}`") make_company() diff --git a/hrms/hr/report/appraisal_overview/appraisal_overview.py b/hrms/hr/report/appraisal_overview/appraisal_overview.py index 55fbd26182..db29196ac5 100644 --- a/hrms/hr/report/appraisal_overview/appraisal_overview.py +++ b/hrms/hr/report/appraisal_overview/appraisal_overview.py @@ -5,7 +5,7 @@ from frappe import _ -def execute(filters: dict = None) -> tuple: +def execute(filters: dict | None = None) -> tuple: filters = frappe._dict(filters or {}) columns = get_columns() data = get_data(filters) @@ -65,7 +65,7 @@ def get_columns() -> list[dict]: ] -def get_data(filters: dict = None) -> list[dict]: +def get_data(filters: dict | None = None) -> list[dict]: Appraisal = frappe.qb.DocType("Appraisal") query = ( frappe.qb.from_(Appraisal) @@ -86,7 +86,7 @@ def get_data(filters: dict = None) -> list[dict]: for condition in ["appraisal_cycle", "employee", "department", "designation", "company"]: if filters.get(condition): - query = query.where((Appraisal[condition] == filters.get(condition))) + query = query.where(Appraisal[condition] == filters.get(condition)) query = query.orderby(Appraisal.appraisal_cycle) query = query.orderby(Appraisal.final_score, order=frappe.qb.desc) diff --git a/hrms/overrides/company.py b/hrms/overrides/company.py index 59b31c98c6..e5547dce65 100644 --- a/hrms/overrides/company.py +++ b/hrms/overrides/company.py @@ -91,9 +91,9 @@ def make_salary_components(country): def read_data_file(file_path): try: - with open(file_path, "r") as f: + with open(file_path) as f: return f.read() - except IOError: + except OSError: return "{}" diff --git a/hrms/setup.py b/hrms/setup.py index 350ef5eeab..6aadb9d43c 100644 --- a/hrms/setup.py +++ b/hrms/setup.py @@ -1,14 +1,15 @@ -import frappe import os + import click -from frappe import _ +import frappe +from frappe import _ from frappe.custom.doctype.custom_field.custom_field import create_custom_fields from frappe.desk.page.setup_wizard.setup_wizard import make_records from frappe.installer import update_site_config -from hrms.subscription_utils import update_erpnext_access from hrms.overrides.company import delete_company_fixtures +from hrms.subscription_utils import update_erpnext_access def after_install(): @@ -512,7 +513,7 @@ def add_non_standard_user_types(): user_types = get_user_types_data() user_type_limit = {} - for user_type, data in user_types.items(): + for user_type, __ in user_types.items(): user_type_limit.setdefault(frappe.scrub(user_type), 30) update_site_config("user_type_doctype_limit", user_type_limit) From 7b2685da846c6beb1a8d85a5355d642ff43d4478 Mon Sep 17 00:00:00 2001 From: krantheman Date: Mon, 15 Apr 2024 18:12:05 +0530 Subject: [PATCH 12/20] fix: ruff linting issues (cherry picked from commit 5485e66172d3f7e7f133d645858eb5a6c210140b) (cherry picked from commit c1f6cf51ed2c2471b3fc9e927225f64dd07c8ed1) --- .../tests/test_employee_reminders.py | 2 +- hrms/hr/doctype/appraisal/test_appraisal.py | 20 ++++++++----- .../test_compensatory_leave_request.py | 5 +++- .../employee_attendance_tool.py | 15 ++++++---- .../employee_checkin/employee_checkin.py | 4 ++- .../employee_checkin/test_employee_checkin.py | 5 +++- .../employee_onboarding.py | 6 ++-- .../employee_separation.py | 6 ++-- hrms/hr/doctype/goal/test_goal.py | 12 +++++--- hrms/hr/doctype/interview/interview.py | 12 ++++++-- hrms/hr/doctype/interview/test_interview.py | 6 ++-- hrms/hr/doctype/job_opening/job_opening.py | 2 -- .../leave_allocation/test_earned_leaves.py | 2 +- .../leave_allocation/test_leave_allocation.py | 8 ++--- .../leave_application/leave_application.py | 1 - .../test_leave_application.py | 9 +++--- .../leave_encashment/test_leave_encashment.py | 6 ++-- .../shift_assignment/shift_assignment.py | 12 ++++---- .../shift_assignment/test_shift_assignment.py | 2 +- hrms/hr/doctype/shift_type/test_shift_type.py | 30 +++++++++++-------- .../test_organizational_chart.py | 2 +- ...ee_hours_utilization_based_on_timesheet.py | 4 +-- .../employee_leave_balance_summary.py | 1 - .../monthly_attendance_sheet.py | 5 ++-- hrms/hr/utils.py | 2 +- hrms/overrides/employee_payment_entry.py | 1 - .../set_department_for_doctypes.py | 9 +++--- ...test_employee_tax_exemption_declaration.py | 4 +-- .../payroll_entry/test_payroll_entry.py | 2 +- .../doctype/salary_slip/salary_slip.py | 2 +- .../doctype/salary_slip/test_salary_slip.py | 9 +++--- .../salary_structure/salary_structure.py | 13 ++++---- .../salary_structure/test_salary_structure.py | 10 +++++-- .../income_tax_computation.py | 4 +-- .../professional_tax_deductions.py | 18 +++++------ .../provident_fund_deductions.py | 8 ++--- 36 files changed, 144 insertions(+), 115 deletions(-) diff --git a/hrms/controllers/tests/test_employee_reminders.py b/hrms/controllers/tests/test_employee_reminders.py index dcf9ba5ec2..0e1ed9456a 100644 --- a/hrms/controllers/tests/test_employee_reminders.py +++ b/hrms/controllers/tests/test_employee_reminders.py @@ -129,7 +129,7 @@ def test_work_anniversary_reminders(self): send_work_anniversary_reminders, ) - emp = make_employee( + make_employee( "test_emp_work_anniversary@gmail.com", company="_Test Company", date_of_joining=frappe.utils.add_years(getdate(), -2), diff --git a/hrms/hr/doctype/appraisal/test_appraisal.py b/hrms/hr/doctype/appraisal/test_appraisal.py index 216e77a26d..029b6c52bd 100644 --- a/hrms/hr/doctype/appraisal/test_appraisal.py +++ b/hrms/hr/doctype/appraisal/test_appraisal.py @@ -115,12 +115,16 @@ def test_goal_score(self): parent1 = create_goal(self.employee1, "Quality", 1, appraisal_cycle=cycle.name) child1 = create_goal(self.employee1, is_group=1, parent_goal=parent1.name) - child1_1 = create_goal(self.employee1, parent_goal=child1.name, progress=25) - child1_2 = create_goal(self.employee1, parent_goal=child1.name) + # child1_1 + create_goal(self.employee1, parent_goal=child1.name, progress=25) + # child1_1 + create_goal(self.employee1, parent_goal=child1.name) parent2 = create_goal(self.employee1, "Development", 1, appraisal_cycle=cycle.name) - child2_1 = create_goal(self.employee1, parent_goal=parent2.name, progress=100) - child2_2 = create_goal(self.employee1, parent_goal=parent2.name) + # child2_1 + create_goal(self.employee1, parent_goal=parent2.name, progress=100) + # child2_2 + create_goal(self.employee1, parent_goal=parent2.name) appraisal = frappe.db.exists("Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1}) appraisal = frappe.get_doc("Appraisal", appraisal) @@ -159,11 +163,13 @@ def test_goal_score_after_parent_goal_change(self): cycle.create_appraisals() parent1 = create_goal(self.employee1, "Quality", 1, appraisal_cycle=cycle.name) - child1 = create_goal(self.employee1, parent_goal=parent1.name, progress=50) + # child1 + create_goal(self.employee1, parent_goal=parent1.name, progress=50) parent2 = create_goal(self.employee1, "Development", 1, appraisal_cycle=cycle.name) child2_1 = create_goal(self.employee1, parent_goal=parent2.name, progress=50) - child2_2 = create_goal(self.employee1, parent_goal=parent2.name) + # child2_2 + create_goal(self.employee1, parent_goal=parent2.name) appraisal = frappe.db.exists("Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1}) appraisal = frappe.get_doc("Appraisal", appraisal) @@ -280,7 +286,7 @@ def test_cycle_summary(self): appraisal = frappe.db.exists("Appraisal", {"appraisal_cycle": cycle.name, "employee": self.employee1}) appraisal = frappe.get_doc("Appraisal", appraisal) - goal = create_goal(self.employee1, "Quality", appraisal_cycle=cycle.name) + create_goal(self.employee1, "Quality", appraisal_cycle=cycle.name) feedback = create_performance_feedback( self.employee1, employee2, diff --git a/hrms/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py b/hrms/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py index 22c6e2f1dc..c05393a000 100644 --- a/hrms/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py +++ b/hrms/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py @@ -156,7 +156,10 @@ def test_request_on_leave_period_boundary(self): compensatory_leave_request.submit() -def get_compensatory_leave_request(employee, leave_date=today()): +def get_compensatory_leave_request(employee, leave_date=None): + if not leave_date: + leave_date = today() + prev_comp_leave_req = frappe.db.get_value( "Compensatory Leave Request", dict( diff --git a/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.py b/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.py index 12047787b7..04f3accaa7 100644 --- a/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.py +++ b/hrms/hr/doctype/employee_attendance_tool/employee_attendance_tool.py @@ -16,7 +16,10 @@ class EmployeeAttendanceTool(Document): @frappe.whitelist() def get_employees( - date: str | datetime.date, department: str = None, branch: str = None, company: str = None + date: str | datetime.date, + department: str | None = None, + branch: str | None = None, + company: str | None = None, ) -> dict[str, list]: filters = {"status": "Active", "date_of_joining": ["<=", date]} @@ -58,11 +61,11 @@ def mark_employee_attendance( employee_list: list | str, status: str, date: str | datetime.date, - leave_type: str = None, - company: str = None, - late_entry: int = None, - early_exit: int = None, - shift: str = None, + leave_type: str | None = None, + company: str | None = None, + late_entry: int | None = None, + early_exit: int | None = None, + shift: str | None = None, ) -> None: if isinstance(employee_list, str): employee_list = json.loads(employee_list) diff --git a/hrms/hr/doctype/employee_checkin/employee_checkin.py b/hrms/hr/doctype/employee_checkin/employee_checkin.py index 2027ac4b9d..8524b6ef6a 100644 --- a/hrms/hr/doctype/employee_checkin/employee_checkin.py +++ b/hrms/hr/doctype/employee_checkin/employee_checkin.py @@ -246,7 +246,9 @@ def handle_attendance_exception(log_names: list, error_message: str): def add_comment_in_checkins(log_names: list, error_message: str): - text = "{0}
{1}".format(frappe.bold(_("Reason for skipping auto attendance:")), error_message) + text = "{prefix}
{error_message}".format( + prefix=frappe.bold(_("Reason for skipping auto attendance:")), error_message=error_message + ) for name in log_names: frappe.get_doc( diff --git a/hrms/hr/doctype/employee_checkin/test_employee_checkin.py b/hrms/hr/doctype/employee_checkin/test_employee_checkin.py index c25a30bed7..aa37b1d88e 100644 --- a/hrms/hr/doctype/employee_checkin/test_employee_checkin.py +++ b/hrms/hr/doctype/employee_checkin/test_employee_checkin.py @@ -465,7 +465,10 @@ def make_n_checkins(employee, n, hours_to_reverse=1): return logs -def make_checkin(employee, time=now_datetime()): +def make_checkin(employee, time=None): + if not time: + time = now_datetime() + log = frappe.get_doc( { "doctype": "Employee Checkin", diff --git a/hrms/hr/doctype/employee_onboarding/employee_onboarding.py b/hrms/hr/doctype/employee_onboarding/employee_onboarding.py index fa1a257227..6f489a85d0 100644 --- a/hrms/hr/doctype/employee_onboarding/employee_onboarding.py +++ b/hrms/hr/doctype/employee_onboarding/employee_onboarding.py @@ -15,7 +15,7 @@ class IncompleteTaskError(frappe.ValidationError): class EmployeeOnboarding(EmployeeBoardingController): def validate(self): - super(EmployeeOnboarding, self).validate() + super().validate() self.set_employee() self.validate_duplicate_employee_onboarding() @@ -50,13 +50,13 @@ def validate_employee_creation(self): ) def on_submit(self): - super(EmployeeOnboarding, self).on_submit() + super().on_submit() def on_update_after_submit(self): self.create_task_and_notify_user() def on_cancel(self): - super(EmployeeOnboarding, self).on_cancel() + super().on_cancel() @frappe.whitelist() def mark_onboarding_as_completed(self): diff --git a/hrms/hr/doctype/employee_separation/employee_separation.py b/hrms/hr/doctype/employee_separation/employee_separation.py index 6ecfb84c07..6f5bc3ac54 100644 --- a/hrms/hr/doctype/employee_separation/employee_separation.py +++ b/hrms/hr/doctype/employee_separation/employee_separation.py @@ -7,13 +7,13 @@ class EmployeeSeparation(EmployeeBoardingController): def validate(self): - super(EmployeeSeparation, self).validate() + super().validate() def on_submit(self): - super(EmployeeSeparation, self).on_submit() + super().on_submit() def on_update_after_submit(self): self.create_task_and_notify_user() def on_cancel(self): - super(EmployeeSeparation, self).on_cancel() + super().on_cancel() diff --git a/hrms/hr/doctype/goal/test_goal.py b/hrms/hr/doctype/goal/test_goal.py index 1aa8a1d5ce..9d0ad2989c 100644 --- a/hrms/hr/doctype/goal/test_goal.py +++ b/hrms/hr/doctype/goal/test_goal.py @@ -84,11 +84,13 @@ def test_update_parent_progress_with_nested_goals(self): |_ child4 """ parent_goal = create_goal(self.employee1, "Development", 1) - child_goal1 = create_goal(self.employee1, parent_goal=parent_goal.name) + # child_goal1 + create_goal(self.employee1, parent_goal=parent_goal.name) child_goal2 = create_goal(self.employee1, "Development", 1, parent_goal.name) child_goal3 = create_goal(self.employee1, parent_goal=child_goal2.name) - child_goal4 = create_goal(self.employee1, parent_goal=child_goal2.name) + # child_goal4 + create_goal(self.employee1, parent_goal=child_goal2.name) child_goal3.progress = 50 child_goal3.save() @@ -126,12 +128,14 @@ def test_update_old_parent_progress(self): parent1 = create_goal(self.employee1, "Development", 1) child1 = create_goal(self.employee1, is_group=1, parent_goal=parent1.name) child1_1 = create_goal(self.employee1, parent_goal=child1.name) - child1_2 = create_goal(self.employee1, parent_goal=child1.name) + # child1_2 + create_goal(self.employee1, parent_goal=child1.name) parent2 = create_goal(self.employee1, "Development", 1) child2 = create_goal(self.employee1, is_group=1, parent_goal=parent2.name) child2_1 = create_goal(self.employee1, parent_goal=child2.name) - child2_2 = create_goal(self.employee1, parent_goal=child2.name) + # child2_2 + create_goal(self.employee1, parent_goal=child2.name) child1_1.progress = 25 child1_1.save() diff --git a/hrms/hr/doctype/interview/interview.py b/hrms/hr/doctype/interview/interview.py index 09154afff1..51d352f7c8 100644 --- a/hrms/hr/doctype/interview/interview.py +++ b/hrms/hr/doctype/interview/interview.py @@ -411,8 +411,16 @@ def get_events(start, end, filters=None): color = event_color.get(d.status) interview_data = { - "from": get_datetime("%s %s" % (d.scheduled_on, d.from_time or "00:00:00")), - "to": get_datetime("%s %s" % (d.scheduled_on, d.to_time or "00:00:00")), + "from": get_datetime( + "{scheduled_on} {from_time}".format( + scheduled_on=d.scheduled_on, from_time=d.from_time or "00:00:00" + ) + ), + "to": get_datetime( + "{scheduled_on} {to_time}".format( + scheduled_on=d.scheduled_on, to_time=d.to_time or "00:00:00" + ) + ), "name": d.name, "subject": "\n".join(subject_data), "color": color if color else "#89bcde", diff --git a/hrms/hr/doctype/interview/test_interview.py b/hrms/hr/doctype/interview/test_interview.py index a66bef04ca..dd3bc3ff87 100644 --- a/hrms/hr/doctype/interview/test_interview.py +++ b/hrms/hr/doctype/interview/test_interview.py @@ -62,7 +62,7 @@ def test_notification_for_scheduling(self): job_applicant = create_job_applicant() scheduled_on = datetime.datetime.now() + datetime.timedelta(minutes=10) - interview = create_interview_and_dependencies(job_applicant.name, scheduled_on=scheduled_on) + create_interview_and_dependencies(job_applicant.name, scheduled_on=scheduled_on) frappe.db.delete("Email Queue") @@ -81,7 +81,7 @@ def test_notification_for_feedback_submission(self): job_applicant = create_job_applicant() scheduled_on = add_days(getdate(), -4) - interview = create_interview_and_dependencies( + create_interview_and_dependencies( job_applicant.name, scheduled_on=scheduled_on, status="Under Review" ) @@ -114,7 +114,7 @@ def test_get_interview_details_for_applicant_dashboard(self): def test_job_applicant_status_update_on_interview_submit(self): job_applicant = create_job_applicant() - interview = create_interview_and_dependencies(job_applicant.name, status="Cleared") + create_interview_and_dependencies(job_applicant.name, status="Cleared") update_job_applicant_status({"job_applicant": job_applicant.name, "status": "Accepted"}) job_applicant.reload() diff --git a/hrms/hr/doctype/job_opening/job_opening.py b/hrms/hr/doctype/job_opening/job_opening.py index cb9d85cb45..934dc5a400 100644 --- a/hrms/hr/doctype/job_opening/job_opening.py +++ b/hrms/hr/doctype/job_opening/job_opening.py @@ -42,8 +42,6 @@ def validate_current_vacancies(self): ) if self.staffing_plan and self.planned_vacancies: - staffing_plan_company = frappe.db.get_value("Staffing Plan", self.staffing_plan, "company") - designation_counts = get_designation_counts(self.designation, self.company, self.name) current_count = designation_counts["employee_count"] + designation_counts["job_openings"] diff --git a/hrms/hr/doctype/leave_allocation/test_earned_leaves.py b/hrms/hr/doctype/leave_allocation/test_earned_leaves.py index 5f036b04e6..e4157c86d3 100644 --- a/hrms/hr/doctype/leave_allocation/test_earned_leaves.py +++ b/hrms/hr/doctype/leave_allocation/test_earned_leaves.py @@ -560,6 +560,6 @@ def get_allocated_leaves(assignment): def allocate_earned_leaves_for_months(months): - for i in range(0, months): + for _ in range(0, months): frappe.flags.current_date = add_months(frappe.flags.current_date, 1) allocate_earned_leaves() diff --git a/hrms/hr/doctype/leave_allocation/test_leave_allocation.py b/hrms/hr/doctype/leave_allocation/test_leave_allocation.py index 7a8d960108..1c258df3e0 100644 --- a/hrms/hr/doctype/leave_allocation/test_leave_allocation.py +++ b/hrms/hr/doctype/leave_allocation/test_leave_allocation.py @@ -206,7 +206,7 @@ def test_validation_for_over_allocation_based_on_leave_setup_post_submission(sel self.assertRaises(OverAllocationError, allocation.save) def test_validate_back_dated_allocation_update(self): - leave_type = create_leave_type(leave_type_name="_Test_CF_leave", is_carry_forward=1) + create_leave_type(leave_type_name="_Test_CF_leave", is_carry_forward=1) # initial leave allocation = 15 leave_allocation = create_leave_allocation( @@ -234,7 +234,7 @@ def test_validate_back_dated_allocation_update(self): self.assertRaises(BackDatedAllocationError, leave_allocation.save) def test_carry_forward_calculation(self): - leave_type = create_leave_type( + create_leave_type( leave_type_name="_Test_CF_leave", is_carry_forward=1, maximum_carry_forwarded_leaves=10, @@ -283,7 +283,7 @@ def test_carry_forward_calculation(self): @change_settings("System Settings", {"float_precision": 2}) def test_precision(self): - leave_type = create_leave_type( + create_leave_type( leave_type_name="_Test_CF_leave", is_carry_forward=1, ) @@ -314,7 +314,7 @@ def test_precision(self): self.assertEqual(leave_allocation_1.total_leaves_allocated, 1) def test_carry_forward_leaves_expiry(self): - leave_type = create_leave_type( + create_leave_type( leave_type_name="_Test_CF_leave_expiry", is_carry_forward=1, expire_carry_forwarded_leaves_after_days=90, diff --git a/hrms/hr/doctype/leave_application/leave_application.py b/hrms/hr/doctype/leave_application/leave_application.py index 53890393d8..16341090b3 100755 --- a/hrms/hr/doctype/leave_application/leave_application.py +++ b/hrms/hr/doctype/leave_application/leave_application.py @@ -2,7 +2,6 @@ # License: GNU General Public License v3. See license.txt import datetime -from typing import Dict, Optional, Tuple, Union import frappe from frappe import _ diff --git a/hrms/hr/doctype/leave_application/test_leave_application.py b/hrms/hr/doctype/leave_application/test_leave_application.py index f15d8381b1..941d65d4f5 100644 --- a/hrms/hr/doctype/leave_application/test_leave_application.py +++ b/hrms/hr/doctype/leave_application/test_leave_application.py @@ -98,7 +98,8 @@ def setUp(self): from_date = get_year_start(getdate()) to_date = get_year_ending(getdate()) self.holiday_list = make_holiday_list(from_date=from_date, to_date=to_date) - list_without_weekly_offs = make_holiday_list( + # list_without_weekly_offs + make_holiday_list( "Holiday List w/o Weekly Offs", from_date=from_date, to_date=to_date, add_weekly_offs=False ) @@ -1050,7 +1051,7 @@ def test_leave_details_with_application_across_cf_expiry(self): ) # leave application across cf expiry - application = make_leave_application( + make_leave_application( employee.name, cf_expiry, add_days(cf_expiry, 3), @@ -1084,7 +1085,7 @@ def test_leave_details_with_application_across_cf_expiry_2(self): ) # leave application across cf expiry, 20 days leave - application = make_leave_application( + make_leave_application( employee.name, add_days(cf_expiry, -16), add_days(cf_expiry, 3), @@ -1126,7 +1127,7 @@ def test_leave_details_with_application_after_cf_expiry(self): ) # leave application after cf expiry - application = make_leave_application( + make_leave_application( employee.name, add_days(cf_expiry, 1), add_days(cf_expiry, 4), diff --git a/hrms/hr/doctype/leave_encashment/test_leave_encashment.py b/hrms/hr/doctype/leave_encashment/test_leave_encashment.py index 76dd62ec5d..9c0cce3514 100644 --- a/hrms/hr/doctype/leave_encashment/test_leave_encashment.py +++ b/hrms/hr/doctype/leave_encashment/test_leave_encashment.py @@ -55,11 +55,9 @@ def setUp(self): "leave_period": self.leave_period.name, } - leave_policy_assignments = create_assignment_for_multiple_employees( - [self.employee], frappe._dict(data) - ) + create_assignment_for_multiple_employees([self.employee], frappe._dict(data)) - salary_structure = make_salary_structure( + make_salary_structure( "Salary Structure for Encashment", "Monthly", self.employee, diff --git a/hrms/hr/doctype/shift_assignment/shift_assignment.py b/hrms/hr/doctype/shift_assignment/shift_assignment.py index 50f80125de..f6b2d34f5f 100644 --- a/hrms/hr/doctype/shift_assignment/shift_assignment.py +++ b/hrms/hr/doctype/shift_assignment/shift_assignment.py @@ -3,7 +3,6 @@ from datetime import datetime, timedelta -from typing import Dict, List import frappe from frappe import _ @@ -155,10 +154,9 @@ def get_events(start, end, filters=None): "Employee", {"user_id": frappe.session.user}, ["name", "company"], as_dict=True ) if employee: - employee, company = employee.name, employee.company + employee = employee.name else: employee = "" - company = frappe.db.get_value("Global Defaults", None, "default_company") assignments = get_shift_assignments(start, end, filters) return get_shift_events(assignments) @@ -393,9 +391,9 @@ def get_shift_for_timestamp(employee: str, for_timestamp: datetime) -> dict: def get_employee_shift( employee: str, - for_timestamp: datetime = None, + for_timestamp: datetime | None = None, consider_default_shift: bool = False, - next_shift_direction: str = None, + next_shift_direction: str | None = None, ) -> dict: """Returns a Shift Type for the given employee on the given date @@ -474,7 +472,7 @@ def get_prev_or_next_shift( def get_employee_shift_timings( - employee: str, for_timestamp: datetime = None, consider_default_shift: bool = False + employee: str, for_timestamp: datetime | None = None, consider_default_shift: bool = False ) -> list[dict]: """Returns previous shift, current/upcoming shift, next_shift for the given timestamp and employee""" if for_timestamp is None: @@ -556,7 +554,7 @@ def get_exact_shift(shifts: list, for_timestamp: datetime) -> dict: ) -def get_shift_details(shift_type_name: str, for_timestamp: datetime = None) -> dict: +def get_shift_details(shift_type_name: str, for_timestamp: datetime | None = None) -> dict: """Returns a Dict containing shift details with the following data: 'shift_type' - Object of DocType Shift Type, 'start_datetime' - datetime of shift start on given timestamp, diff --git a/hrms/hr/doctype/shift_assignment/test_shift_assignment.py b/hrms/hr/doctype/shift_assignment/test_shift_assignment.py index 569cf65c74..2473c728dc 100644 --- a/hrms/hr/doctype/shift_assignment/test_shift_assignment.py +++ b/hrms/hr/doctype/shift_assignment/test_shift_assignment.py @@ -260,7 +260,7 @@ def test_calendar_for_night_shift(self): shift_type = setup_shift_type(shift_type="Shift 1", start_time="08:00:00", end_time="02:00:00") date = getdate() - shift = make_shift_assignment(shift_type.name, employee1, date, date) + make_shift_assignment(shift_type.name, employee1, date, date) events = get_events(start=date, end=date) self.assertEqual(events[0]["start_date"], get_datetime(f"{date} 08:00:00")) diff --git a/hrms/hr/doctype/shift_type/test_shift_type.py b/hrms/hr/doctype/shift_type/test_shift_type.py index 1d3c742782..1932d6c7ca 100644 --- a/hrms/hr/doctype/shift_type/test_shift_type.py +++ b/hrms/hr/doctype/shift_type/test_shift_type.py @@ -60,14 +60,16 @@ def test_mark_attendance_with_different_shift_start_time(self): make_shift_assignment(shift_type.name, employee, date) timestamp = datetime.combine(date, get_time("08:00:00")) - log_in = make_checkin(employee, timestamp) + # log in + make_checkin(employee, timestamp) # change config before adding OUT log shift_type.begin_check_in_before_shift_start_time = 120 shift_type.save() timestamp = datetime.combine(date, get_time("12:00:00")) - log_out = make_checkin(employee, timestamp) + # log out + make_checkin(employee, timestamp) shift_type.process_auto_attendance() @@ -86,10 +88,12 @@ def test_attendance_date_for_different_start_and_actual_start_date(self): make_shift_assignment(shift_type.name, employee, date, date) timestamp = datetime.combine(date, get_time("00:30:00")) - log_in = make_checkin(employee, timestamp) + # log in + make_checkin(employee, timestamp) timestamp = datetime.combine(date, get_time("10:00:00")) - log_out = make_checkin(employee, timestamp) + # log out + make_checkin(employee, timestamp) shift_type.process_auto_attendance() @@ -261,9 +265,9 @@ def test_mark_auto_attendance_on_holiday_enabled(self): # make logs timestamp = datetime.combine(date, get_time("08:00:00")) - log = make_checkin(employee, timestamp) + make_checkin(employee, timestamp) timestamp = datetime.combine(date, get_time("12:00:00")) - log = make_checkin(employee, timestamp) + make_checkin(employee, timestamp) shift_type.process_auto_attendance() @@ -290,9 +294,9 @@ def test_mark_auto_attendance_on_holiday_disabled(self): # make logs timestamp = datetime.combine(date, get_time("08:00:00")) - log = make_checkin(employee, timestamp) + make_checkin(employee, timestamp) timestamp = datetime.combine(date, get_time("12:00:00")) - log = make_checkin(employee, timestamp) + make_checkin(employee, timestamp) shift_type.process_auto_attendance() @@ -387,9 +391,9 @@ def test_do_not_mark_absent_before_shift_actual_end_time(self): # make logs timestamp = datetime.combine(prev_date, get_time("15:00:00")) - log = make_checkin(employee, timestamp) + make_checkin(employee, timestamp) timestamp = datetime.combine(prev_date, get_time("23:30:00")) - log = make_checkin(employee, timestamp) + make_checkin(employee, timestamp) # last sync of checkin is 00:30:00 and the checkin logs are not applicable for attendance yet # so it should not mark the employee as absent either @@ -452,10 +456,12 @@ def test_skip_absent_marking_for_a_fallback_default_shift(self): make_shift_assignment(assigned_shift.name, employee, date) timestamp = datetime.combine(date, get_time("08:00:00")) - log_in = make_checkin(employee, timestamp) + # log in + make_checkin(employee, timestamp) timestamp = datetime.combine(date, get_time("10:00:00")) - log_out = make_checkin(employee, timestamp) + # log out + make_checkin(employee, timestamp) default_shift.process_auto_attendance() attendance = frappe.db.get_value( diff --git a/hrms/hr/page/organizational_chart/test_organizational_chart.py b/hrms/hr/page/organizational_chart/test_organizational_chart.py index db5fa610ca..ba77138f25 100644 --- a/hrms/hr/page/organizational_chart/test_organizational_chart.py +++ b/hrms/hr/page/organizational_chart/test_organizational_chart.py @@ -16,7 +16,7 @@ def setUp(self): frappe.db.delete("Employee", {"company": self.company}) def test_get_children(self): - company = create_company("Test Org Chart").name + create_company("Test Org Chart").name emp1 = make_employee("testemp1@mail.com", company=self.company) emp2 = make_employee("testemp2@mail.com", company=self.company, reports_to=emp1) emp3 = make_employee("testemp3@mail.com", company=self.company, reports_to=emp1) diff --git a/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py b/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py index 151a17f986..a594c3537c 100644 --- a/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py +++ b/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py @@ -156,7 +156,7 @@ def generate_filtered_time_logs(self): def generate_stats_by_employee(self): self.stats_by_employee = frappe._dict() - for emp, hours, is_billable, project in self.filtered_time_logs: + for emp, hours, is_billable, __ in self.filtered_time_logs: self.stats_by_employee.setdefault(emp, frappe._dict()).setdefault("billed_hours", 0.0) self.stats_by_employee[emp].setdefault("non_billed_hours", 0.0) @@ -176,7 +176,7 @@ def set_employee_department_and_name(self): def calculate_utilizations(self): TOTAL_HOURS = flt(self.standard_working_hours * self.day_span, 2) - for emp, data in self.stats_by_employee.items(): + for __, data in self.stats_by_employee.items(): data["total_hours"] = TOTAL_HOURS data["untracked_hours"] = flt(TOTAL_HOURS - data["billed_hours"] - data["non_billed_hours"], 2) diff --git a/hrms/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.py b/hrms/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.py index d9ab8a3bf6..e991571c02 100644 --- a/hrms/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.py +++ b/hrms/hr/report/employee_leave_balance_summary/employee_leave_balance_summary.py @@ -45,7 +45,6 @@ def get_conditions(filters): def get_data(filters, leave_types): - user = frappe.session.user conditions = get_conditions(filters) active_employees = frappe.get_list( diff --git a/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py b/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py index 58c5dfa1ed..0c0beb9d51 100644 --- a/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py +++ b/hrms/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py @@ -4,7 +4,6 @@ from calendar import monthrange from itertools import groupby -from typing import Dict, List, Optional, Tuple import frappe from frappe import _ @@ -613,8 +612,8 @@ def get_chart_data(attendance_map: dict, filters: Filters) -> dict: labels.append(day["label"]) total_absent_on_day = total_leaves_on_day = total_present_on_day = 0 - for employee, attendance_dict in attendance_map.items(): - for shift, attendance in attendance_dict.items(): + for __, attendance_dict in attendance_map.items(): + for __, attendance in attendance_dict.items(): attendance_on_day = attendance.get(cint(day["fieldname"])) if attendance_on_day == "On Leave": diff --git a/hrms/hr/utils.py b/hrms/hr/utils.py index 8c44b4b634..7006a26c25 100644 --- a/hrms/hr/utils.py +++ b/hrms/hr/utils.py @@ -676,7 +676,7 @@ def share_doc_with_approver(doc, user): def validate_active_employee(employee, method=None): - if isinstance(employee, (dict, Document)): + if isinstance(employee, dict | Document): employee = employee.get("employee") if employee and frappe.db.get_value("Employee", employee, "status") == "Inactive": diff --git a/hrms/overrides/employee_payment_entry.py b/hrms/overrides/employee_payment_entry.py index b5567ed372..59bace8da9 100644 --- a/hrms/overrides/employee_payment_entry.py +++ b/hrms/overrides/employee_payment_entry.py @@ -69,7 +69,6 @@ def get_payment_entry_for_employee(dt, dn, party_amount=None, bank_account=None, """Function to make Payment Entry for Employee Advance, Gratuity, Expense Claim""" doc = frappe.get_doc(dt, dn) - party_type = "Employee" party_account = get_party_account(doc) party_account_currency = get_account_currency(party_account) payment_type = "Pay" diff --git a/hrms/patches/post_install/set_department_for_doctypes.py b/hrms/patches/post_install/set_department_for_doctypes.py index 3c3bd63038..2fad765506 100644 --- a/hrms/patches/post_install/set_department_for_doctypes.py +++ b/hrms/patches/post_install/set_department_for_doctypes.py @@ -28,10 +28,9 @@ def execute(): if frappe.db.table_exists(doctype): frappe.reload_doc(module, "doctype", frappe.scrub(doctype)) frappe.db.sql( - """ - update `tab%s` dt + f""" + update `tab{doctype}` dt set department=(select department from `tabEmployee` where name=dt.employee) - where coalesce(`tab%s`.`department`, '') = '' - """ - % doctype + where coalesce(`tab{doctype}`.`department`, '') = '' + """ ) diff --git a/hrms/payroll/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py b/hrms/payroll/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py index e19e16b702..ac6175ae4d 100644 --- a/hrms/payroll/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py +++ b/hrms/payroll/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py @@ -57,7 +57,7 @@ def test_duplicate_category_in_declaration(self): self.assertRaises(frappe.ValidationError, declaration.save) def test_duplicate_entry_for_payroll_period(self): - declaration = frappe.get_doc( + frappe.get_doc( { "doctype": "Employee Tax Exemption Declaration", "employee": frappe.get_value("Employee", {"user_id": "employee@taxexemption.com"}, "name"), @@ -442,7 +442,7 @@ def create_payroll_period(**args): def create_exemption_category(): if not frappe.db.exists("Employee Tax Exemption Category", "_Test Category"): - category = frappe.get_doc( + frappe.get_doc( { "doctype": "Employee Tax Exemption Category", "name": "_Test Category", diff --git a/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py b/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py index c919456132..f8b10b5a49 100644 --- a/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py +++ b/hrms/payroll/doctype/payroll_entry/test_payroll_entry.py @@ -522,7 +522,7 @@ def test_advance_deduction_in_accrual_journal_entry(self): # payroll entry dates = get_start_end_dates("Monthly", nowdate()) - payroll_entry = make_payroll_entry( + make_payroll_entry( start_date=dates.start_date, end_date=dates.end_date, payable_account=company_doc.default_payroll_payable_account, diff --git a/hrms/payroll/doctype/salary_slip/salary_slip.py b/hrms/payroll/doctype/salary_slip/salary_slip.py index b30cb4c338..f5bb12204c 100644 --- a/hrms/payroll/doctype/salary_slip/salary_slip.py +++ b/hrms/payroll/doctype/salary_slip/salary_slip.py @@ -57,7 +57,7 @@ class SalarySlip(TransactionBase): def __init__(self, *args, **kwargs): - super(SalarySlip, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.series = f"Sal Slip/{self.employee}/.#####" self.whitelisted_globals = { "int": int, diff --git a/hrms/payroll/doctype/salary_slip/test_salary_slip.py b/hrms/payroll/doctype/salary_slip/test_salary_slip.py index eaebda7af3..d28dc720d0 100644 --- a/hrms/payroll/doctype/salary_slip/test_salary_slip.py +++ b/hrms/payroll/doctype/salary_slip/test_salary_slip.py @@ -296,7 +296,7 @@ def test_payment_days_based_on_leave_application(self): make_leave_application(emp_id, first_sunday, add_days(first_sunday, 3), "Leave Without Pay") - leave_type_ppl = create_leave_type(leave_type_name="Test Partially Paid Leave", is_ppl=1) + create_leave_type(leave_type_name="Test Partially Paid Leave", is_ppl=1) alloc = create_leave_allocation( employee=emp_id, @@ -993,7 +993,7 @@ def test_tax_for_payroll_period(self): "Salary Structure Assignment", ] for doc in delete_docs: - frappe.db.sql("delete from `tab%s` where employee='%s'" % (doc, employee)) + frappe.db.sql(f"DELETE FROM `tab{doc}` WHERE employee='{employee}'") from hrms.payroll.doctype.salary_structure.test_salary_structure import make_salary_structure @@ -1130,7 +1130,7 @@ def test_tax_for_recurring_additional_salary(self): "Salary Structure Assignment", ] for doc in delete_docs: - frappe.db.sql("delete from `tab%s` where employee='%s'" % (doc, employee)) + frappe.db.sql(f"DELETE FROM `tab{doc}` WHERE employee='{employee}'") from hrms.payroll.doctype.salary_structure.test_salary_structure import make_salary_structure @@ -1318,7 +1318,6 @@ def test_salary_slip_generation_against_opening_entries_in_ssa(self): prev_period = math.ceil(remaining_sub_periods) - annual_tax = 93288 monthly_tax_amount = 7774.0 monthly_earnings = 77800 @@ -2155,7 +2154,7 @@ def make_payroll_period(): ) if not payroll_period: - pp = create_payroll_period(company=company, name=company_based_payroll_period[company]) + create_payroll_period(company=company, name=company_based_payroll_period[company]) def make_holiday_list(list_name=None, from_date=None, to_date=None, add_weekly_offs=True): diff --git a/hrms/payroll/doctype/salary_structure/salary_structure.py b/hrms/payroll/doctype/salary_structure/salary_structure.py index f41091e57d..51dfadae8b 100644 --- a/hrms/payroll/doctype/salary_structure/salary_structure.py +++ b/hrms/payroll/doctype/salary_structure/salary_structure.py @@ -292,13 +292,12 @@ def create_salary_structures_assignment( def get_existing_assignments(employees, salary_structure, from_date): salary_structures_assignments = frappe.db.sql_list( - """ - select distinct employee from `tabSalary Structure Assignment` - where salary_structure=%s and employee in (%s) - and from_date=%s and company= %s and docstatus=1 - """ - % ("%s", ", ".join(["%s"] * len(employees)), "%s", "%s"), - [salary_structure.name] + employees + [from_date] + [salary_structure.company], + f""" + SELECT DISTINCT employee FROM `tabSalary Structure Assignment` + WHERE salary_structure=%s AND employee IN ({", ".join(["%s"] * len(employees))}) + AND from_date=%s AND company=%s AND docstatus=1 + """, + [salary_structure.name, *employees, from_date, salary_structure.company], ) if salary_structures_assignments: frappe.msgprint( diff --git a/hrms/payroll/doctype/salary_structure/test_salary_structure.py b/hrms/payroll/doctype/salary_structure/test_salary_structure.py index abdf86ac26..f251bbaa42 100644 --- a/hrms/payroll/doctype/salary_structure/test_salary_structure.py +++ b/hrms/payroll/doctype/salary_structure/test_salary_structure.py @@ -163,12 +163,15 @@ def make_salary_structure( other_details=None, test_tax=False, company=None, - currency=erpnext.get_default_currency(), + currency=None, payroll_period=None, include_flexi_benefits=False, base=None, allow_duplicate=False, ): + if not currency: + currency = erpnext.get_default_currency() + if frappe.db.exists("Salary Structure", salary_structure): frappe.db.delete("Salary Structure", salary_structure) @@ -227,11 +230,14 @@ def create_salary_structure_assignment( salary_structure, from_date=None, company=None, - currency=erpnext.get_default_currency(), + currency=None, payroll_period=None, base=None, allow_duplicate=False, ): + if not currency: + currency = erpnext.get_default_currency() + if not allow_duplicate and frappe.db.exists("Salary Structure Assignment", {"employee": employee}): frappe.db.sql("""delete from `tabSalary Structure Assignment` where employee=%s""", (employee)) diff --git a/hrms/payroll/report/income_tax_computation/income_tax_computation.py b/hrms/payroll/report/income_tax_computation/income_tax_computation.py index 4cd6d3bdb7..73331ae7a1 100644 --- a/hrms/payroll/report/income_tax_computation/income_tax_computation.py +++ b/hrms/payroll/report/income_tax_computation/income_tax_computation.py @@ -403,7 +403,7 @@ def get_standard_tax_exemption(self): def get_total_taxable_amount(self): self.add_column("Total Taxable Amount") - for emp, emp_details in self.employees.items(): + for __, emp_details in self.employees.items(): emp_details["total_taxable_amount"] = flt(emp_details.get("ctc")) - flt( emp_details.get("total_exemption") ) @@ -483,7 +483,7 @@ def get_total_deducted_tax(self): def get_payable_tax(self): self.add_column("Payable Tax") - for emp, emp_details in self.employees.items(): + for __, emp_details in self.employees.items(): emp_details["payable_tax"] = flt(emp_details.get("applicable_tax")) - flt( emp_details.get("total_tax_deducted") ) diff --git a/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py b/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py index 95dfb99937..f5d9c58ea0 100644 --- a/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py +++ b/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py @@ -51,15 +51,15 @@ def get_data(filters): conditions = get_conditions(filters) entry = frappe.db.sql( - """ select sal.employee, sal.employee_name, ded.salary_component, ded.amount - from `tabSalary Slip` sal, `tabSalary Detail` ded - where sal.name = ded.parent - and ded.parentfield = 'deductions' - and ded.parenttype = 'Salary Slip' - and sal.docstatus = 1 %s - and ded.salary_component in (%s) - """ - % (conditions, ", ".join(["%s"] * len(component_type_dict))), + """SELECT sal.employee, sal.employee_name, ded.salary_component, ded.amount + FROM `tabSalary Slip` sal, `tabSalary Detail` ded + WHERE sal.name = ded.parent + AND ded.parentfield = 'deductions' + AND ded.parenttype = 'Salary Slip' + AND sal.docstatus = 1 %s + AND ded.salary_component IN (%s) + """, + (conditions, ", ".join(["%s"] * len(component_type_dict))), tuple(component_type_dict.keys()), as_dict=1, ) diff --git a/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.py b/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.py index 6815a801a8..aad97d2355 100644 --- a/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.py +++ b/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.py @@ -122,10 +122,10 @@ def get_data(filters): where sal.name = ded.parent and ded.parentfield = 'deductions' and ded.parenttype = 'Salary Slip' - and sal.docstatus = 1 %s - and ded.salary_component in (%s) - """ - % (conditions, ", ".join(["%s"] * len(component_type_dict))), + and sal.docstatus = 1 {} + and ded.salary_component in ({}) + """, + (conditions, ", ".join(["%s"] * len(component_type_dict.keys()))), tuple(component_type_dict.keys()), as_dict=1, ) From aa1cbce5db66e56b835b069738ee06b155509dde Mon Sep 17 00:00:00 2001 From: krantheman Date: Wed, 24 Apr 2024 16:06:49 +0530 Subject: [PATCH 13/20] ci: ignore salary_structure file --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 976fdd96e0..5f2a6b8027 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,16 +21,16 @@ repos: hooks: - id: prettier types_or: [javascript, vue, css, scss] - # Ignore fronetend folder and any files that might contain jinja / bundles + # Ignore any files that might contain jinja / bundles exclude: | (?x)^( - frontend/.*| hrms/public/dist/.*| .*node_modules.*| .*boilerplate.*| hrms/templates/includes/.*| hrms/hr/doctype/employee_promotion/employee_promotion.js| hrms/hr/doctype/employee_transfer/employee_transfer.js| + hrms/payroll/doctype/salary_structure/salary_structure.js| )$ - repo: https://github.com/astral-sh/ruff-pre-commit From f268a10cea2bdb3d9142ebbc162f8450d8a31307 Mon Sep 17 00:00:00 2001 From: krantheman Date: Wed, 24 Apr 2024 16:14:49 +0530 Subject: [PATCH 14/20] fix: more ruff linting issues --- hrms/hr/doctype/interview/test_interview.py | 5 ++++- hrms/hr/utils.py | 1 - .../doctype/payroll_entry/payroll_entry.py | 22 ++++++++----------- .../doctype/salary_slip/test_salary_slip.py | 4 ++-- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/hrms/hr/doctype/interview/test_interview.py b/hrms/hr/doctype/interview/test_interview.py index dd3bc3ff87..9e19de5213 100644 --- a/hrms/hr/doctype/interview/test_interview.py +++ b/hrms/hr/doctype/interview/test_interview.py @@ -163,7 +163,10 @@ def create_interview_and_dependencies( return interview -def create_interview_round(name, skill_set, interviewers=[], designation=None, save=True): +def create_interview_round(name, skill_set, interviewers=None, designation=None, save=True): + if not interviewers: + interviewers = [] + create_skill_set(skill_set) interview_round = frappe.new_doc("Interview Round") interview_round.round_name = name diff --git a/hrms/hr/utils.py b/hrms/hr/utils.py index 7006a26c25..bfe9a34aa9 100644 --- a/hrms/hr/utils.py +++ b/hrms/hr/utils.py @@ -751,7 +751,6 @@ def get_ec_matching_query(bank_account, company, exact_match, from_date=None, to filter_by_date = "" if from_date and to_date: filter_by_date = f"AND posting_date BETWEEN '{from_date}' AND '{to_date}'" - order_by = "posting_date" return f""" SELECT diff --git a/hrms/payroll/doctype/payroll_entry/payroll_entry.py b/hrms/payroll/doctype/payroll_entry/payroll_entry.py index b28cf35af2..0b206759e3 100644 --- a/hrms/payroll/doctype/payroll_entry/payroll_entry.py +++ b/hrms/payroll/doctype/payroll_entry/payroll_entry.py @@ -1012,13 +1012,10 @@ def get_filter_condition(filters): def get_joining_relieving_condition(start_date, end_date): - cond = """ - and ifnull(t1.date_of_joining, '1900-01-01') <= '%(end_date)s' - and ifnull(t1.relieving_date, '2199-12-31') >= '%(start_date)s' - """ % { - "start_date": start_date, - "end_date": end_date, - } + cond = f""" + and ifnull(t1.date_of_joining, '1900-01-01') <= '{end_date}' + and ifnull(t1.relieving_date, '2199-12-31') >= '{start_date}' + """ return cond @@ -1256,12 +1253,11 @@ def get_existing_salary_slips(employees, args): return frappe.db.sql_list( """ select distinct employee from `tabSalary Slip` - where docstatus!= 2 and company = %s and payroll_entry = %s - and start_date >= %s and end_date <= %s - and employee in (%s) - """ - % ("%s", "%s", "%s", "%s", ", ".join(["%s"] * len(employees))), - [args.company, args.payroll_entry, args.start_date, args.end_date] + employees, + where docstatus != 2 and company = {} and payroll_entry = {} + and start_date >= {} and end_date <= {} + and employee in ({}) + """.format("%s", "%s", "%s", "%s", ", ".join(["%s"] * len(employees))), + [args.company, args.payroll_entry, args.start_date, args.end_date, *employees], ) diff --git a/hrms/payroll/doctype/salary_slip/test_salary_slip.py b/hrms/payroll/doctype/salary_slip/test_salary_slip.py index d28dc720d0..32d7b4aa6d 100644 --- a/hrms/payroll/doctype/salary_slip/test_salary_slip.py +++ b/hrms/payroll/doctype/salary_slip/test_salary_slip.py @@ -1178,7 +1178,7 @@ def test_salary_slip_from_timesheet(self): from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet emp = make_employee("test_employee_6@salary.com", company="_Test Company") - salary_structure = make_salary_structure_for_timesheet(emp, "_Test Company") + make_salary_structure_for_timesheet(emp, "_Test Company") timesheet = make_timesheet(emp, simulate=True, is_billable=1) salary_slip = make_salary_slip_from_timesheet(timesheet.name) salary_slip.submit() @@ -1579,7 +1579,7 @@ def test_get_income_tax_slabs(self): tax_slabs = [] salary_structures = [] - for start_date, end_date in [(year_start, mid_year), (mid_year, year_end)]: + for start_date, __ in [(year_start, mid_year), (mid_year, year_end)]: tax_slab = create_tax_slab( payroll_period, allow_tax_exemption=True, From 9773e859bfd572fca2a83726de933ae824c1ea3b Mon Sep 17 00:00:00 2001 From: krantheman Date: Wed, 17 Apr 2024 13:26:52 +0530 Subject: [PATCH 15/20] fix: semgrep errors --- .../hr/doctype/expense_claim/expense_claim.js | 113 +++++++++--------- .../test_leave_application.py | 6 +- hrms/hr/employee_property_update.js | 4 +- .../doctype/payroll_period/payroll_period.py | 2 +- 4 files changed, 62 insertions(+), 63 deletions(-) diff --git a/hrms/hr/doctype/expense_claim/expense_claim.js b/hrms/hr/doctype/expense_claim/expense_claim.js index 29492bb581..789ed5fcb4 100644 --- a/hrms/hr/doctype/expense_claim/expense_claim.js +++ b/hrms/hr/doctype/expense_claim/expense_claim.js @@ -4,64 +4,6 @@ frappe.provide("hrms.hr"); frappe.provide("erpnext.accounts.dimensions"); -frappe.ui.form.on("Expense Claim", { - onload: function (frm) { - erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype); - }, - company: function (frm) { - erpnext.accounts.dimensions.update_dimension(frm, frm.doctype); - var expenses = frm.doc.expenses; - for (var i = 0; i < expenses.length; i++) { - var expense = expenses[i]; - if (!expense.expense_type) { - continue; - } - frappe.call({ - method: "hrms.hr.doctype.expense_claim.expense_claim.get_expense_claim_account_and_cost_center", - args: { - expense_claim_type: expense.expense_type, - company: frm.doc.company, - }, - callback: function (r) { - if (r.message) { - expense.default_account = r.message.account; - expense.cost_center = r.message.cost_center; - } - }, - }); - } - }, -}); - -frappe.ui.form.on("Expense Claim Detail", { - expense_type: function (frm, cdt, cdn) { - var d = locals[cdt][cdn]; - if (!frm.doc.company) { - d.expense_type = ""; - frappe.msgprint(__("Please set the Company")); - this.frm.refresh_fields(); - return; - } - - if (!d.expense_type) { - return; - } - return frappe.call({ - method: "hrms.hr.doctype.expense_claim.expense_claim.get_expense_claim_account_and_cost_center", - args: { - expense_claim_type: d.expense_type, - company: frm.doc.company, - }, - callback: function (r) { - if (r.message) { - d.default_account = r.message.account; - d.cost_center = r.message.cost_center; - } - }, - }); - }, -}); - cur_frm.add_fetch("employee", "company", "company"); cur_frm.add_fetch("employee", "employee_name", "employee_name"); cur_frm.add_fetch("expense_type", "description", "description"); @@ -105,7 +47,7 @@ cur_frm.cscript.refresh = function (doc) { cur_frm.cscript.set_help = function (doc) { cur_frm.set_intro(""); - if (doc.__islocal && !in_list(frappe.user_roles, "HR User")) { + if (doc.__islocal && !frappe.user_roles.includes("HR User")) { cur_frm.set_intro(__("Fill the form and save it")); } }; @@ -211,6 +153,8 @@ frappe.ui.form.on("Expense Claim", { }, onload: function (frm) { + erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype); + if (frm.doc.docstatus == 0) { return frappe.call({ method: "hrms.hr.doctype.leave_application.leave_application.get_mandatory_approval", @@ -307,6 +251,30 @@ frappe.ui.form.on("Expense Claim", { }); }, + company: function (frm) { + erpnext.accounts.dimensions.update_dimension(frm, frm.doctype); + var expenses = frm.doc.expenses; + for (var i = 0; i < expenses.length; i++) { + var expense = expenses[i]; + if (!expense.expense_type) { + continue; + } + frappe.call({ + method: "hrms.hr.doctype.expense_claim.expense_claim.get_expense_claim_account_and_cost_center", + args: { + expense_claim_type: expense.expense_type, + company: frm.doc.company, + }, + callback: function (r) { + if (r.message) { + expense.default_account = r.message.account; + expense.cost_center = r.message.cost_center; + } + }, + }); + } + }, + is_paid: function (frm) { frm.trigger("toggle_fields"); }, @@ -387,6 +355,33 @@ frappe.ui.form.on("Expense Claim", { }); frappe.ui.form.on("Expense Claim Detail", { + expense_type: function (frm, cdt, cdn) { + var d = locals[cdt][cdn]; + if (!frm.doc.company) { + d.expense_type = ""; + frappe.msgprint(__("Please set the Company")); + this.frm.refresh_fields(); + return; + } + + if (!d.expense_type) { + return; + } + return frappe.call({ + method: "hrms.hr.doctype.expense_claim.expense_claim.get_expense_claim_account_and_cost_center", + args: { + expense_claim_type: d.expense_type, + company: frm.doc.company, + }, + callback: function (r) { + if (r.message) { + d.default_account = r.message.account; + d.cost_center = r.message.cost_center; + } + }, + }); + }, + amount: function (frm, cdt, cdn) { var child = locals[cdt][cdn]; frappe.model.set_value(cdt, cdn, "sanctioned_amount", child.amount); diff --git a/hrms/hr/doctype/leave_application/test_leave_application.py b/hrms/hr/doctype/leave_application/test_leave_application.py index 941d65d4f5..9c0aaa291b 100644 --- a/hrms/hr/doctype/leave_application/test_leave_application.py +++ b/hrms/hr/doctype/leave_application/test_leave_application.py @@ -361,7 +361,11 @@ def test_attendance_update_for_exclude_holidays(self): # Case 2: leave type with 'Include holidays within leaves as leaves' disabled frappe.delete_doc_if_exists("Leave Type", "Test Do Not Include Holidays", force=1) leave_type = frappe.get_doc( - dict(leave_type_name="Test Do Not Include Holidays", doctype="Leave Type", include_holiday=False) + { + "leave_type_name": "Test Do Not Include Holidays", + "doctype": "Leave Type", + "include_holiday": False, + } ).insert() date = getdate() diff --git a/hrms/hr/employee_property_update.js b/hrms/hr/employee_property_update.js index cb3e891212..23f182aa97 100644 --- a/hrms/hr/employee_property_update.js +++ b/hrms/hr/employee_property_update.js @@ -82,8 +82,8 @@ frappe.ui.form.on(cur_frm.doctype, { field_label_map[d.fieldname] = __(d.label, null, d.parent) + ` (${d.fieldname})`; if ( - !in_list(exclude_field_types, d.fieldtype) && - !in_list(exclude_fields, d.fieldname) && + !exclude_field_types.includes(d.fieldtype) && + !exclude_fields.includes(d.fieldname) && !d.hidden && !d.read_only ) { diff --git a/hrms/payroll/doctype/payroll_period/payroll_period.py b/hrms/payroll/doctype/payroll_period/payroll_period.py index 9b1054b4c5..62df008093 100644 --- a/hrms/payroll/doctype/payroll_period/payroll_period.py +++ b/hrms/payroll/doctype/payroll_period/payroll_period.py @@ -72,7 +72,7 @@ def get_payroll_period_days(start_date, end_date, employee, company=None): if len(payroll_period) > 0: actual_no_of_days = date_diff(getdate(payroll_period[0][2]), getdate(payroll_period[0][1])) + 1 working_days = actual_no_of_days - if not cint(frappe.db.get_value("Payroll Settings", None, "include_holidays_in_total_working_days")): + if not cint(frappe.db.get_single_value("Payroll Settings", "include_holidays_in_total_working_days")): holidays = get_holiday_dates_for_employee( employee, getdate(payroll_period[0][1]), getdate(payroll_period[0][2]) ) From 9f9eb9b30d761ea06794c4871c7f879bd3f44bb2 Mon Sep 17 00:00:00 2001 From: krantheman Date: Wed, 17 Apr 2024 13:42:44 +0530 Subject: [PATCH 16/20] chore: ignore sql and cur_frm semgrep rules for now --- hrms/hr/doctype/expense_claim/expense_claim.js | 16 ++++++++++++++++ hrms/hr/doctype/interview/interview.py | 1 + .../doctype/leave_allocation/leave_allocation.js | 1 + .../upload_attendance/upload_attendance.js | 1 + .../employee_analytics/employee_analytics.py | 1 + ...loyee_hours_utilization_based_on_timesheet.py | 1 + .../recruitment_analytics.py | 1 + .../unpaid_expense_claim/unpaid_expense_claim.py | 1 + .../report/vehicle_expenses/vehicle_expenses.py | 1 + .../doctype/payroll_entry/payroll_entry.py | 1 + .../doctype/salary_structure/salary_structure.js | 7 ++++--- .../doctype/salary_structure/salary_structure.py | 2 ++ .../professional_tax_deductions.py | 1 + .../provident_fund_deductions.py | 1 + 14 files changed, 33 insertions(+), 3 deletions(-) diff --git a/hrms/hr/doctype/expense_claim/expense_claim.js b/hrms/hr/doctype/expense_claim/expense_claim.js index 789ed5fcb4..964c62c568 100644 --- a/hrms/hr/doctype/expense_claim/expense_claim.js +++ b/hrms/hr/doctype/expense_claim/expense_claim.js @@ -4,11 +4,16 @@ frappe.provide("hrms.hr"); frappe.provide("erpnext.accounts.dimensions"); +// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.add_fetch("employee", "company", "company"); +// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.add_fetch("employee", "employee_name", "employee_name"); +// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.add_fetch("expense_type", "description", "description"); +// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.cscript.refresh = function (doc) { + // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.cscript.set_help(doc); if (!doc.__islocal) { @@ -27,6 +32,7 @@ cur_frm.cscript.refresh = function (doc) { } if (cint(doc.total_amount_reimbursed) > 0 && frappe.model.can_read(entry_doctype)) { + // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.add_custom_button( __("Bank Entries"), function () { @@ -45,17 +51,23 @@ cur_frm.cscript.refresh = function (doc) { } }; +// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.cscript.set_help = function (doc) { + // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.set_intro(""); if (doc.__islocal && !frappe.user_roles.includes("HR User")) { + // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.set_intro(__("Fill the form and save it")); } }; +// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.cscript.validate = function (doc) { + // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.cscript.calculate_total(doc); }; +// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.cscript.calculate_total = function (doc) { doc.total_claimed_amount = 0; doc.total_sanctioned_amount = 0; @@ -65,10 +77,13 @@ cur_frm.cscript.calculate_total = function (doc) { }); }; +// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.cscript.calculate_total_amount = function (doc, cdt, cdn) { + // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.cscript.calculate_total(doc, cdt, cdn); }; +// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.fields_dict["cost_center"].get_query = function (doc) { return { filters: { @@ -388,6 +403,7 @@ frappe.ui.form.on("Expense Claim Detail", { }, sanctioned_amount: function (frm, cdt, cdn) { + // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.cscript.calculate_total(frm.doc, cdt, cdn); frm.trigger("get_taxes"); frm.trigger("calculate_grand_total"); diff --git a/hrms/hr/doctype/interview/interview.py b/hrms/hr/doctype/interview/interview.py index 51d352f7c8..b432ec36f7 100644 --- a/hrms/hr/doctype/interview/interview.py +++ b/hrms/hr/doctype/interview/interview.py @@ -384,6 +384,7 @@ def get_events(start, end, filters=None): conditions = get_event_conditions("Interview", filters) + # nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql interviews = frappe.db.sql( f""" SELECT DISTINCT diff --git a/hrms/hr/doctype/leave_allocation/leave_allocation.js b/hrms/hr/doctype/leave_allocation/leave_allocation.js index 1f11057b22..633a209389 100755 --- a/hrms/hr/doctype/leave_allocation/leave_allocation.js +++ b/hrms/hr/doctype/leave_allocation/leave_allocation.js @@ -1,6 +1,7 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt +// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.add_fetch("employee", "employee_name", "employee_name"); frappe.ui.form.on("Leave Allocation", { diff --git a/hrms/hr/doctype/upload_attendance/upload_attendance.js b/hrms/hr/doctype/upload_attendance/upload_attendance.js index 99ae709947..88593cb31c 100644 --- a/hrms/hr/doctype/upload_attendance/upload_attendance.js +++ b/hrms/hr/doctype/upload_attendance/upload_attendance.js @@ -72,4 +72,5 @@ hrms.hr.AttendanceControlPanel = class AttendanceControlPanel extends frappe.ui. } }; +// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.cscript = new hrms.hr.AttendanceControlPanel({ frm: cur_frm }); diff --git a/hrms/hr/report/employee_analytics/employee_analytics.py b/hrms/hr/report/employee_analytics/employee_analytics.py index 12be156ab9..0fddbc5f42 100644 --- a/hrms/hr/report/employee_analytics/employee_analytics.py +++ b/hrms/hr/report/employee_analytics/employee_analytics.py @@ -48,6 +48,7 @@ def get_conditions(filters): def get_employees(filters): conditions = get_conditions(filters) + # nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql return frappe.db.sql( """select name, employee_name, date_of_birth, branch, department, designation, diff --git a/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py b/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py index a594c3537c..bc140ae351 100644 --- a/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py +++ b/hrms/hr/report/employee_hours_utilization_based_on_timesheet/employee_hours_utilization_based_on_timesheet.py @@ -140,6 +140,7 @@ def generate_filtered_time_logs(self): else: additional_filters += f" AND tt.{field} = {self.filters.get(field)!r}" + # nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql self.filtered_time_logs = frappe.db.sql( f""" SELECT tt.employee AS employee, ttd.hours AS hours, ttd.is_billable AS is_billable, ttd.project AS project diff --git a/hrms/hr/report/recruitment_analytics/recruitment_analytics.py b/hrms/hr/report/recruitment_analytics/recruitment_analytics.py index ae6710fb45..301638e9b6 100644 --- a/hrms/hr/report/recruitment_analytics/recruitment_analytics.py +++ b/hrms/hr/report/recruitment_analytics/recruitment_analytics.py @@ -117,6 +117,7 @@ def get_child_row(jo, jo_ja_map, ja_joff_map): def get_staffing_plan(filters): + # nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql staffing_plan = frappe.db.sql( f""" select diff --git a/hrms/hr/report/unpaid_expense_claim/unpaid_expense_claim.py b/hrms/hr/report/unpaid_expense_claim/unpaid_expense_claim.py index 7289822582..9480088d88 100644 --- a/hrms/hr/report/unpaid_expense_claim/unpaid_expense_claim.py +++ b/hrms/hr/report/unpaid_expense_claim/unpaid_expense_claim.py @@ -29,6 +29,7 @@ def get_unclaimed_expese_claims(filters): if filters.get("employee"): cond = "ec.employee = %(employee)s" + # nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql return frappe.db.sql( f""" select diff --git a/hrms/hr/report/vehicle_expenses/vehicle_expenses.py b/hrms/hr/report/vehicle_expenses/vehicle_expenses.py index 22284bfbac..8fec0140ab 100644 --- a/hrms/hr/report/vehicle_expenses/vehicle_expenses.py +++ b/hrms/hr/report/vehicle_expenses/vehicle_expenses.py @@ -63,6 +63,7 @@ def get_vehicle_log_data(filters): start_date, end_date = get_period_dates(filters) conditions, values = get_conditions(filters) + # nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql data = frappe.db.sql( f""" SELECT diff --git a/hrms/payroll/doctype/payroll_entry/payroll_entry.py b/hrms/payroll/doctype/payroll_entry/payroll_entry.py index 0b206759e3..67abf6731f 100644 --- a/hrms/payroll/doctype/payroll_entry/payroll_entry.py +++ b/hrms/payroll/doctype/payroll_entry/payroll_entry.py @@ -1306,6 +1306,7 @@ def submit_salary_slips_for_employees(payroll_entry, salary_slips, publish_progr @frappe.whitelist() @frappe.validate_and_sanitize_search_inputs def get_payroll_entries_for_jv(doctype, txt, searchfield, start, page_len, filters): + # nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql return frappe.db.sql( f""" select name from `tabPayroll Entry` diff --git a/hrms/payroll/doctype/salary_structure/salary_structure.js b/hrms/payroll/doctype/salary_structure/salary_structure.js index 3a182ad962..b9920af11a 100755 --- a/hrms/payroll/doctype/salary_structure/salary_structure.js +++ b/hrms/payroll/doctype/salary_structure/salary_structure.js @@ -252,8 +252,8 @@ var validate_date = function(frm, cdt, cdn) { } } - -cur_frm.cscript.amount = function(doc, cdt, cdn){ +// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage +cur_frm.cscript.amount = function (doc, cdt, cdn) { calculate_totals(doc, cdt, cdn); }; @@ -278,7 +278,8 @@ var calculate_totals = function(doc) { refresh_many(['total_earning', 'total_deduction', 'net_pay']); } -cur_frm.cscript.validate = function(doc, cdt, cdn) { +// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage +cur_frm.cscript.validate = function (doc, cdt, cdn) { calculate_totals(doc); } diff --git a/hrms/payroll/doctype/salary_structure/salary_structure.py b/hrms/payroll/doctype/salary_structure/salary_structure.py index 51dfadae8b..74f7ad3a35 100644 --- a/hrms/payroll/doctype/salary_structure/salary_structure.py +++ b/hrms/payroll/doctype/salary_structure/salary_structure.py @@ -165,6 +165,7 @@ def get_employees(self, **kwargs): condition_str = " and " + " and ".join(conditions) if conditions else "" + # nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql employees = frappe.db.sql_list( f"select name from tabEmployee where status='Active' {condition_str}", tuple(values), @@ -291,6 +292,7 @@ def create_salary_structures_assignment( def get_existing_assignments(employees, salary_structure, from_date): + # nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql salary_structures_assignments = frappe.db.sql_list( f""" SELECT DISTINCT employee FROM `tabSalary Structure Assignment` diff --git a/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py b/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py index f5d9c58ea0..10893e81f1 100644 --- a/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py +++ b/hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py @@ -50,6 +50,7 @@ def get_data(filters): conditions = get_conditions(filters) + # nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql entry = frappe.db.sql( """SELECT sal.employee, sal.employee_name, ded.salary_component, ded.amount FROM `tabSalary Slip` sal, `tabSalary Detail` ded diff --git a/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.py b/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.py index aad97d2355..8a9d8b7f56 100644 --- a/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.py +++ b/hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.py @@ -116,6 +116,7 @@ def get_data(filters): if not len(component_type_dict): return [] + # nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql entry = frappe.db.sql( """ select sal.name, sal.employee, sal.employee_name, ded.salary_component, ded.amount from `tabSalary Slip` sal, `tabSalary Detail` ded From 763cf3f0a2e9d48ab626540dc4c7be146a0d454b Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 17 Apr 2024 19:40:13 +0530 Subject: [PATCH 17/20] chore: remove unncessary fetch from statements & scripts --- .../hr/doctype/expense_claim/expense_claim.js | 42 ------------------- .../doctype/expense_claim/expense_claim.json | 6 ++- .../hr/doctype/expense_claim/expense_claim.py | 12 ------ 3 files changed, 5 insertions(+), 55 deletions(-) diff --git a/hrms/hr/doctype/expense_claim/expense_claim.js b/hrms/hr/doctype/expense_claim/expense_claim.js index 964c62c568..62b2b37b6d 100644 --- a/hrms/hr/doctype/expense_claim/expense_claim.js +++ b/hrms/hr/doctype/expense_claim/expense_claim.js @@ -4,18 +4,8 @@ frappe.provide("hrms.hr"); frappe.provide("erpnext.accounts.dimensions"); -// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage -cur_frm.add_fetch("employee", "company", "company"); -// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage -cur_frm.add_fetch("employee", "employee_name", "employee_name"); -// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage -cur_frm.add_fetch("expense_type", "description", "description"); - // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.cscript.refresh = function (doc) { - // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage - cur_frm.cscript.set_help(doc); - if (!doc.__islocal) { if (doc.docstatus === 1) { /* eslint-disable */ @@ -51,16 +41,6 @@ cur_frm.cscript.refresh = function (doc) { } }; -// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage -cur_frm.cscript.set_help = function (doc) { - // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage - cur_frm.set_intro(""); - if (doc.__islocal && !frappe.user_roles.includes("HR User")) { - // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage - cur_frm.set_intro(__("Fill the form and save it")); - } -}; - // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage cur_frm.cscript.validate = function (doc) { // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage @@ -83,30 +63,8 @@ cur_frm.cscript.calculate_total_amount = function (doc, cdt, cdn) { cur_frm.cscript.calculate_total(doc, cdt, cdn); }; -// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage -cur_frm.fields_dict["cost_center"].get_query = function (doc) { - return { - filters: { - company: doc.company, - }, - }; -}; - -erpnext.expense_claim = { - set_title: function (frm) { - if (!frm.doc.task) { - frm.set_value("title", frm.doc.employee_name); - } else { - frm.set_value("title", frm.doc.employee_name + " for " + frm.doc.task); - } - }, -}; - frappe.ui.form.on("Expense Claim", { setup: function (frm) { - frm.add_fetch("company", "cost_center", "cost_center"); - frm.add_fetch("company", "default_expense_claim_payable_account", "payable_account"); - frm.set_query("employee_advance", "advances", function () { return { filters: [ diff --git a/hrms/hr/doctype/expense_claim/expense_claim.json b/hrms/hr/doctype/expense_claim/expense_claim.json index 45b78bfb54..88c679c7f9 100644 --- a/hrms/hr/doctype/expense_claim/expense_claim.json +++ b/hrms/hr/doctype/expense_claim/expense_claim.json @@ -264,6 +264,8 @@ "fieldtype": "Column Break" }, { + "fetch_from": "company.default_expense_claim_payable_account", + "fetch_if_empty": 1, "fieldname": "payable_account", "fieldtype": "Link", "label": "Payable Account", @@ -271,6 +273,8 @@ "reqd": 1 }, { + "fetch_from": "company.cost_center", + "fetch_if_empty": 1, "fieldname": "cost_center", "fieldtype": "Link", "label": "Cost Center", @@ -379,7 +383,7 @@ "idx": 1, "is_submittable": 1, "links": [], - "modified": "2021-11-22 16:26:57.787838", + "modified": "2024-04-17 19:38:30.373122", "modified_by": "Administrator", "module": "HR", "name": "Expense Claim", diff --git a/hrms/hr/doctype/expense_claim/expense_claim.py b/hrms/hr/doctype/expense_claim/expense_claim.py index 03f8534447..4580fc6b07 100644 --- a/hrms/hr/doctype/expense_claim/expense_claim.py +++ b/hrms/hr/doctype/expense_claim/expense_claim.py @@ -37,8 +37,6 @@ def validate(self): self.calculate_total_amount() self.validate_advances() self.set_expense_account(validate=True) - self.set_payable_account() - self.set_cost_center() self.calculate_taxes() self.set_status() if self.task and not self.project: @@ -78,16 +76,6 @@ def set_status(self, update=False): def on_update(self): share_doc_with_approver(self, self.expense_approver) - def set_payable_account(self): - if not self.payable_account and not self.is_paid: - self.payable_account = frappe.get_cached_value( - "Company", self.company, "default_expense_claim_payable_account" - ) - - def set_cost_center(self): - if not self.cost_center: - self.cost_center = frappe.get_cached_value("Company", self.company, "cost_center") - def on_submit(self): if self.approval_status == "Draft": frappe.throw(_("""Approval Status must be 'Approved' or 'Rejected'""")) From 4168b1979cb18e7f70bba0960d94d919f7c91b2c Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 17 Apr 2024 20:12:36 +0530 Subject: [PATCH 18/20] refactor(Expense Claim): get rid of `cur_frm` usage --- .../hr/doctype/expense_claim/expense_claim.js | 144 +++++++++--------- 1 file changed, 71 insertions(+), 73 deletions(-) diff --git a/hrms/hr/doctype/expense_claim/expense_claim.js b/hrms/hr/doctype/expense_claim/expense_claim.js index 62b2b37b6d..e13a5dad69 100644 --- a/hrms/hr/doctype/expense_claim/expense_claim.js +++ b/hrms/hr/doctype/expense_claim/expense_claim.js @@ -4,65 +4,6 @@ frappe.provide("hrms.hr"); frappe.provide("erpnext.accounts.dimensions"); -// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage -cur_frm.cscript.refresh = function (doc) { - if (!doc.__islocal) { - if (doc.docstatus === 1) { - /* eslint-disable */ - // no idea how `me` works here - var entry_doctype, entry_reference_doctype, entry_reference_name; - if (doc.__onload.make_payment_via_journal_entry) { - entry_doctype = "Journal Entry"; - entry_reference_doctype = "Journal Entry Account.reference_type"; - entry_reference_name = "Journal Entry.reference_name"; - } else { - entry_doctype = "Payment Entry"; - entry_reference_doctype = "Payment Entry Reference.reference_doctype"; - entry_reference_name = "Payment Entry Reference.reference_name"; - } - - if (cint(doc.total_amount_reimbursed) > 0 && frappe.model.can_read(entry_doctype)) { - // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage - cur_frm.add_custom_button( - __("Bank Entries"), - function () { - frappe.route_options = { - party_type: "Employee", - party: doc.employee, - company: doc.company, - }; - frappe.set_route("List", entry_doctype); - }, - __("View"), - ); - } - /* eslint-enable */ - } - } -}; - -// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage -cur_frm.cscript.validate = function (doc) { - // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage - cur_frm.cscript.calculate_total(doc); -}; - -// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage -cur_frm.cscript.calculate_total = function (doc) { - doc.total_claimed_amount = 0; - doc.total_sanctioned_amount = 0; - $.each(doc.expenses || [], function (i, d) { - doc.total_claimed_amount += d.amount; - doc.total_sanctioned_amount += d.sanctioned_amount; - }); -}; - -// nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage -cur_frm.cscript.calculate_total_amount = function (doc, cdt, cdn) { - // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage - cur_frm.cscript.calculate_total(doc, cdt, cdn); -}; - frappe.ui.form.on("Expense Claim", { setup: function (frm) { frm.set_query("employee_advance", "advances", function () { @@ -145,7 +86,28 @@ frappe.ui.form.on("Expense Claim", { refresh: function (frm) { frm.trigger("toggle_fields"); + frm.trigger("add_ledger_buttons"); + if ( + frm.doc.docstatus === 1 && + frm.doc.status !== "Paid" && + frappe.model.can_create("Payment Entry") + ) { + frm.add_custom_button( + __("Payment"), + function () { + frm.events.make_payment_entry(frm); + }, + __("Create"), + ); + } + }, + + validate: function (frm) { + frm.trigger("calculate_total"); + }, + + add_ledger_buttons: function (frm) { if (frm.doc.docstatus > 0 && frm.doc.approval_status !== "Rejected") { frm.add_custom_button( __("Accounting Ledger"), @@ -164,21 +126,58 @@ frappe.ui.form.on("Expense Claim", { ); } - if ( - frm.doc.docstatus === 1 && - frm.doc.status !== "Paid" && - frappe.model.can_create("Payment Entry") - ) { - frm.add_custom_button( - __("Payment"), - function () { - frm.events.make_payment_entry(frm); - }, - __("Create"), - ); + if (!frm.doc.__islocal && frm.doc.docstatus === 1) { + let entry_doctype, entry_reference_doctype, entry_reference_name; + if (frm.doc.__onload.make_payment_via_journal_entry) { + entry_doctype = "Journal Entry"; + entry_reference_doctype = "Journal Entry Account.reference_type"; + entry_reference_name = "Journal Entry.reference_name"; + } else { + entry_doctype = "Payment Entry"; + entry_reference_doctype = "Payment Entry Reference.reference_doctype"; + entry_reference_name = "Payment Entry Reference.reference_name"; + } + + if ( + cint(frm.doc.total_amount_reimbursed) > 0 && + frappe.model.can_read(entry_doctype) + ) { + // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage + frm.add_custom_button( + __("Bank Entries"), + function () { + frappe.route_options = { + party_type: "Employee", + party: frm.doc.employee, + company: frm.doc.company, + }; + frappe.set_route("List", entry_doctype); + }, + __("View"), + ); + } } }, + calculate_total: function (frm) { + let total_claimed_amount = 0; + let total_sanctioned_amount = 0; + + frm.doc.expenses.forEach((row) => { + total_claimed_amount += row.amount; + total_sanctioned_amount += row.sanctioned_amount; + }); + + frm.set_value( + "total_claimed_amount", + flt(total_claimed_amount, precision("total_claimed_amount")), + ); + frm.set_value( + "total_sanctioned_amount", + flt(total_sanctioned_amount, precision("total_sanctioned_amount")), + ); + }, + calculate_grand_total: function (frm) { var grand_total = flt(frm.doc.total_sanctioned_amount) + @@ -361,8 +360,7 @@ frappe.ui.form.on("Expense Claim Detail", { }, sanctioned_amount: function (frm, cdt, cdn) { - // nosemgrep: frappe-semgrep-rules.rules.frappe-cur-frm-usage - cur_frm.cscript.calculate_total(frm.doc, cdt, cdn); + frm.trigger("calculate_total"); frm.trigger("get_taxes"); frm.trigger("calculate_grand_total"); }, From 258fc60c22a2bd38ba8f6eab6670ff79ee0c495e Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 1 May 2024 14:24:04 +0530 Subject: [PATCH 19/20] chore: handle semgrep errors --- hrms/hr/doctype/leave_control_panel/leave_control_panel.py | 1 + hrms/hr/doctype/leave_encashment/leave_encashment.js | 2 +- hrms/payroll/doctype/payroll_entry/payroll_entry.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hrms/hr/doctype/leave_control_panel/leave_control_panel.py b/hrms/hr/doctype/leave_control_panel/leave_control_panel.py index 77e7e4e8b7..95f8c9794b 100644 --- a/hrms/hr/doctype/leave_control_panel/leave_control_panel.py +++ b/hrms/hr/doctype/leave_control_panel/leave_control_panel.py @@ -32,6 +32,7 @@ def get_employees(self): condition_str = " and " + " and ".join(conditions) if len(conditions) else "" + # nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql e = frappe.db.sql( f"select name from tabEmployee where status='Active' {condition_str}", tuple(values), diff --git a/hrms/hr/doctype/leave_encashment/leave_encashment.js b/hrms/hr/doctype/leave_encashment/leave_encashment.js index 09b1b698ec..d11e251ae8 100644 --- a/hrms/hr/doctype/leave_encashment/leave_encashment.js +++ b/hrms/hr/doctype/leave_encashment/leave_encashment.js @@ -24,7 +24,7 @@ frappe.ui.form.on("Leave Encashment", { }, refresh: function (frm) { cur_frm.set_intro(""); - if (frm.doc.__islocal && !in_list(frappe.user_roles, "Employee")) { + if (frm.doc.__islocal && !frappe.user_roles.includes("Employee")) { frm.set_intro(__("Fill the form and save it")); } }, diff --git a/hrms/payroll/doctype/payroll_entry/payroll_entry.py b/hrms/payroll/doctype/payroll_entry/payroll_entry.py index 67abf6731f..b9ef3655fe 100644 --- a/hrms/payroll/doctype/payroll_entry/payroll_entry.py +++ b/hrms/payroll/doctype/payroll_entry/payroll_entry.py @@ -1250,6 +1250,7 @@ def show_payroll_submission_status(submitted, unsubmitted, payroll_entry): def get_existing_salary_slips(employees, args): + # nosemgrep: frappe-semgrep-rules.rules.frappe-using-db-sql return frappe.db.sql_list( """ select distinct employee from `tabSalary Slip` From 6d5c1180e0747b46243fb6970d929a6e304aea00 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 1 May 2024 16:15:56 +0530 Subject: [PATCH 20/20] chore: don't pin frappe dependencies for v14 --- pyproject.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8ca46bc187..2f992c817d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,3 @@ section-order = [ "first-party", "local-folder", ] - -[tool.bench.frappe-dependencies] -frappe = ">=14.0.0,<15.0.0" -erpnext = ">=14.0.0,<15.0.0"