diff --git a/.gitignore b/.gitignore deleted file mode 100644 index ddbcd048a..000000000 --- a/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -/weaver-hrm-salary.iml -/out/ -/.idea/ - -HELP.md -target/ - -### IntelliJ IDEA ### -.idea - -/src/test -/src/META-INF - -/log - diff --git a/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetFormCmd.java b/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetFormCmd.java new file mode 100644 index 000000000..25d3a329e --- /dev/null +++ b/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetFormCmd.java @@ -0,0 +1,33 @@ +package com.engine.salary.cmd.taxDeclaration; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.TaxRateBiz; +import com.engine.salary.entity.taxrate.param.TaxRateSaveParam; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +public class TaxDeclarationGetFormCmd extends AbstractCommonCommand> { + + public TaxDeclarationGetFormCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + TaxRateBiz taxRateBiz = new TaxRateBiz(); + TaxRateSaveParam taxRateSaveParam = (TaxRateSaveParam) params.get("taxRateSaveParam"); + taxRateBiz.save(taxRateSaveParam, (long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetTaxDeclarationInfoCmd.java b/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetTaxDeclarationInfoCmd.java new file mode 100644 index 000000000..4d0f2bfdd --- /dev/null +++ b/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationGetTaxDeclarationInfoCmd.java @@ -0,0 +1,33 @@ +package com.engine.salary.cmd.taxDeclaration; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.salary.biz.TaxRateBiz; +import com.engine.salary.entity.taxrate.param.TaxRateSaveParam; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.Map; + +public class TaxDeclarationGetTaxDeclarationInfoCmd extends AbstractCommonCommand> { + + public TaxDeclarationGetTaxDeclarationInfoCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map apidatas = new HashMap(16); + TaxRateBiz taxRateBiz = new TaxRateBiz(); + TaxRateSaveParam taxRateSaveParam = (TaxRateSaveParam) params.get("taxRateSaveParam"); + taxRateBiz.save(taxRateSaveParam, (long) user.getUID()); + return apidatas; + } +} diff --git a/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationListCmd.java b/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationListCmd.java index 42032ff57..52433685c 100644 --- a/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationListCmd.java +++ b/src/com/engine/salary/cmd/taxDeclaration/TaxDeclarationListCmd.java @@ -1,19 +1,22 @@ package com.engine.salary.cmd.taxDeclaration; -import com.cloudstore.eccom.constant.WeaBoolAttr; -import com.cloudstore.eccom.pc.table.WeaTable; -import com.cloudstore.eccom.pc.table.WeaTableColumn; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; import com.engine.core.interceptor.CommandContext; +import com.engine.salary.component.SalaryWeaTable; +import com.engine.salary.entity.salaryarchive.po.TaxAgentPO; +import com.engine.salary.entity.taxdeclaration.TaxDeclaration; +import com.engine.salary.entity.taxrate.vo.TaxAgentTableVO; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.DBType; +import com.fapiao.neon.model.in.Page; import org.apache.commons.lang3.StringUtils; -import weaver.general.PageIdConst; -import weaver.general.Util; +import weaver.conn.RecordSet; import weaver.hrm.User; -import java.util.HashMap; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; public class TaxDeclarationListCmd extends AbstractCommonCommand> { @@ -31,51 +34,68 @@ public class TaxDeclarationListCmd extends AbstractCommonCommand execute(CommandContext commandContext) { Map apidatas = new HashMap(16); + //查询个税申报表 + SalaryWeaTable table = new SalaryWeaTable(user, TaxDeclaration.class); + //sql条件 + String sqlWhere = makeSqlWhere(params,user); + table.setSqlwhere(sqlWhere); WeaResultMsg result = new WeaResultMsg(false); - String pageID = "a4f85287-e3f9-4275-9527-7d06e54y6rj8"; - String pageUid = pageID + "_" + user.getUID(); - String pageSize = PageIdConst.getPageSize(pageID, user.getUID()); - - - String fileds = " create_time,creator,delete_type, description, id, name, system_type, tenant_key, update_time"; - String sql = " from hrsa_sys_tax_rate_base s " + - " where s.delete_type = 0"; - //模糊查询 - String name = Util.null2String(params.get("name")); - if (StringUtils.isNotBlank(name)) { - sql += " and s.name like '%" + name + "%' "; - } - sql += " union all " + - " select create_time,creator,delete_type, description, id, name, system_type, tenant_key, update_time " + - " from hrsa_tax_rate_base b " + - " where b.delete_type = 0 "; - //模糊查询 - if (StringUtils.isNotBlank(name)) { - sql += " and b.name like '%" + name + "%' "; - } - - WeaTable table = new WeaTable(); - table.setPageUID(pageUid); - table.setPageID(pageID); - table.setPagesize(pageSize); - table.setBackfields(fileds); - table.setSqlform(sql); -// table.setSqlwhere(); - table.setSqlorderby("id desc"); - table.setSqlprimarykey("id"); - table.setSqlisdistinct("false"); - - table.getColumns().add(new WeaTableColumn("id").setDisplay(WeaBoolAttr.FALSE)); - table.getColumns().add(new WeaTableColumn("20%", "名称", "name", "")); - table.getColumns().add(new WeaTableColumn("20%", "名称", "systemType", "")); - table.getColumns().add(new WeaTableColumn("20%", "名称", "createTime", "")); - table.getColumns().add(new WeaTableColumn("20%", "名称", "description", "")); - - result.putAll(table.makeDataResult()); + result.success(); - apidatas = result.getResultMap(); - return apidatas; + //人员list + List list = table.makeDataResult().values().stream().collect(Collectors.toList()); + //SalaryWeaTable simpleEmployees = new SalaryWeaTable(user, SimpleEmployee.class); + //查询个税扣缴义务人 + + SalaryWeaTable taxAgentPOS = new SalaryWeaTable(user, TaxAgentTableVO.class); + List employeeIds = new ArrayList(); + + if(!table.makeDataResult().isEmpty()){ + //查询人员 + + //查询个税扣缴义务人 + + } + return result.getResultMap(); + + } + + /** + * sql条件 + * + * @param params + * @return + */ + private String makeSqlWhere(Map params,User user) { + DBType dbType = DBType.get(new RecordSet().getDBType()); + //租户key + String userId = user.getLoginid(); + String sqlWhere = "where delete_Type = 0 and tenantKey = userId"; + //区间查询 + String FromSalaryMonth = (String) params.get("FromSalaryMonth"); + String EndSalaryMonth = (String) params.get("EndSalaryMonth"); + if (SalaryEntityUtil.isNotNullOrEmpty(FromSalaryMonth)&&SalaryEntityUtil.isNotNullOrEmpty(EndSalaryMonth)) { + sqlWhere += "AND salary_month between to_date(FromSalaryMonth,'yyyy-mm') and to_date(EndSalaryMonth,'yyyy-mm')"; + } + return sqlWhere; + } + + /** + * sql条件 + * + * @param params + * @return + */ + private String makeSqlWhereAgent(Map params) { + DBType dbType = DBType.get(new RecordSet().getDBType()); + String sqlWhere = "where delete_Type = 0"; + //模糊查询 + String name = (String) params.get("name"); + if (StringUtils.isNotBlank(name)) { + sqlWhere += " AND name " + dbType.like(name); + } + return sqlWhere; } } diff --git a/src/com/engine/salary/entity/taxdeclaration/TaxDeclaration.java b/src/com/engine/salary/entity/taxdeclaration/TaxDeclaration.java index 086f0e45b..e39ebff74 100644 --- a/src/com/engine/salary/entity/taxdeclaration/TaxDeclaration.java +++ b/src/com/engine/salary/entity/taxdeclaration/TaxDeclaration.java @@ -56,4 +56,9 @@ public class TaxDeclaration { */ private Date updateTime; + /** + * 应税项目。1:正常工资薪金所得 + */ + private Integer incomeCategory; + } \ No newline at end of file diff --git a/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java new file mode 100644 index 000000000..d4328bc2c --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/bo/TaxDeclarationBO.java @@ -0,0 +1,372 @@ +package com.engine.salary.entity.taxdeclaration.bo; + +import com.engine.salary.entity.datacollection.AddUpSituation; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.entity.taxrate.TaxAgent; +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; +import dm.jdbc.util.IdGenerator; +import lombok.Data; +import org.apache.commons.collections4.CollectionUtils; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @description: 个税申报表 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 10:01 AM + * @version:v1.0 + */ +public class TaxDeclarationBO { + + public static List convert2ListDTO(List taxDeclarations, + List simpleEmployees, + List taxAgents) { + if (CollectionUtils.isEmpty(simpleEmployees)) { + return Collections.emptyList(); + } + Map taxAgentNameMap = SalaryEntityUtil.convert2Map(taxAgents, TaxAgent::getId, TaxAgent::getName); + Map employeeNameMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId, DataCollectionEmployee::getUsername); + return taxDeclarations.stream().map(e -> TaxDeclarationListDTO.builder() + .id(e.getId()) + .salaryMonth(e.getSalaryMonth().toString()) + .taxAgentId(e.getTaxAgentId()) + .taxAgentName(taxAgentNameMap.getOrDefault(e.getTaxAgentId(), "")) + .taxCycle(e.getTaxCycle().toString()) + .operateEmployeeId(e.getCreator()) + .operateEmployeeName(employeeNameMap.getOrDefault(e.getCreator(), "")) + .operateTime(SalaryDateUtil.getFormatLocalDateTime(e.getCreateTime())) + .description(e.getDescription()) + .build()).collect(Collectors.toList()); + } + + /*public static void buildDetailListDTO(Long taxDeclarationId, + Page page, + List taxDeclarationDetails, + List simpleEmployees) { + if (CollectionUtils.isEmpty(taxDeclarationDetails)) { + return; + } + int index = (int) ((page.getCurrent() - 1) * page.getSize()); + List dtos = Lists.newArrayListWithExpectedSize(simpleEmployees.size()); + Map> taxDeclarationDetailMap = SalaryEntityUtil.group2Map(taxDeclarationDetails, TaxDeclarationDetailPO::getEmployeeId); + for (SimpleEmployee simpleEmployee : simpleEmployees) { + Map valueMap = SalaryEntityUtil.convert2Map(taxDeclarationDetailMap.get(simpleEmployee.getEmployeeId()), TaxDeclarationDetailPO::getFieldCode, TaxDeclarationDetailPO::getFieldValue); + TaxDeclarationDetailListDTO dto = new TaxDeclarationDetailListDTO(); + dto.setId(simpleEmployee.getEmployeeId()); + dto.setTaxDeclarationId(taxDeclarationId); + dto.setSeq(++index); + dto.setEmployeeId(simpleEmployee.getEmployeeId()); + dto.setEmployeeName(simpleEmployee.getUsername()); + dto.setIdCardType(SalaryI18nUtil.getI18nLabel(101696,"身份证")); + dto.setIdCardNo(""); + dto.setTaxpayerIdNo(""); + dto.setResidentType(SalaryI18nUtil.getI18nLabel(101697,"居民")); + dto.setIncomeType(SalaryI18nUtil.getI18nLabel(101698,"工资、薪金")); + dto.setIncome(valueMap.getOrDefault("income","")); + dto.setFee(valueMap.getOrDefault("fee", "")); + dto.setTaxFreeIncome(valueMap.getOrDefault("taxFreeIncome", "")); + dto.setSubtraction(valueMap.getOrDefault("subtraction", "")); + dto.setEndowmentInsurance(valueMap.getOrDefault("endowmentInsurance", "")); + dto.setMedicalInsurance(valueMap.getOrDefault("medicalInsurance","")); + dto.setUnemploymentInsurance(valueMap.getOrDefault("unemploymentInsurance","")); + dto.setHousingProvidentFund(valueMap.getOrDefault("housingProvidentFund","")); + dto.setAnnuity(valueMap.getOrDefault("annuity","")); + dto.setCommercialHealthInsurance(valueMap.getOrDefault("commercialHealthInsurance","")); + dto.setTaxDeferredEndowmentInsurance(valueMap.getOrDefault("taxDeferredEndowmentInsurance","")); + dto.setOriginalValueOfProperty(valueMap.getOrDefault("originalValueOfProperty","")); + dto.setDeductedTax(valueMap.getOrDefault("deductedTax","")); + dto.setOther(valueMap.getOrDefault("other","")); + dto.setAddUpIncome(valueMap.getOrDefault("addUpIncome","")); + dto.setAddUpSubtraction(valueMap.getOrDefault("addUpSubtraction","")); + dto.setAddUpSpecialDeduction(valueMap.getOrDefault("addUpSpecialDeduction","")); + dto.setAddUpChildEducation(valueMap.getOrDefault("addUpChildEducation","")); + dto.setAddUpContinuingEducation(valueMap.getOrDefault("addUpContinuingEducation","")); + dto.setAddUpHousingLoanInterest(valueMap.getOrDefault("addUpHousingLoanInterest","")); + dto.setAddUpHousingRent(valueMap.getOrDefault("addUpHousingRent","")); + dto.setAddUpSupportElderly(valueMap.getOrDefault("addUpSupportElderly","")); + dto.setAddUpOther(valueMap.getOrDefault("addUpOtherDeduction","")); + dto.setLessTaxProportion(valueMap.getOrDefault("lessTaxProportion","")); + dto.setAllowedDonation(valueMap.getOrDefault("addUpAllowedDonation","")); + dto.setTaxableIncome(valueMap.getOrDefault("addUpTaxableIncome","")); + dto.setTaxRate(valueMap.getOrDefault("taxRate","")); + dto.setQuickDeductionFactor(valueMap.getOrDefault("quickDeductionFactor","")); + dto.setTaxPayable(valueMap.getOrDefault("addUpTaxPayable","")); + dto.setTaxSavings(valueMap.getOrDefault("addUpTaxDeduction","")); + dto.setTaxWithheld(valueMap.getOrDefault("taxWithheld","")); + dto.setRefundedOrSupplementedTax(valueMap.getOrDefault("refundedOrSupplementedTax","")); + dtos.add(dto); + } + page.setRecords(dtos); + }*/ + + public static Result handle(TaxDeclarationSaveParam saveParam, + Date taxCycle, + List salaryItems, + List salarySobs, + List salaryAcctResults + ) { + Result result = new Result(); + if (CollectionUtils.isEmpty(salaryAcctResults)) { + return result; + } + // 薪资项目聚合成map(为了根据code获取id) + Map salaryItemMap = SalaryEntityUtil.convert2Map(salaryItems, SalaryItemPO::getCode, SalaryItemPO::getId); + // 薪资账套聚合成map(为了根据id获取incomeCategory) + Map salarySobPOMap = SalaryEntityUtil.convert2Map(salarySobs, SalarySobPO::getId); + // 薪资核算结果按照个税扣缴义务人id、所用薪资账套的incomeCategory聚合成map + /* Map>> taxAgentIdKeyAcctResultMap = salaryAcctResults.stream() + .collect(Collectors.groupingBy(SalaryAcctResultPO::getTaxAgentId, + Collectors.groupingBy(salaryAcctResultPO -> salarySobPOMap.get(salaryAcctResultPO.getSalarySobId()).getIncomeCategory()))); + */// 一个个税扣缴义务人,一种薪资类型生成一张个税申报表 + Map> taxAgentIdKeyAcctResultMap = SalaryEntityUtil.group2Map(salaryAcctResults, SalaryAcctResultPO::getTaxAgentId); + taxAgentIdKeyAcctResultMap.forEach((k, v) -> { + // 新增的个税申报表 + TaxDeclarationPO taxDeclaration = convert2PO(saveParam, taxCycle, k); + result.getNeedInsertTaxDeclarations().add(taxDeclaration); + // 处理个税申报明细以及累计情况 + handleTaxDeclarationDetail(result, taxDeclaration, v, salaryItemMap); + }); + /*taxAgentIdKeyAcctResultMap.forEach((taxAgentId, incomeCategoryKeyAcctResultPOMap) -> { + incomeCategoryKeyAcctResultPOMap.forEach((incomeCategory, salaryAcctResultPOS) -> { + // 新增的个税申报表 + TaxDeclarationPO taxDeclaration = convert2PO(saveParam, taxCycle, taxAgentId, incomeCategory, employeeId); + result.getNeedInsertTaxDeclarations().add(taxDeclaration); + if (Objects.equals(incomeCategory, IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) { + // 生成个税申报表 + handleTaxDeclaration4Wage(result, taxDeclaration, salaryAcctResultPOS, salaryItemMap); + // 生成往期累计情况 + handleAddUpSituation(result, taxDeclaration, salaryAcctResultPOS, salaryItemMap); + } + if (Objects.equals(incomeCategory, IncomeCategoryEnum.REMUNERATION_FOR_LABOR.getValue())) { + // 生成个税申报表 + handleTaxDeclaration4Labor(result, taxDeclaration, salaryAcctResultPOS, salaryItemMap); + } + }); + });*/ + return result; + } + + private static void handleTaxDeclarationDetail(Result result, + TaxDeclarationPO taxDeclaration, + List salaryAcctResults, + Map salaryItemMap) { + if (CollectionUtils.isEmpty(salaryAcctResults)) { + return; + } + // 核算结果按照人员id分类 + Map> acctResultMap = SalaryEntityUtil.group2Map(salaryAcctResults, SalaryAcctResultPO::getEmployeeId); + acctResultMap.forEach((k, v) -> { + Map valueMap = Maps.newHashMapWithExpectedSize(32); + Map> resultMap = SalaryEntityUtil.group2Map(v, SalaryAcctResultPO::getSalaryItemId); + // 收入 + BigDecimal income = SalaryEntityUtil.reduce(resultMap.get(salaryItemMap.getOrDefault("income", 0L)), e -> SalaryEntityUtil.empty2Zero(e.getResultValue())); + valueMap.put("income", income); + // 费用 + BigDecimal fee = BigDecimal.ZERO; + valueMap.put("fee", fee); + // 免税收入 + BigDecimal taxFreeIncome = BigDecimal.ZERO; + valueMap.put("taxFreeIncome", taxFreeIncome); + // 减除费用 + BigDecimal subtraction = findValue("subtraction", resultMap, salaryItemMap); + valueMap.put("subtraction", subtraction); + // 基本养老保险 + BigDecimal endowmentInsurance = findValue("endowmentInsurance", resultMap, salaryItemMap); + valueMap.put("endowmentInsurance", endowmentInsurance); + // 基本医疗保险 + BigDecimal medicalInsurance = findValue("medicalInsurance", resultMap, salaryItemMap); + valueMap.put("medicalInsurance", medicalInsurance); + // 失业保险 + BigDecimal unemploymentInsurance = findValue("unemploymentInsurance", resultMap, salaryItemMap); + valueMap.put("unemploymentInsurance", unemploymentInsurance); + // 住房公积金 + BigDecimal housingProvidentFund = findValue("housingProvidentFund", resultMap, salaryItemMap); + valueMap.put("housingProvidentFund", housingProvidentFund); + // 年金 + BigDecimal annuity = findValue("annuity", resultMap, salaryItemMap); + valueMap.put("annuity", annuity); + // 商业健康保险 + BigDecimal commercialHealthInsurance = findValue("commercialHealthInsurance", resultMap, salaryItemMap); + valueMap.put("commercialHealthInsurance", commercialHealthInsurance); + // 税延养老保险 + BigDecimal taxDeferredEndowmentInsurance = findValue("taxDeferredEndowmentInsurance", resultMap, salaryItemMap); + valueMap.put("taxDeferredEndowmentInsurance", taxDeferredEndowmentInsurance); + // 财产原值 + BigDecimal originalValueOfProperty = findValue("originalValueOfProperty", resultMap, salaryItemMap); + valueMap.put("originalValueOfProperty", originalValueOfProperty); + // 允许扣除的税费 + BigDecimal deductedTax = findValue("deductedTax", resultMap, salaryItemMap); + valueMap.put("deductedTax", deductedTax); + // 其他 + BigDecimal other = findValue("other", resultMap, salaryItemMap); + valueMap.put("other", other); + // 累计收入 + BigDecimal addUpIncome = findAddUpValue("addUpIncome", resultMap, salaryItemMap); + valueMap.put("addUpIncome", addUpIncome); + // 累计减除费用 + BigDecimal addUpSubtraction = findAddUpValue("addUpSubtraction", resultMap, salaryItemMap); + valueMap.put("addUpSubtraction", addUpSubtraction); + // 累计专项扣除 + BigDecimal addUpSpecialDeduction = findAddUpValue("addUpSpecialDeduction", resultMap, salaryItemMap); + valueMap.put("addUpSpecialDeduction", addUpSpecialDeduction); + // 累计子女教育 + BigDecimal addUpChildEducation = findAddUpValue("addUpChildEducation", resultMap, salaryItemMap); + valueMap.put("addUpChildEducation", addUpChildEducation); + // 累计继续教育 + BigDecimal addUpContinuingEducation = findAddUpValue("addUpContinuingEducation", resultMap, salaryItemMap); + valueMap.put("addUpContinuingEducation", addUpContinuingEducation); + // 累计住房贷款利息 + BigDecimal addUpHousingLoanInterest = findAddUpValue("addUpHousingLoanInterest", resultMap, salaryItemMap); + valueMap.put("addUpHousingLoanInterest", addUpHousingLoanInterest); + // 累计住房租金 + BigDecimal addUpHousingRent = findAddUpValue("addUpHousingRent", resultMap, salaryItemMap); + valueMap.put("addUpHousingRent", addUpHousingRent); + // 累计赡养老人 + BigDecimal addUpSupportElderly = findAddUpValue("addUpSupportElderly", resultMap, salaryItemMap); + valueMap.put("addUpSupportElderly", addUpSupportElderly); + // 累计其他扣除 + BigDecimal addUpOtherDeduction = findAddUpValue("addUpOtherDeduction", resultMap, salaryItemMap); + valueMap.put("addUpOtherDeduction", addUpOtherDeduction); + // 减按计税比例 + BigDecimal lessTaxProportion = BigDecimal.ONE; + valueMap.put("lessTaxProportion", lessTaxProportion); + // 准允扣除的捐赠额 + BigDecimal addUpAllowedDonation = findAddUpValue("addUpAllowedDonation", resultMap, salaryItemMap); + valueMap.put("addUpAllowedDonation", addUpAllowedDonation); + // 应纳税所得额 + BigDecimal addUpTaxableIncome = findAddUpValue("addUpTaxableIncome", resultMap, salaryItemMap); + valueMap.put("addUpTaxableIncome", addUpTaxableIncome); + // 税率 + BigDecimal taxRate = findAddUpValue("taxRate", resultMap, salaryItemMap); + valueMap.put("taxRate", taxRate); + // 速算扣除数 + BigDecimal quickDeductionFactor = findAddUpValue("quickDeductionFactor", resultMap, salaryItemMap); + valueMap.put("quickDeductionFactor", quickDeductionFactor); + // 应纳税额 + BigDecimal addUpTaxPayable = findAddUpValue("addUpTaxPayable", resultMap, salaryItemMap); + valueMap.put("addUpTaxPayable", addUpTaxPayable); + // 减免税额 + BigDecimal addUpTaxDeduction = BigDecimal.ZERO; + valueMap.put("addUpTaxDeduction", addUpTaxDeduction); + // 应补缴税额 + BigDecimal refundedOrSupplementedTax = SalaryEntityUtil.reduce(resultMap.get(salaryItemMap.getOrDefault("refundedOrSupplementedTax", 0L)), + e -> SalaryEntityUtil.empty2Zero(e.getResultValue())); + valueMap.put("refundedOrSupplementedTax", refundedOrSupplementedTax); + // 已扣缴税额 + BigDecimal taxWithheld = addUpTaxPayable.subtract(refundedOrSupplementedTax); + valueMap.put("taxWithheld", taxWithheld); + + valueMap.forEach((key, value) -> { + TaxDeclarationDetailPO detailPO = TaxDeclarationDetailPO.builder() + .id(IdGenerator.generate()) + .taxDeclarationId(taxDeclaration.getId()) + .employeeId(k) + .fieldCode(key) + .fieldValue(value.toPlainString()) + .creator(taxDeclaration.getCreator()) + .createTime(SalaryDateUtil.dateToLocalDateTime(taxDeclaration.getCreateTime())) + .updateTime(SalaryDateUtil.dateToLocalDateTime(taxDeclaration.getUpdateTime())) + .deleteType(0) + .tenantKey(taxDeclaration.getTenantKey()) + .build(); + result.getNeedInsertTaxDeclarationDetails().add(detailPO); + }); + // 累计社保个人合计 + BigDecimal addUpSocialSecurityTotal = findAddUpValue("addUpSocialSecurityTotal", resultMap, salaryItemMap); + // 累计公积金个人合计 + BigDecimal addUpAccumulationFundTotal = findAddUpValue("addUpAccumulationFundTotal", resultMap, salaryItemMap); + // 累计年金及其他福利合计 + BigDecimal addUpEnterpriseAndOther = findAddUpValue("addUpEnterpriseAndOther", resultMap, salaryItemMap); + // 更新累计情况 + AddUpSituation accumulatedSituation = AddUpSituation.builder() + .id(IdGenerator.generate()) + .employeeId(k) + .taxAgentId(taxDeclaration.getTaxAgentId()) + .taxYearMonth((taxDeclaration.getSalaryMonth())) + .year(taxDeclaration.getSalaryMonth().getYear()) + .addUpIncome(addUpIncome.toPlainString()) + .addUpSocialSecurityTotal(addUpSocialSecurityTotal.toPlainString()) + .addUpAccumulationFundTotal(addUpAccumulationFundTotal.toPlainString()) + .addUpEnterpriseAndOther(addUpEnterpriseAndOther.toPlainString()) + .addUpSubtraction(addUpSubtraction.toPlainString()) + .addUpChildEducation(addUpChildEducation.toPlainString()) + .addUpContinuingEducation(addUpContinuingEducation.toPlainString()) + .addUpHousingLoanInterest(addUpHousingLoanInterest.toPlainString()) + .addUpHousingRent(addUpHousingRent.toPlainString()) + .addUpSupportElderly(addUpSupportElderly.toPlainString()) + .addUpOtherDeduction(addUpOtherDeduction.toPlainString()) + .addUpTaxExemptIncome("0") + .addUpAllowedDonation(addUpAllowedDonation.toPlainString()) + .addUpAdvanceTax(addUpTaxPayable.toPlainString()) + .creator(taxDeclaration.getCreator()) + .createTime(taxDeclaration.getCreateTime()) + .updateTime(taxDeclaration.getUpdateTime()) + .tenantKey(taxDeclaration.getTenantKey()) + .deleteType(0) + .build(); + result.getNeedInsertAccumulatedSituations().add(accumulatedSituation); + }); + } + + private static TaxDeclarationPO convert2PO(TaxDeclarationSaveParam saveParam, Date taxCycle, Long taxAgentId) { + LocalDateTime now = LocalDateTime.now(); + return TaxDeclarationPO.builder() + .id(IdGenerator.generate()) + .taxAgentId(taxAgentId) + .salaryMonth(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))) + .taxCycle(taxCycle) + .description(saveParam.getDescription()) + // .creator(employeeId) + .createTime(SalaryDateUtil.localDateTimeToDate(now)) + .updateTime(SalaryDateUtil.localDateTimeToDate(now)) + .deleteType(0) + //.tenantKey(tenantKey) + .build(); + } + + private static BigDecimal findValue(String fieldCode, Map> resultMap, Map salaryItemMap) { + return resultMap.getOrDefault(salaryItemMap.getOrDefault(fieldCode, 0L), Collections.emptyList()).stream() + .map(e -> SalaryEntityUtil.empty2Zero(e.getResultValue())) + .filter(e -> e.compareTo(BigDecimal.ZERO) > 0) + .findAny() + .orElse(BigDecimal.ZERO); + } + + private static BigDecimal findAddUpValue(String fieldCode, Map> resultMap, Map salaryItemMap) { + return resultMap.getOrDefault(salaryItemMap.getOrDefault(fieldCode, 0L), Collections.emptyList()).stream() + .map(e -> SalaryEntityUtil.empty2Zero(e.getResultValue())) + .max(Comparator.comparingDouble(BigDecimal::doubleValue)) + .orElse(BigDecimal.ZERO); + } + + @Data + public static class Result { + + private Collection needInsertTaxDeclarations; + + private Collection needInsertTaxDeclarationDetails; + + private Collection needInsertAccumulatedSituations; + + public Result() { + this.needInsertTaxDeclarations = Lists.newArrayList(); + this.needInsertTaxDeclarationDetails = Lists.newArrayList(); + this.needInsertAccumulatedSituations = Lists.newArrayList(); + } + } +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationDetailListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationDetailListDTO.java new file mode 100644 index 000000000..89c66086b --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationDetailListDTO.java @@ -0,0 +1,235 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 个税申报表详情列表 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 10:31 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationDetailListDTO { + + /** + * 主键id + */ + private Long id; + + /** + * 个税申报记录id + */ + private Long taxDeclarationId; + + /** + * 序号 + */ + private Integer seq; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 姓名 + */ + private String employeeName; + + /** + * 身份证件类型 + */ + private String idCardType; + + /** + * 身份证件号码 + */ + private String idCardNo; + + /** + * 纳税人识别号 + */ + private String taxpayerIdNo; + + /** + * 是居民还是非居民 + */ + private String residentType; + + /** + * 所得项目 + */ + private String incomeType; + + /** + * 收入 + */ + private String income; + + /** + * 费用 + */ + private String fee; + + /** + * 免税收入 + */ + private String taxFreeIncome; + + /** + * 减除费用 + */ + private String subtraction; + + /** + * 养老保险 + */ + private String endowmentInsurance; + + /** + * 医疗保险 + */ + private String medicalInsurance; + + /** + * 失业保险 + */ + private String unemploymentInsurance; + + /** + * 住房公积金 + */ + private String housingProvidentFund; + + /** + * 年金 + */ + private String annuity; + + /** + * 商业健康保险 + */ + private String commercialHealthInsurance; + + /** + * 税延养老保险 + */ + private String taxDeferredEndowmentInsurance; + + /** + * 财产原值 + */ + private String originalValueOfProperty; + + /** + * 允许扣除的税费 + */ + private String deductedTax; + + /** + * 其他 + */ + private String other; + + /** + * 累计收入额 + */ + private String addUpIncome; + + /** + * 累计减除费用 + */ + private String addUpSubtraction; + + /** + * 累计专项扣除 + */ + private String addUpSpecialDeduction; + + /** + * 累计子女教育 + */ + private String addUpChildEducation; + + /** + * 累计继续教育 + */ + private String addUpContinuingEducation; + + /** + * 累计住房贷款利息 + */ + private String addUpHousingLoanInterest; + + /** + * 累计住房租金 + */ + private String addUpHousingRent; + + /** + * 累计赡养老人 + */ + private String addUpSupportElderly; + + /** + * 累计其他扣除 + */ + private String addUpOther; + + /** + * 减按计税比例 + */ + private String lessTaxProportion; + + /** + * 准允扣除的捐赠额 + */ + private String allowedDonation; + + /** + * 应纳税所得额 + */ + private String taxableIncome; + + /** + * 税率 + */ + private String taxRate; + + /** + * 速算扣除数 + */ + private String quickDeductionFactor; + + /** + * 应纳税款 + */ + private String taxPayable; + + /** + * 减免税额 + */ + private String taxSavings; + + /** + * 已扣缴税额 + */ + private String taxWithheld; + + /** + * 应补(退)税额 + */ + private String refundedOrSupplementedTax; + + /** + * 备注 + */ + private String description; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationFormDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationFormDTO.java new file mode 100644 index 000000000..b8b120063 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationFormDTO.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.taxdeclaration.dto; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + +/** + * @description: 个税申报记录表单 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 9:40 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationFormDTO { + + //薪资所属月") + private YearMonth salaryMonth; + + //个税扣缴义务人id") + private Long taxAgentId; + + //个税扣缴义务人名称") + private String taxAgentName; + + //备注") + private String description; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationInfoDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationInfoDTO.java new file mode 100644 index 000000000..7fdadf741 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationInfoDTO.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + +/** + * @description: 个税申报表信息 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/16/21 3:22 PM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationInfoDTO { + + //薪资所属月") + private YearMonth salaryMonth; + + //个税扣缴义务人id") + private Long taxAgentId; + + //个税扣缴义务人名称") + private String taxAgentName; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java new file mode 100644 index 000000000..6ef172e76 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationLaborListDTO.java @@ -0,0 +1,61 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @description: 个税申报表详情列表(劳务报酬所得) + * @author: xiajun + * @modified By: xiajun + * @date: 2022/3/11 10:05 + * @version:v1.0 + */ +@Data +@Accessors(chain = true) +public class TaxDeclarationLaborListDTO { + + //主键id") + private Long id; + + //人员id") + private Long employeeId; + + //工号") + private String jobNum; + + //姓名") + private String username; + + //证件类型") + private String cardType; + + //证件号码") + private String cardNum; + + //"所得项目") + private String incomeItems; + + //"劳务收入") + private String laborIncome; + + //"劳务免税收入") + private String laborTaxFreeIncome; + + //"商业健康保险") + private String commercialHealthInsurance; + + //"税延养老保险") + private String taxDeferredEndowmentInsurance; + + //"其他") + private String other; + + //"准允扣除的捐赠额") + private String allowedDonation; + + //"减免税额") + private String taxDeduction; + + //备注") + private String description; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java new file mode 100644 index 000000000..13db69425 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationListDTO.java @@ -0,0 +1,52 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import com.engine.salary.annotation.TableTitle; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 个税申报记录列表 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 9:31 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationListDTO { + + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + @TableTitle(title = "薪资所属月份", dataIndex = "salaryMonth", key = "salaryMonth") + private String salaryMonth; + + @TableTitle(title = "个税扣缴义务人", dataIndex = "taxAgentId", key = "taxAgentId") + private Long taxAgentId; + + @TableTitle(title = "个税扣缴义务人名称", dataIndex = "taxAgentName", key = "taxAgentName") + private String taxAgentName; + + @TableTitle(title = "税款所属期", dataIndex = "taxCycle", key = "taxCycle") + private String taxCycle; + + @TableTitle(title = "操作人id", dataIndex = "operateEmployeeId", key = "operateEmployeeId") + private Long operateEmployeeId; + + @TableTitle(title = "操作人名称", dataIndex = "operateEmployeeName", key = "operateEmployeeName") + private String operateEmployeeName; + + @JsonFormat(pattern = "yyyy-MM-dd") + @TableTitle(title = "操作时间", dataIndex = "operateTime", key = "operateTime") + private String operateTime; + + @TableTitle(title = "备注", dataIndex = "description", key = "description") + private String description; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationWageListDTO.java b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationWageListDTO.java new file mode 100644 index 000000000..a5d1f3630 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/dto/TaxDeclarationWageListDTO.java @@ -0,0 +1,91 @@ +package com.engine.salary.entity.taxdeclaration.dto; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @description: 个税申报表详情列表(正常工资薪金所得) + * @author: xiajun + * @modified By: xiajun + * @date: 2022/3/11 9:35 + * @version:v1.0 + */ +@Data +@Accessors(chain = true) +public class TaxDeclarationWageListDTO { + + //主键id") + private Long id; + + //人员id") + private Long employeeId; + + //"工号") + private String jobNum; + + //"姓名") + private String username; + + //证件类型") + private String cardType; + + //证件号码") + private String cardNum; + + //本期收入") + private String income; + + //本期免税收入") + private String taxFreeIncome; + + //"基本养老保险费") + private String endowmentInsurance; + + //"基本医疗保险费") + private String medicalInsurance; + + //失业保险费") + private String unemploymentInsurance; + + //住房公积金") + private String housingProvidentFund; + + //"累计子女教育") + private String addUpChildEducation; + + //累计住房贷款利息") + private String addUpHousingLoanInterest; + + //"累计住房租金") + private String addUpHousingRent; + + //累计继续教育") + private String addUpContinuingEducation; + + //"累计赡养老人") + private String addUpSupportElderly; + + //"累计大病医疗") + private String addUpIllnessMedical; + + //"企业(职业)年金") + private String annuity; + + //商业健康保险") + private String commercialHealthInsurance; + + //"税延养老保险") + private String taxDeferredEndowmentInsurance; + + //"其他") + private String other; + + //"准允扣除的捐赠额") + private String allowedDonation; + + //"减免税额") + private String taxDeduction; + + //"备注") + private String description; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationDetailListQueryParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationDetailListQueryParam.java new file mode 100644 index 000000000..ee7c58e2a --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationDetailListQueryParam.java @@ -0,0 +1,26 @@ +package com.engine.salary.entity.taxdeclaration.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +/** + * @description: 个税申报记录详情列表查询参数 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 3:21 PM + * @version:v1.0 + */ +@Data +@Builder +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationDetailListQueryParam extends BaseQueryParam { + + //"个税申报记录id") + private Long taxDeclarationId; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java new file mode 100644 index 000000000..9bf32829c --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationListQueryParam.java @@ -0,0 +1,33 @@ +package com.engine.salary.entity.taxdeclaration.param; + +import com.engine.salary.common.BaseQueryParam; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + +/** + * @description: 个税申报记录查询条件 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 9:30 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationListQueryParam extends BaseQueryParam { + + //薪资所属月范围起点 + private YearMonth fromSalaryMonth; + + //薪资所属月范围终点 + private YearMonth endSalaryMonth; + + private String fromSalaryMonthStr; + + private String endSalaryMonthStr; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java new file mode 100644 index 000000000..8e4c734ed --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/param/TaxDeclarationSaveParam.java @@ -0,0 +1,31 @@ +package com.engine.salary.entity.taxdeclaration.param; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.YearMonth; + +/** + * @description: 生成个税申报表参数 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 9:44 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationSaveParam { + + //薪资所属月") + private YearMonth salaryMonth; + + //备注") + private String description; + + private String salaryMonthStr; + +} diff --git a/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationDetailPO.java b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationDetailPO.java new file mode 100644 index 000000000..2f6952696 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationDetailPO.java @@ -0,0 +1,78 @@ +package com.engine.salary.entity.taxdeclaration.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * @description: 个税申报表详情 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/14/21 7:01 PM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationDetailPO { + + /** + * 主键id + */ + private Long id; + + /** + * 个税申报记录id + */ + private Long taxDeclarationId; + + /** + * 人员id + */ + private Long employeeId; + + /** + * 申报表字段code + */ + private String fieldCode; + + /** + * 申报表字段的值 + */ + private String fieldValue; + + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private LocalDateTime createTime; + + /** + * 更新时间 + */ + private LocalDateTime updateTime; + + /** + * 应税项目。1:正常工资薪金所得 + */ + private Integer incomeCategory; +} diff --git a/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java new file mode 100644 index 000000000..7836bff64 --- /dev/null +++ b/src/com/engine/salary/entity/taxdeclaration/po/TaxDeclarationPO.java @@ -0,0 +1,76 @@ +package com.engine.salary.entity.taxdeclaration.po; + +import com.engine.salary.common.LocalDateRange; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @description: 个税申报记录 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/14/21 6:57 PM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TaxDeclarationPO { + + /** + * 主键id + */ + private Long id; + + /** + * 薪资所属月 + */ + private Date salaryMonth; + + /** + * 税款所属期 + */ + private Date taxCycle; + + /** + * 个税扣缴义务人id + */ + private Long taxAgentId; + + /** + * 备注 + */ + private String description; + + /** + * 租户key + */ + private String tenantKey; + + /** + * 创建人id + */ + private Long creator; + + /** + * 是否删除 + */ + private Integer deleteType; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 更新时间 + */ + private Date updateTime; + + //税款所属期 + LocalDateRange salaryMonths; +} diff --git a/src/com/engine/salary/entity/taxrate/vo/TaxDeclarationListVO.java b/src/com/engine/salary/entity/taxrate/vo/TaxDeclarationListVO.java new file mode 100644 index 000000000..6da2aab85 --- /dev/null +++ b/src/com/engine/salary/entity/taxrate/vo/TaxDeclarationListVO.java @@ -0,0 +1,78 @@ +package com.engine.salary.entity.taxrate.vo; + +import com.engine.salary.annotation.SalaryTable; +import com.engine.salary.annotation.SalaryTableColumn; +import com.engine.salary.annotation.SalaryTableOperate; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @description: 个税申报记录列表 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 12/15/21 9:31 AM + * @version:v1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@SalaryTable(pageId = "a4f85287-e3f9-4275-9527-7d06e54y6rj8", + fields = "id, salary_month, tax_cycle, tax_agent_id, description,creator, create_time, update_time, delete_type, tenant_key", + fromSql = "from hrsa_tax_declaration", + orderby = "id desc", + primarykey = "id", + operates = {@SalaryTableOperate(text = "查看")} +) +public class TaxDeclarationListVO { + + private Long id; + + @SalaryTableColumn( + text = "薪资所属月", + column = "salaryMonth", + width = "10%" + ) + private String salaryMonth; + + private Long taxAgentId; + + /* @SalaryTableColumn( + text = "个税扣缴义务人", + column = "taxAgentName", + width = "20%" + ) + private String taxAgentName;*/ + + @SalaryTableColumn( + text = "税款所属期", + column = "taxCycle", + width = "10%" + ) + private String taxCycle; + + private Long operateEmployeeId; + + /* @SalaryTableColumn( + text = "操作人", + column = "operateEmployeeName", + width = "10%" + ) + private String operateEmployeeName; +*/ + /* @SalaryTableColumn( + text = "操作时间", + column = "operateTime", + width = "20%" + ) + private String operateTime;*/ + + @SalaryTableColumn( + text = "备注", + column = "description", + width = "30%" + ) + private String description; +} diff --git a/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java b/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java index 5de3d0b81..5b60f0b0a 100644 --- a/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java +++ b/src/com/engine/salary/enums/salarysob/IncomeCategoryEnum.java @@ -15,6 +15,8 @@ public enum IncomeCategoryEnum implements BaseEnum { WAGES_AND_SALARIES(1, "正常工资薪金所得", 98656), + REMUNERATION_FOR_LABOR(4, "劳务报酬所得", 105218), + // 暂时注释掉,后续会开放 // ONETIME_ANNUAL_BONUS(2,"全年一次性奖金收入", 0), // diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java index 39242506c..e3f852d35 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.java @@ -1,8 +1,11 @@ package com.engine.salary.mapper.taxdeclaration; import com.engine.salary.entity.taxdeclaration.TaxDeclarationDetail; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; @Mapper @@ -63,5 +66,11 @@ public interface TaxDeclarationDetailMapper { * @return 返回影响行数 */ int delete(TaxDeclarationDetail taxDeclarationDetail); - + + /** + * 批量插入 + * + * @param taxDeclarationDetails + */ + void batchInsert(@Param("collection") Collection taxDeclarationDetails); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml index e777cf3d9..3394ebbfa 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationDetailMapper.xml @@ -148,6 +148,26 @@ + + INSERT INTO hrsa_tax_declaration_detail + (id, tax_declaration_id, employee_id, field_code, field_value, creator, + create_time, update_time, delete_type, tenant_key) + VALUES + + ( + #{item.id}, + #{item.taxDeclarationId}, + #{item.employeeId}, + #{item.fieldCode}, + #{item.fieldValue}, + #{item.creator}, + #{item.createTime}, + #{item.updateTime}, + #{item.deleteType}, + #{item.tenantKey} + ) + + diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.java b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.java index ba3011bcc..f436d1d08 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.java +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.java @@ -1,8 +1,11 @@ package com.engine.salary.mapper.taxdeclaration; import com.engine.salary.entity.taxdeclaration.TaxDeclaration; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import java.util.Collection; import java.util.List; @Mapper @@ -63,5 +66,19 @@ public interface TaxDeclarationMapper { * @return 返回影响行数 */ int delete(TaxDeclaration taxDeclaration); + + /** + * 条件查询 + * + * @return 返回集合,没有返回空List + */ + + List listSome(TaxDeclarationPO taxDeclarationPO); + /** + * 批量插入 + * + * @param taxDeclarationDetails + */ + void batchInsert(@Param("collection") Collection taxDeclarationDetails); } \ No newline at end of file diff --git a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml index 03080c4cf..67a478c41 100644 --- a/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml +++ b/src/com/engine/salary/mapper/taxdeclaration/TaxDeclarationMapper.xml @@ -16,9 +16,7 @@ - t - . - create_time + t.create_time , t.creator , t.delete_type , t.description @@ -45,6 +43,41 @@ FROM hrsa_tax_declaration t WHERE id = #{id} AND delete_type = 0 + + + + + INSERT INTO hrsa_tax_declaration + (create_time, creator, delete_type, description, id, salary_month, + tax_agent_id, tax_cycle, tenant_key, update_time) + VALUES + + ( + #{item.create_time}, + #{item.creator}, + #{item.delete_type}, + #{item.description}, + #{item.id}, + #{item.salary_month}, + #{item.tax_agent_id}, + #{item.tax_cycle}, + #{item.tenant_key}, + #{item.update_time} + ) + + listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, Collection employeeIds, String tenantKey); + + /** + * 根据列表查询条件查询个税申报列表明细中的人员 + * + * @param queryParam 列表查询条件 + * @param tenantKey 租户key + * @return + */ + //Page listPage4EmployeeIdByParam(TaxDeclarationDetailListQueryParam queryParam, String tenantKey); + + /** + * 根据列表查询条件查询个税申报列表明细 + * + * @param queryParam 列表查询条件 + * @param tenantKey 租户key + * @return + */ + // Page listDtoPageByParam(TaxDeclarationDetailListQueryParam queryParam, String tenantKey); + + /** + * 根据列表查询条件查询个税申报列表明细(劳务报酬所得) + * + * @param queryParam 列表查询条件 + * @param tenantKey 租户key + * @return + */ + PageInfo listDtoPageByParam4Labor(TaxDeclarationDetailListQueryParam queryParam); + + /** + * 根据列表查询条件查询个税申报列表明细(正常工资薪金所得) + * + * @param queryParam 列表查询条件 + * @param tenantKey 租户key + * @return + */ + PageInfo listDtoPageByParam4Wage(TaxDeclarationDetailListQueryParam queryParam); + + /** + * 批量保存 + * + * @param taxDeclarationDetailPOS 个税申报表明细po + */ + void batchSave(Collection taxDeclarationDetailPOS); +} diff --git a/src/com/engine/salary/service/TaxDeclarationService.java b/src/com/engine/salary/service/TaxDeclarationService.java index 32dbe8831..07ea4d1e5 100644 --- a/src/com/engine/salary/service/TaxDeclarationService.java +++ b/src/com/engine/salary/service/TaxDeclarationService.java @@ -1,5 +1,14 @@ package com.engine.salary.service; +import com.engine.salary.entity.taxdeclaration.TaxDeclaration; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.entity.taxrate.TaxAgent; +import com.engine.salary.util.page.PageInfo; + +import java.util.Collection; +import java.util.List; import java.util.Map; public interface TaxDeclarationService { @@ -9,7 +18,18 @@ public interface TaxDeclarationService { */ Map listPage(Map params); - Map save(Map params); + PageInfo listPageByParam(TaxDeclarationListQueryParam queryParam); + + List countByTaxDeclarationId(Collection taxAgentIds); + + //表单 + TaxDeclaration getById(Long id); + + Map getForm(Map params); + + Map getTaxDeclarationInfo(Map params); + + void save(TaxDeclarationSaveParam saveParam); Map update(Map params); diff --git a/src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java new file mode 100644 index 000000000..40336a291 --- /dev/null +++ b/src/com/engine/salary/service/impl/TaxDeclarationDetailServiceImpl.java @@ -0,0 +1,81 @@ +package com.engine.salary.service.impl; + +import com.engine.core.impl.Service; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO; +import com.engine.salary.mapper.taxdeclaration.TaxDeclarationDetailMapper; +import com.engine.salary.service.TaxDeclarationDetailService; +import com.engine.salary.util.page.PageInfo; + +import javax.annotation.Resource; +import java.util.Collection; + +/** + * @description: 个税申报表明细 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/23/22 4:29 PM + * @version:v1.0 + */ +public class TaxDeclarationDetailServiceImpl extends Service implements TaxDeclarationDetailService { + + @Resource + private TaxDeclarationDetailMapper taxDeclarationDetailMapper; + //@Resource + //private HrmCommonEmployeeService hrmCommonEmployeeService; + + /*@Override + public List listByTaxDeclarationIdAndEmployeeIds(Long taxDeclarationId, Collection employeeIds, String tenantKey) { + if (CollectionUtils.isEmpty(employeeIds)) { + return Collections.emptyList(); + } + return new LambdaQueryChainWrapper<>(taxDeclarationDetailMapper) + .eq(TaxDeclarationDetailPO::getTenantKey, tenantKey) + .eq(TaxDeclarationDetailPO::getDeleteType, 0) + .eq(TaxDeclarationDetailPO::getTaxDeclarationId, taxDeclarationId) + .in(TaxDeclarationDetailPO::getEmployeeId, employeeIds) + .list(); + } + + @Override + public Page listPage4EmployeeIdByParam(TaxDeclarationDetailListQueryParam queryParam, String tenantKey) { + // 分页参数 + Page page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize()); + // 查询个税申报表明细中的人员(分页) + return taxDeclarationDetailMapper.listEmployeeId(page, queryParam.getTaxDeclarationId(), tenantKey); + } + + @Override + public Page listDtoPageByParam(TaxDeclarationDetailListQueryParam queryParam, String tenantKey) { + // 查询个税申报表明细的人员 + Page employeeIdPage = listPage4EmployeeIdByParam(queryParam, tenantKey); + Page dtoPage = new Page<>(employeeIdPage.getCurrent(), employeeIdPage.getSize(), employeeIdPage.getTotal(), employeeIdPage.isSearchCount()); + if (CollectionUtils.isNotEmpty(employeeIdPage.getRecords())) { + // 查询个税申报表明细 + List taxDeclarationDetailPOS = listByTaxDeclarationIdAndEmployeeIds(queryParam.getTaxDeclarationId(), + employeeIdPage.getRecords(), tenantKey); + // 查询人员信息 + List simpleEmployees = hrmCommonEmployeeService.getEmployeeByIds(employeeIdPage.getRecords(), tenantKey); + // 转换成列表dto + TaxDeclarationBO.buildDetailListDTO(queryParam.getTaxDeclarationId(), dtoPage, taxDeclarationDetailPOS, simpleEmployees); + } + return dtoPage; + }*/ + + @Override + public PageInfo listDtoPageByParam4Labor(TaxDeclarationDetailListQueryParam queryParam) { + return null; + } + + @Override + public PageInfo listDtoPageByParam4Wage(TaxDeclarationDetailListQueryParam queryParam) { + return null; + } + + @Override + public void batchSave(Collection taxDeclarationDetailPOS) { + taxDeclarationDetailMapper.batchInsert(taxDeclarationDetailPOS); + } +} diff --git a/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java index ce30a20e1..44290e421 100644 --- a/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java +++ b/src/com/engine/salary/service/impl/TaxDeclarationServiceImpl.java @@ -1,24 +1,98 @@ package com.engine.salary.service.impl; import com.engine.core.impl.Service; -import com.engine.salary.cmd.taxDeclaration.TaxDeclarationDeleteCmd; -import com.engine.salary.cmd.taxDeclaration.TaxDeclarationListCmd; -import com.engine.salary.cmd.taxDeclaration.TaxDeclarationSaveCmd; -import com.engine.salary.cmd.taxDeclaration.TaxDeclarationUpdateCmd; +import com.engine.salary.cmd.taxDeclaration.*; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.entity.taxdeclaration.TaxDeclaration; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.entity.taxrate.TaxAgent; +import com.engine.salary.entity.taxrate.param.TaxAgentQueryParam; +import com.engine.salary.mapper.TaxAgentMapper; +import com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper; import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.db.MapperProxyFactory; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.util.page.PageUtil; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.session.SqlSession; +import weaver.conn.mybatis.MyBatisFactory; -import java.util.Map; +import java.util.*; public class TaxDeclarationServiceImpl extends Service implements TaxDeclarationService { + private TaxDeclarationMapper getTaxDeclarationMapper() { + return MapperProxyFactory.getProxy(TaxDeclarationMapper.class); + } + @Override public Map listPage(Map params) { return commandExecutor.execute(new TaxDeclarationListCmd(params, user)); } @Override - public Map save(Map params) { - return commandExecutor.execute(new TaxDeclarationSaveCmd(params, user)); + public PageInfo listPageByParam(TaxDeclarationListQueryParam queryParam) { + // 分页参数 + TaxDeclarationPO po = TaxDeclarationPO.builder().build(); + PageInfo page = new PageInfo<>(); + LocalDateRange localDateRange = new LocalDateRange(); + if (Objects.nonNull(queryParam.getFromSalaryMonth())) { + localDateRange.setFromDate(SalaryDateUtil.localDateToDate(queryParam.getFromSalaryMonth().atDay(1))); + } + if (Objects.nonNull(queryParam.getEndSalaryMonth())) { + localDateRange.setEndDate(SalaryDateUtil.localDateToDate(queryParam.getEndSalaryMonth().atEndOfMonth())); + } + po.setSalaryMonths(localDateRange); + //Page page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize()); +// if (SalaryEntityUtil.isNotNullOrEmpty(queryParam.getFromSalaryMonth())&&SalaryEntityUtil.isNotNullOrEmpty(queryParam.getEndSalaryMonth()) ) { +// // taxDeclarationMapper.selectPage(page, queryWrapper) +// } + // 查询个税申报表 + PageUtil.start(queryParam.getCurrent(), queryParam.getPageSize()); + List taxDeclarationPOS = getTaxDeclarationMapper().listSome(po); + page.setList(taxDeclarationPOS); + + return page; + } + //根据id查询taxAgents + @Override + public List countByTaxDeclarationId(Collection taxAgentIds) { + if (CollectionUtils.isEmpty(taxAgentIds)) { + return Collections.emptyList(); + } + SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession(); + try { + TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class); + return taxAgentMapper.listBySome(TaxAgentQueryParam.builder().ids(taxAgentIds).build()); + } finally { + sqlSession.close(); + } + } + //根据id获取TaxDeclaration + @Override + public TaxDeclaration getById(Long id) { + return getTaxDeclarationMapper().getById(id); + } + + @Override + public Map getForm(Map params) { + return commandExecutor.execute(new TaxDeclarationGetFormCmd(params, user)); + } + + @Override + public Map getTaxDeclarationInfo(Map params) { + return commandExecutor.execute(new TaxDeclarationGetTaxDeclarationInfoCmd(params, user)); + } + + @Override + public void save(TaxDeclarationSaveParam saveParam) { + //return commandExecutor.execute(new TaxDeclarationSaveCmd(saveParam)); + return; } @Override diff --git a/src/com/engine/salary/util/SalaryDateUtil.java b/src/com/engine/salary/util/SalaryDateUtil.java index 8a4853cd8..566dc95a5 100644 --- a/src/com/engine/salary/util/SalaryDateUtil.java +++ b/src/com/engine/salary/util/SalaryDateUtil.java @@ -165,6 +165,12 @@ public class SalaryDateUtil { ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault()); return Date.from(zonedDateTime.toInstant()); } + public static Date localDateTimeToDate(LocalDateTime localDateTime) { + if (null == localDateTime) { + return null; + } + return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + } public static String getFormatLocalDate(Date date) { if (date == null) { diff --git a/src/com/engine/salary/web/TaxDeclarationController.java b/src/com/engine/salary/web/TaxDeclarationController.java index 48268a4b8..c4bc63540 100644 --- a/src/com/engine/salary/web/TaxDeclarationController.java +++ b/src/com/engine/salary/web/TaxDeclarationController.java @@ -1,47 +1,90 @@ package com.engine.salary.web; +import com.engine.common.util.ServiceUtil; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationFormDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationInfoDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.service.impl.TaxDeclarationServiceImpl; +import com.engine.salary.util.ResponseResult; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.page.PageInfo; +import com.engine.salary.wrapper.TaxDeclarationWrapper; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import weaver.general.BaseBean; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + + public class TaxDeclarationController { - // @PostMapping("/list") - // @ApiOperation("个税申报表列表") - // @WeaPermission - // public WeaResult> listTaxDeclaration(@RequestBody TaxDeclarationListQueryParam queryParam) { - // WeaTable weaTable = taxDeclarationWrapper.listPage(queryParam, TenantContext.getCurrentTenantKey()); - // return WeaResult.success(weaTable); - // } - // - // @GetMapping("/getForm") - // @ApiOperation("个税申报表表单") - // @WeaPermission - // public WeaResult getForm(@RequestParam(value = "id", required = false) Long id) { - // WeaForm weaForm = taxDeclarationWrapper.getForm(id, TenantContext.getCurrentTenantKey()); - // return WeaResult.success(weaForm); - // } - // - // @GetMapping("/getTaxDeclarationInfo") - // @ApiOperation("个税申报表相关信息") - // @WeaPermission - // public WeaResult getTaxDeclarationInfo(@RequestParam(value = "taxDeclarationId") Long taxDeclarationId) { - // TaxDeclarationInfoDTO taxDeclarationInfo = taxDeclarationWrapper.getTaxDeclarationInfoById(taxDeclarationId, TenantContext.getCurrentTenantKey()); - // return WeaResult.success(taxDeclarationInfo); - // } - // - // @PostMapping("/save") - // @ApiOperation("个税申报表生成") - // @WeaPermission - // public WeaResult saveTaxDeclaration(@RequestBody TaxDeclarationSaveParam saveParam) { - // taxDeclarationWrapper.save(saveParam, UserContext.getCurrentEmployeeId(), TenantContext.getCurrentTenantKey()); - // return WeaResult.success(null); - // } - // - // @PostMapping("/detail/list") - // @ApiOperation("个税申报表详情列表") - // @WeaPermission - // public WeaResult> listTaxDeclarationDetail(@RequestBody TaxDeclarationDetailListQueryParam queryParam) { - // WeaTable weaTable = taxDeclarationDetailWrapper.listPage(queryParam, TenantContext.getCurrentTenantKey()); - // return WeaResult.success(weaTable); - // } - // + // private BaseBean logger = new BaseBean(); + + private TaxDeclarationService getService(User user) { + return (TaxDeclarationService) ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + } + + private TaxDeclarationWrapper getTaxDeclarationWrapper(User user) { + return ServiceUtil.getService(TaxDeclarationWrapper.class, user); + } + /* private TaxDeclarationDetailWrapper getTaxDeclarationDetailWrapper(User user) { + return ServiceUtil.getService(TaxDeclarationDetailWrapper.class, user); + }*/ + + + //个税申报表列表 + @POST + @Path("/listPage") + @Produces(MediaType.APPLICATION_JSON) + public String list(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxDeclarationListQueryParam queryParam) { + User user = HrmUserVarify.getUser(request, response); + queryParam.setFromSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getFromSalaryMonthStr())); + queryParam.setEndSalaryMonth(SalaryDateUtil.String2YearMonth(queryParam.getEndSalaryMonthStr())); + return new ResponseResult>().run(getTaxDeclarationWrapper(user)::listPage, queryParam); + } + + //个税申报表表单 + @GET + @Path("/getForm") + @Produces(MediaType.APPLICATION_JSON) + public String getForm(@Context HttpServletRequest request, @Context HttpServletResponse response, @QueryParam(value = "id") Long id) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult().run(getTaxDeclarationWrapper(user)::getForm, id); + } + //个税申报表相关信息 + @GET + @Path("/getTaxDeclarationInfo") + @Produces(MediaType.APPLICATION_JSON) + public String getTaxDeclarationInfo(@Context HttpServletRequest request, @Context HttpServletResponse response,@QueryParam(value = "taxDeclarationId") Long taxDeclarationId) { + User user = HrmUserVarify.getUser(request, response); + return new ResponseResult().run(getTaxDeclarationWrapper(user)::getTaxDeclarationInfoById, taxDeclarationId); + } + //个税申报表生成 + @POST + @Path("/save") + @Produces(MediaType.APPLICATION_JSON) + public String save(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxDeclarationSaveParam param) { + User user = HrmUserVarify.getUser(request, response); + param.setSalaryMonth(SalaryDateUtil.String2YearMonth(param.getSalaryMonthStr())); + return new ResponseResult().run(getTaxDeclarationWrapper(user)::save, param); + } + //个税申报表详情列表 + /* @GET + @Path("/detail/list") + @Produces(MediaType.APPLICATION_JSON) + public String listTaxDeclarationDetail(@Context HttpServletRequest request, @Context HttpServletResponse response,@RequestBody TaxDeclarationDetailListQueryParam param) { + User user = HrmUserVerify.getUser(request, response); + return new ResponseResult().run(getTaxDeclarationDetailWrapper(user)::listPage, param); + }*/ + // @PostMapping("/export") // @ApiOperation("个税申报表相关信息") // @WeaPermission diff --git a/src/com/engine/salary/wrapper/TaxDeclarationDetailWrapper.java b/src/com/engine/salary/wrapper/TaxDeclarationDetailWrapper.java new file mode 100644 index 000000000..0717444c8 --- /dev/null +++ b/src/com/engine/salary/wrapper/TaxDeclarationDetailWrapper.java @@ -0,0 +1,66 @@ +/* +package com.engine.salary.wrapper; + +import com.engine.core.impl.Service; +import com.engine.salary.entity.taxdeclaration.TaxDeclaration; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationDetailListDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationLaborListDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationDetailListQueryParam; +import com.engine.salary.enums.salarysob.IncomeCategoryEnum; +import com.engine.salary.service.TaxDeclarationDetailService; +import com.engine.salary.service.TaxDeclarationService; +import com.engine.salary.util.page.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.Objects; + +*/ +/** + * @description: 个税申报表明细 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/23/22 6:07 PM + * @version:v1.0 + *//* + +@Slf4j +@Component +public class TaxDeclarationDetailWrapper extends Service { + + @Resource + private TaxDeclarationService taxDeclarationService; + @Resource + private TaxDeclarationDetailService taxDeclarationDetailService; + + */ +/** + * 个税申报表明细列表 + * + * @param queryParam 列表查询条件 + * @return + *//* + + public PageInfo listPage(TaxDeclarationDetailListQueryParam queryParam) { + TaxDeclaration taxDeclaration = taxDeclarationService.getById(queryParam.getTaxDeclarationId()); + PageInfo dtoPage = new PageInfo(TaxDeclarationDetailListDTO.class); + dtoPage.setPageNum(queryParam.getCurrent()); + dtoPage.setPageSize(queryParam.getPageSize()); + // 正常工资薪金所得 + if (Objects.equals(taxDeclaration.getIncomeCategory(), IncomeCategoryEnum.WAGES_AND_SALARIES.getValue())) { + PageInfo taxDeclarationWageListDTOPageInfo = taxDeclarationDetailService.listDtoPageByParam4Wage(queryParam); + dtoPage.setList(taxDeclarationWageListDTOPageInfo.getList()); + //weaTable = SalaryFormatUtil.getInstance().buildTable(TaxDeclarationWageListDTO.class, dtoPage); + } + // 劳务报酬所得 + if (Objects.equals(taxDeclaration.getIncomeCategory(), IncomeCategoryEnum.REMUNERATION_FOR_LABOR.getValue())) { + PageInfo taxDeclarationLaborListDTOPageInfo = taxDeclarationDetailService.listDtoPageByParam4Labor(queryParam); + dtoPage.setList(taxDeclarationLaborListDTOPageInfo.getList()); + //weaTable = SalaryFormatUtil.getInstance().buildTable(TaxDeclarationLaborListDTO.class, dtoPage); + } + return dtoPage; + } +} +*/ diff --git a/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java b/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java new file mode 100644 index 000000000..0fea8f8dd --- /dev/null +++ b/src/com/engine/salary/wrapper/TaxDeclarationWrapper.java @@ -0,0 +1,286 @@ +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.biz.TaxAgentBiz; +import com.engine.salary.common.LocalDateRange; +import com.engine.salary.component.WeaFormOption; +import com.engine.salary.entity.datacollection.DataCollectionEmployee; +import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO; +import com.engine.salary.entity.salaryacct.po.SalaryAcctResultPO; +import com.engine.salary.entity.salaryitem.po.SalaryItemPO; +import com.engine.salary.entity.salarysob.po.SalarySobPO; +import com.engine.salary.entity.taxdeclaration.TaxDeclaration; +import com.engine.salary.entity.taxdeclaration.bo.TaxDeclarationBO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationFormDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationInfoDTO; +import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationListDTO; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationListQueryParam; +import com.engine.salary.entity.taxdeclaration.param.TaxDeclarationSaveParam; +import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationPO; +import com.engine.salary.entity.taxrate.TaxAgent; +import com.engine.salary.enums.salaryaccounting.SalaryAcctRecordStatusEnum; +import com.engine.salary.exception.SalaryRunTimeException; +import com.engine.salary.mapper.datacollection.AddUpSituationMapper; +import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper; +import com.engine.salary.mapper.taxdeclaration.TaxDeclarationMapper; +import com.engine.salary.service.*; +import com.engine.salary.service.impl.TaxAgentServiceImpl; +import com.engine.salary.service.impl.TaxDeclarationServiceImpl; +import com.engine.salary.util.SalaryDateUtil; +import com.engine.salary.util.SalaryEntityUtil; +import com.engine.salary.util.SalaryI18nUtil; +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.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import weaver.hrm.User; + +import javax.annotation.Resource; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @description: 个税申报表 + * @author: xiajun + * @modified By: xiajun + * @date: Created in 1/23/22 5:50 PM + * @version:v1.0 + */ +@Component +public class TaxDeclarationWrapper extends Service { + + private TaxDeclarationService getTaxDeclarationService(User user) { + return (TaxDeclarationService) ServiceUtil.getService(TaxDeclarationServiceImpl.class, user); + } + + private TaxAgentService getTaxAgentService(User user) { + return (TaxAgentService) ServiceUtil.getService(TaxAgentServiceImpl.class, user); + } + private TaxDeclarationMapper getTaxDeclarationMapper() { + return MapperProxyFactory.getProxy(TaxDeclarationMapper.class); + } + + private SalaryAcctRecordMapper getSalaryAcctRecordMapper() { + return MapperProxyFactory.getProxy(SalaryAcctRecordMapper.class); + } + + @Resource + private TaxAgentBiz taxAgentBiz; + @Resource + private SalaryItemBiz salaryItemBiz; + @Resource + private TaxDeclarationDetailService taxDeclarationDetailService; + @Resource + private SalaryAcctResultService salaryAcctResultService; + @Resource + private SalaryAcctRecordService salaryAcctRecordService; + @Resource + private AddUpSituationMapper addUpSituationMapper; + @Resource + private TaxDeclarationMapper taxDeclarationMapper; + @Resource + private SalarySobService salarySobService; + + /** + * 个税申报表列表 + * + * @param queryParam 列表查询条件 + * @param + * @return + */ + public PageInfo listPage(TaxDeclarationListQueryParam queryParam) { + EmployBiz employBiz = new EmployBiz(); + // 询个税申报表(分页) + PageInfo page = getTaxDeclarationService(user).listPageByParam(queryParam); + PageInfo dtoPage = new PageInfo(TaxDeclarationListDTO.class); + dtoPage.setPageNum(queryParam.getCurrent()); + dtoPage.setPageSize(queryParam.getPageSize()); + List list = page.getList(); + if (CollectionUtils.isNotEmpty(list)) { + // 查询人员 + List employeeIds = SalaryEntityUtil.properties(list, TaxDeclarationPO::getCreator, Collectors.toList()); + List employeeComInfos = employBiz.getEmployeeByIdsAll(employeeIds); + // 查询个税扣缴义务人 + Set taxAgentIds = SalaryEntityUtil.properties(list, TaxDeclarationPO::getTaxAgentId); + List taxAgentPOS = taxAgentBiz.listByIds(taxAgentIds); + //List taxAgentPOS = getTaxDeclarationService(user).countByTaxDeclarationId(taxAgentIds); + // 转换成列表dto + List taxDeclarationListDTOS = TaxDeclarationBO.convert2ListDTO(list, employeeComInfos, taxAgentPOS); + dtoPage.setList(taxDeclarationListDTOS); + } + return dtoPage; + } + + + public TaxDeclarationFormDTO getForm(Long id) { + TaxDeclarationFormDTO formDTO = new TaxDeclarationFormDTO(); + if (Objects.nonNull(id)) { + // 查询个税申报表 + TaxDeclaration taxDeclaration = getTaxDeclarationService(user).getById(id); + if (Objects.isNull(taxDeclaration)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98877, "个税申报表不存在或已删除")); + } + // 查询个税扣缴义务人 + TaxAgent taxAgent = taxAgentBiz.getById(id); + // 转换成个税申报表详情dto + formDTO = TaxDeclarationFormDTO.builder() + .salaryMonth(SalaryDateUtil.localDate2YearMonth(taxDeclaration.getSalaryMonth())) + .taxAgentId(taxDeclaration.getTaxAgentId()) + .taxAgentName(Optional.ofNullable(taxAgent).map(TaxAgent::getName).orElse("")) + .description(taxDeclaration.getDescription()) + .build(); + } + // 转换成前端所需的数据格式 + // WeaForm weaForm = SalaryFormatUtil.getInstance().buildForm(TaxDeclarationFormDTO.class, formDTO); + + // 查询租户所有的个税扣缴义务人 + Collection taxAgentListDTOS = taxAgentBiz.listAll(); + // 表单中个税扣缴义务人的可选项 + List weaFormOptions = Lists.newArrayListWithExpectedSize(taxAgentListDTOS.size()); + for (TaxAgent taxAgent : taxAgentListDTOS) { + weaFormOptions.add(new WeaFormOption("" + taxAgent.getId(), taxAgent.getName())); + } +// weaForm.getItems().forEach((k, v) -> { +// if (StringUtils.equals("taxAgentId", k)) { +// v.setOptions(weaFormOptions); +// } +// if (StringUtils.equals("salaryMonth", k)) { +// Map otherParams = new HashMap<>(); +// otherParams.put("type", "month"); +// v.setOtherParams(otherParams); +// } +// }); + return formDTO; + } + /* + *//** + * 查询个税申报表的基本信息 + * + * @param id 个税申报表id + * @return + */ + public TaxDeclarationInfoDTO getTaxDeclarationInfoById(Long id) { + // 查询个税申报表 + //TaxDeclarationPO taxDeclarationPO = getTaxDeclarationService(user).getById(id); + TaxDeclaration taxDeclaration = getTaxDeclarationService(user).getById(id); + if (Objects.isNull(taxDeclaration)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98877, "个税申报表不存在或已删除")); + } + // 查询个税扣缴义务人 + TaxAgent taxAgentPO = taxAgentBiz.getById(taxDeclaration.getTaxAgentId()); + return TaxDeclarationInfoDTO.builder() + .salaryMonth(SalaryDateUtil.localDate2YearMonth(taxDeclaration.getSalaryMonth())) + .taxAgentId(taxDeclaration.getTaxAgentId()) + .taxAgentName(Optional.ofNullable(taxAgentPO).map(TaxAgent::getName).orElse("")) + .build(); + } + /* + *//** + * 保存 + * + * @param saveParam 保存参数 + */ + @Transactional(rollbackFor = Exception.class) + public void save(TaxDeclarationSaveParam saveParam) { + //getTaxDeclarationService(user).save(saveParam); + EmployBiz employBiz = new EmployBiz(); + // 薪资所属月的日期范围 + LocalDateRange salaryMonthDateRange = SalaryDateUtil.localDate2YearRange(SalaryDateUtil.localDateToDate(saveParam.getSalaryMonth().atDay(1))); + if (Objects.isNull(salaryMonthDateRange)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(84026, "参数错误")); + } + // 查询薪资所属月已经生成过的个税申报表 + List taxDeclarationPOS = listBySalaryMonthTax(salaryMonthDateRange); + // 已经生成过个税申报表,不允许再次生成个税申报表 + if (CollectionUtils.isNotEmpty(taxDeclarationPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98873, "{0}已经生成过个税申报表,不允许再次生成") + .replace("{0}", saveParam.getSalaryMonth().toString())); + } + // 查询薪资所属月的薪资核算记录 + List salaryAcctRecordPOS = listBySalaryMonth(salaryMonthDateRange); + // 无薪资核算记录,不允许生成个税申报表 + 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 salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getId); + List salaryAcctResultPOS = salaryAcctResultService.listBySalaryAcctRecordIds(salaryAcctRecordIds); + // 无薪资核算结果,不允许生成个税申报表 + if (CollectionUtils.isEmpty(salaryAcctResultPOS)) { + throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据") + .replace("{0}", saveParam.getSalaryMonth().toString())); + } + // 查询薪资账套 + Set salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId); + List salarySobPOS = salarySobService.listByIds(salarySobIds); + + //查询DataCollectionEmployee + //DataCollectionEmployee employeeId = + + // 查询所有薪资项目 + List salaryItemPOS = salaryItemBiz.listAll(); + // 处理要保存的数据 + TaxDeclarationBO.Result result = TaxDeclarationBO.handle(saveParam, taxCycle, salaryItemPOS, salarySobPOS,salaryAcctResultPOS); + // 保存个税申报表 + if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarations())) { + + taxDeclarationMapper.batchInsert(result.getNeedInsertTaxDeclarations()); + } + // 保存个税申报表明细 + if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxDeclarationDetails())) { + + taxDeclarationDetailService.batchSave(result.getNeedInsertTaxDeclarationDetails()); + } + // 保存累计情况 + if (CollectionUtils.isNotEmpty(result.getNeedInsertAccumulatedSituations())) { + // TODO: 1/23/22 待修改(不能直接调用mapper) + // addUpSituationMapper.insertData(Lists.newArrayList(result.getNeedInsertAccumulatedSituations())); + } + // 更新薪资核算记录的状态 + salaryAcctRecordService.updateStatusByIds(salaryAcctRecordIds, SalaryAcctRecordStatusEnum.DECLARED); + // 查询个税扣缴义务人 + Set taxAgentIds = SalaryEntityUtil.properties(result.getNeedInsertTaxDeclarations(), TaxDeclarationPO::getTaxAgentId); + List taxAgentPOS = taxAgentBiz.listByIds(taxAgentIds); + Map 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 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 listBySalaryMonthTax(LocalDateRange salaryMonthDateRange) { + return getTaxDeclarationMapper().listSome(TaxDeclarationPO.builder().salaryMonths(salaryMonthDateRange).build()); + } + + public List listBySalaryMonth(LocalDateRange salaryMonthDateRange) { + return getSalaryAcctRecordMapper().listSome(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).build()); + } + +}