Salary slip - default flexi component

This commit is contained in:
Jamsheer 2018-05-16 11:53:49 +05:30
parent 43740a6511
commit 5f6e274505
2 changed files with 11 additions and 7 deletions

View File

@ -13,7 +13,7 @@ class SalaryComponent(Document):
self.validate_abbr() self.validate_abbr()
self.validate_flexi_default() self.validate_flexi_default()
def validate_flexi_defualt(self): def validate_flexi_default(self):
if self.is_flexible_benefit and self.is_pro_rata_applicable and self.flexi_default: if self.is_flexible_benefit and self.is_pro_rata_applicable and self.flexi_default:
salary_component = frappe.db.exists( salary_component = frappe.db.exists(
'Salary Component', 'Salary Component',

View File

@ -84,16 +84,20 @@ class SalarySlip(TransactionBase):
} }
) )
if default_flexi_compenent: if default_flexi_compenent:
salary_component = frappe.get_doc("Salary Component", default_flexi_compenent) flexi_struct_row = self.create_flexi_struct_row(default_flexi_compenent)
flexi_struct_row = {}
flexi_struct_row['depends_on_lwp'] = salary_component.depends_on_lwp
flexi_struct_row['salary_component'] = salary_component.name
flexi_struct_row['abbr'] = salary_component.salary_component_abbr
flexi_struct_row['do_not_include_in_total'] = salary_component.do_not_include_in_total
payroll_period_days = get_payroll_period_days(self.start_date, self.end_date, self.company) payroll_period_days = get_payroll_period_days(self.start_date, self.end_date, self.company)
amount = get_amount(payroll_period_days, self.start_date, self.end_date, max_benefits) amount = get_amount(payroll_period_days, self.start_date, self.end_date, max_benefits)
self.update_component_row(flexi_struct_row, amount, "earnings") self.update_component_row(flexi_struct_row, amount, "earnings")
def create_flexi_struct_row(self, default_flexi_compenent):
salary_component = frappe.get_doc("Salary Component", default_flexi_compenent)
flexi_struct_row = {}
flexi_struct_row['depends_on_lwp'] = salary_component.depends_on_lwp
flexi_struct_row['salary_component'] = salary_component.name
flexi_struct_row['abbr'] = salary_component.salary_component_abbr
flexi_struct_row['do_not_include_in_total'] = salary_component.do_not_include_in_total
return frappe._dict(flexi_struct_row)
def update_component_row(self, struct_row, amount, key): def update_component_row(self, struct_row, amount, key):
component_row = None component_row = None
for d in self.get(key): for d in self.get(key):