From 0e31089af69e2d3166631657f3b2b3bba020198e Mon Sep 17 00:00:00 2001 From: Himanshu Date: Thu, 16 May 2019 10:35:02 +0530 Subject: [PATCH] validate: if additional salary exists (#17529) --- erpnext/hr/doctype/additional_salary/additional_salary.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/hr/doctype/additional_salary/additional_salary.py b/erpnext/hr/doctype/additional_salary/additional_salary.py index 9ca1260fe0..043f0df78d 100644 --- a/erpnext/hr/doctype/additional_salary/additional_salary.py +++ b/erpnext/hr/doctype/additional_salary/additional_salary.py @@ -9,6 +9,12 @@ from frappe import _ from frappe.utils import getdate, date_diff class AdditionalSalary(Document): + def before_insert(self): + if frappe.db.exists("Additional Salary", {"employee": self.employee, "salary_component": self.salary_component, + "amount": self.amount, "payroll_date": self.payroll_date, "company": self.company}): + + frappe.throw(_("Additional Salary Component Exists.")) + def validate(self): self.validate_dates() if self.amount < 0: