|
|
@ -41,6 +41,7 @@ import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
import static com.github.pagehelper.page.PageMethod.offsetPage; |
|
|
|
import static com.github.pagehelper.page.PageMethod.startPage; |
|
|
|
|
|
|
|
/** |
|
|
@ -455,8 +456,6 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
|
//根据供应商划分物料信息,合计物料不含税单价 ,含税单价,含税总价,不含税总价,实际采购数量
|
|
|
|
// 获取采购订单的子项列表
|
|
|
|
List<PurchaseOrderChild> children = purchaseOrder.getPurchaseOrderChildList(); |
|
|
|
BigDecimal apySupplierNoRmbPrice = new BigDecimal(0); |
|
|
|
BigDecimal apySupplierTaxRmbPrice = new BigDecimal(0); |
|
|
|
// 分组供应商的子订单,分组统计各供应商应付单供应商
|
|
|
|
List<PurchaseOrderChild> supplierGroup = (List<PurchaseOrderChild>) children.stream() |
|
|
|
// 分组依据为supplierCode
|
|
|
@ -469,43 +468,55 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
|
.collect(Collectors.toList()); |
|
|
|
//根据物料中提出的供应商列表核对, 遍历每个相关的子订单,合计数据量
|
|
|
|
for (PurchaseOrderChild purchaseOrderChild : supplierGroup) { |
|
|
|
//初始化合计数
|
|
|
|
BigDecimal supplierNoRmbPrice = BigDecimal.ZERO; |
|
|
|
BigDecimal supplierRmbTaxPrice = BigDecimal.ZERO; |
|
|
|
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; |
|
|
|
//如果是如上述的供应商,则进行统计
|
|
|
|
if (purchaseOrderChild1.getSupplierCode().equals(purchaseOrderChild.getSupplierCode())) { |
|
|
|
//供应商应付账款 不含税金额
|
|
|
|
supplierNoRmbPrice = supplierNoRmbPrice.add(purchaseOrderChild1.getMaterialRealNoRmbSum()); |
|
|
|
//供应商应付账款 含税金额
|
|
|
|
supplierRmbTaxPrice = supplierRmbTaxPrice.add(purchaseOrderChild1.getMaterialRealRmbSum()); |
|
|
|
}else{ |
|
|
|
SysSupplier sysSupplier1 = sysSupplierList.get(0); |
|
|
|
//获取供应商相关的信息
|
|
|
|
financialAccountsPayable.setOpenBank(sysSupplier1.getDepositBank()); |
|
|
|
financialAccountsPayable.setOpenAccount(sysSupplier1.getBankAccount()); |
|
|
|
financialAccountsPayable.setPaymentCondition(sysSupplier1.getPaymentTerms()); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
//每当当前供应商完成一次循环,生成一条供应商应付账款
|
|
|
|
SysSupplier sysSupplier = new SysSupplier(); |
|
|
|
sysSupplier.setSupplierCode(purchaseOrderChild.getSupplierCode()); |
|
|
|
List<SysSupplier> sysSupplierList = sysSupplierService.selectSysSupplierList(sysSupplier); |
|
|
|
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.setSupplierCode(purchaseOrderChild.getSupplierCode()); |
|
|
|
//供应商名称
|
|
|
|
financialAccountsPayable.setSupplierName(purchaseOrderChild.getSupplierName()); |
|
|
|
//创建单号人员
|
|
|
|
financialAccountsPayable.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
//创建时间
|
|
|
|
financialAccountsPayable.setCreateTime(DateUtils.getNowDate()); |
|
|
|
//采购订单的采购员
|
|
|
|
financialAccountsPayable.setPurchaseBuyer(purchaseOrder.getPurchaseBuyer()); |
|
|
|
//不含税金额
|
|
|
|
financialAccountsPayable.setPriceExcludingTax(apySupplierNoRmbPrice); |
|
|
|
financialAccountsPayable.setPriceExcludingTax(supplierNoRmbPrice); |
|
|
|
//含税金额
|
|
|
|
financialAccountsPayable.setPriceIncludesTax(apySupplierTaxRmbPrice); |
|
|
|
financialAccountsPayable.setPriceIncludesTax(supplierRmbTaxPrice); |
|
|
|
financialAccountsPayable.setStorageStatus("0"); |
|
|
|
financialAccountsPayable.setAccountsPayableStatus("0"); |
|
|
|
financialAccountsPayableService.insertFinancialAccountsPayable(financialAccountsPayable); |
|
|
|