fix:订单全部发货后生成服务应收单应付单
parent
626d1f1b09
commit
cca2215a60
|
|
@ -5,6 +5,7 @@ export function listReceivable(query) {
|
|||
return request({
|
||||
url: '/finance/receivable/list',
|
||||
method: 'post',
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
data: query
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.ruoyi.sip.controller;
|
|||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.sip.dto.ProjectTransferRequest;
|
||||
import com.ruoyi.sip.service.IDataProcessService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -26,10 +27,7 @@ public class DataProcessController {
|
|||
//入库单生成应付单
|
||||
@Anonymous
|
||||
@GetMapping("/inventoryInnerGeneratePayableBill")
|
||||
void inventoryInnerGeneratePayableBill(@RequestParam("innerId") Long innerId) {
|
||||
if (innerId == null) {
|
||||
throw new ServiceException("innerId不能为空");
|
||||
}
|
||||
public void inventoryInnerGeneratePayableBill(@RequestParam("innerId") Long innerId) {
|
||||
dataProcessService.inventoryInnerGeneratePayableBill(innerId);
|
||||
}
|
||||
|
||||
|
|
@ -38,4 +36,11 @@ public class DataProcessController {
|
|||
return dataProcessService.projectTransfer(request);
|
||||
}
|
||||
|
||||
//生成服务产品的应收单、应付单
|
||||
@Anonymous
|
||||
@GetMapping("/generateServiceBillsWhenAllDelivered")
|
||||
public void generateServiceBillsWhenAllDelivered(@RequestParam("orderCode") String orderCode) {
|
||||
dataProcessService.generateServiceBillsWhenAllDelivered(orderCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class OmsReceivableBillController extends BaseController
|
|||
@RequiresPermissions("finance:receivable:list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(@RequestBody OmsReceivableBill omsReceivableBill)
|
||||
public TableDataInfo list(OmsReceivableBill omsReceivableBill)
|
||||
{
|
||||
startPage();
|
||||
List<OmsReceivableBill> list = omsReceivableBillService.selectOmsReceivableBillList(omsReceivableBill);
|
||||
|
|
|
|||
|
|
@ -9,4 +9,6 @@ public interface IDataProcessService {
|
|||
|
||||
AjaxResult projectTransfer(ProjectTransferRequest request);
|
||||
|
||||
void generateServiceBillsWhenAllDelivered(String orderCode);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,4 +71,7 @@ public interface IInventoryDeliveryService
|
|||
void recall(Long id);
|
||||
|
||||
List<InventoryDeliveryDetailExcelDto> detailExport(InventoryDelivery inventoryDelivery);
|
||||
|
||||
void generateServiceBillsWhenAllDelivered(String orderCode);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,17 +16,14 @@ import com.ruoyi.sip.mapper.OmsInventoryInnerMapper;
|
|||
import com.ruoyi.sip.mapper.ProjectInfoMapper;
|
||||
import com.ruoyi.sip.mapper.ProjectOrderInfoMapper;
|
||||
import com.ruoyi.sip.mapper.ProjectUserCollectInfoMapper;
|
||||
import com.ruoyi.sip.service.IDataProcessService;
|
||||
import com.ruoyi.sip.service.IOmsPayableBillService;
|
||||
import com.ruoyi.sip.service.IOmsPurchaseOrderService;
|
||||
import com.ruoyi.sip.service.IProductInfoService;
|
||||
import com.ruoyi.sip.service.IVendorInfoService;
|
||||
import com.ruoyi.sip.service.*;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.mgt.DefaultSecurityManager;
|
||||
import org.apache.shiro.mgt.SecurityManager;
|
||||
import org.apache.shiro.subject.SimplePrincipalCollection;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.util.ThreadContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -65,9 +62,13 @@ public class DataProcessServiceImpl implements IDataProcessService {
|
|||
|
||||
@Resource
|
||||
private ProjectInfoMapper projectInfoMapper;
|
||||
|
||||
@Resource
|
||||
private ProjectOrderInfoMapper projectOrderInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private IInventoryDeliveryService inventoryDeliveryService;
|
||||
|
||||
@Value("${oms.inventory.innerTax:0.13}")
|
||||
private String defaultTax;
|
||||
|
||||
|
|
@ -156,4 +157,13 @@ public class DataProcessServiceImpl implements IDataProcessService {
|
|||
return AjaxResult.success("项目转移成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateServiceBillsWhenAllDelivered(String orderCode) {
|
||||
if (StringUtils.isEmpty(orderCode)) {
|
||||
throw new ServiceException("orderCode不能为空");
|
||||
}
|
||||
bindShiroUser(1L, "admin", "平台管理员");
|
||||
inventoryDeliveryService.generateServiceBillsWhenAllDelivered(orderCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
|
|||
import com.ruoyi.sip.mapper.InventoryDeliveryMapper;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
|
@ -316,7 +317,86 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService {
|
|||
billService.insertOmsReceivableBill(receivableBill);
|
||||
}
|
||||
|
||||
//生成服务应收单、应付单
|
||||
generateServiceBillsWhenAllDelivered(inventoryDelivery.getOrderCode());
|
||||
}
|
||||
|
||||
/**
|
||||
生成服务应收单、应付单
|
||||
*/
|
||||
@Override
|
||||
public void generateServiceBillsWhenAllDelivered(String orderCode) {
|
||||
ProjectOrderInfo orderInfo = projectOrderInfoService.selectProjectOrderInfoByOrderCode(orderCode);
|
||||
if (ObjectUtils.isEmpty(orderInfo)) {
|
||||
throw new ServiceException("无对应订单信息");
|
||||
}
|
||||
if (!ProjectOrderInfo.DeliveryStatusEnum.ALL_DELIVERY.getCode().equals(orderInfo.getDeliveryStatus())) {
|
||||
throw new ServiceException("当前订单未全部发货");
|
||||
}
|
||||
List<ProjectProductInfo> serviceProductInfos = CollUtil.isEmpty(orderInfo.getMaintenanceProjectProductInfoList())
|
||||
? Collections.emptyList()
|
||||
: orderInfo.getMaintenanceProjectProductInfoList();
|
||||
if (CollUtil.isEmpty(serviceProductInfos)) {
|
||||
return;
|
||||
}
|
||||
OmsPayableBill payableQuery = new OmsPayableBill();
|
||||
payableQuery.setOrderCode(orderInfo.getOrderCode());
|
||||
Set<String> existsPayableProductCodeSet = payableBillService.selectOmsPayableBillList(payableQuery).stream()
|
||||
.filter(item -> StringUtils.isEmpty(item.getInventoryCode()))
|
||||
.map(OmsPayableBill::getProductCode)
|
||||
.filter(StringUtils::isNotEmpty)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
OmsReceivableBill receivableQuery = new OmsReceivableBill();
|
||||
receivableQuery.setOrderCode(orderInfo.getOrderCode());
|
||||
Set<String> existsReceivableProductCodeSet = billService.selectOmsReceivableBillList(receivableQuery).stream()
|
||||
.filter(item -> StringUtils.isEmpty(item.getInventoryCode()))
|
||||
.map(OmsReceivableBill::getProductCode)
|
||||
.filter(StringUtils::isNotEmpty)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
for (ProjectProductInfo serviceProductInfo : serviceProductInfos) {
|
||||
BigDecimal totalPriceWithTax = Optional.ofNullable(serviceProductInfo.getAllPrice())
|
||||
.orElse(Optional.ofNullable(serviceProductInfo.getPrice()).orElse(BigDecimal.ZERO)
|
||||
.multiply(new BigDecimal(Optional.ofNullable(serviceProductInfo.getQuantity()).orElse(0L))));
|
||||
BigDecimal taxRate = serviceProductInfo.getTaxRate() == null
|
||||
? new BigDecimal(defaultTax)
|
||||
: serviceProductInfo.getTaxRate().divide(new BigDecimal("100"));
|
||||
BigDecimal totalPriceWithoutTax = totalPriceWithTax.divide(BigDecimal.ONE.add(taxRate), 2, RoundingMode.HALF_UP);
|
||||
|
||||
String productCode = serviceProductInfo.getProductBomCode();
|
||||
if (!existsPayableProductCodeSet.contains(productCode)) {
|
||||
OmsPayableBill servicePayableBill = new OmsPayableBill();
|
||||
servicePayableBill.setProductCode(productCode);
|
||||
servicePayableBill.setProductType(serviceProductInfo.getType());
|
||||
servicePayableBill.setProductLevel2Type(serviceProductInfo.getLevel2Type());
|
||||
servicePayableBill.setVendorCode(serviceProductInfo.getVendorCode());
|
||||
servicePayableBill.setTotalPriceWithTax(totalPriceWithTax);
|
||||
servicePayableBill.setTaxRate(taxRate);
|
||||
servicePayableBill.setTotalPriceWithoutTax(totalPriceWithoutTax);
|
||||
servicePayableBill.setTaxAmount(totalPriceWithTax.subtract(totalPriceWithoutTax));
|
||||
servicePayableBill.setOrderCode(orderInfo.getOrderCode());
|
||||
payableBillService.insertOmsPayableBill(servicePayableBill, 0);
|
||||
existsPayableProductCodeSet.add(productCode);
|
||||
}
|
||||
|
||||
if (!existsReceivableProductCodeSet.contains(productCode)) {
|
||||
OmsReceivableBill serviceReceivableBill = new OmsReceivableBill();
|
||||
serviceReceivableBill.setProductCode(productCode);
|
||||
serviceReceivableBill.setProductType(serviceProductInfo.getType());
|
||||
serviceReceivableBill.setPartnerCode(orderInfo.getPartnerCode());
|
||||
serviceReceivableBill.setPartnerName(orderInfo.getPartnerName());
|
||||
serviceReceivableBill.setOrderCode(orderInfo.getOrderCode());
|
||||
serviceReceivableBill.setTotalPriceWithTax(totalPriceWithTax);
|
||||
serviceReceivableBill.setTaxRate(taxRate);
|
||||
serviceReceivableBill.setTotalPriceWithoutTax(totalPriceWithoutTax);
|
||||
serviceReceivableBill.setTaxAmount(totalPriceWithTax.subtract(totalPriceWithoutTax));
|
||||
serviceReceivableBill.setUninvoicedAmount(totalPriceWithTax);
|
||||
serviceReceivableBill.setUnreceivedAmount(totalPriceWithTax);
|
||||
billService.insertOmsReceivableBill(serviceReceivableBill);
|
||||
existsReceivableProductCodeSet.add(productCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -416,6 +496,29 @@ public class InventoryDeliveryServiceImpl implements IInventoryDeliveryService {
|
|||
projectOrderInfoService.updateProjectOrderInfoByCode(updateOrder);
|
||||
//修改累计发货数量
|
||||
productInfoService.updateCumulativeCount(-inventoryDelivery.getQuantity(), inventoryDelivery.getProductCode());
|
||||
//撤回时删除当前出库单对应的应付、应收数据(仅删除软件和硬件类型:1、2)
|
||||
Set<String> deleteProductTypeSet = new HashSet<>(Arrays.asList(
|
||||
ProductInfo.ProductTypeEnum.SOFTWARE.getType(),
|
||||
ProductInfo.ProductTypeEnum.HARDWARE.getType()
|
||||
));
|
||||
OmsPayableBill queryPayable = new OmsPayableBill();
|
||||
queryPayable.setInventoryCode(inventoryDelivery.getOuterCode());
|
||||
List<OmsPayableBill> payableBills = payableBillService.selectOmsPayableBillList(queryPayable).stream()
|
||||
.filter(item -> deleteProductTypeSet.contains(item.getProductType()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(payableBills)) {
|
||||
String ids = payableBills.stream().map(item -> String.valueOf(item.getId())).collect(Collectors.joining(","));
|
||||
payableBillService.deleteOmsPayableBillByIds(ids);
|
||||
}
|
||||
OmsReceivableBill queryReceivable = new OmsReceivableBill();
|
||||
queryReceivable.setInventoryCode(inventoryDelivery.getOuterCode());
|
||||
List<OmsReceivableBill> receivableBills = billService.selectOmsReceivableBillList(queryReceivable).stream()
|
||||
.filter(item -> deleteProductTypeSet.contains(item.getProductType()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(receivableBills)) {
|
||||
String ids = receivableBills.stream().map(item -> String.valueOf(item.getId())).collect(Collectors.joining(","));
|
||||
billService.deleteOmsReceivableBillByIds(ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="orderCode" column="order_code" />
|
||||
<result property="inventoryCode" column="inventory_code" />
|
||||
<result property="productType" column="product_type" />
|
||||
<result property="productCode" column="product_code" />
|
||||
<result property="productLevel2Type" column="product_level2_type" />
|
||||
<result property="totalPriceWithTax" column="total_price_with_tax" />
|
||||
<result property="totalPriceWithoutTax" column="total_price_without_tax" />
|
||||
|
|
@ -39,6 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
t1.order_code,
|
||||
t1.inventory_code,
|
||||
t1.product_type,
|
||||
t1.product_code,
|
||||
t1.total_price_with_tax,
|
||||
t1.total_price_without_tax,
|
||||
t1.tax_amount,
|
||||
|
|
@ -80,6 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
t1.tax_rate,
|
||||
t1.remark,
|
||||
t1.del_flag ,
|
||||
t1.product_code,
|
||||
t3.project_code,
|
||||
t3.project_name,
|
||||
t4.vendor_name,
|
||||
|
|
@ -119,6 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{inventoryCode},'%')
|
||||
</if>
|
||||
<if test="productType != null and productType != ''">and t1.product_type = #{productType}</if>
|
||||
<if test="productCode != null and productCode != ''">and t1.product_code = #{productCode}</if>
|
||||
<if test="totalPriceWithTax != null ">and t1.total_price_with_tax = #{totalPriceWithTax}</if>
|
||||
<if test="totalPriceWithoutTax != null ">and t1.total_price_without_tax = #{totalPriceWithoutTax}</if>
|
||||
<if test="taxAmount != null ">and t1.tax_amount = #{taxAmount}</if>
|
||||
|
|
@ -286,6 +290,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="orderCode != null">order_code = #{orderCode},</if>
|
||||
<if test="inventoryCode != null">inventory_code = #{inventoryCode},</if>
|
||||
<if test="productType != null">product_type = #{productType},</if>
|
||||
<if test="productCode != null">product_code = #{productCode},</if>
|
||||
<if test="totalPriceWithTax != null">total_price_with_tax = #{totalPriceWithTax},</if>
|
||||
<if test="totalPriceWithoutTax != null">total_price_without_tax = #{totalPriceWithoutTax},</if>
|
||||
<if test="taxAmount != null">tax_amount = #{taxAmount},</if>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="orderCode" column="order_code" />
|
||||
<result property="inventoryCode" column="inventory_code" />
|
||||
<result property="productType" column="product_type" />
|
||||
<result property="productCode" column="product_code" />
|
||||
<result property="totalPriceWithTax" column="total_price_with_tax" />
|
||||
<result property="totalPriceWithoutTax" column="total_price_without_tax" />
|
||||
<result property="taxRate" column="tax_rate" />
|
||||
|
|
@ -31,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectOmsReceivableBillVo">
|
||||
select t1.id, t1.receivable_bill_code, t1.last_receipt_plan_id, t1.last_invoice_plan_id, t1.partner_code, t1.partner_name, t1.order_code, t1.inventory_code, t1.product_type,
|
||||
select t1.id, t1.receivable_bill_code, t1.last_receipt_plan_id, t1.last_invoice_plan_id, t1.partner_code, t1.partner_name, t1.order_code, t1.inventory_code, t1.product_type, t1.product_code,
|
||||
t1.total_price_with_tax, t1.total_price_without_tax, t1.tax_rate, t1.tax_amount, t1.received_amount, t1.unreceived_amount,
|
||||
t1.invoiced_amount, t1.uninvoiced_amount, t1.create_by, t1.create_time, t1.update_by, t1.update_time, t1.remark, t1.del_flag
|
||||
,t3.project_name, t3.project_code
|
||||
|
|
@ -68,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="orderCode != null and orderCode != ''"> and t1.order_code = #{orderCode}</if>
|
||||
<if test="inventoryCode != null and inventoryCode != ''"> and t1.inventory_code = #{inventoryCode}</if>
|
||||
<if test="productType != null and productType != ''"> and t1.product_type = #{productType}</if>
|
||||
<if test="productCode != null and productCode != ''"> and t1.product_code = #{productCode}</if>
|
||||
<if test="createBy != null and createBy != ''"> and t1.create_by = #{createBy}</if>
|
||||
<if test="projectCode != null and projectCode != ''">and t3.project_code = #{projectCode}</if>
|
||||
<if test="projectName != null and projectName != ''"> and t3.project_name like concat('%', #{projectName}, '%')</if>
|
||||
|
|
@ -100,6 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="orderCode != null and orderCode != ''">order_code,</if>
|
||||
<if test="inventoryCode != null and inventoryCode != ''">inventory_code,</if>
|
||||
<if test="productType != null and productType != ''">product_type,</if>
|
||||
<if test="productCode != null and productCode != ''">product_code,</if>
|
||||
<if test="totalPriceWithTax != null">total_price_with_tax,</if>
|
||||
<if test="totalPriceWithoutTax != null">total_price_without_tax,</if>
|
||||
<if test="taxRate != null">tax_rate,</if>
|
||||
|
|
@ -124,6 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="orderCode != null and orderCode != ''">#{orderCode},</if>
|
||||
<if test="inventoryCode != null and inventoryCode != ''">#{inventoryCode},</if>
|
||||
<if test="productType != null and productType != ''">#{productType},</if>
|
||||
<if test="productCode != null and productCode != ''">#{productCode},</if>
|
||||
<if test="totalPriceWithTax != null">#{totalPriceWithTax},</if>
|
||||
<if test="totalPriceWithoutTax != null">#{totalPriceWithoutTax},</if>
|
||||
<if test="taxRate != null">#{taxRate},</if>
|
||||
|
|
@ -152,6 +156,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="orderCode != null and orderCode != ''">order_code = #{orderCode},</if>
|
||||
<if test="inventoryCode != null and inventoryCode != ''">inventory_code = #{inventoryCode},</if>
|
||||
<if test="productType != null and productType != ''">product_type = #{productType},</if>
|
||||
<if test="productCode != null and productCode != ''">product_code = #{productCode},</if>
|
||||
<if test="totalPriceWithTax != null">total_price_with_tax = #{totalPriceWithTax},</if>
|
||||
<if test="totalPriceWithoutTax != null">total_price_without_tax = #{totalPriceWithoutTax},</if>
|
||||
<if test="taxRate != null">tax_rate = #{taxRate},</if>
|
||||
|
|
@ -168,11 +173,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</update>
|
||||
|
||||
<delete id="deleteOmsReceivableBillById" parameterType="Long">
|
||||
update oms_receivable_bill set del_flag = '2' where id = #{id}
|
||||
delete from oms_receivable_bill where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteOmsReceivableBillByIds" parameterType="String">
|
||||
update oms_receivable_bill set del_flag = '2' where id in
|
||||
delete from oms_receivable_bill where id in
|
||||
<foreach item="id" collection="ids.split(',')" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
|
|
@ -185,7 +190,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
AND receivable_bill_code REGEXP CONCAT('^', #{codePrefix}, '[0-9]+$')
|
||||
</select>
|
||||
<select id="listReceivableBill" resultType="com.ruoyi.sip.domain.OmsReceivableBill">
|
||||
select t1.id, t1.receivable_bill_code, t1.last_receipt_plan_id, t1.last_invoice_plan_id, t1.partner_code, t1.partner_name, t1.order_code, t1.inventory_code, t1.product_type,
|
||||
select t1.id, t1.receivable_bill_code, t1.last_receipt_plan_id, t1.last_invoice_plan_id, t1.partner_code, t1.partner_name, t1.order_code, t1.inventory_code, t1.product_type, t1.product_code,
|
||||
t1.total_price_with_tax, t1.total_price_without_tax, t1.tax_rate, t1.tax_amount, t1.received_amount, t1.unreceived_amount,
|
||||
t1.invoiced_amount, t1.uninvoiced_amount, t1.create_by, t1.create_time, t1.update_by, t1.update_time, t1.remark, t1.del_flag
|
||||
from oms_receivable_bill t1
|
||||
|
|
|
|||
Loading…
Reference in New Issue