fix: update status on salary Slip submission
This commit is contained in:
parent
46e1c09b45
commit
78fdd5d9b4
@ -14,11 +14,8 @@ class Gratuity(Document):
|
|||||||
data = calculate_work_experience_and_amount(self.employee, self.gratuity_rule)
|
data = calculate_work_experience_and_amount(self.employee, self.gratuity_rule)
|
||||||
self.current_work_experience = data["current_work_experience"]
|
self.current_work_experience = data["current_work_experience"]
|
||||||
self.amount = data["amount"]
|
self.amount = data["amount"]
|
||||||
|
if self.docstatus == 1:
|
||||||
def before_submit(self):
|
self.status = "Unpaid"
|
||||||
self.status = "Unpaid"
|
|
||||||
if self.pay_via_salary_slip:
|
|
||||||
self.status = "Paid"
|
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.create_additional_salary()
|
self.create_additional_salary()
|
||||||
|
|||||||
@ -74,9 +74,27 @@ class SalarySlip(TransactionBase):
|
|||||||
if (frappe.db.get_single_value("Payroll Settings", "email_salary_slip_to_employee")) and not frappe.flags.via_payroll_entry:
|
if (frappe.db.get_single_value("Payroll Settings", "email_salary_slip_to_employee")) and not frappe.flags.via_payroll_entry:
|
||||||
self.email_salary_slip()
|
self.email_salary_slip()
|
||||||
|
|
||||||
|
self.update_payment_status_for_gratuity()
|
||||||
|
|
||||||
|
def update_payment_status_for_gratuity(self):
|
||||||
|
add_salary = frappe.db.get_all("Additional Salary",
|
||||||
|
filters = {
|
||||||
|
"payroll_date": ("BETWEEN", [self.start_date, self.end_date]),
|
||||||
|
"employee": self.employee,
|
||||||
|
"ref_doctype": "Gratuity",
|
||||||
|
"docstatus": 1,
|
||||||
|
}, fields = ["ref_docname", "name"])[0]
|
||||||
|
|
||||||
|
status = "Paid" if self.docstatus == 1 else "Unpaid"
|
||||||
|
|
||||||
|
|
||||||
|
if add_salary and add_salary.name in [data.additional_salary for data in self.earnings]:
|
||||||
|
frappe.db.set_value("Gratuity", add_salary.ref_docname, "status", status)
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
self.set_status()
|
self.set_status()
|
||||||
self.update_status()
|
self.update_status()
|
||||||
|
self.update_payment_status_for_gratuity()
|
||||||
self.cancel_loan_repayment_entry()
|
self.cancel_loan_repayment_entry()
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
@ -566,6 +584,7 @@ class SalarySlip(TransactionBase):
|
|||||||
for d in self.get(key):
|
for d in self.get(key):
|
||||||
if d.salary_component == struct_row.salary_component:
|
if d.salary_component == struct_row.salary_component:
|
||||||
component_row = d
|
component_row = d
|
||||||
|
|
||||||
if not component_row or (struct_row.get("is_additional_component") and not overwrite):
|
if not component_row or (struct_row.get("is_additional_component") and not overwrite):
|
||||||
if amount:
|
if amount:
|
||||||
self.append(key, {
|
self.append(key, {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user