Skip to content

Commit

Permalink
Merge pull request #2717 from frappe/version-14-hotfix
Browse files Browse the repository at this point in the history
chore: release v14
  • Loading branch information
asmitahase authored Jan 28, 2025
2 parents 01e4ea5 + e8a526f commit 7ba5ae7
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts

- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml') }}
Expand All @@ -88,7 +88,7 @@ jobs:
${{ runner.os }}-
- name: Cache node modules
uses: actions/cache@v2
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand All @@ -103,7 +103,7 @@ jobs:
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
- uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand Down
25 changes: 15 additions & 10 deletions hrms/hr/doctype/employee_checkin/employee_checkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,27 @@ frappe.ui.form.on("Employee Checkin", {
add_fetch_shift_button(frm) {
if (frm.doc.attendace) return;
frm.add_custom_button(__("Fetch Shift"), function () {
const previous_shift = frm.doc.shift;
frappe.call({
method: "fetch_shift",
doc: frm.doc,
freeze: true,
freeze_message: __("Fetching Shift"),
callback: function () {
if (previous_shift === frm.doc.shift) return;
frm.dirty();
frm.save();
frappe.show_alert({
message: __("Shift has been successfully updated to {0}.", [
frm.doc.shift,
]),
indicator: "green",
});
if (frm.doc.shift) {
frappe.show_alert({
message: __("Shift has been successfully updated to {0}.", [
frm.doc.shift,
]),
indicator: "green",
});
frm.dirty();
frm.save();
} else {
frappe.show_alert({
message: __("No valid shift found for log time"),
indicator: "orange",
});
}
},
});
});
Expand Down
28 changes: 28 additions & 0 deletions hrms/hr/doctype/employee_checkin/test_employee_checkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,34 @@ def test_bulk_fetch_shift(self):
# shift does not change since attendance is already marked
self.assertEqual(log2.shift, shift1.name)

def test_bulk_fetch_shift_if_shift_settings_change_for_the_same_shift(self):
emp1 = make_employee("[email protected]", company="_Test Company")
emp2 = make_employee("[email protected]", company="_Test Company")

# 8 - 12,
shift = setup_shift_type(shift_type="Test Bulk Shift")
date = getdate()
make_shift_assignment(shift.name, emp1, date)
make_shift_assignment(shift.name, emp2, date)

timestamp = datetime.combine(date, get_time("08:00:00"))
# shift actual start is `current date 07:00:00`
log1 = make_checkin(emp1, timestamp)
self.assertEqual(log1.shift_actual_start, datetime.combine(date, get_time("07:00:00")))
log2 = make_checkin(emp2, timestamp)
self.assertEqual(log2.shift_actual_start, datetime.combine(date, get_time("07:00:00")))

# change shift settings like check in buffer from 60 minutes to 120 minutes
# so now shift actual start is `current date 06:00:00`
shift.begin_check_in_before_shift_start_time = 120
shift.save()
bulk_fetch_shift([log1.name, log2.name])
# shift changes according to the new assignment
log1.reload()
self.assertEqual(log1.shift_actual_start, datetime.combine(date, get_time("06:00:00")))
log2.reload()
self.assertEqual(log2.shift_actual_start, datetime.combine(date, get_time("06:00:00")))


def make_n_checkins(employee, n, hours_to_reverse=1):
logs = [make_checkin(employee, now_datetime() - timedelta(hours=hours_to_reverse, minutes=n + 1))]
Expand Down

0 comments on commit 7ba5ae7

Please sign in to comment.