use of org.eevolution.model.I_PP_Product_BOMLine in project metasfresh-webui-api by metasfresh.
the class OrderLineQuickInputProcessor method explodePhantomBOM.
private List<OrderLineCandidate> explodePhantomBOM(final OrderLineCandidate initialCandidate) {
final ProductId bomProductId = initialCandidate.getProductId();
final I_PP_Product_BOM bom = bomsRepo.getDefaultBOMByProductId(bomProductId).orElse(null);
if (bom == null) {
return ImmutableList.of(initialCandidate);
}
final BOMUse bomUse = BOMUse.ofNullableCode(bom.getBOMUse());
if (!BOMUse.Phantom.equals(bomUse)) {
return ImmutableList.of(initialCandidate);
}
GroupId compensationGroupId = null;
final ArrayList<OrderLineCandidate> result = new ArrayList<>();
final List<I_PP_Product_BOMLine> bomLines = bomsRepo.retrieveLines(bom);
for (final I_PP_Product_BOMLine bomLine : bomLines) {
final ProductBOMLineId bomLineId = ProductBOMLineId.ofRepoId(bomLine.getPP_Product_BOMLine_ID());
final ProductId bomLineProductId = ProductId.ofRepoId(bomLine.getM_Product_ID());
final BigDecimal bomLineQty = bomsService.computeQtyRequired(bomLine, bomProductId, initialCandidate.getQty());
final AttributeSetInstanceId bomLineAsiId = AttributeSetInstanceId.ofRepoIdOrNone(bomLine.getM_AttributeSetInstance_ID());
final ImmutableAttributeSet attributes = asiBL.getImmutableAttributeSetById(bomLineAsiId);
if (compensationGroupId == null) {
compensationGroupId = orderGroupsRepo.createNewGroupId(GroupCreateRequest.builder().orderId(initialCandidate.getOrderId()).name(productBL.getProductName(bomProductId)).build());
}
result.add(initialCandidate.toBuilder().productId(bomLineProductId).attributes(attributes).qty(bomLineQty).compensationGroupId(compensationGroupId).explodedFromBOMLineId(bomLineId).build());
}
return result;
}
Aggregations