use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class ProductsToPickRowsDataFactory method allocateRowFromHU.
@Nullable
private ProductsToPickRow allocateRowFromHU(final ProductsToPickRow row, final AllocablePackageable packageable) {
if (packageable.isAllocated()) {
return null;
}
final HuId pickFromHUId = row.getPickFromHUId();
if (pickFromHUId == null) {
throw new AdempiereException("No pickFromHUId set for " + row);
}
final ProductId productId = packageable.getProductId();
final ReservableStorage storage = storages.getStorage(pickFromHUId, productId);
final Quantity qty = storage.reserve(packageable);
if (qty.isZero()) {
return null;
}
return row.withQty(qty);
}
use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class OrderLineQuickInputCallout method updateM_HU_PI_Item_Product.
private void updateM_HU_PI_Item_Product(@NonNull final QuickInput quickInput) {
if (!quickInput.hasField(IOrderLineQuickInput.COLUMNNAME_M_HU_PI_Item_Product_ID)) {
// there are users whose systems don't have M_HU_PI_Item_Product_ID in their quick-input
return;
}
final IOrderLineQuickInput quickInputModel = quickInput.getQuickInputDocumentAs(IOrderLineQuickInput.class);
final LookupValue productLookupValue = quickInputModel.getM_Product_ID();
if (productLookupValue == null) {
return;
}
final ProductAndAttributes productAndAttributes = ProductLookupDescriptor.toProductAndAttributes(productLookupValue);
final ProductId quickInputProductId = productAndAttributes.getProductId();
final I_C_Order order = quickInput.getRootDocumentAs(I_C_Order.class);
final Optional<DefaultPackingItemCriteria> defaultPackingItemCriteria = DefaultPackingItemCriteria.of(order, quickInputProductId);
final I_M_HU_PI_Item_Product huPIItemProduct = defaultPackingItemCriteria.flatMap(packingItemProductFieldHelper::getDefaultPackingMaterial).orElse(null);
quickInputModel.setM_HU_PI_Item_Product(huPIItemProduct);
}
use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class OrderLineQuickInputProcessor method validateInput.
private void validateInput(final OrderLineCandidate candidate) {
final BPartnerId bpartnerId = candidate.getBpartnerId();
final ProductId productId = candidate.getProductId();
final SOTrx soTrx = candidate.getSoTrx();
final ArrayList<ITranslatableString> validationErrorMessages = new ArrayList<>();
for (final IOrderLineInputValidator validator : validators) {
final OrderLineInputValidatorResults validationResults = validator.validate(bpartnerId, productId, soTrx);
if (validationResults != null && !validationResults.isValid() && validationResults.getErrorMessage() != null) {
validationErrorMessages.add(validationResults.getErrorMessage());
}
}
if (!validationErrorMessages.isEmpty()) {
throw new AdempiereException(TranslatableStrings.joinList("\n", validationErrorMessages));
}
}
use of de.metas.product.ProductId 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;
}
use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class ShipmentCandidateRow method getWebuiASIEditingInfo.
@Override
public WebuiASIEditingInfo getWebuiASIEditingInfo(@NonNull final AttributeSetInstanceId asiId) {
final ProductId productId = product.getIdAs(ProductId::ofRepoIdOrNull);
final ASIEditingInfo info = ASIEditingInfo.builder().type(WindowType.Regular).productId(productId).attributeSetInstanceId(asiId).callerTableName(null).callerColumnId(-1).soTrx(SOTrx.SALES).build();
return WebuiASIEditingInfo.builder(info).build();
}
Aggregations