feat: add link to policy
diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.js b/erpnext/hr/doctype/leave_allocation/leave_allocation.js
index 489db67..50dbaad 100755
--- a/erpnext/hr/doctype/leave_allocation/leave_allocation.js
+++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.js
@@ -22,10 +22,19 @@
},
refresh: function(frm) {
- if(frm.doc.docstatus == 1){
- frm.add_custom_button('Expire Allocation', function() {
+ if(frm.doc.docstatus === 1 && frm.doc.status === "Active") {
+ // expire current allocation
+ frm.add_custom_button(__('Expire Allocation'), function() {
frm.trigger("expire_allocation");
});
+
+ // opens leave balance report for employee
+ frm.add_custom_button(__('Check Leave Balance'), function() {
+ frappe.route_options = {
+ employee: frm.doc.employee,
+ };
+ frappe.set_route("query-report", "Employee Leave Balance");
+ });
}
},
diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.json b/erpnext/hr/doctype/leave_allocation/leave_allocation.json
index 1d6307c..125fb31 100644
--- a/erpnext/hr/doctype/leave_allocation/leave_allocation.json
+++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.json
@@ -606,6 +606,39 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "fieldname": "status",
+ "fieldtype": "Select",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 1,
+ "label": "Status",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Active\nExpired",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"fieldname": "amended_from",
"fieldtype": "Link",
"hidden": 0,
@@ -711,7 +744,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2019-05-30 11:28:09.360525",
+ "modified": "2019-05-31 11:28:09.360525",
"modified_by": "Administrator",
"module": "HR",
"name": "Leave Allocation",
diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.py b/erpnext/hr/doctype/leave_allocation/leave_allocation.py
index 0b2972e..b402e90 100755
--- a/erpnext/hr/doctype/leave_allocation/leave_allocation.py
+++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.py
@@ -183,13 +183,15 @@
if flt(leaves) > 0:
args = dict(
leaves=leaves * -1,
- from_date=ref_doc.from_date,
- to_date=ref_doc.from_date,
+ from_date=ref_doc.to_date,
+ to_date=ref_doc.to_date,
is_carry_forward=0,
is_expired=1
)
create_leave_ledger_entry(ref_doc, args)
+ frappe.db.set_value("Leave Allocation", ref_doc.name, "status", "Expired")
+
def get_unused_leaves(employee, leave_type, date):
return frappe.db.get_value("Leave Ledger Entry", filters={
"to_date": ("<=", date),
diff --git a/erpnext/hr/doctype/leave_policy/leave_policy_dashboard.py b/erpnext/hr/doctype/leave_policy/leave_policy_dashboard.py
index f97d285..48a2045 100644
--- a/erpnext/hr/doctype/leave_policy/leave_policy_dashboard.py
+++ b/erpnext/hr/doctype/leave_policy/leave_policy_dashboard.py
@@ -12,6 +12,9 @@
},
{
'items': ['Employee Grade']
- }
+ },
+ {
+ 'items': ['Leave Allocation']
+ },
]
}
\ No newline at end of file