Skip to content

Commit

Permalink
Merge pull request #1844 from frappe/version-15-hotfix
Browse files Browse the repository at this point in the history
chore: release v15
  • Loading branch information
ruchamahabal authored Jun 7, 2024
2 parents 00351a4 + 883e0ea commit f4cb776
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 20 deletions.
16 changes: 10 additions & 6 deletions frontend/src/components/CheckInPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="flex flex-col bg-white rounded w-full py-6 px-4 border-none">
<h2 class="text-lg font-bold text-gray-900">Hey, {{ employee?.data?.first_name }} 👋</h2>

<template v-if="HRSettings.doc?.allow_employee_checkin_from_mobile_app">
<template v-if="settings.data?.allow_employee_checkin_from_mobile_app">
<div class="font-medium text-sm text-gray-500 mt-1.5" v-if="lastLog">
Last {{ lastLogType }} was at {{ lastLogTime }}
</div>
Expand All @@ -27,7 +27,7 @@
</div>

<ion-modal
v-if="HRSettings.doc?.allow_employee_checkin_from_mobile_app"
v-if="settings.data?.allow_employee_checkin_from_mobile_app"
ref="modal"
trigger="open-checkin-modal"
:initial-breakpoint="1"
Expand All @@ -43,7 +43,7 @@
</div>
</div>

<template v-if="HRSettings.doc?.allow_geolocation_tracking">
<template v-if="settings.data?.allow_geolocation_tracking">
<span v-if="locationStatus" class="font-medium text-gray-500 text-sm">
{{ locationStatus }}
</span>
Expand Down Expand Up @@ -71,10 +71,9 @@
</template>

<script setup>
import { createListResource, toast, FeatherIcon } from "frappe-ui"
import { createResource, createListResource, toast, FeatherIcon } from "frappe-ui"
import { computed, inject, ref, onMounted, onBeforeUnmount } from "vue"
import { IonModal, modalController } from "@ionic/vue"
import { HRSettings } from "@/data/HRSettings"
const DOCTYPE = "Employee Checkin"
Expand All @@ -86,6 +85,11 @@ const latitude = ref(0)
const longitude = ref(0)
const locationStatus = ref("")
const settings = createResource({
url: "hrms.api.get_hr_settings",
auto: true,
})
const checkins = createListResource({
doctype: DOCTYPE,
fields: ["name", "employee", "employee_name", "log_type", "time", "device_id"],
Expand Down Expand Up @@ -150,7 +154,7 @@ const fetchLocation = () => {
const handleEmployeeCheckin = () => {
checkinTimestamp.value = dayjs().format("YYYY-MM-DD HH:mm:ss")
if (HRSettings.doc?.allow_geolocation_tracking) {
if (settings.data?.allow_geolocation_tracking) {
fetchLocation()
}
}
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/data/HRSettings.js

This file was deleted.

19 changes: 17 additions & 2 deletions hrms/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from frappe import _
from frappe.model.workflow import get_workflow_name
from frappe.query_builder import Order
from frappe.utils import getdate
from frappe.utils import getdate, strip_html

SUPPORTED_FIELD_TYPES = [
"Link",
Expand Down Expand Up @@ -75,6 +75,16 @@ def get_all_employees() -> list[dict]:
)


# HR Settings
@frappe.whitelist()
def get_hr_settings() -> dict:
settings = frappe.db.get_singles_dict("HR Settings", cast=True)
return frappe._dict(
allow_employee_checkin_from_mobile_app=settings.allow_employee_checkin_from_mobile_app,
allow_geolocation_tracking=settings.allow_geolocation_tracking,
)


# Notifications
@frappe.whitelist()
def get_unread_notifications_count() -> int:
Expand Down Expand Up @@ -207,13 +217,18 @@ def get_holidays_for_employee(employee: str) -> list[dict]:
return []

Holiday = frappe.qb.DocType("Holiday")
return (
holidays = (
frappe.qb.from_(Holiday)
.select(Holiday.name, Holiday.holiday_date, Holiday.description)
.where((Holiday.parent == holiday_list) & (Holiday.weekly_off == 0))
.orderby(Holiday.holiday_date, order=Order.asc)
).run(as_dict=True)

for holiday in holidays:
holiday["description"] = strip_html(holiday["description"] or "").strip()

return holidays


@frappe.whitelist()
def get_leave_approval_details(employee: str) -> dict:
Expand Down
1 change: 1 addition & 0 deletions hrms/hr/doctype/attendance_request/attendance_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def has_leave_record(self, attendance_date: str) -> str | None:
"docstatus": 1,
"from_date": ("<=", attendance_date),
"to_date": (">=", attendance_date),
"status": "Approved",
},
)

Expand Down
8 changes: 6 additions & 2 deletions hrms/hr/doctype/department_approver/department_approver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import get_link_to_form


class DepartmentApprover(Document):
Expand Down Expand Up @@ -81,10 +82,13 @@ def get_approvers(doctype, txt, searchfield, start, page_len, filters):

if len(approvers) == 0:
error_msg = _("Please set {0} for the Employee: {1}").format(
_(field_name), frappe.bold(employee.employee_name)
frappe.bold(_(field_name)),
get_link_to_form("Employee", filters.get("employee"), employee.employee_name),
)
if department_list:
error_msg += " " + _("or for Department: {0}").format(frappe.bold(employee_department))
error_msg += " " + _("or for the Employee's Department: {0}").format(
get_link_to_form("Department", employee_department)
)
frappe.throw(error_msg, title=_("{0} Missing").format(_(field_name)))

return set(tuple(approver) for approver in approvers)
3 changes: 0 additions & 3 deletions hrms/hr/doctype/leave_application/leave_application.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ frappe.ui.form.on("Leave Application", {
if (!r.exc && r.message["leave_allocation"]) {
leave_details = r.message["leave_allocation"];
}
if (!r.exc && r.message["leave_approver"]) {
frm.set_value("leave_approver", r.message["leave_approver"]);
}
lwps = r.message["lwps"];
},
});
Expand Down

0 comments on commit f4cb776

Please sign in to comment.