@@ -1828,6 +1828,128 @@ def test_status_on_discard(self):
18281828 salary_slip .reload ()
18291829 self .assertEqual (salary_slip .status , "Cancelled" )
18301830
1831+ def test_salary_component_for_payment_days_zero (self ):
1832+ from hrms .payroll .doctype .salary_structure .test_salary_structure import (
1833+ create_salary_structure_assignment ,
1834+ make_salary_structure ,
1835+ )
1836+
1837+ emp = make_employee (
1838+ "test_payment_days_zero_component@salary.com" ,
1839+ company = "_Test Company" ,
1840+ ** {"date_of_joining" : "2021-12-01" },
1841+ )
1842+
1843+ payroll_period = frappe .get_all ("Payroll Period" , filters = {"company" : "_Test Company" }, limit = 1 )
1844+ payroll_period = frappe .get_cached_doc ("Payroll Period" , payroll_period [0 ].name )
1845+
1846+ data = [
1847+ {
1848+ "salary_component" : "Basic" ,
1849+ "abbr" : "BS" ,
1850+ "type" : "Earning" ,
1851+ "formula" : "base" ,
1852+ "amount_based_on_formula" : 1 ,
1853+ "depends_on_payment_days" : 1 ,
1854+ },
1855+ {
1856+ "salary_component" : "House Rent Allowance" ,
1857+ "abbr" : "HRA" ,
1858+ "type" : "Earning" ,
1859+ "formula" : "BS * 0.5" ,
1860+ "amount_based_on_formula" : 1 ,
1861+ "depends_on_payment_days" : 0 ,
1862+ },
1863+ ]
1864+ make_salary_component (data , False , company_list = ["_Test Company" ])
1865+
1866+ salary_structure_name = "Test Payment Days Zero Component"
1867+ salary_structure_doc = make_salary_structure (
1868+ salary_structure_name ,
1869+ "Monthly" ,
1870+ company = "_Test Company" ,
1871+ employee = emp ,
1872+ from_date = payroll_period .start_date ,
1873+ payroll_period = payroll_period ,
1874+ base = 65000 ,
1875+ )
1876+
1877+ create_salary_structure_assignment (
1878+ emp ,
1879+ salary_structure_doc .name ,
1880+ from_date = payroll_period .start_date ,
1881+ company = "_Test Company" ,
1882+ currency = "INR" ,
1883+ payroll_period = payroll_period ,
1884+ base = 65000 ,
1885+ )
1886+
1887+ salary_slip = make_salary_slip (
1888+ salary_structure_doc .name , employee = emp , posting_date = payroll_period .start_date
1889+ )
1890+ salary_slip .payment_days = 0
1891+
1892+ earnings = {d .salary_component : d for d in salary_slip .earnings }
1893+
1894+ self .assertNotIn ("Basic" , earnings )
1895+
1896+ self .assertNotIn ("House Rent Allowance" , earnings )
1897+
1898+ def test_salary_component_for_additional_salary_zero (self ):
1899+ from hrms .payroll .doctype .salary_structure .test_salary_structure import make_salary_structure
1900+
1901+ emp = make_employee (
1902+ "test_zero_value_component@salary.com" ,
1903+ company = "_Test Company" ,
1904+ ** {"date_of_joining" : "2021-12-01" },
1905+ )
1906+
1907+ payroll_period = frappe .get_all ("Payroll Period" , filters = {"company" : "_Test Company" }, limit = 1 )
1908+ payroll_period = frappe .get_cached_doc ("Payroll Period" , payroll_period [0 ].name )
1909+
1910+ data = [
1911+ {
1912+ "salary_component" : "Allowance" ,
1913+ "abbr" : "ALL" ,
1914+ "type" : "Earning" ,
1915+ "is_income_tax_component" : 0 ,
1916+ "amount" : 350 ,
1917+ },
1918+ ]
1919+ make_salary_component (data , False , company_list = ["_Test Company" ])
1920+
1921+ salary_structure_name = "Test Additional Salary component"
1922+ salary_structure_doc = make_salary_structure (
1923+ salary_structure_name ,
1924+ "Monthly" ,
1925+ company = "_Test Company" ,
1926+ employee = emp ,
1927+ from_date = payroll_period .start_date ,
1928+ payroll_period = payroll_period ,
1929+ base = 65000 ,
1930+ )
1931+
1932+ frappe .get_doc (
1933+ {
1934+ "doctype" : "Additional Salary" ,
1935+ "employee" : emp ,
1936+ "company" : "_Test Company" ,
1937+ "salary_component" : "Allowance" ,
1938+ "overwrite_salary_structure_amount" : 1 ,
1939+ "amount" : 0 ,
1940+ "payroll_date" : payroll_period .start_date ,
1941+ "currency" : erpnext .get_default_currency (),
1942+ }
1943+ ).submit ()
1944+
1945+ salary_slip = make_salary_slip (
1946+ salary_structure_doc .name , employee = emp , posting_date = payroll_period .start_date
1947+ )
1948+ earnings = {d .salary_component : d .amount for d in salary_slip .earnings }
1949+
1950+ self .assertIn ("Allowance" , earnings )
1951+ self .assertEqual (earnings ["Allowance" ], 0.0 )
1952+
18311953
18321954class TestSalarySlipSafeEval (IntegrationTestCase ):
18331955 def test_safe_eval_for_salary_slip (self ):
0 commit comments