Skip to content

Commit

Permalink
feat: unlink payment on cancelation of employee advance
Browse files Browse the repository at this point in the history
  • Loading branch information
l0gesh29 committed Oct 17, 2024
1 parent cb541e4 commit 5da95a3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
11 changes: 11 additions & 0 deletions hrms/hr/doctype/employee_advance/employee_advance.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def validate(self):

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

def on_update(self):
Expand Down Expand Up @@ -175,6 +176,16 @@ def set_pending_amount(self):
)
).run()[0][0] or 0.0

def check_linked_payment_entry(self):
from erpnext.accounts.utils import (
remove_ref_doc_link_from_pe,
update_accounting_ledgers_after_reference_removal,
)

if frappe.db.get_single_value("HR Settings", "unlink_payment_on_cancellation_of_employee_advance"):
remove_ref_doc_link_from_pe(self.doctype, self.name)
update_accounting_ledgers_after_reference_removal(self.doctype, self.name)


@frappe.whitelist()
def make_bank_entry(dt, dn):
Expand Down
17 changes: 15 additions & 2 deletions hrms/hr/doctype/hr_settings/hr_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
"exit_questionnaire_notification_template",
"attendance_settings_section",
"allow_employee_checkin_from_mobile_app",
"allow_geolocation_tracking"
"allow_geolocation_tracking",
"unlink_payment_section",
"unlink_payment_on_cancellation_of_employee_advance"
],
"fields": [
{
Expand Down Expand Up @@ -316,13 +318,24 @@
"fieldname": "attendance_settings_section",
"fieldtype": "Section Break",
"label": "Attendance Settings"
},
{
"fieldname": "unlink_payment_section",
"fieldtype": "Section Break",
"label": "Unlink Payment"
},
{
"default": "0",
"fieldname": "unlink_payment_on_cancellation_of_employee_advance",
"fieldtype": "Check",
"label": " Unlink Payment on Cancellation of Employee Advance"
}
],
"icon": "fa fa-cog",
"idx": 1,
"issingle": 1,
"links": [],
"modified": "2024-06-26 15:20:17.802079",
"modified": "2024-09-29 12:49:16.175079",
"modified_by": "Administrator",
"module": "HR",
"name": "HR Settings",
Expand Down

0 comments on commit 5da95a3

Please sign in to comment.