fix:应付单详情数据内容修改
parent
87a3901694
commit
43fc48a3a5
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<el-drawer title="采购 - 应付单详情" :visible.sync="internalVisible" :wrapper-closable="false" size="70%" :z-index="zIndex" @close="handleClose">
|
||||
<div class="dialog-body">
|
||||
<div class="dialog-body" v-loading="loading" element-loading-text="数据加载中...">
|
||||
<!-- Part 1: Details -->
|
||||
<div>
|
||||
<el-divider content-position="left">采购-应付单</el-divider>
|
||||
|
|
@ -91,7 +91,29 @@
|
|||
<!-- Part 2: Tabs -->
|
||||
<div style="padding: 20px">
|
||||
<el-tabs v-model="activeTab">
|
||||
<el-tab-pane label="明细" name="details">
|
||||
<el-tab-pane label="应付单明细" name="details">
|
||||
<el-table :data="formData.goodsDetailList" style="width: 100%">
|
||||
<el-table-column type="index" label="序号" width="50"></el-table-column>
|
||||
<el-table-column prop="productType" label="产品类型" width="120">
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.product_type" :value="scope.row.productType"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="productCode" label="产品编码" width="120"></el-table-column>
|
||||
<el-table-column prop="productModel" label="产品型号" width="120"></el-table-column>
|
||||
<el-table-column prop="productDescription" label="产品描述" min-width="180" show-overflow-tooltip></el-table-column>
|
||||
<el-table-column prop="quantity" label="数量" width="100" align="center"></el-table-column>
|
||||
<el-table-column prop="unit" label="单位" width="80" align="center"></el-table-column>
|
||||
<el-table-column prop="price" label="单价" width="120" align="center" :formatter="(row, column, cellValue)=>formatCurrency(cellValue)"></el-table-column>
|
||||
<el-table-column prop="taxRate" label="税率" width="100" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.taxRate * 100 }}%
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="amountTotal" label="含税小计" width="140" align="center" :formatter="(row, column, cellValue)=>formatCurrency(cellValue)"></el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="付款计划" name="paymentPlan">
|
||||
<el-divider content-position="left">采购-付款单</el-divider>
|
||||
<el-table :data="formData.detailList" style="width: 100%" show-summary :summary-method="getSummaries">
|
||||
<el-table-column type="index" label="序号" width="50"></el-table-column>
|
||||
|
|
@ -136,6 +158,9 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<PaymentPlan :isInitEdit=true @syncPlan="refreshTicketPlan()" :payableData="data"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="收票计划" name="receivingTicketPlan">
|
||||
<el-divider content-position="left">采购-收票单</el-divider>
|
||||
<el-table :data="formData.ticketDetailList" style="width: 100%" show-summary :summary-method="getSummaries">
|
||||
<el-table-column type="index" label="序号" width="50"></el-table-column>
|
||||
|
|
@ -181,11 +206,6 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="付款计划" name="paymentPlan">
|
||||
<PaymentPlan :isInitEdit=true @syncPlan="refreshTicketPlan()" :payableData="data"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="收票计划" name="receivingTicketPlan">
|
||||
<ReceivingTicketPlan ref="ticketPlan" :isInitEdit=true :payableData="data"/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
|
@ -251,6 +271,7 @@ export default {
|
|||
internalVisible: this.visible, // Local copy of the visible prop
|
||||
activeTab: 'details',
|
||||
formData: {},
|
||||
loading: false, // 数据加载蒙层
|
||||
paymentDetailOpen: false,
|
||||
paymentDetailData: {},
|
||||
receiptDetailOpen: false,
|
||||
|
|
@ -276,8 +297,13 @@ export default {
|
|||
this.$refs.ticketPlan.fetchTicketPlans(this.formData.id);
|
||||
},
|
||||
getDetails() {
|
||||
this.loading = true;
|
||||
getPayable(this.data.id).then(res => {
|
||||
this.formData = res.data;
|
||||
}).catch(() => {
|
||||
this.$modal.msgError("数据加载失败");
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
handlePreview(attachment) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.sip.domain.dto.PayableGoodsDetailDto;
|
||||
import lombok.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
|
@ -119,6 +120,8 @@ public class OmsPayableBill extends BaseEntity
|
|||
|
||||
private List<OmsPayablePaymentDetail> detailList;
|
||||
private List<OmsPayableTicketDetail> ticketDetailList;
|
||||
/** 商品明细(来源:入库单) */
|
||||
private List<PayableGoodsDetailDto> goodsDetailList;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
package com.ruoyi.sip.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 应付单商品明细DTO(来源:入库单)
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
public class PayableGoodsDetailDto {
|
||||
/** 产品类型 */
|
||||
private String productType;
|
||||
/** 产品编码 */
|
||||
private String productCode;
|
||||
/** 产品型号 */
|
||||
private String productModel;
|
||||
/** 产品描述 */
|
||||
private String productDescription;
|
||||
/** 数量 */
|
||||
private Long quantity;
|
||||
/** 单位 */
|
||||
private String unit;
|
||||
/** 单价 */
|
||||
private BigDecimal price;
|
||||
/** 税率 */
|
||||
private BigDecimal taxRate;
|
||||
/** 含税小计 */
|
||||
private BigDecimal amountTotal;
|
||||
}
|
||||
|
|
@ -13,8 +13,12 @@ import com.ruoyi.common.utils.spring.SpringUtils;
|
|||
import com.ruoyi.sip.domain.*;
|
||||
import com.ruoyi.sip.domain.dto.MergedPaymentDataDto;
|
||||
import com.ruoyi.sip.domain.dto.MergedReceiptDataDto;
|
||||
import com.ruoyi.sip.domain.dto.PayableGoodsDetailDto;
|
||||
import com.ruoyi.sip.domain.dto.PayableOrderDto;
|
||||
import com.ruoyi.sip.domain.dto.PayableOrderReceiptDto;
|
||||
import com.ruoyi.sip.mapper.InventoryInfoMapper;
|
||||
import com.ruoyi.sip.mapper.InventoryOuterMapper;
|
||||
import com.ruoyi.sip.mapper.OmsInventoryInnerMapper;
|
||||
import com.ruoyi.sip.mapper.OmsPayableBillMapper;
|
||||
import com.ruoyi.sip.mapper.OmsPayablePaymentPlanMapper;
|
||||
import com.ruoyi.sip.mapper.OmsPayableTicketPlanMapper;
|
||||
|
|
@ -59,6 +63,15 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
|||
|
||||
@Autowired
|
||||
private IOmsPayableTicketDetailService omsPayableTicketDetailService;
|
||||
|
||||
@Autowired
|
||||
private OmsInventoryInnerMapper omsInventoryInnerMapper;
|
||||
|
||||
@Autowired
|
||||
private InventoryInfoMapper inventoryInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private InventoryOuterMapper inventoryOuterMapper;
|
||||
@Value("${oms.inventory.innerTax:0.13}")
|
||||
private String defaultTax;
|
||||
/**
|
||||
|
|
@ -550,10 +563,103 @@ public class OmsPayableBillServiceImpl implements IOmsPayableBillService {
|
|||
List<OmsPaymentBill> omsPaymentBills = omsPaymentBillService.listPreResidueAmountByVendorCodeList(Collections.singletonList(omsPayableBill.getVendorCode()));
|
||||
Map<String, BigDecimal> decimalMap = omsPaymentBills.stream().filter(item -> item.getPreResidueAmount() != null).collect(Collectors.toMap(OmsPaymentBill::getVendorCode, OmsPaymentBill::getPreResidueAmount, BigDecimal::add));
|
||||
omsPayableBill.setPreResidueAmount(decimalMap.getOrDefault(omsPayableBill.getVendorCode(), BigDecimal.ZERO));
|
||||
// 商品明细(来源:入库单)
|
||||
omsPayableBill.setGoodsDetailList(queryGoodsDetailList(omsPayableBill.getInventoryCode()));
|
||||
|
||||
return omsPayableBill;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过入库/出库单号查询应付单商品明细
|
||||
* inventoryCode 可能为入库单号(inner_code)或出库单号(outer_code)
|
||||
*
|
||||
* @param inventoryCode 入库/出库单号
|
||||
* @return 商品明细列表
|
||||
*/
|
||||
private List<PayableGoodsDetailDto> queryGoodsDetailList(String inventoryCode) {
|
||||
if (StringUtils.isEmpty(inventoryCode)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// 入库单来源
|
||||
List<OmsInventoryInner> inventoryInners = omsInventoryInnerMapper.selectOmsInventoryInnerByInnerCodeList(Collections.singletonList(inventoryCode));
|
||||
if (CollUtil.isNotEmpty(inventoryInners)) {
|
||||
OmsInventoryInner inventoryInner = inventoryInners.get(0);
|
||||
List<InventoryInfo> inventoryInfoList = inventoryInfoMapper.selectInventoryInfoByInnerCodeList(Collections.singletonList(inventoryCode));
|
||||
// 产品类型为3(服务)/22(硬件维保)时 含税小计 = 单价 × 数量,其他为入库价合计
|
||||
boolean multiplyQuantity = Arrays.asList("3", "22").contains(inventoryInner.getProductType());
|
||||
BigDecimal taxRate = inventoryInner.getTaxRate() != null ? inventoryInner.getTaxRate() : defaultTaxRate();
|
||||
return buildGoodsDetailList(inventoryInner.getProductType(), taxRate, inventoryInfoList, multiplyQuantity);
|
||||
}
|
||||
// 出库单来源
|
||||
InventoryOuter inventoryOuter = inventoryOuterMapper.selectInventoryOuterByCode(inventoryCode);
|
||||
if (inventoryOuter != null) {
|
||||
List<InventoryInfo> inventoryInfoList = inventoryInfoMapper.selectInventoryInfoByOuterCodeList(Collections.singletonList(inventoryCode));
|
||||
if (CollUtil.isEmpty(inventoryInfoList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String productType = inventoryInfoList.get(0).getProductType();
|
||||
BigDecimal taxRate = inventoryInfoList.get(0).getTaxRate() != null ? inventoryInfoList.get(0).getTaxRate() : defaultTaxRate();
|
||||
// 出库单生成的应付单:含税小计直接为入库价合计,不乘数量
|
||||
return buildGoodsDetailList(productType, taxRate, inventoryInfoList, false);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 按产品编码分组组装商品明细
|
||||
*
|
||||
* @param productType 产品类型
|
||||
* @param taxRate 税率(小数)
|
||||
* @param inventoryInfoList 库存明细
|
||||
* @param multiplyQuantity 是否 含税小计 = 单价 × 数量
|
||||
* @return 商品明细列表
|
||||
*/
|
||||
private List<PayableGoodsDetailDto> buildGoodsDetailList(String productType, BigDecimal taxRate,
|
||||
List<InventoryInfo> inventoryInfoList,
|
||||
boolean multiplyQuantity) {
|
||||
if (CollUtil.isEmpty(inventoryInfoList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// 按产品编码分组(同一单据可能存在多行SN明细)
|
||||
Map<String, List<InventoryInfo>> groupMap = inventoryInfoList.stream()
|
||||
.filter(item -> StringUtils.isNotEmpty(item.getProductCode()))
|
||||
.collect(Collectors.groupingBy(InventoryInfo::getProductCode));
|
||||
List<PayableGoodsDetailDto> goodsDetailList = new ArrayList<>();
|
||||
for (Map.Entry<String, List<InventoryInfo>> entry : groupMap.entrySet()) {
|
||||
List<InventoryInfo> infos = entry.getValue();
|
||||
InventoryInfo first = infos.get(0);
|
||||
PayableGoodsDetailDto dto = new PayableGoodsDetailDto();
|
||||
dto.setProductType(productType);
|
||||
dto.setProductCode(entry.getKey());
|
||||
dto.setProductModel(first.getModel());
|
||||
dto.setProductDescription(first.getProductDesc());
|
||||
dto.setQuantity((long) infos.size());
|
||||
dto.setUnit("个");
|
||||
dto.setPrice(first.getInnerPrice());
|
||||
dto.setTaxRate(taxRate);
|
||||
if (multiplyQuantity) {
|
||||
dto.setAmountTotal(first.getInnerPrice() == null ? BigDecimal.ZERO
|
||||
: first.getInnerPrice().multiply(new BigDecimal(infos.size())));
|
||||
} else {
|
||||
dto.setAmountTotal(infos.stream().map(InventoryInfo::getInnerPrice).filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||
}
|
||||
goodsDetailList.add(dto);
|
||||
}
|
||||
return goodsDetailList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认税率(小数)
|
||||
*/
|
||||
private BigDecimal defaultTaxRate() {
|
||||
try {
|
||||
return new BigDecimal(defaultTax);
|
||||
} catch (Exception e) {
|
||||
return new BigDecimal("0.13");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> checkDelete(List<String> inventoryCodeList) {
|
||||
return omsPayableBillMapper.checkDelete(inventoryCodeList);
|
||||
|
|
|
|||
Loading…
Reference in New Issue