diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/PaymentApplicationServiceImpl.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/PaymentApplicationServiceImpl.java index 34b22cb8..d60ede21 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/PaymentApplicationServiceImpl.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/PaymentApplicationServiceImpl.java @@ -1134,6 +1134,8 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl 0 ? entryGroup.quantity() : BigDecimal.ONE); + // 明细.单价:该行运输单价(费用明细 unit_price;单据头 ispricetotal=true 录入总价,单价仅作参考) + entry.setPrice(entryGroup.price()); // 应付金额(含税):该行应付货物费用行调整后总金额(含税) entry.setEPricetaxtotal(entryGroup.amount()); // 金额(不含税):该行结算金额(不含税)(应付费用行无不含税字段,经结算货物费用行回链) @@ -1275,13 +1277,14 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl @@ -1326,7 +1329,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl documentNos = settlementDocumentNos(settlementDetails); Map cargoCodeByName = cargoCodeByName(context); - // 应付明细id->应付货物费用行(分录主取数来源) + // 应付明细id->应付货物费用行(分录取数来源,无兜底) Map> payableFeesByDetailId = payableCargoFeesByDetailId(settlementDetails); // 应付费用行id->结算金额(不含税):应付费用行无不含税字段,经结算货物费用行 sourceFeeId 回链 Map noTaxByPayableFeeId = settlementNoTaxByPayableFeeId(settlementDetails); @@ -1334,27 +1337,19 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl payableFees = payableFeesByDetailId.getOrDefault(settlementDetail.getSourceDetailId(), List.of()); - if (Func.isNotEmpty(payableFees)) { - for (ReceivablePayableCargoFee payableFee : payableFees) { - appendEntryGroups(entryGroups, cargoCodeByName, payableFee.getCargoType(), - resolveMeasureunitNumber(payableFee.getPriceUnit(), payableFee.getQuantityUnit()), - payableFee.getId(), - money(payableFee.getAfterAmount()), - noTaxByPayableFeeId.getOrDefault(payableFee.getId(), BigDecimal.ZERO), - money(payableFee.getTransportQuantity()), - "应付货物费用[" + Func.toStr(payableFee.getCargoName()) + " 第" + Func.toStr(payableFee.getLineNo()) + "行]"); - } - } else { - appendEntryGroups(entryGroups, cargoCodeByName, settlementDetail.getCargoType(), - resolveMeasureunitNumber(null, settlementDetail.getQuantityUnit()), - settlementDetail.getId(), - money(settlementDetail.getSettlementAmountTax()), money(settlementDetail.getSettlementAmountNoTax()), - money(settlementDetail.getTransportQuantity()), - "结算明细[" + Func.toStr(settlementDetail.getDocumentNo()) + " 第" + Func.toStr(settlementDetail.getLineNo()) + "行]"); + if (Func.isEmpty(payableFees)) { + throw new ServiceException("推送金蝶财务应付单失败:结算明细[" + Func.toStr(settlementDetail.getDocumentNo()) + + "]对应应付明细无货物费用行,分录取数必须来自应付费用明细,请先维护费用数据"); + } + for (ReceivablePayableCargoFee payableFee : payableFees) { + appendEntryGroups(entryGroups, cargoCodeByName, payableFee.getCargoType(), + resolveMeasureunitNumber(payableFee.getPriceUnit(), payableFee.getQuantityUnit()), + payableFee.getId(), money(payableFee.getUnitPrice()), + money(payableFee.getAfterAmount()), + noTaxByPayableFeeId.getOrDefault(payableFee.getId(), BigDecimal.ZERO), + money(payableFee.getTransportQuantity()), + "应付货物费用[" + Func.toStr(payableFee.getCargoName()) + " 第" + Func.toStr(payableFee.getLineNo()) + "行]"); } - } - if (entryGroups.isEmpty()) { - throw new ServiceException("推送金蝶财务应付单失败:结算明细未解析出任何分录,请检查货物类型维护"); } return new BfiEntryGroupResult(entryGroups, documentNos); } @@ -1431,21 +1426,22 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl货物编码映射 * @param cargoType 货物类型(支持“、”分隔多类型) * @param measureunitNumber 计量单位编码(运费计算单位,档案暂无编码字段暂传单位名称) - * @param sourceRowId 来源行id(应付货物费用行id,兜底结算明细行id),雪花id天然唯一 + * @param sourceRowId 应付货物费用行id,雪花id天然唯一 + * @param price 该行运输单价(费用明细 unit_price) * @param amount 该行金额(含税) * @param amountNoTax 该行金额(不含税) * @param quantity 该行运输数量 * @param sourceDesc 来源行描述,用于异常提示 */ private void appendEntryGroups(List entryGroups, Map cargoCodeByName, - String cargoType, String measureunitNumber, Long sourceRowId, + String cargoType, String measureunitNumber, Long sourceRowId, BigDecimal price, BigDecimal amount, BigDecimal amountNoTax, BigDecimal quantity, String sourceDesc) { List cargoNames = splitCargoTypes(cargoType); if (Func.isBlank(measureunitNumber)) { @@ -1464,10 +1460,10 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl 1 ? rowEntryCode + "-" + (index + 1) : rowEntryCode; entryGroups.add(new BfiEntryGroup(materialNumber, measureunitNumber, entryCode, - quantityShares.get(index), amountShares.get(index), amountNoTaxShares.get(index))); - log.info("金蝶应付单分录生成:来源[{}],分录标识[{}],物料编码[{}],计量单位[{}],数量[{}],含税金额[{}],不含税金额[{}]", + quantityShares.get(index), price, amountShares.get(index), amountNoTaxShares.get(index))); + log.info("金蝶应付单分录生成:来源[{}],分录标识[{}],物料编码[{}],计量单位[{}],数量[{}],单价[{}],含税金额[{}],不含税金额[{}]", sourceDesc, entryCode, materialNumber, measureunitNumber, - quantityShares.get(index), amountShares.get(index), amountNoTaxShares.get(index)); + quantityShares.get(index), price, amountShares.get(index), amountNoTaxShares.get(index)); } }