mirror of
https://gitee.com/yudaocode/yudao-boot-mini.git
synced 2026-10-06 14:13:14 +08:00
+2
-2
@@ -265,7 +265,7 @@ public class HrmSalaryEmployeeInfoServiceImpl implements HrmSalaryEmployeeInfoSe
|
||||
|
||||
@Override
|
||||
public List<HrmSalaryOptionDO> getSalaryImportOptionList() {
|
||||
List<HrmSalaryOptionDO> options = salaryOptionService.getSalaryOptionList(false);
|
||||
List<HrmSalaryOptionDO> options = salaryOptionService.getSalaryOptionList(true);
|
||||
return filterList(options, option -> ObjectUtil.notEqual(option.getParentCode(), ROOT_PARENT_CODE)
|
||||
&& Boolean.TRUE.equals(option.getCalculateEnabled())
|
||||
&& !HrmSalaryOptionCodeEnum.EMPLOYEE_INFO_IMPORT_EXCLUDED_PARENT_CODES.contains(option.getParentCode()));
|
||||
@@ -762,7 +762,7 @@ public class HrmSalaryEmployeeInfoServiceImpl implements HrmSalaryEmployeeInfoSe
|
||||
}
|
||||
|
||||
private Map<Integer, HrmSalaryOptionDO> getSalaryOptionMap() {
|
||||
return convertMap(salaryOptionService.getSalaryOptionList(false), HrmSalaryOptionDO::getCode);
|
||||
return convertMap(salaryOptionService.getSalaryOptionList(true), HrmSalaryOptionDO::getCode);
|
||||
}
|
||||
|
||||
private HrmSalaryOptionValueVO buildSalaryOptionValueVO(HrmSalaryEmployeeInfoDO.SalaryOption optionDO) {
|
||||
|
||||
+25
-1
@@ -154,13 +154,37 @@ public class HrmSalaryOptionServiceImplTest extends BaseDbUnitTest {
|
||||
salaryOptionMapper.insert(createSalaryOption(100101, 100, "个人社保", false));
|
||||
salaryOptionMapper.insert(createSalaryOption(20, 0, "津贴", false).setEnabled(false));
|
||||
salaryOptionMapper.insert(createSalaryOption(20101, 20, "交通补贴", false));
|
||||
salaryOptionMapper.insert(createSalaryOption(180, 0, "加班工资", true));
|
||||
salaryOptionMapper.insert(createSalaryOption(180101, 180, "加班工资", true));
|
||||
salaryOptionMapper.insert(createSalaryOption(190, 0, "考勤扣款", true));
|
||||
for (int code = 190101; code <= 190106; code++) {
|
||||
salaryOptionMapper.insert(createSalaryOption(code, 190, "考勤扣款", true).setVisible(false));
|
||||
}
|
||||
salaryOptionMapper.insert(createSalaryOption(10102, 10, "停用工资项", false).setEnabled(false));
|
||||
salaryOptionMapper.insert(createSalaryOption(10103, 10, "隐藏工资项", false).setVisible(false));
|
||||
|
||||
// 调用
|
||||
List<HrmSalaryOptionDO> options = salaryOptionService.getSalaryOptionList(true);
|
||||
|
||||
// 断言
|
||||
assertEquals(1, options.size());
|
||||
assertEquals(2, options.size());
|
||||
assertEquals(Integer.valueOf(10101), options.get(0).getCode());
|
||||
assertEquals(Integer.valueOf(10103), options.get(1).getCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSalaryOptionList_adjustableCategoryDisabled() {
|
||||
// mock 数据
|
||||
salaryOptionMapper.insert(createSalaryOption(10, 0, "基本工资", false).setEnabled(false));
|
||||
salaryOptionMapper.insert(createSalaryOption(10101, 10, "基本工资", false));
|
||||
salaryOptionMapper.insert(createSalaryOption(180, 0, "加班工资", true));
|
||||
salaryOptionMapper.insert(createSalaryOption(180101, 180, "加班工资", true));
|
||||
|
||||
// 调用
|
||||
List<HrmSalaryOptionDO> options = salaryOptionService.getSalaryOptionList(true);
|
||||
|
||||
// 断言
|
||||
assertTrue(options.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+47
-2
@@ -40,6 +40,7 @@ import java.util.Map;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.module.hrm.enums.ErrorCodeConstants.SALARY_CHANGE_EFFECT_DATE_INVALID;
|
||||
import static cn.iocoder.yudao.module.hrm.enums.ErrorCodeConstants.SALARY_CHANGE_RECORD_STATUS_INVALID;
|
||||
import static cn.iocoder.yudao.module.hrm.enums.ErrorCodeConstants.SALARY_DATA_ILLEGAL;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
@@ -165,6 +166,50 @@ public class HrmSalaryEmployeeInfoServiceImplTest extends BaseDbUnitTest {
|
||||
assertAmount("10000.00", changeRecord.getAfterTotal());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateSalaryEmployeeInfo_salaryOptionInvalid() {
|
||||
// mock 数据
|
||||
mockSalaryOptions();
|
||||
HrmEmployeeDO employee = mockEmployee(1L, HrmEmployeeStatusEnum.REGULAR.getStatus());
|
||||
// 准备参数
|
||||
HrmSalaryEmployeeInfoUpdateReqVO reqVO = buildSetSalaryReqVO(employee.getId(),
|
||||
new BigDecimal("8000"), new BigDecimal("2000"), new BigDecimal("6000"));
|
||||
|
||||
// 调用,并断言加班工资、考勤扣款不能作为定薪项
|
||||
for (Integer code : Arrays.asList(180101, 190101, 190102, 190103, 190104, 190105, 190106)) {
|
||||
reqVO.setSalaryOptions(Collections.singletonList(
|
||||
optionValue(code, "系统计算项", new BigDecimal("100"))));
|
||||
assertServiceException(() -> salaryEmployeeInfoService.updateSalaryEmployeeInfo(reqVO),
|
||||
SALARY_DATA_ILLEGAL);
|
||||
}
|
||||
|
||||
// 断言未写入薪资档案和调薪记录
|
||||
assertEquals(0L, salaryEmployeeInfoMapper.selectCount());
|
||||
verify(salaryChangeRecordService, never()).createSalaryChangeRecord(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateSalaryEmployeeInfo_probationSalaryOptionInvalid() {
|
||||
// mock 数据
|
||||
mockSalaryOptions();
|
||||
HrmEmployeeDO employee = mockEmployee(1L, HrmEmployeeStatusEnum.REGULAR.getStatus());
|
||||
// 准备参数
|
||||
HrmSalaryEmployeeInfoUpdateReqVO reqVO = buildSetSalaryReqVO(employee.getId(),
|
||||
new BigDecimal("8000"), new BigDecimal("2000"), new BigDecimal("6000"));
|
||||
|
||||
// 调用,并断言加班工资、考勤扣款不能作为定薪项
|
||||
for (Integer code : Arrays.asList(180101, 190101, 190102, 190103, 190104, 190105, 190106)) {
|
||||
reqVO.setProbationSalaryOptions(Collections.singletonList(
|
||||
optionValue(code, "系统计算项", new BigDecimal("100"))));
|
||||
assertServiceException(() -> salaryEmployeeInfoService.updateSalaryEmployeeInfo(reqVO),
|
||||
SALARY_DATA_ILLEGAL);
|
||||
}
|
||||
|
||||
// 断言未写入薪资档案和调薪记录
|
||||
assertEquals(0L, salaryEmployeeInfoMapper.selectCount());
|
||||
verify(salaryChangeRecordService, never()).createSalaryChangeRecord(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateSalaryEmployeeInfo_adjustmentPending() {
|
||||
// mock 数据
|
||||
@@ -317,7 +362,7 @@ public class HrmSalaryEmployeeInfoServiceImplTest extends BaseDbUnitTest {
|
||||
public void testGetSalaryImportOptionList() {
|
||||
// mock 数据
|
||||
List<HrmSalaryOptionDO> options = buildSalaryOptions();
|
||||
when(salaryOptionService.getSalaryOptionList(false)).thenReturn(options);
|
||||
when(salaryOptionService.getSalaryOptionList(true)).thenReturn(options);
|
||||
|
||||
// 调用
|
||||
List<HrmSalaryOptionDO> result =
|
||||
@@ -435,7 +480,7 @@ public class HrmSalaryEmployeeInfoServiceImplTest extends BaseDbUnitTest {
|
||||
}
|
||||
|
||||
private void mockSalaryOptions() {
|
||||
when(salaryOptionService.getSalaryOptionList(false))
|
||||
when(salaryOptionService.getSalaryOptionList(true))
|
||||
.thenReturn(buildSalaryOptions());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user