Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fetch leave encashment amount from Salary Structure Assignment #2296

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion hrms/hr/doctype/leave_encashment/leave_encashment.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,16 @@ def set_encashment_amount(self):
self.set_salary_structure()

per_day_encashment = frappe.db.get_value(
"Salary Structure", self._salary_structure, "leave_encashment_amount_per_day"
"Salary Structure Assignment",
{"employee": self.employee, "docstatus": 1, "from_date": ("<=", self.encashment_date)},
"leave_encashment_amount_per_day",
order_by="from_date desc",
)
if not per_day_encashment:
# for old records where leave encashment amount is defined in salary structure
per_day_encashment = frappe.db.get_value(
"Salary Structure", self._salary_structure, "leave_encashment_amount_per_day"
)
self.encashment_amount = self.encashment_days * per_day_encashment if per_day_encashment > 0 else 0

def get_leave_allocation(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"currency",
"section_break_7",
"base",
"leave_encashment_amount_per_day",
"column_break_9",
"variable",
"amended_from",
Expand Down Expand Up @@ -206,6 +207,13 @@
"fieldtype": "Section Break",
"hidden": 1,
"label": "Opening Balances"
},
{
"fetch_from": "salary_structure.leave_encashment_amount_per_day",
"fetch_if_empty": 1,
"fieldname": "leave_encashment_amount_per_day",
"fieldtype": "Currency",
"label": "Leave Encashment Amount Per Day"
}
],
"is_submittable": 1,
Expand Down Expand Up @@ -263,4 +271,4 @@
"states": [],
"title_field": "employee_name",
"track_changes": 1
}
}
Loading