2023-08-14 20:07:29 +08:00
|
|
|
|
package com.engine.salary.entity.taxdeclaration.bo;
|
|
|
|
|
|
|
|
|
|
|
|
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.employeedeclare.CardTypeEnum;
|
|
|
|
|
|
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
|
|
|
|
|
|
import com.engine.salary.report.enums.IncomeCategoryEnum;
|
|
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-08-23 16:49:45 +08:00
|
|
|
|
* 个税申报
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2023</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
2023-08-14 20:07:29 +08:00
|
|
|
|
public class TaxDeclarationRequest {
|
|
|
|
|
|
|
|
|
|
|
|
public static Map<String, Object> convert2RequestParam(List<TaxReportColumnPO> taxReportColumns,
|
|
|
|
|
|
List<TaxDeclarationPO> taxDeclarations,
|
|
|
|
|
|
List<TaxDeclarationValuePO> taxDeclarationValues,
|
|
|
|
|
|
List<EmployeeDeclarePO> employeeDeclares) {
|
|
|
|
|
|
Map<String, Map<String, Object>> objRequestParam = Maps.newHashMap();
|
|
|
|
|
|
Map<String, List<Map<String, Object>>> listRequestParam = Maps.newHashMap();
|
|
|
|
|
|
Map<String, List<TaxReportColumnPO>> taxReportColumnMap = SalaryEntityUtil.group2Map(taxReportColumns, TaxReportColumnPO::getIncomeCategory);
|
|
|
|
|
|
Map<Long, EmployeeDeclarePO> employeeDeclareMap = SalaryEntityUtil.convert2Map(employeeDeclares, EmployeeDeclarePO::getEmployeeId);
|
|
|
|
|
|
Map<Long, List<TaxDeclarationValuePO>> taxDeclarationValueMap = SalaryEntityUtil.group2Map(taxDeclarationValues, TaxDeclarationValuePO::getTaxDeclarationId);
|
|
|
|
|
|
for (TaxDeclarationPO taxDeclaration : taxDeclarations) {
|
|
|
|
|
|
List<TaxDeclarationValuePO> values = taxDeclarationValueMap.get(taxDeclaration.getId());
|
|
|
|
|
|
for (TaxDeclarationValuePO taxDeclarationValue : values) {
|
|
|
|
|
|
EmployeeDeclarePO employeeDeclare = employeeDeclareMap.get(taxDeclarationValue.getEmployeeId());
|
|
|
|
|
|
IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByValue(taxDeclaration.getIncomeCategory());
|
|
|
|
|
|
if (employeeDeclare == null || incomeCategoryEnum == null) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
List<TaxReportColumnPO> taxReportColumnList = taxReportColumnMap.get(Util.null2String(incomeCategoryEnum.getValue()));
|
|
|
|
|
|
Map<String, Object> employeeRequestParam = convert2RequestParam(incomeCategoryEnum, taxReportColumnList, taxDeclarationValue, employeeDeclare);
|
|
|
|
|
|
if (incomeCategoryEnum == IncomeCategoryEnum.WAGES_AND_SALARIES) {
|
|
|
|
|
|
Map<String, Object> paramMap = objRequestParam.computeIfAbsent("zcgzxj", k -> {
|
|
|
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
|
|
|
// 正常工资薪金列表
|
|
|
|
|
|
param.put("zcgzxjlb", Lists.newArrayList());
|
|
|
|
|
|
// 正常工资薪金是否需要专项
|
|
|
|
|
|
param.put("zcgzxjsfxyzx", 0);
|
|
|
|
|
|
// 正常工资薪金是否传入专项累计
|
|
|
|
|
|
param.put("zcgzxjsfcrlj", 1);
|
|
|
|
|
|
return param;
|
|
|
|
|
|
});
|
|
|
|
|
|
List<Map<String, Object>> employeeRequestParams = (List<Map<String, Object>>) paramMap.computeIfAbsent("zcgzxjlb", K -> Lists.newArrayList());
|
|
|
|
|
|
employeeRequestParams.add(employeeRequestParam);
|
|
|
|
|
|
} else if (incomeCategoryEnum == IncomeCategoryEnum.ONETIME_ANNUAL_BONUS) {
|
|
|
|
|
|
// 全年一次性奖金收入
|
|
|
|
|
|
List<Map<String, Object>> employeeRequestParams = listRequestParam.computeIfAbsent("qnycxjjsslb", k -> Lists.newArrayList());
|
|
|
|
|
|
employeeRequestParams.add(employeeRequestParam);
|
|
|
|
|
|
} else if (incomeCategoryEnum == IncomeCategoryEnum.COMPENSATION_FOR_RETIRE) {
|
|
|
|
|
|
// 内退一次性补偿金
|
|
|
|
|
|
List<Map<String, Object>> employeeRequestParams = listRequestParam.computeIfAbsent("ntycxbcjlb", k -> Lists.newArrayList());
|
|
|
|
|
|
employeeRequestParams.add(employeeRequestParam);
|
|
|
|
|
|
} else if (incomeCategoryEnum == IncomeCategoryEnum.COMPENSATION_FOR_DISMISS) {
|
|
|
|
|
|
// 解除劳动合同一次性补偿金
|
|
|
|
|
|
List<Map<String, Object>> employeeRequestParams = listRequestParam.computeIfAbsent("jcldhtycxbcjlb", k -> Lists.newArrayList());
|
|
|
|
|
|
employeeRequestParams.add(employeeRequestParam);
|
|
|
|
|
|
} else if (incomeCategoryEnum == IncomeCategoryEnum.INCOME_FOR_INDIVIDUAL_EQUITY_INCENTIVE) {
|
|
|
|
|
|
// 个人股权激励收入
|
|
|
|
|
|
List<Map<String, Object>> employeeRequestParams = listRequestParam.computeIfAbsent("grgqjl", k -> Lists.newArrayList());
|
|
|
|
|
|
employeeRequestParams.add(employeeRequestParam);
|
|
|
|
|
|
} else if (incomeCategoryEnum == IncomeCategoryEnum.ANNUITY_RECEIPT) {
|
|
|
|
|
|
// 处理"是否一次性领取"(接口只能传0和1但是接口的错误返回信息告知只能填写是和否,所以需要转一下)
|
|
|
|
|
|
String sfycxlq = Util.null2String(employeeRequestParam.get("sfycxlq"));
|
|
|
|
|
|
employeeRequestParam.put("sfycxlq", Objects.equals("是", sfycxlq) ? "1" : "0");
|
|
|
|
|
|
// 年金领取
|
|
|
|
|
|
List<Map<String, Object>> employeeRequestParams = listRequestParam.computeIfAbsent("qynj", k -> Lists.newArrayList());
|
|
|
|
|
|
employeeRequestParams.add(employeeRequestParam);
|
|
|
|
|
|
} else if (incomeCategoryEnum == IncomeCategoryEnum.REMUNERATION_FOR_LABOR) {
|
|
|
|
|
|
// 一般劳务报酬所得
|
|
|
|
|
|
List<Map<String, Object>> employeeRequestParams = listRequestParam.computeIfAbsent("lwbclb", k -> Lists.newArrayList());
|
|
|
|
|
|
employeeRequestParams.add(employeeRequestParam);
|
|
|
|
|
|
} else if (incomeCategoryEnum == IncomeCategoryEnum.INCOME_FOR_INSURANCE_SALESMAN) {
|
|
|
|
|
|
// 保险营销员佣金收入
|
|
|
|
|
|
Map<String, Object> paramMap = objRequestParam.computeIfAbsent("bxyxy", k -> {
|
|
|
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
|
|
|
param.put("bxyxylwbclb", Lists.newArrayList());
|
|
|
|
|
|
return param;
|
|
|
|
|
|
});
|
|
|
|
|
|
List<Map<String, Object>> employeeRequestParams = (List<Map<String, Object>>) paramMap.computeIfAbsent("bxyxylwbclb", k -> Lists.newArrayList());
|
|
|
|
|
|
employeeRequestParams.add(employeeRequestParam);
|
|
|
|
|
|
} else if (incomeCategoryEnum == IncomeCategoryEnum.INCOME_FOR_SECURITIES_BROKER) {
|
|
|
|
|
|
// 证券经纪人佣金收入
|
|
|
|
|
|
Map<String, Object> paramMap = objRequestParam.computeIfAbsent("zqjjr", k -> {
|
|
|
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
|
|
|
param.put("zqjjrsdlb", Lists.newArrayList());
|
|
|
|
|
|
return param;
|
|
|
|
|
|
});
|
|
|
|
|
|
List<Map<String, Object>> employeeRequestParams = (List<Map<String, Object>>) paramMap.computeIfAbsent("zqjjrsdlb", k -> Lists.newArrayList());
|
|
|
|
|
|
employeeRequestParams.add(employeeRequestParam);
|
|
|
|
|
|
} else if (incomeCategoryEnum == IncomeCategoryEnum.REMUNERATION_FOR_OTHER_CONTINUOUS_LABOR) {
|
|
|
|
|
|
// 其他连续劳务报酬所得
|
|
|
|
|
|
Map<String, Object> paramMap = objRequestParam.computeIfAbsent("qtlxlwbc", k -> {
|
|
|
|
|
|
Map<String, Object> param = new HashMap<>();
|
|
|
|
|
|
param.put("qtlxlwbclb", Lists.newArrayList());
|
|
|
|
|
|
return param;
|
|
|
|
|
|
});
|
|
|
|
|
|
List<Map<String, Object>> employeeRequestParams = (List<Map<String, Object>>) paramMap.computeIfAbsent("qtlxlwbclb", k -> Lists.newArrayList());
|
|
|
|
|
|
employeeRequestParams.add(employeeRequestParam);
|
|
|
|
|
|
} else if (incomeCategoryEnum == IncomeCategoryEnum.REMUNERATION_FOR_OTHER_LABOR) {
|
|
|
|
|
|
// 其他非连续劳务报酬所得
|
|
|
|
|
|
List<Map<String, Object>> employeeRequestParams = listRequestParam.computeIfAbsent("qtflxlwbc", k -> Lists.newArrayList());
|
|
|
|
|
|
employeeRequestParams.add(employeeRequestParam);
|
|
|
|
|
|
} else if (incomeCategoryEnum == IncomeCategoryEnum.REMUNERATION_FOR_AUTHOR) {
|
|
|
|
|
|
// 稿酬所得
|
|
|
|
|
|
List<Map<String, Object>> employeeRequestParams = listRequestParam.computeIfAbsent("gcsdlb", k -> Lists.newArrayList());
|
|
|
|
|
|
employeeRequestParams.add(employeeRequestParam);
|
|
|
|
|
|
} else if (incomeCategoryEnum == IncomeCategoryEnum.ROYALTIES) {
|
|
|
|
|
|
// 特许权使用费所得
|
|
|
|
|
|
List<Map<String, Object>> employeeRequestParams = listRequestParam.computeIfAbsent("txq", k -> Lists.newArrayList());
|
|
|
|
|
|
employeeRequestParams.add(employeeRequestParam);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> requestParam = Maps.newHashMap();
|
|
|
|
|
|
requestParam.putAll(objRequestParam);
|
|
|
|
|
|
requestParam.putAll(listRequestParam);
|
|
|
|
|
|
return requestParam;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static Map<String, Object> convert2RequestParam(IncomeCategoryEnum incomeCategoryEnum,
|
|
|
|
|
|
List<TaxReportColumnPO> taxReportColumns,
|
|
|
|
|
|
TaxDeclarationValuePO taxDeclarationValue,
|
|
|
|
|
|
EmployeeDeclarePO employeeDeclare) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(taxReportColumns)) {
|
|
|
|
|
|
return Collections.emptyMap();
|
|
|
|
|
|
}
|
|
|
|
|
|
Map<String, Object> requestParam = Maps.newHashMap();
|
|
|
|
|
|
// 姓名
|
|
|
|
|
|
requestParam.put("xm", employeeDeclare.getEmployeeName());
|
|
|
|
|
|
// 证件类型
|
|
|
|
|
|
requestParam.put("zzlx", CardTypeEnum.RESIDENT_IDENTITY_CARDS.getDefaultLabel());
|
|
|
|
|
|
// 证件号码
|
|
|
|
|
|
requestParam.put("zzhm", employeeDeclare.getCardNum());
|
|
|
|
|
|
// 所得项目
|
|
|
|
|
|
requestParam.put("sdxm", incomeCategoryEnum.getDefaultLabel());
|
|
|
|
|
|
for (TaxReportColumnPO taxReportColumn : taxReportColumns) {
|
|
|
|
|
|
String value = taxDeclarationValue.getResultValue().getOrDefault(taxReportColumn.getReportColumnDataIndex(), StringUtils.EMPTY);
|
|
|
|
|
|
if (Objects.equals(taxReportColumn.getDataType(), SalaryDataTypeEnum.NUMBER.getValue())) {
|
|
|
|
|
|
value = SalaryEntityUtil.string2BigDecimalDefault0(taxDeclarationValue.getResultValue().get(taxReportColumn.getReportColumnDataIndex())).toPlainString();
|
|
|
|
|
|
} else if (Objects.equals(taxReportColumn.getDataType(), "integer")) {
|
|
|
|
|
|
value = SalaryEntityUtil.string2BigDecimalDefault0(taxDeclarationValue.getResultValue().get(taxReportColumn.getReportColumnDataIndex())).setScale(0, RoundingMode.HALF_UP).toPlainString();
|
|
|
|
|
|
}
|
|
|
|
|
|
requestParam.put(taxReportColumn.getRequestParamKey(), value);
|
|
|
|
|
|
}
|
|
|
|
|
|
return requestParam;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|