Merge pull request #24842 from resilient-tech/allow-duplicate-additional

fix(payroll): allow duplicate additional salaries
This commit is contained in:
Anurag Mishra 2021-03-17 17:39:52 +05:30 committed by GitHub
commit 23b6294f5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,17 +9,10 @@ from frappe import _, bold
from frappe.utils import getdate, date_diff, comma_and, formatdate from frappe.utils import getdate, date_diff, comma_and, formatdate
class AdditionalSalary(Document): class AdditionalSalary(Document):
def on_submit(self): def on_submit(self):
if self.ref_doctype == "Employee Advance" and self.ref_docname: if self.ref_doctype == "Employee Advance" and self.ref_docname:
frappe.db.set_value("Employee Advance", self.ref_docname, "return_amount", self.amount) frappe.db.set_value("Employee Advance", self.ref_docname, "return_amount", self.amount)
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, "docstatus": 1}):
frappe.throw(_("Additional Salary Component Exists."))
def validate(self): def validate(self):
self.validate_dates() self.validate_dates()
self.validate_salary_structure() self.validate_salary_structure()