Skip to content

Commit f0f3c27

Browse files
authored
Merge branch 'develop' into l10n_develop
2 parents df1cefa + 011ae10 commit f0f3c27

4 files changed

Lines changed: 54 additions & 6 deletions

File tree

hrms/payroll/doctype/additional_salary/additional_salary.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,42 @@ def validate(self):
3737
frappe.throw(_("Amount should not be less than zero"))
3838

3939
def validate_salary_structure(self):
40-
if not frappe.db.exists("Salary Structure Assignment", {"employee": self.employee}):
40+
salary_structure = frappe.db.get_value(
41+
"Salary Structure Assignment",
42+
{
43+
"employee": self.employee,
44+
"docstatus": 1,
45+
"from_date": ["<=", self.payroll_date or self.from_date],
46+
},
47+
"salary_structure",
48+
order_by="from_date desc",
49+
)
50+
51+
if not salary_structure:
4152
frappe.throw(
4253
_("There is no Salary Structure assigned to {0}. First assign a Salary Structure.").format(
4354
self.employee
4455
)
4556
)
4657

58+
if self.overwrite_salary_structure_amount:
59+
is_structure_component = frappe.db.get_value(
60+
"Salary Detail",
61+
{
62+
"parenttype": "Salary Structure",
63+
"parent": salary_structure,
64+
"salary_component": self.salary_component,
65+
},
66+
)
67+
68+
if not is_structure_component:
69+
self.overwrite_salary_structure_amount = 0
70+
frappe.msgprint(
71+
_(
72+
"Overwrite Salary Structure Amount is disabled as the Salary Component: {0} not part of the Salary Structure: {1}"
73+
).format(self.salary_component, salary_structure)
74+
)
75+
4776
def validate_recurring_additional_salary_overlap(self):
4877
if self.is_recurring:
4978
AdditionalSalary = frappe.qb.DocType("Additional Salary")

hrms/payroll/doctype/additional_salary/test_additional_salary.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ def test_recurring_additional_salary(self):
2626
emp_id = make_employee("test_additional@salary.com")
2727
frappe.db.set_value("Employee", emp_id, "relieving_date", add_days(nowdate(), 1800))
2828
salary_structure = make_salary_structure(
29-
"Test Salary Structure Additional Salary", "Monthly", employee=emp_id
29+
"Test Salary Structure Additional Salary",
30+
"Monthly",
31+
employee=emp_id,
32+
from_date=add_days(nowdate(), -50),
3033
)
3134
add_sal = get_additional_salary(emp_id)
3235

@@ -44,7 +47,10 @@ def test_disabled_recurring_additional_salary(self):
4447
emp_id = make_employee("test_additional@salary.com")
4548

4649
salary_structure = make_salary_structure(
47-
"Test Salary Structure Additional Salary", "Monthly", employee=emp_id
50+
"Test Salary Structure Additional Salary",
51+
"Monthly",
52+
employee=emp_id,
53+
from_date=add_days(nowdate(), -50),
4854
)
4955
add_sal = get_additional_salary(emp_id)
5056
ss = make_employee_salary_slip(emp_id, "Monthly", salary_structure=salary_structure.name)
@@ -149,8 +155,13 @@ def _get_tds_component(doc) -> dict:
149155

150156
def test_validate_duplicate_or_overlapping_additional_salary(self):
151157
emp_id = make_employee("test_additional@salary.com")
152-
make_salary_structure("Test Salary Structure Additional Salary", "Monthly", employee=emp_id)
153158
date = nowdate()
159+
make_salary_structure(
160+
"Test Salary Structure Additional Salary",
161+
"Monthly",
162+
employee=emp_id,
163+
from_date=add_days(date, -50),
164+
)
154165
get_additional_salary(emp_id, overwrite_salary_structure=1)
155166
additional_salary_doc = frappe.get_doc(
156167
{

hrms/payroll/doctype/salary_slip/salary_slip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,9 +1963,9 @@ def get_taxable_earnings(self, allow_tax_exemption=False, based_on_payment_days=
19631963
amount, additional_amount = self.get_amount_based_on_payment_days(earning)
19641964
else:
19651965
if earning.additional_amount:
1966-
amount, additional_amount = earning.amount, earning.additional_amount
1966+
amount, additional_amount = earning.amount or 0, earning.additional_amount or 0
19671967
else:
1968-
amount, additional_amount = earning.default_amount, earning.additional_amount
1968+
amount, additional_amount = earning.default_amount or 0, earning.additional_amount or 0
19691969

19701970
if earning.is_tax_applicable:
19711971
taxable_earnings += amount - additional_amount

hrms/payroll/doctype/salary_slip/test_salary_slip.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,6 +2051,14 @@ def make_earning_salary_component(
20512051
"amount": 0,
20522052
"remove_if_zero_valued": 1,
20532053
},
2054+
{
2055+
"salary_component": "Recurring Salary Component",
2056+
"abbr": "RSC",
2057+
"type": "Earning",
2058+
"depends_on_payment_days": 0,
2059+
"amount": 0,
2060+
"remove_if_zero_valued": 1,
2061+
},
20542062
]
20552063

20562064
if test_accrual_component:

0 commit comments

Comments
 (0)