use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class WEBUI_C_OrderLineSO_Delete_HUReservation method checkPreconditionsApplicable.
@Override
public ProcessPreconditionsResolution checkPreconditionsApplicable() {
final SalesOrderLine salesOrderLine = WEBUI_C_OrderLineSO_Util.retrieveSalesOrderLine(getView(), salesOrderLineRepository).orElse(null);
if (salesOrderLine == null) {
return ProcessPreconditionsResolution.rejectWithInternalReason("No sales order was set");
}
final ProductId productId = salesOrderLine.getProductId();
final Quantity unreservableQty = retrieveUnreservableQuantity(productId);
if (unreservableQty.signum() <= 0) {
return ProcessPreconditionsResolution.rejectWithInternalReason("No unreservableQty quantity for productId=" + productId);
}
return ProcessPreconditionsResolution.accept();
}
use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class WEBUI_C_OrderLineSO_Make_HUReservation method getParameterDefaultValue.
@Override
public Object getParameterDefaultValue(@NonNull final IProcessDefaultParameter parameter) {
if (PARAMNAME_QTY_TO_RESERVE.equals(parameter.getColumnName())) {
final SalesOrderLine salesOrderLine = WEBUI_C_OrderLineSO_Util.retrieveSalesOrderLine(getView(), salesOrderLineRepository).get();
final ProductId productId = salesOrderLine.getProductId();
final Quantity orderedQty = salesOrderLine.getOrderedQty();
final Quantity reservedQty = huReservationService.retrieveReservedQty(salesOrderLine.getId().getOrderLineId()).orElse(orderedQty.toZero());
final Quantity reservedQtyInSalesOrderUOM = uomConversionBL.convertQuantityTo(reservedQty, UOMConversionContext.of(productId), orderedQty.getUomId());
final Quantity requiredQty = orderedQty.subtract(salesOrderLine.getDeliveredQty()).subtract(reservedQtyInSalesOrderUOM);
final Quantity reservableQty = retrieveReservableQuantity(productId);
final Quantity reservableQtyInSalesOrderUOM = uomConversionBL.convertQuantityTo(reservableQty, UOMConversionContext.of(productId), orderedQty.getUomId());
return requiredQty.min(reservableQtyInSalesOrderUOM).toBigDecimal();
}
return null;
}
use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class OrderLinePricingConditionsViewFactory method createPricingConditionsBreakQuery.
private final PricingConditionsBreakQuery createPricingConditionsBreakQuery(final I_C_OrderLine salesOrderLine) {
final IProductDAO productsRepo = Services.get(IProductDAO.class);
final IAttributeDAO attributesRepo = Services.get(IAttributeDAO.class);
final ProductId productId = ProductId.ofRepoId(salesOrderLine.getM_Product_ID());
final ProductAndCategoryAndManufacturerId product = productsRepo.retrieveProductAndCategoryAndManufacturerByProductId(productId);
final AttributeSetInstanceId asiId = AttributeSetInstanceId.ofRepoIdOrNone(salesOrderLine.getM_AttributeSetInstance_ID());
final ImmutableAttributeSet attributes = attributesRepo.getImmutableAttributeSetById(asiId);
final BigDecimal qty = salesOrderLine.getQtyOrdered();
final BigDecimal price = salesOrderLine.getPriceActual();
return PricingConditionsBreakQuery.builder().product(product).attributes(attributes).qty(qty).price(price).build();
}
use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class ProductsProposalRowsLoader method toProductsProposalRowOrNull.
private ProductsProposalRow toProductsProposalRowOrNull(@NonNull final I_M_ProductPrice record) {
final ProductId productId = ProductId.ofRepoId(record.getM_Product_ID());
final LookupValue product = productLookup.findById(productId);
if (!product.isActive()) {
return null;
}
final HUPIItemProductId packingMaterialId = HUPIItemProductId.ofRepoIdOrNull(record.getM_HU_PI_Item_Product_ID());
final ITranslatableString packingDescription = packingMaterialId != null ? packingMaterialsService.getDisplayName(packingMaterialId) : TranslatableStrings.empty();
return ProductsProposalRow.builder().id(nextRowIdSequence.nextDocumentId()).product(product).packingMaterialId(packingMaterialId).packingDescription(packingDescription).asiDescription(extractProductASIDescription(record)).price(extractProductProposalPrice(record)).qty(null).lastShipmentDays(// will be populated later
null).seqNo(record.getSeqNo()).productPriceId(ProductPriceId.ofRepoId(record.getM_ProductPrice_ID())).build().withExistingOrderLine(order);
}
use of de.metas.product.ProductId in project metasfresh-webui-api by metasfresh.
the class ProductsProposalRowsLoader method extractProductProposalPrice.
private ProductProposalPrice extractProductProposalPrice(final I_M_ProductPrice record) {
final PriceListVersionId priceListVersionId = PriceListVersionId.ofRepoId(record.getM_PriceList_Version_ID());
final Amount priceListPrice = Amount.of(record.getPriceStd(), getCurrencyCode(priceListVersionId));
final ProductId productId = ProductId.ofRepoId(record.getM_Product_ID());
final ProductProposalCampaignPrice campaignPrice = campaignPriceProvider.getCampaignPrice(productId).orElse(null);
return ProductProposalPrice.builder().priceListPrice(priceListPrice).campaignPrice(campaignPrice).build();
}
Aggregations