Commit 4fe06fa0 authored by fangxinjiang's avatar fangxinjiang

Merge remote-tracking branch 'origin/MVP1.7.23' into MVP1.7.23

parents af60df30 1e138bff
...@@ -1627,6 +1627,35 @@ public class DateUtil { ...@@ -1627,6 +1627,35 @@ public class DateUtil {
return new BigDecimal(0); return new BigDecimal(0);
} }
/**
* 根据计税年月返回个税扣除额
* @param taxYearMonth 计税月
* @param settleMonth 结算月
* @return
*/
public static BigDecimal getTaxMonthMoneyBySettleMonth(String taxYearMonth, String settleMonth) {
try {
int taxYear = Integer.parseInt(taxYearMonth.substring(0, 4));
int taxMonth = Integer.parseInt(taxYearMonth.substring(4, 6));
int nowYear = Integer.parseInt(settleMonth.substring(0, 4));
int nowMonth = Integer.parseInt(settleMonth.substring(4, 6));
// 同一个计税年
if (nowYear - taxYear == 0) {
return new BigDecimal((nowMonth - taxMonth + 1) * 5000);
// 前一个计税年
} else if (nowYear - taxYear > 0) {
// 禅道461:王成说的。
return new BigDecimal((nowMonth) * 5000);
} else {
// 比当前年还大
return new BigDecimal(0);
}
} catch (Exception e) {
log.error("getTaxMonthMoneyBySettleMonth",e);
}
return new BigDecimal(0);
}
/** /**
* <p>Description: 返回最大值月份</p> * <p>Description: 返回最大值月份</p>
* @author hgw * @author hgw
......
...@@ -186,7 +186,6 @@ public class TSalaryEmployee extends BaseEntity { ...@@ -186,7 +186,6 @@ public class TSalaryEmployee extends BaseEntity {
@Length(max = 6, message = "计税月份不能超过6个字符") @Length(max = 6, message = "计税月份不能超过6个字符")
@HeadFontStyle(fontHeightInPoints = 11) @HeadFontStyle(fontHeightInPoints = 11)
@ExcelProperty("计税月份") @ExcelProperty("计税月份")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private String taxMonth; private String taxMonth;
/** /**
* 在职状态(0在职;1离职) * 在职状态(0在职;1离职)
......
...@@ -82,22 +82,5 @@ public class TSalaryZeroVo extends RowIndex implements Serializable { ...@@ -82,22 +82,5 @@ public class TSalaryZeroVo extends RowIndex implements Serializable {
@Schema(description = "项目编码") @Schema(description = "项目编码")
@ExcelProperty("项目编码") @ExcelProperty("项目编码")
private String deptNo; private String deptNo;
/**
* 减除费用
*/
@NotNull(message = "减除费用不能为空")
@ExcelAttribute(name = "减除费用", isNotEmpty = true, errorInfo = "减除费用不能为空")
@Schema(description = "减除费用")
@ExcelProperty("减除费用")
private String costReduction;
/**
* 计税月份
*/
@NotBlank(message = "计税月份 不能为空")
@Length(max = 6, message = "计税月份 不能超过6 个字符")
@ExcelAttribute(name = "计税月份", isNotEmpty = true, errorInfo = "计税月份 不能为空", maxLength = 6)
@Schema(description = "计税月份")
@ExcelProperty("计税月份")
private String taxMonth;
} }
...@@ -309,6 +309,9 @@ public interface TSalaryAccountMapper extends BaseMapper<TSalaryAccount> { ...@@ -309,6 +309,9 @@ public interface TSalaryAccountMapper extends BaseMapper<TSalaryAccount> {
List<KeyMoneyVo> getTaxMonthToAll(@Param("deptNo") String deptNo, @Param("invoiceTitle") String invoiceTitle List<KeyMoneyVo> getTaxMonthToAll(@Param("deptNo") String deptNo, @Param("invoiceTitle") String invoiceTitle
, @Param("tableName") String tableName, @Param("lastSettleMonth") String lastSettleMonth); , @Param("tableName") String tableName, @Param("lastSettleMonth") String lastSettleMonth);
List<KeyMoneyVo> getTaxMonthByCard(@Param("cardList") List<String> cardList, @Param("invoiceTitle") String invoiceTitle
, @Param("tableName") String tableName, @Param("lastSettleMonth") String lastSettleMonth);
String getTaxMonthToCard(@Param("idCard") String idCard, @Param("invoiceTitle") String invoiceTitle String getTaxMonthToCard(@Param("idCard") String idCard, @Param("invoiceTitle") String invoiceTitle
, @Param("tableName") String tableName, @Param("lastSettleMonth") String lastSettleMonth); , @Param("tableName") String tableName, @Param("lastSettleMonth") String lastSettleMonth);
......
...@@ -257,8 +257,10 @@ public interface TSalaryAccountService extends IService<TSalaryAccount> { ...@@ -257,8 +257,10 @@ public interface TSalaryAccountService extends IService<TSalaryAccount> {
**/ **/
List<TSalaryAccount> getIdCardListBySalaryId(String salaryId); List<TSalaryAccount> getIdCardListBySalaryId(String salaryId);
// 获取上月减除费用,按项目 // 获取上月计税月,按项目
Map<String, String> getTaxMonthToAll(String deptNo, String invoiceTitle); Map<String, String> getTaxMonthToAll(String deptNo, String invoiceTitle);
// 获取上月计税月,按身份证
Map<String, String> getTaxMonthByCard(String settleMonth, String invoiceTitle, List<String> cardList);
// 获取上月减除费用,单个身份证的 // 获取上月减除费用,单个身份证的
String getTaxMonthToCard(String idCard, String invoiceTitle); String getTaxMonthToCard(String idCard, String invoiceTitle);
......
...@@ -1031,17 +1031,18 @@ public class TSalaryAccountServiceImpl extends ServiceImpl<TSalaryAccountMapper, ...@@ -1031,17 +1031,18 @@ public class TSalaryAccountServiceImpl extends ServiceImpl<TSalaryAccountMapper,
return baseMapper.getIdCardListBySalaryId(salaryId); return baseMapper.getIdCardListBySalaryId(salaryId);
} }
private String getTableName() { private String getTableName(String lastSettleMonth) {
LocalDateTime now = LocalDateTime.now(); if (Common.isEmpty(lastSettleMonth) || lastSettleMonth.length() < 4) {
int year = now.getYear(); lastSettleMonth = DateUtil.addMonth(-1);
return SalaryConstants.TABLE_NAME_PRE + year; }
return SalaryConstants.TABLE_NAME_PRE + lastSettleMonth.substring(0,4);
} }
// 获取上月减除费用,按项目 // 获取上月减除费用,按项目
@Override @Override
public Map<String, String> getTaxMonthToAll(String deptNo, String invoiceTitle) { public Map<String, String> getTaxMonthToAll(String deptNo, String invoiceTitle) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
String tableName = getTableName();
String lastSettleMonth = DateUtil.addMonth(-1); String lastSettleMonth = DateUtil.addMonth(-1);
String tableName = getTableName(lastSettleMonth);
List<KeyMoneyVo> list = baseMapper.getTaxMonthToAll(deptNo, invoiceTitle, tableName, lastSettleMonth); List<KeyMoneyVo> list = baseMapper.getTaxMonthToAll(deptNo, invoiceTitle, tableName, lastSettleMonth);
if (Common.isNotNull(list)) { if (Common.isNotNull(list)) {
for (KeyMoneyVo vo : list) { for (KeyMoneyVo vo : list) {
...@@ -1050,12 +1051,26 @@ public class TSalaryAccountServiceImpl extends ServiceImpl<TSalaryAccountMapper, ...@@ -1050,12 +1051,26 @@ public class TSalaryAccountServiceImpl extends ServiceImpl<TSalaryAccountMapper,
} }
return map; return map;
} }
// 获取结算月对应的上月的计税月,按身份证
@Override
public Map<String, String> getTaxMonthByCard(String settleMonth, String invoiceTitle, List<String> cardList) {
Map<String, String> map = new HashMap<>();
String lastSettleMonth = DateUtil.addMonthByString(settleMonth,-1);
String tableName = getTableName(lastSettleMonth);
List<KeyMoneyVo> list = baseMapper.getTaxMonthByCard(cardList, invoiceTitle, tableName, lastSettleMonth);
if (Common.isNotNull(list)) {
for (KeyMoneyVo vo : list) {
map.put(vo.getKeyValue(), vo.getTextValue());
}
}
return map;
}
// 获取上月减除费用,单个身份证的 // 获取上月减除费用,单个身份证的
@Override @Override
public String getTaxMonthToCard(String idCard, String invoiceTitle) { public String getTaxMonthToCard(String idCard, String invoiceTitle) {
String tableName = getTableName();
String lastSettleMonth = DateUtil.addMonth(-1); String lastSettleMonth = DateUtil.addMonth(-1);
String tableName = getTableName(lastSettleMonth);
return baseMapper.getTaxMonthToCard(idCard, invoiceTitle, tableName, lastSettleMonth); return baseMapper.getTaxMonthToCard(idCard, invoiceTitle, tableName, lastSettleMonth);
} }
......
...@@ -1016,7 +1016,7 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe ...@@ -1016,7 +1016,7 @@ public class TSalaryEmployeeServiceImpl extends ServiceImpl<TSalaryEmployeeMappe
} }
// 变更日志 fxj 2023-10-24 // 变更日志 fxj 2023-10-24
logService.initModLog(old,emp,CommonConstants.ONE_STRING,user.getNickname(),util); logService.initModLog(emp,old,CommonConstants.ONE_STRING,user.getNickname(),util);
baseMapper.updateById(emp); baseMapper.updateById(emp);
/*if (curTaxMonth) { /*if (curTaxMonth) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), SalaryConstants.CUR_TAX_INFO)); errorMessageList.add(new ErrorMessage(excel.getRowIndex(), SalaryConstants.CUR_TAX_INFO));
......
...@@ -394,12 +394,14 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala ...@@ -394,12 +394,14 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala
if (rowCount <= MAX_ROWS && cachedDataList != null && !cachedDataList.isEmpty()) { if (rowCount <= MAX_ROWS && cachedDataList != null && !cachedDataList.isEmpty()) {
// 获取项目编码数据 以供校验 // 获取项目编码数据 以供校验
Map<String, ProjectSetInfoVo> projectVoMap = getProjectVoMap(codeList); Map<String, ProjectSetInfoVo> projectVoMap = getProjectVoMap(codeList);
// 1.7.23版本改造为获取上月计税月
Map<String, String> taxMonthMap = getTaxMonthMap(cardList);
Map<String, Integer> accountMap = getAccountMap(cardList); Map<String, Integer> accountMap = getAccountMap(cardList);
Map<String, Boolean> idCardMap = getCardMap(checkList); Map<String, Boolean> idCardMap = getCardMap(checkList);
Map<String, Boolean> phoneMap = getPhoneMap(phoneList); Map<String, Boolean> phoneMap = getPhoneMap(phoneList);
Map<String, Integer> zeroMap = getZeroMap(cardList); Map<String, Integer> zeroMap = getZeroMap(cardList);
importTSalaryZero(cachedDataList, errorMessageList, settleMonth, invoiceTitle, nickName, projectVoMap importTSalaryZero(cachedDataList, errorMessageList, settleMonth, invoiceTitle, nickName, projectVoMap
, accountMap, idCardMap, phoneMap, zeroMap); , accountMap, idCardMap, phoneMap, zeroMap, taxMonthMap);
} }
} }
...@@ -417,6 +419,11 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala ...@@ -417,6 +419,11 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala
return salaryAccountService.getAccountMapByKey(invoiceTitle, settleMonth, cardList); return salaryAccountService.getAccountMapByKey(invoiceTitle, settleMonth, cardList);
} }
// 获取报账信息等
private Map<String, String> getTaxMonthMap(List<String> cardList) {
return salaryAccountService.getTaxMonthByCard(settleMonth, invoiceTitle, cardList);
}
// 获取0申报表在用的信息等 // 获取0申报表在用的信息等
private Map<String, Integer> getZeroMap(List<String> cardList) { private Map<String, Integer> getZeroMap(List<String> cardList) {
Map<String, Integer> zeroMap = new HashMap<>(); Map<String, Integer> zeroMap = new HashMap<>();
...@@ -476,7 +483,7 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala ...@@ -476,7 +483,7 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala
private void importTSalaryZero(List<TSalaryZeroVo> excelVOList, List<ErrorMessage> errorMessageList private void importTSalaryZero(List<TSalaryZeroVo> excelVOList, List<ErrorMessage> errorMessageList
, String settleMonth, String invoiceTitle, String userName, Map<String, ProjectSetInfoVo> projectVoMap , String settleMonth, String invoiceTitle, String userName, Map<String, ProjectSetInfoVo> projectVoMap
, Map<String, Integer> accountMap, Map<String, Boolean> idCardMap, Map<String, Boolean> phoneMap , Map<String, Integer> accountMap, Map<String, Boolean> idCardMap, Map<String, Boolean> phoneMap
, Map<String, Integer> zeroMap) { , Map<String, Integer> zeroMap, Map<String, String> taxMonthMap) {
String tableName = getSalaryTableName(settleMonth.substring(0, 4)); String tableName = getSalaryTableName(settleMonth.substring(0, 4));
if (Common.isEmpty(tableName)) { if (Common.isEmpty(tableName)) {
...@@ -501,85 +508,76 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala ...@@ -501,85 +508,76 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala
} }
String idCard; String idCard;
Boolean resultB; Boolean resultB;
BigDecimal costReduction; String taxMonth;
for (int i = 0; i < excelVOList.size(); i++) { for (int i = 0; i < excelVOList.size(); i++) {
excel = excelVOList.get(i); excel = excelVOList.get(i);
if (Common.isNotNull(excel.getCostReduction())) { if (Common.isNotNull(excel.getDeptNo()) && projectVoMap.get(excel.getDeptNo()) != null) {
try { if (accountMap.get(excel.getEmpIdcard()) != null) {
costReduction = new BigDecimal(excel.getCostReduction()); errorMessageList.add(new ErrorMessage(excel.getRowIndex(), SalaryConstants.HAVE_ACCOUNT, excel));
} catch (Exception e) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), SalaryConstants.MONEY_NUM_ERROR, excel));
continue;
}
if (costReduction.compareTo(SalaryConstants.COST_MONEY) < CommonConstants.ZERO_INT
|| costReduction.compareTo(SalaryConstants.MAX_COST_MONEY) > CommonConstants.ZERO_INT
|| costReduction.remainder(SalaryConstants.COST_MONEY).compareTo(BigDecimal.ZERO) != 0) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), SalaryConstants.MONEY_ERROR, excel));
} else { } else {
if (Common.isNotNull(excel.getDeptNo()) && projectVoMap.get(excel.getDeptNo()) != null) { if (zeroMap.get(excel.getEmpIdcard()) != null) {
if (accountMap.get(excel.getEmpIdcard()) != null) { errorMessageList.add(new ErrorMessage(excel.getRowIndex(), SalaryConstants.HAVE_ZERO, excel));
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), SalaryConstants.HAVE_ACCOUNT, excel)); } else {
} else { idCard = excel.getEmpIdcard();
if (zeroMap.get(excel.getEmpIdcard()) != null) { if (idCardFlag == 0) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), SalaryConstants.HAVE_ZERO, excel)); if (Common.isNotNull(idCard)) {
} else { resultB = idCardMap.get(idCard + CommonConstants.DOWN_LINE_STRING + excel.getEmpName());
idCard = excel.getEmpIdcard();
if (idCardFlag == 0) {
if (Common.isNotNull(idCard)) {
resultB = idCardMap.get(idCard + CommonConstants.DOWN_LINE_STRING + excel.getEmpName());
if (resultB != null) {
if (Boolean.FALSE.equals(resultB)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "姓名&身份证号不一致,请检查并修改后重新导入", excel));
continue;
}
} else {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "姓名&身份证号不一致,请检查并修改后重新导入!", excel));
continue;
}
}
} else if (idCardFlag == 2) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "姓名&身份证号不一致,请检查并修改后重新导入!!", excel));
continue;
}
resultB = phoneMap.get(excel.getEmpPhone());
if (resultB != null) { if (resultB != null) {
if (Boolean.FALSE.equals(resultB)) { if (Boolean.FALSE.equals(resultB)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "手机号校验不通过,请更改手机号后重试", excel)); errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "姓名&身份证号不一致,请检查并修改后重新导入", excel));
continue; continue;
} }
} else { } else {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "手机号校验不通过,请更改手机号后重试!", excel)); errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "姓名&身份证号不一致,请检查并修改后重新导入!", excel));
continue; continue;
} }
if (judgeTaxMonth(excel.getTaxMonth())) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "计税月份格式不正确!", excel));
continue;
}
insert = new TSalaryZero();
BeanUtil.copyProperties(excel, insert);
insert.setSettleMonth(settleMonth);
insert.setInvoiceTitle(invoiceTitle);
insert.setDataSource(CommonConstants.THREE_STRING);
insert.setImporterName(userName);
insert.setCreateTime(now);
dept = projectVoMap.get(excel.getDeptNo());
if (dept != null) {
insert.setDeptId(dept.getId());
insert.setDeptName(dept.getDepartName());
insert.setDeleteFlag(CommonConstants.ZERO_INT);
insertList.add(insert);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), CommonConstants.SAVE_SUCCESS, excel));
} else {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), SalaryConstants.DEPT_ERROR, excel));
}
} }
} else if (idCardFlag == 2) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "姓名&身份证号不一致,请检查并修改后重新导入!!", excel));
continue;
} }
} else { resultB = phoneMap.get(excel.getEmpPhone());
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), SalaryConstants.DEPT_ERROR, excel)); if (resultB != null) {
if (Boolean.FALSE.equals(resultB)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "手机号校验不通过,请更改手机号后重试", excel));
continue;
}
} else {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "手机号校验不通过,请更改手机号后重试!", excel));
continue;
}
insert = new TSalaryZero();
BeanUtil.copyProperties(excel, insert);
// 1.7.23新计税月(找上月,没找到就是结算月
taxMonth = taxMonthMap.get(idCard);
if (taxMonth == null) {
taxMonth = settleMonth;
}
insert.setTaxMonth(taxMonth);
// 1.7.23新计算减除费用
insert.setCostReduction(DateUtil.getTaxMonthMoneyBySettleMonth(taxMonth, settleMonth));
insert.setSettleMonth(settleMonth);
insert.setInvoiceTitle(invoiceTitle);
insert.setDataSource(CommonConstants.THREE_STRING);
insert.setImporterName(userName);
insert.setCreateTime(now);
dept = projectVoMap.get(excel.getDeptNo());
if (dept != null) {
insert.setDeptId(dept.getId());
insert.setDeptName(dept.getDepartName());
insert.setDeleteFlag(CommonConstants.ZERO_INT);
insertList.add(insert);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), CommonConstants.SAVE_SUCCESS, excel));
} else {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), SalaryConstants.DEPT_ERROR, excel));
}
} }
} }
} else {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), SalaryConstants.DEPT_ERROR, excel));
} }
} }
if (!insertList.isEmpty()) { if (!insertList.isEmpty()) {
...@@ -587,21 +585,6 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala ...@@ -587,21 +585,6 @@ public class TSalaryZeroServiceImpl extends ServiceImpl<TSalaryZeroMapper, TSala
} }
} }
// 返回false则对
private boolean judgeTaxMonth(String taxMonth) {
if (Common.isEmpty(taxMonth)) {
return true;
}
if (taxMonth.length() > CommonConstants.dingleDigitIntArray[6]) {
taxMonth = taxMonth.substring(0, 6);
} else if (taxMonth.length() < CommonConstants.dingleDigitIntArray[6]) {
return true;
}
if (DateUtil.compareYearMonth(taxMonth, DateUtil.addMonth(0))) {
return true;
}
return false;
}
// 批量新增0申报 // 批量新增0申报
public void saveBatchWithTableName(List<TSalaryZero> insertList, String tableName) { public void saveBatchWithTableName(List<TSalaryZero> insertList, String tableName) {
if (insertList == null || insertList.isEmpty()) { if (insertList == null || insertList.isEmpty()) {
......
...@@ -2188,7 +2188,7 @@ ...@@ -2188,7 +2188,7 @@
where a.DELETE_FLAG = 0 and a.SALARY_FORM_ID = #{salaryId} where a.DELETE_FLAG = 0 and a.SALARY_FORM_ID = #{salaryId}
</select> </select>
<!-- 获取减除费用 --> <!-- 获取计税月,根据项目编码 -->
<select id="getTaxMonthToAll" resultType="com.yifu.cloud.plus.v1.yifu.salary.vo.KeyMoneyVo"> <select id="getTaxMonthToAll" resultType="com.yifu.cloud.plus.v1.yifu.salary.vo.KeyMoneyVo">
select a.keyValue,a.textValue from ( select a.keyValue,a.textValue from (
SELECT SELECT
...@@ -2205,6 +2205,31 @@ ...@@ -2205,6 +2205,31 @@
) a GROUP BY a.keyValue ) a GROUP BY a.keyValue
</select> </select>
<!-- 获取计税月,根据身份证 -->
<select id="getTaxMonthByCard" resultType="com.yifu.cloud.plus.v1.yifu.salary.vo.KeyMoneyVo">
select a.keyValue,a.textValue from (
SELECT
a.EMP_IDCARD as keyValue,
a.tax_month as textValue
FROM t_salary_account a
where a.DELETE_FLAG = 0 and a.INVOICE_TITLE = #{invoiceTitle} and a.SETTLEMENT_MONTH = #{lastSettleMonth}
and a.EMP_IDCARD in
<foreach item="idStr" index="index" collection="cardList" open="(" separator="," close=")">
#{idStr}
</foreach>
union all
SELECT
a.EMP_IDCARD as keyValue,
a.tax_month as textValue
FROM ${tableName} a
where a.DELETE_FLAG = 0 and a.INVOICE_TITLE = #{invoiceTitle} and a.SETTLE_MONTH = #{lastSettleMonth}
and a.EMP_IDCARD in
<foreach item="idStr" index="index" collection="cardList" open="(" separator="," close=")">
#{idStr}
</foreach>
) a GROUP BY a.keyValue
</select>
<!-- 获取减除费用-单个身份证的 --> <!-- 获取减除费用-单个身份证的 -->
<select id="getTaxMonthToCard" resultType="java.lang.String"> <select id="getTaxMonthToCard" resultType="java.lang.String">
select a.textValue from ( select a.textValue from (
......
...@@ -384,21 +384,41 @@ ...@@ -384,21 +384,41 @@
</update> </update>
<!-- 自动创建临时表(1月创建含去年12月的计税月份)(2月更新成当年的上月的计税月份) (不含减除费用与)--> <!-- 自动创建临时表(1月创建含去年12月的计税月份)(2月更新成当年的上月的计税月份) (不含减除费用与)-->
<update id="updateTempZeroYear" statementType="STATEMENT"> <!--<update id="updateTempZeroYear" statementType="STATEMENT">
update t_salary_zero_tmp t update t_salary_zero_tmp t
LEFT JOIN mvp_salary.t_salary_account a on a.EMP_IDCARD = t.EMP_IDCARD and a.DELETE_FLAG = 0 and a.INVOICE_TITLE=t.INVOICE_TITLE and a.SETTLEMENT_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m') LEFT JOIN mvp_salary.t_salary_account a on a.EMP_IDCARD = t.EMP_IDCARD and a.DELETE_FLAG = 0 and a.INVOICE_TITLE=t.INVOICE_TITLE and a.SETTLEMENT_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m')
LEFT JOIN ${tableNameOrLastTable} z on z.EMP_IDCARD = t.EMP_IDCARD and z.DELETE_FLAG = 0 and z.INVOICE_TITLE=t.INVOICE_TITLE and z.SETTLE_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m') LEFT JOIN ${tableNameOrLastTable} z on z.EMP_IDCARD = t.EMP_IDCARD and z.DELETE_FLAG = 0 and z.INVOICE_TITLE=t.INVOICE_TITLE and z.SETTLE_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m')
set t.COST_REDUCTION=if(DATE_FORMAT(now(),'%m')='01',5000,ifnull(a.COST_REDUCTION,ifnull(z.COST_REDUCTION,0)) + 5000) set t.COST_REDUCTION=if(DATE_FORMAT(now(),'%m')='01',5000,ifnull(a.COST_REDUCTION,ifnull(z.COST_REDUCTION,0)) + 5000)
,t.TAX_MONTH =ifnull(a.TAX_MONTH,ifnull(z.TAX_MONTH,DATE_FORMAT(now(),'%Y%m'))) ,t.TAX_MONTH =ifnull(a.TAX_MONTH,ifnull(z.TAX_MONTH,DATE_FORMAT(now(),'%Y%m')))
</update>-->
<update id="updateTempZeroYear" statementType="STATEMENT">
update t_salary_zero_tmp t
LEFT JOIN mvp_salary.t_salary_account a on a.EMP_IDCARD = t.EMP_IDCARD and a.DELETE_FLAG = 0 and a.INVOICE_TITLE=t.INVOICE_TITLE and a.SETTLEMENT_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m')
LEFT JOIN ${tableNameOrLastTable} z on z.EMP_IDCARD = t.EMP_IDCARD and z.DELETE_FLAG = 0 and z.INVOICE_TITLE=t.INVOICE_TITLE and z.SETTLE_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m')
set t.COST_REDUCTION=if(DATE_FORMAT(now(),'%m')='01',5000,
if(SUBSTRING(ifnull(a.TAX_MONTH,ifnull(z.TAX_MONTH,DATE_FORMAT(now(),'%Y%m'))), 1, 4) = YEAR(NOW()),
(MONTH(NOW()) - SUBSTRING(ifnull(a.TAX_MONTH,ifnull(z.TAX_MONTH,DATE_FORMAT(now(),'%Y%m'))), 5, 2) + 1) * 5000,MONTH(NOW()) * 5000)
)
,t.TAX_MONTH =ifnull(a.TAX_MONTH,ifnull(z.TAX_MONTH,DATE_FORMAT(now(),'%Y%m')))
</update> </update>
<!-- 自动创建临时表(1月创建含去年12月的计税月份)(2月更新成当年的上月的计税月份) (不含减除费用与)--> <!-- 自动创建临时表(1月创建含去年12月的计税月份)(2月更新成当年的上月的计税月份) (不含减除费用与)-->
<update id="updateTempZeroDay" statementType="STATEMENT"> <!--<update id="updateTempZeroDay" statementType="STATEMENT">
update t_salary_zero_day_tmp t update t_salary_zero_day_tmp t
LEFT JOIN mvp_salary.t_salary_account a on a.EMP_IDCARD = t.EMP_IDCARD and a.DELETE_FLAG = 0 and a.INVOICE_TITLE=t.INVOICE_TITLE and a.SETTLEMENT_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m') LEFT JOIN mvp_salary.t_salary_account a on a.EMP_IDCARD = t.EMP_IDCARD and a.DELETE_FLAG = 0 and a.INVOICE_TITLE=t.INVOICE_TITLE and a.SETTLEMENT_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m')
LEFT JOIN ${tableNameOrLastTable} z on z.EMP_IDCARD = t.EMP_IDCARD and z.DELETE_FLAG = 0 and z.INVOICE_TITLE=t.INVOICE_TITLE and z.SETTLE_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m') LEFT JOIN ${tableNameOrLastTable} z on z.EMP_IDCARD = t.EMP_IDCARD and z.DELETE_FLAG = 0 and z.INVOICE_TITLE=t.INVOICE_TITLE and z.SETTLE_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m')
set t.COST_REDUCTION=if(DATE_FORMAT(now(),'%m')='01',5000,ifnull(a.COST_REDUCTION,ifnull(z.COST_REDUCTION,0)) + 5000) set t.COST_REDUCTION=if(DATE_FORMAT(now(),'%m')='01',5000,ifnull(a.COST_REDUCTION,ifnull(z.COST_REDUCTION,0)) + 5000)
,t.TAX_MONTH =ifnull(a.TAX_MONTH,ifnull(z.TAX_MONTH,DATE_FORMAT(now(),'%Y%m'))) ,t.TAX_MONTH =ifnull(a.TAX_MONTH,ifnull(z.TAX_MONTH,DATE_FORMAT(now(),'%Y%m')))
</update>-->
<update id="updateTempZeroDay" statementType="STATEMENT">
update t_salary_zero_day_tmp t
LEFT JOIN mvp_salary.t_salary_account a on a.EMP_IDCARD = t.EMP_IDCARD and a.DELETE_FLAG = 0 and a.INVOICE_TITLE=t.INVOICE_TITLE and a.SETTLEMENT_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m')
LEFT JOIN ${tableNameOrLastTable} z on z.EMP_IDCARD = t.EMP_IDCARD and z.DELETE_FLAG = 0 and z.INVOICE_TITLE=t.INVOICE_TITLE and z.SETTLE_MONTH = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y%m')
set t.COST_REDUCTION=if(DATE_FORMAT(now(),'%m')='01',5000,
if(SUBSTRING(ifnull(a.TAX_MONTH,ifnull(z.TAX_MONTH,DATE_FORMAT(now(),'%Y%m'))), 1, 4) = YEAR(NOW()),
(MONTH(NOW()) - SUBSTRING(ifnull(a.TAX_MONTH,ifnull(z.TAX_MONTH,DATE_FORMAT(now(),'%Y%m'))), 5, 2) + 1) * 5000,MONTH(NOW()) * 5000)
)
,t.TAX_MONTH =ifnull(a.TAX_MONTH,ifnull(z.TAX_MONTH,DATE_FORMAT(now(),'%Y%m')))
</update> </update>
<update id="updateTempZeroDayDelete" statementType="STATEMENT"> <update id="updateTempZeroDayDelete" statementType="STATEMENT">
......
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