Merge branch 'release/个税版本' into release/个税&业务线
This commit is contained in:
commit
9d03aaffdc
|
|
@ -1,5 +1,7 @@
|
|||
package com.engine.salary.entity.taxdeclaration.bo;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.engine.salary.annotation.SalaryFormulaVar;
|
||||
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
||||
import com.engine.salary.entity.datacollection.AddUpSituation;
|
||||
|
|
@ -20,7 +22,6 @@ import com.engine.salary.util.SalaryEntityUtil;
|
|||
import com.engine.salary.util.db.IdGenerator;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -49,29 +50,116 @@ public class TaxDeclarationCommon implements TaxDeclarationStrategy {
|
|||
|
||||
List<TaxDeclarationValuePO> taxDeclarationValues = Lists.newArrayListWithExpectedSize(employeeIdKeyMap.size());
|
||||
for (Map.Entry<Long, List<SalaryAcctEmployeePO>> employeeIdEntry : employeeIdKeyMap.entrySet()) {
|
||||
// 取最后一次薪资核算记录的核算结果作为个税申报表的数据来源
|
||||
SalaryAcctEmployeePO lastSalaryAcctEmployee = SalaryEntityUtil.findFirst(employeeIdEntry.getValue());
|
||||
for (SalaryAcctEmployeePO salaryAcctEmployee : employeeIdEntry.getValue()) {
|
||||
SalaryAcctRecordPO salaryAcctRecord = taxDeclareContext.getSalaryAcctRecordMap().get(salaryAcctEmployee.getSalaryAcctRecordId());
|
||||
SalaryAcctRecordPO lastSalaryAcctRecord = taxDeclareContext.getSalaryAcctRecordMap().get(lastSalaryAcctEmployee.getSalaryAcctRecordId());
|
||||
if (salaryAcctRecord.getCreateTime().compareTo(lastSalaryAcctRecord.getCreateTime()) > 0) {
|
||||
lastSalaryAcctEmployee = salaryAcctEmployee;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, String> valueMap = Maps.newHashMap();
|
||||
for (TaxReportColumnPO taxReportColumn : taxDeclareContext.getTaxReportColumns()) {
|
||||
SalarySobTaxReportRulePO salarySobTaxReportRule = taxDeclareContext.getSalarySobTaxReportRuleMap()
|
||||
.get(lastSalaryAcctEmployee.getSalarySobId() + "-" + taxReportColumn.getReportColumnDataIndex());
|
||||
List<SalaryAcctResultPO> salaryAcctResultValue = salaryAcctResultValueMap.get(lastSalaryAcctEmployee.getId());
|
||||
String value = "";
|
||||
if (salarySobTaxReportRule != null && salaryAcctResultValue != null) {
|
||||
value = salaryAcctResultValue.stream()
|
||||
.filter(result -> result.getSalaryItemId().equals(salarySobTaxReportRule.getSalaryItemId()))
|
||||
.findFirst()
|
||||
.orElse(new SalaryAcctResultPO())
|
||||
.getResultValue();
|
||||
|
||||
List<String> firstValueList = Lists.newArrayList(
|
||||
"taxFreeIncome",
|
||||
"endowmentInsurance",
|
||||
"medicalInsurance",
|
||||
"unemploymentInsurance",
|
||||
"housingProvidentFund",
|
||||
"addUpChildEducation",
|
||||
"addUpHousingLoanInterest",
|
||||
"addUpHousingRent",
|
||||
"addUpSupportElderly",
|
||||
"addUpContinuingEducation",
|
||||
"addUpInfantCare",
|
||||
"annuity",
|
||||
"commercialHealthInsurance",
|
||||
"taxDeferredEndowmentInsurance",
|
||||
"other",
|
||||
"allowedDonation",
|
||||
"taxDeduction",
|
||||
"description",
|
||||
"addUpAdvanceTax");
|
||||
|
||||
List<String> lastValueList = Lists.newArrayList(
|
||||
"addUpIncome",
|
||||
"addUpTaxFreeIncome",
|
||||
"addUpSubtraction",
|
||||
"addUpSpecialDeduction",
|
||||
"addUpOtherDeduction",
|
||||
"addUpAllowedDonation",
|
||||
"addUpTaxableIncome",
|
||||
"taxRate",
|
||||
"quickDeductionFactor",
|
||||
"addUpTaxPayable",
|
||||
"addUpTaxDeduction"
|
||||
);
|
||||
|
||||
List<String> mergeValueList = Lists.newArrayList(
|
||||
"income",
|
||||
"refundedOrSupplementedTax"
|
||||
);
|
||||
|
||||
//取第一次值
|
||||
if (firstValueList.contains(taxReportColumn.getReportColumnDataIndex())) {
|
||||
SalaryAcctEmployeePO lastSalaryAcctEmployee = SalaryEntityUtil.findFirst(employeeIdEntry.getValue());
|
||||
for (SalaryAcctEmployeePO salaryAcctEmployee : employeeIdEntry.getValue()) {
|
||||
SalaryAcctRecordPO salaryAcctRecord = taxDeclareContext.getSalaryAcctRecordMap().get(salaryAcctEmployee.getSalaryAcctRecordId());
|
||||
SalaryAcctRecordPO lastSalaryAcctRecord = taxDeclareContext.getSalaryAcctRecordMap().get(lastSalaryAcctEmployee.getSalaryAcctRecordId());
|
||||
if (salaryAcctRecord.getCreateTime().compareTo(lastSalaryAcctRecord.getCreateTime()) < 0) {
|
||||
lastSalaryAcctEmployee = salaryAcctEmployee;
|
||||
}
|
||||
}
|
||||
SalarySobTaxReportRulePO salarySobTaxReportRule = taxDeclareContext.getSalarySobTaxReportRuleMap()
|
||||
.get(lastSalaryAcctEmployee.getSalarySobId() + "-" + taxReportColumn.getReportColumnDataIndex());
|
||||
List<SalaryAcctResultPO> salaryAcctResultValue = salaryAcctResultValueMap.get(lastSalaryAcctEmployee.getId());
|
||||
if (salarySobTaxReportRule != null && salaryAcctResultValue != null) {
|
||||
value = salaryAcctResultValue.stream()
|
||||
.filter(result -> result.getSalaryItemId().equals(salarySobTaxReportRule.getSalaryItemId()))
|
||||
.findFirst()
|
||||
.orElse(new SalaryAcctResultPO())
|
||||
.getResultValue();
|
||||
}
|
||||
value = StrUtil.isNotBlank(value) ? value : Objects.equals(taxReportColumn.getDataType(), SalaryDataTypeEnum.NUMBER.getValue()) ? "0.00" : "";
|
||||
}
|
||||
//取多次累计值
|
||||
else if (mergeValueList.contains(taxReportColumn.getReportColumnDataIndex()) && Objects.equals(taxReportColumn.getDataType(), SalaryDataTypeEnum.NUMBER.getValue())) {
|
||||
List<SalaryAcctEmployeePO> employeePOS = employeeIdEntry.getValue();
|
||||
BigDecimal income = new BigDecimal("0.00");
|
||||
for (SalaryAcctEmployeePO salaryAcctEmployeePO : employeePOS) {
|
||||
SalarySobTaxReportRulePO incomeRule = taxDeclareContext.getSalarySobTaxReportRuleMap()
|
||||
.get(salaryAcctEmployeePO.getSalarySobId() + "-" + taxReportColumn.getReportColumnDataIndex());
|
||||
List<SalaryAcctResultPO> salaryAcctResultValue = salaryAcctResultValueMap.get(salaryAcctEmployeePO.getId());
|
||||
if (incomeRule != null && salaryAcctResultValue != null) {
|
||||
String incomeValue = salaryAcctResultValue.stream()
|
||||
.filter(result -> result.getSalaryItemId().equals(incomeRule.getSalaryItemId()))
|
||||
.findFirst()
|
||||
.orElse(new SalaryAcctResultPO())
|
||||
.getResultValue();
|
||||
if (StrUtil.isNotBlank(incomeValue) && NumberUtil.isNumber(incomeValue)) {
|
||||
income = income.add(new BigDecimal(incomeValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
value = income.toPlainString();
|
||||
}
|
||||
//取最后一次值
|
||||
else {
|
||||
SalaryAcctEmployeePO lastSalaryAcctEmployee = SalaryEntityUtil.findFirst(employeeIdEntry.getValue());
|
||||
for (SalaryAcctEmployeePO salaryAcctEmployee : employeeIdEntry.getValue()) {
|
||||
SalaryAcctRecordPO salaryAcctRecord = taxDeclareContext.getSalaryAcctRecordMap().get(salaryAcctEmployee.getSalaryAcctRecordId());
|
||||
SalaryAcctRecordPO lastSalaryAcctRecord = taxDeclareContext.getSalaryAcctRecordMap().get(lastSalaryAcctEmployee.getSalaryAcctRecordId());
|
||||
if (salaryAcctRecord.getCreateTime().compareTo(lastSalaryAcctRecord.getCreateTime()) > 0) {
|
||||
lastSalaryAcctEmployee = salaryAcctEmployee;
|
||||
}
|
||||
}
|
||||
SalarySobTaxReportRulePO salarySobTaxReportRule = taxDeclareContext.getSalarySobTaxReportRuleMap()
|
||||
.get(lastSalaryAcctEmployee.getSalarySobId() + "-" + taxReportColumn.getReportColumnDataIndex());
|
||||
List<SalaryAcctResultPO> salaryAcctResultValue = salaryAcctResultValueMap.get(lastSalaryAcctEmployee.getId());
|
||||
if (salarySobTaxReportRule != null && salaryAcctResultValue != null) {
|
||||
value = salaryAcctResultValue.stream()
|
||||
.filter(result -> result.getSalaryItemId().equals(salarySobTaxReportRule.getSalaryItemId()))
|
||||
.findFirst()
|
||||
.orElse(new SalaryAcctResultPO())
|
||||
.getResultValue();
|
||||
}
|
||||
value = StrUtil.isNotBlank(value) ? value : Objects.equals(taxReportColumn.getDataType(), SalaryDataTypeEnum.NUMBER.getValue()) ? "0.00" : "";
|
||||
}
|
||||
value = StringUtils.isNotBlank(value) ? value : Objects.equals(taxReportColumn.getDataType(), SalaryDataTypeEnum.NUMBER.getValue()) ? "0.00" : "";
|
||||
valueMap.put(taxReportColumn.getReportColumnDataIndex(), value);
|
||||
}
|
||||
TaxDeclarationValuePO taxDeclarationValue = TaxDeclarationValuePO.builder()
|
||||
|
|
|
|||
Loading…
Reference in New Issue