|
@ -4,6 +4,7 @@ import java.math.BigDecimal; |
|
|
import java.math.RoundingMode; |
|
|
import java.math.RoundingMode; |
|
|
import java.util.Date; |
|
|
import java.util.Date; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Objects; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
@ -93,8 +94,28 @@ public class SalesEstimateServiceImpl implements ISalesEstimateService |
|
|
salesEstimate.setEstimateStatus("0"); |
|
|
salesEstimate.setEstimateStatus("0"); |
|
|
//设置默认值为RMB
|
|
|
//设置默认值为RMB
|
|
|
salesEstimate.setCommonCurrency("1"); |
|
|
salesEstimate.setCommonCurrency("1"); |
|
|
|
|
|
|
|
|
List<SalesEstimateDetail> salesEstimateDetailList = salesEstimate.getSalesEstimateDetailList(); |
|
|
List<SalesEstimateDetail> salesEstimateDetailList = salesEstimate.getSalesEstimateDetailList(); |
|
|
|
|
|
|
|
|
if (salesEstimateDetailList != null && salesEstimateDetailList.size() > 0) { |
|
|
if (salesEstimateDetailList != null && salesEstimateDetailList.size() > 0) { |
|
|
|
|
|
// 确保 getMaterialNum 返回类型为 Long 或 long
|
|
|
|
|
|
long enterpriseSum = salesEstimateDetailList.stream() |
|
|
|
|
|
.filter(detail->detail.getMaterialNum() != null) // 过滤掉 null 元素
|
|
|
|
|
|
.mapToLong(SalesEstimateDetail::getMaterialNum) |
|
|
|
|
|
.sum(); |
|
|
|
|
|
|
|
|
|
|
|
salesEstimate.setEnterpriseSum(enterpriseSum); |
|
|
|
|
|
salesEstimate.setMaterialSum((long) salesEstimateDetailList.size()); |
|
|
|
|
|
|
|
|
|
|
|
//计算不含税单价人民币
|
|
|
|
|
|
//计算不含税单价美元
|
|
|
|
|
|
//计算含税单价人民币
|
|
|
|
|
|
//计算含税单价美元
|
|
|
|
|
|
//计算不含税总价人民币
|
|
|
|
|
|
//计算不含税总价美元
|
|
|
|
|
|
//计算含税总价人民币
|
|
|
|
|
|
//计算含税总价美元
|
|
|
|
|
|
|
|
|
for (SalesEstimateDetail salesEstimateDetail : salesEstimateDetailList) { |
|
|
for (SalesEstimateDetail salesEstimateDetail : salesEstimateDetailList) { |
|
|
salesEstimateDetail.setSalesEstimateCode(salesEstimateCode); |
|
|
salesEstimateDetail.setSalesEstimateCode(salesEstimateCode); |
|
|
|
|
|
|
|
@ -286,7 +307,13 @@ public class SalesEstimateServiceImpl implements ISalesEstimateService |
|
|
3、不含税经营成本(RMB)=(该料号的BOM物料总不含税采购成本/总不含税物料成本)*总不含税经营成本 |
|
|
3、不含税经营成本(RMB)=(该料号的BOM物料总不含税采购成本/总不含税物料成本)*总不含税经营成本 |
|
|
4、含税经营成本(RMB)=(该料号的BOM物料总含税采购成本/总含税物料成本)*总含税经营成本 |
|
|
4、含税经营成本(RMB)=(该料号的BOM物料总含税采购成本/总含税物料成本)*总含税经营成本 |
|
|
5、不含税料号估价成本:该料号的BOM物料总不含税采购成本+不含税总经营成本+(该料号的BOM物料总不含税采购成本/总不含税物料成本)*总不含税经营成本 |
|
|
5、不含税料号估价成本:该料号的BOM物料总不含税采购成本+不含税总经营成本+(该料号的BOM物料总不含税采购成本/总不含税物料成本)*总不含税经营成本 |
|
|
|
|
|
新版:不含税料号估价成本:该料号的BOM物料总不含税采购成本+不含税运输成本+不含税服务成本+不含税开发成本+(该料号的BOM物料总不含税采购成本/总物料不含税成本)*总经营不含税成 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6、含税料号估价成本:该料号的BOM物料总含税采购成本+含税总经营成本+(该料号的BOM物料总含税采购成本/总含税物料成本)*总含税经营成本 |
|
|
6、含税料号估价成本:该料号的BOM物料总含税采购成本+含税总经营成本+(该料号的BOM物料总含税采购成本/总含税物料成本)*总含税经营成本 |
|
|
|
|
|
新版:含税料号估价成本:该料号的BOM物料总含税采购成本+含税运输成本+含税服务成本+含税开发成本+(该料号的BOM物料总含税采购成本/总物料含税成本)*总经营含税成本 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7、不含税单价(RMB):该料号不含税估价成本/(1-利润率) |
|
|
7、不含税单价(RMB):该料号不含税估价成本/(1-利润率) |
|
|
8、含税单价(RMB)=该料号含税估价成本/(1-利润率) |
|
|
8、含税单价(RMB)=该料号含税估价成本/(1-利润率) |
|
|
9、不含税总价(RMB)=不含税单价(RMB)*数量 |
|
|
9、不含税总价(RMB)=不含税单价(RMB)*数量 |
|
@ -340,6 +367,11 @@ public class SalesEstimateServiceImpl implements ISalesEstimateService |
|
|
BigDecimal noTaxBusinessCosts = salesEstimateDetail.getNoTaxBusinessCosts(); // 获取不含税的业务成本
|
|
|
BigDecimal noTaxBusinessCosts = salesEstimateDetail.getNoTaxBusinessCosts(); // 获取不含税的业务成本
|
|
|
BigDecimal noTaxManagesCosts = salesEstimateDetail.getNoTaxManagesCosts(); // 获取不含税的管理成本
|
|
|
BigDecimal noTaxManagesCosts = salesEstimateDetail.getNoTaxManagesCosts(); // 获取不含税的管理成本
|
|
|
BigDecimal noTaxMaterialCosts = salesEstimateDetail.getNoTaxMaterialCosts(); // 获取不含税的物料成本
|
|
|
BigDecimal noTaxMaterialCosts = salesEstimateDetail.getNoTaxMaterialCosts(); // 获取不含税的物料成本
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal noTaxShippingCosts = salesEstimateDetail.getNoTaxShippingCosts(); //不含税运输成本
|
|
|
|
|
|
BigDecimal noTaxServiceCosts = salesEstimateDetail.getNoTaxServiceCosts(); //不含税服务成本
|
|
|
|
|
|
BigDecimal noTaxDevelopmentCosts = salesEstimateDetail.getNoTaxDevelopCosts();//不含税开发成本
|
|
|
|
|
|
|
|
|
BigDecimal profitRate = salesEstimateDetail.getProfitRate().divide(BigDecimal.valueOf(100)); // 获取利润率并转换为小数形式
|
|
|
BigDecimal profitRate = salesEstimateDetail.getProfitRate().divide(BigDecimal.valueOf(100)); // 获取利润率并转换为小数形式
|
|
|
Long materialNum = salesEstimateDetail.getMaterialNum(); // 获取物料数量
|
|
|
Long materialNum = salesEstimateDetail.getMaterialNum(); // 获取物料数量
|
|
|
|
|
|
|
|
@ -367,10 +399,10 @@ public class SalesEstimateServiceImpl implements ISalesEstimateService |
|
|
.setScale(2, RoundingMode.HALF_UP); |
|
|
.setScale(2, RoundingMode.HALF_UP); |
|
|
|
|
|
|
|
|
// 计算不含税料号估价成本,并保留两位小数
|
|
|
// 计算不含税料号估价成本,并保留两位小数
|
|
|
BigDecimal noTaxEstimateCost = calculateNoTaxEstimateCost(totalNoTaxPurchaseRmb, noAllTaxOperatingCosts, noTaxMaterialCosts) |
|
|
BigDecimal noTaxEstimateCost = calculateNoTaxEstimateCost(totalNoTaxPurchaseRmb, noTaxShippingCosts,noTaxServiceCosts,noTaxDevelopmentCosts,noAllTaxOperatingCosts, noTaxMaterialCosts) |
|
|
.setScale(2, RoundingMode.HALF_UP); |
|
|
.setScale(2, RoundingMode.HALF_UP); |
|
|
// 计算含税料号估价成本,并保留两位小数
|
|
|
// 计算含税料号估价成本,并保留两位小数
|
|
|
BigDecimal taxEstimateCost = calculateTaxEstimateCost(totalTaxPurchaseRmb, allTaxOperatingCosts, taxMaterialCosts) |
|
|
BigDecimal taxEstimateCost = calculateTaxEstimateCost(totalTaxPurchaseRmb,noTaxShippingCosts,noTaxServiceCosts,noTaxDevelopmentCosts, allTaxOperatingCosts, taxMaterialCosts) |
|
|
.setScale(2, RoundingMode.HALF_UP); |
|
|
.setScale(2, RoundingMode.HALF_UP); |
|
|
|
|
|
|
|
|
// 计算不含税单价(RMB),并保留两位小数
|
|
|
// 计算不含税单价(RMB),并保留两位小数
|
|
@ -498,16 +530,24 @@ public class SalesEstimateServiceImpl implements ISalesEstimateService |
|
|
.multiply(allTaxOperatingCosts); |
|
|
.multiply(allTaxOperatingCosts); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 计算不含税料号估价成本
|
|
|
// 计算不含税料号估价成本 BigDecimal noTaxShippingCosts = salesEstimateDetail.getNoTaxShippingCosts(); //不含税运输成本
|
|
|
private BigDecimal calculateNoTaxEstimateCost(BigDecimal totalNoTaxPurchaseRmb, BigDecimal noAllTaxOperatingCosts, BigDecimal noTaxMaterialCosts) { |
|
|
// BigDecimal noTaxServiceCosts = salesEstimateDetail.getNoTaxServiceCosts(); //不含税服务成本
|
|
|
return totalNoTaxPurchaseRmb.add(noAllTaxOperatingCosts) |
|
|
// BigDecimal noTaxDevelopmentCosts = salesEstimateDetail.getNoTaxDevelopCosts();//不含税开发成本
|
|
|
|
|
|
private BigDecimal calculateNoTaxEstimateCost(BigDecimal totalNoTaxPurchaseRmb, BigDecimal noTaxShippingCosts ,BigDecimal noTaxServiceCosts,BigDecimal noTaxDevelopmentCosts ,BigDecimal noAllTaxOperatingCosts,BigDecimal noTaxMaterialCosts) { |
|
|
|
|
|
return totalNoTaxPurchaseRmb |
|
|
|
|
|
.add(noTaxShippingCosts) |
|
|
|
|
|
.add(noTaxServiceCosts) |
|
|
|
|
|
.add(noTaxDevelopmentCosts) |
|
|
.add(totalNoTaxPurchaseRmb.divide(noTaxMaterialCosts, 2, RoundingMode.HALF_UP) |
|
|
.add(totalNoTaxPurchaseRmb.divide(noTaxMaterialCosts, 2, RoundingMode.HALF_UP) |
|
|
.multiply(noAllTaxOperatingCosts)); |
|
|
.multiply(noAllTaxOperatingCosts)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 计算含税料号估价成本
|
|
|
// 计算含税料号估价成本
|
|
|
private BigDecimal calculateTaxEstimateCost(BigDecimal totalTaxPurchaseRmb, BigDecimal allTaxOperatingCosts, BigDecimal taxMaterialCosts) { |
|
|
private BigDecimal calculateTaxEstimateCost(BigDecimal totalTaxPurchaseRmb, BigDecimal noTaxShippingCosts ,BigDecimal noTaxServiceCosts,BigDecimal noTaxDevelopmentCosts ,BigDecimal allTaxOperatingCosts, BigDecimal taxMaterialCosts) { |
|
|
return totalTaxPurchaseRmb.add(allTaxOperatingCosts) |
|
|
return totalTaxPurchaseRmb |
|
|
|
|
|
.add(noTaxShippingCosts) |
|
|
|
|
|
.add(noTaxServiceCosts) |
|
|
|
|
|
.add(noTaxDevelopmentCosts) |
|
|
.add(totalTaxPurchaseRmb.divide(taxMaterialCosts, 2, RoundingMode.HALF_UP) |
|
|
.add(totalTaxPurchaseRmb.divide(taxMaterialCosts, 2, RoundingMode.HALF_UP) |
|
|
.multiply(allTaxOperatingCosts)); |
|
|
.multiply(allTaxOperatingCosts)); |
|
|
} |
|
|
} |
|
|