申报表分权
This commit is contained in:
parent
cedc9f2644
commit
79632dd1bf
|
|
@ -133,4 +133,4 @@ ALTER TABLE hrsa_tax_agent ADD COLUMN payment_agency varchar(255) NULL COMMENT '
|
|||
ALTER TABLE hrsa_salary_sob ADD COLUMN tax_agent_id bigint(0) NULL COMMENT '个税扣缴义务人的主键id' AFTER tenant_key;
|
||||
|
||||
|
||||
INSERT INTO hrsa_tax_agent_base(id, devolution_status, create_time, update_time, creator, delete_type, tenant_key) VALUES (1653303537239, 1, '2022-05-23 18:58:53', '2022-05-23 19:12:12', 1, 0, 'all_teams');
|
||||
INSERT INTO hrsa_tax_agent_base(id, devolution_status, create_time, update_time, creator, delete_type, tenant_key) VALUES (1653303537239, 0, '2022-05-23 18:58:53', '2022-05-23 19:12:12', 1, 0, 'all_teams');
|
||||
|
|
|
|||
|
|
@ -93,4 +93,5 @@ public class SalaryAcctResultPO {
|
|||
private Collection<Long> salaryAcctRecordIds;
|
||||
private Collection<Long> salaryAcctEmpIds;
|
||||
private Collection<Long> employeeIds;
|
||||
private Collection<Long> taxAgentIds;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,12 @@
|
|||
#{employeeId}
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
<if test="taxAgentIds != null and taxAgentIds.size()>0">
|
||||
AND tax_agent_id IN
|
||||
<foreach collection="taxAgentIds" open="(" item="taxAgentId" separator="," close=")">
|
||||
#{taxAgentId}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY id DESC
|
||||
</select>
|
||||
|
||||
|
|
|
|||
|
|
@ -131,4 +131,13 @@ public interface SalaryAcctResultService {
|
|||
* @param simpleEmployee
|
||||
*/
|
||||
void calculate(SalaryAcctCalculateParam calculateParam, DataCollectionEmployee simpleEmployee);
|
||||
|
||||
/**
|
||||
* 根据薪资核算记录的id、个税扣缴义务人查询薪资核算结果
|
||||
*
|
||||
* @param salaryAcctRecordIds 薪资核算记录的id
|
||||
* @param taxAgentIds 个税扣缴义务人id
|
||||
* @return
|
||||
*/
|
||||
List<SalaryAcctResultPO> listBySalaryAcctRecordIdsAndTaxAgentIds(Collection<Long> salaryAcctRecordIds, Collection<Long> taxAgentIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -398,6 +398,12 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
|
||||
@Override
|
||||
public PageInfo<AddUpDeductionDTO> listPage(AddUpDeductionQueryParam queryParam) {
|
||||
//申报月份
|
||||
List<String> declareMonth = queryParam.getDeclareMonth();
|
||||
if (CollectionUtils.isNotEmpty(declareMonth)) {
|
||||
queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
long employeeId = user.getUID();
|
||||
|
||||
// 未开启分权或是薪酬模块总管理员
|
||||
|
|
|
|||
|
|
@ -161,6 +161,12 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
|
|||
|
||||
@Override
|
||||
public PageInfo<AddUpSituationDTO> listPage(AddUpSituationQueryParam queryParam) {
|
||||
|
||||
List<String> taxYearMonth = queryParam.getTaxYearMonth();
|
||||
if(CollectionUtils.isNotEmpty(taxYearMonth)){
|
||||
queryParam.setTaxYearMonth(taxYearMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
long employeeId = user.getUID();
|
||||
// 未开启分权或是薪酬模块总管理员
|
||||
if (!getTaxAgentService(user).isOpenDevolution() || getTaxAgentService(user).isChief(employeeId)) {
|
||||
|
|
@ -222,7 +228,9 @@ public class AddUpSituationServiceImpl extends Service implements AddUpSituation
|
|||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100353, "参数有误:税款所属期必传"));
|
||||
}
|
||||
AddUpSituationBiz biz = new AddUpSituationBiz();
|
||||
biz.deleteSome(AddUpSituation.builder().employeeIds(employeeIds).taxYearMonth(SalaryDateUtil.toDateStartOfMonth(taxYearMonth)).build());
|
||||
String formatLocalDate = SalaryDateUtil.getFormatLocalDate(SalaryDateUtil.toDateStartOfMonth(taxYearMonth));
|
||||
Date date = SalaryDateUtil.localDateToDate(LocalDate.parse(formatLocalDate, SalaryDateUtil.DATE_FORMATTER));
|
||||
biz.deleteSome(AddUpSituation.builder().employeeIds(employeeIds).taxYearMonth(date).build());
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,12 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
|
|||
|
||||
@Override
|
||||
public PageInfo<OtherDeductionListDTO> listPage(OtherDeductionQueryParam queryParam) {
|
||||
//申报月份
|
||||
List<String> declareMonth = queryParam.getDeclareMonth();
|
||||
if (CollectionUtils.isNotEmpty(declareMonth)) {
|
||||
queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
long employeeId = user.getUID();
|
||||
// 未开启分权或是薪酬模块总管理员
|
||||
if (!getTaxAgentV2Service(user).isOpenDevolution() || getTaxAgentV2Service(user).isChief(employeeId)) {
|
||||
|
|
|
|||
|
|
@ -148,20 +148,21 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
|
|||
|
||||
// 判断是否开启了分权
|
||||
Boolean needAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
|
||||
// 如果没有开启分权,直接分页
|
||||
if (!needAuth) {
|
||||
// 查询薪资核算记录
|
||||
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
|
||||
List<SalaryAcctRecordPO> salaryAcctRecordPOS = getSalaryAcctRecordMapper().listSome(po);
|
||||
page.setList(salaryAcctRecordPOS);
|
||||
return page;
|
||||
} else {
|
||||
List<SalaryAcctRecordPO> salaryAcctRecords = getSalaryAcctRecordMapper().listSome(po);
|
||||
List<SalaryAcctRecordPO> canViewSalaryAcctRecords = filterByAuthority(salaryAcctRecords, currentEmployeeId);
|
||||
page.setTotal(canViewSalaryAcctRecords.size());
|
||||
page.setList(SalaryPageUtil.subList((int) page.getPageNum(), (int) page.getPageSize(), canViewSalaryAcctRecords));
|
||||
return page;
|
||||
if (needAuth) {
|
||||
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByAdmin();
|
||||
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
|
||||
|
||||
if (CollectionUtils.isEmpty(salarySobIds)) {
|
||||
return new PageInfo<>();
|
||||
}
|
||||
|
||||
po.setSalarySobIds(salarySobIds);
|
||||
}
|
||||
|
||||
// 查询薪资核算记录
|
||||
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
|
||||
List<SalaryAcctRecordPO> salaryAcctRecordPOS = getSalaryAcctRecordMapper().listSome(po);
|
||||
return new PageInfo<>(salaryAcctRecordPOS,SalaryAcctRecordPO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -518,7 +519,7 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
|
|||
.map(SalaryAcctEmployeePO::getSalaryAcctRecordId)
|
||||
.collect(Collectors.toSet());
|
||||
return salaryAcctRecords.stream()
|
||||
.filter(salaryAcctRecordPO -> canViewSalaryAcctRecordIds.contains(salaryAcctRecordPO.getId()) || Objects.equals(salaryAcctRecordPO.getCreator(), employeeId))
|
||||
.filter(salaryAcctRecordPO -> canViewSalaryAcctRecordIds.contains(salaryAcctRecordPO.getId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -541,4 +541,12 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
|
|||
// throw e;
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SalaryAcctResultPO> listBySalaryAcctRecordIdsAndTaxAgentIds(Collection<Long> salaryAcctRecordIds, Collection<Long> taxAgentIds) {
|
||||
if (CollectionUtils.isEmpty(salaryAcctRecordIds)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getSalaryAcctResultMapper().listSome(SalaryAcctResultPO.builder().salaryAcctRecordIds(salaryAcctRecordIds).taxAgentIds(taxAgentIds).build());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -379,6 +379,19 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
|
|||
|
||||
@Override
|
||||
public void deleteByIds(Collection<Long> ids) {
|
||||
|
||||
//分权
|
||||
Boolean isOpenDevolution = getTaxAgentService(user).isOpenDevolution();
|
||||
if (isOpenDevolution) {
|
||||
List<SalarySobPO> salarySobPOS = listByAdmin();
|
||||
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
|
||||
Optional<Long> first = ids.stream().filter(f -> !salarySobIds.contains(f)).findFirst();
|
||||
if (first.isPresent()) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "无权限删除"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 查询薪资账套
|
||||
List<SalarySobPO> salarySobPOS = listByIds(ids);
|
||||
if (CollectionUtils.isEmpty(salarySobPOS)) {
|
||||
|
|
@ -535,12 +548,9 @@ public class SalarySobServiceImpl extends Service implements SalarySobService {
|
|||
|
||||
public List<SalarySobPO> filterByAdmin(List<SalarySobPO> salarySobPOS) {
|
||||
long employeeId = user.getUID();
|
||||
// 判断是否是“总管理员”
|
||||
Boolean isChief = getTaxAgentService(user).isChief(employeeId);
|
||||
// 是否开启分权
|
||||
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
||||
// 开启分权后
|
||||
// 总管理员都能看见
|
||||
// 管理员自己管理的个税下的
|
||||
if (!openDevolution) {
|
||||
return salarySobPOS;
|
||||
|
|
|
|||
|
|
@ -461,6 +461,24 @@ public class SalaryDateUtil {
|
|||
|
||||
return localDate;
|
||||
}
|
||||
|
||||
public static Date dateStrToLocalTime(String date) {
|
||||
Date localDate = null;
|
||||
try {
|
||||
if (date.contains("/")) {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
|
||||
localDate = format.parse(date);
|
||||
} else if (date.contains("-")) {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
||||
localDate = format.parse(date);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("日期解析异常,{}", date);
|
||||
localDate = null;
|
||||
}
|
||||
|
||||
return localDate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -54,13 +54,6 @@ public class AddUpDeductionWrapper extends Service {
|
|||
* @return
|
||||
*/
|
||||
public PageInfo<AddUpDeductionDTO> list(AddUpDeductionQueryParam queryParam) {
|
||||
|
||||
//申报月份
|
||||
List<String> declareMonth = queryParam.getDeclareMonth();
|
||||
if (CollectionUtils.isNotEmpty(declareMonth)) {
|
||||
queryParam.setDeclareMonth(declareMonth.stream().map(e -> e + "-01 00:00:00").collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
PageInfo<AddUpDeductionDTO> pageInfo = getAddUpDeductionService(user).listPage(queryParam);
|
||||
|
||||
return pageInfo;
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ public class AddUpSituationWrapper extends Service {
|
|||
* @return
|
||||
*/
|
||||
public PageInfo<AddUpSituationDTO> list(AddUpSituationQueryParam queryParam) {
|
||||
// queryParam.setTaxYearMonthDate(CollectionUtils.emptyIfNull(queryParam.getTaxYearMonth()).stream().map(e-> LocalDate.of(e.getYear(),e.getMonthValue(),1)).collect(Collectors.toList()));
|
||||
|
||||
return getAddUpSituationService(user).listPage(queryParam);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ public class SalaryAcctRecordWrapper extends Service {
|
|||
}
|
||||
|
||||
/**
|
||||
* 重新归档
|
||||
* 重新核算
|
||||
*
|
||||
* @param id 薪资核算记录的id
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public class SalaryArchiveTaxAgentWrapper extends Service {
|
|||
|
||||
private Map<String, Object> buildTaxAgentForm(Date effectiveTime, String adjustReason, String adjustBefore, Long adjustAfter) {
|
||||
// 个税扣缴义务人下拉列表
|
||||
Collection<TaxAgentListDTO> taxAgentList = getTaxAgentService(user).findAll();
|
||||
Collection<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long)user.getUID());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("adjustReasonList", SalaryArchiveTaxAgentAdjustReasonEnum.getList());
|
||||
map.put("taxAgentList", taxAgentList);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.engine.salary.wrapper;
|
|||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.salary.biz.EmployBiz;
|
||||
import com.engine.salary.biz.SalaryItemBiz;
|
||||
import com.engine.salary.common.LocalDateRange;
|
||||
import com.engine.salary.component.WeaFormOption;
|
||||
import com.engine.salary.entity.datacollection.AddUpSituation;
|
||||
|
|
@ -36,6 +35,7 @@ import com.engine.salary.util.db.MapperProxyFactory;
|
|||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import weaver.hrm.User;
|
||||
|
||||
|
|
@ -92,6 +92,10 @@ public class TaxDeclarationWrapper extends Service {
|
|||
private SalaryAcctResultService getSalaryAcctResultService(User user) {
|
||||
return ServiceUtil.getService(SalaryAcctResultServiceImpl.class, user);
|
||||
}
|
||||
private SalaryItemService getSalaryItemService(User user) {
|
||||
return (SalaryItemService) ServiceUtil.getService(SalaryItemServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 个税申报表列表
|
||||
|
|
@ -192,76 +196,79 @@ public class TaxDeclarationWrapper extends Service {
|
|||
public void save(TaxDeclarationSaveParam saveParam) {
|
||||
long currentEmployeeId = user.getUID();
|
||||
|
||||
// 个税扣缴义务人id
|
||||
Set<Long> taxAgentIds;
|
||||
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
||||
if (BooleanUtils.isFalse(openDevolution)) {
|
||||
taxAgentIds = SalaryEntityUtil.properties(getTaxAgentService(user).listAll(), TaxAgentPO::getId);
|
||||
} else {
|
||||
taxAgentIds = SalaryEntityUtil.properties(getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId), TaxAgentPO::getId);
|
||||
}
|
||||
|
||||
// 检查是否具有权限
|
||||
if (CollectionUtils.isEmpty(taxAgentIds)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(0, "对不起,您不具备任何个税扣缴义务人的管理权限"));
|
||||
}
|
||||
|
||||
// 查询个税扣缴义务人
|
||||
List<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listByIds(taxAgentIds);
|
||||
Map<Long, String> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgentPO::getId, TaxAgentPO::getName);
|
||||
|
||||
// 薪资所属月的日期范围
|
||||
LocalDateRange salaryMonthDateRange = SalaryDateUtil.localDate2Range(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1)));
|
||||
if (Objects.isNull(salaryMonthDateRange)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "薪资所属月参数错误"));
|
||||
}
|
||||
|
||||
Long taxAgentId = saveParam.getTaxAgentId();
|
||||
|
||||
if (Objects.isNull(taxAgentId)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "请选择个税扣缴义务人"));
|
||||
}
|
||||
|
||||
//查询个税扣缴义务人
|
||||
TaxAgentPO taxAgentPO = getTaxAgentService(user).getById(taxAgentId);
|
||||
if (Objects.isNull(taxAgentPO)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "所选个税扣缴义务人不存在"));
|
||||
}
|
||||
|
||||
//开启分权
|
||||
Boolean isNeedAuth = getTaxAgentService(user).isNeedAuth(currentEmployeeId);
|
||||
if (isNeedAuth) {
|
||||
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin(currentEmployeeId);
|
||||
Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId);
|
||||
if(!taxAgentIds.contains(taxAgentId)){
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "无权限操作所选个税扣缴义务人"));
|
||||
}
|
||||
}
|
||||
|
||||
//获取个税扣缴义务人下的账套
|
||||
List<SalarySobPO> salarySobs = getSalarySobService(user).listByTaxAgentId(taxAgentId);
|
||||
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobs, SalarySobPO::getId);
|
||||
|
||||
// 查询薪资所属月个税扣缴义务人已经生成过的个税申报表
|
||||
List<TaxDeclarationPO> taxDeclarationPOS = listBySalaryMonthTax(TaxDeclarationPO.builder().salaryMonths(salaryMonthDateRange).taxAgentId(taxAgentId).build());
|
||||
List<TaxDeclarationPO> taxDeclarationPOS = listBySalaryMonthTax(TaxDeclarationPO.builder().salaryMonths(salaryMonthDateRange).taxAgentIds(taxAgentNameMap.keySet()).build());
|
||||
// 已经生成过个税申报表,不允许再次生成个税申报表
|
||||
if (CollectionUtils.isNotEmpty(taxDeclarationPOS)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98873, "{0}已经生成过个税申报表,不允许再次生成").replace("{0}", saveParam.getSalaryMonth().toString()));
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(107986, "{0}在{1}已经生成过个税申报表,不允许再次生成")
|
||||
.replace("{0}", taxAgentNameMap.get(taxDeclarationPOS.get(0).getTaxAgentId()))
|
||||
.replace("{1}", saveParam.getSalaryMonth().toString()));
|
||||
}
|
||||
// 查询薪资所属月的薪资核算记录
|
||||
List<SalaryAcctRecordPO> salaryAcctRecordPOS = listBySalaryMonth(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).salarySobIds(salarySobIds).build());
|
||||
List<SalaryAcctRecordPO> salaryAcctRecordPOS = listBySalaryMonth(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).build());
|
||||
// 无薪资核算记录,不允许生成个税申报表
|
||||
if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", saveParam.getSalaryMonth().toString()));
|
||||
}
|
||||
// 查询薪资核算结果
|
||||
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultService(user)
|
||||
.listBySalaryAcctRecordIdsAndTaxAgentIds(SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId), taxAgentIds);
|
||||
|
||||
// 无薪资核算结果,不允许生成个税申报表
|
||||
if (CollectionUtils.isEmpty(salaryAcctResultPOS)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(110093, "{0}无可申报数据")
|
||||
.replace("{0}", saveParam.getSalaryMonth().toString()));
|
||||
}
|
||||
|
||||
Set<Long> salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryAcctRecordId);
|
||||
salaryAcctRecordPOS = salaryAcctRecordPOS.stream().filter(salaryAcctRecordPO -> salaryAcctRecordIds.contains(salaryAcctRecordPO.getId())).collect(Collectors.toList());
|
||||
// 如果存在未归档的,也不允许生成个税申报表
|
||||
boolean notArchived = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> !Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()));
|
||||
if (notArchived) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报").replace("{0}", saveParam.getSalaryMonth().toString()));
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报")
|
||||
.replace("{0}", saveParam.getSalaryMonth().toString()));
|
||||
}
|
||||
// 如果当前薪资所属月下存在不同的税款所属期,属于异常业务场景,不允许生成个税申报表
|
||||
Date taxCycle = salaryAcctRecordPOS.get(0).getTaxCycle();
|
||||
boolean differentTaxCycle = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> salaryAcctRecordPO.getTaxCycle().compareTo(taxCycle) != 0);
|
||||
if (differentTaxCycle) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98876, "{0}存在不同的税款所属期,无法正常生成个税申报表,请调整账套设置,重新核算后再生成个税申报表").replace("{0}", saveParam.getSalaryMonth().toString()));
|
||||
}
|
||||
// 查询薪资核算结果
|
||||
Set<Long> salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId);
|
||||
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(salaryAcctRecordIds);
|
||||
// 无薪资核算结果,不允许生成个税申报表
|
||||
if (CollectionUtils.isEmpty(salaryAcctResultPOS)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", saveParam.getSalaryMonth().toString()));
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98876, "{0}存在不同的税款所属期,无法正常生成个税申报表,请调整账套设置,重新核算后再生成个税申报表")
|
||||
.replace("{0}", saveParam.getSalaryMonth().toString()));
|
||||
}
|
||||
// 查询薪资账套
|
||||
// Set<Long> salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId);
|
||||
// List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByIds(salarySobIds);
|
||||
Set<Long> salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId);
|
||||
List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByIds(salarySobIds);
|
||||
|
||||
// 查询所有薪资项目
|
||||
List<SalaryItemPO> salaryItemPOS = new SalaryItemBiz().listAll();
|
||||
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listAll();
|
||||
|
||||
|
||||
// 处理要保存的数据
|
||||
TaxDeclarationBO.Result result = TaxDeclarationBO.handle(saveParam, taxCycle, user, salaryItemPOS, salarySobs, salaryAcctResultPOS);
|
||||
TaxDeclarationBO.Result result = TaxDeclarationBO.handle(saveParam, taxCycle, user, salaryItemPOS, salarySobPOS, salaryAcctResultPOS);
|
||||
// 保存个税申报表
|
||||
if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarations())) {
|
||||
getTaxDeclarationMapper().batchInsert(result.getNeedInsertTaxDeclarations());
|
||||
|
|
@ -272,88 +279,12 @@ public class TaxDeclarationWrapper extends Service {
|
|||
}
|
||||
// 保存累计情况
|
||||
if (CollectionUtils.isNotEmpty(result.getNeedInsertAccumulatedSituations())) {
|
||||
Set<Long> taxAgentIds = SalaryEntityUtil.properties(result.getNeedInsertTaxDeclarations(), TaxDeclarationPO::getTaxAgentId);
|
||||
getAddUpSituationService(user).deleteByTaxYearMonthAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxCycle), taxAgentIds);
|
||||
List<List<AddUpSituation>> partition = Lists.partition((List) result.getNeedInsertAccumulatedSituations(), 100);
|
||||
partition.forEach(getAddUpSituationMapper()::insertData);
|
||||
}
|
||||
// 更新薪资核算记录的状态
|
||||
getSalaryAcctRecordService(user).updateStatusByIds(salaryAcctRecordIds, SalaryAcctRecordStatusEnum.DECLARED);
|
||||
//
|
||||
// } else {
|
||||
//
|
||||
// // 查询薪资所属月已经生成过的个税申报表
|
||||
// List<TaxDeclarationPO> taxDeclarationPOS = listBySalaryMonthTax(TaxDeclarationPO.builder().salaryMonths(salaryMonthDateRange).build());
|
||||
// // 已经生成过个税申报表,不允许再次生成个税申报表
|
||||
// if (CollectionUtils.isNotEmpty(taxDeclarationPOS)) {
|
||||
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98873, "{0}已经生成过个税申报表,不允许再次生成").replace("{0}", saveParam.getSalaryMonth().toString()));
|
||||
// }
|
||||
// // 查询薪资所属月的薪资核算记录
|
||||
// List<SalaryAcctRecordPO> salaryAcctRecordPOS = listBySalaryMonth(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).build());
|
||||
// // 无薪资核算记录,不允许生成个税申报表
|
||||
// if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) {
|
||||
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", saveParam.getSalaryMonth().toString()));
|
||||
// }
|
||||
// // 如果存在未归档的,也不允许生成个税申报表
|
||||
// boolean notArchived = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> !Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue()));
|
||||
// if (notArchived) {
|
||||
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报").replace("{0}", saveParam.getSalaryMonth().toString()));
|
||||
// }
|
||||
// // 如果当前薪资所属月下存在不同的税款所属期,属于异常业务场景,不允许生成个税申报表
|
||||
// Date taxCycle = salaryAcctRecordPOS.get(0).getTaxCycle();
|
||||
// boolean differentTaxCycle = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> salaryAcctRecordPO.getTaxCycle().compareTo(taxCycle) != 0);
|
||||
// if (differentTaxCycle) {
|
||||
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98876, "{0}存在不同的税款所属期,无法正常生成个税申报表,请调整账套设置,重新核算后再生成个税申报表").replace("{0}", saveParam.getSalaryMonth().toString()));
|
||||
// }
|
||||
// // 查询薪资核算结果
|
||||
// Set<Long> salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId);
|
||||
// List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctRecordIds(salaryAcctRecordIds);
|
||||
// // 无薪资核算结果,不允许生成个税申报表
|
||||
// if (CollectionUtils.isEmpty(salaryAcctResultPOS)) {
|
||||
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", saveParam.getSalaryMonth().toString()));
|
||||
// }
|
||||
// // 查询薪资账套
|
||||
// Set<Long> salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId);
|
||||
// List<SalarySobPO> salarySobPOS = getSalarySobService(user).listByIds(salarySobIds);
|
||||
//
|
||||
// // 查询所有薪资项目
|
||||
// List<SalaryItemPO> salaryItemPOS = new SalaryItemBiz().listAll();
|
||||
// // 处理要保存的数据
|
||||
// TaxDeclarationBO.Result result = TaxDeclarationBO.handle(saveParam, taxCycle, user, salaryItemPOS, salarySobPOS, salaryAcctResultPOS);
|
||||
// // 保存个税申报表
|
||||
// if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarations())) {
|
||||
// getTaxDeclarationMapper().batchInsert(result.getNeedInsertTaxDeclarations());
|
||||
// }
|
||||
// // 保存个税申报表明细
|
||||
// if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarationDetails())) {
|
||||
// getTaxDeclarationDetailService(user).batchSave(result.getNeedInsertTaxDeclarationDetails());
|
||||
// }
|
||||
// // 保存累计情况
|
||||
// if (CollectionUtils.isNotEmpty(result.getNeedInsertAccumulatedSituations())) {
|
||||
// Set<Long> taxAgentIds = SalaryEntityUtil.properties(result.getNeedInsertTaxDeclarations(), TaxDeclarationPO::getTaxAgentId);
|
||||
// getAddUpSituationService(user).deleteByTaxYearMonthAndTaxAgentIds(SalaryDateUtil.localDate2YearMonth(taxCycle), taxAgentIds);
|
||||
// List<List<AddUpSituation>> partition = Lists.partition((List) result.getNeedInsertAccumulatedSituations(), 100);
|
||||
// partition.forEach(getAddUpSituationMapper()::insertData);
|
||||
// }
|
||||
// // 更新薪资核算记录的状态
|
||||
// getSalaryAcctRecordService(user).updateStatusByIds(salaryAcctRecordIds, SalaryAcctRecordStatusEnum.DECLARED);
|
||||
// }
|
||||
// 查询个税扣缴义务人
|
||||
// Set<Long> taxAgentIds = SalaryEntityUtil.properties(result.getNeedInsertTaxDeclarations(), TaxDeclarationPO::getTaxAgentId);
|
||||
// List<TaxAgent> taxAgentPOS = new TaxAgentBiz().listByIds(taxAgentIds);
|
||||
// Map<Long, String> taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgentPOS, TaxAgent::getId, TaxAgent::getName);
|
||||
// 记录日志
|
||||
/*for (TaxDeclarationPO taxDeclarationPO : result.getNeedInsertTaxDeclarations()) {
|
||||
String targetName = SalaryDateUtil.toYearMonth(taxDeclarationPO.getSalaryMonth())
|
||||
+ "(" + taxAgentNameMap.getOrDefault(taxDeclarationPO.getTaxAgentId(), StringUtils.EMPTY) + ")";
|
||||
LoggerContext<TaxDeclarationPO> loggerContext = new LoggerContext<>();
|
||||
loggerContext.setTargetId(String.valueOf(taxDeclarationPO.getId()));
|
||||
loggerContext.setTargetName(targetName);
|
||||
loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
||||
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(99815, "生成个税申报表"));
|
||||
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(99815, "生成个税申报表"));
|
||||
taxDeclarationLoggerTemplate.write(loggerContext);
|
||||
}*/
|
||||
}
|
||||
|
||||
public List<TaxDeclarationPO> listBySalaryMonthTax(TaxDeclarationPO build) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue