Browse Source

[feat] 添加采购订单物料列表中,采购物料转财务应付账款数据,数据转换为以供应商为分组,合计对每个供应商的应付账款,生成不同的供应商相关应付账款。需查询供应商相关资料,相关资料获取有开户银行,付款条件。

dev
zhangsiqi 4 months ago
parent
commit
ad9f5c11aa
  1. 2
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java
  2. 3
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderChildService.java
  3. 2
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java
  4. 78
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java
  5. 1
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java

2
ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java

@ -169,6 +169,8 @@ public class PurchaseOrderController extends BaseController
purchaseOrder.setUseStatus("0");
purchaseOrder.setDelFlag("0");
purchaseOrderService.insertPurchaseOrder(purchaseOrder);
purchaseOrderService.addPurchaseOrderPayable(purchaseOrder);
// 数据校验,确保前端传入数据格式正确
// 执行主表插入操作
return AjaxResult.success(); // 假设toAjax方法处理成功逻辑

3
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderChildService.java

@ -1,6 +1,8 @@
package com.ruoyi.purchase.service;
import java.util.List;
import com.ruoyi.purchase.domain.PurchaseOrder;
import com.ruoyi.purchase.domain.PurchaseOrderChild;
/**
@ -78,4 +80,5 @@ public interface IPurchaseOrderChildService
List<PurchaseOrderChild> selectPurchaseOrderChildByOrderCodeTotal(String purchaseOrderCode);
List<PurchaseOrderChild> selectPurchaseOrderStorageByPurchaseOrderCode(String purchaseOrderCode);
}

2
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java

@ -73,6 +73,8 @@ public interface IPurchaseOrderService
int addPurchaseOrderStorage(WarehouseStorageOrder warehouseStorageOrder);
Integer addPurchaseOrderPayable(PurchaseOrder purchaseOrder);
@Transactional(rollbackFor = Exception.class)
ProcessInstance submitApply(PurchaseOrder purchaseOrder);

78
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java

@ -3,25 +3,27 @@ package com.ruoyi.purchase.service.impl;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.service.ICommonService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.financial.domain.FinancialAccountsPayable;
import com.ruoyi.financial.service.IFinancialAccountsPayableService;
import com.ruoyi.financial.service.impl.FinancialAccountsPayableServiceImpl;
import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper;
import com.ruoyi.purchase.domain.PurchaseOrder;
import com.ruoyi.purchase.domain.PurchaseOrderChild;
import com.ruoyi.purchase.domain.PurchaseOrderVo;
import com.ruoyi.purchase.domain.PurchasePlan;
import com.ruoyi.purchase.mapper.PurchaseOrderChildMapper;
import com.ruoyi.purchase.mapper.PurchaseOrderMapper;
import com.ruoyi.purchase.mapper.PurchasePlanMapper;
import com.ruoyi.purchase.service.IPurchaseOrderService;
import com.ruoyi.system.domain.SysSupplier;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysAttachFileService;
import com.ruoyi.system.service.ISysAttachService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysSupplierService;
import com.ruoyi.warehouse.domain.WarehouseStorageOrder;
import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail;
import com.ruoyi.warehouse.mapper.WarehouseStorageOrderDetailMapper;
@ -35,12 +37,10 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import static com.github.pagehelper.page.PageMethod.startPage;
/**
@ -97,6 +97,9 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
@Autowired
private IFinancialAccountsPayableService financialAccountsPayableService;
@Autowired
private ISysSupplierService sysSupplierService;
/**
* 查询采购订单
*
@ -437,7 +440,70 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
return result;
}
@Transactional(rollbackFor = Exception.class)
@Override
public Integer addPurchaseOrderPayable(PurchaseOrder purchaseOrder) {
//根据供应商划分物料信息,合计物料不含税单价 ,含税单价,含税总价,不含税总价,实际采购数量
// 获取采购订单的子项列表
List<PurchaseOrderChild> children = purchaseOrder.getPurchaseOrderChildList();
BigDecimal apySupplierNoRmbPrice = new BigDecimal(0);
BigDecimal apySupplierTaxRmbPrice = new BigDecimal(0);
// 分组供应商的子订单,分组统计各供应商应付单供应商
List<PurchaseOrderChild> supplierGroup = (List<PurchaseOrderChild>) children.stream()
// 分组依据为supplierCode
.collect(Collectors.groupingBy(PurchaseOrderChild::getSupplierCode))
// 把每个分组转为流,然后取第一个元素
.values().stream()
.map(groupSupplier -> groupSupplier.stream().findFirst().orElse(null))
// 过滤掉null值,以防万一某些分组是空的
.filter(Objects::nonNull)
.collect(Collectors.toList());
//根据物料中提出的供应商列表核对, 遍历每个相关的子订单,合计数据量
for (PurchaseOrderChild purchaseOrderChild : supplierGroup) {
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrder.getPurchaseOrderChildList();
FinancialAccountsPayable financialAccountsPayable = new FinancialAccountsPayable();
financialAccountsPayable.setAccountsPayableCode(redisCache.generateBillNo("YF"));
financialAccountsPayable.setRelevanceCode(purchaseOrder.getPurchaseOrderCode());
for (PurchaseOrderChild purchaseOrderChild1 : purchaseOrderChildList) {
BigDecimal supplierNoRmbPrice = purchaseOrderChild1.getMaterialRealNoRmbSum();
BigDecimal supplierRmbTaxPrice = purchaseOrderChild1.getMaterialRealRmbSum();
//供应商应付账款 不含税金额
apySupplierNoRmbPrice = supplierNoRmbPrice.add(supplierNoRmbPrice);
//供应商应付账款 含税金额
apySupplierTaxRmbPrice = apySupplierTaxRmbPrice.add(supplierRmbTaxPrice);
//每当当前供应商完成一次循环,生成一条供应商应付账款
SysSupplier sysSupplier = new SysSupplier();
sysSupplier.setSupplierCode(purchaseOrderChild1.getSupplierCode());
List<SysSupplier> sysSupplierList = sysSupplierService.selectSysSupplierList(sysSupplier);
financialAccountsPayable.setSupplierCode(purchaseOrderChild.getSupplierCode());
financialAccountsPayable.setSupplierName(purchaseOrderChild.getSupplierName());
int supplierListSize = sysSupplierList.size();
if(supplierListSize == 0){
continue;
}else{
SysSupplier sysSupplier1 = sysSupplierList.get(0);
//获取供应商相关的信息
financialAccountsPayable.setOpenBank(sysSupplier1.getDepositBank());
financialAccountsPayable.setOpenAccount(sysSupplier1.getBankAccount());
financialAccountsPayable.setPaymentCondition(sysSupplier1.getPaymentTerms());
}
}
financialAccountsPayable.setCreateBy(ShiroUtils.getLoginName());
financialAccountsPayable.setCreateTime(DateUtils.getNowDate());
financialAccountsPayable.setPurchaseBuyer(purchaseOrder.getPurchaseBuyer());
//不含税金额
financialAccountsPayable.setPriceExcludingTax(apySupplierNoRmbPrice);
//含税金额
financialAccountsPayable.setPriceIncludesTax(apySupplierTaxRmbPrice);
financialAccountsPayable.setStorageStatus("0");
financialAccountsPayable.setAccountsPayableStatus("0");
financialAccountsPayableService.insertFinancialAccountsPayable(financialAccountsPayable);
}
//根据供应商编分组,合计供应商总共合计了多少数,采购物采购,采购物料料
return 1; // 返回成功标识
}
@Transactional(rollbackFor = Exception.class)
public ProcessInstance submitApply(PurchaseOrder purchaseOrder) {
SysUser user = ShiroUtils.getSysUser();

1
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java

@ -182,7 +182,6 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
//统计物料种类的数量
Integer materialAmount = filterUniqueBoms.size();
// 仅查询一次,因为所有SysMakeorderBom都关联同一生产单号
SysMakeOrder sysMakeOrder = sysMakeOrderMapper.selectMakeOrderByMakeNo(insertedSysMakeorderBoms.get(0).getMakeNo());

Loading…
Cancel
Save