|
@@ -126,7 +126,35 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
}
|
|
|
//开票成本 - 辅料
|
|
|
List<FabricCostAssist> fabricCostAssistList = fabricLossMapper.getCostAssistList(code);
|
|
|
+ // 去掉成本发票中的转入成本,根据订单号+物料编号
|
|
|
+ List<FabricCostInvoice> costInvoiceList = ret.getFabricCostInvoiceList();
|
|
|
+ if (oConvertUtils.listIsNotEmpty(costInvoiceList)){
|
|
|
+ List<FabricCostInvoice> filterList = costInvoiceList.stream().filter(e->"转入成本".equalsIgnoreCase(e.getCBusType())).collect(Collectors.toList());
|
|
|
+ if (oConvertUtils.listIsNotEmpty(filterList)){
|
|
|
+ for (FabricCostInvoice invoice : filterList){
|
|
|
+ List<FabricCostInvoiceDetail> costInvoiceDetailList = invoice.getCostInvoiceDetailList();
|
|
|
+ if (oConvertUtils.listIsNotEmpty(costInvoiceDetailList)){
|
|
|
+ for (FabricCostInvoiceDetail detail : costInvoiceDetailList){
|
|
|
+ Double dQuantity = detail.getIQuantity();
|
|
|
+ List<FabricCostAssist> findCostAssistList = fabricCostAssistList.stream().filter(e->e.getCostInvoiceDetailMatchId().equalsIgnoreCase(detail.getCostAssistMatchId())).collect(Collectors.toList());
|
|
|
+ if (oConvertUtils.listIsNotEmpty(findCostAssistList)){
|
|
|
+ for (FabricCostAssist assist : findCostAssistList){
|
|
|
+ Double dSub = Math.min(dQuantity, assist.getIQuantityIn());
|
|
|
+ assist.setIQuantityIn(DoubleOperation.sub(assist.getIQuantityIn(),dSub));
|
|
|
+ dQuantity = DoubleOperation.sub(dQuantity, dSub);
|
|
|
+ if (dQuantity<=0){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fabricCostAssistList = fabricCostAssistList.stream().filter(e->e.getIQuantityIn()>0).collect(Collectors.toList());
|
|
|
for (FabricCostAssist fabricCostAssist : fabricCostAssistList){
|
|
|
+
|
|
|
List<FabricCostAssistDetail> fabricCostAssistDetailList = new ArrayList<>();
|
|
|
FabricCostAssistDetail fabricCostAssistDetail = new FabricCostAssistDetail();
|
|
|
fabricCostAssistDetail.setIQuantityInvoice(fabricCostAssist.getIQuantityInvoice());
|
|
@@ -502,7 +530,7 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
}
|
|
|
// 获取本次采购入库详情
|
|
|
List<FabricPoOrderIn> fabricPoOrderInList = fabricLossMapper.getPurchaseInList(code);
|
|
|
- // 设置未开票数量和未结算数量,采购单价
|
|
|
+ // 设置未开票数量和未结算数量,采购单价,采购单价设置成:开票数量/结算数量*单价
|
|
|
for (FabricPoOrderIn fabricPoOrderIn: fabricPoOrderInList){
|
|
|
fabricPoOrderIn.setIQuantityNInvoice(DoubleOperation.sub(fabricPoOrderIn.getIQuantity(),fabricPoOrderIn.getIQuantityInvoice()));
|
|
|
fabricPoOrderIn.setIQuantityNSettle(DoubleOperation.sub(fabricPoOrderIn.getIQuantity(),fabricPoOrderIn.getIQuantitySettle()));
|
|
@@ -512,7 +540,11 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
FabricMoOrderCK findItem = findOpt.get();
|
|
|
fabricPoOrderIn.setIPrice(DoubleOperation.getScale(findItem.getIPrice(),4));
|
|
|
}else {
|
|
|
- fabricPoOrderIn.setIPrice(DoubleOperation.getScale(fabricPoOrderIn.getIPrice(),4));
|
|
|
+ if (fabricPoOrderIn.getIQuantitySettle() != 0 && fabricPoOrderIn.getIQuantityInvoice() != 0){
|
|
|
+ fabricPoOrderIn.setIPrice(DoubleOperation.getScale(fabricPoOrderIn.getIPrice()*fabricPoOrderIn.getIQuantityInvoice()/fabricPoOrderIn.getIQuantitySettle(),4));
|
|
|
+ }else {
|
|
|
+ fabricPoOrderIn.setIPrice(DoubleOperation.getScale(fabricPoOrderIn.getIPrice(), 4));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -848,12 +880,28 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
List<FabricCommonIn> otherInList = new ArrayList<>();
|
|
|
if (otherInInvId.size()>0) {
|
|
|
otherInList = fabricLossMapper.getInListByInvId(otherInInvId);
|
|
|
-
|
|
|
- otherInList.forEach(e -> e.setITempUseSum(0.0));
|
|
|
+ // 设置单价比例
|
|
|
+ otherInList.forEach(e -> {
|
|
|
+ e.setITempUseSum(0.0);
|
|
|
+ if (e.getIQuantityInvoice() != 0 && e.getIQuantitySettle() != 0){
|
|
|
+ e.setIPrice(DoubleOperation.getScale(e.getIPrice()*e.getIQuantityInvoice()/e.getIQuantitySettle(),4));
|
|
|
+ }
|
|
|
+ });
|
|
|
// 设置其他委外订单入库的材料成本,只计算一层
|
|
|
setOtherOmInPriceList(code, otherInList);
|
|
|
// 设置形态转换入库成本,及源头物料
|
|
|
setAssemVouchInPriceList(otherInList);
|
|
|
+ // 批号为空的,去掉订单号,日期,金额为0
|
|
|
+ for (FabricCommonIn commonIn : otherInList){
|
|
|
+ if (oConvertUtils.isEmpty(commonIn.getCBatch())){
|
|
|
+ commonIn.setCPlanCode("");
|
|
|
+ commonIn.setDDate(null);
|
|
|
+ commonIn.setIPrice(0.0);
|
|
|
+ commonIn.setCCode("");
|
|
|
+ commonIn.setCVenAbbName("");
|
|
|
+ commonIn.setCVenName("");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
// 设置非本次委外加工出入库成本
|
|
|
List<FabricMoOrderCK> findOutList = rowOutList.stream().filter(e->e.getIQuantityOut()!=0).collect(Collectors.toList());
|
|
@@ -1028,8 +1076,14 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
List<String> invIdList = new ArrayList<>();
|
|
|
outList.forEach(e->invIdList.add(e.getInvOutId()));
|
|
|
List<FabricCommonIn> inList = fabricLossMapper.getInListByInvId(invIdList);
|
|
|
- // 入库价格保留四位小数
|
|
|
- inList.forEach(e->e.setIPrice(DoubleOperation.getScale(e.getIPrice(),4)));
|
|
|
+ // 设置价格比例,入库价格保留四位小数
|
|
|
+ inList.forEach(e->{
|
|
|
+ if (e.getIQuantityInvoice() != 0 && e.getIQuantitySettle() != 0){
|
|
|
+ e.setIPrice(DoubleOperation.getScale(e.getIPrice()*e.getIQuantityInvoice()/e.getIQuantitySettle(),4));
|
|
|
+ }else {
|
|
|
+ e.setIPrice(DoubleOperation.getScale(e.getIPrice(), 4));
|
|
|
+ }
|
|
|
+ });
|
|
|
// 设置形态转换的源头单价,及源头物料
|
|
|
setAssemVouchInPriceList(inList);
|
|
|
|
|
@@ -1133,6 +1187,11 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
!"委外入库".equalsIgnoreCase(e.getCBusType())).map(FabricAssemVouchsOrgIn::getAutoId).collect(Collectors.toList());
|
|
|
if (autoIdList.size()>0){
|
|
|
List<FabricInPrice> priceList = fabricLossMapper.getPoInPriceList(autoIdList);
|
|
|
+ priceList.forEach(e -> {
|
|
|
+ if (e.getIQuantityInvoice() != 0 && e.getIQuantitySettle() != 0){
|
|
|
+ e.setIPrice(DoubleOperation.getScale(e.getIPrice()*e.getIQuantityInvoice()/e.getIQuantitySettle(),4));
|
|
|
+ }
|
|
|
+ });
|
|
|
setAssemVouchsInPrice(commonInList, assemVouchsInvIdList, priceList);
|
|
|
}
|
|
|
|
|
@@ -1158,8 +1217,14 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
List<String> invIdList = new ArrayList<>();
|
|
|
outList.forEach(e->invIdList.add(e.getInvOutId()));
|
|
|
List<FabricCommonIn> inList = fabricLossMapper.getInListByInvId(invIdList);
|
|
|
- // 入库价格保留四位小数
|
|
|
- inList.forEach(e->e.setIPrice(DoubleOperation.getScale(e.getIPrice(),4)));
|
|
|
+ // 设置价格比例,入库价格保留四位小数
|
|
|
+ inList.forEach(e-> {
|
|
|
+ if (e.getIQuantityInvoice() != 0 && e.getIQuantitySettle() != 0){
|
|
|
+ e.setIPrice(DoubleOperation.getScale(e.getIPrice()*e.getIQuantityInvoice()/e.getIQuantitySettle(),4));
|
|
|
+ }else {
|
|
|
+ e.setIPrice(DoubleOperation.getScale(e.getIPrice(), 4));
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
for (Integer detailId : moDetailIdList){
|
|
|
Double iOutTotalMoney = 0.0;// 出库材料费用
|
|
@@ -1485,6 +1550,11 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
|
|
|
List<String> invIdList = new ArrayList<>();
|
|
|
otherOutList.forEach(e -> invIdList.add(e.getInvOutId()));
|
|
|
List<FabricCommonIn> inList = fabricLossMapper.getInListByInvId(invIdList);
|
|
|
+ inList.forEach(e -> {
|
|
|
+ if (e.getIQuantityInvoice() != 0 && e.getIQuantitySettle() != 0){
|
|
|
+ e.setIPrice(DoubleOperation.getScale(e.getIPrice()*e.getIQuantityInvoice()/e.getIQuantitySettle(),4));
|
|
|
+ }
|
|
|
+ });
|
|
|
inList = getAssemVouchSourceInvId(inList);
|
|
|
for (FabricCommonIn item : inList) {
|
|
|
List<FabricMoOrderCK> findList = otherOutList.stream().filter(e -> e.getInvOutId().equalsIgnoreCase(item.getInvId())).collect(Collectors.toList());
|