Skip to content
Merged
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
26 changes: 26 additions & 0 deletions hrms/hr/doctype/job_requisition/job_requisition.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,30 @@ frappe.ui.form.on("Job Requisition", {
frm.page.set_inner_btn_group_as_primary(__("Actions"));
}
},
before_save: function (frm) {
frm.trigger("handle_duplicate_check");
},
handle_duplicate_check: function (frm) {
if (!frm.is_new() || frm.duplicate_confirmed) return;
frappe.validated = false;

frm.call("check_duplicate_job_requisition").then((r) => {
if (!r.message) {
frm.duplicate_confirmed = true;
frm.save();
return;
}

frappe.confirm(
__(
"A Job Requisition already exists for {0} requested by {1} for the same department.<br> Do you want to continue?",
[frm.doc.designation.bold(), frm.doc.requested_by.bold()],
),
() => {
frm.duplicate_confirmed = true;
frm.save();
},
);
});
},
});
24 changes: 7 additions & 17 deletions hrms/hr/doctype/job_requisition/job_requisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ class JobRequisition(Document):
# end: auto-generated types

def validate(self):
self.validate_duplicates()
self.set_time_to_fill()

def validate_duplicates(self):
duplicate = frappe.db.exists(
def set_time_to_fill(self):
if self.status == "Filled" and self.completed_on:
self.time_to_fill = time_diff_in_seconds(self.completed_on, self.posting_date)

@frappe.whitelist()
def check_duplicate_job_requisition(self):
return frappe.db.exists(
"Job Requisition",
{
"designation": self.designation,
Expand All @@ -52,20 +56,6 @@ def validate_duplicates(self):
},
)

if duplicate:
frappe.throw(
_("A Job Requisition for {0} requested by {1} already exists: {2}").format(
frappe.bold(self.designation),
frappe.bold(self.requested_by),
get_link_to_form("Job Requisition", duplicate),
),
title=_("Duplicate Job Requisition"),
)

def set_time_to_fill(self):
if self.status == "Filled" and self.completed_on:
self.time_to_fill = time_diff_in_seconds(self.completed_on, self.posting_date)

@frappe.whitelist()
def associate_job_opening(self, job_opening: str) -> None:
frappe.db.set_value(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"engine": "InnoDB",
"field_order": [
"max_amount",
"is_active"
"is_active",
"description"
],
"fields": [
{
Expand All @@ -23,10 +24,15 @@
"fieldname": "is_active",
"fieldtype": "Check",
"label": "Is Active"
},
{
"fieldname": "description",
"fieldtype": "Small Text",
"label": "Description"
}
],
"links": [],
"modified": "2024-03-27 13:09:41.659098",
"modified": "2026-05-27 00:00:00.000000",
"modified_by": "Administrator",
"module": "Payroll",
"name": "Employee Tax Exemption Category",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class EmployeeTaxExemptionCategory(Document):
if TYPE_CHECKING:
from frappe.types import DF

description: DF.SmallText | None
is_active: DF.Check
max_amount: DF.Currency
# end: auto-generated types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"field_order": [
"exemption_category",
"max_amount",
"is_active"
"is_active",
"description"
],
"fields": [
{
Expand All @@ -35,10 +36,15 @@
"fieldname": "is_active",
"fieldtype": "Check",
"label": "Is Active"
},
{
"fieldname": "description",
"fieldtype": "Small Text",
"label": "Description"
}
],
"links": [],
"modified": "2024-03-27 13:09:42.420982",
"modified": "2026-05-27 00:00:00.000000",
"modified_by": "Administrator",
"module": "Payroll",
"name": "Employee Tax Exemption Sub Category",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class EmployeeTaxExemptionSubCategory(Document):
if TYPE_CHECKING:
from frappe.types import DF

description: DF.SmallText | None
exemption_category: DF.Link
is_active: DF.Check
max_amount: DF.Currency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import frappe
from frappe import _
from frappe.utils import flt, get_link_to_form
from frappe.utils.formatters import format_value
from frappe.utils.formatters import fmt_money
from frappe.utils.jinja import render_template

from hrms.payroll.doctype.salary_structure.salary_structure import make_salary_slip
Expand Down Expand Up @@ -201,7 +201,7 @@ def indent_salary_components(self):
component["indent"] = 1

def format_currency(self, amount):
return format_value(amount, currency=self.currency)
return fmt_money(amount, precision=2, currency=self.currency)

def get_columns(self) -> list[dict]:
"""Return columns for the report.
Expand Down
Loading