Merge pull request #2566 from expsa/bakry_hr3

fix termination cal
This commit is contained in:
bakry 2025-03-04 15:17:46 +03:00 committed by GitHub
commit 7974b95aaf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 10 deletions

View File

@ -427,12 +427,13 @@ class HrTermination(models.Model):
# Make the maximum paid duration is 30
_, number_of_days = calendar.monthrange(self.last_work_date.year, self.last_work_date.month)
if self.paid_duration > 0:
if self.paid_duration == 31:
duration_percentage = 30 / 30
elif self.last_work_date.month ==2:
if number_of_days == 28:
if number_of_days == 31:
duration_percentage = 31 / self.paid_duration
elif number_of_days == 28:
duration_percentage = 28 / self.paid_duration
else:
elif number_of_days == 29:
duration_percentage = 29 / self.paid_duration
else:
duration_percentage = 30 / self.paid_duration
@ -892,33 +893,33 @@ class HrTermination(models.Model):
amount = round(item.amount,2)
if item.category_id.rule_type == 'allowance':
line_vals.append({
'name': ('Employee %s allowance.') % (self.employee_id.name),
'name': item.salary_rule_id.name,
'debit': abs(amount),
'account_id': item.account_debit_id.id,
'partner_id': self.employee_id.user_id.partner_id.id})
elif item.category_id.rule_type == 'deduction':
line_vals.append({
'name': ('Employee %s deduction.') % (self.employee_id.name),
'name': item.salary_rule_id.name,
'credit': abs(amount),
'account_id': item.account_credit_id.id,
'partner_id': self.employee_id.user_id.partner_id.id})
else:
line_vals.append({
'name': ('Employee %s rule.') % (self.employee_id.name),
'name': item.salary_rule_id.name,
'debit': abs(amount),
'account_id': item.account_debit_id.id,
'partner_id': self.employee_id.user_id.partner_id.id})
for item in self.loans_ids:
line_vals.append({
'name': ('Employee %s loans.') % (self.employee_id.name),
'name': item.request_type.name,
'credit': abs(round(item.remaining_loan_amount,2)),
'account_id': item.request_type.account_id.id,
'partner_id': self.employee_id.user_id.partner_id.id})
line_vals.append({
'name': ('Employee %s Net.') % (self.employee_id.name),
'name': 'Total Net',
'credit': abs(round(self.net,2)),
'account_id': self.journal.default_account_id.id,
'partner_id': self.employee_id.user_id.partner_id.id})