feat : Leave type with partial payment (#23173)

* feat: Partially paid Leaves

* feat: some importatnt validation

* fix: requested changes

* fix: requested changes

* fix: travis, sider, codacy

* fix: changes requested

* test: Partially Paid Leaves
This commit is contained in:
Anurag Mishra
2020-11-25 16:00:15 +05:30
committed by GitHub
parent 90e33e53fd
commit f32cff1080
8 changed files with 117 additions and 48 deletions

View File

@@ -672,10 +672,10 @@
"oldfieldtype": "Date"
},
{
"depends_on": "eval:doc.status == \"Left\"",
"fieldname": "relieving_date",
"fieldtype": "Date",
"label": "Relieving Date",
"mandatory_depends_on": "eval:doc.status == \"Left\"",
"oldfieldname": "relieving_date",
"oldfieldtype": "Date"
},
@@ -822,7 +822,7 @@
"idx": 24,
"image_field": "image",
"links": [],
"modified": "2020-10-06 15:58:23.805489",
"modified": "2020-10-16 14:41:10.580897",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee",

View File

@@ -130,8 +130,7 @@ class LeaveApplication(Document):
if self.status == "Approved":
for dt in daterange(getdate(self.from_date), getdate(self.to_date)):
date = dt.strftime("%Y-%m-%d")
status = "Half Day" if getdate(date) == getdate(self.half_day_date) else "On Leave"
status = "Half Day" if self.half_day_date and getdate(date) == getdate(self.half_day_date) else "On Leave"
attendance_name = frappe.db.exists('Attendance', dict(employee = self.employee,
attendance_date = date, docstatus = ('!=', 2)))
@@ -293,7 +292,8 @@ class LeaveApplication(Document):
def set_half_day_date(self):
if self.from_date == self.to_date and self.half_day == 1:
self.half_day_date = self.from_date
elif self.half_day == 0:
if self.half_day == 0:
self.half_day_date = None
def notify_employee(self):

View File

@@ -15,6 +15,8 @@
"column_break_3",
"is_carry_forward",
"is_lwp",
"is_ppl",
"fraction_of_daily_salary_per_leave",
"is_optional_leave",
"allow_negative",
"include_holiday",
@@ -77,6 +79,7 @@
},
{
"default": "0",
"depends_on": "eval:doc.is_ppl == 0",
"fieldname": "is_lwp",
"fieldtype": "Check",
"label": "Is Leave Without Pay"
@@ -183,12 +186,26 @@
{
"fieldname": "column_break_22",
"fieldtype": "Column Break"
},
{
"default": "0",
"depends_on": "eval:doc.is_lwp == 0",
"fieldname": "is_ppl",
"fieldtype": "Check",
"label": "Is Partially Paid Leave"
},
{
"depends_on": "eval:doc.is_ppl == 1",
"fieldname": "fraction_of_daily_salary_per_leave",
"fieldtype": "Float",
"label": "Fraction of Daily Salary per Leave",
"mandatory_depends_on": "eval:doc.is_ppl == 1"
}
],
"icon": "fa fa-flag",
"idx": 1,
"links": [],
"modified": "2019-12-12 12:48:37.780254",
"modified": "2020-08-26 14:04:54.318687",
"modified_by": "Administrator",
"module": "HR",
"name": "Leave Type",

View File

@@ -21,3 +21,9 @@ class LeaveType(Document):
leave_allocation = [l['name'] for l in leave_allocation]
if leave_allocation:
frappe.throw(_('Leave application is linked with leave allocations {0}. Leave application cannot be set as leave without pay').format(", ".join(leave_allocation))) #nosec
if self.is_lwp and self.is_ppl:
frappe.throw(_("Leave Type can be either without pay or partial pay"))
if self.is_ppl and (self.fraction_of_daily_salary_per_leave < 0 or self.fraction_of_daily_salary_per_leave > 1):
frappe.throw(_("The fraction of Daily Salary per Leave should be between 0 and 1"))

View File

@@ -18,9 +18,14 @@ def create_leave_type(**args):
"allow_encashment": args.allow_encashment or 0,
"is_earned_leave": args.is_earned_leave or 0,
"is_lwp": args.is_lwp or 0,
"is_ppl":args.is_ppl or 0,
"is_carry_forward": args.is_carry_forward or 0,
"expire_carry_forwarded_leaves_after_days": args.expire_carry_forwarded_leaves_after_days or 0,
"encashment_threshold_days": args.encashment_threshold_days or 5,
"earning_component": "Leave Encashment"
})
if leave_type.is_ppl:
leave_type.fraction_of_daily_salary_per_leave = args.fraction_of_daily_salary_per_leave or 0.5
return leave_type