Skip to content

Commit

Permalink
Merge pull request #2455 from frappe/version-15-hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal authored Nov 26, 2024
2 parents 6f7a7b5 + 7f5e969 commit 74dfdbc
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 11 deletions.
2 changes: 1 addition & 1 deletion hrms/hr/doctype/employee_advance/employee_advance.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def validate(self):
self.set_pending_amount()

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

Expand Down
1 change: 1 addition & 0 deletions hrms/hr/doctype/interview/interview.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ frappe.ui.form.on("Interview", {
interview_round: frm.doc.interview_round || "",
},
callback: function (r) {
frm.clear_table("interview_details");
r.message.forEach((interviewer) =>
frm.add_child("interview_details", interviewer),
);
Expand Down
23 changes: 20 additions & 3 deletions hrms/hr/report/vehicle_expenses/vehicle_expenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ frappe.query_reports["Vehicle Expenses"] = {
options: ["Fiscal Year", "Date Range"],
default: ["Fiscal Year"],
reqd: 1,
on_change: () => {
let filter_based_on = frappe.query_report.get_filter_value("filter_based_on");

if (filter_based_on == "Fiscal Year") {
set_reqd_filter("fiscal_year", true);
set_reqd_filter("from_date", false);
set_reqd_filter("to_date", false);
}
if (filter_based_on == "Date Range") {
set_reqd_filter("fiscal_year", false);
set_reqd_filter("from_date", true);
set_reqd_filter("to_date", true);
}
},
},
{
fieldname: "fiscal_year",
Expand All @@ -17,21 +31,18 @@ frappe.query_reports["Vehicle Expenses"] = {
options: "Fiscal Year",
default: frappe.defaults.get_user_default("fiscal_year"),
depends_on: "eval: doc.filter_based_on == 'Fiscal Year'",
reqd: 1,
},
{
fieldname: "from_date",
label: __("From Date"),
fieldtype: "Date",
reqd: 1,
depends_on: "eval: doc.filter_based_on == 'Date Range'",
default: frappe.datetime.add_months(frappe.datetime.nowdate(), -12),
},
{
fieldname: "to_date",
label: __("To Date"),
fieldtype: "Date",
reqd: 1,
depends_on: "eval: doc.filter_based_on == 'Date Range'",
default: frappe.datetime.nowdate(),
},
Expand All @@ -49,3 +60,9 @@ frappe.query_reports["Vehicle Expenses"] = {
},
],
};

function set_reqd_filter(fieldname, is_reqd) {
let filter = frappe.query_report.get_filter(fieldname);
filter.df.reqd = is_reqd;
filter.refresh();
}
4 changes: 3 additions & 1 deletion hrms/payroll/doctype/salary_structure/salary_structure.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
"search_index": 1
},
{
"allow_on_submit": 1,
"fetch_from": "company.default_letter_head",
"fetch_if_empty": 1,
"fieldname": "letter_head",
"fieldtype": "Link",
"label": "Letter Head",
Expand Down Expand Up @@ -240,7 +242,7 @@
"idx": 1,
"is_submittable": 1,
"links": [],
"modified": "2024-02-06 13:06:59.579135",
"modified": "2024-11-22 11:17:28.384386",
"modified_by": "Administrator",
"module": "Payroll",
"name": "Salary Structure",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ def validate(self):
if not self.get("payroll_cost_centers"):
self.set_payroll_cost_centers()

self.validate_cost_center_distribution()
self.validate_cost_centers()
self.warn_about_missing_opening_entries()

def on_update_after_submit(self):
self.validate_cost_centers()

def validate_dates(self):
joining_date, relieving_date = frappe.db.get_value(
"Employee", self.employee, ["date_of_joining", "relieving_date"]
Expand Down Expand Up @@ -124,11 +127,25 @@ def get_payroll_cost_center(self):

return payroll_cost_center

def validate_cost_center_distribution(self):
if self.get("payroll_cost_centers"):
total_percentage = sum([flt(d.percentage) for d in self.get("payroll_cost_centers", [])])
if total_percentage != 100:
frappe.throw(_("Total percentage against cost centers should be 100"))
def validate_cost_centers(self):
if not self.get("payroll_cost_centers"):
return

total_percentage = 0
for entry in self.payroll_cost_centers:
company = frappe.db.get_value("Cost Center", entry.cost_center, "company")
if company != self.company:
frappe.throw(
_("Row {0}: Cost Center {1} does not belong to Company {2}").format(
entry.idx, frappe.bold(entry.cost_center), frappe.bold(self.company)
),
title=_("Invalid Cost Center"),
)

total_percentage += flt(entry.percentage)

if total_percentage != 100:
frappe.throw(_("Total percentage against cost centers should be 100"))

def warn_about_missing_opening_entries(self):
if (
Expand Down

0 comments on commit 74dfdbc

Please sign in to comment.