Skip to content

Commit

Permalink
Merge branch 'develop' into over-time
Browse files Browse the repository at this point in the history
  • Loading branch information
iamejaaz authored Oct 20, 2024
2 parents 622fe24 + eaba4d6 commit 8708272
Show file tree
Hide file tree
Showing 147 changed files with 24,119 additions and 12,435 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
BRANCH_TO_CLONE: ${{ env.HR_BRANCH }}

- name: Run Tests
run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app hrms --total-builds 2 --build-number ${{ matrix.container }}
run: cd ~/frappe-bench/ && bench --site test_site run-parallel-tests --app hrms --total-builds ${{ strategy.job-total }} --build-number ${{ matrix.container }}
env:
TYPE: server
CAPTURE_COVERAGE: ${{ github.event_name != 'pull_request' }}
Expand Down Expand Up @@ -138,4 +138,4 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
verbose: true
22 changes: 21 additions & 1 deletion frontend/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@
Login
</Button>
</form>

<template v-if="authProviders.data?.length">
<div class="text-center text-sm text-gray-600 my-4">or</div>
<div class="space-y-4">
<a
v-for="provider in authProviders.data"
:key="provider.name"
class="flex items-center justify-center gap-2 transition-colors focus:outline-none text-gray-800 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 focus-visible:ring focus-visible:ring-gray-400 h-7 text-base p-2 rounded"
:href="provider.auth_url"
>
<img class="h-4 w-4" :src="provider.icon" :alt="provider.provider_name" />
<span>Login with {{ provider.provider_name }}</span>
</a>
</div>
</template>
</div>
</div>

Expand Down Expand Up @@ -88,7 +103,7 @@
<script setup>
import { IonPage, IonContent } from "@ionic/vue"
import { inject, reactive, ref } from "vue"
import { Input, Button, ErrorMessage, Dialog } from "frappe-ui"
import { Input, Button, ErrorMessage, Dialog, createResource } from "frappe-ui"
import FrappeHRLogo from "@/components/icons/FrappeHRLogo.vue"
Expand Down Expand Up @@ -141,4 +156,9 @@ async function submit(e) {
errorMessage.value = error.messages.join("\n")
}
}
const authProviders = createResource({
url: "hrms.api.oauth.oauth_providers",
auto: true,
})
</script>
33 changes: 33 additions & 0 deletions hrms/api/oauth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import frappe


@frappe.whitelist(allow_guest=True)
def oauth_providers():
from frappe.utils.html_utils import get_icon_html
from frappe.utils.oauth import get_oauth2_authorize_url, get_oauth_keys
from frappe.utils.password import get_decrypted_password

out = []
providers = frappe.get_all(
"Social Login Key",
filters={"enable_social_login": 1},
fields=["name", "client_id", "base_url", "provider_name", "icon"],
order_by="name",
)

for provider in providers:
client_secret = get_decrypted_password("Social Login Key", provider.name, "client_secret")
if not client_secret:
continue

if provider.client_id and provider.base_url and get_oauth_keys(provider.name):
out.append(
{
"name": provider.name,
"provider_name": provider.provider_name,
"auth_url": get_oauth2_authorize_url(provider.name, "/hrms"),
"icon": provider.icon,
}
)

return out
8 changes: 6 additions & 2 deletions hrms/api/roster.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,18 @@ def insert_shift(

def get_holidays(month_start: str, month_end: str, employee_filters: dict[str, str]) -> dict[str, list[dict]]:
holidays = {}
holiday_lists = {}

for employee in frappe.get_list("Employee", filters=employee_filters, pluck="name"):
if holiday_list := get_holiday_list_for_employee(employee, raise_exception=False):
holidays[employee] = frappe.get_all(
if not (holiday_list := get_holiday_list_for_employee(employee, raise_exception=False)):
continue
if holiday_list not in holiday_lists:
holiday_lists[holiday_list] = frappe.get_all(
"Holiday",
filters={"parent": holiday_list, "holiday_date": ["between", [month_start, month_end]]},
fields=["name as holiday", "holiday_date", "description", "weekly_off"],
)
holidays[employee] = holiday_lists[holiday_list].copy()

return holidays

Expand Down
4 changes: 2 additions & 2 deletions hrms/controllers/tests/test_employee_reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import timedelta

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase
from frappe.utils import add_months, getdate

from erpnext.setup.doctype.employee.test_employee import make_employee
Expand All @@ -14,7 +14,7 @@
from hrms.hr.utils import get_holidays_for_employee


class TestEmployeeReminders(FrappeTestCase):
class TestEmployeeReminders(IntegrationTestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down
4 changes: 2 additions & 2 deletions hrms/hr/doctype/appointment_letter/test_appointment_letter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TestAppointmentLetter(FrappeTestCase):
class TestAppointmentLetter(IntegrationTestCase):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TestAppointmentLetterTemplate(FrappeTestCase):
class TestAppointmentLetterTemplate(IntegrationTestCase):
pass
4 changes: 2 additions & 2 deletions hrms/hr/doctype/appraisal/test_appraisal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See license.txt

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase

from erpnext.setup.doctype.designation.test_designation import create_designation
from erpnext.setup.doctype.employee.test_employee import make_employee
Expand All @@ -17,7 +17,7 @@
from hrms.tests.test_utils import create_company


class TestAppraisal(FrappeTestCase):
class TestAppraisal(IntegrationTestCase):
def setUp(self):
frappe.db.delete("Goal")
frappe.db.delete("Appraisal")
Expand Down
4 changes: 2 additions & 2 deletions hrms/hr/doctype/appraisal_cycle/test_appraisal_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See license.txt

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase

from erpnext.setup.doctype.designation.test_designation import create_designation
from erpnext.setup.doctype.employee.test_employee import make_employee
Expand All @@ -11,7 +11,7 @@
from hrms.tests.test_utils import create_company


class TestAppraisalCycle(FrappeTestCase):
class TestAppraisalCycle(IntegrationTestCase):
def setUp(self):
company = create_company("_Test Appraisal").name
self.template = create_appraisal_template()
Expand Down
4 changes: 2 additions & 2 deletions hrms/hr/doctype/appraisal_template/test_appraisal_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# See license.txt

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase


class TestAppraisalTemplate(FrappeTestCase):
class TestAppraisalTemplate(IntegrationTestCase):
def test_incorrect_weightage_allocation(self):
template = create_appraisal_template()
template.goals[1].per_weightage = 69.99
Expand Down
4 changes: 2 additions & 2 deletions hrms/hr/doctype/attendance/test_attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See license.txt

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase
from frappe.utils import (
add_days,
add_months,
Expand All @@ -27,7 +27,7 @@
test_records = frappe.get_test_records("Attendance")


class TestAttendance(FrappeTestCase):
class TestAttendance(IntegrationTestCase):
def setUp(self):
from hrms.payroll.doctype.salary_slip.test_salary_slip import make_holiday_list

Expand Down
2 changes: 1 addition & 1 deletion hrms/hr/doctype/attendance_request/attendance_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OverlappingAttendanceRequestError(frappe.ValidationError):
class AttendanceRequest(Document):
def validate(self):
validate_active_employee(self.employee)
validate_dates(self, self.from_date, self.to_date)
validate_dates(self, self.from_date, self.to_date, False)
self.validate_half_day()
self.validate_request_overlap()

Expand Down
4 changes: 2 additions & 2 deletions hrms/hr/doctype/attendance_request/test_attendance_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See license.txt

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase
from frappe.utils import add_days, add_months, get_year_ending, get_year_start, getdate

from hrms.hr.doctype.attendance.attendance import mark_attendance
Expand All @@ -17,7 +17,7 @@
test_dependencies = ["Employee"]


class TestAttendanceRequest(FrappeTestCase):
class TestAttendanceRequest(IntegrationTestCase):
def setUp(self):
for doctype in ["Attendance Request", "Attendance"]:
frappe.db.delete(doctype)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See license.txt

import frappe
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase
from frappe.utils import add_days, add_months, today

from hrms.hr.doctype.attendance_request.test_attendance_request import get_employee
Expand All @@ -13,7 +13,7 @@
test_dependencies = ["Employee"]


class TestCompensatoryLeaveRequest(FrappeTestCase):
class TestCompensatoryLeaveRequest(IntegrationTestCase):
def setUp(self):
frappe.db.delete("Compensatory Leave Request")
frappe.db.delete("Leave Ledger Entry")
Expand Down
4 changes: 2 additions & 2 deletions hrms/hr/doctype/daily_work_summary/test_daily_work_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

import frappe
import frappe.utils
from frappe.tests.utils import FrappeTestCase
from frappe.tests import IntegrationTestCase

# test_records = frappe.get_test_records('Daily Work Summary')


class TestDailyWorkSummary(FrappeTestCase):
class TestDailyWorkSummary(IntegrationTestCase):
def test_email_trigger(self):
self.setup_and_prepare_test()
for d in self.users:
Expand Down
11 changes: 11 additions & 0 deletions hrms/hr/doctype/employee_advance/employee_advance.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def validate(self):

def on_cancel(self):
self.ignore_linked_doctypes = "GL Entry"
self.check_linked_payment_entry()
self.set_status(update=True)

def on_update(self):
Expand Down Expand Up @@ -175,6 +176,16 @@ def set_pending_amount(self):
)
).run()[0][0] or 0.0

def check_linked_payment_entry(self):
from erpnext.accounts.utils import (
remove_ref_doc_link_from_pe,
update_accounting_ledgers_after_reference_removal,
)

if frappe.db.get_single_value("HR Settings", "unlink_payment_on_cancellation_of_employee_advance"):
remove_ref_doc_link_from_pe(self.doctype, self.name)
update_accounting_ledgers_after_reference_removal(self.doctype, self.name)


@frappe.whitelist()
def make_bank_entry(dt, dn):
Expand Down
Loading

0 comments on commit 8708272

Please sign in to comment.