Skip to content

Commit

Permalink
Merge pull request #2001 from frappe/version-15-hotfix
Browse files Browse the repository at this point in the history
chore: release v15
  • Loading branch information
ruchamahabal authored Jul 27, 2024
2 parents b6171bd + a861f4f commit 4f64699
Show file tree
Hide file tree
Showing 20 changed files with 945 additions and 89 deletions.
2 changes: 2 additions & 0 deletions hrms/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,14 @@
"on_submit": [
"hrms.hr.doctype.expense_claim.expense_claim.update_payment_for_expense_claim",
"hrms.hr.doctype.full_and_final_statement.full_and_final_statement.update_full_and_final_statement_status",
"hrms.payroll.doctype.salary_withholding.salary_withholding.update_salary_withholding_payment_status",
],
"on_update_after_submit": "hrms.hr.doctype.expense_claim.expense_claim.update_payment_for_expense_claim",
"on_cancel": [
"hrms.hr.doctype.expense_claim.expense_claim.update_payment_for_expense_claim",
"hrms.payroll.doctype.salary_slip.salary_slip.unlink_ref_doc_from_salary_slip",
"hrms.hr.doctype.full_and_final_statement.full_and_final_statement.update_full_and_final_statement_status",
"hrms.payroll.doctype.salary_withholding.salary_withholding.update_salary_withholding_payment_status",
],
},
"Loan": {"validate": "hrms.hr.utils.validate_loan_repay_from_salary"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def before_submit(self):
self.validate_settlement("receivables")
self.validate_assets()

def on_cancel(self):
self.ignore_linked_doctypes = ("GL Entry",)

def validate_relieving_date(self):
if not self.relieving_date:
frappe.throw(
Expand Down Expand Up @@ -58,19 +61,20 @@ def validate_assets(self):

@frappe.whitelist()
def get_outstanding_statements(self):
if self.relieving_date:
if not len(self.get("payables", [])):
components = self.get_payable_component()
self.create_component_row(components, "payables")
if not len(self.get("receivables", [])):
components = self.get_receivable_component()
self.create_component_row(components, "receivables")
self.get_assets_statements()
else:
if not self.relieving_date:
frappe.throw(
_("Set Relieving Date for Employee: {0}").format(get_link_to_form("Employee", self.employee))
)

if not self.payables:
self.add_withheld_salary_slips()
components = self.get_payable_component()
self.create_component_row(components, "payables")
if not self.receivables:
components = self.get_receivable_component()
self.create_component_row(components, "receivables")
self.get_assets_statements()

def get_assets_statements(self):
if not len(self.get("assets_allocated", [])):
for data in self.get_assets_movement():
Expand Down Expand Up @@ -98,6 +102,30 @@ def set_totals(self):
self.precision("total_receivable_amount"),
)

def add_withheld_salary_slips(self):
salary_slips = frappe.get_all(
"Salary Slip",
filters={
"employee": self.employee,
"status": "Withheld",
"docstatus": ("!=", 2),
},
fields=["name", "net_pay"],
)

for slip in salary_slips:
self.append(
"payables",
{
"status": "Unsettled",
"component": "Salary Slip",
"reference_document_type": "Salary Slip",
"reference_document": slip.name,
"amount": slip.net_pay,
"paid_via_salary_slip": 1,
},
)

def create_component_row(self, components, component_type):
for component in components:
self.append(
Expand All @@ -111,18 +139,17 @@ def create_component_row(self, components, component_type):

def get_payable_component(self):
return [
"Salary Slip",
"Gratuity",
"Expense Claim",
"Bonus",
"Leave Encashment",
]

def get_receivable_component(self):
return [
"Loan",
"Employee Advance",
]
receivables = ["Employee Advance"]
if "lending" in frappe.get_installed_apps():
receivables.append("Loan")
return receivables

def get_assets_movement(self):
asset_movements = frappe.get_all(
Expand Down Expand Up @@ -280,4 +307,6 @@ def update_full_and_final_statement_status(doc, method=None):

for entry in doc.accounts:
if entry.reference_type == "Full and Final Statement":
frappe.db.set_value("Full and Final Statement", entry.reference_name, "status", status)
fnf = frappe.get_doc("Full and Final Statement", entry.reference_name)
fnf.db_set("status", status)
fnf.notify_update()
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ def setup_fnf(self):

def test_check_bootstraped_data_asset_movement_and_jv_creation(self):
payables_bootstraped_component = [
"Salary Slip",
"Gratuity",
"Expense Claim",
"Bonus",
"Leave Encashment",
]

receivable_bootstraped_component = ["Loan", "Employee Advance"]
receivable_bootstraped_component = ["Employee Advance", "Loan"]

# checking payables and receivables bootstraped value
self.assertEqual([payable.component for payable in self.fnf.payables], payables_bootstraped_component)
Expand Down
2 changes: 1 addition & 1 deletion hrms/hr/doctype/leave_application/leave_application.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ frappe.ui.form.on("Leave Application", {
frm.perm[0].submit &&
!frm.is_dirty() &&
!frm.is_new() &&
!frappe.model.has_workflow(this.doctype) &&
!frappe.model.has_workflow(frm.doctype) &&
frm.doc.docstatus === 0
) {
frm.set_intro(__("Submit this Leave Application to confirm."));
Expand Down
7 changes: 6 additions & 1 deletion hrms/overrides/dashboard_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ def get_dashboard_for_employee(data):
},
{
"label": _("Exit"),
"items": ["Employee Separation", "Exit Interview", "Full and Final Statement"],
"items": [
"Employee Separation",
"Exit Interview",
"Full and Final Statement",
"Salary Withholding",
],
},
{"label": _("Shift"), "items": ["Shift Request", "Shift Assignment"]},
{"label": _("Expense"), "items": ["Expense Claim", "Travel Request", "Employee Advance"]},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
"employee_name",
"column_break_3",
"department",
"designation"
"designation",
"is_salary_withheld"
],
"fields": [
{
"columns": 2,
"fieldname": "employee",
"fieldtype": "Link",
"in_list_view": 1,
Expand Down Expand Up @@ -47,11 +49,19 @@
"in_list_view": 1,
"label": "Designation",
"read_only": 1
},
{
"columns": 2,
"default": "0",
"fieldname": "is_salary_withheld",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Is Salary Withheld"
}
],
"istable": 1,
"links": [],
"modified": "2020-12-17 15:43:29.542977",
"modified": "2024-07-22 13:28:40.573807",
"modified_by": "Administrator",
"module": "Payroll",
"name": "Payroll Employee Detail",
Expand Down
28 changes: 13 additions & 15 deletions hrms/payroll/doctype/payroll_entry/payroll_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,16 @@ frappe.ui.form.on("Payroll Entry", {
},

add_bank_entry_button: function (frm) {
frappe.call({
method: "hrms.payroll.doctype.payroll_entry.payroll_entry.payroll_entry_has_bank_entries",
args: {
name: frm.doc.name,
payroll_payable_account: frm.doc.payroll_payable_account,
},
callback: function (r) {
if (r.message && !r.message.submitted) {
frm.add_custom_button(__("Make Bank Entry"), function () {
make_bank_entry(frm);
}).addClass("btn-primary");
}
},
frm.call("has_bank_entries").then((r) => {
if (!r.message.has_bank_entries) {
frm.add_custom_button(__("Make Bank Entry"), function () {
make_bank_entry(frm);
}).addClass("btn-primary");
} else if (!r.message.has_bank_entries_for_withheld_salaries) {
frm.add_custom_button(__("Release Withheld Salaries"), function () {
make_bank_entry(frm, (for_withheld_salaries = 1));
}).addClass("btn-primary");
}
});
},

Expand Down Expand Up @@ -421,15 +418,16 @@ const submit_salary_slip = function (frm) {
);
};

let make_bank_entry = function (frm) {
var doc = frm.doc;
let make_bank_entry = function (frm, for_withheld_salaries = 0) {
const doc = frm.doc;
if (doc.payment_account) {
return frappe.call({
method: "run_doc_method",
args: {
method: "make_bank_entry",
dt: "Payroll Entry",
dn: frm.doc.name,
args: { for_withheld_salaries: for_withheld_salaries },
},
callback: function () {
frappe.set_route("List", "Journal Entry", {
Expand Down
Loading

0 comments on commit 4f64699

Please sign in to comment.