支持跨扣缴义务人兼容性

This commit is contained in:
钱涛 2024-09-03 15:48:20 +08:00
parent e788f3dd37
commit e7eb2e3459
6 changed files with 34 additions and 31 deletions

View File

@ -673,7 +673,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
List<Long> needUpdateSalaryAcctRecordIds = selfSalaryAcctRecordPOS.stream().filter(po -> po.getTaxCycle().equals(salaryAcctRecordPO.getTaxCycle()))
.map(SalaryAcctRecordPO::getId).collect(Collectors.toList());
if (Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())) {
if (needUpdateSalaryAcctRecordIds != null && needUpdateSalaryAcctRecordIds.size() > 0) {
if (needUpdateSalaryAcctRecordIds.size() > 0) {
// 更新薪资核算记录的状态
updateStatusByIds(needUpdateSalaryAcctRecordIds, SalaryAcctRecordStatusEnum.ARCHIVED);
}

View File

@ -28,7 +28,6 @@ import com.engine.salary.entity.salaryformula.ExpressFormula;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.dto.*;
import com.engine.salary.entity.salarysob.po.*;
import com.engine.salary.entity.taxagent.po.TaxAgentAdminPO;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.OperateTypeEnum;
import com.engine.salary.enums.UserStatusEnum;
@ -1107,17 +1106,17 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
@Override
public Boolean checkAuth(Long salaryAcctRecordId) {
// 获取该核算记录的个税扣缴义务
SalaryAcctRecordPO recordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId);
if (Objects.isNull(recordPO)) {
return false;
}
SalarySobPO salarySobPO = getSalarySobService(user).getById(recordPO.getSalarySobId());
Long taxAgentId = salarySobPO.getTaxAgentId();
List<TaxAgentAdminPO> adminTaxAgentList = getTaxAgentAdminService(user).listByEmployeeId(Long.valueOf(user.getUID()));
Optional<TaxAgentAdminPO> canOperate = adminTaxAgentList.stream().filter(po -> NumberUtils.compare(taxAgentId, po.getTaxAgentId()) == 0).findFirst();
if (!canOperate.isPresent()) {
return false;
}
// SalaryAcctRecordPO recordPO = getSalaryAcctRecordService(user).getById(salaryAcctRecordId);
// if (Objects.isNull(recordPO)) {
// return false;
// }
// SalarySobPO salarySobPO = getSalarySobService(user).getById(recordPO.getSalarySobId());
// Long taxAgentId = salarySobPO.getTaxAgentId();
// List<TaxAgentAdminPO> adminTaxAgentList = getTaxAgentAdminService(user).listByEmployeeId((long) user.getUID());
// Optional<TaxAgentAdminPO> canOperate = adminTaxAgentList.stream().filter(po -> NumberUtils.compare(taxAgentId, po.getTaxAgentId()) == 0).findFirst();
// if (!canOperate.isPresent()) {
// return false;
// }
return true;
}

View File

@ -1,5 +1,6 @@
package com.engine.salary.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.api.formmode.mybatis.util.SqlProxyHandle;
@ -457,12 +458,12 @@ public class SalaryItemServiceImpl extends Service implements SalaryItemService
// 查询所有启用的薪资账套
List<SalarySobItemPO> salarySobItemList = getSalarySobItemService(user).listBySalaryItemIds(Collections.singleton(salaryItemId));
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobItemList, SalarySobItemPO::getSalarySobId);
List<SalarySobPO> salarySobs = getSalarySobService(user).listByIds(salarySobIds);
List<SalarySobPO> salarySobs = getSalarySobService(user).listByIdsWithTax(salarySobIds);
// 获取能够管理的义务人
Boolean isChief = getTaxAgentService(user).isChief(Long.valueOf(user.getUID()));
Boolean isChief = getTaxAgentService(user).isChief((long) user.getUID());
if (!isChief) {
Set<Long> taxAgentIds = SalaryEntityUtil.properties(getTaxAgentService(user).listAllTaxAgentsAsAdmin(Long.valueOf(user.getUID())), TaxAgentPO::getId);
salarySobs = salarySobs.stream().filter(sob -> taxAgentIds.contains(sob.getTaxAgentId())).collect(Collectors.toList());
Set<Long> taxAgentIds = SalaryEntityUtil.properties(getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) user.getUID()), TaxAgentPO::getId);
salarySobs = salarySobs.stream().filter(sob -> CollectionUtil.intersection(taxAgentIds, sob.getTaxAgentIds()).size() > 0).collect(Collectors.toList());
}
return salarySobs.stream().map(m -> {
Map<String, Object> map = new HashMap<>();

View File

@ -638,10 +638,10 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
}
}
TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(salarySendInfo.getTaxAgentId());
DataCollectionEmployee simpleEmployee = getSalaryEmployeeService(user).getEmployeeById(salarySendInfo.getEmployeeId());
SalaryAcctEmployeePO acctEmployeePO = getSalaryAcctEmployeeService(user).getById(salaryAcctResultPOS.get(0).getSalaryAcctEmpId());
SalaryAcctEmployeeBO.copyAcctEmp(simpleEmployee, acctEmployeePO);
TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(acctEmployeePO.getTaxAgentId());
buildEmployeeInfo(employeeInformation, simpleEmployee, taxAgentPO.getName(), SalaryAcctResultBO.buildEmployeeFieldName());
map.put("employeeInformation", employeeInformation);
map.put("salaryGroups", itemSetListDTOS);

View File

@ -295,7 +295,8 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
build.setName(name);
}
if (queryParam.getTaxAgentId() != null) {
build.setTaxAgentId(queryParam.getTaxAgentId());
List<SobTaxLinkPO> sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(queryParam.getTaxAgentId()).build());
build.setIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList()));
}
List<SalarySobPO> list = salarySobMapper.listSome(build);

View File

@ -282,8 +282,8 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration
@Override
public void delete(SalaryAcctRecordPO salaryAcctRecordPO) {
SalarySobPO sobPO = getSalarySobService(user).getById(salaryAcctRecordPO.getSalarySobId());
if (sobPO == null || sobPO.getTaxAgentId() == null) {
SalarySobPO sobPO = getSalarySobService(user).getByIdWithTax(salaryAcctRecordPO.getSalarySobId());
if (sobPO == null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "账套信息异常"));
}
@ -292,18 +292,20 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration
if (Objects.isNull(taxCycleDateRange)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误"));
}
List<TaxDeclarationPO> taxDeclarationPOS = listByTaxCycleAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getTaxCycle()), Collections.singleton(sobPO.getTaxAgentId()));
sobPO.getTaxAgentIds().forEach(taxAgentId -> {
List<TaxDeclarationPO> taxDeclarationPOS = listByTaxCycleAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getTaxCycle()), Collections.singleton(taxAgentId));
Set<Long> taxDeclarationIds = SalaryEntityUtil.properties(taxDeclarationPOS, TaxDeclarationPO::getId);
if (CollectionUtils.isNotEmpty(taxDeclarationIds)) {
// 删除个税申报表
getTaxDeclarationMapper().deleteByIds(taxDeclarationIds);
// 删除个税申报表详情
getTaxDeclarationDetailService(user).deleteByTaxDeclarationIds(taxDeclarationIds);
}
Set<Long> taxDeclarationIds = SalaryEntityUtil.properties(taxDeclarationPOS, TaxDeclarationPO::getId);
if (CollectionUtils.isNotEmpty(taxDeclarationIds)) {
// 删除个税申报表
getTaxDeclarationMapper().deleteByIds(taxDeclarationIds);
// 删除个税申报表详情
getTaxDeclarationDetailService(user).deleteByTaxDeclarationIds(taxDeclarationIds);
}
// 删除往期累计情况
getAddUpSituationService(user).deleteAddUpSituationList(salaryAcctRecordPO.getTaxCycle(), sobPO.getTaxAgentId());
// 删除往期累计情况
getAddUpSituationService(user).deleteAddUpSituationList(salaryAcctRecordPO.getTaxCycle(), taxAgentId);
});
}