减免税额附表
This commit is contained in:
parent
4a9a001311
commit
fe8910f2c5
|
|
@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
|
|||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 免税收入
|
||||
* 减免税额
|
||||
* <p>Copyright: Copyright (c) 2022</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
|
|
@ -85,12 +85,12 @@ public class DerateDeductionListDTO {
|
|||
@TableTitle(title = "减免事项", dataIndex = "derateItem", key = "derateItem")
|
||||
private String derateItem;
|
||||
|
||||
@ExcelProperty(index = 8)
|
||||
@ExcelProperty(index = 7)
|
||||
@TableTitle(title = "减免性质", dataIndex = "derateProperty", key = "derateProperty")
|
||||
@ElogTransform(name = "减免性质")
|
||||
private String derateProperty;
|
||||
|
||||
@ExcelProperty(index = 9)
|
||||
@ExcelProperty(index = 8)
|
||||
@TableTitle(title = "减免金额", dataIndex = "derateAmount", key = "derateAmount")
|
||||
@ElogTransform(name = "减免金额")
|
||||
private String derateAmount;
|
||||
|
|
|
|||
|
|
@ -135,9 +135,12 @@ public class OtherDeductionPO {
|
|||
private List<Long> employeeIds;
|
||||
private Collection<Long> taxAgentIds;
|
||||
|
||||
/**
|
||||
* 减免税额
|
||||
*/
|
||||
|
||||
private List<FreeIncomePO> freeIncomeList;
|
||||
private List<DerateDeductionPO> derateDeductionList;
|
||||
private List<EndowmentInsurancePO> endowmentInsuranceList;
|
||||
private List<GrantDonationPO> grantDonationList;
|
||||
private List<HealthInsurancePO> healthInsuranceList;
|
||||
private List<OtherDerateDeductionPO> otherDerateDeductionList;
|
||||
|
||||
}
|
||||
|
|
@ -12,10 +12,12 @@ import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
|||
import com.engine.salary.encrypt.EncryptUtil;
|
||||
import com.engine.salary.entity.datacollection.AddUpDeduction;
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.datacollection.dto.DerateDeductionListDTO;
|
||||
import com.engine.salary.entity.datacollection.dto.FreeIncomeListDTO;
|
||||
import com.engine.salary.entity.datacollection.dto.OtherDeductionListDTO;
|
||||
import com.engine.salary.entity.datacollection.dto.OtherDeductionRecordDTO;
|
||||
import com.engine.salary.entity.datacollection.param.*;
|
||||
import com.engine.salary.entity.datacollection.po.DerateDeductionPO;
|
||||
import com.engine.salary.entity.datacollection.po.FreeIncomePO;
|
||||
import com.engine.salary.entity.datacollection.po.OtherDeductionPO;
|
||||
import com.engine.salary.entity.salaryacct.po.SalaryAcctEmployeePO;
|
||||
|
|
@ -427,29 +429,30 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
|
|||
//税款所属期
|
||||
String declareMonthStr = Util.null2String(importParam.getDeclareMonth());
|
||||
|
||||
//人员信息
|
||||
List<DataCollectionEmployee> employees = getSalaryEmployeeService(user).listEmployee();
|
||||
// 获取所有个税扣缴义务人
|
||||
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
||||
//税款所属期
|
||||
Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01");
|
||||
// 获取已经核算的数据
|
||||
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr);
|
||||
// 查询已有数据
|
||||
List<OtherDeductionPO> list = getOtherDeductionMapper().listSome(OtherDeductionPO.builder().declareMonth(declareMonth).build());
|
||||
|
||||
InputStream fileInputStream = null;
|
||||
|
||||
List<OtherDeductionPO> eligibleData = new ArrayList<>();
|
||||
|
||||
try {
|
||||
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
||||
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
|
||||
//人员信息
|
||||
List<DataCollectionEmployee> employees = getSalaryEmployeeService(user).listEmployee();
|
||||
// 获取所有个税扣缴义务人
|
||||
Collection<TaxAgentManageRangeEmployeeDTO> taxAgentList = getTaxAgentService(user).listTaxAgentAndEmployeeTree(currentEmployeeId);
|
||||
//税款所属期
|
||||
Date declareMonth = SalaryDateUtil.stringToDate(declareMonthStr + "-01");
|
||||
// 获取已经核算的数据
|
||||
List<SalaryAcctEmployeePO> salaryAcctEmployees = getAddUpDeductionService(user).getAccountedEmployeeData(declareMonthStr);
|
||||
// 查询已有数据
|
||||
List<OtherDeductionPO> list = getOtherDeductionMapper().listSome(OtherDeductionPO.builder().declareMonth(declareMonth).build());
|
||||
|
||||
// 错误excel内容
|
||||
List<Map> errorData = new ArrayList<>();
|
||||
|
||||
List<OtherDeductionPO> eligibleData = new ArrayList<>();
|
||||
//免税收入
|
||||
List<FreeIncomeListDTO> freeIncomeList = ExcelParseHelper.parse2Map(fileInputStream, FreeIncomeListDTO.class, 0, 1, 9, "OtherDeductionTemplate.xlsx");
|
||||
for (int i = 0; i < freeIncomeList.size(); i++) {
|
||||
|
|
@ -460,6 +463,11 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
|
|||
OtherDeductionPO po = OtherDeductionPO.builder()
|
||||
.declareMonth(declareMonth)
|
||||
.freeIncomeList(new ArrayList<>())
|
||||
.derateDeductionList(new ArrayList<>())
|
||||
.endowmentInsuranceList(new ArrayList<>())
|
||||
.grantDonationList(new ArrayList<>())
|
||||
.healthInsuranceList(new ArrayList<>())
|
||||
.otherDerateDeductionList(new ArrayList<>())
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.creator((long) user.getUID())
|
||||
|
|
@ -565,7 +573,7 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
|
|||
|
||||
if (errorSum == 0) {
|
||||
successCount += 1;
|
||||
String key = po.getEmployeeId() + "-" + po.getTaxAgentId();
|
||||
String key = po.getTaxAgentId() + "-" + po.getEmployeeId();
|
||||
Map<String, OtherDeductionPO> deductionPOMap = SalaryEntityUtil.convert2Map(eligibleData, e -> e.getTaxAgentId() + "-" + e.getEmployeeId());
|
||||
if (deductionPOMap.containsKey(key)) {
|
||||
deductionPOMap.get(key).getFreeIncomeList().add(freeIncomePO);
|
||||
|
|
@ -580,16 +588,173 @@ public class OtherDeductionServiceImpl extends Service implements OtherDeduction
|
|||
}
|
||||
}
|
||||
|
||||
//入库
|
||||
// handleImportDetailData(eligibleData);
|
||||
|
||||
apidatas.put("successCount", successCount);
|
||||
apidatas.put("errorCount", errorCount);
|
||||
apidatas.put("errorData", errorData);
|
||||
HashMap<Object, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("successCount", successCount);
|
||||
dataMap.put("errorCount", errorCount);
|
||||
dataMap.put("errorData", errorData);
|
||||
apidatas.put("freeIncome", dataMap);
|
||||
|
||||
} finally {
|
||||
IOUtils.closeQuietly(fileInputStream);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
fileInputStream = ImageFileManager.getInputStreamById(Integer.parseInt(imageId));
|
||||
|
||||
int successCount = 0;
|
||||
int errorCount = 0;
|
||||
|
||||
// 错误excel内容
|
||||
List<Map> errorData = new ArrayList<>();
|
||||
|
||||
List<DerateDeductionListDTO> derateDeductionList = ExcelParseHelper.parse2Map(fileInputStream, DerateDeductionListDTO.class, 4, 1, 9, "OtherDeductionTemplate.xlsx");
|
||||
for (int i = 0; i < derateDeductionList.size(); i++) {
|
||||
DerateDeductionListDTO dto = derateDeductionList.get(i);
|
||||
|
||||
Date now = new Date();
|
||||
//待插入数据库对象
|
||||
OtherDeductionPO mainPo = OtherDeductionPO.builder()
|
||||
.declareMonth(declareMonth)
|
||||
.freeIncomeList(new ArrayList<>())
|
||||
.derateDeductionList(new ArrayList<>())
|
||||
.endowmentInsuranceList(new ArrayList<>())
|
||||
.grantDonationList(new ArrayList<>())
|
||||
.healthInsuranceList(new ArrayList<>())
|
||||
.otherDerateDeductionList(new ArrayList<>())
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.creator((long) user.getUID())
|
||||
.tenantKey(DEFAULT_TENANT_KEY)
|
||||
.build();
|
||||
|
||||
DerateDeductionPO po = DerateDeductionPO.builder()
|
||||
.taxYearMonth(declareMonth)
|
||||
.fileStatus(1)
|
||||
.creator((long) user.getUID())
|
||||
.createTime(now)
|
||||
.updateTime(now)
|
||||
.tenantKey(DEFAULT_TENANT_KEY)
|
||||
.build();
|
||||
|
||||
//异常点数量
|
||||
int errorSum = 0;
|
||||
|
||||
//行号
|
||||
String rowIndex = String.format("第%s行", i + 2);
|
||||
|
||||
//相同的姓名
|
||||
String userName = dto.getUsername();
|
||||
String deparmentName = dto.getDepartmentName();
|
||||
String mobile = dto.getMobile();
|
||||
String workcode = dto.getJobNum();
|
||||
String idNo = dto.getIdNo();
|
||||
List<Long> employeeSameIds = new ArrayList<>();
|
||||
|
||||
//筛选导入人员信息可以在人力资源池中匹配到的人员信息
|
||||
List<DataCollectionEmployee> emps = getSalaryEmployeeService(user).matchImportEmployee(confValue, employees, userName, deparmentName, mobile, workcode, idNo, null);
|
||||
//含在职和离职,选在职数据
|
||||
if (CollectionUtils.isNotEmpty(emps) && emps.size() > 1) {
|
||||
employeeSameIds = emps.stream()
|
||||
.filter(e -> UserStatusEnum.getNormalStatus().contains(e.getStatus()))
|
||||
.map(DataCollectionEmployee::getEmployeeId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(emps) && emps.size() == 1) {
|
||||
employeeSameIds = emps.stream()
|
||||
.map(DataCollectionEmployee::getEmployeeId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
//当人员信息导入筛选的全局配置为"0"时,姓名才是必填项
|
||||
if (StringUtils.isBlank(userName) && "0".equals(confValue)) {
|
||||
//姓名 不能为空
|
||||
//错误消息对象
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowIndex + "姓名不能为空");
|
||||
errorData.add(errorMessageMap);
|
||||
errorSum += 1;
|
||||
} else if (CollectionUtils.isEmpty(employeeSameIds) || employeeSameIds.size() > 1) {
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowIndex + "员工信息不存在或者存在多个员工");
|
||||
errorData.add(errorMessageMap);
|
||||
errorSum += 1;
|
||||
} else {
|
||||
Long employeeId = CollectionUtils.isNotEmpty(employeeSameIds) && employeeSameIds.size() == 1 ? employeeSameIds.get(0) : null;
|
||||
if (employeeId != null && employeeId > 0) {
|
||||
mainPo.setEmployeeId(employeeId);
|
||||
po.setEmployeeId(employeeId);
|
||||
po.setEmployeeType(DataCollectionEmployeeTypeEnum.ORGANIZATION.getValue());
|
||||
} else {
|
||||
//姓名错误,系统内不存在该姓名
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowIndex + "姓名错误,系统内不存在该姓名");
|
||||
errorData.add(errorMessageMap);
|
||||
errorSum += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String taxAgentName = dto.getTaxAgentName();
|
||||
if (StringUtils.isBlank(taxAgentName)) {
|
||||
//个税扣缴义务人不能为空
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不能为空");
|
||||
errorData.add(errorMessageMap);
|
||||
errorSum += 1;
|
||||
} else {
|
||||
Optional<TaxAgentManageRangeEmployeeDTO> optionalTemp = taxAgentList.stream().filter(m -> m.getTaxAgentName().equals(taxAgentName)).findFirst();
|
||||
if (optionalTemp.isPresent()) {
|
||||
mainPo.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
||||
po.setTaxAgentId(optionalTemp.get().getTaxAgentId());
|
||||
} else {
|
||||
//个税扣缴义务人不存在
|
||||
Map<String, String> errorMessageMap = Maps.newHashMap();
|
||||
errorMessageMap.put("message", rowIndex + "个税扣缴义务人不存在或不在权限范围内");
|
||||
errorData.add(errorMessageMap);
|
||||
errorSum += 1;
|
||||
}
|
||||
}
|
||||
|
||||
String derateAmount = dto.getDerateAmount();
|
||||
String derateItem = dto.getDerateItem();
|
||||
String derateProperty = dto.getDerateProperty();
|
||||
po.setDerateAmount(derateAmount);
|
||||
po.setDerateItem(derateItem);
|
||||
po.setDerateProperty(derateProperty);
|
||||
|
||||
|
||||
if (errorSum == 0) {
|
||||
successCount += 1;
|
||||
String key = mainPo.getTaxAgentId() + "-" + mainPo.getEmployeeId();
|
||||
Map<String, OtherDeductionPO> deductionPOMap = SalaryEntityUtil.convert2Map(eligibleData, e -> e.getTaxAgentId() + "-" + e.getEmployeeId());
|
||||
if (deductionPOMap.containsKey(key)) {
|
||||
deductionPOMap.get(key).getDerateDeductionList().add(po);
|
||||
} else {
|
||||
mainPo.getDerateDeductionList().add(po);
|
||||
eligibleData.add(mainPo);
|
||||
}
|
||||
|
||||
} else {
|
||||
errorCount += 1;
|
||||
// 添加错误数据
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<Object, Object> dataMap = new HashMap<>();
|
||||
dataMap.put("successCount", successCount);
|
||||
dataMap.put("errorCount", errorCount);
|
||||
dataMap.put("errorData", errorData);
|
||||
apidatas.put("derateDeduction", dataMap);
|
||||
|
||||
} finally {
|
||||
IOUtils.closeQuietly(fileInputStream);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return apidatas;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue