Skip to content

feat: Added checkbox to exclude specific salary component amount from Journal Entry #3315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: add test case of exclusion of component in jv
  • Loading branch information
iamkhanraheel committed Jul 18, 2025
commit dd07997ca7677edb043c87edfa8c9df121d4f8b6
64 changes: 64 additions & 0 deletions hrms/payroll/doctype/payroll_entry/test_payroll_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,70 @@ def run_test_for_loan_repayment_from_salary(self):
self.assertEqual(total_debit, expected_bank_entry_amount)
self.assertEqual(total_credit, expected_bank_entry_amount)

@change_settings("Payroll Settings", {"process_payroll_accounting_entry_based_on_employee": 0})
def test_component_exclusion_from_accounting_entries(self):
company = frappe.get_doc("Company", "_Test Company")
employee = make_employee("[email protected]", company=company.name)

# Create Salary Components
basic = create_salary_component("Basic", **{"type": "Earning"})
basic.append("accounts", {"company": company.name, "account": "Salary - _TC"})
basic.save()

esi = create_salary_component(
"ESI", **{"type": "Deduction", "do_not_include_in_total": 1, "do_not_include_in_accounts": 1}
)
esi.append("accounts", {"company": company.name, "account": "Salary - _TC"})
esi.save()

# Create Salary structure with both components
make_salary_structure(
"Test Salary Structure",
"Monthly",
employee,
company=company.name,
other_details={
"earnings": [{"salary_component": basic.name, "amount": 20000}],
"deductions": [
{
"salary_component": esi.name,
"amount": 200,
"do_not_include_in_total": 1,
"do_not_include_in_accounts": 1,
}
],
},
)

# Create Payroll entry
dates = get_start_end_dates("Monthly", nowdate())
payroll_entry = make_payroll_entry(
start_date=dates.start_date,
end_date=dates.end_date,
payable_account=company.default_payroll_payable_account,
currency=company.default_currency,
company=company.name,
cost_center="Main - _TC",
)

# Get and verify salary slip & jv
salary_slip = frappe.get_doc("Salary Slip", {"payroll_entry": payroll_entry.name})

self.assertAlmostEqual(salary_slip.gross_pay, 20000.0, places=2)

# Deductions table should include ESI
self.assertTrue(any(row.salary_component == esi.name for row in salary_slip.deductions))

# verify jv & accounts
journal_entry = frappe.get_doc("Journal Entry", salary_slip.journal_entry)
self.assertTrue(journal_entry, "Journal Entry not created")
self.assertEqual(salary_slip.gross_pay, journal_entry.total_debit)

accounts = [d.account for d in journal_entry.accounts]
self.assertIn("Salary - _TC", accounts)
self.assertIn(company.default_payroll_payable_account, accounts)
self.assertNotIn("ESIC Payable - _TC", accounts, "ESIC component wrongly included in JE")


def get_payroll_entry(**args):
args = frappe._dict(args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,6 @@ var set_value_for_condition_and_formula = function (frm) {
frm.set_value("amount_based_on_formula", 0);
frm.set_value("statistical_component", 0);
frm.set_value("do_not_include_in_total", 0);
frm.set_value("do_not_include_in_accounts", 0);
frm.set_value("depends_on_payment_days", 0);
};
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,7 @@ def create_salary_component(component_name, **args):
"salary_component": component_name,
"type": args.get("type") or "Earning",
"is_tax_applicable": args.get("is_tax_applicable") or 1,
"do_not_include_in_total": args.get("do_not_include_in_total") or 0,
"do_not_include_in_accounts": args.get("do_not_include_in_accounts") or 0,
}
).insert()
Loading