Skip to content

Commit

Permalink
Merge branch 'frappe:version-15' into version-15
Browse files Browse the repository at this point in the history
  • Loading branch information
metalmon authored Feb 2, 2025
2 parents 555ac4a + d5a30b9 commit 526a981
Show file tree
Hide file tree
Showing 104 changed files with 2,877 additions and 887 deletions.
5 changes: 5 additions & 0 deletions .github/helper/apps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
{"url": "https://github.com/frappe/erpnext","branch": "version-15"},
{"url": "https://github.com/frappe/payments","branch": "version-15"},
{"url": "https://github.com/frappe/hrms","branch": "version-15"}
]
66 changes: 66 additions & 0 deletions .github/workflows/build_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build Container Image
on:
release:
types: [published]
workflow_dispatch:
push:
branches:
- version-15
tags:
- "*"
jobs:
build:
name: Build
runs-on: ubuntu-latest

strategy:
matrix:
arch: [amd64, arm64]

permissions:
packages: write

steps:
- name: Checkout Entire Repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/${{ matrix.arch }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set Branch
run: |
export APPS_JSON_PATH='${{ github.workspace }}/.github/helper/apps.json'
echo "APPS_JSON_BASE64=$(cat $APPS_JSON_PATH | base64 -w 0)" >> $GITHUB_ENV
echo "FRAPPE_BRANCH=version-15" >> $GITHUB_ENV
- name: Set Image Tag
run: |
echo "IMAGE_TAG=stable" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
repository: frappe/frappe_docker
path: builds

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
context: builds
file: builds/images/layered/Containerfile
tags: >
ghcr.io/${{ github.repository }}:${{ github.ref_name }},
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
build-args: |
"FRAPPE_BRANCH=${{ env.FRAPPE_BRANCH }}"
"APPS_JSON_BASE64=${{ env.APPS_JSON_BASE64 }}"
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,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 @@ -79,7 +79,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 @@ -94,7 +94,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 All @@ -115,7 +115,7 @@ jobs:
CAPTURE_COVERAGE: ${{ github.event_name != 'pull_request' }}

- name: Upload coverage data
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: github.event_name != 'pull_request'
with:
name: coverage-${{ matrix.container }}
Expand All @@ -131,7 +131,7 @@ jobs:
uses: actions/checkout@v2

- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4

- name: Upload coverage data
uses: codecov/codecov-action@v2
Expand Down
2 changes: 1 addition & 1 deletion frappe-ui
Submodule frappe-ui updated 130 files
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dayjs": "^1.11.11",
"feather-icons": "^4.29.1",
"firebase": "^10.8.0",
"frappe-ui": "^0.1.72",
"frappe-ui": "0.1.105",
"postcss": "^8.4.5",
"tailwindcss": "^3.4.3",
"vite": "^5.4.10",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/CheckInPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
</div>
</template>

<Button variant="solid" class="w-full py-5 text-sm" @click="submitLog(nextAction.action)">
<Button variant="solid" class="w-full py-5 text-sm" @click.once="submitLog(nextAction.action)">
{{ __("Confirm {0}", [nextAction.label]) }}
</Button>
</div>
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/components/ExpenseClaimItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
{{ claimTitle }}
</div>
<div class="text-xs font-normal text-gray-500">
<span>
{{ formatCurrency(props.doc.total_claimed_amount, currency) }}
</span>
<span>{{ claimDates }}</span>
<span class="whitespace-pre"> &middot; </span>
<span class="whitespace-nowrap">
{{ claimDates }}
{{ formatCurrency(props.doc.total_claimed_amount, currency) }}
</span>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/dayjs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dayjs from "dayjs"
import updateLocale from "dayjs/plugin/updateLocale"
import localizedFormat from "dayjs/plugin/localizedFormat"
import relativeTime from "dayjs/esm/plugin/relativeTime"
import relativeTime from "dayjs/plugin/relativeTime"
import isToday from "dayjs/plugin/isToday"
import isYesterday from "dayjs/plugin/isYesterday"
import isBetween from "dayjs/plugin/isBetween"
Expand Down
1 change: 0 additions & 1 deletion frontend/src/views/Notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ import {
arePushNotificationsEnabled,
} from "@/data/notifications"
const user = inject("$user")
const dayjs = inject("$dayjs")
const router = useRouter()
Expand Down
2 changes: 1 addition & 1 deletion hrms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import frappe

__version__ = "15.36.1"
__version__ = "15.39.0"


def refetch_resource(cache_key: str | list, user=None):
Expand Down
67 changes: 51 additions & 16 deletions hrms/api/roster.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from hrms.hr.doctype.shift_assignment.shift_assignment import ShiftAssignment
from hrms.hr.doctype.shift_assignment_tool.shift_assignment_tool import create_shift_assignment
from hrms.hr.doctype.shift_schedule.shift_schedule import get_or_insert_shift_schedule


@frappe.whitelist()
Expand Down Expand Up @@ -37,7 +38,17 @@ def get_events(


@frappe.whitelist()
def create_shift_assignment_schedule(
def get_schedule_from_assignment(shift_schedule_assignment: str):
shift_schedule = frappe.db.get_value(
"Shift Schedule Assignment", shift_schedule_assignment, "shift_schedule"
)
frequency = frappe.db.get_value("Shift Schedule", shift_schedule, "frequency")
repeat_on_days = frappe.get_all("Assignment Rule Day", filters={"parent": shift_schedule}, pluck="day")
return {"frequency": frequency, "repeat_on_days": repeat_on_days}


@frappe.whitelist()
def create_shift_schedule_assignment(
employee: str,
company: str,
shift_type: str,
Expand All @@ -46,34 +57,39 @@ def create_shift_assignment_schedule(
end_date: str | None,
repeat_on_days: list[str],
frequency: str,
shift_location: str | None = None,
) -> None:
schedule = frappe.get_doc(
shift_schedule = get_or_insert_shift_schedule(shift_type, frequency, repeat_on_days)
shift_schedule_assignment = frappe.get_doc(
{
"doctype": "Shift Assignment Schedule",
"frequency": frequency,
"repeat_on_days": [{"day": day} for day in repeat_on_days],
"enabled": 0 if end_date else 1,
"doctype": "Shift Schedule Assignment",
"shift_schedule": shift_schedule,
"employee": employee,
"company": company,
"shift_type": shift_type,
"shift_status": status,
"shift_location": shift_location,
"enabled": 0 if end_date else 1,
}
).insert()

if not end_date or date_diff(end_date, start_date) <= 90:
return schedule.create_shifts(start_date, end_date)
return shift_schedule_assignment.create_shifts(start_date, end_date)

frappe.enqueue(schedule.create_shifts, timeout=4500, start_date=start_date, end_date=end_date)
frappe.enqueue(
shift_schedule_assignment.create_shifts, timeout=4500, start_date=start_date, end_date=end_date
)


@frappe.whitelist()
def delete_shift_assignment_schedule(schedule: str) -> None:
for shift_assignment in frappe.get_all("Shift Assignment", {"schedule": schedule}, pluck="name"):
def delete_shift_schedule_assignment(shift_schedule_assignment: str) -> None:
for shift_assignment in frappe.get_all(
"Shift Assignment", {"shift_schedule_assignment": shift_schedule_assignment}, pluck="name"
):
doc = frappe.get_doc("Shift Assignment", shift_assignment)
if doc.docstatus == 1:
doc.cancel()
frappe.delete_doc("Shift Assignment", shift_assignment)
frappe.delete_doc("Shift Assignment Schedule", schedule)
frappe.delete_doc("Shift Schedule Assignment", shift_schedule_assignment)


@frappe.whitelist()
Expand All @@ -93,7 +109,13 @@ def swap_shift(
src_shift_doc = frappe.get_doc("Shift Assignment", src_shift)
break_shift(src_shift_doc, src_date)
insert_shift(
tgt_employee, tgt_company, src_shift_doc.shift_type, tgt_date, tgt_date, src_shift_doc.status
tgt_employee,
tgt_company,
src_shift_doc.shift_type,
tgt_date,
tgt_date,
src_shift_doc.status,
src_shift_doc.shift_location,
)

if tgt_shift:
Expand All @@ -104,6 +126,7 @@ def swap_shift(
src_date,
src_date,
tgt_shift_doc.status,
tgt_shift_doc.shift_location,
)


Expand All @@ -122,6 +145,7 @@ def break_shift(assignment: str | ShiftAssignment, date: str) -> None:
shift_type = assignment.shift_type
status = assignment.status
end_date = assignment.end_date
shift_location = assignment.shift_location

if date_diff(date, assignment.start_date) == 0:
assignment.cancel()
Expand All @@ -131,19 +155,28 @@ def break_shift(assignment: str | ShiftAssignment, date: str) -> None:
assignment.save()

if not end_date or date_diff(end_date, date) > 0:
create_shift_assignment(employee, company, shift_type, add_days(date, 1), end_date, status)
create_shift_assignment(
employee, company, shift_type, add_days(date, 1), end_date, status, shift_location
)


@frappe.whitelist()
def insert_shift(
employee: str, company: str, shift_type: str, start_date: str, end_date: str | None, status: str
employee: str,
company: str,
shift_type: str,
start_date: str,
end_date: str | None,
status: str,
shift_location: str | None = None,
) -> None:
filters = {
"doctype": "Shift Assignment",
"employee": employee,
"company": company,
"shift_type": shift_type,
"status": status,
"shift_location": shift_location,
}
prev_shift = frappe.db.exists(dict({"end_date": add_days(start_date, -1)}, **filters))
next_shift = (
Expand All @@ -161,7 +194,7 @@ def insert_shift(
frappe.db.set_value("Shift Assignment", next_shift, "start_date", start_date)

else:
create_shift_assignment(employee, company, shift_type, start_date, end_date, status)
create_shift_assignment(employee, company, shift_type, start_date, end_date, status, shift_location)


def get_holidays(month_start: str, month_end: str, employee_filters: dict[str, str]) -> dict[str, list[dict]]:
Expand Down Expand Up @@ -223,9 +256,11 @@ def get_shifts(
ShiftAssignment.name,
ShiftAssignment.employee,
ShiftAssignment.shift_type,
ShiftAssignment.shift_location,
ShiftAssignment.start_date,
ShiftAssignment.end_date,
ShiftAssignment.status,
ShiftAssignment.shift_schedule_assignment,
ShiftType.start_time,
ShiftType.end_time,
ShiftType.color,
Expand Down
15 changes: 14 additions & 1 deletion hrms/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
"hrms.overrides.company.make_company_fixtures",
"hrms.overrides.company.set_default_hr_accounts",
],
"on_trash": "hrms.overrides.company.handle_linked_docs",
},
"Holiday List": {
"on_update": "hrms.utils.holiday_list.invalidate_cache",
Expand Down Expand Up @@ -221,7 +222,7 @@
],
"hourly_long": [
"hrms.hr.doctype.shift_type.shift_type.process_auto_attendance_for_all_shifts",
"hrms.hr.doctype.shift_assignment_schedule.shift_assignment_schedule.process_auto_shift_creation",
"hrms.hr.doctype.shift_schedule_assignment.shift_schedule_assignment.process_auto_shift_creation",
],
"daily": [
"hrms.controllers.employee_reminders.send_birthday_reminders",
Expand Down Expand Up @@ -347,3 +348,15 @@
# Recommended only for DocTypes which have limited documents with untranslated names
# For example: Role, Gender, etc.
# translated_search_doctypes = []

company_data_to_be_ignored = [
"Salary Component Account",
"Salary Structure",
"Salary Structure Assignment",
"Payroll Period",
"Income Tax Slab",
"Leave Period",
"Leave Policy Assignment",
"Employee Onboarding Template",
"Employee Separation Template",
]
Loading

0 comments on commit 526a981

Please sign in to comment.