申报表状态更新主记录
This commit is contained in:
parent
57a0030cc8
commit
7f965c41c9
|
|
@ -1,5 +1,6 @@
|
||||||
package com.engine.salary.entity.taxdeclaration.po;
|
package com.engine.salary.entity.taxdeclaration.po;
|
||||||
|
|
||||||
|
import com.engine.salary.enums.taxdeclaration.TaxDeclareStatusEnum;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -34,6 +35,7 @@ public class TaxDeclareStatusPO {
|
||||||
private Integer taxDeclareType;
|
private Integer taxDeclareType;
|
||||||
/**
|
/**
|
||||||
* 申报状态
|
* 申报状态
|
||||||
|
* @see TaxDeclareStatusEnum
|
||||||
*/
|
*/
|
||||||
private Integer taxDeclareStatus;
|
private Integer taxDeclareStatus;
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,8 @@ import java.time.YearMonth;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.engine.salary.enums.taxdeclaration.TaxDeclareStatusEnum.NOT_DECLARE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 个税申报
|
* 个税申报
|
||||||
* <p>Copyright: Copyright (c) 2022</p>
|
* <p>Copyright: Copyright (c) 2022</p>
|
||||||
|
|
@ -278,12 +280,12 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
||||||
TaxDeclareRecordPO oldTaxDeclareRecord = taxDeclareRecordMap.get(taxCycleEntry.getKey() + "-" + taxAgentIdEntry.getKey());
|
TaxDeclareRecordPO oldTaxDeclareRecord = taxDeclareRecordMap.get(taxCycleEntry.getKey() + "-" + taxAgentIdEntry.getKey());
|
||||||
// 如果已经生成了个税申报表,并且个税申报表已经申报过了,就跳过
|
// 如果已经生成了个税申报表,并且个税申报表已经申报过了,就跳过
|
||||||
if (oldTaxDeclareRecord != null) {
|
if (oldTaxDeclareRecord != null) {
|
||||||
if (!(Objects.equals(oldTaxDeclareRecord.getTaxDeclareType(), TaxDeclareTypeEnum.NORMAL_DECLARE.getValue()) && Objects.equals(oldTaxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.NOT_DECLARE.getValue()))) {
|
if (!(Objects.equals(oldTaxDeclareRecord.getTaxDeclareType(), TaxDeclareTypeEnum.NORMAL_DECLARE.getValue()) && Objects.equals(oldTaxDeclareRecord.getTaxDeclareStatus(), NOT_DECLARE.getValue()))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
needDeleteTaxDeclareRecordIds.add(oldTaxDeclareRecord.getId());
|
needDeleteTaxDeclareRecordIds.add(oldTaxDeclareRecord.getId());
|
||||||
}
|
}
|
||||||
TaxDeclareRecordPO taxDeclareRecord = new TaxDeclareRecordPO().setId(IdGenerator.generate()).setTaxAgentId(taxAgentIdEntry.getKey()).setSalaryMonth(saveParam.getSalaryMonth()).setTaxCycle(taxCycleEntry.getKey()).setTaxDeclareType(TaxDeclareTypeEnum.NORMAL_DECLARE.getValue()).setTaxDeclareStatus(TaxDeclareStatusEnum.NOT_DECLARE.getValue()).setRemark(saveParam.getDescription()).setCreator((long) user.getUID()).setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()).setCreateTime(now).setUpdateTime(now);
|
TaxDeclareRecordPO taxDeclareRecord = new TaxDeclareRecordPO().setId(IdGenerator.generate()).setTaxAgentId(taxAgentIdEntry.getKey()).setSalaryMonth(saveParam.getSalaryMonth()).setTaxCycle(taxCycleEntry.getKey()).setTaxDeclareType(TaxDeclareTypeEnum.NORMAL_DECLARE.getValue()).setTaxDeclareStatus(NOT_DECLARE.getValue()).setRemark(saveParam.getDescription()).setCreator((long) user.getUID()).setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY).setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue()).setCreateTime(now).setUpdateTime(now);
|
||||||
newTaxDeclareRecords.add(taxDeclareRecord);
|
newTaxDeclareRecords.add(taxDeclareRecord);
|
||||||
// 生成个税申报表
|
// 生成个税申报表
|
||||||
TaxDeclarationResult taxDeclarationResult = generateReportPerRecord(taxDeclareRecord, taxAgentIdEntry.getValue());
|
TaxDeclarationResult taxDeclarationResult = generateReportPerRecord(taxDeclareRecord, taxAgentIdEntry.getValue());
|
||||||
|
|
@ -348,7 +350,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
||||||
if (Objects.isNull(taxDeclareRecord)) {
|
if (Objects.isNull(taxDeclareRecord)) {
|
||||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156495, "参数异常,个税申报记录不存在或已被删除"));
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(156495, "参数异常,个税申报记录不存在或已被删除"));
|
||||||
}
|
}
|
||||||
if (!Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.NOT_DECLARE.getValue()) && !Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_FAIL.getValue())) {
|
if (!Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), NOT_DECLARE.getValue()) && !Objects.equals(taxDeclareRecord.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_FAIL.getValue())) {
|
||||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(182700, "对不起,只有未申报状态下可以刷新数据"));
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(182700, "对不起,只有未申报状态下可以刷新数据"));
|
||||||
}
|
}
|
||||||
// 查询税款所属期下的薪资核算人员
|
// 查询税款所属期下的薪资核算人员
|
||||||
|
|
@ -488,7 +490,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
||||||
for (Map.Entry<Date, List<SalaryAcctTaxAgentPO>> taxCycleEntry : taxCycleKeySalaryAcctTaxAgentMap.entrySet()) {
|
for (Map.Entry<Date, List<SalaryAcctTaxAgentPO>> taxCycleEntry : taxCycleKeySalaryAcctTaxAgentMap.entrySet()) {
|
||||||
Set<Long> archivedTaxAgentIds = SalaryEntityUtil.properties(taxCycleEntry.getValue(), SalaryAcctTaxAgentPO::getTaxAgentId);
|
Set<Long> archivedTaxAgentIds = SalaryEntityUtil.properties(taxCycleEntry.getValue(), SalaryAcctTaxAgentPO::getTaxAgentId);
|
||||||
List<TaxDeclareRecordPO> taxDeclareRecords = listBySalaryMonthAndTaxAgentIds(saveParam.getSalaryMonth(), archivedTaxAgentIds);
|
List<TaxDeclareRecordPO> taxDeclareRecords = listBySalaryMonthAndTaxAgentIds(saveParam.getSalaryMonth(), archivedTaxAgentIds);
|
||||||
TaxDeclareRecordPO declareSuccessTaxDeclareRecord = taxDeclareRecords.stream().filter(taxDeclareRecordPO -> archivedTaxAgentIds.contains(taxDeclareRecordPO.getTaxAgentId()) && !(Objects.equals(taxDeclareRecordPO.getTaxDeclareStatus(), TaxDeclareStatusEnum.NOT_DECLARE.getValue()) || Objects.equals(taxDeclareRecordPO.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_FAIL.getValue()))).findAny().orElse(null);
|
TaxDeclareRecordPO declareSuccessTaxDeclareRecord = taxDeclareRecords.stream().filter(taxDeclareRecordPO -> archivedTaxAgentIds.contains(taxDeclareRecordPO.getTaxAgentId()) && !(Objects.equals(taxDeclareRecordPO.getTaxDeclareStatus(), NOT_DECLARE.getValue()) || Objects.equals(taxDeclareRecordPO.getTaxDeclareStatus(), TaxDeclareStatusEnum.DECLARE_FAIL.getValue()))).findAny().orElse(null);
|
||||||
// 已经申报成功了的个税申报表的个税扣缴义务人不允许重新生成
|
// 已经申报成功了的个税申报表的个税扣缴义务人不允许重新生成
|
||||||
if (Objects.nonNull(declareSuccessTaxDeclareRecord)) {
|
if (Objects.nonNull(declareSuccessTaxDeclareRecord)) {
|
||||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(160522, "已开启智能算薪业务,个税扣缴义务人{0}的税款所属期{1}的个税申报表正在申报中或者已经申报成功,不可重复生成").replace("{0}", taxAgentNameMap.get(declareSuccessTaxDeclareRecord.getTaxAgentId())).replace("{1}", SalaryDateUtil.getFormatYearMonth(declareSuccessTaxDeclareRecord.getTaxCycle())));
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(160522, "已开启智能算薪业务,个税扣缴义务人{0}的税款所属期{1}的个税申报表正在申报中或者已经申报成功,不可重复生成").replace("{0}", taxAgentNameMap.get(declareSuccessTaxDeclareRecord.getTaxAgentId())).replace("{1}", SalaryDateUtil.getFormatYearMonth(declareSuccessTaxDeclareRecord.getTaxCycle())));
|
||||||
|
|
@ -589,7 +591,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
||||||
if (CollectionUtils.isEmpty(taxDeclareRecords)) {
|
if (CollectionUtils.isEmpty(taxDeclareRecords)) {
|
||||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(160524, "个税申报表不存在或已被删除"));
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(160524, "个税申报表不存在或已被删除"));
|
||||||
}
|
}
|
||||||
List<TaxDeclareRecordPO> cantDeleteTaxDeclareRecords = taxDeclareRecords.stream().filter(e -> !(Objects.equals(e.getTaxDeclareType(), TaxDeclareTypeEnum.NORMAL_DECLARE.getValue()) && Objects.equals(e.getTaxDeclareStatus(), TaxDeclareStatusEnum.NOT_DECLARE.getValue()))).collect(Collectors.toList());
|
List<TaxDeclareRecordPO> cantDeleteTaxDeclareRecords = taxDeclareRecords.stream().filter(e -> !(Objects.equals(e.getTaxDeclareType(), TaxDeclareTypeEnum.NORMAL_DECLARE.getValue()) && Objects.equals(e.getTaxDeclareStatus(), NOT_DECLARE.getValue()))).collect(Collectors.toList());
|
||||||
if (CollectionUtils.isNotEmpty(cantDeleteTaxDeclareRecords)) {
|
if (CollectionUtils.isNotEmpty(cantDeleteTaxDeclareRecords)) {
|
||||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(177854, "个税申报表已经申报,无法删除"));
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(177854, "个税申报表已经申报,无法删除"));
|
||||||
}
|
}
|
||||||
|
|
@ -1064,7 +1066,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
||||||
|
|
||||||
//更新申报状态
|
//更新申报状态
|
||||||
declareStatus.setTaxDeclareType(TaxDeclareTypeEnum.UPDATE_DECLARE.getValue());
|
declareStatus.setTaxDeclareType(TaxDeclareTypeEnum.UPDATE_DECLARE.getValue());
|
||||||
declareStatus.setTaxDeclareStatus(TaxDeclareStatusEnum.NOT_DECLARE.getValue());
|
declareStatus.setTaxDeclareStatus(NOT_DECLARE.getValue());
|
||||||
declareStatus.setRequestId("");
|
declareStatus.setRequestId("");
|
||||||
getTaxDeclareStatusMapper().updateIgnoreNull(declareStatus);
|
getTaxDeclareStatusMapper().updateIgnoreNull(declareStatus);
|
||||||
|
|
||||||
|
|
@ -1200,14 +1202,19 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Integer> reportTypes = new HashSet<>();
|
Set<Integer> reportTypes = new HashSet<>();
|
||||||
|
|
||||||
taxDeclarations.forEach(taxDeclarationPO -> {
|
taxDeclarations.forEach(taxDeclarationPO -> {
|
||||||
reportTypes.add(IncomeCategoryEnum.parseByValue(taxDeclarationPO.getIncomeCategory()).getReportType().getValue());
|
reportTypes.add(IncomeCategoryEnum.parseByValue(taxDeclarationPO.getIncomeCategory()).getReportType().getValue());
|
||||||
});
|
});
|
||||||
|
|
||||||
List<TaxDeclareStatusPO> statuses = new ArrayList<>();
|
List<TaxDeclareStatusPO> statuses = new ArrayList<>();
|
||||||
|
|
||||||
reportTypes.forEach(reportType -> {
|
|
||||||
|
int personNum = 0;
|
||||||
|
BigDecimal taxPayAmount = new BigDecimal(0);
|
||||||
|
BigDecimal taxPaidAmount = new BigDecimal(0);
|
||||||
|
BigDecimal taxPurePaidAmount = new BigDecimal(0);
|
||||||
|
|
||||||
|
for (Integer reportType : reportTypes) {
|
||||||
TaxDeclareStatusPO declareStatus = getTaxDeclareStatus(id, reportType);
|
TaxDeclareStatusPO declareStatus = getTaxDeclareStatus(id, reportType);
|
||||||
if (declareStatus == null) {
|
if (declareStatus == null) {
|
||||||
declareStatus = TaxDeclareStatusPO.builder()
|
declareStatus = TaxDeclareStatusPO.builder()
|
||||||
|
|
@ -1225,9 +1232,23 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe
|
||||||
.build();
|
.build();
|
||||||
getTaxDeclareStatusMapper().insertIgnoreNull(declareStatus);
|
getTaxDeclareStatusMapper().insertIgnoreNull(declareStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
statuses.add(declareStatus);
|
statuses.add(declareStatus);
|
||||||
});
|
|
||||||
|
personNum += declareStatus.getPersonNum();
|
||||||
|
taxPayAmount = taxPayAmount.add(SalaryEntityUtil.empty2Zero(declareStatus.getTaxPayAmount()));
|
||||||
|
taxPaidAmount = taxPaidAmount.add(SalaryEntityUtil.empty2Zero(declareStatus.getTaxPaidAmount()));
|
||||||
|
taxPurePaidAmount = taxPurePaidAmount.add(SalaryEntityUtil.empty2Zero(declareStatus.getTaxPurePaidAmount()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新记录的状态,各个报表状态一致则采纳,否则取最小的进度状态
|
||||||
|
Integer declareStatusEnum = statuses.stream().map(TaxDeclareStatusPO::getTaxDeclareStatus).min(Comparator.comparing(Integer::valueOf)).orElse(NOT_DECLARE.getValue());
|
||||||
|
|
||||||
|
taxDeclareRecord.setPersonNum(personNum);
|
||||||
|
taxDeclareRecord.setTaxPayAmount(taxPayAmount.toString());
|
||||||
|
taxDeclareRecord.setTaxPaidAmount(taxPaidAmount.toString());
|
||||||
|
taxDeclareRecord.setTaxPurePaidAmount(taxPurePaidAmount.toString());
|
||||||
|
taxDeclareRecord.setTaxDeclareStatus(declareStatusEnum);
|
||||||
|
updateById(taxDeclareRecord);
|
||||||
|
|
||||||
return statuses;
|
return statuses;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -373,7 +373,7 @@ public class TaxDeclareRecordWrapper extends Service {
|
||||||
.displayIcon(Objects.equals(taxDeclareRecord.getDisplayUpdateIcon(), 1))
|
.displayIcon(Objects.equals(taxDeclareRecord.getDisplayUpdateIcon(), 1))
|
||||||
.declareFailSize(taxDeclareFails.size())
|
.declareFailSize(taxDeclareFails.size())
|
||||||
.abnormalSize(notDeclareTaxDeclareEmployees.size() + noValueTaxDeclareEmployees.size())
|
.abnormalSize(notDeclareTaxDeclareEmployees.size() + noValueTaxDeclareEmployees.size())
|
||||||
.taxPaidAmount(SalaryEntityUtil.thousandthConvert(taxDeclareRecord.getTaxPaidAmount()))
|
.taxPaidAmount(SalaryEntityUtil.thousandthConvert(taxDeclareStatus.getTaxPaidAmount()))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue