Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new DocType "Employment Contract" #50

Draft
wants to merge 2 commits into
base: version-15
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2024, ALYF GmbH and contributors
// For license information, please see license.txt

frappe.ui.form.on("Employment Contract", {
refresh(frm) {
if (frm.is_new() && !frm.doc.working_time_per_weekday?.length) {
frm.trigger("prefill_working_days");
}
},
distribute(frm) {
if (!frm.doc.working_time_per_week) {
frappe.show_alert(__("Please set the working time per week"));
}

if (!frm.doc.working_time_per_weekday?.length) {
frm.trigger("prefill_working_days");
}

for (const row of frm.doc.working_time_per_weekday) {
frappe.model.set_value(
row.doctype,
row.name,
"working_time",
frm.doc.working_time_per_week /
frm.doc.working_time_per_weekday.length
);
}
},
prefill_working_days(frm) {
frm.clear_table("working_time_per_weekday");
const working_days = frm
.get_docfield("working_time_per_weekday", "weekday")
.options.split("\n")
.slice(0, 5);
for (const day of working_days) {
frm.add_child("working_time_per_weekday", { weekday: day });
}
frm.refresh_field("working_time_per_weekday");
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2024-10-15 10:55:46.902007",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"salutation",
"first_name",
"last_name",
"birthday",
"birthplace",
"address",
"column_break_ryzy",
"employee",
"company",
"working_time_section",
"start_date",
"working_time_per_week",
"distribute",
"working_time_per_weekday",
"vacation_days_per_year",
"section_break_zspi",
"currency",
"remuneration",
"section_break_afys",
"amended_from"
],
"fields": [
{
"fieldname": "section_break_afys",
"fieldtype": "Section Break"
},
{
"fieldname": "amended_from",
"fieldtype": "Link",
"label": "Amended From",
"no_copy": 1,
"options": "Employment Contract",
"print_hide": 1,
"read_only": 1,
"search_index": 1
},
{
"fieldname": "salutation",
"fieldtype": "Link",
"label": "Salutation",
"options": "Salutation"
},
{
"fieldname": "first_name",
"fieldtype": "Data",
"label": "First Name"
},
{
"fieldname": "last_name",
"fieldtype": "Data",
"label": "Last Name"
},
{
"fieldname": "birthday",
"fieldtype": "Date",
"label": "Birthday"
},
{
"fieldname": "birthplace",
"fieldtype": "Data",
"label": "Birthplace"
},
{
"fieldname": "address",
"fieldtype": "Small Text",
"label": "Address"
},
{
"fieldname": "column_break_ryzy",
"fieldtype": "Column Break"
},
{
"allow_on_submit": 1,
"fieldname": "employee",
"fieldtype": "Link",
"label": "Employee",
"options": "Employee"
},
{
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
"options": "Company"
},
{
"fieldname": "working_time_section",
"fieldtype": "Section Break",
"label": "Working Time"
},
{
"fieldname": "start_date",
"fieldtype": "Date",
"label": "Start Date"
},
{
"fieldname": "working_time_per_week",
"fieldtype": "Duration",
"hide_days": 1,
"hide_seconds": 1,
"label": "Working Time per Week"
},
{
"fieldname": "working_time_per_weekday",
"fieldtype": "Table",
"label": "Working Time per Weekday",
"options": "Weekday Working Time"
},
{
"fieldname": "vacation_days_per_year",
"fieldtype": "Float",
"label": "Vacation Days per Year"
},
{
"fieldname": "section_break_zspi",
"fieldtype": "Section Break",
"label": "Remuneration"
},
{
"fieldname": "remuneration",
"fieldtype": "Table",
"label": "Remuneration",
"options": "Work Remuneration"
},
{
"fieldname": "distribute",
"fieldtype": "Button",
"label": "Distribute"
},
{
"fieldname": "currency",
"fieldtype": "Link",
"label": "Currency",
"options": "Currency"
}
],
"is_submittable": 1,
"links": [],
"modified": "2024-10-15 12:43:22.616668",
"modified_by": "Administrator",
"module": "ERPNext Germany",
"name": "Employment Contract",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"submit": 1,
"write": 1
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "HR Manager",
"share": 1,
"submit": 1,
"write": 1
},
{
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "HR User",
"share": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024, ALYF GmbH and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class EmploymentContract(Document):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024, ALYF GmbH and Contributors
# See license.txt

# import frappe
from frappe.tests.utils import FrappeTestCase


class TestEmploymentContract(FrappeTestCase):
pass
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2024-10-15 11:23:49.635058",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"weekday",
"working_time"
],
"fields": [
{
"fieldname": "weekday",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Weekday",
"options": "Monday\nTuesday\nWednesday\nThursday\nFriday\nSaturday\nSunday"
},
{
"fieldname": "working_time",
"fieldtype": "Duration",
"hide_days": 1,
"hide_seconds": 1,
"in_list_view": 1,
"label": "Working Time"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-10-15 11:25:04.292389",
"modified_by": "Administrator",
"module": "ERPNext Germany",
"name": "Weekday Working Time",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024, ALYF GmbH and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class WeekdayWorkingTime(Document):
pass
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2024-10-15 11:41:55.768742",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"description",
"gross_pay",
"frequency",
"effective_from"
],
"fields": [
{
"fieldname": "description",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Description"
},
{
"fieldname": "gross_pay",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Gross Pay",
"options": "currency"
},
{
"fieldname": "frequency",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Frequency",
"options": "Hourly\nMonthly\nOne-time"
},
{
"fieldname": "effective_from",
"fieldtype": "Date",
"in_list_view": 1,
"label": "Effective From"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2024-10-15 11:47:04.340876",
"modified_by": "Administrator",
"module": "ERPNext Germany",
"name": "Work Remuneration",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024, ALYF GmbH and contributors
# For license information, please see license.txt

# import frappe
from frappe.model.document import Document


class WorkRemuneration(Document):
pass