Skip to content

Commit

Permalink
Merge pull request #1475 from frappe/version-14-hotfix
Browse files Browse the repository at this point in the history
chore: release v14
  • Loading branch information
ruchamahabal authored Mar 6, 2024
2 parents 5809431 + 7c619f0 commit de8f2b2
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 874 deletions.
6 changes: 4 additions & 2 deletions hrms/hr/doctype/employee_advance/employee_advance.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
"fieldname": "return_amount",
"fieldtype": "Currency",
"label": "Returned Amount",
"no_copy": 1,
"options": "currency",
"read_only": 1
},
Expand All @@ -177,6 +178,7 @@
"fieldname": "pending_amount",
"fieldtype": "Currency",
"label": "Pending Amount",
"no_copy": 1,
"options": "currency",
"read_only": 1
},
Expand All @@ -200,7 +202,7 @@
],
"is_submittable": 1,
"links": [],
"modified": "2023-03-21 18:24:06.416439",
"modified": "2024-02-26 14:42:01.853329",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee Advance",
Expand Down Expand Up @@ -269,4 +271,4 @@
],
"title_field": "employee_name",
"track_changes": 1
}
}
3 changes: 2 additions & 1 deletion hrms/hr/doctype/staffing_plan/staffing_plan.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"fieldname": "total_estimated_budget",
"fieldtype": "Currency",
"label": "Total Estimated Budget",
"options": "Company:company:default_currency",
"read_only": 1
},
{
Expand All @@ -89,7 +90,7 @@
],
"is_submittable": 1,
"links": [],
"modified": "2023-01-11 18:06:32.989641",
"modified": "2024-02-23 18:20:51.305004",
"modified_by": "Administrator",
"module": "HR",
"name": "Staffing Plan",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"actions": [],
"creation": "2018-04-13 18:04:20.978931",
"doctype": "DocType",
"editable_grid": 1,
Expand Down Expand Up @@ -33,7 +34,8 @@
"fieldname": "estimated_cost_per_position",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Estimated Cost Per Position"
"label": "Estimated Cost Per Position",
"options": "Company:company:default_currency"
},
{
"fieldname": "column_break_5",
Expand Down Expand Up @@ -62,11 +64,13 @@
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Total Estimated Cost",
"options": "Company:company:default_currency",
"read_only": 1
}
],
"istable": 1,
"modified": "2019-06-24 18:40:37.140178",
"links": [],
"modified": "2024-02-23 18:21:52.585104",
"modified_by": "Administrator",
"module": "HR",
"name": "Staffing Plan Detail",
Expand All @@ -75,5 +79,6 @@
"quick_entry": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
35 changes: 22 additions & 13 deletions hrms/overrides/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ def delete_company_fixtures():
except (ImportError, AttributeError):
# regional file or method does not exist
pass
except Exception:
frappe.log_error("Unable to delete country fixtures for HRMS")
frappe.throw(
_("Failed to delete defaults for country {0}. Please contact support.").format(
frappe.bold(country)
)
)
except Exception as e:
frappe.log_error("Unable to delete country fixtures for Frappe HR")
msg = _("Failed to delete defaults for country {0}.").format(frappe.bold(country))
msg += "<br><br>" + _("{0}: {1}").format(frappe.bold(_("Error")), get_error_message(e))
frappe.throw(msg, title=_("Country Fixture Deletion Failed"))


def run_regional_setup(country):
Expand All @@ -46,13 +44,24 @@ def run_regional_setup(country):
frappe.get_attr(module_name)()
except ImportError:
pass
except Exception as e:
frappe.log_error("Unable to setup country fixtures for Frappe HR")
msg = _("Failed to setup defaults for country {0}.").format(frappe.bold(country))
msg += "<br><br>" + _("{0}: {1}").format(frappe.bold(_("Error")), get_error_message(e))
frappe.throw(msg, title=_("Country Setup failed"))


def get_error_message(error) -> str:
try:
message_log = frappe.message_log.pop() if frappe.message_log else str(error)
if isinstance(message_log, str):
error_message = json.loads(message_log).get("message")
else:
error_message = message_log.get("message")
except Exception:
frappe.log_error("Unable to setup country fixtures for HRMS")
frappe.throw(
_("Failed to setup defaults for country {0}. Please contact support.").format(
frappe.bold(country)
)
)
error_message = message_log

return error_message


def make_salary_components(country):
Expand Down
8 changes: 7 additions & 1 deletion hrms/overrides/employee_payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ def get_valid_reference_doctypes(self):
return ("Expense Claim", "Journal Entry", "Employee Advance", "Gratuity")

def set_missing_ref_details(
self, force: bool = False, update_ref_details_only_for: list | None = None
self,
force: bool = False,
update_ref_details_only_for: list | None = None,
ref_exchange_rate: float | None = None,
) -> None:
for d in self.get("references"):
if d.allocated_amount:
Expand All @@ -41,6 +44,9 @@ def set_missing_ref_details(
d.reference_doctype, d.reference_name, self.party_account_currency
)

if ref_exchange_rate:
ref_details.update({"exchange_rate": ref_exchange_rate})

for field, value in ref_details.items():
if d.exchange_gain_loss:
# for cases where gain/loss is booked into invoice
Expand Down
2 changes: 1 addition & 1 deletion hrms/payroll/doctype/payroll_entry/payroll_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ frappe.ui.form.on('Payroll Entry', {
'currency', 'department', 'branch', 'designation', 'salary_slip_based_on_timesheet'];

fields.forEach(field => {
if (frm.doc[field]) {
if (frm.doc[field] || frm.doc[field] === 0) {
filters[field] = frm.doc[field];
}
});
Expand Down
13 changes: 9 additions & 4 deletions hrms/payroll/doctype/salary_slip/test_salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,21 +519,26 @@ def test_consider_marked_attendance_on_holidays_with_unmarked_attendance(self):
joining_date = add_days(month_start_date, 3)

emp_id = make_employee(
"test_salary_slip_with_holidays_included@salary.com",
"test_salary_slip_with_holidays_included1@salary.com",
status="Active",
joining_date=joining_date,
date_of_joining=joining_date,
relieving_date=None,
)

for days in range(date_diff(month_end_date, add_days(joining_date, 1)) + 1):
for days in range(date_diff(month_end_date, joining_date) + 1):
date = add_days(joining_date, days)
if not is_holiday("Salary Slip Test Holiday List", date):
mark_attendance(emp_id, date, "Present", ignore_validate=True)

# mark absent on holiday
first_sunday = get_first_sunday(for_date=getdate())
first_sunday = get_first_sunday(for_date=joining_date, find_after_for_date=True)
mark_attendance(emp_id, first_sunday, "Absent", ignore_validate=True)

# unmarked attendance for a day
frappe.db.delete(
"Attendance", {"employee": emp_id, "attendance_date": add_days(first_sunday, 1)}
)

ss = make_employee_salary_slip(
emp_id,
"Monthly",
Expand Down
9 changes: 4 additions & 5 deletions hrms/regional/india/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ def add_custom_roles_for_reports():
"Income Tax Deductions",
):
if not frappe.db.get_value("Custom Role", dict(report=report_name)):
frappe.get_doc(
doc = frappe.new_doc("Custom Role")
doc.update(
dict(
doctype="Custom Role",
report=report_name,
roles=[dict(role="HR User"), dict(role="HR Manager"), dict(role="Employee")],
)
).insert()
).insert(ignore_permissions=True)


def create_gratuity_rule_for_india():
Expand All @@ -272,5 +272,4 @@ def create_gratuity_rule_for_india():
],
}
)
rule.flags.ignore_mandatory = True
rule.save()
rule.insert(ignore_permissions=True, ignore_mandatory=True)
4 changes: 1 addition & 3 deletions hrms/regional/united_arab_emirates/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def create_gratuity_rules_for_uae():
docs = get_gratuity_rules()
for d in docs:
doc = frappe.get_doc(d)
doc.flags.ignore_mandatory = True
doc.flags.ignore_permissions = True
doc.insert(ignore_if_duplicate=True)
doc.insert(ignore_if_duplicate=True, ignore_permissions=True, ignore_mandatory=True)


def get_gratuity_rules():
Expand Down
2 changes: 1 addition & 1 deletion hrms/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


def after_install():
create_custom_fields(get_custom_fields())
create_custom_fields(get_custom_fields(), ignore_validate=True)
make_fixtures()
setup_notifications()
update_hr_defaults()
Expand Down
10 changes: 9 additions & 1 deletion hrms/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,17 @@ def set_defaults():
)


def get_first_sunday(holiday_list="Salary Slip Test Holiday List", for_date=None):
def get_first_sunday(
holiday_list="Salary Slip Test Holiday List", for_date=None, find_after_for_date=False
):
date = for_date or getdate()
month_start_date = get_first_day(date)

if find_after_for_date:
# explictly find first sunday after for_date
# useful when DOJ is after the month start
month_start_date = date

month_end_date = get_last_day(date)
first_sunday = frappe.db.sql(
"""
Expand Down
Loading

0 comments on commit de8f2b2

Please sign in to comment.