Search in sources :

Example 1 with ProductAndCategoryAndManufacturerId

use of de.metas.product.ProductAndCategoryAndManufacturerId 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();
}
Also used : ProductAndCategoryAndManufacturerId(de.metas.product.ProductAndCategoryAndManufacturerId) AttributeSetInstanceId(org.adempiere.mm.attributes.AttributeSetInstanceId) ImmutableAttributeSet(org.adempiere.mm.attributes.api.ImmutableAttributeSet) IProductDAO(de.metas.product.IProductDAO) ProductId(de.metas.product.ProductId) BigDecimal(java.math.BigDecimal) IAttributeDAO(org.adempiere.mm.attributes.api.IAttributeDAO)

Example 2 with ProductAndCategoryAndManufacturerId

use of de.metas.product.ProductAndCategoryAndManufacturerId in project metasfresh-webui-api by metasfresh.

the class ProductPricingConditionsViewFactory method createPricingConditionsRowData.

@Override
protected PricingConditionsRowData createPricingConditionsRowData(final CreateViewRequest request) {
    final Set<ProductId> productIds = ProductId.ofRepoIds(request.getFilterOnlyIds());
    Check.assumeNotEmpty(productIds, "productIds is not empty");
    final IProductDAO productsRepo = Services.get(IProductDAO.class);
    final Set<ProductAndCategoryAndManufacturerId> products = productsRepo.retrieveProductAndCategoryAndManufacturersByProductIds(productIds);
    return preparePricingConditionsRowData().pricingConditionsBreaksExtractor(pricingConditions -> pricingConditions.streamBreaksMatchingAnyOfProducts(products)).basePricingSystemPriceCalculator(this::calculateBasePricingSystemPrice).load();
}
Also used : ProductAndCategoryAndManufacturerId(de.metas.product.ProductAndCategoryAndManufacturerId) IProductDAO(de.metas.product.IProductDAO) ProductId(de.metas.product.ProductId)

Aggregations

IProductDAO (de.metas.product.IProductDAO)2 ProductAndCategoryAndManufacturerId (de.metas.product.ProductAndCategoryAndManufacturerId)2 ProductId (de.metas.product.ProductId)2 BigDecimal (java.math.BigDecimal)1 AttributeSetInstanceId (org.adempiere.mm.attributes.AttributeSetInstanceId)1 IAttributeDAO (org.adempiere.mm.attributes.api.IAttributeDAO)1 ImmutableAttributeSet (org.adempiere.mm.attributes.api.ImmutableAttributeSet)1