个税申报功能-重启

This commit is contained in:
Harryxzy 2022-11-10 09:46:30 +08:00
parent 775580f994
commit 3d4be3265e
6 changed files with 151 additions and 24 deletions

View File

@ -2,6 +2,7 @@ package com.engine.salary.mapper.sys;
import com.engine.salary.sys.entity.po.SalarySysConfPO;
import java.util.Date;
import java.util.List;
public interface SalarySysConfMapper {
@ -64,4 +65,12 @@ public interface SalarySysConfMapper {
SalarySysConfPO getOneByCode(String confKey);
int countByCode(String confKey);
/**
* @description 获取个税申报功能重启时间
* @return Date
* @author Harryxzy
* @date 2022/11/9 21:09
*/
Date getTaxDeclarationRebootDate();
}

View File

@ -233,5 +233,8 @@
WHERE delete_type = 0
AND conf_key = #{confKey}
</select>
<select id="getTaxDeclarationRebootDate" resultType="java.util.Date">
select update_time from HRSA_SALARY_SYS_CONF WHERE conf_key = 'taxDeclarationFunction'
</select>
</mapper>

View File

@ -16,6 +16,7 @@ import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salaryacct.SalaryAcctRecordMapper;
import com.engine.salary.service.*;
import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum;
import com.engine.salary.sys.service.SalarySysConfService;
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
import com.engine.salary.util.SalaryDateUtil;
@ -303,9 +304,10 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
//获取账套下的所有核算结果
List<SalaryAcctRecordPO> salaryAcctRecords = listByTaxCycle(taxCycleYearRange,salarySobIds);
// 是否关闭个税申报功能
Boolean haveClosedTaxDeclaration = getSalarySysConfService(user).haveClosedTaxDeclaration();
if(haveClosedTaxDeclaration){
// 获取个税申报功能状态
TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration();
if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.CLOSURE.getValue())){
// 关闭了个税申报功能
// 如果某个月薪资所属期还未归档不可以新建之后月份的薪资核算
SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
@ -330,7 +332,8 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
.replace("{1}",salarySobCycleDTO.getSalaryMonth().toString()));
}
}else {
}
if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())){
// 开启了个税申报功能
// 如果某个月税款所属期已经归档了不可以新建之前月份的薪资核算
SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
@ -366,6 +369,67 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
}
if(taxDeclarationFunctionEnum.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())){
// 重启了个税申报功能不去校验重启之前是否申报数据
// 如果某个月薪资所属期还未归档不可以新建之后月份的薪资核算
SalaryAcctRecordPO notArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue())
&& e.getSalaryMonth().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getSalaryMonth().atDay(1))))
.findAny()
.orElse(null);
if(Objects.nonNull(notArchivedSalaryAcctRecordPO)){
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98754, "薪资所属期{0}的薪资核算结果还未归档,不能新建薪资所属期{1}的薪资核算")
.replace("{0}",SalaryDateUtil.localDate2YearMonth(notArchivedSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}",salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果某个月税款所属期已经归档了不可以新建之前月份的薪资核算
SalaryAcctRecordPO hasArchivedSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.ARCHIVED.getValue())
&& e.getTaxCycle().after(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))))
.findAny()
.orElse(null);
if (Objects.nonNull(hasArchivedSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98752, "税款所属期{0}的薪资核算结果已经归档,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(hasArchivedSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果某个月税款所属期还未申报不可以新建之后月份的薪资核算
//获取账套下从重启月至所在年的最后一天的所有核算结果
Date taxDeclarationRebootDate = getSalarySysConfService(user).getTaxDeclarationRebootDate();
if(taxDeclarationRebootDate == null){
throw new SalaryRunTimeException("个税申报功能异常");
}
LocalDateRange taxCycleRebootYearRange = LocalDateRange.builder()
.fromDate(SalaryDateUtil.getFirstDayDateOfMonthWithMinutesAndSeconds(taxDeclarationRebootDate))
.endDate(SalaryDateUtil.getLastDayOfYearWithMinutesAndSeconds(taxDeclarationRebootDate))
.build();
List<SalaryAcctRecordPO> salaryAcctRebootRecords = listByTaxCycle(taxCycleRebootYearRange,salarySobIds);
SalaryAcctRecordPO notDeclaredSalaryAcctRecordPO = salaryAcctRebootRecords.stream()
.filter(e -> !Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())
&& e.getTaxCycle().before(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))))
.findAny()
.orElse(null);
if (Objects.nonNull(notDeclaredSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98751, "税款所属期{0}的薪资核算结果还未申报,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(notDeclaredSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
// 如果某个月税款所属期已经申报了不可以新建本月以及之前月份的薪资核算
SalaryAcctRecordPO hasDeclaredSalaryAcctRecordPO = salaryAcctRecords.stream()
.filter(e -> Objects.equals(e.getStatus(), SalaryAcctRecordStatusEnum.DECLARED.getValue())
&& e.getTaxCycle().compareTo(SalaryDateUtil.localDateToDate(salarySobCycleDTO.getTaxCycle().atDay(1))) >= 0)
.findAny()
.orElse(null);
if (Objects.nonNull(hasDeclaredSalaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98753, "税款所属期{0}的薪资核算结果已经申报,不能新建税款所属期{1}的薪资核算")
.replace("{0}", SalaryDateUtil.localDate2YearMonth(hasDeclaredSalaryAcctRecordPO.getTaxCycle()).toString())
.replace("{1}", salarySobCycleDTO.getTaxCycle().toString()));
}
}
}
@ -512,11 +576,21 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
}
//撤回工资单
getSalarySendService(user).revokeSalaryBill(salaryAcctRecordId);
Boolean haveClosedTaxDeclaration = getSalarySysConfService(user).haveClosedTaxDeclaration();
if(!haveClosedTaxDeclaration){
TaxDeclarationFunctionEnum taxDeclaration = getSalarySysConfService(user).getTaxDeclaration();
if(taxDeclaration.getValue().equals(TaxDeclarationFunctionEnum.OPEN.getValue())){
// 开启了个税申报功能
// 删除个税申报表(个税申报表个税申报表详情往期累计情况)
getTaxDeclarationService(user).delete(salaryAcctRecordPO);
}else if(taxDeclaration.getValue().equals(TaxDeclarationFunctionEnum.REBOOT.getValue())){
// 重启个税申报功能
Date taxDeclarationRebootDateTemp = getSalarySysConfService(user).getTaxDeclarationRebootDate();
Date taxDeclarationRebootDate = SalaryDateUtil.getFirstDayDateOfMonthWithMinutesAndSeconds(taxDeclarationRebootDateTemp);
if(!taxDeclarationRebootDate.after(salaryAcctRecordPO.getTaxCycle())){
// 删除个税申报表(个税申报表个税申报表详情往期累计情况)
getTaxDeclarationService(user).delete(salaryAcctRecordPO);
}
}
// 更新薪资核算记录的状态
salaryAcctRecordPO.setStatus(SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue());

View File

@ -7,6 +7,7 @@ import com.engine.salary.sys.entity.vo.AppSettingVO;
import com.engine.salary.sys.entity.vo.OrderRuleVO;
import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -33,7 +34,7 @@ public interface SalarySysConfService {
* 是否关闭了个税申报功能
* @return BOOLEAN
*/
public Boolean haveClosedTaxDeclaration();
TaxDeclarationFunctionEnum getTaxDeclaration();
SalarySysConfPO getOneByCode(String code);
@ -74,4 +75,12 @@ public interface SalarySysConfService {
Map<String, Object> saveEncryptSetting(AppSettingSaveParam appSettingSaveParam);
Map<String, Object> getEncryptProgress(String progressId);
/**
* @description 获取个税申报功能重启日期
* @return Date
* @author Harryxzy
* @date 2022/11/9 21:07
*/
Date getTaxDeclarationRebootDate();
}

View File

@ -149,15 +149,15 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
return true;
}
//关闭
if (flag == TaxDeclarationFunctionEnum.CLOSURE) {
if (flag == TaxDeclarationFunctionEnum.CLOSURE || flag == TaxDeclarationFunctionEnum.OPEN) {
taxDeclarationFunction.setConfValue(flag.getValue());
taxDeclarationFunction.setTitle(flag.getDefaultLabel());
taxDeclarationFunction.setUpdateTime(new Date());
}
//重启
//重启 (从关闭到开启)
if (flag == TaxDeclarationFunctionEnum.OPEN && oldFunctionEnum == TaxDeclarationFunctionEnum.CLOSURE) {
taxDeclarationFunction.setConfValue(flag.getValue());
taxDeclarationFunction.setTitle(flag.getDefaultLabel());
taxDeclarationFunction.setConfValue(TaxDeclarationFunctionEnum.REBOOT.getValue());
taxDeclarationFunction.setTitle(TaxDeclarationFunctionEnum.REBOOT.getDefaultLabel());
taxDeclarationFunction.setUpdateTime(new Date());
}
getSalarySysConfMapper().updateIgnoreNull(taxDeclarationFunction);
@ -166,18 +166,19 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
}
/**
* @description 是否关闭需要申报功能
* @description 获取申报功能状态
* @return Boolean
* @author Harryxzy
* @date 2022/11/7 17:05
*/
public Boolean haveClosedTaxDeclaration(){
public TaxDeclarationFunctionEnum getTaxDeclaration(){
SalarySysConfPO taxDeclarationFunction = salarySysConfService.getOneByCode(TAX_DECLARATION_FUNCTION);
if(taxDeclarationFunction != null && taxDeclarationFunction.getConfValue().equals(TaxDeclarationFunctionEnum.CLOSURE.getValue())){
// 关闭
return true;
if(taxDeclarationFunction == null){
// 默认开启
return TaxDeclarationFunctionEnum.OPEN;
}
return false;
TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = TaxDeclarationFunctionEnum.parseByValue(taxDeclarationFunction.getConfValue());
return taxDeclarationFunctionEnum;
}
@ -380,6 +381,12 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
return resultMap;
}
@Override
public Date getTaxDeclarationRebootDate() {
Date date = getSalarySysConfMapper().getTaxDeclarationRebootDate();
return date;
}
/**
* 保存或者修改应用设置
*
@ -426,22 +433,23 @@ public class SalarySysConfServiceImpl extends Service implements SalarySysConfSe
case OPEN_APPLICATION_ENCRYPT:
appSettingVO.setIsOpenEncrypt(salarySysConfPO.getConfValue());
break;
case TAX_DECLARATION_FUNCTION:
appSettingVO.setIsOpenTaxDeclaration(salarySysConfPO.getConfValue());
break;
default:
break;
}
});
}
List<SalarySysConfPO> taxDeclarationFunction = getSalarySysConfMapper().listSome(SalarySysConfPO.builder().deleteType(0).confKey(TAX_DECLARATION_FUNCTION).build());
if(taxDeclarationFunction == null || taxDeclarationFunction.size() == 0){
// 默认开启报税功能
appSettingVO.setIsOpenTaxDeclaration("1");
}else{
appSettingVO.setIsOpenTaxDeclaration(taxDeclarationFunction.get(0).getConfValue());
}
//默认加密开启
if (StringUtils.isEmpty(appSettingVO.getIsOpenEncrypt())) {
appSettingVO.setIsOpenEncrypt("1");
}
// 默认开启报税功能
if(StringUtils.isEmpty(appSettingVO.getIsOpenTaxDeclaration())){
appSettingVO.setIsOpenTaxDeclaration("1");
}
return appSettingVO;
}

View File

@ -240,6 +240,17 @@ public class SalaryDateUtil {
cal.set(Calendar.DAY_OF_MONTH, last);
return cal.getTime();
}
public static Date getFirstDayDateOfMonthWithMinutesAndSeconds(final Date date) {
final Calendar cal = Calendar.getInstance();
cal.setTime(date);
final int last = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, last);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
public static Date getLastDayOfMonth(final Date date) {
final Calendar cal = Calendar.getInstance();
@ -265,6 +276,19 @@ public class SalaryDateUtil {
return cal.getTime();
}
public static Date getLastDayOfYearWithMinutesAndSeconds(final Date date) {
final Calendar cal = Calendar.getInstance();
cal.setTime(date);
final int last = cal.getActualMaximum(Calendar.DAY_OF_YEAR);
cal.set(Calendar.DAY_OF_YEAR, last);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
public static String getMonthBegin(String specifiedDay) {
int year;
int month;