| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void createTaxRateConfigList(List<HrmTaxRateConfigDO> configList) { |
| | | for (HrmTaxRateConfigDO config : configList) { |
| | | applyDefaults(config); |
| | | taxRateConfigMapper.insert(config); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public void updateTaxRateConfig(HrmTaxRateConfigDO config) { |
| | | validateTaxRateConfigExists(config.getId()); |
| | | applyDefaults(config); |
| | | taxRateConfigMapper.updateById(config); |
| | | } |
| | | |
| | | /** |
| | | * 补全默认值:生效日期默认为当月 1 号,配置名称自动生成,速算扣除数/上限缺省按 0 |
| | | */ |
| | | private void applyDefaults(HrmTaxRateConfigDO config) { |
| | | if (config.getEffectiveDate() == null) { |
| | | config.setEffectiveDate(LocalDate.now().withDayOfMonth(1)); |
| | | } |
| | | if (config.getName() == null || config.getName().isBlank()) { |
| | | config.setName(config.getEffectiveDate().getYear() + "年" |
| | | + config.getEffectiveDate().getMonthValue() + "月个税税率表"); |
| | | } |
| | | if (config.getStatus() == null) { |
| | | config.setStatus(0); |
| | | } |
| | | if (config.getQuickDeduction() == null) { |
| | | config.setQuickDeduction(BigDecimal.ZERO); |
| | | } |
| | | if (config.getMaxAmount() == null) { |
| | | config.setMaxAmount(BigDecimal.ZERO); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void deleteTaxRateConfig(Long id) { |
| | | validateTaxRateConfigExists(id); |