diff --git a/resource/WEB-INF/lib/hrmelog.jar b/resource/WEB-INF/lib/hrmelog.jar index 7589cfeae..ba4091f61 100644 Binary files a/resource/WEB-INF/lib/hrmelog.jar and b/resource/WEB-INF/lib/hrmelog.jar differ diff --git a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationRequest.java b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationRequest.java index 5bcad824f..284b5a010 100644 --- a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationRequest.java +++ b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationRequest.java @@ -9,6 +9,7 @@ import com.engine.salary.entity.taxdeclaration.po.TaxReportColumnPO; import com.engine.salary.enums.datacollection.TaxFreeTypeEnum; import com.engine.salary.enums.employeedeclare.CardTypeEnum; import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum; +import com.engine.salary.enums.salarysob.DeclareReportTypeEnum; import com.engine.salary.enums.salarysob.IncomeCategoryEnum; import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; @@ -43,6 +44,10 @@ public class TaxDeclarationRequest { Map> taxReportColumnMap = SalaryEntityUtil.group2Map(taxReportColumns, TaxReportColumnPO::getIncomeCategory); Map employeeDeclareMap = SalaryEntityUtil.convert2Map(employeeDeclares, EmployeeDeclarePO::getEmployeeId); Map> taxDeclarationValueMap = SalaryEntityUtil.group2Map(taxDeclarationValues, TaxDeclarationValuePO::getTaxDeclarationId); + taxDeclarations = taxDeclarations.stream() + .filter(taxDeclaration -> IncomeCategoryEnum.parseByValue(taxDeclaration.getIncomeCategory()) != null + && IncomeCategoryEnum.parseByValue(taxDeclaration.getIncomeCategory()).getReportType()== DeclareReportTypeEnum.COMPREHENSIVE_INCOME) + .collect(Collectors.toList()); for (TaxDeclarationPO taxDeclaration : taxDeclarations) { List values = taxDeclarationValueMap.get(taxDeclaration.getId()); for (TaxDeclarationValuePO taxDeclarationValue : values) { @@ -338,6 +343,10 @@ public class TaxDeclarationRequest { Map> taxReportColumnMap = SalaryEntityUtil.group2Map(taxReportColumns, TaxReportColumnPO::getIncomeCategory); Map employeeDeclareMap = SalaryEntityUtil.convert2Map(employeeDeclares, EmployeeDeclarePO::getEmployeeId); Map> taxDeclarationValueMap = SalaryEntityUtil.group2Map(taxDeclarationValues, TaxDeclarationValuePO::getTaxDeclarationId); + taxDeclarations = taxDeclarations.stream() + .filter(taxDeclaration -> IncomeCategoryEnum.parseByValue(taxDeclaration.getIncomeCategory()) != null + && IncomeCategoryEnum.parseByValue(taxDeclaration.getIncomeCategory()).getReportType()== DeclareReportTypeEnum.CLASSIFIED_INCOME) + .collect(Collectors.toList()); for (TaxDeclarationPO taxDeclaration : taxDeclarations) { List values = taxDeclarationValueMap.get(taxDeclaration.getId()); IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByValue(taxDeclaration.getIncomeCategory()); @@ -380,6 +389,10 @@ public class TaxDeclarationRequest { Map> taxReportColumnMap = SalaryEntityUtil.group2Map(taxReportColumns, TaxReportColumnPO::getIncomeCategory); Map employeeDeclareMap = SalaryEntityUtil.convert2Map(employeeDeclares, EmployeeDeclarePO::getEmployeeId); Map> taxDeclarationValueMap = SalaryEntityUtil.group2Map(taxDeclarationValues, TaxDeclarationValuePO::getTaxDeclarationId); + taxDeclarations = taxDeclarations.stream() + .filter(taxDeclaration -> IncomeCategoryEnum.parseByValue(taxDeclaration.getIncomeCategory()) != null + && IncomeCategoryEnum.parseByValue(taxDeclaration.getIncomeCategory()).getReportType()== DeclareReportTypeEnum.NONRESIDENT_INCOME) + .collect(Collectors.toList()); for (TaxDeclarationPO taxDeclaration : taxDeclarations) { List values = taxDeclarationValueMap.get(taxDeclaration.getId()); for (TaxDeclarationValuePO taxDeclarationValue : values) { diff --git a/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java index 91b162cb4..906889b5e 100644 --- a/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java @@ -48,6 +48,7 @@ import com.engine.salary.enums.sicategory.DeleteTypeEnum; import com.engine.salary.enums.taxagent.TaxAgentTaxReturnStatusEnum; import com.engine.salary.enums.taxdeclaration.*; import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; import com.engine.salary.mapper.taxdeclaration.TaxDeclareRecordMapper; import com.engine.salary.mapper.taxdeclaration.TaxDeclareStatusMapper; import com.engine.salary.remote.tax.client.DeclareClient; @@ -79,6 +80,7 @@ import java.util.*; import java.util.stream.Collectors; import static com.engine.salary.enums.taxdeclaration.TaxDeclareStatusEnum.NOT_DECLARE; +import static com.engine.salary.sys.constant.SalarySysConstant.TAX_DECLARATION_DATE_TYPE; /** * 个税申报 @@ -188,9 +190,20 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); } + private SalaryAcctRecordMapper getSalaryAcctRecordMapper() { + return MapperProxyFactory.getProxy(SalaryAcctRecordMapper.class); + } + private TaxPaymentServiceFactory taxPaymentServiceFactory = new TaxPaymentServiceFactory(user); + private SalarySysConfService getSalarySysConfService(User user) { + return ServiceUtil.getService(SalarySysConfServiceImpl.class, user); + } + + //是否根据税款所属期进行申报 + private final boolean isTaxDeclarationByTaxCycle = "1".equals(getSalarySysConfService(user).getValueByCode(TAX_DECLARATION_DATE_TYPE)); + // private TaxPaymentRequestMapper taxPaymentRequestMapper; @@ -280,9 +293,44 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe // 根据个税扣缴义务人范围查询个税扣缴义务人 Collection taxAgents = queryByTaxAgentRange(saveParam); Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgentPO::getId, TaxAgentPO::getName); + + Date taxCycle; + List salaryAcctRecords = new ArrayList<>(); + //根据税款所属期申报 + if (isTaxDeclarationByTaxCycle) { + taxCycle = saveParam.getTaxCycle(); + if (Objects.isNull(taxCycle)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "税款所属期参数错误")); + } + + // 查询薪资所属月的薪资核算记录 + salaryAcctRecords = listByTaxCycle(SalaryAcctRecordPO.builder().taxCycle(taxCycle).build()); + // 无薪资核算记录,不允许生成个税申报表 + if (CollectionUtils.isEmpty(salaryAcctRecords)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", SalaryDateUtil.getFormatYearMonth(taxCycle))); + } + } else { + //根据薪资所属月申报 + // 薪资所属月的日期范围 + LocalDateRange salaryMonthDateRange = SalaryDateUtil.localDate2Range(saveParam.getSalaryMonth()); + if (Objects.isNull(salaryMonthDateRange)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "薪资所属月参数错误")); + } + // 查询薪资所属月的薪资核算记录 + salaryAcctRecords = listBySalaryMonth(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).build()); + // 如果当前薪资所属月下存在不同的税款所属期,属于异常业务场景,不允许生成个税申报表 + taxCycle = salaryAcctRecords.get(0).getTaxCycle(); + boolean differentTaxCycle = salaryAcctRecords.stream().anyMatch(salaryAcctRecordPO -> salaryAcctRecordPO.getTaxCycle().compareTo(taxCycle) != 0); + if (differentTaxCycle) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98876, "{0}存在不同的税款所属期,无法正常生成个税申报表,请调整账套设置,重新核算后再生成个税申报表") + .replace("{0}", SalaryDateUtil.getFormatYearMonth(saveParam.getSalaryMonth()))); + } + } // 查询薪资所属月下的薪资核算记录,并按照权限过滤 - LocalDateRange salaryMonthRange = new LocalDateRange().setFromDate(saveParam.getSalaryMonth()).setEndDate(saveParam.getSalaryMonth()); - List salaryAcctRecords = getSalaryAcctRecordService(user).listBySalaryMonth(salaryMonthRange); + // LocalDateRange salaryMonthRange = new LocalDateRange().setFromDate(saveParam.getSalaryMonth()).setEndDate(saveParam.getSalaryMonth()); + // List salaryAcctRecords = getSalaryAcctRecordService(user).listBySalaryMonth(salaryMonthRange); + + // 查询薪资核算记录关联的个税扣缴义务人 List salaryAcctTaxAgents = getSalaryAcctRecordService(user).listBySalaryAcctRecordIds(SalaryEntityUtil.properties(salaryAcctRecords, SalaryAcctRecordPO::getId)); // 按照saveParam中的个税扣缴义务人范围过滤 @@ -375,6 +423,14 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe } } + public List listBySalaryMonth(SalaryAcctRecordPO po) { + return getSalaryAcctRecordMapper().listSome(po); + } + + public List listByTaxCycle(SalaryAcctRecordPO po) { + return getSalaryAcctRecordMapper().listSome(po); + } + @Override public void refreshData(Long id) { // 查询个税申报记录