Merge pull request #16508 from navdeepghai1/salary-slip-net-pay-fixes
fix(human resources): gross pay calculation issue
This commit is contained in:
commit
25cb13c0f8
@ -330,7 +330,7 @@ class SalarySlip(TransactionBase):
|
||||
if frappe.db.get_value('Timesheet', data.time_sheet, 'status') == 'Payrolled':
|
||||
frappe.throw(_("Salary Slip of employee {0} already created for time sheet {1}").format(self.employee, data.time_sheet))
|
||||
|
||||
def sum_components(self, component_type, total_field):
|
||||
def sum_components(self, component_type, total_field, precision):
|
||||
joining_date, relieving_date = frappe.db.get_value("Employee", self.employee,
|
||||
["date_of_joining", "relieving_date"])
|
||||
|
||||
@ -350,7 +350,7 @@ class SalarySlip(TransactionBase):
|
||||
)):
|
||||
|
||||
d.amount = rounded(
|
||||
(flt(d.default_amount) * flt(self.payment_days)
|
||||
(flt(d.default_amount, precision) * flt(self.payment_days)
|
||||
/ cint(self.total_working_days)), self.precision("amount", component_type)
|
||||
)
|
||||
|
||||
@ -360,19 +360,19 @@ class SalarySlip(TransactionBase):
|
||||
elif not d.amount:
|
||||
d.amount = d.default_amount
|
||||
if not d.do_not_include_in_total:
|
||||
self.set(total_field, self.get(total_field) + flt(d.amount))
|
||||
self.set(total_field, self.get(total_field) + flt(d.amount, precision))
|
||||
|
||||
def calculate_net_pay(self):
|
||||
if self.salary_structure:
|
||||
self.calculate_component_amounts()
|
||||
|
||||
disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, "disable_rounded_total"))
|
||||
|
||||
precision = frappe.defaults.get_global_default("currency_precision")
|
||||
self.total_deduction = 0
|
||||
self.gross_pay = 0
|
||||
|
||||
self.sum_components('earnings', 'gross_pay')
|
||||
self.sum_components('deductions', 'total_deduction')
|
||||
self.sum_components('earnings', 'gross_pay', precision)
|
||||
self.sum_components('deductions', 'total_deduction', precision)
|
||||
|
||||
self.set_loan_repayment()
|
||||
|
||||
@ -473,4 +473,4 @@ def unlink_ref_doc_from_salary_slip(ref_no):
|
||||
if linked_ss:
|
||||
for ss in linked_ss:
|
||||
ss_doc = frappe.get_doc("Salary Slip", ss)
|
||||
frappe.db.set_value("Salary Slip", ss_doc.name, "journal_entry", "")
|
||||
frappe.db.set_value("Salary Slip", ss_doc.name, "journal_entry", "")
|
||||
|
Loading…
Reference in New Issue
Block a user