联特 半年度、年度

This commit is contained in:
Harryxzy 2025-07-22 18:30:34 +08:00
parent dd53bd861c
commit 3a1d2defbe
5 changed files with 71 additions and 13 deletions

View File

@ -280,17 +280,25 @@ public class CalculateFormulaVarBO {
// 调薪计薪规则
Map<Long, SalarySobAdjustRulePO> salarySobAdjustRulePOMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalarySobAdjustRulePOS(),
SalarySobAdjustRulePO::getSalaryItemId);
boolean isSeasonSob = false;
int monthCount = 1;
if (attendCycleType != null && (attendCycleType.equals(SalaryCycleTypeEnum.THIS_SEASON.getValue()) || attendCycleType.equals(SalaryCycleTypeEnum.LAST_SEASON.getValue()) )) {
// 联特 是季度账套
isSeasonSob = true;
monthCount = 3;
}
if (attendCycleType != null && attendCycleType.equals(SalaryCycleTypeEnum.HALF_YEAR.getValue())) {
// 联特 是季度账套
monthCount = 6;
}
if (attendCycleType != null && attendCycleType.equals(SalaryCycleTypeEnum.FULL_YEAR.getValue())) {
// 联特 是季度账套
monthCount = 12;
}
for (SalaryArchiveDataDTO salaryArchiveDataDTO : salaryArchiveData) {
for (SalaryArchiveTaxAgentDataDTO salaryArchiveTaxAgentDataDTO : salaryArchiveDataDTO.getTaxAgents()) {
String key = salaryArchiveDataDTO.getEmployeeId() + "_" + salaryArchiveTaxAgentDataDTO.getTaxAgentId();
List<FormulaVarValue> formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList());
// 将薪资档案的值转换成公式中的变量填充到返回结果集中
formulaVarValues.addAll(handleSalaryArchiveItemVal(salaryAcctCalculateBO, salaryArchiveTaxAgentDataDTO.getSalaryItemValues(), salarySobAdjustRulePOMap, kqGroupService, salaryArchiveDataDTO.getEmployeeId(), isSeasonSob));
formulaVarValues.addAll(handleSalaryArchiveItemVal(salaryAcctCalculateBO, salaryArchiveTaxAgentDataDTO.getSalaryItemValues(), salarySobAdjustRulePOMap, kqGroupService, salaryArchiveDataDTO.getEmployeeId(), monthCount));
}
}
}
@ -329,7 +337,7 @@ public class CalculateFormulaVarBO {
Map<Long, SalarySobAdjustRulePO> salarySobAdjustRulePOMap,
KQGroupService kqGroupService,
Long employeeId,
boolean isSeasonSob) {
int mounthCount) {
// 薪资周期
LocalDateRange salaryCycle = salaryAcctCalculateBO.getSalarySobCycleDTO().getSalaryCycle();
// key:薪资项目的idvalue:薪资项目的code
@ -364,18 +372,18 @@ public class CalculateFormulaVarBO {
// }
if (entry.getValue().size() > 2) {
// 如果薪资项目在薪资周期内经历了多次调薪则默认分段计薪
value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.PARTITION, entry.getValue(), kqGroupService, employeeId, isSeasonSob);
value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.PARTITION, entry.getValue(), kqGroupService, employeeId, mounthCount);
} else if (salaryAdjustmentRulePO == null || entry.getValue().size() < 2) {
// 如果薪资项目没有设置调薪计薪规则默认取薪资周期内薪资档案中最新的值
// 如果薪资项目在薪资周期内没有调薪默认取薪资周期内薪资档案中最新的值
value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.USE_AFTER_ADJUSTMENT, entry.getValue(), kqGroupService, employeeId, isSeasonSob);
value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.USE_AFTER_ADJUSTMENT, entry.getValue(), kqGroupService, employeeId, mounthCount);
} else {
// 如果薪资项目在薪资周期内只有一次调薪则根据调薪计薪规则处理
SalarySobAdjustRuleTypeEnum adjustRuleTypeEnum = salaryAdjustmentRulePO.getDayOfMonth() < SalaryDateUtil.dateToLocalDate(entry.getValue().get(0).getEffectiveDateRange().getEndDate()).getDayOfMonth()
? SalarySobAdjustRuleTypeEnum.parseByValue(salaryAdjustmentRulePO.getAfterAdjustmentType())
: SalarySobAdjustRuleTypeEnum.parseByValue(salaryAdjustmentRulePO.getBeforeAdjustmentType());
// 根据调薪计薪规则处理薪资档案的调薪
value = calculateBySalarySobAdjustRule(salaryCycle, adjustRuleTypeEnum, entry.getValue(), kqGroupService, employeeId, isSeasonSob);
value = calculateBySalarySobAdjustRule(salaryCycle, adjustRuleTypeEnum, entry.getValue(), kqGroupService, employeeId, mounthCount);
}
String fieldId = SalaryFormulaReferenceEnum.SALARY_ARCHIVES.getValue()
+ SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR
@ -397,7 +405,7 @@ public class CalculateFormulaVarBO {
List<SalaryArchiveItemDataDTO> salaryArchiveItemDataDTOS,
KQGroupService kqGroupService,
Long employeeId,
boolean isSeasonSob) {
int mounthCount) {
if (Objects.isNull(adjustRuleTypeEnum)) {
return StringUtils.EMPTY;
}
@ -416,9 +424,7 @@ public class CalculateFormulaVarBO {
// BigDecimal valueSum = BigDecimal.ZERO;
BigDecimal firstValue = BigDecimal.ZERO;
BigDecimal baseValue = new BigDecimal("21.75");
if (isSeasonSob) {
baseValue = baseValue.multiply(new BigDecimal(3));
}
baseValue = baseValue.multiply(new BigDecimal(String.valueOf(mounthCount)));
// 调薪补差金额
BigDecimal needAddValue = new BigDecimal(0);
if (CollectionUtils.isNotEmpty(salaryArchiveItemDataDTOS)) {

View File

@ -58,6 +58,16 @@ public class SalarySobCycleBO {
salarySobCycleDTO.setAttendCycle(attendCycle);
salarySobCycleDTO.setAttendCycleFromDate(attendCycle.getFromDate());
salarySobCycleDTO.setAttendCycleEndDate(attendCycle.getEndDate());
} else if (salarySob.getAttendCycleType().equals(SalaryCycleTypeEnum.HALF_YEAR.getValue())) {
LocalDateRange attendCycle = SalaryDateUtil.getHalfYearRangeByDate(salaryMonth);
salarySobCycleDTO.setAttendCycle(attendCycle);
salarySobCycleDTO.setAttendCycleFromDate(attendCycle.getFromDate());
salarySobCycleDTO.setAttendCycleEndDate(attendCycle.getEndDate());
} else if (salarySob.getAttendCycleType().equals(SalaryCycleTypeEnum.FULL_YEAR.getValue())) {
LocalDateRange attendCycle = SalaryDateUtil.getFullYearRangeByDate(salaryMonth);
salarySobCycleDTO.setAttendCycle(attendCycle);
salarySobCycleDTO.setAttendCycleFromDate(attendCycle.getFromDate());
salarySobCycleDTO.setAttendCycleEndDate(attendCycle.getEndDate());
} else {
LocalDateRange attendCycle = salarySobCycleDTO.getAttendCycle();
salarySobCycleDTO.setAttendCycleFromDate(attendCycle.getFromDate());

View File

@ -19,7 +19,9 @@ public enum SalaryCycleTypeEnum implements BaseEnum<Integer> {
NEXT_MONTH(4, "下月", 86073),
AFTER_NEXT_MONTH(5, "下下月", 0),
THIS_SEASON(10, "本季度", 0),
LAST_SEASON(11, "上季度", 0);
LAST_SEASON(11, "上季度", 0),
HALF_YEAR(12, "半年度", 0),
FULL_YEAR(13, "全年", 0);
private int value;

View File

@ -145,7 +145,8 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
List<SalaryArchiveDataDTO> salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds);
// 联特二开需要判断考勤周期是不是设置的季度
Integer attendCycleType = salaryAcctCalculateBO.getSalarySobPO().getAttendCycleType();
if (attendCycleType.equals(SalaryCycleTypeEnum.THIS_SEASON.getValue()) || attendCycleType.equals(SalaryCycleTypeEnum.LAST_SEASON.getValue())) {
if (attendCycleType.equals(SalaryCycleTypeEnum.THIS_SEASON.getValue()) || attendCycleType.equals(SalaryCycleTypeEnum.LAST_SEASON.getValue())
|| attendCycleType.equals(SalaryCycleTypeEnum.HALF_YEAR.getValue()) || attendCycleType.equals(SalaryCycleTypeEnum.FULL_YEAR.getValue())) {
salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getAttendCycle(), employeeIds, taxAgentIds);
}

View File

@ -14,6 +14,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.Calendar;
import java.util.Date;
import java.util.Objects;
@ -644,6 +645,44 @@ public class SalaryDateUtil {
.endDate(localDateToDate(endDate))
.build();
}
public static LocalDateRange getHalfYearRangeByDate(YearMonth yearMonth) {
if (yearMonth == null) {
return LocalDateRange.builder().build();
}
int month = yearMonth.getMonthValue();
int year = yearMonth.getYear();
// 半年度开始月份
int halfStartMonth = month <= 6 ? 1 : 7;
// 半年度结束月份
int halfEndMonth = halfStartMonth + 5;
LocalDate startDate = LocalDate.of(year, halfStartMonth, 1);
LocalDate endDate = LocalDate.of(year, halfEndMonth, 1);
// endDate调整为当月最后一天
endDate = endDate.with(TemporalAdjusters.lastDayOfMonth());
return LocalDateRange.builder()
.fromDate(localDateToDate(startDate))
.endDate(localDateToDate(endDate))
.build();
}
public static LocalDateRange getFullYearRangeByDate(YearMonth yearMonth) {
if (yearMonth == null) {
return LocalDateRange.builder().build();
}
int year = yearMonth.getYear();
LocalDate startDate = LocalDate.of(year, 1, 1);
LocalDate endDate = LocalDate.of(year, 12, 31);
return LocalDateRange.builder()
.fromDate(localDateToDate(startDate))
.endDate(localDateToDate(endDate))
.build();
}
}