diff --git a/src/com/engine/salary/entity/datacollection/dto/EndowmentInsuranceListDTO.java b/src/com/engine/salary/entity/datacollection/dto/EndowmentInsuranceListDTO.java index 0af824f19..0ca693bcf 100644 --- a/src/com/engine/salary/entity/datacollection/dto/EndowmentInsuranceListDTO.java +++ b/src/com/engine/salary/entity/datacollection/dto/EndowmentInsuranceListDTO.java @@ -81,24 +81,27 @@ public class EndowmentInsuranceListDTO { @TableTitle(title = "证件号码", dataIndex = "idNo", key = "idNo") private String idNo; - @ExcelProperty(index = 6) + @TableTitle(title = "申报扣除月份", dataIndex = "deductionMonth", key = "deductionMonth") + private Date deductionMonth; + + @ExcelProperty(index = 7) @TableTitle(title = "税延养老账户编号", dataIndex = "accountNumber", key = "accountNumber") private String accountNumber; - @ExcelProperty(index = 7) + @ExcelProperty(index = 8) @TableTitle(title = "报税校验码", dataIndex = "checkCode", key = "checkCode") private String checkCode; - @ExcelProperty(index = 8) + @ExcelProperty(index = 9) @TableTitle(title = "年度保费", dataIndex = "yearPremium", key = "yearPremium") private String yearPremium; - @ExcelProperty(index = 9) + @ExcelProperty(index = 10) @TableTitle(title = "月度保费", dataIndex = "monthPremium", key = "monthPremium") private String monthPremium; - @ExcelProperty(index = 10) + @ExcelProperty(index = 11) @TableTitle(title = "本期扣除金额", dataIndex = "currentDeduction", key = "currentDeduction") private String currentDeduction; diff --git a/src/com/engine/salary/entity/datacollection/dto/GrantDonationListDTO.java b/src/com/engine/salary/entity/datacollection/dto/GrantDonationListDTO.java index 6255c4043..f38aa7181 100644 --- a/src/com/engine/salary/entity/datacollection/dto/GrantDonationListDTO.java +++ b/src/com/engine/salary/entity/datacollection/dto/GrantDonationListDTO.java @@ -103,6 +103,7 @@ public class GrantDonationListDTO { @ExcelProperty(index = 9) @TableTitle(title = "捐赠日期", dataIndex = "donateDate", key = "donateDate") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private Date donateDate; @ExcelProperty(index = 10) diff --git a/src/com/engine/salary/entity/datacollection/dto/HealthInsuranceListDTO.java b/src/com/engine/salary/entity/datacollection/dto/HealthInsuranceListDTO.java index 9cc8d0b4f..890682379 100644 --- a/src/com/engine/salary/entity/datacollection/dto/HealthInsuranceListDTO.java +++ b/src/com/engine/salary/entity/datacollection/dto/HealthInsuranceListDTO.java @@ -90,11 +90,11 @@ public class HealthInsuranceListDTO { @ExcelProperty(index = 7) @TableTitle(title = "保单生效日期", dataIndex = "effectiveDate", key = "effectiveDate") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") private Date effectiveDate; @ExcelProperty(index = 8) @TableTitle(title = "年度保费", dataIndex = "yearPremium", key = "yearPremium") - private String yearPremium; @ExcelProperty(index = 9) diff --git a/src/com/engine/salary/entity/datacollection/param/OtherDeductionFreeListQueryParam.java b/src/com/engine/salary/entity/datacollection/param/OtherDeductionFreeListQueryParam.java new file mode 100644 index 000000000..9b0a07212 --- /dev/null +++ b/src/com/engine/salary/entity/datacollection/param/OtherDeductionFreeListQueryParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.datacollection.param; + +import com.engine.salary.util.valid.DataCheck; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 其他免税扣除,附表查询列表 + *

Copyright: Copyright (c) 2022

+ *

Company: 泛微软件

+ * + * @author qiantao + * @version 1.0 + **/ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OtherDeductionFreeListQueryParam{ + + @DataCheck(require = true, message = "扣缴义务人id为空") + private Long taxAgentId; + + @DataCheck(require = true, message = "税款所属期为空") + private Date taxCycle; + +} diff --git a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationRequest.java b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationRequest.java index 5c2c82770..8432faa61 100644 --- a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationRequest.java +++ b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationRequest.java @@ -1,12 +1,15 @@ package com.engine.salary.entity.taxdeclaration.bo; +import com.engine.salary.entity.datacollection.po.*; import com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO; import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationValuePO; 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.IncomeCategoryEnum; +import com.engine.salary.util.SalaryDateUtil; import com.engine.salary.util.SalaryEntityUtil; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -14,6 +17,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import weaver.general.Util; +import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; @@ -30,7 +34,8 @@ public class TaxDeclarationRequest { public static Map convert2RequestParam(List taxReportColumns, List taxDeclarations, List taxDeclarationValues, - List employeeDeclares) { + List employeeDeclares, + Map> taxFreeMap) { Map> objRequestParam = Maps.newHashMap(); Map>> listRequestParam = Maps.newHashMap(); Map> taxReportColumnMap = SalaryEntityUtil.group2Map(taxReportColumns, TaxReportColumnPO::getIncomeCategory); @@ -127,7 +132,7 @@ public class TaxDeclarationRequest { employeeRequestParams.add(employeeRequestParam); } // 其他免税扣除附表 -// buildOtherDeductionDetailParams(taxFreeMap, listRequestParam, employeeDeclare, incomeCategoryEnum, employeeRequestParam); + buildOtherDeductionDetailParams(taxFreeMap, listRequestParam, employeeDeclare, incomeCategoryEnum, employeeRequestParam); } } @@ -137,6 +142,148 @@ public class TaxDeclarationRequest { return requestParam; } + private static void buildOtherDeductionDetailParams(Map> taxFreeMap, Map>> listRequestParam, EmployeeDeclarePO employeeDeclare, IncomeCategoryEnum incomeCategoryEnum, Map employeeRequestParam) { + if (new BigDecimal(employeeRequestParam.getOrDefault("mssd", "0").toString()).compareTo(new BigDecimal("0")) > 0) { + Map freeIncomeMap = taxFreeMap.get(TaxFreeTypeEnum.FREE_INCOME); + List poList = (List) freeIncomeMap.get(employeeDeclare.getTaxAgentId() + "-" + employeeDeclare.getEmployeeId() + "-" + SalaryDateUtil.getFormatYearMonth(employeeDeclare.getTaxCycle())); + if (CollectionUtils.isNotEmpty(poList)) { + List> paramMaps = new ArrayList<>(); + for (FreeIncomePO po : poList) { + Map map = new HashMap<>(); + // 姓名 + map.put("xm", employeeDeclare.getEmployeeName()); + // 证件类型 + map.put("zzlx", CardTypeEnum.RESIDENT_IDENTITY_CARDS.getDefaultLabel()); + // 证件号码 + map.put("zzhm", employeeDeclare.getCardNum()); + // 所得项目 + map.put("sdxm", incomeCategoryEnum.getDefaultLabel()); + map.put("jmsx", po.getFreeItem()); + map.put("jmxz", po.getFreeProperty()); + map.put("sjkcje", po.getFreeAmount()); + paramMaps.add(map); + } + listRequestParam.put("msfblb", paramMaps); + } + } + + String string = employeeRequestParam.getOrDefault("syjkbx", "0").toString(); + System.out.println(); + + if (new BigDecimal(employeeRequestParam.getOrDefault("syjkbx", "0").toString()).compareTo(new BigDecimal("0")) > 0) { + Map healthInsuranceMap = taxFreeMap.get(TaxFreeTypeEnum.HEALTH_INSURANCE); + List pos = (List) healthInsuranceMap.get(employeeDeclare.getTaxAgentId() + "-" + employeeDeclare.getEmployeeId() + "-" + SalaryDateUtil.getFormatYearMonth(employeeDeclare.getTaxCycle())); + if (CollectionUtils.isNotEmpty(pos)) { + List> paramMaps = new ArrayList<>(); + for (HealthInsurancePO healthInsurancePO : pos) { + Map map = new HashMap<>(); + // 姓名 + map.put("xm", employeeDeclare.getEmployeeName()); + // 证件类型 + map.put("zzlx", CardTypeEnum.RESIDENT_IDENTITY_CARDS.getDefaultLabel()); + // 证件号码 + map.put("zzhm", employeeDeclare.getCardNum()); + // 所得项目 + map.put("sdxm", incomeCategoryEnum.getDefaultLabel()); + map.put("bdsxrq",SalaryDateUtil.getFormatLocalDate(healthInsurancePO.getEffectiveDate()) ); + map.put("sysbm", healthInsurancePO.getIdentificationNumber()); + map.put("ndbf", healthInsurancePO.getYearPremium()); + map.put("ydbf", healthInsurancePO.getMonthPremium()); + map.put("sjkcje", healthInsurancePO.getCurrentDeduction()); + paramMaps.add(map); + } + listRequestParam.put("syjkbxfblb", paramMaps); + } + } + if (new BigDecimal(employeeRequestParam.getOrDefault("syylbx", "0").toString()).compareTo(new BigDecimal("0")) > 0) { + Map posMap = taxFreeMap.get(TaxFreeTypeEnum.ENDOWMENT_INSURANCE); + List pos = (List) posMap.get(employeeDeclare.getTaxAgentId() + "-" + employeeDeclare.getEmployeeId() + "-" + SalaryDateUtil.getFormatYearMonth(employeeDeclare.getTaxCycle())); + if (CollectionUtils.isNotEmpty(pos)) { + List> paramMaps = new ArrayList<>(); + for (EndowmentInsurancePO po : pos) { + Map map = new HashMap<>(); + // 姓名 + map.put("xm", employeeDeclare.getEmployeeName()); + // 证件类型 + map.put("zzlx", CardTypeEnum.RESIDENT_IDENTITY_CARDS.getDefaultLabel()); + // 证件号码 + map.put("zzhm", employeeDeclare.getCardNum()); + // 所得项目 + map.put("sdxm", incomeCategoryEnum.getDefaultLabel()); + map.put("sbkcyf", SalaryDateUtil.getFormatYearMonth((po.getDeductionMonth()))); + map.put("syylzhbh", po.getAccountNumber()); + map.put("bsjym", po.getCheckCode()); + map.put("ndbf", po.getYearPremium()); + map.put("ydbf", po.getMonthPremium()); + map.put("sjkcje", po.getCurrentDeduction()); + paramMaps.add(map); + } + listRequestParam.put("syjkbxfblb", paramMaps); + } + } + if (new BigDecimal(employeeRequestParam.getOrDefault("zykcjze", "0").toString()).compareTo(new BigDecimal("0")) > 0) { + Map posMap = taxFreeMap.get(TaxFreeTypeEnum.GRANT_DONATION); + List pos = (List) posMap.get(employeeDeclare.getTaxAgentId() + "-" + employeeDeclare.getEmployeeId() + "-" + SalaryDateUtil.getFormatYearMonth(employeeDeclare.getTaxCycle())); + if (CollectionUtils.isNotEmpty(pos)) { + List> paramMaps = new ArrayList<>(); + for (GrantDonationPO po : pos) { + Map map = new HashMap<>(); + // 姓名 + map.put("xm", employeeDeclare.getEmployeeName()); + // 证件类型 + map.put("zzlx", CardTypeEnum.RESIDENT_IDENTITY_CARDS.getDefaultLabel()); + // 证件号码 + map.put("zzhm", employeeDeclare.getCardNum()); + // 所得项目 + map.put("sdxm", incomeCategoryEnum.getDefaultLabel()); + map.put("szdwmc", po.getRecipientName()); + map.put("szdwnsrsbh", po.getTaxCode()); + map.put("jzpzh", po.getDonationNumber()); + if (po.getDonateDate() != null) { + map.put("jzrq", SalaryDateUtil.getFormatLocalDate(po.getDonateDate())); + } + map.put("jzje", po.getDonateAmount()); + map.put("kcbl", po.getDeductionProportion()); + map.put("sjkcje", po.getActualDeduction()); + paramMaps.add(map); + } + listRequestParam.put("zykcjzefb", paramMaps); + } + } + + if (new BigDecimal(employeeRequestParam.getOrDefault("jmse", "0").toString()).compareTo(new BigDecimal("0")) > 0) { + Map posMap = taxFreeMap.get(TaxFreeTypeEnum.DERATE_DEDUCTION); + List pos = (List) posMap.get(employeeDeclare.getTaxAgentId() + "-" + employeeDeclare.getEmployeeId() + "-" + SalaryDateUtil.getFormatYearMonth(employeeDeclare.getTaxCycle())); + if (CollectionUtils.isNotEmpty(pos)) { + List> paramMaps = new ArrayList<>(); + for (DerateDeductionPO po : pos) { + Map map = new HashMap<>(); + // 姓名 + map.put("xm", employeeDeclare.getEmployeeName()); + // 证件类型 + map.put("zzlx", CardTypeEnum.RESIDENT_IDENTITY_CARDS.getDefaultLabel()); + // 证件号码 + map.put("zzhm", employeeDeclare.getCardNum()); + // 所得项目 + map.put("sdxm", incomeCategoryEnum.getDefaultLabel()); + map.put("jmsx", po.getDerateItem()); + map.put("jmxz", po.getDerateProperty()); + map.put("sjkcje", po.getDerateAmount()); + paramMaps.add(map); + } + listRequestParam.put("jmfblb", paramMaps); + } + } + + if (new BigDecimal(employeeRequestParam.getOrDefault("qt", "0").toString()).compareTo(new BigDecimal("0")) > 0) { + Map posMap = taxFreeMap.get(TaxFreeTypeEnum.OTHER_DERATE_DEDUCTION); + List pos = (List) posMap.get(employeeDeclare.getTaxAgentId() + "-" + employeeDeclare.getEmployeeId() + "-" + SalaryDateUtil.getFormatYearMonth(employeeDeclare.getTaxCycle())); + if (CollectionUtils.isNotEmpty(pos)) { + employeeRequestParam.put("bz", pos.get(0).getRemark()); + } + } + } + private static Map convert2RequestParam(IncomeCategoryEnum incomeCategoryEnum, List taxReportColumns, TaxDeclarationValuePO taxDeclarationValue, diff --git a/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java b/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java index 5e38bb298..83892cf9a 100644 --- a/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java +++ b/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java @@ -38,7 +38,6 @@ public enum IncomeCategoryEnum implements BaseEnum { // todo 多语言 WAGES_AND_SALARIES(1, "0101", "正常工资薪金", DeclareReportTypeEnum.COMPREHENSIVE_INCOME, 160487) { - @Override public void parseGetDeclareTaxResultFeedbackResponse(Map>> result, GetDeclareTaxResultFeedbackResponse declareTaxResultFeedbackResponse) { List zhsd = declareTaxResultFeedbackResponse.getBody().getZhsd().getZcgzxj().getSscglb(); @@ -52,6 +51,12 @@ public enum IncomeCategoryEnum implements BaseEnum { Gson gs = new Gson(); List taxRules = taxRuleDTO.getTaxRules(); + List sssbyylb = declareTaxResultFeedbackResponse.getBody().getZhsd().getZcgzxj().getSssbyylb(); + if (CollectionUtil.isNotEmpty(sssbyylb)) { + String err = sssbyylb.stream().map(yy -> yy.getXm() + "" + yy.getCwxx()).collect(Collectors.joining(";")); + throw new OnlineCalculateTaxException(err); + } + List sscglb = declareTaxResultFeedbackResponse.getBody().getZhsd().getZcgzxj().getSscglb(); Map idNoResultMap = SalaryEntityUtil.convert2Map(sscglb, GetASynIndividualIncomeTaxFeedbackResponse.Body.zhsd.ssjgdx.result::getZzhm); Map resultMap = new HashMap<>(); @@ -526,6 +531,7 @@ public enum IncomeCategoryEnum implements BaseEnum { List> sheetData = ExcelUtil.getExcelSheetData(GetDeclareTaxResultFeedbackResponse.Body.fjmsd.fjmsdssjgdx.fjmsdscbw.class, fjmsd); result.put(this.getDefaultLabel(), sheetData); } + @Override public Map parseGetASynIndividualIncomeTaxFeedbackResponse(GetASynIndividualIncomeTaxFeedbackResponse declareTaxResultFeedbackResponse, List employeeDeclares, SalarySobTaxRuleDTO taxRuleDTO) { checkGetASynIndividualIncomeTaxFeedbackResponse(declareTaxResultFeedbackResponse); @@ -637,6 +643,7 @@ public enum IncomeCategoryEnum implements BaseEnum { List> sheetData = ExcelUtil.getExcelSheetData(GetDeclareTaxResultFeedbackResponse.Body.fjmsd.fjmsdssjgdx.fjmsdscbw.class, fjmsd); result.put(this.getDefaultLabel(), sheetData); } + @Override public Map parseGetASynIndividualIncomeTaxFeedbackResponse(GetASynIndividualIncomeTaxFeedbackResponse declareTaxResultFeedbackResponse, List employeeDeclares, SalarySobTaxRuleDTO taxRuleDTO) { checkGetASynIndividualIncomeTaxFeedbackResponse(declareTaxResultFeedbackResponse); diff --git a/src/com/engine/salary/service/OtherDeductionService.java b/src/com/engine/salary/service/OtherDeductionService.java index 3e4c0c7d7..c8e72bb1e 100644 --- a/src/com/engine/salary/service/OtherDeductionService.java +++ b/src/com/engine/salary/service/OtherDeductionService.java @@ -2,7 +2,7 @@ package com.engine.salary.service; import com.engine.salary.entity.datacollection.dto.*; import com.engine.salary.entity.datacollection.param.*; -import com.engine.salary.entity.datacollection.po.OtherDeductionPO; +import com.engine.salary.entity.datacollection.po.*; import com.engine.salary.util.page.PageInfo; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -132,6 +132,14 @@ public interface OtherDeductionService { PageInfo otherDerateDeductionList(OtherDeductionDetailQueryParam param); PageInfo personalPensionList(OtherDeductionDetailQueryParam param); + List queryFreeIncomes(OtherDeductionFreeListQueryParam param); + List queryDerateDeductions(OtherDeductionFreeListQueryParam param); + List queryEndowmentInsurances(OtherDeductionFreeListQueryParam param); + List queryGrantDonations(OtherDeductionFreeListQueryParam param); + List queryHealthInsurances(OtherDeductionFreeListQueryParam param); + List queryOtherDerateDeductions(OtherDeductionFreeListQueryParam param); + List queryPersonalPensions(OtherDeductionFreeListQueryParam param); + void saveFreeIncome(FreeIncomeSaveParam param); void saveEndowmentInsurance(EndowmentInsuranceSaveParam param); void saveGrantDonation(GrantDonationSaveParam param); diff --git a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java index 8a4d9e364..251523ba8 100644 --- a/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java +++ b/src/com/engine/salary/service/impl/OtherDeductionServiceImpl.java @@ -44,6 +44,7 @@ import com.engine.salary.util.excel.ExcelSupport; import com.engine.salary.util.excel.ExcelUtil; import com.engine.salary.util.page.PageInfo; import com.engine.salary.util.page.SalaryPageUtil; +import com.engine.salary.util.valid.ValidUtil; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.commons.collections4.CollectionUtils; @@ -760,7 +761,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction // 错误excel内容 List errorData = new ArrayList<>(); - List derateDeductionList = ExcelParseHelper.parse2Map(fileInputStream, EndowmentInsuranceListDTO.class, 2, 1, 11, "OtherDeductionTemplate.xlsx"); + List derateDeductionList = ExcelParseHelper.parse2Map(fileInputStream, EndowmentInsuranceListDTO.class, 2, 1, 12, "OtherDeductionTemplate.xlsx"); for (int i = 0; i < derateDeductionList.size(); i++) { EndowmentInsuranceListDTO dto = derateDeductionList.get(i); @@ -1508,7 +1509,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction //清除旧数据 OtherDeductionPO otherDeductionPO = getOtherDeductionMapper().getByTaxAgentIdAndEmployeeId(po.getTaxAgentId(), po.getEmployeeId()); - if(otherDeductionPO != null){ + if (otherDeductionPO != null) { getOtherDeductionMapper().delete(otherDeductionPO); getFreeIncomeMapper().deleteByMainId(otherDeductionPO.getId()); getHealthInsuranceMapper().deleteByMainId(otherDeductionPO.getId()); @@ -2413,6 +2414,48 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction return SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), listDTOS, PersonalPensionListDTO.class); } + @Override + public List queryFreeIncomes(OtherDeductionFreeListQueryParam param) { + ValidUtil.doValidator(param); + return getFreeIncomeMapper().listSome(FreeIncomePO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build()); + } + + @Override + public List queryDerateDeductions(OtherDeductionFreeListQueryParam param) { + ValidUtil.doValidator(param); + return getDerateDeductionMapper().listSome(DerateDeductionPO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build()); + } + + @Override + public List queryEndowmentInsurances(OtherDeductionFreeListQueryParam param) { + ValidUtil.doValidator(param); + return getEndowmentInsuranceMapper().listSome(EndowmentInsurancePO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build()); + } + + @Override + public List queryGrantDonations(OtherDeductionFreeListQueryParam param) { + ValidUtil.doValidator(param); + return getGrantDonationMapper().listSome(GrantDonationPO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build()); + } + + @Override + public List queryHealthInsurances(OtherDeductionFreeListQueryParam param) { + ValidUtil.doValidator(param); + return getHealthInsuranceMapper().listSome(HealthInsurancePO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build()); + } + + @Override + public List queryOtherDerateDeductions(OtherDeductionFreeListQueryParam param) { + ValidUtil.doValidator(param); + return getOtherDerateDeductionMapper().listSome(OtherDerateDeductionPO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build()); + } + + @Override + public List queryPersonalPensions(OtherDeductionFreeListQueryParam param) { + ValidUtil.doValidator(param); + return getPersonalPensionMapper().listSome(PersonalPensionPO.builder().taxYearMonth(param.getTaxCycle()).taxAgentId(param.getTaxAgentId()).build()); + } + @Override public void saveFreeIncome(FreeIncomeSaveParam param) { diff --git a/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java index bb77848ad..f5d3f94b6 100644 --- a/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclareRecordServiceImpl.java @@ -9,6 +9,8 @@ import com.engine.salary.config.SalaryElogConfig; import com.engine.salary.constant.SalaryDefaultTenantConstant; import com.engine.salary.constant.SzyhApiConstant; import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.param.OtherDeductionFreeListQueryParam; +import com.engine.salary.entity.datacollection.po.*; import com.engine.salary.entity.employeedeclare.bo.EmployeeDeclareRequest; import com.engine.salary.entity.employeedeclare.po.EmployeeDeclarePO; import com.engine.salary.entity.salaryacct.param.SalaryAcctEmployeeQueryParam; @@ -34,6 +36,7 @@ import com.engine.salary.entity.taxdeclaration.response.DeclareTaxFeedbackRespon import com.engine.salary.entity.taxdeclaration.response.DeclareTaxResponse; import com.engine.salary.entity.taxdeclaration.response.UpdateDeclareResponse; import com.engine.salary.enums.OperateTypeEnum; +import com.engine.salary.enums.datacollection.TaxFreeTypeEnum; import com.engine.salary.enums.employeedeclare.DeclareStatusEnum; import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; import com.engine.salary.enums.salarysob.DeclareReportTypeEnum; @@ -172,6 +175,10 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe return ServiceUtil.getService(SalarySobServiceImpl.class, user); } + private OtherDeductionService getOtherDeductionService(User user) { + return ServiceUtil.getService(OtherDeductionServiceImpl.class, user); + } + private TaxPaymentServiceFactory taxPaymentServiceFactory = new TaxPaymentServiceFactory(user); @@ -680,6 +687,9 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe List employeeDeclares = getEmployeeDeclareService(user).listByTaxCycleAndTaxAgentId(taxDeclareRecord.getTaxCycle(), taxDeclareRecord.getTaxAgentId()); employeeDeclares = employeeDeclares.stream().filter(e -> Objects.equals(e.getDeclareStatus(), DeclareStatusEnum.DECLARE_SUCCESS.getValue())).collect(Collectors.toList()); + // 查询其他免税扣除明细 + Map> taxFreeMap = getOtherDeductionDetailMap(taxDeclareRecord); + TaxDeclarationApiConfigPO apiConfig = taxDeclareRequest.getTaxDeclarationApiConfig(); // 查询个税申报表的表头 List taxReportColumns = getTaxReportColumnService(user).listAll(); @@ -693,7 +703,7 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe if (declareReportType == DeclareReportTypeEnum.COMPREHENSIVE_INCOME) { // 综合所得 - Map taxDeclarationParam = TaxDeclarationRequest.convert2RequestParam(taxReportColumns, taxDeclarations, taxDeclarationValues, employeeDeclares); + Map taxDeclarationParam = TaxDeclarationRequest.convert2RequestParam(taxReportColumns, taxDeclarations, taxDeclarationValues, employeeDeclares, taxFreeMap); requestParam.put("zhsd", taxDeclarationParam); } @@ -740,6 +750,36 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe SalaryElogConfig.taxDeclarationLoggerTemplate.write(loggerContext); } + private Map> getOtherDeductionDetailMap(TaxDeclareRecordPO taxDeclareRecord) { + Map> taxFreeMap = new HashMap<>(); + OtherDeductionFreeListQueryParam queryParam = OtherDeductionFreeListQueryParam.builder().taxAgentId(taxDeclareRecord.getTaxAgentId()).taxCycle(taxDeclareRecord.getTaxCycle()).build(); + + List freeIncomes = getOtherDeductionService(user).queryFreeIncomes(queryParam); + Map> freeIncomeMap = freeIncomes.stream().collect(Collectors.groupingBy(e -> e.getTaxAgentId() + "-" + e.getEmployeeId() + "-" + SalaryDateUtil.getFormatYearMonth(e.getTaxYearMonth()))); + taxFreeMap.put(TaxFreeTypeEnum.FREE_INCOME, freeIncomeMap); + + List healthInsurances = getOtherDeductionService(user).queryHealthInsurances(queryParam); + Map> healthInsuranceMap = healthInsurances.stream().collect(Collectors.groupingBy(e -> e.getTaxAgentId() + "-" + e.getEmployeeId() + "-" + SalaryDateUtil.getFormatYearMonth(e.getTaxYearMonth()))); + taxFreeMap.put(TaxFreeTypeEnum.HEALTH_INSURANCE, healthInsuranceMap); + + List endowmentInsurances = getOtherDeductionService(user).queryEndowmentInsurances(queryParam); + Map> endowmentInsuranceMap = endowmentInsurances.stream().collect(Collectors.groupingBy(e -> e.getTaxAgentId() + "-" + e.getEmployeeId() + "-" + SalaryDateUtil.getFormatYearMonth(e.getTaxYearMonth()))); + taxFreeMap.put(TaxFreeTypeEnum.ENDOWMENT_INSURANCE, endowmentInsuranceMap); + + List grantDonations = getOtherDeductionService(user).queryGrantDonations(queryParam); + Map> grantDonationMap = grantDonations.stream().collect(Collectors.groupingBy(e -> e.getTaxAgentId() + "-" + e.getEmployeeId() + "-" + SalaryDateUtil.getFormatYearMonth(e.getTaxYearMonth()))); + taxFreeMap.put(TaxFreeTypeEnum.GRANT_DONATION, grantDonationMap); + + List derateDeductions = getOtherDeductionService(user).queryDerateDeductions(queryParam); + Map> derateDeductionMap = derateDeductions.stream().collect(Collectors.groupingBy(e -> e.getTaxAgentId() + "-" + e.getEmployeeId() + "-" + SalaryDateUtil.getFormatYearMonth(e.getTaxYearMonth()))); + taxFreeMap.put(TaxFreeTypeEnum.DERATE_DEDUCTION, derateDeductionMap); + + List otherDerateDeductions = getOtherDeductionService(user).queryOtherDerateDeductions(queryParam); + Map> otherDerateDeductionMap = otherDerateDeductions.stream().collect(Collectors.groupingBy(e -> e.getTaxAgentId() + "-" + e.getEmployeeId() + "-" + SalaryDateUtil.getFormatYearMonth(e.getTaxYearMonth()))); + taxFreeMap.put(TaxFreeTypeEnum.OTHER_DERATE_DEDUCTION, otherDerateDeductionMap); + return taxFreeMap; + } + @Override public void getDeclareFeedback(Long id, Integer reportType, TaxDeclarationRateDTO taxDeclarationRate) { TaxDeclareRequest taxDeclareRequest = buildTaxDeclareRequest(id); @@ -901,10 +941,10 @@ public class TaxDeclareRecordServiceImpl extends Service implements TaxDeclareRe // 是否清空所得 requestParam.put("sfqksd", "0"); - Map responseParam = new HashMap<>(); - responseParam.put("reportType",reportType + ""); + Map responseParam = new HashMap<>(); + responseParam.put("reportType", reportType + ""); DeclareClient declareClient = new DeclareClient(taxAgentId); - CancelDeclareFeedbackResponse cancelDeclareFeedbackResponse = declareClient.cancel(requestParam,responseParam); + CancelDeclareFeedbackResponse cancelDeclareFeedbackResponse = declareClient.cancel(requestParam, responseParam); // 作废是否成功 CancelDeclareStatusEnum cancelDeclareStatusEnum = SalaryEnumUtil.enumMatchByValue(SalaryEntityUtil.getIntValue(cancelDeclareFeedbackResponse.getBody().get("fkztbj"), 10), CancelDeclareStatusEnum.class);