|
|
|
|
@ -2,6 +2,8 @@ package org.dromara.oa.erp.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
|
|
import org.dromara.common.core.enums.BusinessStatusEnum;
|
|
|
|
|
import org.dromara.common.core.enums.OAStatusEnum;
|
|
|
|
|
@ -246,6 +248,33 @@ public class ErpFinInvoiceInfoServiceImpl extends AbstractWorkflowService<ErpFin
|
|
|
|
|
&& entity.getIssuancePercentage().compareTo(ONE_HUNDRED) > 0) {
|
|
|
|
|
throw new ServiceException("本次开具发票比例不能超过100%");
|
|
|
|
|
}
|
|
|
|
|
validContractIssuancePercentageTotal(entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 同一合同下各开票单本次开具比例累计不得超过100%
|
|
|
|
|
*/
|
|
|
|
|
private void validContractIssuancePercentageTotal(ErpFinInvoiceInfo entity) {
|
|
|
|
|
if (entity.getContractId() == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
BigDecimal currentPercentage = entity.getIssuancePercentage() == null ? ZERO : entity.getIssuancePercentage();
|
|
|
|
|
LambdaQueryWrapper<ErpFinInvoiceInfo> qw = Wrappers.lambdaQuery(ErpFinInvoiceInfo.class)
|
|
|
|
|
.eq(ErpFinInvoiceInfo::getContractId, entity.getContractId())
|
|
|
|
|
.eq(ErpFinInvoiceInfo::getDelFlag, "0")
|
|
|
|
|
.ne(ErpFinInvoiceInfo::getInvoiceStatus, OAStatusEnum.INVALID.getStatus());
|
|
|
|
|
if (entity.getInvoiceId() != null) {
|
|
|
|
|
qw.ne(ErpFinInvoiceInfo::getInvoiceId, entity.getInvoiceId());
|
|
|
|
|
}
|
|
|
|
|
List<ErpFinInvoiceInfo> existingList = baseMapper.selectList(qw);
|
|
|
|
|
BigDecimal totalPercentage = existingList.stream()
|
|
|
|
|
.map(ErpFinInvoiceInfo::getIssuancePercentage)
|
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
|
.reduce(ZERO, BigDecimal::add)
|
|
|
|
|
.add(currentPercentage);
|
|
|
|
|
if (totalPercentage.compareTo(ONE_HUNDRED) > 0) {
|
|
|
|
|
throw new ServiceException("同一合同本次开具发票比例之和不能超过100%");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void validInvoiceDetailList(List<ErpFinInvoiceDetail> detailList) {
|
|
|
|
|
|