申报表提示日期优化

This commit is contained in:
钱涛 2023-11-22 16:37:48 +08:00
parent f16f93fd43
commit e0f7ec3256
2 changed files with 18 additions and 9 deletions

View File

@ -189,7 +189,7 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration
if (CollectionUtils.isNotEmpty(taxDeclarationPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(107986, "{0}在{1}已经生成过个税申报表,不允许再次生成")
.replace("{0}", taxAgentNameMap.get(taxDeclarationPOS.get(0).getTaxAgentId()))
.replace("{1}", saveParam.getSalaryMonth().toString()));
.replace("{1}", SalaryDateUtil.getFormatYearMonth(saveParam.getSalaryMonth())));
}
// 查询薪资所属月的薪资核算记录
List<SalaryAcctRecordPO> salaryAcctRecordPOS = listBySalaryMonth(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).build());
@ -204,7 +204,7 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration
// 无薪资核算结果不允许生成个税申报表
if (CollectionUtils.isEmpty(salaryAcctResultPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(110093, "{0}无可申报数据")
.replace("{0}", saveParam.getSalaryMonth().toString()));
.replace("{0}", SalaryDateUtil.getFormatYearMonth(saveParam.getSalaryMonth())));
}
Set<Long> salaryAcctRecordIds = SalaryEntityUtil.properties(salaryAcctResultPOS, SalaryAcctResultPO::getSalaryAcctRecordId);
@ -213,14 +213,14 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration
boolean notArchived = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> Objects.equals(salaryAcctRecordPO.getStatus(), SalaryAcctRecordStatusEnum.NOT_ARCHIVED.getValue()));
if (notArchived) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98875, "{0}有未归档数据,请全部归档后再申报")
.replace("{0}", saveParam.getSalaryMonth().toString()));
.replace("{0}", SalaryDateUtil.getFormatYearMonth(saveParam.getSalaryMonth())));
}
// 如果当前薪资所属月下存在不同的税款所属期属于异常业务场景不允许生成个税申报表
Date taxCycle = salaryAcctRecordPOS.get(0).getTaxCycle();
boolean differentTaxCycle = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> salaryAcctRecordPO.getTaxCycle().compareTo(taxCycle) != 0);
if (differentTaxCycle) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98876, "{0}存在不同的税款所属期,无法正常生成个税申报表,请调整账套设置,重新核算后再生成个税申报表")
.replace("{0}", saveParam.getSalaryMonth().toString()));
.replace("{0}", SalaryDateUtil.getFormatYearMonth(saveParam.getSalaryMonth())));
}
// 查询薪资账套
Set<Long> salarySobIds = SalaryEntityUtil.properties(salaryAcctRecordPOS, SalaryAcctRecordPO::getSalarySobId);

View File

@ -103,6 +103,14 @@ public class SalaryDateUtil {
}
}
public static String getFormatYearMonth(YearMonth localDate) {
if (localDate == null) {
return StringUtils.EMPTY;
}
return localDate.format(DateTimeFormatter.ofPattern("yyyy-MM"));
}
public static String getFormatLocalDate(LocalDate localDate) {
if (localDate == null) {
return StringUtils.EMPTY;
@ -224,7 +232,7 @@ public class SalaryDateUtil {
Calendar c = Calendar.getInstance();
c.setTime(localDate);
int year = c.get(Calendar.YEAR);
return year ;
return year;
}
public static LocalDateRange localDate2Range(Date localDate) {
@ -254,6 +262,7 @@ 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);
@ -291,8 +300,6 @@ public class SalaryDateUtil {
}
public static String getMonthBegin(String specifiedDay) {
int year;
int month;
@ -563,9 +570,10 @@ public class SalaryDateUtil {
/**
* 转换时间对象
* @see SalaryDateUtil#toDate(LocalDateTime, String)
*
* @param dateTime LocalDateTime
* @return Date
* @see SalaryDateUtil#toDate(LocalDateTime, String)
*/
public static Date toDate(LocalDateTime dateTime) {
return toDate(dateTime, null);
@ -574,8 +582,9 @@ public class SalaryDateUtil {
/**
* 转换时间对象
*
* @param dateTime LocalDateTime
* @param offset 时区e.g. +8
* @param offset 时区e.g. +8
* @return Date
*/
public static Date toDate(LocalDateTime dateTime, String offset) {