use of de.metas.product.IProductDAO 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.IProductDAO in project metasfresh-webui-api by metasfresh.
the class OrderLinePricingConditionsViewFactory method createSourceDocumentLine.
private final SourceDocumentLine createSourceDocumentLine(@NonNull final I_C_OrderLine orderLineRecord, @NonNull final SOTrx soTrx) {
final IProductDAO productsRepo = Services.get(IProductDAO.class);
final ProductId productId = ProductId.ofRepoId(orderLineRecord.getM_Product_ID());
final ProductCategoryId productCategoryId = productsRepo.retrieveProductCategoryByProductId(productId);
final Money priceEntered = Money.of(orderLineRecord.getPriceEntered(), CurrencyId.ofRepoId(orderLineRecord.getC_Currency_ID()));
return SourceDocumentLine.builder().orderLineId(OrderLineId.ofRepoIdOrNull(orderLineRecord.getC_OrderLine_ID())).soTrx(soTrx).bpartnerId(BPartnerId.ofRepoId(orderLineRecord.getC_BPartner_ID())).productId(productId).productCategoryId(productCategoryId).priceEntered(priceEntered).discount(Percent.of(orderLineRecord.getDiscount())).paymentTermId(PaymentTermId.ofRepoIdOrNull(orderLineRecord.getC_PaymentTerm_Override_ID())).pricingConditionsBreakId(PricingConditionsBreakId.ofOrNull(orderLineRecord.getM_DiscountSchema_ID(), orderLineRecord.getM_DiscountSchemaBreak_ID())).build();
}
use of de.metas.product.IProductDAO 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();
}
Aggregations