feat(sip):bug修改,税率税额取的是产品信息中的数据
parent
5749d20c80
commit
e992a62a5b
|
|
@ -79,4 +79,6 @@ public interface ProductInfoMapper
|
||||||
void updateCount(List<ProductInfo> values);
|
void updateCount(List<ProductInfo> values);
|
||||||
|
|
||||||
List<ProductInfo> listInventory(ProductInfo info);
|
List<ProductInfo> listInventory(ProductInfo info);
|
||||||
|
|
||||||
|
ProductInfo selectProductInfoByBomCode(String productCode);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,7 @@ import com.ruoyi.sip.flowable.domain.Todo;
|
||||||
import com.ruoyi.sip.flowable.service.DeleteFlowableProcessInstanceCmd;
|
import com.ruoyi.sip.flowable.service.DeleteFlowableProcessInstanceCmd;
|
||||||
import com.ruoyi.sip.flowable.service.TodoCommonTemplate;
|
import com.ruoyi.sip.flowable.service.TodoCommonTemplate;
|
||||||
import com.ruoyi.sip.flowable.service.TodoService;
|
import com.ruoyi.sip.flowable.service.TodoService;
|
||||||
import com.ruoyi.sip.mapper.OmsPurchaseOrderItemHistoryMapper;
|
import com.ruoyi.sip.mapper.*;
|
||||||
import com.ruoyi.sip.mapper.OmsPurchaseOrderHistoryMapper;
|
|
||||||
import com.ruoyi.sip.mapper.VendorInfoMapper;
|
|
||||||
import com.ruoyi.sip.service.*;
|
import com.ruoyi.sip.service.*;
|
||||||
import com.ruoyi.system.mapper.SysUserMapper;
|
import com.ruoyi.system.mapper.SysUserMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -38,7 +36,6 @@ import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import com.ruoyi.sip.mapper.OmsPurchaseOrderMapper;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
|
@ -67,6 +64,9 @@ public class OmsPurchaseOrderServiceImpl implements IOmsPurchaseOrderService, To
|
||||||
@Resource
|
@Resource
|
||||||
private VendorInfoMapper vendorInfoMapper;
|
private VendorInfoMapper vendorInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProductInfoMapper productInfoMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SysUserMapper userMapper;
|
private SysUserMapper userMapper;
|
||||||
|
|
||||||
|
|
@ -646,10 +646,26 @@ public class OmsPurchaseOrderServiceImpl implements IOmsPurchaseOrderService, To
|
||||||
orderItem.setProductType(addToNexReq.getProductType());
|
orderItem.setProductType(addToNexReq.getProductType());
|
||||||
orderItem.setProductCode(addToNexReq.getProductCode());
|
orderItem.setProductCode(addToNexReq.getProductCode());
|
||||||
orderItem.setQuantity(new BigDecimal(addToNexReq.getQuantity()));
|
orderItem.setQuantity(new BigDecimal(addToNexReq.getQuantity()));
|
||||||
orderItem.setPrice(addToNexReq.getPrice());
|
|
||||||
orderItem.setTaxRate(addToNexReq.getTaxRate());
|
|
||||||
orderItem.setTaxTotal(addToNexReq.getTaxTotal());
|
|
||||||
|
|
||||||
|
// 根据BOM编码查询产品信息,折扣,单价和税率都从产品信息读
|
||||||
|
log.info("通过BOM编码查询产品信息");
|
||||||
|
ProductInfo productInfo = productInfoMapper.selectProductInfoByBomCode(addToNexReq.getProductCode());
|
||||||
|
if (productInfo == null) {
|
||||||
|
throw new ServiceException("未找到BOM编码对应的产品信息: " + addToNexReq.getProductCode());
|
||||||
|
}
|
||||||
|
log.info("通过BOM编码查询产品信息");
|
||||||
|
// 将String类型转换为BigDecimal
|
||||||
|
BigDecimal price = new BigDecimal(productInfo.getCataloguePrice() != null ? productInfo.getCataloguePrice() : "0");
|
||||||
|
BigDecimal taxRate = new BigDecimal(productInfo.getGuidanceDiscount() != null ? productInfo.getGuidanceDiscount() : "0");
|
||||||
|
|
||||||
|
orderItem.setPrice(price);
|
||||||
|
orderItem.setTaxRate(taxRate);
|
||||||
|
|
||||||
|
// 税额 = 单价 * 数量 - (单价 * 数量) / (1 + 税率),结果取两位小数
|
||||||
|
BigDecimal quantity = orderItem.getQuantity();
|
||||||
|
BigDecimal totalAmount = price.multiply(quantity);
|
||||||
|
BigDecimal taxTotal = totalAmount.subtract(totalAmount.divide(BigDecimal.ONE.add(taxRate), 2, BigDecimal.ROUND_HALF_UP));
|
||||||
|
orderItem.setTaxTotal(taxTotal.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||||
// 根据传入的参数计算金额
|
// 根据传入的参数计算金额
|
||||||
BigDecimal amountTotal = addToNexReq.getPrice() != null && addToNexReq.getQuantity() != null
|
BigDecimal amountTotal = addToNexReq.getPrice() != null && addToNexReq.getQuantity() != null
|
||||||
? addToNexReq.getPrice().multiply(new BigDecimal(addToNexReq.getQuantity()))
|
? addToNexReq.getPrice().multiply(new BigDecimal(addToNexReq.getQuantity()))
|
||||||
|
|
|
||||||
|
|
@ -259,4 +259,12 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectProductInfoByBomCode" parameterType="String" resultMap="ProductInfoResult">
|
||||||
|
<include refid="selectProductInfoVo"/>
|
||||||
|
where t1.product_code = #{productCode}
|
||||||
|
and t1.status = 0
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue