From 975ff75eb3a14f476f80235c8d947c060fc6f994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B3=89=E4=BD=B3?= <1107186916@qq.com> Date: Tue, 13 Oct 2026 15:02:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=91=E8=9D=B6=E5=88=86=E5=BD=95?= =?UTF-8?q?=E6=8B=86=E5=88=86=E8=B7=B3=E8=BF=870=E5=85=83=E8=B4=B9?= =?UTF-8?q?=E7=94=A8=E9=A1=B9=E9=81=BF=E5=85=8D=E7=94=9F=E6=88=900?= =?UTF-8?q?=E5=85=83=E6=98=8E=E7=BB=86=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fee_items_json 中金额为0的费用项(附加运输补贴/仓储服务费等)不再参与分组,0元货物行整体跳过;修复FJS2026101300005推送8条分录(其中5条为0元行)的问题,修复后该单应为3条有效分录 --- .../support/KingdeeApBillSyncSupport.java | 8 ++++- .../transport/KingdeeEntrySplitTest.java | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/support/KingdeeApBillSyncSupport.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/support/KingdeeApBillSyncSupport.java index 181cc4be..f091b00f 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/support/KingdeeApBillSyncSupport.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/support/KingdeeApBillSyncSupport.java @@ -463,7 +463,9 @@ public class KingdeeApBillSyncSupport { List splits = splitFeeItems(parseFeeItems(feeItemsJson), context.feeCategoryByName(), context.taxRateByRule(), rowAmount); if (splits.isEmpty()) { - throw new ServiceException("推送金蝶失败:" + sourceDesc + "无费用项金额,无法拆分明细分录"); + // 0元货物行(费用项与结算金额均为0)跳过不生成0元分录 + log.info("金蝶应付单分录生成:来源[{}],费用项与结算金额均为0,跳过该货物行", sourceDesc); + return; } // 运输类数量:取运单运输量(未维护兜底 1) BigDecimal freightQuantity = transportQuantity != null && transportQuantity.compareTo(BigDecimal.ZERO) > 0 @@ -656,6 +658,10 @@ public class KingdeeApBillSyncSupport { continue; } BigDecimal amount = item.getValue() == null ? BigDecimal.ZERO : item.getValue(); + // 0元费用项跳过,不生成0元分录(金额缺失由运输类无税率组残差兜底) + if (amount.signum() == 0) { + continue; + } boolean loading = isLoadingCategory(item.getKey(), feeCategoryByName); BigDecimal taxRate = taxRateByRule == null ? null : taxRateByRule.get(item.getKey()); FeeLineSplit split = grouped.get(splitGroupKey(loading, taxRate)); diff --git a/blade-service/blade-transport/src/test/java/org/springblade/transport/KingdeeEntrySplitTest.java b/blade-service/blade-transport/src/test/java/org/springblade/transport/KingdeeEntrySplitTest.java index 1b34b596..9b0575b1 100644 --- a/blade-service/blade-transport/src/test/java/org/springblade/transport/KingdeeEntrySplitTest.java +++ b/blade-service/blade-transport/src/test/java/org/springblade/transport/KingdeeEntrySplitTest.java @@ -136,4 +136,34 @@ class KingdeeEntrySplitTest { assertFalse(splits.get(1).isLoading()); assertEquals(new BigDecimal("100"), splits.get(1).getAmount()); } + + /** 0元费用项跳过:不生成0元分录(FJS2026101300005 结算单8条分录问题的回归用例) */ + @Test + void zeroAmountFeeItemsSkipped() { + Map feeItems = new LinkedHashMap<>(); + feeItems.put("运输费", new BigDecimal("3120")); + feeItems.put("附加运输补贴", BigDecimal.ZERO); + feeItems.put("装卸费", new BigDecimal("800")); + feeItems.put("仓储服务费", BigDecimal.ZERO); + Map taxRateByRule = Map.of( + "运输费", new BigDecimal("9"), + "附加运输补贴", new BigDecimal("6"), + "装卸费", new BigDecimal("6")); + List splits = KingdeeApBillSyncSupport.splitFeeItems(feeItems, Map.of(), taxRateByRule, new BigDecimal("3920")); + assertEquals(2, splits.size()); + assertFalse(splits.get(0).isLoading()); + assertEquals(new BigDecimal("3120"), splits.get(0).getAmount()); + assertTrue(splits.get(1).isLoading()); + assertEquals(new BigDecimal("800"), splits.get(1).getAmount()); + } + + /** 全部费用项为0且结算金额为0:拆分结果为空(调用方跳过该0元货物行) */ + @Test + void allZeroFeeItemsYieldEmptySplits() { + Map feeItems = new LinkedHashMap<>(); + feeItems.put("运输费", BigDecimal.ZERO); + feeItems.put("装卸费", BigDecimal.ZERO); + List splits = KingdeeApBillSyncSupport.splitFeeItems(feeItems, Map.of(), Map.of(), BigDecimal.ZERO); + assertTrue(splits.isEmpty()); + } }