144 lines
11 KiB
Java
144 lines
11 KiB
Java
|
|
package com.engine.salary.entity.taxdeclaration.bo;
|
|||
|
|
|
|||
|
|
import com.engine.salary.constant.TaxDeclarationDataIndexConstant;
|
|||
|
|
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
|||
|
|
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationEmployeeDTO;
|
|||
|
|
import com.engine.salary.entity.taxdeclaration.dto.TaxDeclarationWageListDTO;
|
|||
|
|
import com.engine.salary.entity.taxdeclaration.po.TaxDeclarationDetailPO;
|
|||
|
|
import com.engine.salary.enums.salaryaccounting.EmployeeTypeEnum;
|
|||
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|||
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
|||
|
|
import com.google.common.collect.Lists;
|
|||
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|||
|
|
import org.apache.commons.lang3.StringUtils;
|
|||
|
|
|
|||
|
|
import java.util.*;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @description: 个税申报表详情
|
|||
|
|
* @author: xiajun
|
|||
|
|
* @modified By: xiajun
|
|||
|
|
* @date: 2022/3/14 18:31
|
|||
|
|
* @version:v1.0
|
|||
|
|
*/
|
|||
|
|
public class TaxDeclarationDetailBO {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 转换成个税申报表详情列表(正常工资薪金所得)
|
|||
|
|
*
|
|||
|
|
* @param taxDeclarationDetailPOS
|
|||
|
|
* @param simpleEmployees
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
public static List<TaxDeclarationWageListDTO> convert2ListDTO4Wage(List<TaxDeclarationDetailPO> taxDeclarationDetailPOS,
|
|||
|
|
List<TaxDeclarationEmployeeDTO> taxDeclarationEmployeeDTOS,
|
|||
|
|
List<DataCollectionEmployee> simpleEmployees) {
|
|||
|
|
if (CollectionUtils.isEmpty(taxDeclarationDetailPOS)) {
|
|||
|
|
return Collections.emptyList();
|
|||
|
|
}
|
|||
|
|
List<TaxDeclarationWageListDTO> taxDeclarationWageListDTOS = Lists.newArrayListWithExpectedSize(taxDeclarationEmployeeDTOS.size());
|
|||
|
|
Map<String, List<TaxDeclarationDetailPO>> employeeIdKeyTaxDeclarationDetailPOMap = SalaryEntityUtil.group2Map(taxDeclarationDetailPOS,
|
|||
|
|
taxDeclarationDetailPO -> EmployeeTypeEnum.ORGANIZATION.getValue() + "_" + taxDeclarationDetailPO.getEmployeeId());
|
|||
|
|
Map<Long, DataCollectionEmployee> simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId);
|
|||
|
|
for (TaxDeclarationEmployeeDTO dto : taxDeclarationEmployeeDTOS) {
|
|||
|
|
Map<String, String> fieldCodeKeyFieldValueMap = SalaryEntityUtil.convert2Map(employeeIdKeyTaxDeclarationDetailPOMap.get(dto.getEmployeeType() + "_" + dto.getEmployeeId()),
|
|||
|
|
TaxDeclarationDetailPO::getFieldCode, TaxDeclarationDetailPO::getFieldValue);
|
|||
|
|
TaxDeclarationWageListDTO taxDeclarationWageListDTO = new TaxDeclarationWageListDTO()
|
|||
|
|
.setCardType(SalaryI18nUtil.getI18nLabel(105564, "居民身份证"))
|
|||
|
|
.setIncome(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.INCOME))
|
|||
|
|
.setTaxFreeIncome(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_FREE_INCOME))
|
|||
|
|
.setEndowmentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ENDOWMENT_INSURANCE))
|
|||
|
|
.setMedicalInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.MEDICAL_INSURANCE))
|
|||
|
|
.setUnemploymentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.UNEMPLOYMENT_INSURANCE))
|
|||
|
|
.setHousingProvidentFund(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.HOUSING_PROVIDENT_FUND))
|
|||
|
|
.setAddUpChildEducation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_CHILD_EDUCATION))
|
|||
|
|
.setAddUpHousingLoanInterest(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_LOAN_INTEREST))
|
|||
|
|
.setAddUpHousingRent(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_HOUSING_RENT))
|
|||
|
|
.setAddUpContinuingEducation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_CONTINUING_EDUCATION))
|
|||
|
|
.setAddUpSupportElderly(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_SUPPORT_ELDERLY))
|
|||
|
|
.setAddUpIllnessMedical(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_ILLNESS_MEDICAL))
|
|||
|
|
.setAddUpInfantCare(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ADD_UP_INFANT_CARE))
|
|||
|
|
.setAnnuity(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ANNUITY))
|
|||
|
|
.setCommercialHealthInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.COMMERCIAL_HEALTH_INSURANCE))
|
|||
|
|
.setTaxDeferredEndowmentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_DEFERRED_ENDOWMENT_INSURANCE))
|
|||
|
|
.setOther(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.OTHER))
|
|||
|
|
.setAllowedDonation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ALLOWED_DONATION))
|
|||
|
|
.setTaxDeduction(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_DEDUCTION))
|
|||
|
|
.setDescription(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.DESCRIPTION));
|
|||
|
|
if (dto.getEmployeeType() == null || Objects.equals(dto.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())) {
|
|||
|
|
DataCollectionEmployee simpleEmployee = simpleEmployeeMap.get(dto.getEmployeeId());
|
|||
|
|
taxDeclarationWageListDTO.setId(simpleEmployee.getEmployeeId())
|
|||
|
|
.setEmployeeId(simpleEmployee.getEmployeeId())
|
|||
|
|
.setJobNum(simpleEmployee.getWorkcode())
|
|||
|
|
.setUsername(simpleEmployee.getUsername())
|
|||
|
|
.setCardNum(Optional.ofNullable(simpleEmployee).map(DataCollectionEmployee::getIdNo).orElse(StringUtils.EMPTY));
|
|||
|
|
} else {
|
|||
|
|
// ExtEmployeePO extEmployeePO = extEmployeePOMap.get(dto.getEmployeeId());
|
|||
|
|
// taxDeclarationWageListDTO.setId(extEmployeePO.getId())
|
|||
|
|
// .setEmployeeId(extEmployeePO.getId())
|
|||
|
|
// .setJobNum(StringUtils.EMPTY)
|
|||
|
|
// .setUsername(extEmployeePO.getUsername())
|
|||
|
|
// .setCardNum(extEmployeePO.getCardNum());
|
|||
|
|
}
|
|||
|
|
taxDeclarationWageListDTOS.add(taxDeclarationWageListDTO);
|
|||
|
|
}
|
|||
|
|
return taxDeclarationWageListDTOS;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// /**
|
|||
|
|
// * 转换成个税申报表详情列表(劳务报酬所得)
|
|||
|
|
// *
|
|||
|
|
// * @param taxDeclarationDetailPOS
|
|||
|
|
// * @param simpleEmployees
|
|||
|
|
// * @return
|
|||
|
|
// */
|
|||
|
|
// public static List<TaxDeclarationLaborListDTO> convert2ListDTO4Labor(List<TaxDeclarationDetailPO> taxDeclarationDetailPOS,
|
|||
|
|
// List<TaxDeclarationEmployeeDTO> taxDeclarationEmployeeDTOS,
|
|||
|
|
// List<SimpleEmployee> simpleEmployees,
|
|||
|
|
// List<SimpleUserInfo> simpleUserInfos,
|
|||
|
|
// List<ExtEmployeePO> extEmployees) {
|
|||
|
|
// if (CollectionUtils.isEmpty(taxDeclarationDetailPOS)) {
|
|||
|
|
// return Collections.emptyList();
|
|||
|
|
// }
|
|||
|
|
// List<TaxDeclarationLaborListDTO> taxDeclarationLaborListDTOS = Lists.newArrayListWithExpectedSize(taxDeclarationEmployeeDTOS.size());
|
|||
|
|
// Map<String, List<TaxDeclarationDetailPO>> employeeIdKeyTaxDeclarationDetailPOMap = SalaryEntityUtil.group2Map(taxDeclarationDetailPOS,
|
|||
|
|
// taxDeclarationDetailPO -> taxDeclarationDetailPO.getEmployeeType() + "_" + taxDeclarationDetailPO.getEmployeeId());
|
|||
|
|
// Map<Long, SimpleEmployee> simpleEmployeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, SimpleEmployee::getEmployeeId);
|
|||
|
|
// Map<Long, SimpleUserInfo> simpleUserInfoMap = simpleUserInfos.stream()
|
|||
|
|
// .filter(simpleUserInfo -> Objects.nonNull(simpleUserInfo) && Objects.nonNull(simpleUserInfo.getUser()))
|
|||
|
|
// .collect(Collectors.toMap(simpleUserInfo -> simpleUserInfo.getUser().getId(), Function.identity(), (a, b) -> a));
|
|||
|
|
// Map<Long, ExtEmployeePO> extEmployeePOMap = SalaryEntityUtil.convert2Map(extEmployees, ExtEmployeePO::getId);
|
|||
|
|
// for (TaxDeclarationEmployeeDTO dto : taxDeclarationEmployeeDTOS) {
|
|||
|
|
// Map<String, String> fieldCodeKeyFieldValueMap = SalaryEntityUtil.convert2Map(employeeIdKeyTaxDeclarationDetailPOMap.get(dto.getEmployeeType() + "_" + dto.getEmployeeId()),
|
|||
|
|
// TaxDeclarationDetailPO::getFieldCode, TaxDeclarationDetailPO::getFieldValue);
|
|||
|
|
// TaxDeclarationLaborListDTO taxDeclarationLaborListDTO = new TaxDeclarationLaborListDTO()
|
|||
|
|
// .setId(dto.getEmployeeId())
|
|||
|
|
// .setEmployeeId(dto.getEmployeeId())
|
|||
|
|
// .setCardType(SalaryI18nUtil.getI18nLabel(105564, "居民身份证"))
|
|||
|
|
// .setIncomeItems(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.INCOME_ITEMS))
|
|||
|
|
// .setLaborIncome(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.LABOR_INCOME))
|
|||
|
|
// .setLaborTaxFreeIncome(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.LABOR_TAX_FREE_INCOME))
|
|||
|
|
// .setCommercialHealthInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.COMMERCIAL_HEALTH_INSURANCE))
|
|||
|
|
// .setTaxDeferredEndowmentInsurance(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_DEFERRED_ENDOWMENT_INSURANCE))
|
|||
|
|
// .setOther(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.OTHER))
|
|||
|
|
// .setAllowedDonation(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.ALLOWED_DONATION))
|
|||
|
|
// .setTaxDeduction(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.TAX_DEDUCTION))
|
|||
|
|
// .setDescription(fieldCodeKeyFieldValueMap.get(TaxDeclarationDataIndexConstant.DESCRIPTION));
|
|||
|
|
// if (Objects.equals(dto.getEmployeeType(), EmployeeTypeEnum.ORGANIZATION.getValue())) {
|
|||
|
|
// SimpleEmployee simpleEmployee = simpleEmployeeMap.get(dto.getEmployeeId());
|
|||
|
|
// SimpleUserInfo simpleUserInfo = simpleUserInfoMap.get(dto.getEmployeeId());
|
|||
|
|
// taxDeclarationLaborListDTO.setJobNum(simpleEmployee.getJobNum())
|
|||
|
|
// .setUsername(simpleEmployee.getUsername())
|
|||
|
|
// .setCardNum(Optional.ofNullable(simpleUserInfo).map(SimpleUserInfo::getIdNo).orElse(StringUtils.EMPTY));
|
|||
|
|
// } else {
|
|||
|
|
// ExtEmployeePO extEmployeePO = extEmployeePOMap.get(dto.getEmployeeId());
|
|||
|
|
// taxDeclarationLaborListDTO.setJobNum(StringUtils.EMPTY)
|
|||
|
|
// .setUsername(extEmployeePO.getUsername())
|
|||
|
|
// .setCardNum(extEmployeePO.getCardNum());
|
|||
|
|
// }
|
|||
|
|
// taxDeclarationLaborListDTOS.add(taxDeclarationLaborListDTO);
|
|||
|
|
// }
|
|||
|
|
// return taxDeclarationLaborListDTOS;
|
|||
|
|
// }
|
|||
|
|
}
|