feat: 重推认领收票单支持携带匹配结算单金额
This commit is contained in:
+4
-3
@@ -241,9 +241,10 @@ public class FormalSettlementController extends BladeController {
|
||||
|
||||
@PostMapping("/repush-claimed-invoice")
|
||||
@ApiOperationSupport(order = 16)
|
||||
@Operation(summary = "重推认领收票单(查看页入口:收票单A303-2+指定应付A302-6 一步式,failed/pushed 通吃)")
|
||||
public R<String> repushClaimedInvoice(@RequestParam Long id, @RequestParam String invoiceNo) {
|
||||
return R.data(formalSettlementService.repushClaimedInvoice(id, invoiceNo));
|
||||
@Operation(summary = "重推认领收票单(查看页入口:收票单A303-2+指定应付A302-6 一步式,failed/pushed 通吃,可带匹配金额)")
|
||||
public R<String> repushClaimedInvoice(@RequestParam Long id, @RequestParam String invoiceNo,
|
||||
@RequestParam(required = false) BigDecimal matchedAmount) {
|
||||
return R.data(formalSettlementService.repushClaimedInvoice(id, invoiceNo, matchedAmount));
|
||||
}
|
||||
|
||||
@PostMapping("/sync-kingdee-ar-result")
|
||||
|
||||
+5
-3
@@ -18,6 +18,7 @@ import org.springblade.transport.pojo.vo.PreSettlementVO;
|
||||
import org.springblade.transport.pojo.entity.PreSettlement;
|
||||
import org.springblade.transport.pojo.dto.PreSettlementDetailAdjustRequest;
|
||||
import org.springblade.transport.pojo.entity.FormalSettlementDetailFee;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.springblade.transport.pojo.dto.FormalSettlementPaymentRequest;
|
||||
@@ -77,11 +78,12 @@ public interface IFormalSettlementService extends BaseService<FormalSettlement>
|
||||
* 前置付款结算单 + 审批通过 + 财务应付单已同步;先复用收票推送状态机重推金蝶收票单(A303-2,
|
||||
* A801-3 幂等预检防重复保存),再组装应付单防重键逐单 A302-6 指定应付(幂等)
|
||||
*
|
||||
* @param id 正式结算单id
|
||||
* @param invoiceNo 认领发票号
|
||||
* @param id 正式结算单id
|
||||
* @param invoiceNo 认领发票号
|
||||
* @param matchedAmount 匹配结算单金额(可空:空不修改;非空校验 0~发票金额 后更新发票行并重建认领分摊)
|
||||
* @return 重推结果描述
|
||||
*/
|
||||
String repushClaimedInvoice(Long id, String invoiceNo);
|
||||
String repushClaimedInvoice(Long id, String invoiceNo, BigDecimal matchedAmount);
|
||||
|
||||
/**
|
||||
* 独立事务落"生成失败"状态并记失败原因(在推送事务回滚、行锁释放后执行,与付款/收票口径统一);
|
||||
|
||||
+27
-1
@@ -1105,7 +1105,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public String repushClaimedInvoice(Long id, String invoiceNo) {
|
||||
public String repushClaimedInvoice(Long id, String invoiceNo, BigDecimal matchedAmount) {
|
||||
FormalSettlement settlement = lockedExisting(id);
|
||||
if (!"payable".equals(settlement.getSettlementType())) {
|
||||
throw new ServiceException("仅付款结算单允许重推认领收票单");
|
||||
@@ -1133,6 +1133,32 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl<FormalSettlemen
|
||||
if (KingdeeBfiConstant.RECEIVED_PUSH_ASSIGNED.equals(pushStatus)) {
|
||||
throw new ServiceException("发票" + trimmedInvoiceNo + "已指定应付,无需重复推送");
|
||||
}
|
||||
// 匹配结算单金额随重推一并生效:更新发票行并重建本单认领分摊(收票覆盖度随之刷新)
|
||||
if (matchedAmount != null) {
|
||||
FormalSettlementInvoice settlementInvoice = invoiceMapper.selectOne(
|
||||
Wrappers.<FormalSettlementInvoice>lambdaQuery()
|
||||
.eq(FormalSettlementInvoice::getFormalSettlementId, id)
|
||||
.eq(FormalSettlementInvoice::getInvoiceNo, trimmedInvoiceNo)
|
||||
.last("LIMIT 1"));
|
||||
if (settlementInvoice == null) {
|
||||
throw new ServiceException("发票" + trimmedInvoiceNo + "不在本结算单发票信息中,无法修改匹配金额");
|
||||
}
|
||||
if (matchedAmount.compareTo(BigDecimal.ZERO) < 0) {
|
||||
throw new ServiceException("发票" + trimmedInvoiceNo + "匹配结算单金额不能为负数");
|
||||
}
|
||||
if (matchedAmount.compareTo(money(settlementInvoice.getInvoiceAmount())) > 0) {
|
||||
throw new ServiceException("发票" + trimmedInvoiceNo + "匹配结算单金额不能超过发票金额"
|
||||
+ money(settlementInvoice.getInvoiceAmount()));
|
||||
}
|
||||
invoiceMapper.update(null, Wrappers.<FormalSettlementInvoice>lambdaUpdate()
|
||||
.eq(FormalSettlementInvoice::getId, settlementInvoice.getId())
|
||||
.set(FormalSettlementInvoice::getMatchedAmount, matchedAmount));
|
||||
// 关系重建语义为删全量重建,须传本单全部发票号,只传单票会清掉其他认领关系
|
||||
List<String> allInvoiceNos = invoiceMapper.selectList(Wrappers.<FormalSettlementInvoice>lambdaQuery()
|
||||
.eq(FormalSettlementInvoice::getFormalSettlementId, id)).stream()
|
||||
.map(FormalSettlementInvoice::getInvoiceNo).filter(Func::isNotBlank).distinct().toList();
|
||||
invoiceReceiptService.syncSettlementReceiptRelations(id, allInvoiceNos);
|
||||
}
|
||||
// 第一步:复用收票推送状态机重推金蝶收票单(A303-2,A801-3 幂等预检防重复保存,单笔事务独立回滚)
|
||||
String pushResult = invoiceReceiptService.pushKingdeeReceivedInvoice(List.of(receipt.getId()));
|
||||
// 第二步:收票单就绪后按应付单防重键 A302-6 指定应付(幂等,已指定的跳过)
|
||||
|
||||
Reference in New Issue
Block a user