Commit 0cf71411 authored by huyuchen's avatar huyuchen

申报,稿酬,劳务费接口修改

parent 97d37ac5
......@@ -75,13 +75,6 @@ public class TStatisticsLabor {
@Length(max = 32, message = "身份证号不能超过32个字符")
@ExcelProperty("身份证号")
private String empIdcard;
/**
* 工号
*/
@ExcelAttribute(name = "工号", maxLength = 32)
@Length(max = 32, message = "工号不能超过32个字符")
@ExcelProperty("工号")
private String workNo;
/**
* 证件类型
*/
......
......@@ -94,12 +94,5 @@ public class TStatisticsRemuneration {
@ExcelAttribute(name = "个税")
@ExcelProperty("个税")
private BigDecimal personalTax;
/**
* 工号
*/
@ExcelAttribute(name = "工号", maxLength = 32)
@Length(max = 32, message = "工号不能超过32个字符")
@ExcelProperty("工号")
private String workNo;
}
......@@ -81,14 +81,6 @@ public class TStatisticsLaborVo extends RowIndex implements Serializable {
@Schema(description = "身份证号")
@ExcelProperty("身份证号")
private String empIdcard;
/**
* 工号
*/
@Length(max = 32, message = "工号 不能超过32 个字符")
@ExcelAttribute(name = "工号", maxLength = 32)
@Schema(description = "工号")
@ExcelProperty("工号")
private String workNo;
/**
* 证件类型
*/
......
......@@ -103,13 +103,5 @@ public class TStatisticsRemunerationVo extends RowIndex implements Serializable
@Schema(description = "个税")
@ExcelProperty("个税")
private BigDecimal personalTax;
/**
* 工号
*/
@Length(max = 32, message = "工号 不能超过32 个字符")
@ExcelAttribute(name = "工号", maxLength = 32)
@Schema(description = "工号")
@ExcelProperty("工号")
private String workNo;
}
......@@ -32,7 +32,6 @@ public class SalaryUploadController {
* @param settleDepart 结算主体id
* @param configId 配置方案id
* @param salaryType 报表类型id
* @param repeatFlag 默认 0:不允许重复导入已存在系统内的数据;1:允许重复导入
* @Description:
* @Author: hgw
* @Date: 2019/9/11 15:21
......@@ -41,7 +40,7 @@ public class SalaryUploadController {
@Operation(description = "上传:jsonString:表格json;settleDepart:结算主体id;configId:工资配置结算月等信息的id;salaryType:工资类型")
@SysLog("上传薪资表")
@PostMapping("/upload")
public R upload(@RequestBody String jsonString, @RequestParam String settleDepart, @RequestParam String configId
public R upload(@RequestBody String jsonString, @RequestParam String settleDepart, @RequestParam(required = false) String configId
, @RequestParam String salaryType) {
return salaryUploadService.salaryUpload(jsonString, settleDepart, configId, salaryType);
}
......
......@@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TStatisticsLabor;
import com.yifu.cloud.plus.v1.yifu.salary.service.TStatisticsLaborService;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TStatisticsLaborSearchVo;
......@@ -36,7 +37,7 @@ import javax.servlet.http.HttpServletResponse;
/**
* 本期劳务费申报表
*
* @author hgw
* @author huyc
* @date 2022-08-05 11:40:14
*/
@RestController
......@@ -90,7 +91,7 @@ public class TStatisticsLaborController {
/**
* 本期劳务费申报表 批量导出
*
* @author hgw
* @author huyc
* @date 2022-08-05 11:40:14
**/
@Operation(description = "导出本期劳务费申报表 hasPermission('salary_tstatisticslabor-export')")
......@@ -113,4 +114,18 @@ public class TStatisticsLaborController {
public R batchDelete(@RequestParam String declareMonth){
return tStatisticsLaborService.batchDelete(declareMonth);
}
/**
* @param
* @Description: 生成本期劳务费
* @Author: huyc
* @Date: 2022-08-17 18:17:48
* @return: com.yifu.cloud.v1.common.core.util.R
**/
@Inner
@Operation(description = "生成本期劳务费")
@PostMapping("/inner/doStatisticsLabor")
public R doStatisticsLabor() {
return tStatisticsLaborService.doStatisticsLabor();
}
}
......@@ -23,6 +23,9 @@ import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 本期劳务费申报表
*
......@@ -37,4 +40,11 @@ public interface TStatisticsLaborMapper extends BaseMapper<TStatisticsLabor> {
* @return
*/
IPage<TStatisticsLabor> getTStatisticsLaborPage(Page<TStatisticsLabor> page, @Param("tStatisticsLabor") TStatisticsLabor tStatisticsLabor);
/**
* @param
* @Description: 统计
* @return:
**/
List<TStatisticsLabor> doStatisticsLabor(@Param("nowMonth") String nowMonth, @Param("lastYear") String lastYear);
}
......@@ -50,9 +50,15 @@ public interface TStatisticsLaborService extends IService<TStatisticsLabor> {
List<TStatisticsLabor> noPageDiy(TStatisticsLaborSearchVo searchVo);
/**
* 批量删除本期稿酬申报表
* 批量删除本期劳务费申报表
* @param declareMonth 申报月份
* @return
*/
R batchDelete(String declareMonth);
/** 生成本期劳务费
* @param
* @return
**/
R doStatisticsLabor();
}
......@@ -94,7 +94,8 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
**/
@Override
public R salaryUpload(String jsonString, String settleDepart, String configId, String salaryType) {
if (Common.isNotNull(jsonString) && Common.isNotNull(settleDepart) && Common.isNotNull(configId) && Common.isNotNull(salaryType)) {
if (Common.isNotNull(jsonString) && Common.isNotNull(settleDepart) && Common.isNotNull(salaryType)) {
R<TSettleDomainSelectVo> sdr = HttpDaprUtil.invokeMethodPost(archivesProperties.getAppUrl(), archivesProperties.getAppId()
, "/tsettledomain/inner/getSettleDomainVoById", settleDepart, TSettleDomainSelectVo.class, SecurityConstants.FROM_IN);
// 结算主体
......@@ -102,14 +103,7 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
if (sdr != null && sdr.getData() != null) {
dept = sdr.getData();
}
if (dept == null || dept.getId() == null) {
return R.failed("新建工资主表失败-获取结算主体信息为空");
}
// 2020-3-29 11:24:14变更为结算主体的封面抬头
String invoiceTitle = dept.getBusinessSubjectName();
if (Common.isEmpty(invoiceTitle)) {
return R.failed("上传失败-获取结算主体的-封面抬头-信息为空,请去<客户管理-结算主体>模块,编辑封面抬头后再导入");
}
// 薪资识别配置(原表-标准模板)
List<TSalaryConfigStandard> salaryAccountList = tSalaryConfigStandardService.list();
Map<String, TSalaryConfigStandard> salaryConfigMap = new HashMap<>(); //存放所有字段
......@@ -120,65 +114,135 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
isMustMap.put(sc.getDbFiedName(), true);
}
}
// 薪资配置-结算月、社保月等信息
TConfigSalary configSalary = configSalaryService.getById(configId);
if (dept == null || dept.getId() == null) {
return R.failed("新建工资主表失败-获取结算主体信息为空");
}
// 2020-3-29 11:24:14变更为结算主体的封面抬头
String invoiceTitle = dept.getBusinessSubjectName();
if (Common.isEmpty(invoiceTitle)) {
return R.failed("上传失败-获取结算主体的-封面抬头-信息为空,请去<客户管理-结算主体>模块,编辑封面抬头后再导入");
}
YifuUser user = SecurityUtils.getUser();
if (null == user || null == user.getId()) {
return R.failed("获取登录用户信息失败!");
}
try {
jsonString = URLDecoder.decode(jsonString, "UTF-8").replace("=", "");
SalaryAccountUtil util1 = new SalaryAccountUtil();
TSalaryEmployee empSearch = new TSalaryEmployee();
empSearch.setUnitId(dept.getCustomerId());
List<TSalaryEmployee> empList = employeeService.list(Wrappers.<TSalaryEmployee>query().lambda()
.eq(TSalaryEmployee::getUnitId, dept.getCustomerId()));
Map<String, TSalaryEmployee> empIdCardMap = new HashMap<>();
Map<String, TSalaryEmployee> empNameMap = new HashMap<>();
boolean isDuplicateName = false;
if (empList != null) {
TSalaryEmployee es;//筛选人员,添加判断:非在职,或开户行为空,或 结算主体等于选择的结算主体且在职,都可以存入Map优先备用
for (TSalaryEmployee e : empList) {
es = empIdCardMap.get(e.getEmpIdcard());
if (es == null || CommonConstants.ZERO_INT != es.getFileStatus() || Common.isEmpty(es.getBankName())
|| (e.getDeptId().equals(settleDepart) && CommonConstants.ZERO_INT == e.getFileStatus()
&& Common.isNotNull(e.getBankName()))) {
empIdCardMap.put(e.getEmpIdcard(), e);
empNameMap.put(e.getEmpName().replace(" ", ""), e);
//薪资导入
if (CommonConstants.ZERO_STRING.equals(salaryType) && Common.isNotNull(configId)) {
// 薪资配置-结算月、社保月等信息
TConfigSalary configSalary = configSalaryService.getById(configId);
try {
jsonString = URLDecoder.decode(jsonString, "UTF-8").replace("=", "");
SalaryAccountUtil util1 = new SalaryAccountUtil();
TSalaryEmployee empSearch = new TSalaryEmployee();
empSearch.setUnitId(dept.getCustomerId());
List<TSalaryEmployee> empList = employeeService.list(Wrappers.<TSalaryEmployee>query().lambda()
.eq(TSalaryEmployee::getUnitId, dept.getCustomerId()));
Map<String, TSalaryEmployee> empIdCardMap = new HashMap<>();
Map<String, TSalaryEmployee> empNameMap = new HashMap<>();
boolean isDuplicateName = false;
if (empList != null) {
TSalaryEmployee es;//筛选人员,添加判断:非在职,或开户行为空,或 结算主体等于选择的结算主体且在职,都可以存入Map优先备用
for (TSalaryEmployee e : empList) {
es = empIdCardMap.get(e.getEmpIdcard());
if (es == null || CommonConstants.ZERO_INT != es.getFileStatus() || Common.isEmpty(es.getBankName())
|| (e.getDeptId().equals(settleDepart) && CommonConstants.ZERO_INT == e.getFileStatus()
&& Common.isNotNull(e.getBankName()))) {
empIdCardMap.put(e.getEmpIdcard(), e);
empNameMap.put(e.getEmpName().replace(" ", ""), e);
}
}
if (empNameMap.size() == empIdCardMap.size()) {
isDuplicateName = true;
}
}
if (empNameMap.size() == empIdCardMap.size()) {
isDuplicateName = true;
// 自有员工结算主体id,新员工使用
Map<String, Integer> ownDeptMap = tOwnDeptService.getOwnDeptMap();
// 自有员工所在结算主体Map
Map<String, Integer> ownEmployeeMap = tOwnDeptService.getOwnEmpMap();
// 2.6.6:校验导入数据重复的Map格式:#身份证号_工资月份_报表类型_应发金额
Map<String, Integer> checkMap = tSalaryAccountService.getAccountCheckMap(dept.getId(), DateUtil.addMonth(configSalary.getSalaryMonth()));
util1.getJsonStringToList(user, jsonString,
dept, configSalary, salaryConfigMap, isMustMap, empIdCardMap, empNameMap, isDuplicateName
, salaryType, invoiceTitle, employeeService, checkMap, ownEmployeeMap, ownDeptMap, tSalaryAccountService);
List<TSalaryAccountVo> saList = util1.getEntityList();
if ((null != util1.getErrorInfo() && !util1.getErrorInfo().isEmpty())) {
return R.failed(util1.getErrorInfo());
} else {
if (null != saList && !saList.isEmpty()) {
// return R.ok(saList)
return this.saveAndSubmit(saList);
} else {
return R.failed("导入数据不可为空");
}
}
} catch (Exception e) {
log.error(e.getMessage());
return R.failed("数据导入解析失败!");
}
// 自有员工结算主体id,新员工使用
Map<String, Integer> ownDeptMap = tOwnDeptService.getOwnDeptMap();
// 自有员工所在结算主体Map
Map<String, Integer> ownEmployeeMap = tOwnDeptService.getOwnEmpMap();
// 2.6.6:校验导入数据重复的Map格式:#身份证号_工资月份_报表类型_应发金额
Map<String, Integer> checkMap = tSalaryAccountService.getAccountCheckMap(dept.getId(), DateUtil.addMonth(configSalary.getSalaryMonth()));
util1.getJsonStringToList(user, jsonString,
dept, configSalary, salaryConfigMap, isMustMap, empIdCardMap, empNameMap, isDuplicateName
, salaryType, invoiceTitle, employeeService, checkMap, ownEmployeeMap, ownDeptMap, tSalaryAccountService);
List<TSalaryAccountVo> saList = util1.getEntityList();
if ((null != util1.getErrorInfo() && !util1.getErrorInfo().isEmpty())) {
return R.failed(util1.getErrorInfo());
} else {
if (null != saList && !saList.isEmpty()) {
// return R.ok(saList)
return this.saveAndSubmit(saList);
//劳务费导入
} else if (CommonConstants.THREE_STRING.equals(salaryType)) {
TConfigSalary configSalary = new TConfigSalary();
// 薪资配置-结算月、社保月等信息
configSalary = configSalaryService.getById(CommonConstants.ONE_STRING);
try {
jsonString = URLDecoder.decode(jsonString, "UTF-8").replace("=", "");
SalaryAccountUtil util1 = new SalaryAccountUtil();
List<TSalaryEmployee> empList = employeeService.list(Wrappers.<TSalaryEmployee>query().lambda()
.eq(TSalaryEmployee::getUnitId, dept.getCustomerId()));
Map<String, TSalaryEmployee> empIdCardMap = new HashMap<>();
Map<String, TSalaryEmployee> empNameMap = new HashMap<>();
boolean isDuplicateName = false;
if (empList != null) {
TSalaryEmployee es;//筛选人员,添加判断:非在职,或开户行为空,或 结算主体等于选择的结算主体且在职,都可以存入Map优先备用
for (TSalaryEmployee e : empList) {
es = empIdCardMap.get(e.getEmpIdcard());
if (es == null || CommonConstants.ZERO_INT != es.getFileStatus() || Common.isEmpty(es.getBankName())
|| (e.getDeptId().equals(settleDepart) && CommonConstants.ZERO_INT == e.getFileStatus()
&& Common.isNotNull(e.getBankName()))) {
empIdCardMap.put(e.getEmpIdcard(), e);
empNameMap.put(e.getEmpName().replace(" ", ""), e);
}
}
if (empNameMap.size() == empIdCardMap.size()) {
isDuplicateName = true;
}
}
// 自有员工结算主体id,新员工使用
Map<String, Integer> ownDeptMap = tOwnDeptService.getOwnDeptMap();
// 自有员工所在结算主体Map
Map<String, Integer> ownEmployeeMap = tOwnDeptService.getOwnEmpMap();
// 2.6.6:校验导入数据重复的Map格式:#身份证号_工资月份_报表类型_应发金额
Map<String, Integer> checkMap = new HashMap<>();
if (Common.isNotNull(configSalary)) {
checkMap = tSalaryAccountService.getAccountCheckMap(dept.getId(), DateUtil.addMonth(configSalary.getSalaryMonth()));
}
util1.getJsonStringToList(user, jsonString, dept, !Common.isNotNull(configSalary) ? null: configSalary,
salaryConfigMap, isMustMap, empIdCardMap, empNameMap, isDuplicateName, salaryType,
null, employeeService, checkMap, ownEmployeeMap, ownDeptMap, tSalaryAccountService);
List<TSalaryAccountVo> saList = util1.getEntityList();
if ((null != util1.getErrorInfo() && !util1.getErrorInfo().isEmpty())) {
return R.failed(util1.getErrorInfo());
} else {
return R.failed("导入数据不可为空");
if (null != saList && !saList.isEmpty()) {
return this.saveLaborSubmit(saList, dept);
} else {
return R.failed("导入数据不可为空");
}
}
} catch (Exception e) {
log.error(e.getMessage());
return R.failed("数据导入解析失败!");
}
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
return R.failed("数据导入解析失败!");
}
}
return R.failed("导入数据不可为空");
......@@ -1415,4 +1479,316 @@ public class SalaryUploadServiceImpl extends ServiceImpl<TSalaryStandardMapper,
return new R<>(salaryDetailVo);
}
/**
* @param savList 报账表Vo
* @Description: 保存并提交
* @Author: huyc
* @Date: 2022/8/16
* @return: com.yifu.cloud.v1.common.core.util.R
**/
public R saveLaborSubmit(List<TSalaryAccountVo> savList, TSettleDomainSelectVo dept) {
if (Common.isNotNull(savList) && !savList.isEmpty()) {
TSalaryAccountVo salaryAccountVo = savList.get(0);
List<TSalaryAccountItem> saiList = null; //报账明细List
TSalaryAccountItem sai = null; //报账明细
YifuUser user = SecurityUtils.getUser();
TSalaryStandard salary;
LocalDateTime nowTime = LocalDateTime.now();
//工资主表
R<TSalaryStandard> sr = this.saveNewTSalary(salaryAccountVo, dept, user, nowTime);
String invoiceTitle = dept.getBusinessSubjectName();
if (sr == null || sr.getCode() == CommonConstants.FAIL) {
return sr;
} else {
salary = sr.getData();
}
boolean isActual = false; //false:应发导入; true:实发 倒推导入
List<TSalaryAccountItemVo> itemList = salaryAccountVo.getSaiList();
for (TSalaryAccountItemVo item : itemList) {
if (SalaryConstants.ACTUAL_SALARY_SUM_JAVA.equals(item.getJavaFiedName())) {
isActual = true;
break;
}
}
if (salary != null) {
// 薪资导入、删除前加锁:
TSalaryLock lock = salaryLockService.lambdaQuery()
.eq(TSalaryLock::getDeptId, dept.getId())
.eq(TSalaryLock::getDeleteFlag, CommonConstants.ZERO_INT)
.last("limit 1").one();
if (lock != null && Common.isNotNull(lock.getId())) {
return R.failed("当前结算主体已被用户锁定,请稍等!超过10分钟还没释放,请联系管理员!当前时间:" + nowTime);
} else {
lock = new TSalaryLock();
lock.setCreateTime(nowTime);
lock.setDeleteFlag(CommonConstants.ZERO_INT);
lock.setDeptId(dept.getId());
lock.setDeptName(dept.getDepartName());
lock.setSettleMonth(salaryAccountVo.getSettlementMonth());
lock.setType(CommonConstants.ZERO_INT);
salaryLockService.save(lock);
TSalaryLock lockUpdate;
try {
// 薪资核心导入代码
return this.doLaborCoreSalary(savList, salaryAccountVo, saiList, sai, dept, invoiceTitle, user, nowTime, salary, isActual);
} catch (Exception e) {
lockUpdate = new TSalaryLock();
lockUpdate.setId(lock.getId());
lockUpdate.setDeleteFlag(CommonConstants.ONE_INT);
salaryLockService.updateById(lockUpdate);
throw new RuntimeException(e.getMessage() == null ? "薪资导入失败!" : e.getMessage());
} finally {
lockUpdate = new TSalaryLock();
lockUpdate.setId(lock.getId());
lockUpdate.setDeleteFlag(CommonConstants.ONE_INT);
if (Common.isNotNull(salary.getId())) {
lockUpdate.setSalaryId(salary.getId());
lockUpdate.setSettleMoney(salary.getSettlementAmount());
}
salaryLockService.updateById(lockUpdate);
}
}
} else {
return R.failed("新建工资主表失败");
}
}
return R.failed("提交的数据不可为空");
}
/**
* @Description: 劳务费导入核心代码
* @Author: huyc
* @return: com.yifu.cloud.v1.common.core.util.R
**/
public R doLaborCoreSalary(List<TSalaryAccountVo> savList, TSalaryAccountVo salaryAccountVo
, List<TSalaryAccountItem> saiList, TSalaryAccountItem sai, TSettleDomainSelectVo dept
, String invoiceTitle, YifuUser user, LocalDateTime nowTime, TSalaryStandard salary
, boolean isActual) {
List<TSalaryAccount> aList = new ArrayList<>();
TSalaryAccount a;//定库:
BigDecimal money = new BigDecimal(CommonConstants.ZERO_STRING); //初始化金额备用
BigDecimal relaySalarySum = BigDecimal.ZERO; //工资应发
List<TSalaryAccountItem> asList; //累计扣税
// 历史个税合计
BigDecimal sumTax = BigDecimal.ZERO;
int size = savList.size();
// 自有员工人数
int ownNum = 0;
// 自有员工应发金额
BigDecimal ownMoney = BigDecimal.ZERO;
BigDecimal relaySalary; //工资应发
// 劳务费、稿酬是否含有发薪false:否;true:是
boolean haveSalaryFlag = false;
// 是否含有特殊金额false:否;true:是
boolean haveSpecialFlag = false;
// 是否重复金额false:否;true:是
boolean repeatFlag = false;
List<String> idCardList = new ArrayList<>();
for (TSalaryAccountVo vo : savList) {
if (Common.isNotNull(vo.getEmpIdcard())) {
idCardList.add(vo.getEmpIdcard());
}
}
// 工资查询所需的全部list,组装Map来使用
Map<String, List<TSalaryAccountItem>> itemMap = tSalaryAccountItemService.getAllItemVoList(idCardList, invoiceTitle);
for (int i = CommonConstants.ZERO_INT; i < size; i++) {
relaySalary = BigDecimal.ZERO;
a = new TSalaryAccount();
// 本次实发
BigDecimal actualSalarySumNow = BigDecimal.ZERO;
// 当月实发合计
BigDecimal actualSalarySum = BigDecimal.ZERO;
try {
SalaryAccountUtil.reflectionAttr(savList.get(i), a);
if (!haveSalaryFlag && a.getHaveSalaryFlag() != null && a.getHaveSalaryFlag() == CommonConstants.ONE_INT) {
haveSalaryFlag = true;
}
if (!haveSpecialFlag && a.getHaveSpecialFlag() != null && a.getHaveSpecialFlag() == CommonConstants.ONE_INT) {
haveSpecialFlag = true;
}
if (!repeatFlag && a.getIsRepeat() != null && a.getIsRepeat() == CommonConstants.ONE_INT) {
repeatFlag = true;
}
if (savList.get(i).getSaiList() != null && !savList.get(i).getSaiList().isEmpty()) {
saiList = new ArrayList<>();
for (int j = 0; j < savList.get(i).getSaiList().size(); j++) {
sai = new TSalaryAccountItem();
SalaryAccountUtil.reflectionAttr(savList.get(i).getSaiList().get(j), sai);
//工资应发
if (SalaryConstants.RELAY_SALARY_JAVA.equals(sai.getJavaFiedName())) {
relaySalary = sai.getSalaryMoney();
relaySalarySum = relaySalarySum.add(sai.getSalaryMoney());
}
SalaryAccountUtil.reflectionAttr(savList.get(i).getSaiList().get(j), sai);
//个人实发合计
if (SalaryConstants.ACTUAL_SALARY_SUM_JAVA.equals(sai.getJavaFiedName())) {
actualSalarySum = actualSalarySum.add(sai.getSalaryMoney());
actualSalarySumNow = actualSalarySumNow.add(sai.getSalaryMoney());
}
saiList.add(sai);
}
}
// 自有员工以及自有员工应发金额
if (Common.isNotNull(a.getOwnFlag()) && a.getOwnFlag() == 1) {
ownNum++;
ownMoney = ownMoney.add(relaySalary);
}
//累计扣税list
asList = this.getLaborAsList(itemMap.get(a.getEmpIdcard()), a.getSettlementMonth());
// 实发劳务费,按月累计扣税
this.saveNewItems(sai, saiList, SalaryConstants.SALARY_TAX,
SalaryConstants.SALARY_TAX_JAVA,
calculationLabor(saiList, asList
, saiList,a), CommonConstants.ZERO_INT);
a.setSaiList(saiList);
aList.add(a);
} catch (Exception e) {
e.printStackTrace();
}
}
salary.setOwnNums(ownNum);
salary.setOwnMoney(ownMoney);
TSalaryDetailVo salaryDetailVo = new TSalaryDetailVo();
salaryDetailVo.setSalaryAccountList(aList);
salary.setSettlementAmount(relaySalarySum);
salary.setHaveSalaryFlag(CommonConstants.ZERO_INT);
salary.setHaveSpecialFlag(CommonConstants.ZERO_INT);
salary.setIsRepeat(CommonConstants.ZERO_INT);
salary.setStatus(SalaryConstants.AUDIT_STATUS[0]);
if (haveSalaryFlag || haveSpecialFlag || ownNum>0 || repeatFlag) {
if (haveSalaryFlag) {
salary.setHaveSalaryFlag(CommonConstants.ONE_INT);
}
if (haveSpecialFlag) {
salary.setHaveSpecialFlag(CommonConstants.ONE_INT);
}
if (repeatFlag) {
salary.setIsRepeat(CommonConstants.ONE_INT);
}
}
//保存工资表
tSalaryStandardService.save(salary);
salaryDetailVo.setSalary(salary);
for (TSalaryAccount account : aList) {
saiList = account.getSaiList();
account.setSaiList(null);
account.setSalaryFormId(salary.getId());
tSalaryAccountService.save(account);
money = SalaryConstants.B_ZERO;
for (TSalaryAccountItem item : saiList) {
if (SalaryConstants.ACTUAL_SALARY_SUM_JAVA.equals(item.getJavaFiedName())) {
money = item.getSalaryMoney();
}
item.setSalaryAccountId(account.getId());
tSalaryAccountItemService.save(item);
}
}
return R.ok(salaryDetailVo);
}
/**
* @param itemList
* @param itemHistoryList
* @param saiList
* @Description: 计算劳务费个税、应发
* @Author: hgw
* @Date: 2022/3/3 11:30
* @return: java.math.BigDecimal
**/
private static BigDecimal calculationLabor(List<TSalaryAccountItem> itemList, List<TSalaryAccountItem> itemHistoryList,
List<TSalaryAccountItem> saiList, TSalaryAccount a) {
// B7 = 当月实发合计
// 税=ROUND(IF(B7<=800,0,IF(B7<=3360,(B7-800)/4,IF(B7<=21000,0.16*B7/0.84,IF(B7<=49500,(0.24*B7-2000)/0.76,(0.32*B7-7000)/0.68)))),2)
// 本次实发
BigDecimal actualSalarySumNow = BigDecimal.ZERO;
// 当月实发合计
BigDecimal actualSalarySum = BigDecimal.ZERO;
// 历史个税合计
BigDecimal sumTax = BigDecimal.ZERO;
// 本次实发
for (TSalaryAccountItem item : itemList) {
if (SalaryConstants.ACTUAL_SALARY_SUM_JAVA.equals(item.getJavaFiedName())) {
actualSalarySum = actualSalarySum.add(item.getSalaryMoney());
actualSalarySumNow = actualSalarySumNow.add(item.getSalaryMoney());
}
}
// 历史实发、个税
for (TSalaryAccountItem item : itemHistoryList) {
if (SalaryConstants.SALARY_TAX_JAVA.equals(item.getJavaFiedName())) {
sumTax = sumTax.add(item.getSalaryMoney());
}
if (SalaryConstants.ACTUAL_SALARY_SUM_JAVA.equals(item.getJavaFiedName())) {
actualSalarySum = actualSalarySum.add(item.getSalaryMoney());
}
}
//个人承担部分税费
BigDecimal nowTaxT = BigDecimal.ZERO;
//个人不承担部分税费
BigDecimal nowTaxY = BigDecimal.ZERO;
BigDecimal relaySalary;
if (CommonConstants.ONE_STRING.equals(a.getIsPersonTax())) {
nowTaxT = getNowTax(actualSalarySumNow);
nowTaxY = getNowTax(actualSalarySum);
relaySalary = BigDecimalUtils.safeAdd(actualSalarySumNow, nowTaxT).setScale(SalaryConstants.PLACES, BigDecimal.ROUND_HALF_UP);
BigDecimal salaryTax = BigDecimalUtils.safeSubtract(nowTaxY,BigDecimalUtils.safeAdd(nowTaxT,sumTax));
a.setSalaryTax(salaryTax);
a.setRelaySalaryUnit(relaySalary);
a.setSalaryTaxUnit(nowTaxT);
a.setActualSalary(BigDecimalUtils.safeSubtract(actualSalarySumNow,salaryTax));
} else {
nowTaxY = getNowTax(actualSalarySum);
if (sumTax.compareTo(BigDecimal.ZERO) != 0) {
nowTaxY = BigDecimalUtils.safeSubtract(nowTaxY, sumTax).setScale(SalaryConstants.PLACES, BigDecimal.ROUND_HALF_UP);
}
relaySalary = BigDecimalUtils.safeAdd(actualSalarySumNow, nowTaxY).setScale(SalaryConstants.PLACES, BigDecimal.ROUND_HALF_UP);
}
// 本次个人应发合计
TSalaryAccountItem sai = new TSalaryAccountItem();
sai.setCnName(SalaryConstants.RELAY_SALARY);
sai.setJavaFiedName(SalaryConstants.RELAY_SALARY_JAVA);
sai.setIsTax(CommonConstants.ZERO_INT);
sai.setSalaryMoney(relaySalary);
saiList.add(sai);
return nowTaxT;
}
public static BigDecimal getNowTax (BigDecimal actualSalarySum) {
BigDecimal nowTax;
// 2022-3-3 11:24:20 运营中心郭华照提供的公式:
// ROUND(IF(B7<=800,0,IF(B7<=3360,(B7-800)/4,IF(B7<=21000,0.16*B7/0.84,IF(B7<=49500,(0.24*B7-2000)/0.76,(0.32*B7-7000)/0.68)))),2)
if (actualSalarySum.compareTo(new BigDecimal("800")) <= 0) {
nowTax = BigDecimal.ZERO;
} else if (actualSalarySum.compareTo(new BigDecimal("3360")) <= 0) {
// (B7-800)/4
nowTax = BigDecimalUtils.safeDivide(BigDecimalUtils.safeSubtract(actualSalarySum, new BigDecimal("800"))
, new BigDecimal("4"));
} else if (actualSalarySum.compareTo(new BigDecimal("21000")) <= 0) {
// 0.16*B7/0.84
nowTax = BigDecimalUtils.safeDivide(BigDecimalUtils.safeMultiply(actualSalarySum, new BigDecimal("0.16"))
, new BigDecimal("0.84"));
} else if (actualSalarySum.compareTo(new BigDecimal("49500")) <= 0) {
// (0.24*B7-2000)/0.76
nowTax = BigDecimalUtils.safeDivide(BigDecimalUtils.safeSubtract(
BigDecimalUtils.safeMultiply(actualSalarySum, new BigDecimal("0.24")), new BigDecimal("2000"))
, new BigDecimal("0.76"));
} else {
nowTax = BigDecimalUtils.safeDivide(BigDecimalUtils.safeSubtract(
BigDecimalUtils.safeMultiply(actualSalarySum, new BigDecimal("0.32")), new BigDecimal("7000"))
, new BigDecimal("0.68"));
}
nowTax = nowTax.setScale(SalaryConstants.PLACES, BigDecimal.ROUND_HALF_UP);
return nowTax;
}
}
......@@ -25,6 +25,7 @@ import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.excel.util.ListUtils;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -241,6 +242,27 @@ public class TStatisticsLaborServiceImpl extends ServiceImpl<TStatisticsLaborMap
return null;
}
@Override
public R doStatisticsLabor() {
String nowMonth = DateUtil.addMonth(0); //本月
TStatisticsLabor std = new TStatisticsLabor();
std.setDeclareMonth(nowMonth);
QueryWrapper<TStatisticsLabor> queryWrapperSs = new QueryWrapper<>();
queryWrapperSs.setEntity(std);
long num = this.count(queryWrapperSs);
if (num > 0) {
return R.failed("上月数据已生成,不可重复生成!");
} else {
String lastMonth = DateUtil.addMonth(-1); //上月
String lastYear = lastMonth.substring(0,4);
List<TStatisticsLabor> stdvoList = baseMapper.doStatisticsLabor(nowMonth,lastYear);
for (TStatisticsLabor declarer : stdvoList) {
this.save(declarer);
}
return R.ok();
}
}
private void importTStatisticsLabor(List<TStatisticsLaborVo> excelVOList, List<ErrorMessage> errorMessageList) {
// 个性化校验逻辑
ErrorMessage errorMsg;
......
......@@ -296,9 +296,11 @@ public class SalaryAccountUtil implements Serializable {
entity.setIsRepeat(CommonConstants.ZERO_INT);
if (relaySalary != null) {
relaySalary = relaySalary.setScale(2, BigDecimal.ROUND_HALF_UP);
if (checkMap.get(entity.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING + DateUtil.addMonth(configSalary.getSalaryMonth())
+ CommonConstants.DOWN_LINE_STRING + salaryType + CommonConstants.DOWN_LINE_STRING + relaySalary) != null) {
entity.setIsRepeat(CommonConstants.ONE_INT);
if (checkMap.size() > CommonConstants.ZERO_INT) {
if (checkMap.get(entity.getEmpIdcard() + CommonConstants.DOWN_LINE_STRING + DateUtil.addMonth(configSalary.getSalaryMonth())
+ CommonConstants.DOWN_LINE_STRING + salaryType + CommonConstants.DOWN_LINE_STRING + relaySalary) != null) {
entity.setIsRepeat(CommonConstants.ONE_INT);
}
}
if (new BigDecimal("3500").compareTo(relaySalary) == CommonConstants.ZERO_INT
|| new BigDecimal("5000").compareTo(relaySalary) == CommonConstants.ZERO_INT) {
......
......@@ -29,7 +29,6 @@
<result property="declareMonth" column="DECLARE_MONTH"/>
<result property="empName" column="EMP_NAME"/>
<result property="empIdcard" column="EMP_IDCARD"/>
<result property="workNo" column="WORK_NO"/>
<result property="cardType" column="CARD_TYPE"/>
<result property="income" column="INCOME"/>
<result property="personalTax" column="PERSONAL_TAX"/>
......@@ -41,7 +40,6 @@
a.DECLARE_MONTH,
a.EMP_NAME,
a.EMP_IDCARD,
a.WORK_NO,
a.CARD_TYPE,
a.INCOME,
a.PERSONAL_TAX,
......@@ -64,9 +62,6 @@
<if test="tStatisticsLabor.empIdcard != null and tStatisticsLabor.empIdcard.trim() != ''">
AND a.EMP_IDCARD = #{tStatisticsLabor.empIdcard}
</if>
<if test="tStatisticsLabor.workNo != null and tStatisticsLabor.workNo.trim() != ''">
AND a.WORK_NO = #{tStatisticsLabor.workNo}
</if>
<if test="tStatisticsLabor.cardType != null and tStatisticsLabor.cardType.trim() != ''">
AND a.CARD_TYPE = #{tStatisticsLabor.cardType}
</if>
......@@ -93,4 +88,15 @@
group by a.EMP_IDCARD,a.DECLARE_MONTH,a.EMP_NAME
order by a.DECLARE_MONTH desc
</select>
<!--统计-->
<select id="doStatisticsLabor" resultMap="tStatisticsLaborMap">
select
#{nowMonth} DECLARE_MONTH,a.EMP_NAME,a.EMP_IDCARD,a.SALARY_TAX PERSONAL_TAX,a.ACTUAL_SALARY INCOME,
b.UNIT_NAME DECLARE_UNIT,'一般劳务报酬所得' INCOME_ITEM,'居民身份证' CARD_TYPE
from t_salary_account a
left join t_salary_employee b on b.id = a.EMP_ID
where a.DELETE_FLAG = 0 and a.SETTLEMENT_MONTH like '${lastYear}%'
GROUP BY a.EMP_IDCARD
</select>
</mapper>
......@@ -32,7 +32,6 @@
<result property="cardType" column="CARD_TYPE"/>
<result property="income" column="INCOME"/>
<result property="personalTax" column="PERSONAL_TAX"/>
<result property="workNo" column="WORK_NO"/>
</resultMap>
<sql id="Base_Column_List">
a.ID,
......@@ -42,8 +41,7 @@
a.EMP_IDCARD,
a.CARD_TYPE,
a.INCOME,
a.PERSONAL_TAX,
a.WORK_NO
a.PERSONAL_TAX
</sql>
<sql id="tStatisticsRemuneration_where">
<if test="tStatisticsRemuneration != null">
......@@ -71,9 +69,6 @@
<if test="tStatisticsRemuneration.personalTax != null">
AND a.PERSONAL_TAX = #{tStatisticsRemuneration.personalTax}
</if>
<if test="tStatisticsRemuneration.workNo != null and tStatisticsRemuneration.workNo.trim() != ''">
AND a.WORK_NO = #{tStatisticsRemuneration.workNo}
</if>
</if>
</sql>
<!--tStatisticsRemuneration简单分页查询-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment