From 819c3b1bf698827898d32262dc71eb6ef5a6097f Mon Sep 17 00:00:00 2001 From: Ranjith Date: Tue, 15 May 2018 19:17:31 +0530 Subject: [PATCH] Retention Bonus - menu, validate --- erpnext/config/hr.py | 4 ++++ .../hr/doctype/retention_bonus/retention_bonus.js | 9 +++++++++ .../hr/doctype/retention_bonus/retention_bonus.py | 12 +++++++----- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/erpnext/config/hr.py b/erpnext/config/hr.py index c2ccbd3905..ef28ee8ff0 100644 --- a/erpnext/config/hr.py +++ b/erpnext/config/hr.py @@ -106,6 +106,10 @@ def get_data(): "type": "doctype", "name": "Employee Incentive", }, + { + "type": "doctype", + "name": "Retention Bonus", + }, ] }, { diff --git a/erpnext/hr/doctype/retention_bonus/retention_bonus.js b/erpnext/hr/doctype/retention_bonus/retention_bonus.js index b481af0b6e..58f6b53604 100644 --- a/erpnext/hr/doctype/retention_bonus/retention_bonus.js +++ b/erpnext/hr/doctype/retention_bonus/retention_bonus.js @@ -2,6 +2,15 @@ // For license information, please see license.txt frappe.ui.form.on('Retention Bonus', { + setup: function(frm) { + frm.set_query("employee", function() { + return { + filters: { + "status": "Active" + } + }; + }); + }, refresh: function(frm) { } diff --git a/erpnext/hr/doctype/retention_bonus/retention_bonus.py b/erpnext/hr/doctype/retention_bonus/retention_bonus.py index 361c9bdb0a..20d4c13f19 100644 --- a/erpnext/hr/doctype/retention_bonus/retention_bonus.py +++ b/erpnext/hr/doctype/retention_bonus/retention_bonus.py @@ -5,10 +5,12 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document +from frappe import _ +from frappe.utils import getdate class RetentionBonus(Document): - def on_submit(self): - pass - - def on_cancel(self): - pass + def validate(self): + if frappe.get_value("Employee", self.employee, "status") == "Left": + frappe.throw(_("Cannot create Retention Bonus for left Employees")) + if getdate(self.bonus_payment_date) < getdate(): + frappe.throw(_("Bonus Payment Date cannot be a past date"))