feat: 沿用上月增加校验

This commit is contained in:
fcli 2022-11-17 14:54:13 +08:00
parent 0f51d44cd4
commit 0aa59757c5
2 changed files with 20 additions and 6 deletions

View File

@ -790,6 +790,15 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
@Override
public String extendToLastMonth(OtherDeductionExtendLastParam param) {
//查询已经核算的数据
List<SalaryAcctEmployeePO> salaryAcctEmployees =
getAddUpDeductionService(user)
.getAccountedEmployeeData(param.getDeclareMonth());
Map<String, Long> acctInfoMap = salaryAcctEmployees.stream().collect(Collectors.toMap(
i -> i.getTaxAgentId() + "" + i.getEmployeeId(),
SalaryAcctEmployeePO::getId
));
// 查找到所有个税扣缴义务人
Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID());
Collection<TaxAgentPO> taxAgentPOS;
@ -815,7 +824,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
));
Map<String, Long> updateIdMap = getOtherDeductionMapper()
.list(queryParam).stream()
.collect(Collectors.toMap(i -> i.getEmployeeId()+"" + i.getTaxAgentId(), OtherDeductionListDTO::getId));
.collect(Collectors.toMap(i -> i.getEmployeeId() + "" + i.getTaxAgentId(), OtherDeductionListDTO::getId));
List<OtherDeductionPO> insertInfo = new ArrayList<>();
List<OtherDeductionPO> updatetInfo = new ArrayList<>();
@ -827,20 +836,21 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
po.setId(null);
po.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
boolean hasOld = updateIdMap.containsKey(po.getEmployeeId() + "" + po.getTaxAgentId());
if (hasOld) {
if (hasOld && acctInfoMap.containsKey(po.getTaxAgentId() + "" + po.getEmployeeId())) {
//核算过的数据直接跳过不做更改
po.setId(updateIdMap.get(po.getEmployeeId() + "" + po.getTaxAgentId()));
updatetInfo.add(po);
} else {
} else if (!hasOld){
po.setCreator((long) user.getUID());
po.setCreateTime(new Date());
insertInfo.add(po);
}
}
List<List<OtherDeductionPO>> list = Lists.partition(insertInfo, 1000);
list.forEach(l->getOtherDeductionMapper().insertData(l));
list.forEach(l -> getOtherDeductionMapper().insertData(l));
List<List<OtherDeductionPO>> updateList = Lists.partition(updatetInfo, 1000);
list.forEach(l->getOtherDeductionMapper().updateData(l));
list.forEach(l -> getOtherDeductionMapper().updateData(l));
return "";
}

View File

@ -25,6 +25,7 @@ import weaver.hrm.User;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
@ -257,9 +258,12 @@ public class OtherDeductionWrapper extends Service {
} catch (Exception e) {
log.error("", e);
}
if (null == param.getDeclareMonth() || null == param.getYearMonthTime()) {
if (null == param.getDeclareMonth() || null == localDate || null == param.getYearMonthTime()) {
throw new SalaryRunTimeException("当前年月不合法");
}
if (Month.JANUARY.equals(localDate.getMonth())) {
throw new SalaryRunTimeException("失败,当前年度内第一个月无法沿用上月");
}
param.setYearMonthTime(localDate);
return getOtherDeductionService(user).extendToLastMonth(param);
}